public void doMove(Collection paths) {
   Iterator i = paths.iterator();
   while (i.hasNext()) {
     TreePath path = (TreePath) i.next();
     LazyTreeNode draggedNode = (LazyTreeNode) path.getLastPathComponent();
     LazyTreeNode draggedNodeParent = (LazyTreeNode) draggedNode.getParent();
     Cls draggedCls = (Cls) draggedNode.getUserObject();
     Cls draggedClsParent = (Cls) draggedNodeParent.getUserObject();
     if (draggedCls instanceof OWLNamedClass) {
       OWLNamedClass namedClass = (OWLNamedClass) draggedCls;
       if (namedClass.isDefinedClass()) {
         for (Iterator it = namedClass.getEquivalentClasses().iterator(); it.hasNext(); ) {
           RDFSClass equi = (RDFSClass) it.next();
           if (equi instanceof OWLIntersectionClass) {
             if (((OWLIntersectionClass) equi)
                 .hasOperandWithBrowserText(draggedClsParent.getBrowserText())) {
               return;
             }
           }
         }
       }
     }
     draggedCls.removeDirectSuperclass(draggedClsParent);
   }
 }
  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);
    }
  }
 public void testSystemResources() {
   OWLNamedClass cls = owlModel.createOWLNamedClass("Class");
   assertTrue(cls.canAs(OWLNamedClass.class));
   assertTrue(cls.canAs(RDFSNamedClass.class));
   assertTrue(cls.canAs(RDFResource.class));
   assertFalse(cls.canAs(OWLAnonymousClass.class));
   assertFalse(cls.canAs(OWLObjectProperty.class));
   assertTrue(cls.as(RDFSNamedClass.class) instanceof OWLNamedClass);
 }
Beispiel #4
0
  public boolean processTask(int taskId) {

    String s = (String) data_vec.elementAt(taskId);

    super.print("processing: " + s);

    try {

      Vector<String> w = getTokenStr(s, 9);
      String name = (String) w.elementAt(0);

      if (super.checkNoErrors(w, taskId)) {
        // ok
      } else {
        return false;
      }

      String edit = (String) w.elementAt(1);

      String attribute = (String) w.elementAt(2);

      String attributeName = (String) w.elementAt(3);

      String attributeValue = (String) w.elementAt(4);

      String newAttributeValue = (String) w.elementAt(5);

      owlModel.beginTransaction("BatchEdit. Processing " + s);

      // this should be false???
      boolean retval = false;
      if (edit.compareToIgnoreCase("new") == 0) {
        if (attribute.compareToIgnoreCase("property") == 0) {
          if (attributeName.compareToIgnoreCase(NCIEditTab.ALTLABEL) == 0) {
            OWLNamedClass hostClass = wrapper.getOWLNamedClass(name);
            retval =
                wrapper.addAnnotationProperty(
                    hostClass,
                    NCIEditTab.ALTLABEL,
                    owlModel.createRDFSLiteral(
                        attributeValue, owlModel.getSystemFrames().getXmlLiteralType()));
          } else {
            retval = wrapper.addAnnotationProperty(name, attributeName, attributeValue);
          }

        } else if (attribute.compareToIgnoreCase("parent") == 0) {
          OWLNamedClass hostClass = wrapper.getOWLNamedClass(name);
          OWLNamedClass targetClass = wrapper.getOWLNamedClass(attributeName);
          retval = wrapper.addDirectSuperclass(hostClass, targetClass);
        } else if (attribute.compareToIgnoreCase("association") == 0) {
          OWLNamedClass hostClass = wrapper.getOWLNamedClass(name);
          retval = wrapper.addObjectProperty(hostClass, attributeName, attributeValue);
        } else if (attribute.compareToIgnoreCase("role") == 0) {
          int pos = attributeValue.indexOf('|');
          String modifier = attributeValue.substring(0, pos);
          String value = attributeValue.substring(pos + 1);
          retval = wrapper.addRestriction(name, attributeName, value, modifier);
        }
      } else if (edit.compareToIgnoreCase("delete") == 0) {
        if (attribute.compareToIgnoreCase("property") == 0) {
          retval = wrapper.removeAnnotationProperty(name, attributeName, attributeValue);
        } else if (attribute.compareToIgnoreCase("parent") == 0) {
          OWLNamedClass hostClass = wrapper.getOWLNamedClass(name);
          OWLNamedClass targetClass = wrapper.getOWLNamedClass(attributeName);

          RDFSClass definition = hostClass.getDefinition();
          if (definition == null) {
            retval = wrapper.removeDirectSuperclass(hostClass, targetClass);
          } else {
            retval = wrapper.removeEquivalentDefinitionNew(hostClass, targetClass);
          }

        } else if (attribute.compareToIgnoreCase("association") == 0) {
          OWLNamedClass hostClass = wrapper.getOWLNamedClass(name);
          retval = wrapper.removeObjectProperty(hostClass, attributeName, attributeValue);
        } else if (attribute.compareToIgnoreCase("role") == 0) {
          int pos = attributeValue.indexOf('|');
          String modifier = attributeValue.substring(0, pos);
          String value = attributeValue.substring(pos + 1);
          retval = wrapper.removeRestriction(name, attributeName, value, modifier);
        }
      } else if (edit.compareToIgnoreCase("edit") == 0) {
        if (attribute.compareToIgnoreCase("property") == 0) {

          retval =
              wrapper.modifyAnnotationProperty(
                  name, attributeName, attributeValue, newAttributeValue);
          possiblySyncPreferredTerm(name, attributeName, newAttributeValue);

        } else if (attribute.compareToIgnoreCase("role") == 0) {
          int pos = attributeValue.indexOf('|');
          String modifier = attributeValue.substring(0, pos);
          String value = attributeValue.substring(pos + 1);

          pos = newAttributeValue.indexOf('|');
          String newmodifier = newAttributeValue.substring(0, pos);
          String newvalue = newAttributeValue.substring(pos + 1);

          retval =
              wrapper.modifyRestriction(
                  name, attributeName, value, modifier, newvalue, newmodifier);
        } else if (attribute.compareToIgnoreCase("association") == 0) {
          OWLNamedClass hostClass = wrapper.getOWLNamedClass(name);

          retval = wrapper.removeObjectProperty(hostClass, attributeName, attributeValue);
          retval = wrapper.addObjectProperty(hostClass, attributeName, newAttributeValue);
        }
      }

      // to be implemented
      /*
       * else if (edit.compareToIgnoreCase("delete-all") == 0) { }
       */

      if (retval) {
        tab.recordHistory(NCIEditTab.EVSHistoryAction.MODIFY, wrapper.getOWLNamedClass(name), "");
        super.print("\t Done.");
      } else {
        super.print("\t Failed.");
      }
      owlModel.commitTransaction();

    } catch (Exception ex) {

      owlModel.rollbackTransaction();
      print("Server Error occurred:");
      ex.printStackTrace();
      super.print(" Failed.");
      data_vec.remove(taskId);
      this.setMax(max - 1);
      return false;
    }

    return true;
  }
 private void loadOwlOntology() {
   this.owlModel = ontoHandler.getOWLModel();
   OWLNamedClass startClass = owlModel.getOWLNamedClass("XCLOntology:specificationPropertyNames");
   log.debug("loaded ontology." + startClass.getPrefixedName());
 }
    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;
    }