private void refreshList() {
   OWLModel owlModel = ((ImportWizard) getWizard()).getOWLModel();
   Collection availOntologies = new LinkedHashSet();
   for (Iterator it = owlModel.getRepositoryManager().getProjectRepositories().iterator();
       it.hasNext(); ) {
     Repository rep = (Repository) it.next();
     availOntologies.addAll(new TreeSet(rep.getOntologies()));
   }
   for (Iterator it = owlModel.getRepositoryManager().getGlobalRepositories().iterator();
       it.hasNext(); ) {
     Repository rep = (Repository) it.next();
     availOntologies.addAll(new TreeSet(rep.getOntologies()));
   }
   Collection importedOntologies = owlModel.getAllImports();
   for (Iterator it = availOntologies.iterator(); it.hasNext(); ) {
     URI uri = (URI) it.next();
     if (importedOntologies.contains(uri.toString())) {
       it.remove();
     }
   }
   try {
     availOntologies.remove(new URI(owlModel.getDefaultOWLOntology().getURI()));
   } catch (URISyntaxException e) {
     System.err.print(e.getMessage());
   }
   list.setListData(availOntologies.toArray());
 }
  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);
    }
  }
示例#3
0
 /*
  * WARNING!
  *    See OWLModel.getProtegeReadOnlyProperty javadoc for explanation of protege:readOnly property.
  */
 @Override
 public boolean isCellEditable(int rowIndex, int columnIndex) {
   RDFProperty property = getPredicate(rowIndex);
   if (!allowReadOnlyEdit && property.isReadOnly()) {
     return false;
   }
   if (columnIndex != COL_PROPERTY) {
     if (columnIndex == COL_VALUE) {
       Object value = getValue(rowIndex);
       for (Iterator<AnnotationsWidgetPlugin> it = TriplesComponent.plugins(); it.hasNext(); ) {
         AnnotationsWidgetPlugin plugin = it.next();
         if (plugin.canEdit(subject, property, value)) {
           return false;
         }
       }
       OWLModel owlModel = property.getOWLModel();
       if (!owlModel.getTripleStoreModel().isActiveTriple(subject, property, value)) {
         return false;
       } else if (getDefaultProperties().contains(property) && value == null) {
         return true;
       } else {
         return property instanceof OWLDatatypeProperty
             || (property.isAnnotationProperty() && !(value instanceof Instance));
       }
     } else if (isTypeColumn(columnIndex)) {
       return getValueAt(rowIndex, columnIndex) instanceof RDFSDatatype;
     } else {
       return property.getOWLModel().getXSDstring().equals(property.getRange())
           && !property.isReadOnly();
     }
   } else {
     return false;
   }
 }
  private void disableProtegeOntology() {
    if (OWLUtil.confirmSaveAndReload(owlModel.getProject())) {
      owlModel.getDefaultOWLOntology().removeImports(ProtegeNames.PROTEGE_OWL_ONTOLOGY);
      OWLUtil.saveAndReloadProject();
    }

    userDatatypesCBox.setSelected(false);
    userDatatypesCBox.setEnabled(false);
  }
示例#5
0
 private void setPrefixOfNamespace(String namespace, String value) {
   OWLModel owlModel = ontology.getOWLModel();
   try {
     owlModel.beginTransaction(
         "Change prefix of " + namespace + " to " + value, ontology.getName());
     owlModel.getNamespaceManager().setPrefix(namespace, value);
     owlModel.commitTransaction();
   } catch (Exception ex) {
     owlModel.rollbackTransaction();
     OWLUI.handleError(owlModel, ex);
   }
 }
