Java 类org.semanticweb.owlapi.model.parameters.ChangeApplied 实例源码

项目:OWLAx    文件:IntegrateOntologyWithProtege.java   
private boolean commitDeclarations() {
    // editor.status("Integrating Declaration axioms with Protege ");
    if (declarationAxioms != null && !declarationAxioms.isEmpty()) {
        // declarationAxioms
        List<OWLOntologyChange> declarations = new ArrayList<OWLOntologyChange>();
        for (OWLAxiom declarationAxiom : declarationAxioms) {

            declarations.add(new AddAxiom(activeOntology, declarationAxiom));

        }
        ChangeApplied changeResult = owlOntologyManager.applyChanges(declarations);
        if (changeResult == ChangeApplied.SUCCESSFULLY) {
            editor.status("Declaration axioms integrated with protege successfully.");
            return true;
        } else if (changeResult == ChangeApplied.UNSUCCESSFULLY) {
            editor.status("Declaration integration with Protege unsuccessfull.");
            return false;
        } else if (changeResult == ChangeApplied.NO_OPERATION) {
            editor.status(
                    "Declaration axioms are duplicate. Possible reason: trying to create new OWL Entity which IRI match with existing OWLEntity IRI.");
            return false;
        }
    } else {

        editor.status("");
        return false;
    }

    return false;
}
项目:OWLAx    文件:IntegrateOntologyWithProtege.java   
private boolean saveOWLAxioms() {
    editor.status("Integrating axioms with Protege");
    if (changes != null) {
        ChangeApplied changeResult = owlOntologyManager.applyChanges(changes);
        if (changeResult == ChangeApplied.SUCCESSFULLY) {
            editor.status("All axioms integrated with protege successfully.");
            return true;
        } else if (changeResult == ChangeApplied.UNSUCCESSFULLY) {
            editor.status("Axiom integration with Protege unsuccessfull.");
            return false;
        } else if (changeResult == ChangeApplied.NO_OPERATION) {
            editor.status("Selected axioms are duplicate. No operation carried out (change had no effect)");
            return false;
        }
    } else
        return false;

    return false;
}
项目:minerva    文件:ModelContainer.java   
public List<OWLOntologyChange> applyChanges(List<? extends OWLOntologyChange> changes) {
    ChangeApplied applied = getOWLOntologyManager().applyChanges(changes);
    if (applied == ChangeApplied.SUCCESSFULLY) {
        List<OWLOntologyChange> relevantChanges = new ArrayList<>();
        for (OWLOntologyChange change : changes) {
            if (aboxOntology.equals(change.getOntology())) {
                aboxModified = true;
                relevantChanges.add(change);
            }
        }
        if (relevantChanges.isEmpty() == false) {
            for(ModelChangeListener listener : listeners) {
                listener.handleChange(relevantChanges);
            }
        }
    }
    return new ArrayList<OWLOntologyChange>(changes);
}
项目:owltools    文件:AssertInferenceTool.java   
private static List<OWLOntologyChange> handleSupportOntologies(OWLGraphWrapper graph)
{
    OWLOntology ontology = graph.getSourceOntology();
    OWLOntologyManager manager = ontology.getOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();

    List<OWLOntologyChange> removeImportChanges = new ArrayList<OWLOntologyChange>();
    Set<OWLOntology> supportOntologySet = graph.getSupportOntologySet();
    for (OWLOntology support : supportOntologySet) {
        Optional<IRI> supportIRI = support.getOntologyID().getOntologyIRI();
        if(supportIRI.isPresent()) {
            IRI ontologyIRI = supportIRI.get();
            OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(ontologyIRI);
            ChangeApplied status = manager.applyChange(new AddImport(ontology, importDeclaration));
            if (ChangeApplied.SUCCESSFULLY == status) {
                // the change was successful, create remove import for later
                removeImportChanges.add(new RemoveImport(ontology, importDeclaration));
            }
        }
    }
    return removeImportChanges;
}
项目:jopa    文件:OntologySnapshot.java   
/**
 * Applies the specified changes to this ontology snapshot.
 *
 * @param changes The changes to apply
 * @return The applied changes
 */
public List<OWLOntologyChange> applyChanges(List<OWLOntologyChange> changes) {
    final ChangeApplied result = ontologyManager.applyChanges(changes);
    if (result == ChangeApplied.UNSUCCESSFULLY) {
        throw new OntologyChangeApplicationException(
                "At least one of the following changes could not have been applied to this ontology snapshot: " +
                        changes);
    }
    return changes;
}
项目:owltools    文件:OWLGraphManipulator.java   
/**
 * Add {@code edge} to its related ontology. 
 * This method transforms the {@code OWLGraphEdge} {@code edge} 
 * into an {@code OWLSubClassOfAxiom}, then add it to the ontology   
    * and update the {@code OWLGraphWrapper} container. 
 * 
 * @param edge      The {@code OWLGraphEdge} to be added to its related ontology. 
 * @return          {@code true} if {@code edge} was actually added 
 *                  to the ontology. 
 */
