use of org.semanticweb.owlapi.model.OWLOntologyID in project webprotege by protegeproject.
the class OntologyIdData_CustomFieldSerializer method serialize.
public static void serialize(SerializationStreamWriter streamWriter, OntologyIdData instance) throws SerializationException {
OWLOntologyID ontologyID = instance.getObject();
streamWriter.writeBoolean(ontologyID.isAnonymous());
if (!ontologyID.isAnonymous()) {
streamWriter.writeString(ontologyID.getOntologyIRI().toString());
if (ontologyID.getVersionIRI() != null) {
streamWriter.writeString(ontologyID.getVersionIRI().toString());
} else {
streamWriter.writeString("");
}
}
streamWriter.writeString(instance.getBrowserText());
}
use of org.semanticweb.owlapi.model.OWLOntologyID in project stanbol by apache.
the class TestClerezzaSpaces method testCreateSpace.
@Test
public void testCreateSpace() throws Exception {
OntologySpace space = factory.createCustomOntologySpace(scopeId, dropSrc);
OWLOntologyID logicalId = null;
Object o = dropSrc.getRootOntology();
if (o instanceof Graph)
logicalId = OWLUtils.extractOntologyID((Graph) o);
else if (o instanceof OWLOntology)
logicalId = OWLUtils.extractOntologyID((OWLOntology) o);
assertNotNull(logicalId);
assertTrue(space.hasOntology(logicalId));
}
use of org.semanticweb.owlapi.model.OWLOntologyID in project stanbol by apache.
the class LibraryImpl method loadOntologies.
@Override
public synchronized void loadOntologies(OntologyProvider<?> loader) {
if (loader == null)
throw new IllegalArgumentException("A null loader is not allowed.");
for (RegistryItem item : getChildren()) {
if (item instanceof RegistryOntology) {
RegistryOntology o = (RegistryOntology) item;
IRI id = o.getIRI();
try {
// No preferred key, we don't have a prefix here.
OWLOntologyID key = loader.loadInStore(id, null, false);
if (key == null || key.isAnonymous())
log.error("Empty storage key. Ontology {} was apparently not stored.", id);
} catch (IOException ex) {
log.error("I/O error occurred loading {}", id);
}
}
}
loaded = true;
}
use of org.semanticweb.owlapi.model.OWLOntologyID in project stanbol by apache.
the class HermitReasoningServiceTest method testRun.
private void testRun(String testID, String expectedID) {
log.info("Testing the run() method");
OWLOntologyManager manager = TestData.manager;
// We prepare the input ontology
try {
OWLOntology testOntology = manager.createOntology();
OWLOntologyID testOntologyID = testOntology.getOntologyID();
log.debug("Created test ontology with ID: {}", testOntologyID);
AddImport addImport = new AddImport(testOntology, TestData.factory.getOWLImportsDeclaration(IRI.create(testID)));
manager.applyChange(addImport);
// We just test class assertions
List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
gens.add(new InferredClassAssertionAxiomGenerator());
// Maybe we want to see what is in before
if (log.isDebugEnabled())
TestUtils.debug(manager.getOntology(testOntologyID), log);
// Now we test the method
log.debug("Running HermiT");
Set<OWLAxiom> inferred = this.theinstance.run(manager.getOntology(testOntologyID), gens);
// Maybe we want to see the inferred axiom list
if (log.isDebugEnabled()) {
TestUtils.debug(inferred, log);
}
// These are the set of expected axioms
Set<OWLLogicalAxiom> expectedAxioms = manager.getOntology(IRI.create(expectedID)).getLogicalAxioms();
Set<OWLAxiom> missing = new HashSet<OWLAxiom>();
for (OWLAxiom expected : expectedAxioms) {
if (!inferred.contains(expected)) {
log.error("missing expected axiom: {}", expected);
missing.add(expected);
}
}
log.info("Are all expected axioms in the result (true)? {}", missing.isEmpty());
assertTrue(missing.isEmpty());
// We want to remove the ontology from the manager
manager.removeOntology(testOntology);
} catch (OWLOntologyCreationException e) {
log.error("An {} have been thrown while creating the input ontology for test", e.getClass());
assertTrue(false);
} catch (org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException e) {
log.error("An {} have been thrown while executing the reasoning", e.getClass());
assertTrue(false);
} catch (org.apache.stanbol.reasoners.servicesapi.InconsistentInputException e) {
log.error("An {} have been thrown while executing the reasoning", e.getClass());
assertTrue(false);
}
}
use of org.semanticweb.owlapi.model.OWLOntologyID in project stanbol by apache.
the class TestOWLUtils method lookaheadVersionedDistance100Reversed.
/*
* Guessing the ID of an ontology whose ontology IRI is declared >100 triples after its version IRI.
*/
@Test
public void lookaheadVersionedDistance100Reversed() throws Exception {
// Actual distance is 102
String location = "/owl/versioned_distance-100-reversed.owl";
log.info("Testing lookahead for location {}", location);
org.semanticweb.owlapi.model.IRI incubatedVersion = org.semanticweb.owlapi.model.IRI.create("http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/owl/src/test/resources/owl/versioned_distance-100-reversed.owl");
OWLOntologyID expectedOntId = new OWLOntologyID(ontologyIri, incubatedVersion);
// No triple limit but offset < 102 : guessing should fail.
InputStream content = getClass().getResourceAsStream(location);
OWLOntologyID id = OWLUtils.guessOntologyID(content, parser, TURTLE, -1, 99);
assertTrue(id.isAnonymous());
// Try again, setting limit = 1024 (offset = 102) should work.
content = getClass().getResourceAsStream(location);
id = OWLUtils.guessOntologyID(content, parser, TURTLE, 1024);
assertNotNull(id);
assertFalse(id.isAnonymous());
assertEquals(expectedOntId, id);
}
Aggregations