示例#6
0
 public Object setValue(Object aValue, int row) {
   RDFProperty property = getPredicate(row);
   Object oldValue = getValue(row);
   if (oldValue == null || !oldValue.equals(aValue)) {
     try {
       Object newValue;
       String str = aValue.toString();
       OWLModel owlModel = property.getOWLModel();
       if (owlModel.getOWLOntologyProperties().contains(property)) {
         String message = str + " is not a valid URI.";
         try {
           new URI(str);
         } catch (Exception ex) {
           ProtegeUI.getModalDialogFactory().showErrorMessageDialog(owlModel, message);
           return oldValue;
         }
         if (!str.startsWith("http://") && !str.startsWith("file:")) {
           ProtegeUI.getModalDialogFactory().showErrorMessageDialog(owlModel, message);
           return oldValue;
         }
       }
       String lang = getLanguage(row);
       if (aValue instanceof RDFSLiteral && ((RDFSLiteral) aValue).getLanguage() != null) {
         newValue = aValue;
       } else if (lang != null) {
         newValue = createNewValue(property, str, lang);
       } else if (oldValue instanceof RDFSLiteral) {
         RDFSLiteral oldLiteral = (RDFSLiteral) oldValue;
         newValue = getOWLModel().createRDFSLiteral(str, oldLiteral.getDatatype());
       } else if (oldValue instanceof Boolean) {
         newValue = Boolean.valueOf(str.equals("true"));
       } else if (oldValue instanceof Float) {
         newValue = Float.valueOf(str);
       } else if (oldValue instanceof Integer) {
         newValue = Integer.valueOf(str);
       } else {
         newValue = str;
       }
       if (!subject.getPropertyValues(property).contains(newValue)) {
         if (oldValue != null) {
           subject.removePropertyValue(property, oldValue);
         }
         subject.addPropertyValue(property, newValue);
       }
       return newValue;
     } catch (NumberFormatException ex) {
       // Ignore illegal number format
     }
   }
   return oldValue;
 }
示例#7
0
 public void testGetProject() {
   if (!Server_Test.isServerRunning()) {
     return;
   }
   Project p =
       RemoteProjectManager.getInstance()
           .getProject(Server_Test.HOST, USER, PASSWORD, PROJECT_NAME, true);
   assertNotNull(p);
   OWLModel kb = (OWLModel) p.getKnowledgeBase();
   Cls cls = kb.getOWLNamedClass(kb.getNamespaceManager().getDefaultNamespace() + "Pizza");
   Log.getLogger().info("found " + cls + " with frame id = " + cls.getFrameID());
   assertNotNull(cls);
   p.dispose();
 }
 private void addRepository() {
   JComponent c = null;
   if (SwingUtilities.getRoot(this) instanceof JFrame) {
     c = this;
   }
   OWLModel owlModel = ((ImportWizard) getWizard()).getOWLModel();
   RepositoryWizard wizard = new RepositoryWizard(c, owlModel);
   if (wizard.execute() == Wizard.RESULT_FINISH) {
     Repository rep = wizard.getRepository();
     if (rep != null) {
       owlModel.getRepositoryManager().addProjectRepository(0, rep);
       refreshList();
     }
   }
 }
 private void enableProtegeOntology() {
   if (!owlModel.isProtegeMetaOntologyImported()) {
     ImportHelper importHelper = new ImportHelper((JenaOWLModel) owlModel);
     try {
       URI uri = new URI(ProtegeNames.PROTEGE_OWL_ONTOLOGY);
       importHelper.addImport(uri);
       importHelper.importOntologies();
       owlModel
           .getNamespaceManager()
           .setPrefix(ProtegeNames.PROTEGE_OWL_NAMESPACE, ProtegeNames.PROTEGE_PREFIX);
       userDatatypesCBox.setEnabled(true);
     } catch (Exception e) {
       ProtegeUI.getModalDialogFactory().showErrorMessageDialog(owlModel, e.getMessage());
     }
   }
 }
示例#10
0
 /*
  * Returns the process:components value for a Control Construct. If it is
  * null, it will be set to list:nil, and this will be returned.
  */
 private OWLIndividual getComponents(OWLIndividual inst) {
   OWLIndividual components =
       (OWLIndividual) OWLUtils.getNamedSlotValue(inst, "process:components", okb);
   if (components == null) {
     components = okb.getOWLIndividual("list:nil");
     OWLUtils.setNamedSlotValue(inst, "process:components", components, okb);
   }
   return components;
 }
示例#11
0
 private RDFResource getMetadataOnt() {
   RDFResource result = null;
   try {
     URI metaURI = new URI(ProtegeNames.PROTEGE_OWL_ONTOLOGY);
     result = owlModel.getOWLOntologyByURI(metaURI);
   } catch (URISyntaxException e) {
     Log.getLogger().log(Level.SEVERE, "Exception caught", e);
   }
   return result;
 }
