コード例 #1
0
  private void loadTree(boolean applyFilter) {

    PropertyDnDTreeBean.filterTreeStringOld = this.getFilterTreeString();
    this.selectedviewOld = this.getSelectedViewItem();

    rootNode = new TreeNodeImpl();

    if (this.selectedview.equals(VIEW_STANDARD)) {
      OWLNamedClass startClass =
          owlModel.getOWLNamedClass("XCLOntology:specificationPropertyNames");
      this.rootNodeName = startClass.getLocalName();
      TreeViews.standardTraverseTree(startClass, new Vector(), rootNode, applyFilter);
    }
    if (this.selectedview.equals(VIEW_ROTHENBERG)) {
      OWLNamedClass startClass = owlModel.getOWLNamedClass("Testbed:RothenbergCategories");
      this.rootNodeName = startClass.getLocalName();
      TreeViews.standardTraverseTree(startClass, new Vector(), rootNode, applyFilter);
      // TreeViews.rothenbergTraverseTree(startClass, new Vector(), rootNode, applyFilter);
    }
    if (this.selectedview.equals(VIEW_TBEXTENDED)) {
      OWLNamedClass startClass = owlModel.getOWLNamedClass("Testbed:TestbedProperties");
      this.rootNodeName = startClass.getLocalName();
      TreeViews.standardTraverseTree(startClass, new Vector(), rootNode, applyFilter);
    }
  }
コード例 #2
0
    public static TreeNode standardTraverseTree(
        OWLNamedClass cl, List stack, TreeNode node, boolean applyfilter) {
      Collection<RDFIndividual> instances = cl.getInstances(false);

      // adding a new category - isn't backed by any data, not even name??
      TreeNode childClass = new TreeNodeImpl();
      String instanceCountText = instances.size() > 0 ? " (" + instances.size() + ")" : "";
      childClass.setData(new DummyOntologyProperty(cl.getLocalName() + instanceCountText));
      // addChild(key, nodeImpl
      node.addChild(cl.getURI(), childClass);

      if (instances.size() > 0) {
        for (Iterator<RDFIndividual> jt = instances.iterator(); jt.hasNext(); ) {
          try {
            RDFIndividual individual = (RDFIndividual) jt.next();
            // OWLIndividual individual = (OWLIndividual) jt.next();
            TreeNode child = new TreeNodeImpl();
            OntologyProperty ontologyProperty = new OntologyPropertyImpl(individual);

            boolean bMatchesFilter = true;
            if (applyfilter) {
              boolean b1 =
                  ontologyProperty.getName().toLowerCase().contains(filterTreeString.toLowerCase());
              boolean b2 =
                  ontologyProperty
                      .getHumanReadableName()
                      .toLowerCase()
                      .contains(filterTreeString.toLowerCase());
              bMatchesFilter = b1 || b2;
            }
            if (bMatchesFilter) {
              child.setData(ontologyProperty);
              childClass.addChild(ontologyProperty.getURI(), child);
            }
          } catch (ClassCastException e) {
            log.debug("Shouldn't happen any more: Filtering out RDFIndividual");
          }
        }
      }
      if (!stack.contains(cl)) {
        for (java.util.Iterator<OWLNamedClass> it = cl.getSubclasses(false).iterator();
            it.hasNext(); ) {
          OWLNamedClass subClass = (OWLNamedClass) it.next();
          stack.add(cl);
          standardTraverseTree(subClass, stack, childClass, applyfilter);
          stack.remove(cl);
        }
      }

      // remove nodes that don't apply the given filter
      if (applyfilter) {
        Iterator it = childClass.getChildren();
        if (it.hasNext()) {
          // ok node still has other leaf elements - keep it
        } else {
          node.removeChild(cl.getURI());
        }
      }

      return node;
    }