@Override public OntProperty createOntProperty(String uri) { return inner.createOntProperty(uri); }
private void initOntology() { ontology = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); Map<String, String> prefixMap = ontology.getNsPrefixMap(); prefixMap.put(Constants.ONTMALIZER_BASE_URI_PREFIX, Constants.ONTMALIZER_BASE_URI); ontology.setNsPrefixes(prefixMap); hasValue = ontology.createOntProperty(Constants.ONTMALIZER_VALUE_PROP_NAME); abstractClasses = new ArrayList<>(); mixedClasses = new ArrayList<>(); }
public static void main2( String[] args ) { final String NS = "http://stackoverflow.com/q/20194409/1281433/"; final OntModel model = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM ); OntProperty p = model.createOntProperty( NS+"PropertyName" ); p.addDomain( model.getOntClass( NS+"ClassName" )); p.addRange( RDFS.Literal ); model.write( System.out, "RDF/XML-ABBREV" ); }
@Override public void ontTest( OntModel m ) { OntResource a = m.createOntResource( "http://foo/bar#a" ); Resource b = m.createResource( "http://foo/bar#b" ); OntProperty p = m.createOntProperty( "http://foo/bar#p" ); OntProperty q = m.createOntProperty( "http://foo/bar#q" ); m.add( a, p, b ); Object bb = a.getPropertyValue( q ); assertNull( bb ); } },
@Override public void ontTest( OntModel m ) { OntResource a = m.createOntResource( "http://foo/bar#a" ); Resource b = m.createResource( "http://foo/bar#b" ); OntProperty p = m.createOntProperty( "http://foo/bar#p" ); OntProperty q = m.createOntProperty( "http://foo/bar#q" ); m.add( a, p, b ); Object bb = a.getPropertyValue( q ); assertNull( bb ); } },
@Override public void ontTest( OntModel m ) { OntResource a = m.createOntResource( "http://foo/bar#a" ); Resource b = m.createResource( "http://foo/bar#b" ); OntProperty p = m.createOntProperty( "http://foo/bar#p" ); m.add( a, p, b ); Object bb = a.getPropertyValue( p ); assertEquals( b, bb ); assertTrue( "Return value should be an OntResource", bb instanceof OntResource ); } },
@Override public void ontTest( OntModel m ) { OntResource a = m.createOntResource( "http://foo/bar#a" ); Resource b = m.createResource( "http://foo/bar#b" ); OntProperty p = m.createOntProperty( "http://foo/bar#p" ); m.add( a, p, b ); Object bb = a.getPropertyValue( p ); assertEquals( b, bb ); assertTrue( "Return value should be an OntResource", bb instanceof OntResource ); } },
/** * Test LDP with anonymous classes */ public void testListDeclaredProperties1() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); OntProperty p = m.createOntProperty( NS + "p" ); OntClass a = m.createClass( NS + "a" ); Restriction r = m.createMinCardinalityRestriction( null, p, 1 ); r.addSubClass( a ); Iterator<OntProperty> i = a.listDeclaredProperties(); TestUtil.assertIteratorLength( a.listDeclaredProperties(), 1 ); }
/** * Test LDP with anonymous classes */ public void testListDeclaredProperties1() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); OntProperty p = m.createOntProperty( NS + "p" ); OntClass a = m.createClass( NS + "a" ); Restriction r = m.createMinCardinalityRestriction( null, p, 1 ); r.addSubClass( a ); Iterator<OntProperty> i = a.listDeclaredProperties(); TestUtil.assertIteratorLength( a.listDeclaredProperties(), 1 ); }
public void testOwlLiteClasses() { OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM_TRANS_INF ); OntClass b = model.createClass( NS + "B" ); OntProperty p0 = model.createOntProperty( NS + "p0" ); ObjectProperty p1 = model.createObjectProperty( NS + "p1" ); DatatypeProperty p2 = model.createDatatypeProperty( NS + "p2" ); Individual i0 = model.createIndividual( NS + "i0", b ); model.setStrictMode( true ); for (OntResource r: new OntResource[] {b,p0,p1,p2}) { assertFalse( r + " should not be an individual", r.canAs( Individual.class )); } }
public void testOwlLiteClasses() { OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM_TRANS_INF ); OntClass b = model.createClass( NS + "B" ); OntProperty p0 = model.createOntProperty( NS + "p0" ); ObjectProperty p1 = model.createObjectProperty( NS + "p1" ); DatatypeProperty p2 = model.createDatatypeProperty( NS + "p2" ); Individual i0 = model.createIndividual( NS + "i0", b ); model.setStrictMode( true ); for (OntResource r: new OntResource[] {b,p0,p1,p2}) { assertFalse( r + " should not be an individual", r.canAs( Individual.class )); } }
public void testGetOntProperty() { OntModel m = ModelFactory.createOntologyModel(); Resource r = m.getResource( NS + "r" ); m.add( r, RDF.type, r ); Resource s = m.createOntProperty( NS + "s" ); assertEquals( "Result of get s", s, m.getOntProperty( NS + "s" ) ); assertNull( "result of get q", m.getOntProperty( NS+"q") ); assertNull( "result of get r", m.getOntProperty( NS+"r")); }
public void testGetOntProperty() { OntModel m = ModelFactory.createOntologyModel(); Resource r = m.getResource( NS + "r" ); m.add( r, RDF.type, r ); Resource s = m.createOntProperty( NS + "s" ); assertEquals( "Result of get s", s, m.getOntProperty( NS + "s" ) ); assertNull( "result of get q", m.getOntProperty( NS+"q") ); assertNull( "result of get r", m.getOntProperty( NS+"r")); }
public void testListOntProperties1() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); assertTrue( iteratorContains( m.listOntProperties(), op ) ); assertTrue( iteratorContains( m.listOntProperties(), dp ) ); // note that owl:AnnotationProperty is an rdf:Property in OWL Full assertTrue( iteratorContains( m.listOntProperties(), ap ) ); assertTrue( iteratorContains( m.listOntProperties(), ontp ) ); assertTrue( iteratorContains( m.listOntProperties(), rdfp ) ); }
public void testListObjectProperties0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); // no rdf:type entailment, so we don't find most properties ... assertTrue( iteratorContains( m.listObjectProperties(), op ) ); assertFalse( iteratorContains( m.listObjectProperties(), dp ) ); assertFalse( iteratorContains( m.listObjectProperties(), ap ) ); assertFalse( iteratorContains( m.listObjectProperties(), ontp ) ); assertFalse( iteratorContains( m.listObjectProperties(), rdfp ) ); }
public void testListAllOntProperties0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); // no rdf:type entailment, so we don't find most properties ... assertTrue( iteratorContains( m.listAllOntProperties(), op ) ); assertTrue( iteratorContains( m.listAllOntProperties(), dp ) ); assertTrue( iteratorContains( m.listAllOntProperties(), ap ) ); assertTrue( iteratorContains( m.listAllOntProperties(), ontp ) ); assertTrue( iteratorContains( m.listAllOntProperties(), rdfp ) ); }
public void testListObjectProperties0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); // no rdf:type entailment, so we don't find most properties ... assertTrue( iteratorContains( m.listObjectProperties(), op ) ); assertFalse( iteratorContains( m.listObjectProperties(), dp ) ); assertFalse( iteratorContains( m.listObjectProperties(), ap ) ); assertFalse( iteratorContains( m.listObjectProperties(), ontp ) ); assertFalse( iteratorContains( m.listObjectProperties(), rdfp ) ); }
public void testListAnnotationProperties0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); // no rdf:type entailment, so we don't find most properties ... assertFalse( iteratorContains( m.listAnnotationProperties(), op ) ); assertFalse( iteratorContains( m.listAnnotationProperties(), dp ) ); assertTrue( iteratorContains( m.listAnnotationProperties(), ap ) ); assertFalse( iteratorContains( m.listAnnotationProperties(), ontp ) ); assertFalse( iteratorContains( m.listAnnotationProperties(), rdfp ) ); }
public void testListDatatypeProperties0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); // no rdf:type entailment, so we don't find most properties ... assertFalse( iteratorContains( m.listDatatypeProperties(), op ) ); assertTrue( iteratorContains( m.listDatatypeProperties(), dp ) ); assertFalse( iteratorContains( m.listDatatypeProperties(), ap ) ); assertFalse( iteratorContains( m.listDatatypeProperties(), ontp ) ); assertFalse( iteratorContains( m.listDatatypeProperties(), rdfp ) ); }
public void testListAnnotationProperties0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); ObjectProperty op = m.createObjectProperty( NS + "op" ); DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" ); AnnotationProperty ap = m.createAnnotationProperty( NS + "ap" ); OntProperty ontp = m.createOntProperty( NS + "ontp" ); Property rdfp = m.createProperty( NS + "rdfp" ); rdfp.addProperty( RDF.type, RDF.Property ); // no rdf:type entailment, so we don't find most properties ... assertFalse( iteratorContains( m.listAnnotationProperties(), op ) ); assertFalse( iteratorContains( m.listAnnotationProperties(), dp ) ); assertTrue( iteratorContains( m.listAnnotationProperties(), ap ) ); assertFalse( iteratorContains( m.listAnnotationProperties(), ontp ) ); assertFalse( iteratorContains( m.listAnnotationProperties(), rdfp ) ); }