示例#12
0
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
   SWRLImp imp = getImp(rowIndex);
   if (columnIndex == COL_EXPRESSION) {
     String text = (String) aValue;
     try {
       imp.setExpression(text);
       if (!isSuitable(imp)) {
         ProtegeUI.getModalDialogFactory()
             .showMessageDialog(
                 owlModel,
                 "The replacing rule no longer fits the selection\n"
                     + "criteria of this rules list, and will therefore no\n"
                     + "longer be visible here.  But no reason to panic: It\n"
                     + "should still show up on the SWRL tab.");
       }
     } catch (Exception ex) {
       Log.getLogger().warning("Exception caught defining rule " + ex);
     }
   } else if (columnIndex == COL_NAME) {
     String newName = (String) aValue;
     if (owlModel.isValidResourceName(newName, imp)) {
       RDFResource resource = owlModel.getRDFResource(newName);
       if (resource != null) {
         if (!imp.equals(resource)) {
           ProtegeUI.getModalDialogFactory()
               .showErrorMessageDialog(
                   owlModel, "The name " + newName + " is already used in this ontology.");
         }
       } else {
         imp = (SWRLImp) imp.rename(newName);
         setImp(rowIndex, imp);
       }
     } else
       ProtegeUI.getModalDialogFactory()
           .showErrorMessageDialog(owlModel, newName + " is not a valid rule name.");
   } else if (columnIndex == COL_ENABLED) {
     Boolean enabled = (Boolean) aValue;
     if (enabled.booleanValue()) imp.enable();
     else imp.disable();
   } // if
 } // setValueAt
示例#13
0
 public boolean equalsStructurally(RDFObject object) {
   if (object instanceof RDFList) {
     RDFList list = (RDFList) object;
     if (getValues().size() == list.getValues().size()) {
       Iterator it = getValues().iterator();
       for (Iterator listIt = list.getValues().iterator(); listIt.hasNext(); ) {
         OWLModel model = getOWLModel();
         RDFObject curListObj = model.asRDFObject(listIt.next());
         RDFObject curThisObj = model.asRDFObject(it.next());
         if (curListObj != null && curThisObj != null) {
           if (curListObj.equalsStructurally(curThisObj) == false) {
             return false;
           }
         } else {
           if (curListObj != curThisObj) {
             return false;
           }
         }
       }
       return true;
     }
   }
   return false;
 }
  private void addProperty() {
    Collection oldValues = ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView();
    Collection properties = owlModel.getRDFProperties();
    for (Iterator it = properties.iterator(); it.hasNext(); ) {
      RDFProperty property = (RDFProperty) it.next();
      if (oldValues.contains(property)
          || (((Slot) property).getValueType() != ValueType.STRING
              && !property.isAnnotationProperty())) {
        it.remove();
      }
    }

    Collection neo = new HashSet(oldValues);
    neo.addAll(
        ProtegeUI.getSelectionDialogFactory()
            .selectResourcesFromCollection(this, owlModel, properties, "Add properties..."));
    ((AbstractOWLModel) owlModel).setDefaultAnnotationPropertiesInView(neo);
    list.setListData(
        ((AbstractOWLModel) owlModel).getDefaultAnnotationPropertiesInView().toArray());
  }
示例#15
0
  public O2WXSLTDialog(
      OWLModel okb, OWLIndividual aP, String wsdl, String wsdlM, OWLIndividual owlInst)
      throws XSLTException {
    super(okb, wsdl);
    atomicProcess = aP;
    wsdlmessageuri = wsdlM;
    m_owlInst = owlInst;
    // Do some sanity checking
    if (wsdl == null) throw new XSLTException("No WSDL document defined.");
    if (wsdlM == null) throw new XSLTException("No WSDL Input Message defined.");
    OWLDatatypeProperty wsdlMessagePartProp =
        okb.getOWLDatatypeProperty("grounding:wsdlMessagePart");
    RDFSLiteral wsdlpart = (RDFSLiteral) owlInst.getPropertyValue(wsdlMessagePartProp);
    if (wsdlpart == null) throw new XSLTException("No WSDL Input Message Part defined.");
    wsdlparturi = wsdlpart.getString();
    if (wsdlparturi == null) throw new XSLTException("No WSDL Input Message Part defined.");
    wsdlInputMessage = getWsdlMessage(wsdlM);
    if (wsdlInputMessage == null)
      throw new XSLTException("WSDL Input Message " + wsdlM + " not found.");
    // WSDL4J sucks. It expects just the local part of the message part uri.
    wsdlInputMessagePart =
        wsdlInputMessage.getPart(wsdlparturi.substring(wsdlparturi.indexOf('#') + 1));
    if (wsdlInputMessagePart == null)
      throw new XSLTException("WSDL Input Message Part " + wsdlparturi + " not found.");

    prepareTree();
    setupGUI();
    Collection inputs = generateParameterNameList(generateParameterList());
    createTranslationPanel();
    O2WParameterPanel pp = (O2WParameterPanel) transPanel;
    pp.getAttributePanel().addParameters(inputs);
    pp.getDataPanel().addParameters(inputs);
    pp.getVariablePanel().addParameters(inputs);
    tree.addTreeSelectionListener((O2WParameterPanel) transPanel);
    tree.addTreeSelectionListener(this);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(new XMLTreeRenderer());
  }
