Package org.semanticweb.owlapi.util

Examples of org.semanticweb.owlapi.util.OWLEntityRemover


        OWLOntology o = loadPizzaOntology(m);
        // Ontologies don't directly contain entities but axioms
        // OWLEntityRemover will remove an entity (class, property or
        // individual)
        // from a set of ontologies by removing all referencing axioms
        OWLEntityRemover remover = new OWLEntityRemover(
                Collections.singleton(o));
        int previousNumberOfIndividuals = o.getIndividualsInSignature().size();
        // Visit all individuals with the remover
        // Changes needed for removal will be prepared
        for (OWLNamedIndividual ind : o.getIndividualsInSignature()) {
            ind.accept(remover);
        }
        // Now apply the changes
        m.applyChanges(remover.getChanges());
        int size = o.getIndividualsInSignature().size();
        assertTrue(previousNumberOfIndividuals + " supposed to be larger than "
                + size, previousNumberOfIndividuals > size);
    }
View Full Code Here


        // utility class, which will remove an entity (class, property or
        // individual) from a set of ontologies. Create the entity remover - in
        // this case we just want to remove the individuals from the pizza
        // ontology, so pass our reference to the pizza ontology in as a
        // singleton set.
        OWLEntityRemover remover = new OWLEntityRemover(singleton(ont));
        // System.out.println("Number of individuals: "
        // + ont.getIndividualsInSignature().size());
        // Loop through each individual that is referenced in the pizza
        // ontology, and ask it to accept a visit from the entity remover. The
        // remover will automatically accumulate the changes which are necessary
        // to remove the individual from the ontologies (the pizza ontology)
        // which it knows about
        for (OWLNamedIndividual ind : ont.getIndividualsInSignature()) {
            ind.accept(remover);
        }
        // Now we get all of the changes from the entity remover, which should
        // be applied to remove all of the individuals that we have visited from
        // the pizza ontology. Notice that "batch" deletes can essentially be
        // performed - we simply visit all of the classes, properties and
        // individuals that we want to remove and then apply ALL of the changes
        // after using the entity remover to collect them
        man.applyChanges(remover.getChanges());
        // System.out.println("Number of individuals: "
        // + ont.getIndividualsInSignature().size());
        // At this point, if we wanted to reuse the entity remover, we would
        // have to reset it
        remover.reset();
    }
View Full Code Here

    return ontology;
  }

  public void delete() {
    if(obj instanceof OWLEntity){
      OWLEntityRemover remover = getOWLEntityRemover();
      ((OWLEntity)obj).accept(remover);
      getOWLOntologyManager().applyChanges(remover.getChanges());
          remover.reset();
    }
  }
View Full Code Here

    return modified;
  }
 
  protected OWLEntityRemover getOWLEntityRemover(){
    if(remover == null){
      remover = new OWLEntityRemover(manager,Collections.singleton(ontology));
    }
    return remover;
  }
View Full Code Here

    return modified;
  }
 
  protected OWLEntityRemover getOWLEntityRemover(){
    if(remover == null){
      remover = new OWLEntityRemover(manager,Collections.singleton(ontology));
    }
    return remover;
  }
View Full Code Here

    return ontology;
  }

  public void delete() {
    if(obj instanceof OWLEntity){
      OWLEntityRemover remover = getOWLEntityRemover();
      ((OWLEntity)obj).accept(remover);
      getOWLOntologyManager().applyChanges(remover.getChanges());
          remover.reset();
    }
  }
View Full Code Here

    }

    @Override
    public OntologyChangeList<OWLEntity> generateChanges(OWLAPIProject project, ChangeGenerationContext context) {
        OntologyChangeList.Builder<OWLEntity> builder = new OntologyChangeList.Builder<OWLEntity>();
        OWLEntityRemover remover = new OWLEntityRemover(project.getRootOntology().getOWLOntologyManager(), project.getRootOntology().getImportsClosure());
        entity.accept(remover);
        List<OWLOntologyChange> changeList = remover.getChanges();
        builder.addAll(changeList);
        return builder.build();
    }
View Full Code Here

    @Override
    public void createChanges(List<OWLOntologyChange> changeListToFill) {
        OWLOntologyManager rootOntologyManager = getRootOntologyManager();
        OWLOntology rootOntology = getRootOntology();
        Set<OWLOntology> importsClosure = rootOntology.getImportsClosure();
        OWLEntityRemover entityRemover = new OWLEntityRemover(rootOntologyManager, importsClosure);

        RenderingManager rm = getRenderingManager();
        Set<OWLEntity> entities = rm.getEntities(entityName);
        for(OWLEntity entity : entities) {
            entity.accept(entityRemover);
        }
        changeListToFill.addAll(entityRemover.getChanges());
    }
View Full Code Here

        OWLOntologyManager mng = owlmodel.getOWLOntologyManager();
        OWLDataFactory factory = mng.getOWLDataFactory();

        // Create the remover to be used to delete the recipe from the ontology.
        OWLEntityRemover remover = new OWLEntityRemover(mng, Collections.singleton(owlmodel));

        // Create the recipe axiom
        OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(recipe.getRecipeID());

        // Remove the recipe
        ontoind.accept(remover);
        mng.applyChanges(remover.getChanges());
        remover.reset();

        // Check if the recipe ahs been removed
        if (owlmodel.containsIndividualInSignature(recipe.getRecipeID())) return false;
        else return true;
View Full Code Here

        OWLOntologyManager mng = owlmodel.getOWLOntologyManager();
        OWLDataFactory factory = mng.getOWLDataFactory();
        String ruleNS = "http://incubator.apache.org/stanbol/ontology/rmi.owl#";

        // Create the remover to be used to delete the rule from the ontology.
        OWLEntityRemover remover = new OWLEntityRemover(mng, Collections.singleton(owlmodel));

        // Create the rule axiom
        OWLNamedIndividual ontoind = factory.getOWLNamedIndividual(IRI.create((ruleNS + rule.getRuleName())));

        // Remove the rule
        ontoind.accept(remover);
        mng.applyChanges(remover.getChanges());
        remover.reset();

        // Check if the recipe ahs been removed
        if (owlmodel.containsIndividualInSignature(IRI.create((ruleNS + rule.getRuleName())))) return false;
        else return true;
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.