Java 类org.semanticweb.owlapi.model.RemoveAxiom 实例源码

项目:archonte    文件:ArchonteUtils.java   
/** Removes the set annotations of the entity from the given ontology using the given manager.
 * @param modelManager
 * @param currentEntity
 * @param ontology
 * @param annotations
 */
public static void removeAnnotation(OWLModelManager modelManager,
        OWLEntity currentEntity,
        OWLOntology ontology,
        Set<OWLAnnotation> annotations) {

    OWLDataFactory factory = modelManager.getOWLDataFactory();

    List<OWLOntologyChange> changes = new Vector<OWLOntologyChange>();
    for(OWLAnnotation annot : annotations) {
        OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(
                currentEntity.getIRI(),
                annot);
        changes.add(new RemoveAxiom(ontology, axiom));
    }
    modelManager.applyChanges(changes);
}
项目:ontocomplib    文件:CounterExampleCandidateDescriptionChange.java   
public void undo() {
    OWLClassAssertionAxiom axiom = null;
    if (isTypePlus) {
        axiom = theContext.getFactory().getOWLClassAssertionAxiom(changedType, candidate);
    }
    else {
        axiom = theContext.getFactory().getOWLClassAssertionAxiom( 
                theContext.getFactory().getOWLObjectComplementOf(changedType), candidate);
    }
    RemoveAxiom  removeAxiom = new RemoveAxiom(theContext.getOntology(),axiom); 
    try {
        theContext.getManager().applyChange(removeAxiom);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
项目:SciGraph    文件:ReasonerUtil.java   
void removeRedundantAxioms() {
  final List<RemoveAxiom> changes = new ArrayList<RemoveAxiom>();
  Set<OWLClass> allClasses = ont.getClassesInSignature(true);
  logger.info("Check classes for redundant super class axioms, all OWL classes count: " + allClasses.size());
  for (OWLClass cls: allClasses) {
    final Set<OWLClass> directSuperClasses = reasoner.getSuperClasses(cls, true).getFlattened();
    for (final OWLOntology importedOntology: ont.getImportsClosure()) {
      Set<OWLSubClassOfAxiom> subClassAxioms = importedOntology.getSubClassAxiomsForSubClass(cls);
      for (final OWLSubClassOfAxiom subClassAxiom : subClassAxioms) {
        subClassAxiom.getSuperClass().accept(new OWLClassExpressionVisitorAdapter(){
          @Override
          public void visit(OWLClass desc) {
            if (directSuperClasses.contains(desc) == false) {
              changes.add(new RemoveAxiom(importedOntology, subClassAxiom));
            }
          }
        });
      }
    }
  }
  logger.info("Found redundant axioms: " + changes.size());
  List<OWLOntologyChange> result = manager.applyChanges(changes);
  logger.info("Removed axioms: " + result.size());
}
项目:ontocomplib    文件:AbstractContextModification.java   
public void undo() {
    RemoveAxiom removeAxiom = new RemoveAxiom(getContext().getOntology(),
            getChange().getAxiom());
    try {
        getContext().getManager().applyChange(removeAxiom);
        // context.reClassifyOntology();
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
项目:minerva    文件:CoreMolecularModelManager.java   
private OWLObjectPropertyAssertionAxiom modifyAnnotations(OWLObjectPropertyAssertionAxiom axiom, 
        Set<OWLAnnotation> replacement, 
        ModelContainer model, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    OWLDataFactory f = model.getOWLDataFactory();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(2);
    changes.add(new RemoveAxiom(ont, axiom));
    OWLObjectPropertyAssertionAxiom newAxiom = 
            f.getOWLObjectPropertyAssertionAxiom(axiom.getProperty(), axiom.getSubject(), axiom.getObject(), replacement);
    changes.add(new AddAxiom(ont, newAxiom));
    applyChanges(model, changes, metadata);
    return newAxiom;
}
项目:minerva    文件:CoreMolecularModelManager.java   
void removeAxiom(ModelContainer model, OWLAxiom axiom, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    List<OWLOntologyChange> changes = Collections.<OWLOntologyChange>singletonList(new RemoveAxiom(ont, axiom));
    synchronized (ont) {
        /*
         * all changes to the ontology are synchronized via the ontology object
         */
        applyChanges(model, ont.getOWLOntologyManager(), changes, metadata);
    }
}
项目:minerva    文件:CoreMolecularModelManager.java   
void removeAxioms(ModelContainer model, Set<OWLAxiom> axioms, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(axioms.size());
    for(OWLAxiom axiom : axioms) {
        changes.add(new RemoveAxiom(ont, axiom));
    }
    synchronized (ont) {
        /*
         * all changes to the ontology are synchronized via the ontology object
         */
        applyChanges(model, ont.getOWLOntologyManager(), changes, metadata);
    }
}
项目:pronto    文件:ProntoLoaderUtils.java   
/**
 * Loads conditional constraints from an ontology with annotated axioms
 * 
 * @param ontology
 * @param signature 
 * @param declAxioms Used to return declaration axioms for auto-generated class names
 * @param iriPrefix IRI prefix for auto-generated class names
 * @param raxList
 * @return
 */
public static Set<ConditionalConstraint> loadDefaultConstraintsFromOWL(
        OWLOntology ontology,
        Map<String, OWLClassExpression> nameMap,
        Set<OWLEntity> signature,
        List<RemoveAxiom> raxList, String iriPrefix,
        OWLOntologyManager manager) {

    Set<ConditionalConstraint> ccSet = new HashSet<ConditionalConstraint>();
    //Begin with generic (default) subclass-of axioms
    for( OWLAxiom axiom : ontology.getAxioms( AxiomType.SUBCLASS_OF ) ) {
        for( OWLAnnotation annotation : axiom.getAnnotations() ) {

            if( Constants.CERTAINTY_ANNOTATION_URI.equals(annotation.getProperty().getIRI().toURI() ) ) {

                OWLSubClassOfAxiom sbAxiom = (OWLSubClassOfAxiom) axiom;
                String subClassIRI = generateClassName(sbAxiom.getSubClass(), nameMap, iriPrefix);
                String superClassIRI = generateClassName(sbAxiom.getSuperClass(), nameMap, iriPrefix);
                ConditionalConstraint cc = newConstraint(subClassIRI, superClassIRI, annotation.getValue().toString());

                signature.addAll( sbAxiom.getSubClass().getClassesInSignature() );
                signature.addAll( sbAxiom.getSuperClass().getClassesInSignature() );

                if( null != cc ) {

                    ccSet.add( cc );

                    if( null != raxList ) {
                        raxList.add( new RemoveAxiom( ontology, axiom ) );
                    }
                }
            }
        }
    }

    return ccSet;
}
项目:HermiT-android    文件:Reasoner.java   
public Set<OWLAxiom> getPendingAxiomRemovals() {
    Set<OWLAxiom> removed = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : m_pendingChanges)
        if (change instanceof RemoveAxiom)
            removed.add(change.getAxiom());
    return removed;
}
项目:elk-reasoner    文件:OwlChangesLoaderFactory.java   
Set<OWLAxiom> getPendingAxiomRemovals() {
    Set<OWLAxiom> removed = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : pendingChanges_) {
        if (change instanceof RemoveAxiom) {
            removed.add(change.getAxiom());
        }
    }
    return removed;
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
public Set<OWLAxiom> getPendingAxiomRemovals() {
    Set<OWLAxiom> removed = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : m_pendingChanges)
        if (change instanceof RemoveAxiom)
            removed.add(change.getAxiom());
    return removed;
}
项目:owltools    文件:CommandRunner.java   
@CLIMethod("--remove-subset-entities")
public void removeSubsetEntities(Opts opts) throws Exception {
    opts.info("[SUBSET]+","Removes all classes, individuals and object properties that are in the specific subset(s)");
    List<String> subSets = opts.nextList();
    if (subSets == null || subSets.isEmpty()) {
        System.err.println("At least one subset is required for this function.");
        exit(-1);
    }
    // create annotation values to match
    Set<OWLAnnotationValue> values = new HashSet<OWLAnnotationValue>();
    OWLDataFactory f = g.getDataFactory();
    for(String subSet : subSets) {
        // subset as plain string
        values.add(f.getOWLLiteral(subSet));
        // subset as IRI
        values.add(IRI.create(Obo2OWLConstants.DEFAULT_IRI_PREFIX+"#"+subSet));
    }

    // get annotation property for subset
    OWLAnnotationProperty p = g.getAnnotationProperty(OboFormatTag.TAG_SUBSET.getTag());

    // collect all objects in the given subset
    final Set<OWLObject> entities = Mooncat.findTaggedEntities(p, values, g);
    LOG.info("Found "+entities.size()+" tagged objects.");

    if (entities.isEmpty() == false) {
        final List<RemoveAxiom> changes = Mooncat.findRelatedAxioms(entities, g);
        if (changes.isEmpty() == false) {
            LOG.info("applying changes to ontology, count: "+changes.size());
            g.getManager().applyChanges(changes);
        }
        else {
            LOG.info("No axioms found for removal.");
        }
    }
}
项目:owltools    文件:TemplatedTransformer.java   
public Set<OWLOntologyChange> tr(OWLAxiom inAxiom, Mapping m) {
    Set<OWLOntologyChange> chgs = new HashSet<OWLOntologyChange>();
    boolean isModified = false;
    OWLAxiom newAxiom = null;
    if (inAxiom instanceof OWLEquivalentClassesAxiom) {
        OWLEquivalentClassesAxiom aa = (OWLEquivalentClassesAxiom)inAxiom;
        Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>();
        for (OWLClassExpression x : aa.getClassExpressions()) {
            OWLClassExpression x2 = replace(x, m);
            if (x2 == null) {
                xs.add(x);
            }
            else {
                isModified = true;
                xs.add(x2);
                LOG.info("  TR : "+x+ " ---> "+x2);
            }
        }
        if (isModified) {
            newAxiom = getOWLDataFactory().getOWLEquivalentClassesAxiom(xs);
        }
    }
    if (isModified) {
        if (m.isReplace) {
            chgs.add(new RemoveAxiom(ontology, inAxiom));
        }
        chgs.add(new AddAxiom(ontology, newAxiom));
    }
    return chgs;

}
项目:owltools    文件:OboOntologyReleaseRunner.java   
/**
 * Remove inferred axioms, which are marked by the appropriate axiom annotation. 
 * 
 * @param removedSubClassOfAxioms
 * @param removedSubClassOfAxiomChanges
 * 
 * @see AxiomAnnotationTools#isMarkedAsInferredAxiom(OWLAxiom)
 */
private void removeInferredAxioms(Set<OWLSubClassOfAxiom> removedSubClassOfAxioms, Set<RemoveAxiom> removedSubClassOfAxiomChanges)
{
    final OWLOntology ont = mooncat.getGraph().getSourceOntology();
    for (OWLSubClassOfAxiom a : ont.getAxioms(AxiomType.SUBCLASS_OF)) {
        if (AxiomAnnotationTools.isMarkedAsInferredAxiom(a)) {
            RemoveAxiom rmax = new RemoveAxiom(ont, a);
            removedSubClassOfAxiomChanges.add(rmax);
            removedSubClassOfAxioms.add(a);
        }
    }
}
项目:ecco    文件:Ecco.java   
/**
 * Remove unary disjointness axioms from the given ontology
 * @param ont   OWL ontology
 */
private void removeUnaryDisjointnessAxioms(OWLOntology ont) {
    List<RemoveAxiom> toRemove = new ArrayList<RemoveAxiom>();
    for(OWLAxiom ax : ont.getAxioms(AxiomType.DISJOINT_CLASSES)) {
        OWLDisjointClassesAxiom dis = (OWLDisjointClassesAxiom)ax;
        if(dis.getClassesInSignature().size() < 2)
            toRemove.add(new RemoveAxiom(ont, ax));
    }
    ont.getOWLOntologyManager().applyChanges(toRemove);
}
项目:ecco    文件:Ecco.java   
/**
 * Remove Abox axioms from given ontology
 * @param ont   Ontology to remove Abox axioms from
 */
private void removeAbox(OWLOntology ont) {
    Set<OWLAxiom> aboxAxs = ont.getABoxAxioms(true);
    List<RemoveAxiom> toRemove = new ArrayList<RemoveAxiom>();
    for(OWLAxiom ax : aboxAxs)
        toRemove.add(new RemoveAxiom(ont, ax));
    ont.getOWLOntologyManager().applyChanges(toRemove);
}
项目:ontocomplib    文件:IndividualContext.java   
private boolean implicationMakesOntologyInconsistent(FCAImplication<OWLClass> imp) {
    boolean retCode = false;
    // first create the GCI
    // OWLSubClassAxiom axiom = getFactory().getOWLSubClassAxiom(
    //      toOWLDescription(imp.getPremise()),
    //      toOWLDescription(imp.getConclusion()));
    OWLSubClassOfAxiom axiom = toOWLSubClassAxiom(imp);

    // create a new AddAxiom object
    AddAxiom addAxiom = new AddAxiom(getOntology(),axiom);
    RemoveAxiom removeAxiom = new RemoveAxiom(getOntology(),axiom);
    // apply the change
    try {
        getManager().applyChange(addAxiom);
        // getReasoner().unloadOntologies(ontologies);
        // getReasoner().loadOntologies(ontologies);
        // reClassifyOntology unloads/loads and classifies
        reClassifyOntology();
        if (getReasoner().isConsistent()) {
            retCode = false;
        }
        else {
            retCode = true;
        }
        getManager().applyChange(removeAxiom);
        // getReasoner().unloadOntologies(ontologies);
        // getReasoner().loadOntologies(ontologies);
        // reClassifyOntology unloads/loads and classifies
        reClassifyOntology();
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    // logger.debug("dnm2");
    // // if (!retCode) {
    //  try {
    //      getManager().applyChange(removeAxiom);
    //      getReasoner().unloadOntologies(ontologies);
    //      getReasoner().loadOntologies(ontologies);
    //  }
    //  catch (OWLOntologyChangeException x) {
    //      x.printStackTrace();
    //      System.exit(-1);
    //  }
    //  catch (OWLReasonerException x) {
    //      x.printStackTrace();
    //      logger.fatal("reasoner exception, exiting...");
    //      System.exit(-1);
    //  }
    //  
    // // }
    return retCode;
}
项目:minerva    文件:ReverseChangeGenerator.java   
public OWLOntologyChange visit(AddAxiom change) {
    return new RemoveAxiom(change.getOntology(), change.getAxiom());
}
项目:minerva    文件:ReverseChangeGenerator.java   
public OWLOntologyChange visit(RemoveAxiom change) {
    return new AddAxiom(change.getOntology(), change.getAxiom());
}
项目:pronto    文件:ProntoLoaderUtils.java   
public static Map<ATermAppl, Set<ConditionalConstraint>>
                            loadConcreteConstraintsFromOWL( OWLOntology ontology,
                                                            Map<String, OWLClassExpression> nameMap,
                                                            Set<OWLEntity> signature,
                                                            List<RemoveAxiom> raxList,
                                                            String iriPrefix,
                                                            OWLOntologyManager manager) {

    Map<ATermAppl, Set<ConditionalConstraint>> ccMap = new HashMap<ATermAppl, Set<ConditionalConstraint>>();
    ConditionalConstraint cc = null;
    Set<ConditionalConstraint> ccSet = null;
    OWLDataFactory factory = manager.getOWLDataFactory();

    for( OWLAxiom axiom : ontology.getAxioms( AxiomType.CLASS_ASSERTION ) ) {

        for( OWLAnnotation annotation : axiom.getAnnotations() ) {

            if( Constants.CERTAINTY_ANNOTATION_URI.equals( annotation.getProperty().getIRI().toURI() ) ) {

                OWLClassAssertionAxiom caAxiom = (OWLClassAssertionAxiom) axiom;
                String classNameIRI = generateClassName(caAxiom.getClassExpression(), nameMap, iriPrefix);
                OWLIndividual individ = caAxiom.getIndividual();
                ATermAppl indTerm = ATermUtils.makeTermAppl( individ.asOWLNamedIndividual().getIRI().toURI().toString() );

                ccSet = (Set<ConditionalConstraint>) ccMap.get( indTerm );
                cc = newConstraint( factory.getOWLThing().getIRI().toString(), classNameIRI, annotation.getValue().toString() );
                signature.addAll( caAxiom.getClassExpression().getClassesInSignature() );

                if( null != cc ) {

                    if( null == ccSet ) {

                        ccSet = new HashSet<ConditionalConstraint>();
                    }

                    ccSet.add( cc );
                    ccMap.put( indTerm, ccSet );

                    if( null != raxList ) {

                        raxList.add( new RemoveAxiom( ontology, axiom ) );
                    }
                }
            }
        }
    }

    return ccMap;
}
项目:elk-reasoner    文件:ProofTestUtils.java   
public static <I extends Inference<?>> void proofCompletenessTest(
        final OWLProver prover, final OWLAxiom entailment,
        final Object conclusion, final Proof<? extends I> proof,
        final InferenceJustifier<? super I, ? extends Set<? extends OWLAxiom>> justifier,
        final boolean mustNotBeATautology) {

    final OWLOntology ontology = prover.getRootOntology();
    final OWLOntologyManager manager = ontology.getOWLOntologyManager();

    // compute repairs

    final Set<Set<? extends OWLAxiom>> repairs = new HashSet<Set<? extends OWLAxiom>>();
    MinimalSubsetEnumerators.enumerateRepairs(conclusion, proof, justifier,
            InterruptMonitor.DUMMY,
            new MinimalSubsetCollector<OWLAxiom>(repairs));

    if (mustNotBeATautology) {
        assertFalse("Entailment is a tautology; there are no repairs!",
                repairs.isEmpty());
    }

    for (final Set<? extends OWLAxiom> repair : repairs) {

        final List<OWLOntologyChange> deletions = new ArrayList<OWLOntologyChange>();
        final List<OWLOntologyChange> additions = new ArrayList<OWLOntologyChange>();
        for (final OWLAxiom axiom : repair) {
            deletions.add(new RemoveAxiom(ontology, axiom));
            additions.add(new AddAxiom(ontology, axiom));
        }

        manager.applyChanges(deletions);

        final boolean conclusionDerived = prover.isEntailed(entailment);

        manager.applyChanges(additions);

        assertFalse("Not all proofs were found!\n" + "Conclusion: "
                + conclusion + "\n" + "Repair: " + repair,
                conclusionDerived);
    }

}
项目:elk-reasoner    文件:ProofTest.java   
@Test
public void proofsUnderOntologyUpdate() throws Exception {
    // loading and classifying via the OWL API
    OWLOntology ontology = loadOntology(
            ProofTest.class.getClassLoader().getResourceAsStream(
                    "ontologies/PropertyCompositionsWithHierarchy.owl"));
    final OWLProver prover = OWLAPITestUtils.createProver(ontology);

    prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

    OWLClass sub = factory.getOWLClass(IRI.create("http://example.org/A"));
    OWLClass sup = factory.getOWLClass(IRI.create("http://example.org/G"));

    // printInferences(reasoner, sub, sup);
    // OWLExpression root =
    // reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
    // sup));
    // System.err.println(OWLProofUtils.printProofTree(root));
    ProofTestUtils.provabilityTest(prover,
            factory.getOWLSubClassOfAxiom(sub, sup));

    // now convert C <= R3 some D to C < S3 some D
    OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
    OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
    OWLObjectProperty r3 = factory
            .getOWLObjectProperty(IRI.create("http://example.org/R3"));
    OWLObjectProperty s3 = factory
            .getOWLObjectProperty(IRI.create("http://example.org/S3"));
    OWLAxiom oldAx = factory.getOWLSubClassOfAxiom(c,
            factory.getOWLObjectSomeValuesFrom(r3, d));
    OWLAxiom newAx = factory.getOWLSubClassOfAxiom(c,
            factory.getOWLObjectSomeValuesFrom(s3, d));

    OWLOntologyManager manager = ontology.getOWLOntologyManager();

    manager.applyChanges(Arrays.asList(new RemoveAxiom(ontology, oldAx),
            new AddAxiom(ontology, newAx)));

    prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

    // printInferences(reasoner, sub, sup);
    // root =
    // reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
    // sup));
    // System.err.println(OWLProofUtils.printProofTree(root));
    ProofTestUtils.provabilityTest(prover,
            factory.getOWLSubClassOfAxiom(sub, sup));
}
项目:owltools    文件:OWLGraphManipulator.java   
/**
 * Relaxes all {@code OWLObjectIntersectionOf}s. This method will relax 
 * {@code OWLSubClassOfAxiom}s, whose superclass is an {@code OWLObjectIntersectionOf}, 
 * into multiple {@code OWLSubClassOfAxiom}s, using a <a 
 * href='http://owlapi.sourceforge.net/javadoc/org/semanticweb/owlapi/SplitSubClassAxioms.html'>
 * SplitSubClassAxioms</a>. It will also relax {@code OWLSubClassOfAxiom}s, whose 
 * superclass is an {@code OWLObjectSomeValuesFrom} with a filler being an 
 * {@code OWLObjectIntersectionOf}, into multiple {@code OWLSubClassOfAxiom}s with 
 * an {@code OWLObjectSomeValuesFrom} as superclass, with the same 
 * {@code OWLPropertyExpression}, and individual operands as filler. 
 * <p>
 * Note that it is likely that the {@code OWLObjectIntersectionOf}s where used in
 * {@code OWLEquivalentClassesAxiom}s, rather than in {@code OWLSubClassOfAxiom}s. 
 * But the method {@link #convertEquivalentClassesToSuperClasses()} would have transformed 
 * them into {@code OWLSubClassOfAxiom}s. It must be called before this method.
 * 
 * @see #performDefaultModifications()
 * @see #convertEquivalentClassesToSuperClasses()
 */
private void splitSubClassAxioms() {
    log.info("Relaxing OWLSubClassOfAxioms whose superclass is an OWLObjectIntersectionOf");

    //first, split subClassOf axioms whose superclass is an OWLObjectIntersectionOf
    SplitSubClassAxioms split = new SplitSubClassAxioms(
            this.getOwlGraphWrapper().getAllOntologies(), 
            this.getOwlGraphWrapper().getDataFactory());
    this.getOwlGraphWrapper().getManager().applyChanges(split.getChanges());
    this.triggerWrapperUpdate();

    //some ontologies use an OWLObjectIntersectionOf as the filler of 
    //an OWLObjectSomeValuesFrom class expression. We go only one level down 
    //(i.e., we would not translate another OWLObjectSomeValuesFrom part of the 
    //OWLObjectIntersectionOf)
    OWLDataFactory dataFactory = this.getOwlGraphWrapper().getDataFactory();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
    for (OWLOntology ont : this.getOwlGraphWrapper().getAllOntologies()) {
        for (OWLSubClassOfAxiom ax : ont.getAxioms(AxiomType.SUBCLASS_OF)) {
            OWLClassExpression superClsExpr = ax.getSuperClass();
            if (superClsExpr instanceof OWLObjectSomeValuesFrom) {
                OWLObjectSomeValuesFrom someValuesFrom = 
                        (OWLObjectSomeValuesFrom) superClsExpr;
                if (someValuesFrom.getFiller() instanceof OWLObjectIntersectionOf) {
                    //remove original axiom
                    changes.add(new RemoveAxiom(ont, ax));

                    OWLObjectIntersectionOf filler = 
                            (OWLObjectIntersectionOf) someValuesFrom.getFiller();
                    for (OWLClassExpression op : filler.getOperands()) {
                        //we accept only OWLClasses, otherwise we would need to compose 
                        //OWLObjectPropertyExpressions
                        if (op instanceof OWLClass) {
                            OWLAxiom replAx = dataFactory.
                                    getOWLSubClassOfAxiom(ax.getSubClass(), 
                                    dataFactory.getOWLObjectSomeValuesFrom(
                                                someValuesFrom.getProperty(), op));
                            changes.add(new AddAxiom(ont, replAx));
                        }
                    }
                }

            }
        }
    }
    this.getOwlGraphWrapper().getManager().applyChanges(changes);
    this.triggerWrapperUpdate();

    log.info("OWLObjectIntersectionOf relaxation done.");
}
项目:owltools    文件:OWLGraphManipulatorTest.java   
/**
 * Test that two {@code OWLClass}es that are equal have a same hashcode, 
 * because the OWLGraphEdge bug get me paranoid. 
 */
@Test
public void testOWLOntologyChangeHashCode()
{

    OWLOntology ont = this.graphManipulator.getOwlGraphWrapper().getSourceOntology();
    OWLDataFactory factory = this.graphManipulator.getOwlGraphWrapper().
            getManager().getOWLDataFactory();
    OWLClass source = 
            this.graphManipulator.getOwlGraphWrapper().getOWLClassByIdentifier("FOO:0005");
    OWLClass target = 
            this.graphManipulator.getOwlGraphWrapper().getOWLClassByIdentifier("FOO:0001");

    OWLGraphEdge checkEdge = new OWLGraphEdge(source, target, ont);
    OWLAxiom axiom = factory.getOWLSubClassOfAxiom(source, 
            (OWLClassExpression) this.graphManipulator.getOwlGraphWrapper().
            edgeToTargetExpression(checkEdge));
    OWLAxiomChange rm1 = new RemoveAxiom(ont, axiom);

    OWLGraphEdge checkEdge2 = new OWLGraphEdge(source, target, ont);
    OWLAxiom axiom2 = factory.getOWLSubClassOfAxiom(source, 
            (OWLClassExpression) this.graphManipulator.getOwlGraphWrapper().
            edgeToTargetExpression(checkEdge2));
    OWLAxiomChange rm2 = new RemoveAxiom(ont, axiom2);

    assertTrue("The two OWLAxiomChange objects are equal", 
             rm1.equals(rm2));
     //then of course the hashcodes will be the same...
     assertTrue("Two OWLAxiomChange are equal but have different hashcode", 
             rm1.equals(rm2) && rm1.hashCode() == rm2.hashCode());



     source = 
             this.graphManipulator.getOwlGraphWrapper().getOWLClassByIdentifier("FOO:0014");
     target = 
             this.graphManipulator.getOwlGraphWrapper().getOWLClassByIdentifier("FOO:0001");

     checkEdge = new OWLGraphEdge(source, target, ont);
     axiom = factory.getOWLSubClassOfAxiom(source, 
             (OWLClassExpression) this.graphManipulator.getOwlGraphWrapper().
             edgeToTargetExpression(checkEdge));
     OWLAxiomChange rm3 = new RemoveAxiom(ont, axiom);

     assertFalse("Different OWLAxiomChange objects are equal", 
             rm1.equals(rm3));
     //then of course the hashcodes will be the same...
     assertFalse("Different OWLAxiomChanges have same hashcode", 
             rm1.hashCode() == rm3.hashCode());
}
项目:jcel    文件:JcelOntologyChangeVisitorEx.java   
@Override
public Boolean visit(RemoveAxiom change) {
    Objects.requireNonNull(change);
    return this.reasoner.removeAxiom(change.getAxiom());
}
项目:archonte    文件:DoeToSkosVisitor.java   
public void myvisit(IRI desc_iri) {
    Collection<OWLAnnotation> annotations =
            Searcher.annotationObjects(getCurrentOntology().getAnnotationAssertionAxioms(desc_iri));
    // For each annotation...
    for(OWLAnnotation annot : annotations) {
        // Del it if it is DOE
        OWLAnnotationProperty property = annot.getProperty();
        IRI propIri = property.getIRI();
        // Trying to test IRI and if match, go!
        if(LexicalisationGlobalPanel.doeAnnotations.contains(propIri)) {
            // Remove it
            OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(
                    desc_iri,
                    annot);
            changes.add(new RemoveAxiom(getCurrentOntology(), axiom));
            // What fragment?
            String fragment = propIri.getFragment();
            OWLAnnotation newAnnot;
            if(fragment.equals("prefLabel")) {
                newAnnot = factory.getOWLAnnotation(
                        skosPrefLabel,
                        annot.getValue());
            }
            else if(fragment.equals("altLabel")) {
                newAnnot = factory.getOWLAnnotation(
                        skosAltLabel,
                        annot.getValue());
            }
            else if(fragment.equals("definition")) {
                newAnnot = factory.getOWLAnnotation(
                        skosDefinition,
                        annot.getValue());
            }
            else if(fragment.equals("hiddenLabel")) {
                newAnnot = factory.getOWLAnnotation(
                        skosHiddenLabel,
                        annot.getValue());
            }
            else {
                // Must be an error...
                continue;
            }
            OWLAxiom newAxiom = factory.getOWLAnnotationAssertionAxiom(
                    desc_iri,
                    newAnnot);
            changes.add(new AddAxiom(getCurrentOntology(), newAxiom));
        }
    }
}
项目:archonte    文件:DifferentialGlobalView.java   
void changeDifferentialAnnotation(String principleType, OWLEntity myEntity, String diffText) {
    // All annotations
    Collection<OWLAnnotation> annotations = 
        Searcher.annotationObjects(
            currentOntology.getAnnotationAssertionAxioms(myEntity.getIRI()),
            factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI()));
    // The annotation if a find it
    OWLAnnotation searchAnnotation = null;
    // The prefix I will use
    IRI goodPrefix = (principleType.equals("SWP"))?swpIRI:swsIRI;

    // Searching for the right annotation
    for(OWLAnnotation annotation : annotations) {
        OWLAnnotationValue value = annotation.getValue();
        if(value instanceof OWLLiteral) {
            IRI annotURI = annotation.getProperty().getIRI();
            if(annotURI.equals(goodPrefix)) {
                searchAnnotation = annotation;
                break;
            }
        }
    }

    // If there was an annotation, delete it
    if(searchAnnotation != null) {
        // Get the axiom
        OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(
                myEntity.getIRI(),
                searchAnnotation);
        // Remove it
        currentOWLModelManager.applyChange(new RemoveAxiom(currentOntology, axiom));
    }
    // Create a new annotation
    OWLLiteral altIDConstant = factory.getOWLLiteral(diffText);
    OWLAnnotation newAnnot = factory.getOWLAnnotation(
            factory.getOWLAnnotationProperty(goodPrefix), altIDConstant);
    // Create the axiom
    OWLAxiom newAxiom = factory.getOWLAnnotationAssertionAxiom(
            myEntity.getIRI(),
            newAnnot);
    // Add it
    currentOWLModelManager.applyChange(new AddAxiom(currentOntology, newAxiom));
}
项目:Pellet4Android    文件:OntologyManager.java   
private void removeAxiom(final OWLAxiom axiom) {
    RemoveAxiom rAxiom = new RemoveAxiom(ontology, axiom);
    getManager().applyChange(rAxiom);
    reasoner.flush();
}
项目:snorocket    文件:SnorocketOWLReasoner.java   
/**
 * Classifies the ontology incrementally if no import changes have occurred.
 *
 * Flushes any changes stored in the buffer, which causes the reasoner to
 * take into consideration the changes the current root ontology specified
 * by the changes. If the reasoner buffering mode is
 * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING}
 * then this method will have no effect.
 */
@Override
public void flush() {
    if (rawChanges.isEmpty() || !buffering) {
        return;
    }

    // Get the changed axioms
    boolean hasRemoveAxiom = false;
    List<OWLAxiom> newAxioms = new ArrayList<OWLAxiom>();
    for (OWLOntologyChange change : rawChanges) {
        OWLAxiom axiom = change.getAxiom();
        if(axiom instanceof RemoveAxiom) {
            hasRemoveAxiom = true;
            break;
        }
        newAxioms.add(axiom);
    }

    if(hasRemoveAxiom) {
        rawChanges.clear();
        classify();
        return;
    }

    // Transform the axioms into the canonical model
    Set<Axiom> canAxioms = getAxioms(newAxioms);

    // Classify
    monitor.taskStarted("Classifying incrementally");
    monitor.taskBusy();
    reasoner.loadAxioms(canAxioms);
    reasoner = reasoner.classify();
    monitor.taskEnded();

    monitor.taskStarted("Calculating taxonomy incrementally");
    monitor.taskBusy();
    taxonomy = reasoner.getClassifiedOntology();
    monitor.taskEnded();

    rawChanges.clear();
}
项目:java-skos-api    文件:SKOSChangeUtility.java   
public RemoveAxiom getRemoveAxiom () {
    return new RemoveAxiom(dataSet.getAsOWLOntology(), ax);
}
项目:elk-reasoner    文件:OwlOntologyChangeProcessorVisitor.java   
@Override
public void visit(RemoveAxiom arg) {
    ElkAxiom elkAxiom = OWL_CONVERTER_.convert(arg.getAxiom());

    axiomDeleter_.visit(elkAxiom);

    if (LOGGER_.isTraceEnabled())
        LOGGER_.trace("removing " + arg.getAxiom());

}
项目:snorocket    文件:SnorocketOWLReasoner.java   
/**
 * Gets the axioms that as a result of ontology changes need to removed to
 * the reasoner to synchronise it with the root ontology imports closure. If
 * the buffering mode is
 * {@link org.semanticweb.owlapi.reasoner.BufferingMode#NON_BUFFERING} then
 * there will be no pending axiom additions.
 *
 * @return The set of axioms that need to added to the reasoner to the
 *         reasoner to synchronise it with the root ontology imports
 *         closure.
 */
@Override
public Set<OWLAxiom> getPendingAxiomRemovals() {
    Set<OWLAxiom> removed = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : rawChanges) {
        if (change instanceof RemoveAxiom) {
            removed.add(change.getAxiom());
        }
    }
    return removed;
}