示例#16
0
  /**
   * Returns the OWLSTree associated with a given composite process. If there is no tree, one will
   * be created (that is the whole beauty of this class).
   *
   * @param process
   * @param listener
   * @return
   */
  public OWLSTree getTree(OWLIndividual process, GraphUpdateManager mgr) {
    OWLSTree tree = (OWLSTree) process2tree.get(process);
    if (tree == null) {
      /*
       * We have no model for this process, so we create one and add a
       * mapping for it
       */
      // System.out.println("OWLSTreeMapper.getTree, creating tree for " +
      // process.getName());

      tree = createTree(process, mgr);
      tree.expandAll(); // Newly created trees are always fully expanded.
      DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
      // model.addTreeModelListener(tree);
      addMapping(process, tree);
    } else {
      Vector extraConstructs = (Vector) okb.getClientInformation(generateKey(process));
      if (extraConstructs != null) {
        // There are extra constructs stored in the project file, so we
        // have
        // to add those to the model

        System.out.println("Process " + process + " has extra constructs.");

        DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
        OWLSTreeNode root = (OWLSTreeNode) model.getRoot();
        for (Enumeration e = extraConstructs.elements(); e.hasMoreElements(); ) {
          OWLIndividual construct = (OWLIndividual) e.nextElement();
          OWLSTreeNodeInfo ni = new OWLSTreeNodeInfo(construct, okb);
          OWLSTreeNode newnode = OWLSTreeNodeFactory.createTreeNode(ni);
          System.out.println("Looking at " + newnode);
          model.insertNodeInto(newnode, root, root.getChildCount());
        }
      }
    }
    tree.setSelectedCompositeProcess(process);
    return tree;
  }
示例#17
0
 public void dispose() {
   owlModel.getRDFSNamedClass(SWRLNames.Cls.IMP).removeClassListener(clsListener);
   ((KnowledgeBase) owlModel).removeKnowledgeBaseListener(kbListener);
 }
