Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLNamedIndividual


            return null;
        }

        List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();

        OWLNamedIndividual iSes = __factory.getOWLNamedIndividual(IRI.create(session.getID()));
        additions.add(new AddAxiom(ont, __factory.getOWLClassAssertionAxiom(cSession, iSes)));
        OWLDatatype anyURI = __factory.getOWLDatatype(IRI.create("http://www.w3.org/2001/XMLSchema#anyURI"));
        OWLLiteral hasIdValue = __factory.getOWLTypedLiteral(session.getID().toString(), anyURI);
        additions.add(new AddAxiom(ont, __factory.getOWLDataPropertyAssertionAxiom(hasId, iSes, hasIdValue)));
        mgr.applyChanges(additions);
View Full Code Here


        String recipeDescription = "My comment to the recipe";
        AddRecipe instance = new AddRecipe(load.getStore());
        boolean result = instance.addRecipe(recipeName, rules, recipeDescription);
        OWLOntology newonto = instance.getStore().getOntology();
        if(result){
            OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRecipeNew"));
            int axiom = newonto.getAxioms(ruleind).size();
            assertEquals(8,axiom);
            // TODO review the generated test code and remove the default call to fail.
        }else{
            fail("Some problem occurs with addRecipe of KReSAddRule");
View Full Code Here

        String recipeDescription = "My comment to the recipe";
        AddRecipe instance = new AddRecipe(store);
        boolean result = instance.addSimpleRecipe(recipeName,recipeDescription);
        OWLOntology newonto = instance.getStore().getOntology();
        if(result){
            OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRecipeNew"));
          
            int axiom = newonto.getAxioms(ruleind).size();
            assertEquals(2,axiom);
            // TODO review the generated test code and remove the default call to fail.
        }else{
View Full Code Here

        AddRecipe instance = new AddRecipe(load.getStore());
        boolean result = instance.addRecipe(recipeName, rules, recipeDescription);
        OWLOntology newonto = instance.getStore().getOntology();

        if(result){
            OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRecipeNew"));
            int axiom = newonto.getAxioms(ruleind).size();
            assertEquals(8,axiom);
            // TODO review the generated test code and remove the default call to fail.
        }else{
            fail("Some problem occurs with addRecipe of KReSAddRule");
View Full Code Here

       if(result){
            Iterator<String> keys = recipeMap.keySet().iterator();
            int axiom = 0;
            while(keys.hasNext()){
                OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID+keys.next()));
                axiom = axiom + newonto.getAxioms(ruleind).size();
            }
            assertEquals(16,axiom);
            // TODO review the generated test code and remove the default call to fail.
        }else{
View Full Code Here

       if(result){
            Iterator<IRI> keys = recipeMap.keySet().iterator();
            int axiom = 0;
            while(keys.hasNext()){
                OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(keys.next());
               
                axiom = axiom + newonto.getAxioms(ruleind).size();
            }
            assertEquals(16,axiom);
            // TODO review the generated test code and remove the default call to fail.
View Full Code Here

   public boolean addRecipe(String recipeName, Vector<IRI> rules, String recipeDescription) {
       boolean ok = false;

       OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi + "Recipe"));
       OWLClass kresrule = factory.getOWLClass(IRI.create(owlIDrmi + "KReSRule"));
       OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(IRI.create(owlID + recipeName));
       OWLDataProperty description = factory.getOWLDataProperty(IRI.create(owlIDrmi + "hasDescription"));
       OWLDataProperty sequence = factory.getOWLDataProperty(IRI.create(owlIDrmi + "hasSequence"));
       OWLObjectProperty hasrule = factory.getOWLObjectProperty(IRI.create(owlIDrmi + "hasRule"));
       OWLObjectProperty start = factory.getOWLObjectProperty(IRI.create(owlIDrmi + "startWith"));
       OWLObjectProperty end = factory.getOWLObjectProperty(IRI.create(owlIDrmi + "endWith"));
       OWLObjectProperty precedes = factory.getOWLObjectProperty(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"));
       OWLObjectPropertyAssertionAxiom objectPropAssertion;

       if (((recipeName != null) || !recipeName.toString().isEmpty()) && ((rules != null) || !rules.isEmpty())) {
           if (!owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))) {

               //Add the rule istance
               OWLClassAssertionAxiom classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
               owlmanager.addAxiom(owlmodel, classAssertion);

               //start and end
               OWLNamedIndividual ind = factory.getOWLNamedIndividual(rules.firstElement());
               if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, ind))) {
                   objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(start, ontoind, ind);
                   owlmanager.addAxiom(owlmodel, objectPropAssertion);
                   ok = true;
               } else {
                   log.error("The rule with IRI " + ind.getIRI() + " is not inside the ontology. Pleas check its IRI.");
                   ok = false;
                   return (ok);
               }

               ind = factory.getOWLNamedIndividual(rules.lastElement());
               if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, ind))) {
                   objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(end, ontoind, ind);
                   owlmanager.addAxiom(owlmodel, objectPropAssertion);
                   ok = true;
               } else {
                   log.error("The rule with IRI " + ind.getIRI() + " is not inside the ontology. Pleas check its IRI.");
                   ok = false;
                   return (ok);

               }

               //Add the sequence string
               OWLDataPropertyAssertionAxiom dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(sequence, ontoind, rules.toString().replace("[", "").replace("]", ""));
               owlmanager.addAxiom(owlmodel, dataPropAssertion);

               //Add description
               if ((recipeDescription != null) || !recipeDescription.isEmpty()) {
                   //Add the rule description
                   dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(description, ontoind, recipeDescription);
                   owlmanager.addAxiom(owlmodel, dataPropAssertion);
                   ok = true;
               }

               //Add single rule
               for (int r = 0; r < rules.size() - 1; r++) {
                   ind = factory.getOWLNamedIndividual(rules.get(r));
                   if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, ind))) {
                       //Add the rule to the recipes
                       objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(hasrule, ontoind, ind);
                       owlmanager.addAxiom(owlmodel, objectPropAssertion);
                       ok = true;
                       //Add precedes
                       OWLNamedIndividual indf = factory.getOWLNamedIndividual(rules.get(r + 1));
                       if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, indf))) {
                           objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(precedes, ind, indf);
                           owlmanager.addAxiom(owlmodel, objectPropAssertion);
                           ok = true;
                       } else {
                           log.error("The rule with IRI " + indf.getIRI() + " is not inside the ontology. Pleas check its IRI.");
                           ok = false;
                           return (ok);
                       }
                   } else {
                       log.error("The rule with IRI " + ind.getIRI() + " is not inside the ontology. Pleas check its IRI.");
View Full Code Here

     */
    public boolean addSimpleRecipe(String recipeName, String recipeDescription) {
        boolean ok = false;

        OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi + "Recipe"));
        OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(IRI.create(owlID + recipeName));
        OWLDataProperty description = factory.getOWLDataProperty(IRI.create(owlIDrmi + "hasDescription"));
        OWLDataPropertyAssertionAxiom dataPropAssertion;


        if ((recipeName != null || !recipeName.isEmpty())) {
View Full Code Here

     */
    public boolean addSimpleRecipe(IRI recipeIRI, String recipeDescription) {
        boolean ok = false;

        OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi + "Recipe"));
        OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(recipeIRI);
        OWLDataProperty description = factory.getOWLDataProperty(IRI.create(owlIDrmi + "hasDescription"));
        OWLDataPropertyAssertionAxiom dataPropAssertion;

        if ((recipeIRI != null)) {
            if (!owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))) {
View Full Code Here

   public boolean addRecipe(IRI recipeName, Vector<IRI> rules, String recipeDescription) {
       boolean ok = false;

       OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi + "Recipe"));
       OWLClass kresrule = factory.getOWLClass(IRI.create(owlIDrmi + "KReSRule"));
       OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(recipeName);
       OWLDataProperty description = factory.getOWLDataProperty(IRI.create(owlIDrmi + "hasDescription"));
       OWLDataProperty sequence = factory.getOWLDataProperty(IRI.create(owlIDrmi + "hasSequence"));
       OWLObjectProperty hasrule = factory.getOWLObjectProperty(IRI.create(owlIDrmi + "hasRule"));
       OWLObjectProperty start = factory.getOWLObjectProperty(IRI.create(owlIDrmi + "startWith"));
       OWLObjectProperty end = factory.getOWLObjectProperty(IRI.create(owlIDrmi + "endWith"));
       OWLObjectProperty precedes = factory.getOWLObjectProperty(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"));
       OWLObjectPropertyAssertionAxiom objectPropAssertion;

       if (((recipeName != null) || !recipeName.toString().isEmpty()) && ((rules != null) || !rules.isEmpty())) {
           if (!owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))) {

               //Add the rule istance
               OWLClassAssertionAxiom classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
               owlmanager.addAxiom(owlmodel, classAssertion);

               //start and end
               OWLNamedIndividual ind = factory.getOWLNamedIndividual(rules.firstElement());
               if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, ind))) {
                   objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(start, ontoind, ind);
                   owlmanager.addAxiom(owlmodel, objectPropAssertion);
                   ok = true;
               } else {
                   log.error("The rule with IRI " + ind.getIRI() + " is not inside the ontology. Pleas check its IRI.");
                   ok = false;
                   return (ok);
               }

               ind = factory.getOWLNamedIndividual(rules.lastElement());
               if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, ind))) {
                   objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(end, ontoind, ind);
                   owlmanager.addAxiom(owlmodel, objectPropAssertion);
                   ok = true;
               } else {
                   log.error("The rule with IRI " + ind.getIRI() + " is not inside the ontology. Pleas check its IRI.");
                   ok = false;
                   return (ok);
               }

               //Add the sequence string
               OWLDataPropertyAssertionAxiom dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(sequence, ontoind, rules.toString().replace("[", "").replace("]", ""));
               owlmanager.addAxiom(owlmodel, dataPropAssertion);

               //Add description
               if ((recipeDescription != null) || !recipeDescription.isEmpty()) {
                   //Add the rule description
                   dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(description, ontoind, recipeDescription);
                   owlmanager.addAxiom(owlmodel, dataPropAssertion);
                   ok = true;
               }

               //Add single rule

               /*
               * BUGFIX - previously the check was done on rules.size()-1.
               * The right code is rules.size(). Moreover is need also a control "if(r+1>(rules.size()-1)) break;" because the last rule has not successive rules.
               *
               */
               for (int r = 0; r < rules.size(); r++) {
                   ind = factory.getOWLNamedIndividual(rules.get(r));
                   if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, ind))) {
                       //Add the rule to the recipes
                       objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(hasrule, ontoind, ind);
                       owlmanager.addAxiom(owlmodel, objectPropAssertion);
                       ok = true;
                       //Add precedes
                       if (r + 1 > (rules.size() - 1)) {
                           break;
                       }
                       OWLNamedIndividual indf = factory.getOWLNamedIndividual(rules.get(r + 1));
                       if (owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(kresrule, indf))) {
                           objectPropAssertion = factory.getOWLObjectPropertyAssertionAxiom(precedes, ind, indf);
                           owlmanager.addAxiom(owlmodel, objectPropAssertion);
                           ok = true;
                       } else {
                           log.error("The rule with IRI " + indf.getIRI() + " is not inside the ontology. Pleas check its IRI.");
                           ok = false;
                           return (ok);
                       }
                   } else {
                       log.error("The rule with IRI " + ind.getIRI() + " is not inside the ontology. Pleas check its IRI.");
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLNamedIndividual

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.