Package edu.stanford.smi.protegex.owl.model

Examples of edu.stanford.smi.protegex.owl.model.OWLObjectProperty


    this.model = model;
  }

  public void actionPerformed(ActionEvent e) {
    RDFProperty property = OWLUI.pickRDFProperty(model.getUserDefinedOWLObjectProperties(), "Select a property");
    OWLObjectProperty objProperty = (OWLObjectProperty) property;
    if(property != null && property instanceof OWLObjectProperty) {
      tab.addExistentialPanel(objProperty);
    }
  }
View Full Code Here


      Argument argument;
      MultiEntityNode multiEntityNode;

      RDFIndividual individualOne;
      RDFIndividual individualTwo;
      OWLObjectProperty objectProperty;

      OWLNamedClass domainResidentNodePr = this.getOwlModel().getOWLNamedClass(DOMAIN_RESIDENT);
      Collection instances = domainResidentNodePr.getInstances(true);
      MFrag mFragOfNode = null;

      for (Iterator it = instances.iterator(); it.hasNext();) {

        individualOne = (RDFIndividual) it.next();
        domainResidentNode = getMapDomainResidentNode().get(individualOne
            .getBrowserText());
        if (domainResidentNode == null) {
          throw new IOMebnException(
              getResource().getString("DomainResidentNotExistsInMTheory"),
              individualOne.getBrowserText());
        }

        Debug.println("Domain Resident loaded: "
            + individualOne.getBrowserText());

        domainResidentNode.setDescription(getDescription(individualOne));

        /* -> isResidentNodeIn */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("isResidentNodeIn");
        instances = individualOne.getPropertyValues(objectProperty);
        Iterator itAux = instances.iterator();
        individualTwo = (RDFIndividual) itAux.next();
        domainMFrag = getMapDomainMFrag().get(individualTwo.getBrowserText());
        if (domainMFrag.containsDomainResidentNode(domainResidentNode) == false) {
          throw new IOMebnException(
              getResource().getString("DomainResidentNotExistsInDomainMFrag"));
        }
        mFragOfNode = domainMFrag;
        Debug.println("-> " + individualOne.getBrowserText() + ": "
            + objectProperty.getBrowserText() + " = "
            + individualTwo.getBrowserText());

        /* -> hasArgument */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasArgument");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          argument = new Argument(individualTwo.getBrowserText(),
              domainResidentNode);
          domainResidentNode.addArgument(argument);
          getMapArgument().put(individualTwo.getBrowserText(), argument);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasParent */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasParent");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          if (getMapDomainResidentNode().containsKey(individualTwo
              .getBrowserText())) {
            ResidentNode aux = getMapDomainResidentNode().get(individualTwo
                .getBrowserText());

            Edge auxEdge = new Edge(aux, domainResidentNode);
            try {
              mFragOfNode.addEdge(auxEdge);
            } catch (Exception e) {
              Debug.println("Erro: arco invalido!!!");
            }
          } else {
            if (getMapGenerativeInputNode().containsKey(individualTwo
                .getBrowserText())) {
              InputNode aux = getMapGenerativeInputNode()
                  .get(individualTwo.getBrowserText());

              Edge auxEdge = new Edge(aux, domainResidentNode);
              try {
                mFragOfNode.addEdge(auxEdge);
              } catch (Exception e) {
                Debug.println("Erro: arco invalido!!!");
              }

            } else {
              throw new IOMebnException(
                  getResource().getString("NodeNotFound"),
                  individualTwo.getBrowserText());
            }
          }
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasInputInstance */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasInputInstance");
        instances = individualOne.getPropertyValues(objectProperty);

        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          generativeInputNode = getMapGenerativeInputNode().get(individualTwo
              .getBrowserText());
          try {
            generativeInputNode.setInputInstanceOf(domainResidentNode);
          } catch (Exception e) {
            e.printStackTrace();
          }
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> isInnerTermOf */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("isInnerTermOf");
        instances = individualOne.getPropertyValues(objectProperty);
        itAux = instances.iterator();
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          multiEntityNode = getMapMultiEntityNode().get(individualTwo
              .getBrowserText());
          domainResidentNode.addInnerTermFromList(multiEntityNode);
          multiEntityNode.addInnerTermOfList(domainResidentNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasPossibleValues */
        {
          CategoricalStateEntity state = null;
          objectProperty = (OWLObjectProperty) getOwlModel()
              .getOWLObjectProperty("hasPossibleValues");
          instances = individualOne.getPropertyValues(objectProperty);
          itAux = instances.iterator();
          for (Object instance : instances) {
            individualTwo = (RDFIndividual) instance;
            String stateName = individualTwo.getBrowserText();
            /* case 1: booleans states */
            if (stateName.equals("true")) {
              StateLink link = domainResidentNode
                  .addPossibleValueLink(getMebn()
                      .getBooleanStatesEntityContainer()
                      .getTrueStateEntity());
              List<String> globallyObjects = getMapBooleanStateGloballyObjects()
                  .get("true");
              if (globallyObjects.contains(domainResidentNode
                  .getName())) {
                link.setGloballyExclusive(true);
              } else {
                link.setGloballyExclusive(false);
              }
              domainResidentNode
                  .setTypeOfStates(IResidentNode.BOOLEAN_RV_STATES);
            } else {
              if (stateName.equals("false")) {
                StateLink link = domainResidentNode
                    .addPossibleValueLink(getMebn()
                        .getBooleanStatesEntityContainer()
                        .getFalseStateEntity());
                List<String> globallyObjects = getMapBooleanStateGloballyObjects()
                    .get("false");
                if (globallyObjects.contains(domainResidentNode
                    .getName())) {
                  link.setGloballyExclusive(true);
                } else {
                  link.setGloballyExclusive(false);
                }
                domainResidentNode
                    .setTypeOfStates(IResidentNode.BOOLEAN_RV_STATES);
              } else {
                if (stateName.equals("absurd")) {
                  StateLink link = domainResidentNode
                      .addPossibleValueLink(getMebn()
                          .getBooleanStatesEntityContainer()
                          .getAbsurdStateEntity());
                  List<String> globallyObjects = getMapBooleanStateGloballyObjects()
                      .get("absurd");
                  if (globallyObjects.contains(domainResidentNode
                      .getName())) {
                    link.setGloballyExclusive(true);
                  } else {
                    link.setGloballyExclusive(false);
                  }
                  domainResidentNode
                      .setTypeOfStates(IResidentNode.BOOLEAN_RV_STATES);
                } else {
                  if (getMapTypes().get(stateName) != null) {

                    /* case 2:object entities */

                    StateLink link = domainResidentNode
                        .addPossibleValueLink(getMapTypes()
                            .get(stateName));
                    domainResidentNode
                        .setTypeOfStates(IResidentNode.OBJECT_ENTITY);

                  } else {
                    /* case 3: categorical states */
                    try {
                      state = getMebn()
                          .getCategoricalStatesEntityContainer()
                          .getCategoricalState(
                              individualTwo
                                  .getBrowserText());
                      StateLink link = domainResidentNode
                          .addPossibleValueLink(state);

                      List<String> globallyObjects = getMapCategoricalStateGloballyObjects()
                          .get(state.getName());
                      if (globallyObjects
                          .contains(domainResidentNode
                              .getName())) {
                        link.setGloballyExclusive(true);
                      } else {
                        link.setGloballyExclusive(false);
                      }
                      domainResidentNode
                          .setTypeOfStates(IResidentNode.CATEGORY_RV_STATES);
                    } catch (CategoricalStateDoesNotExistException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                    }
                  }

                }
              }
            }
          } /* for */

        }

        /* hasProbDist */

        OWLObjectProperty hasProbDist = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasProbDist");
        OWLDatatypeProperty hasDeclaration = getOwlModel()
            .getOWLDatatypeProperty("hasDeclaration");
        String cpt = null;
        for (Iterator iter = individualOne.getPropertyValues(hasProbDist)
View Full Code Here

      BuiltInRV builtInRV;

      RDFIndividual individualOne;
      RDFIndividual individualTwo;
      OWLNamedClass owlNamedClass;
      OWLObjectProperty objectProperty;

      owlNamedClass = getOwlModel().getOWLNamedClass(DOMAIN_MFRAG);
      Collection instances = owlNamedClass.getInstances(false);

      for (Iterator it = instances.iterator(); it.hasNext();) {
        individualOne = (RDFIndividual) it.next();
        domainMFrag = getMapDomainMFrag().get(individualOne.getBrowserText());
        if (domainMFrag == null) {
          throw new IOMebnException(
              getResource().getString("DomainMFragNotExistsInMTheory"),
              individualOne.getBrowserText());
        }

        Debug.println("DomainMFrag loaded: "
            + individualOne.getBrowserText());

        domainMFrag.setDescription(getDescription(individualOne));

        /* -> hasResidentNode */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasResidentNode");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          Object itInNext = itIn.next();
          if (!(itInNext instanceof RDFIndividual)) {
            try {
              System.err.println(itInNext + " != RDFIndividual");
            } catch (Throwable t) {
              t.printStackTrace();
            }
            continue;
          }
          individualTwo = (RDFIndividual) itInNext;

          // remove prefixes from the name
          String name = individualTwo.getBrowserText();
          if (name.startsWith(SaverPrOwlIO.RESIDENT_NAME_PREFIX)) {
            try {
              name = name.substring(SaverPrOwlIO.RESIDENT_NAME_PREFIX
                  .length());
            } catch (Exception e) {
              // ignore, because we can still try the original name
              e.printStackTrace();
            }
          }

          // instanciate a continuous resident node instead of resident node, if individual is assignable to a continuous node
          if (individualTwo.hasRDFType(getOwlModel().getOWLNamedClass(CONTINUOUS_RESIDENT_NODE), true)) {
            domainResidentNode = new ContinuousResidentNode(name, domainMFrag);
//            try {
//              ((ContinuousResidentNode)domainResidentNode).onAddToMFrag(domainMFrag);
//            } catch (MFragDoesNotExistException e) {
//              e.printStackTrace();
//            }
          } else {
            domainResidentNode = new ResidentNode(name, domainMFrag);
          }
          getMebn().getNamesUsed().add(name);

          domainMFrag.addResidentNode(domainResidentNode);

          // the mappings uses the original names (no prefix removal)
          getMapDomainResidentNode().put(individualTwo.getBrowserText(),
              domainResidentNode);
          getMapMultiEntityNode().put(individualTwo.getBrowserText(),
              domainResidentNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasInputNode */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasInputNode");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          generativeInputNode = new InputNode(
              individualTwo.getBrowserText(), domainMFrag);
          getMebn().getNamesUsed().add(individualTwo.getBrowserText());
          domainMFrag.addInputNode(generativeInputNode);
          getMapGenerativeInputNode().put(individualTwo.getBrowserText(),
              generativeInputNode);
          getMapMultiEntityNode().put(individualTwo.getBrowserText(),
              generativeInputNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasContextNode */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasContextNode");
        instances = individualOne.getPropertyValues(objectProperty);
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          contextNode = new ContextNode(individualTwo.getBrowserText(),
              domainMFrag);
          getMebn().getNamesUsed().add(individualTwo.getBrowserText());
          domainMFrag.addContextNode(contextNode);
          getMapContextNode().put(individualTwo.getBrowserText(), contextNode);
          getMapMultiEntityNode().put(individualTwo.getBrowserText(),
              contextNode);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }

        /* -> hasOVariable */
        objectProperty = (OWLObjectProperty) getOwlModel()
            .getOWLObjectProperty("hasOVariable");
        instances = individualOne.getPropertyValues(objectProperty);
        String ovName = null;
        for (Iterator itIn = instances.iterator(); itIn.hasNext();) {
          individualTwo = (RDFIndividual) itIn.next();
          ovName = individualTwo.getBrowserText(); // Name of the OV
                                // individual
          // Remove MFrag name from ovName. MFrag name is a scope
          // identifier
          try {
            ovName = ovName.split(domainMFrag.getName()
                + this.getOrdinaryVarScopeSeparator())[1];
          } catch (java.lang.ArrayIndexOutOfBoundsException e) {
            // Use the original name...
            ovName = ovName; // If its impossible to split, then no
                      // Scope id was found
          }
          // Debug.println("> Internal OV name is : " + ovName);
          // Create instance of OV w/o scope identifier
          oVariable = new OrdinaryVariable(ovName, getMebn()
              .getTypeContainer().getDefaultType(), domainMFrag);
          domainMFrag.addOrdinaryVariable(oVariable);
          // let's map objects w/ scope identifier included
          getMapOVariable().put(individualTwo.getBrowserText(), oVariable);
          Debug.println("-> " + individualOne.getBrowserText() + ": "
              + objectProperty.getBrowserText() + " = "
              + individualTwo.getBrowserText());
        }
      }
    }
View Full Code Here

          mTheoryIndividual.addComment(getMebn().getDescription());
        }
       
        /* hasMFrag */
       
        OWLObjectProperty hasMFragProperty = (OWLObjectProperty)getOwlModel().getOWLObjectProperty("hasMFrag");  
        List<MFrag> listDomainMFrag = getMebn().getDomainMFragList();
       
        for(MFrag domainMFrag: listDomainMFrag){
          OWLNamedClass domainMFragClass = getOwlModel().getOWLNamedClass(DOMAIN_MFRAG);
          Debug.println("Domain_MFrag = " + domainMFrag.getName());
          // check if individual exists.
          OWLIndividual domainMFragIndividual = getOwlModel().getOWLIndividual(this.MFRAG_NAME_PREFIX + domainMFrag.getName());
          if (domainMFragIndividual == null) {
            // if new, create it
            domainMFragIndividual = domainMFragClass.createOWLIndividual(this.MFRAG_NAME_PREFIX + domainMFrag.getName());
          }
          getMapMFrag().put(domainMFrag, domainMFragIndividual);
          mTheoryIndividual.addPropertyValue(hasMFragProperty, domainMFragIndividual);
         
          if(domainMFrag.getDescription()!=null){
            domainMFragIndividual.addComment(domainMFrag.getDescription());
          }
         
          /* hasResidentNode */
          OWLObjectProperty hasResidentNodeProperty = (OWLObjectProperty)getOwlModel().getOWLObjectProperty("hasResidentNode");  
         
          for(Node node: domainMFrag.getNodeList()){
            if (node instanceof ResidentNode) {
              ResidentNode residentNode = (ResidentNode) node;
             
              Debug.println("Domain_Res = " + residentNode.getName())
              // check if individual exists
              OWLIndividual domainResIndividual = getOwlModel().getOWLIndividual(this.RESIDENT_NAME_PREFIX + residentNode.getName());
              if (domainResIndividual == null) {
                // if new, create it
                OWLNamedClass domainResClass = null;
                if (residentNode instanceof ContinuousResidentNode) {
                  // get owl class for continuous nodes
                  domainResClass = getOwlModel().getOWLNamedClass(CONTINUOUS_RESIDENT_NODE);
                  if (domainResClass == null) {
                    // if CONTINUOUS_RESIDENT_NODE does not exist, create it
                    domainResClass = getOwlModel().createOWLNamedSubclass(CONTINUOUS_RESIDENT_NODE, getOwlModel().getOWLNamedClass(DOMAIN_RESIDENT));
                  }
                } else {
                  // get owl class for resident nodes
                  domainResClass = getOwlModel().getOWLNamedClass(DOMAIN_RESIDENT);
                }
               
                domainResIndividual = domainResClass.createOWLIndividual(this.RESIDENT_NAME_PREFIX + residentNode.getName());
              }
              domainMFragIndividual.addPropertyValue(hasResidentNodeProperty, domainResIndividual);  
              getMapDomainResident().put(residentNode, domainResIndividual);
            }
           
          } 
         
          /* hasInputNode */
          OWLObjectProperty hasInputNodeProperty = (OWLObjectProperty)getOwlModel().getOWLObjectProperty("hasInputNode");  
          OWLNamedClass generativeInputClass = getOwlModel().getOWLNamedClass(GENERATIVE_INPUT);
          for(InputNode inputNode: domainMFrag.getInputNodeList()){
            Debug.println("Generative_input = " + inputNode.getName());
            // check if individuals exists
            OWLIndividual generativeInputIndividual = getOwlModel().getOWLIndividual(inputNode.getName());
            if (generativeInputIndividual == null) {
              // if new, create it
              generativeInputIndividual = generativeInputClass.createOWLIndividual(inputNode.getName());
            }
            domainMFragIndividual.addPropertyValue(hasInputNodeProperty, generativeInputIndividual);    
            getMapGenerativeInput().put(inputNode, generativeInputIndividual);    
          }       
         
          /* hasContextNode */
          OWLObjectProperty hasContextNodeProperty = (OWLObjectProperty)getOwlModel().getOWLObjectProperty("hasContextNode");  
          OWLNamedClass contextClass = getOwlModel().getOWLNamedClass(CONTEXT_NODE);
          for(ContextNode contextNode: domainMFrag.getContextNodeList()){
            // check if individuals exist
            OWLIndividual contextIndividual = getOwlModel().getOWLIndividual(contextNode.getName());
            if (contextIndividual == null) {
              // if new, create it
              contextIndividual = contextClass.createOWLIndividual(contextNode.getName());
            }
            domainMFragIndividual.addPropertyValue(hasContextNodeProperty, contextIndividual);                  
            getMapContext().put(contextNode, contextIndividual);  
          }       
         
          /* hasOVariable */
          OWLObjectProperty hasOVariableProperty = (OWLObjectProperty)getOwlModel().getOWLObjectProperty("hasOVariable");  
            OWLNamedClass oVariableClass = getOwlModel().getOWLNamedClass(ORDINARY_VARIABLE);
          OWLObjectProperty isSubsByProperty = (OWLObjectProperty)getOwlModel().getOWLObjectProperty("isSubsBy");  
         
          for(OrdinaryVariable oVariable: domainMFrag.getOrdinaryVariableList()){
            // Set variable name as "MFragName.OVName"
            OWLIndividual oVariableIndividual = getOwlModel().getOWLIndividual(
                  oVariable.getMFrag().getName() + SCOPE_SEPARATOR
View Full Code Here

    public List<RDFIndividual> getIsSameAs(){
      if(lis_same_asIndividuals==null){
        lis_same_asIndividuals = new ArrayList<RDFIndividual>();   
       
        //object property e.g. http://planetarium.hki.uni-koeln.de/public/XCL/ontology/XCLOntology.owl#is_same_as
      OWLObjectProperty propertyIs_same_as = individual.getOWLModel().getOWLObjectProperty(this.xclOntologyLocation+"#is_same_as");
      try {
        //using the reasoner for resolving the symmetric individual relations
        Iterator<OWLIndividual> it = this.getReasoner().getRelatedIndividuals(convertRDFIndividual(individual), propertyIs_same_as).iterator();
        while(it.hasNext()){
          OWLIndividual sameAsIndividual = it.next();
View Full Code Here

TOP

Related Classes of edu.stanford.smi.protegex.owl.model.OWLObjectProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.