public boolean addEdge(OWLGraphEdge edge) {
    //this.getAxiom was used here in former versions
    OWLSubClassOfAxiom newAxiom = edge.getOntology().getOWLOntologyManager().
       getOWLDataFactory().getOWLSubClassOfAxiom(
           (OWLClassExpression) this.getOwlGraphWrapper().edgeToSourceExpression(edge), 
           (OWLClassExpression) this.getOwlGraphWrapper().edgeToTargetExpression(edge));

    ChangeApplied status = edge.getOntology().getOWLOntologyManager().addAxiom(
            edge.getOntology(), newAxiom);
    this.triggerWrapperUpdate();
    return (status != ChangeApplied.UNSUCCESSFULLY);
}
项目:owltools    文件:OWLGraphManipulator.java   
/**
 * Convenient method to apply {@code changes} to the ontology.
 * 
 * @param changes   The {@code List} of {@code OWLOntologyChange}s 
 *                  to be applied to the ontology. 
 * @return          {@code true} if all changes were applied, 
 *                  {@code false} otherwise. 
 */
private boolean applyChanges(List<? extends OWLOntologyChange> changes) {

    ChangeApplied status = this.getOwlGraphWrapper().getManager().applyChanges(changes);
    if (status != ChangeApplied.UNSUCCESSFULLY) {
        return true;
    }
    return false;
}
项目:java-skos-api    文件:SKOSManager.java   
public List<SKOSChange> applyChanges(List<SKOSChange> change) throws SKOSChangeException {

        List<OWLOntologyChange> ch = new ArrayList<OWLOntologyChange>();

        Map<OWLOntologyChange, SKOSChange> newChanges = new HashMap<OWLOntologyChange, SKOSChange>();

        for (SKOSChange skCh : change) {
            SKOSChangeUtility util = new SKOSChangeUtility(skCh.getSKOSDataset(), skCh.getSKOSAssertion());
            if (skCh.isAdd()) {
                AddAxiom addAx = util.getAddAxiom();
                ch.add(addAx);
                newChanges.put(addAx, skCh);
            }
            else {
                RemoveAxiom remAx = util.getRemoveAxiom();
                ch.add(remAx);
                newChanges.put(remAx, skCh);
            }
        }


        List<SKOSChange> succesfulChanges = new ArrayList<SKOSChange>();

        ChangeApplied OWLChange = null;

        try {
            OWLChange = man.applyChanges(ch);
        } catch (OWLOntologyChangeException e) {
            throw new SKOSChangeException(newChanges.get(e.getChange()), e);
        }

        if (null != OWLChange && OWLChange.equals(ChangeApplied.SUCCESSFULLY)) {
            succesfulChanges.addAll(newChanges.values());
        }
        return succesfulChanges;
    }
项目:java-skos-api    文件:SKOSManager.java   
public List<SKOSChange> applyChange(SKOSChange change) throws SKOSChangeException {

        SKOSAssertion as = change.getSKOSAssertion();
        SKOSDataset dataSet = change.getSKOSDataset();

        SKOSChangeUtility util = new SKOSChangeUtility(dataSet, as);

        List<SKOSChange> succesfulChanges = new ArrayList<SKOSChange>();

        ChangeApplied OWLChange = null;

        try {
            OWLAxiomChange cha;
            if (change.isAdd()) {
                AddAxiom addAx = util.getAddAxiom();
                OWLChange = man.applyChange(addAx);
            }
            else if (change.isRemove()) {
                RemoveAxiom remAx = util.getRemoveAxiom();
                OWLChange = man.applyChange(remAx);
            }
        } catch (OWLOntologyChangeException e) {
            throw new SKOSChangeException(change, e);
        }

        return succesfulChanges;
    }
项目:owltools    文件:OWLGraphManipulator.java   
/**
 * Remove {@code edge} from its ontology. It means that the {@code OWLAxiom}s 
 * returned by the method {@code OWLGraphEdge#getAxioms()}, that allowed to generate 
 * {@code edge}, will be removed from the ontology. 
 * 
 * @param edge     The {@code OWLGraphEdge} to be removed from the ontology. 
 * @return         {@code true} if all underlying {@code OWLAxiom}s of {@code edge} 
 *                 were actually present in its ontology, and removed. 
 * @see #removeEdges(Collection)
 */
public boolean removeEdge(OWLGraphEdge edge) {
    ChangeApplied status = edge.getOntology().getOWLOntologyManager().removeAxioms(
            edge.getOntology(), edge.getAxioms());
    this.triggerWrapperUpdate();
    return (status != ChangeApplied.UNSUCCESSFULLY);
}