Search in sources :

Example 6 with AddAxiom

use of org.semanticweb.owlapi.model.AddAxiom in project stanbol by apache.

the class ScopeSetRenderer method getScopes.

public static OWLOntology getScopes(Set<Scope> scopes) {
    OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
    OWLOntology ont = null;
    try {
        ont = mgr.createOntology();
    } catch (OWLOntologyCreationException e) {
        LoggerFactory.getLogger(ScopeSetRenderer.class).error("KReS :: could not create empty ontology for rendering scopes.", e);
        return null;
    }
    List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
    // The ODP metadata vocabulary is always imported.
    // TODO : also import the ONM meta when it goes online.
    additions.add(new AddImport(ont, __factory.getOWLImportsDeclaration(IRI.create("http://www.ontologydesignpatterns.org/schemas/meta.owl"))));
    for (Scope scope : scopes) {
        OWLNamedIndividual iScope = __factory.getOWLNamedIndividual(IRI.create(scope.getDefaultNamespace() + scope.getID()));
        OWLAxiom ax = __factory.getOWLClassAssertionAxiom(cScope, iScope);
        additions.add(new AddAxiom(ont, ax));
    }
    mgr.applyChanges(additions);
    return ont;
}
Also used : AddAxiom(org.semanticweb.owlapi.model.AddAxiom) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) Scope(org.apache.stanbol.ontologymanager.servicesapi.scope.Scope) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) AddImport(org.semanticweb.owlapi.model.AddImport) LinkedList(java.util.LinkedList)

Example 7 with AddAxiom

use of org.semanticweb.owlapi.model.AddAxiom in project stanbol by apache.

the class TestOntologySpaces method setup.

@BeforeClass
public static void setup() throws Exception {
    factory = onManager.getOntologySpaceFactory();
    if (factory == null)
        fail("Could not instantiate ontology space factory");
    OWLOntologyManager mgr = OWLOntologyManagerFactory.createOWLOntologyManager(onManager.getOfflineConfiguration().getOntologySourceLocations().toArray(new IRI[0]));
    OWLDataFactory df = mgr.getOWLDataFactory();
    ont = mgr.createOntology(baseIri);
    inMemorySrc = new RootOntologySource(ont);
    // Let's state that Linus is a human being
    OWLClass cHuman = df.getOWLClass(IRI.create(baseIri + "/" + Constants.humanBeing));
    OWLIndividual iLinus = df.getOWLNamedIndividual(IRI.create(baseIri + "/" + Constants.linus));
    linusIsHuman = df.getOWLClassAssertionAxiom(cHuman, iLinus);
    mgr.applyChange(new AddAxiom(ont, linusIsHuman));
    ont2 = mgr.createOntology(baseIri2);
    minorSrc = new RootOntologySource(ont2);
    dropSrc = getLocalSource("/ontologies/droppedcharacters.owl", mgr);
    nonexSrc = getLocalSource("/ontologies/nonexistentcharacters.owl", mgr);
    minorSrc = new RootOntologySource(ont2);
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) AddAxiom(org.semanticweb.owlapi.model.AddAxiom) RootOntologySource(org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologySource) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual) BeforeClass(org.junit.BeforeClass)

Aggregations

AddAxiom (org.semanticweb.owlapi.model.AddAxiom)7 IRI (org.semanticweb.owlapi.model.IRI)5 OWLClass (org.semanticweb.owlapi.model.OWLClass)5 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)5 OWLAnnotationAssertionAxiom (org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom)3 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)3 OWLClassAssertionAxiom (org.semanticweb.owlapi.model.OWLClassAssertionAxiom)3 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)3 OWLDataProperty (org.semanticweb.owlapi.model.OWLDataProperty)3 OWLDataPropertyAssertionAxiom (org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom)3 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)3 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)3 OWLObjectPropertyAssertionAxiom (org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom)3 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)3 OWLOntologyChange (org.semanticweb.owlapi.model.OWLOntologyChange)3 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)3 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)3 LinkedList (java.util.LinkedList)2 AddImport (org.semanticweb.owlapi.model.AddImport)2 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)2