@Override public Ontology createOntology(String uri) { return inner.createOntology(uri); }
@Override public OntResource doCreate( OntModel m ) { return m.createOntology( BASE ); } @Override
@Override public OntResource doCreate( OntModel m ) { return m.createOntology( BASE ); } @Override
final Ontology imprtOnt = imprt.createOntology("x-model://a"); final OntClass clazz = imprt.createClass("x-model://a/class"); assertTrue("delcared class should exist in a", imprt.contains(clazz, RDF.type, OWL.Class)); final Ontology modelOnt = model.createOntology("x-model://b"); modelOnt.addImport(imprtOnt);
public String insertNewOntology(Ontology ontology, OntModel ontModel) { if (ontology == null) { return null; } try { String ontologyURI = adjustAndValidateOntologyURI(ontology.getURI()); ontModel.enterCriticalSection(Lock.WRITE); try { org.apache.jena.ontology.Ontology o = ontModel.createOntology(ontologyURI); if (ontology.getName() != null && ontology.getName().length()>0) { o.setLabel(ontology.getName(), getDefaultLanguage()); } if (ontology.getPrefix() != null && ontology.getPrefix().length()>0) { addPropertyStringValue(o,ONTOLOGY_PREFIX_ANNOT,ontology.getPrefix(),ontModel); } return o.getURI(); } finally { ontModel.leaveCriticalSection(); } } catch (URISyntaxException e) { log.warn("Failed to insert new ontology: " + ontology, e); throw new RuntimeException(e); } }
public void testGetOntology() { OntModel m = ModelFactory.createOntologyModel(); Resource r = m.getResource( NS + "r" ); m.add( r, RDF.type, r ); Resource s = m.createOntology( NS + "s" ); assertEquals( "Result of get s", s, m.getOntology( NS + "s" ) ); assertNull( "result of get q", m.getOntology( NS+"q") ); assertNull( "result of get r", m.getOntology( NS+"r")); }
public void testGetOntology() { OntModel m = ModelFactory.createOntologyModel(); Resource r = m.getResource( NS + "r" ); m.add( r, RDF.type, r ); Resource s = m.createOntology( NS + "s" ); assertEquals( "Result of get s", s, m.getOntology( NS + "s" ) ); assertNull( "result of get q", m.getOntology( NS+"q") ); assertNull( "result of get r", m.getOntology( NS+"r")); }
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addIncompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); assertEquals( "x should be in comp with y", y, x.getIncompatibleWith() ); x.addIncompatibleWith( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); iteratorTest( x.listIncompatibleWith(), new Object[] {y,z} ); x.setIncompatibleWith( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); assertEquals( "x should be incomp with z", z, x.getIncompatibleWith() ); x.removeIncompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); x.removeIncompatibleWith( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addBackwardCompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); assertEquals( "x should be back comp with y", y, x.getBackwardCompatibleWith() ); x.addBackwardCompatibleWith( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); iteratorTest( x.listBackwardCompatibleWith(), new Object[] {y,z} ); x.setBackwardCompatibleWith( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); assertEquals( "x should be back comp with z", z, x.getBackwardCompatibleWith() ); x.removeBackwardCompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); x.removeBackwardCompatibleWith( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addPriorVersion( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) ); assertEquals( "x should have prior y", y, x.getPriorVersion() ); x.addPriorVersion( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.PRIOR_VERSION() ) ); iteratorTest( x.listPriorVersion(), new Object[] {y,z} ); x.setPriorVersion( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) ); assertEquals( "x should have prior z", z, x.getPriorVersion() ); x.removePriorVersion( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) ); x.removePriorVersion( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.PRIOR_VERSION() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addIncompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); assertEquals( "x should be in comp with y", y, x.getIncompatibleWith() ); x.addIncompatibleWith( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); iteratorTest( x.listIncompatibleWith(), new Object[] {y,z} ); x.setIncompatibleWith( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); assertEquals( "x should be incomp with z", z, x.getIncompatibleWith() ); x.removeIncompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); x.removeIncompatibleWith( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.INCOMPATIBLE_WITH() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addImport( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) ); assertEquals( "x should import y", y, x.getImport() ); x.addImport( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.IMPORTS() ) ); iteratorTest( x.listImports(), new Object[] {y,z} ); x.setImport( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) ); assertEquals( "x should import z", z, x.getImport() ); x.removeImport( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) ); x.removeImport( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.IMPORTS() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addPriorVersion( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) ); assertEquals( "x should have prior y", y, x.getPriorVersion() ); x.addPriorVersion( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.PRIOR_VERSION() ) ); iteratorTest( x.listPriorVersion(), new Object[] {y,z} ); x.setPriorVersion( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) ); assertEquals( "x should have prior z", z, x.getPriorVersion() ); x.removePriorVersion( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.PRIOR_VERSION() ) ); x.removePriorVersion( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.PRIOR_VERSION() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addBackwardCompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); assertEquals( "x should be back comp with y", y, x.getBackwardCompatibleWith() ); x.addBackwardCompatibleWith( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); iteratorTest( x.listBackwardCompatibleWith(), new Object[] {y,z} ); x.setBackwardCompatibleWith( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); assertEquals( "x should be back comp with z", z, x.getBackwardCompatibleWith() ); x.removeBackwardCompatibleWith( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); x.removeBackwardCompatibleWith( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.BACKWARD_COMPATIBLE_WITH() ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); Ontology x = m.createOntology( NS + "x" ); Ontology y = m.createOntology( NS + "y" ); Ontology z = m.createOntology( NS + "z" ); x.addImport( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) ); assertEquals( "x should import y", y, x.getImport() ); x.addImport( z ); assertEquals( "Cardinality should be 2", 2, x.getCardinality( prof.IMPORTS() ) ); iteratorTest( x.listImports(), new Object[] {y,z} ); x.setImport( z ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) ); assertEquals( "x should import z", z, x.getImport() ); x.removeImport( y ); assertEquals( "Cardinality should be 1", 1, x.getCardinality( prof.IMPORTS() ) ); x.removeImport( z ); assertEquals( "Cardinality should be 0", 0, x.getCardinality( prof.IMPORTS() ) ); } },
public void testAddImports1() { String ns = "http://jena.hpl.hp.com/2003/03/testont"; OntModel base = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); OntDocumentManager odm = OntDocumentManager.getInstance(); odm.addAltEntry( ns + "#a", "file:testing/ontology/testImport7/a.owl" ); OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF, base ); Ontology oo = base.createOntology( ns ); oo.addImport( base.createResource( ns + "#a") ); // nothing is known about a and b yet Resource a = m.getResource( ns + "#A" ); Resource c = m.getResource( ns + "#C" ); assertFalse( m.contains( c, RDFS.subClassOf, a ) ); // when we load the imports, the odm must kick the reasoner with a rebind() m.getDocumentManager().loadImports( m ); assertTrue( m.contains( c, RDFS.subClassOf, a ) ); }
public void testAddImports1() { String ns = "http://jena.hpl.hp.com/2003/03/testont"; OntModel base = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); OntDocumentManager odm = OntDocumentManager.getInstance(); odm.addAltEntry( ns + "#a", "file:testing/ontology/testImport7/a.owl" ); OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF, base ); Ontology oo = base.createOntology( ns ); oo.addImport( base.createResource( ns + "#a") ); // nothing is known about a and b yet Resource a = m.getResource( ns + "#A" ); Resource c = m.getResource( ns + "#C" ); assertFalse( m.contains( c, RDFS.subClassOf, a ) ); // when we load the imports, the odm must kick the reasoner with a rebind() m.getDocumentManager().loadImports( m ); assertTrue( m.contains( c, RDFS.subClassOf, a ) ); }