示例#18
0
  public Vector<String> validateData(Vector<String> v) {

    // keep a vector or error messages, may be more than one
    Vector<String> w = new Vector<String>();

    try {

      String cls_name = (String) v.elementAt(0);
      String action = (String) v.elementAt(1);
      String attribute = (String) v.elementAt(2);
      String attributename = (String) v.elementAt(3);
      String attributevalue_1 = (String) v.elementAt(4);
      String attributevalue_2 = (String) v.elementAt(5);

      OWLNamedClass hostClass = wrapper.getOWLNamedClass(cls_name);

      Vector superclasses = new Vector();
      if (hostClass == null) {
        String error_msg = " -- concept " + cls_name + " does not exist.";
        w.add(error_msg);

      } else if (wrapper.isRetired(hostClass)) {
        w.add(" -- concept " + cls_name + " is retired, cannot edit");
      }

      if (action.compareToIgnoreCase("new") != 0
          && action.compareToIgnoreCase("edit") != 0
          && action.compareToIgnoreCase("delete") != 0) {
        String error_msg = " -- action " + action + " is not supported.";
        w.add(error_msg);
      }

      if (attribute.compareToIgnoreCase("parent") != 0
          && attribute.compareToIgnoreCase("role") != 0
          && attribute.compareToIgnoreCase("property") != 0
          && attribute.compareToIgnoreCase("association") != 0) {
        String error_msg = " -- attribute " + attribute + " is not supported.";
        w.add(error_msg);
      }

      if (action.compareToIgnoreCase("new") == 0) {
        if (hostClass != null) {
          if (attribute.compareToIgnoreCase("role") == 0) {
            if (!supportedRoles.contains(attributename)) {
              String error_msg = " -- role " + attributename + " is not identifiable.";
              w.add(error_msg);
            } else {
              int pos = attributevalue_1.indexOf("|");
              if (pos == -1) {
                String error_msg = " -- missing modifier or filler.";
                w.add(error_msg);
              } else {
                String filler = attributevalue_1.substring(pos + 1, attributevalue_1.length());

                OWLNamedClass targetClass = (OWLNamedClass) owlModel.getRDFSNamedClass(filler);
                if (targetClass == null) {
                  String error_msg = " -- concept " + filler + " does not exist.";
                  w.add(error_msg);
                } else {
                  if (wrapper.hasRole(hostClass, attributename, filler)) {
                    String error_msg = " -- role already exists.";
                    w.add(error_msg);
                  }
                }
              }
            }
          } else if (attribute.compareToIgnoreCase("parent") == 0) {

            OWLNamedClass superClass = (OWLNamedClass) owlModel.getRDFSNamedClass(attributename);
            if (superClass == null) {
              String error_msg = " -- superconcept does not exist.";
              w.add(error_msg);

            } else {

              if (wrapper.isPremerged(superClass)
                  || wrapper.isPreretired(superClass)
                  || wrapper.isRetired(superClass)) {
                String error_msg = "superconcept cannot be premerged, preretired, or retired.";
                w.add(error_msg);
              }
            }

          } else if (attribute.compareToIgnoreCase("property") == 0) {
            if (!supportedProperties.contains(attributename)) {
              String error_msg = " -- property " + attributename + " is not identifiable.";
              w.add(error_msg);
            } else {
              if (wrapper.hasProperty(hostClass, attributename, attributevalue_1)) {
                String error_msg = " -- property already exists.";
                w.add(error_msg);
              }
            }
            if (this.tab.getFilter().checkBatchProperty(attributename, attributevalue_1)
                && this.tab
                    .getFilter()
                    .checkBatchPropertyNotFullSynPT(attributename, attributevalue_1)) {

            } else {
              w.add(tab.getFilter().getErrorMessage());
            }
          } else if (attribute.compareToIgnoreCase("association") == 0) {
            if (!supportedAssociations.contains(attributename)) {
              String error_msg = " -- association " + attributename + " is not identifiable.";
              w.add(error_msg);
            } else {
              OWLNamedClass targetClass =
                  (OWLNamedClass) owlModel.getRDFSNamedClass(attributevalue_1);
              if (targetClass == null) {
                String error_msg = " -- concept " + attributevalue_1 + " does not exist.";
                w.add(error_msg);
              } else {
                if (wrapper.hasAssociation(hostClass, attributename, attributevalue_1)) {
                  String error_msg = " -- association already exists.";
                  w.add(error_msg);
                }
              }
            }
          }
        }
      } else if (action.compareToIgnoreCase("edit") == 0
          || action.compareToIgnoreCase("delete") == 0) {
        if (hostClass != null) {
          if (attribute.compareToIgnoreCase("parent") == 0) {
            if (action.compareToIgnoreCase("delete") == 0) {
              OWLNamedClass superClass = (OWLNamedClass) owlModel.getRDFSNamedClass(attributename);
              if (superClass == null) {
                String error_msg = " -- superconcept " + attributename + " does not exist.";
                w.add(error_msg);
              } else if (wrapper.getDirectSuperclassNames(hostClass).size() == 1) {
                String error_msg = " -- can't delete last superconcept " + attributename;
                w.add(error_msg);
              }

            } else {
              String error_msg =
                  " -- edit parent action is not supported. Use delete and add actions instead.";
              w.add(error_msg);
            }
          } else if (attribute.compareTo("role") == 0) {
            if (!supportedRoles.contains(attributename)) {
              String error_msg = " -- role " + attributename + " is not identifiable.";
              w.add(error_msg);
            } else {
              int pos = attributevalue_1.indexOf("|");
              if (pos == -1) {
                String error_msg = " -- missing modifier or filler.";
                w.add(error_msg);
              } else {
                String filler = attributevalue_1.substring(pos + 1, attributevalue_1.length());

                OWLNamedClass targetClass = (OWLNamedClass) owlModel.getRDFSNamedClass(filler);
                if (targetClass == null) {
                  String error_msg = " -- concept " + filler + " does not exist.";
                  w.add(error_msg);
                } else {
                  if (!wrapper.hasRole(hostClass, attributename, filler)) {
                    String error_msg = " -- role does not exist.";
                    w.add(error_msg);
                  }

                  if (action.compareTo("edit") == 0) {
                    pos = attributevalue_2.indexOf("|");
                    if (pos == -1) {
                      String error_msg = " -- missing modifier or filler.";
                      w.add(error_msg);
                    } else {
                      filler = attributevalue_2.substring(pos + 1, attributevalue_2.length());

                      targetClass = (OWLNamedClass) owlModel.getRDFSNamedClass(filler);
                      if (targetClass == null) {
                        String error_msg = " -- concept " + filler + " does not exist.";
                        w.add(error_msg);
                      }
                    }
                  }
                }
              }
            }
          } else if (attribute.compareToIgnoreCase("property") == 0) {
            if (!supportedProperties.contains(attributename)) {
              String error_msg = " -- property " + attributename + " is not identifiable.";
              w.add(error_msg);
            } else {
              Boolean editable = wrapper.isReadOnlyProperty(attributename);
              if (editable.equals(Boolean.TRUE)) {
                String error_msg = " -- property " + attributename + ", it is read-only.";
                w.add(error_msg);
              }

              if (!wrapper.hasProperty(hostClass, attributename, attributevalue_1)) {

                String error_msg =
                    " -- property "
                        + "("
                        + attributename
                        + ", "
                        + attributevalue_1
                        + ") does not exist.";
                w.add(error_msg);
              }

              if (action.compareToIgnoreCase("edit") == 0) {
                if (wrapper.hasProperty(hostClass, attributename, attributevalue_2)) {
                  String error_msg =
                      " -- property "
                          + "("
                          + attributename
                          + ", "
                          + attributevalue_2
                          + ") already exists.";
                  w.add(error_msg);
                } else if (attributevalue_2.equalsIgnoreCase("NA")) {
                  String error_msg =
                      " -- property " + "(" + attributename + ") new value is not specified.";
                  w.add(error_msg);
                } else if (this.tab.getFilter().checkBatchProperty(attributename, attributevalue_2)
                    && this.tab
                        .getFilter()
                        .checkBatchPropertyNotFullSynPT(attributename, attributevalue_2)) {

                } else {
                  w.add(tab.getFilter().getErrorMessage());
                }
              } else {
                if (this.tab.getFilter().checkBatchProperty(attributename, attributevalue_1)) {

                } else {
                  w.add(tab.getFilter().getErrorMessage());
                }
              }
            }
          } else if (attribute.compareTo("association") == 0) {
            if (!supportedAssociations.contains(attributename)) {
              String error_msg = " -- association " + attributename + " is not identifiable.";
              w.add(error_msg);
            }

            if (action.compareToIgnoreCase("delete") == 0) {
              OWLNamedClass targetClass =
                  (OWLNamedClass) owlModel.getRDFSNamedClass(attributevalue_1);
              if (targetClass == null) {
                String error_msg = " -- concept " + attributevalue_1 + " does not exist.";
                w.add(error_msg);
              } else {
                if (!wrapper.hasAssociation(hostClass, attributename, attributevalue_1)) {
                  String error_msg = " -- association does not exist.";
                  w.add(error_msg);
                }
              }
            } else {
              String error_msg =
                  " -- edit association action is not supported. Use delete and add actions instead.";
              w.add(error_msg);
            }
          }
        }
      }

    } catch (Exception e) {
      Log.getLogger().log(Level.WARNING, "Exception caught", e);
    }

    return w;
  }
