public void possiblySyncPreferredTerm(String cls_name, String name, String value) { if (name.compareTo(NCIEditTab.ALTLABEL) == 0) { String tn = ComplexPropertyParser.getPtNciTermName(value); if (tn != null) { // need to mod preferred name and rdfs:label OWLNamedClass cls = wrapper.getOWLNamedClass(cls_name); String pn = wrapper.getPropertyValue(cls, NCIEditTab.PREFLABEL); String rdl = wrapper.getPropertyValue(cls, "rdfs:label"); wrapper.modifyAnnotationProperty(cls_name, NCIEditTab.PREFLABEL, pn, tn); wrapper.modifyAnnotationProperty(cls_name, "rdfs:label", rdl, tn); } } else if (name.compareTo(NCIEditTab.PREFLABEL) == 0) { OWLNamedClass cls = wrapper.getOWLNamedClass(cls_name); ArrayList<String> pvals = wrapper.getPropertyValues(cls, NCIEditTab.ALTLABEL); for (String s : pvals) { String tn = ComplexPropertyParser.getPtNciTermName(s); if (tn != null) { HashMap<String, String> hm = ComplexPropertyParser.parseXML(s); String newfspt = ComplexPropertyParser.replaceFullSynValue(hm, "term-name", value); wrapper.modifyAnnotationProperty(cls_name, NCIEditTab.ALTLABEL, s, newfspt); } } String rdl = wrapper.getPropertyValue(cls, "rdfs:label"); wrapper.modifyAnnotationProperty(cls_name, "rdfs:label", rdl, value); } }
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; }