Package org.semanticweb.owlapi.util

Examples of org.semanticweb.owlapi.util.OWLEntityRemover


     */
    public Vector<IRI> getRuleUsage(IRI ruleName){
        Vector<IRI> ruleusage = new Vector();
        OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi+"KReSRule"));
        OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(ruleName);
        OWLEntityRemover remover = new OWLEntityRemover(owlmanager, Collections.singleton(owlmodel));
        OWLObjectProperty hasrule = factory.getOWLObjectProperty(IRI.create(owlIDrmi+"hasRule"));


        if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){

            ontoind.accept(remover);
            List<OWLOntologyChange> list = remover.getChanges();
            Iterator<OWLOntologyChange> iter = list.iterator();

            while(iter.hasNext()){
                OWLAxiom ax =iter.next().getAxiom();
                if(ax.getObjectPropertiesInSignature().contains(hasrule)){
                    String[] data = Arrays.toString(ax.getIndividualsInSignature().toArray()).split(",");
                    for(int s = 0; s<data.length;s++){
                        if(!data[s].contains(ontoind.getIRI().toString())){
                            String string = data[s].replace("<","").replace(">","").replace("[","").replace("]","").replace(" ","");
                            if(!string.startsWith("["))
                                ruleusage.add(IRI.create(string));
                        }
                    } 
                }
            }

            remover.reset();

            return(ruleusage);
        }else{
           log.error("The rule with name "+ruleName+" is not inside the ontology. Pleas check the name.");
           return(null);
View Full Code Here


   public boolean removeRule(String ruleName){
       boolean ok = false;
       OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi+"KReSRule"));
       OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(IRI.create(owlID+ruleName));
       OWLObjectProperty hasrule = factory.getOWLObjectProperty(IRI.create(owlIDrmi+"hasRule"));
       OWLEntityRemover remover = new OWLEntityRemover(owlmanager, Collections.singleton(owlmodel));

       if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){
          
            ontoind.accept(remover);
            List<OWLOntologyChange> list = remover.getChanges();
            Iterator<OWLOntologyChange> iter = list.iterator();
            Vector<String> usage = new Vector();

            while(iter.hasNext()){
                OWLAxiom ax =iter.next().getAxiom();
                if(ax.getObjectPropertiesInSignature().contains(hasrule)){
                    usage.add(Arrays.toString(ax.getIndividualsInSignature().toArray()));
             
                }
            }

            if(usage.isEmpty()){
                        ok = true;
                        owlmanager.applyChanges(remover.getChanges());
                        remover.reset();
                    }else{
                         LoggerFactory.getLogger(RemoveRule.class).error("The rule cannot be deleted because is used by some recipes. Pleas check the following recipes:\n"+usage.toString());
                         ok = false;
                         return(ok);
                 }
View Full Code Here

   public boolean removeRule(IRI ruleName){
       boolean ok = false;
       OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi+"KReSRule"));
       OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(ruleName);
       OWLObjectProperty hasrule = factory.getOWLObjectProperty(IRI.create(owlIDrmi+"hasRule"));
       OWLEntityRemover remover = new OWLEntityRemover(owlmanager, Collections.singleton(owlmodel));

       if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){

            ontoind.accept(remover);
            List<OWLOntologyChange> list = remover.getChanges();
            Iterator<OWLOntologyChange> iter = list.iterator();
            Vector<String> usage = new Vector();

            while(iter.hasNext()){
                OWLAxiom ax =iter.next().getAxiom();
                if(ax.getObjectPropertiesInSignature().contains(hasrule)){
                    usage.add(Arrays.toString(ax.getIndividualsInSignature().toArray()));

                }
            }

            if(usage.isEmpty()){
                        ok = true;
                        owlmanager.applyChanges(remover.getChanges());
                        remover.reset();
                    }else{
                         LoggerFactory.getLogger(RemoveRule.class).error("The rule cannot be deleted because is used by some recipes. Pleas check the following recipes:\n"+usage.toString());
                         ok = false;
                         return(ok);
                 }
View Full Code Here

    */
   public boolean removeRecipe(String recipeName){
       boolean ok = false;
       OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi+"Recipe"));
       OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(IRI.create(owlID+recipeName));
       OWLEntityRemover remover = new OWLEntityRemover(owlmanager, Collections.singleton(owlmodel));
       OWLObjectProperty precedes = factory.getOWLObjectProperty(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"));
       OWLObjectPropertyAssertionAxiom objectPropAssertion;

        GetRecipe getrecipe = new GetRecipe(storeaux);
        HashMap<IRI, String> map = getrecipe.getRecipe(recipeName);
       
        String[] sequence = map.get(IRI.create(owlID+recipeName)).split(",");
        Vector<IRI> ruleseq = new Vector();
        for(String seq : sequence){
            if(!seq.replace(" ","").trim().isEmpty())
                ruleseq.add(IRI.create(seq.replace(" ","").trim()));
        }
        HashMap<String, Integer> count = getrecipe.getBinSequenceRecipeCount();
        Vector<String> binseq = new Vector();
        String bs="";
        for(int i = 0; i<ruleseq.size()-1;i++){
            bs=ruleseq.get(i).toString()+" precedes "+ruleseq.get(i+1).toString();
            if(count.containsKey(bs)){
                if(count.get(bs)==1){
                    binseq.add(bs);
                }
            }
        }

       if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){

            ontoind.accept(remover);
            owlmanager.applyChanges(remover.getChanges());
            remover.reset();

           if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){
               log.error("Some error occurs during deletion.");
               ok = false;
               return(ok);
View Full Code Here

    */
   public boolean removeRecipe(IRI recipeName){
       boolean ok = false;
       OWLClass ontocls = factory.getOWLClass(IRI.create(owlIDrmi+"Recipe"));
       OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(recipeName);
       OWLEntityRemover remover = new OWLEntityRemover(owlmanager, Collections.singleton(owlmodel));
       OWLObjectProperty precedes = factory.getOWLObjectProperty(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"));
       OWLObjectPropertyAssertionAxiom objectPropAssertion;

        GetRecipe getrecipe = new GetRecipe(storeaux);
        HashMap<IRI, String> map = getrecipe.getRecipe(recipeName);
       
        String[] sequence = map.get(recipeName).split(",");
        Vector<IRI> ruleseq = new Vector();
        for(String seq : sequence){
            if(!seq.replace(" ","").trim().isEmpty())
                ruleseq.add(IRI.create(seq.replace(" ","").trim()));
        }
        HashMap<String, Integer> count = getrecipe.getBinSequenceRecipeCount();
      
        Vector<String> binseq = new Vector();
        String bs="";
        for(int i = 0; i<ruleseq.size()-1;i++){
            bs=ruleseq.get(i).toString()+" precedes "+ruleseq.get(i+1).toString();
            if(count.containsKey(bs)){
                if(count.get(bs)==1){
                    binseq.add(bs);
                }
            }
        }
  
       if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){

            ontoind.accept(remover);
            owlmanager.applyChanges(remover.getChanges());
            remover.reset();

           if(owlmodel.containsAxiom(factory.getOWLClassAssertionAxiom(ontocls, ontoind))){
               log.error("Some error occurs during deletion.");
               ok = false;
               return(ok);
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.util.OWLEntityRemover

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.