예제 #1
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;
  }
 public AllValuesFromRestrictionUpdater(OWLModel owlModel) {
   super(owlModel);
   metaCls = owlModel.getSystemFrames().getOwlAllValuesFromClass();
   valueTypeFacet = owlModel.getSystemFrames().getValueTypeFacet();
 }