示例#19
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();
 }
示例#21
0
 private void initListeners() {
   owlModel.getRDFSNamedClass(SWRLNames.Cls.IMP).addClassListener(clsListener);
   ((KnowledgeBase) owlModel).addKnowledgeBaseListener(kbListener);
 }
示例#22
0
 protected BagOrTreeNode(OWLSTreeNodeInfo ni, String type) {
   super(ni, true);
   this.type = type;
   model = getOWLModel();
   components = model.getOWLObjectProperty("process:components");
 }
 private void loadOwlOntology() {
   this.owlModel = ontoHandler.getOWLModel();
   OWLNamedClass startClass = owlModel.getOWLNamedClass("XCLOntology:specificationPropertyNames");
   log.debug("loaded ontology." + startClass.getPrefixedName());
 }
示例#24
0
 protected Collection<RDFProperty> getRelevantProperties() {
   OWLModel owlModel = subject.getOWLModel();
   return owlModel.getRDFProperties(); // show everything!
 }
示例#25
0
 public static boolean isUserDefinedDatatypesSupported(OWLModel owlModel) {
   return Boolean.TRUE.equals(
       owlModel.getOWLProject().getSettingsMap().getBoolean(USER_DEFINED_DATATYPES));
 }
示例#26
0
 public static void setUserDefinedDatatypesSupported(OWLModel owlModel, boolean value) {
   owlModel
       .getOWLProject()
       .getSettingsMap()
       .setBoolean(USER_DEFINED_DATATYPES, Boolean.valueOf(value));
 }