/** * <p> * Answer a resource that represents an anonymous property restriction in this model. A new * anonymous resource of <code>rdf:type R</code>, where R is the restriction type from the * language profile. * </p> * * @param p The property that is restricted by this restriction * @return An anonymous Restriction resource. */ @Override public Restriction createRestriction( Property p ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), null ); if (p != null) { r.setOnProperty( p ); } return r; }
/** * <p> * Answer a resource that represents an anonymous property restriction in this model. A new * anonymous resource of <code>rdf:type R</code>, where R is the restriction type from the * language profile. * </p> * * @param p The property that is restricted by this restriction * @return An anonymous Restriction resource. */ @Override public Restriction createRestriction( Property p ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), null ); if (p != null) { r.setOnProperty( p ); } return r; }
/** * <p> * Answer a resource that represents a property restriction in this model. If a resource * with the given uri exists in the model, it will be re-used. If not, a new one is created in * the updateable sub-graph of the ontology model. * </p> * * @param uri The uri for the restriction node, or null for an anonymous restriction. * @param p The property that is restricted by this restriction * @return A Restriction resource. */ @Override public Restriction createRestriction( String uri, Property p ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), uri ); if (p != null) { r.setOnProperty( p ); } return r; }
/** * <p> * Answer a resource that represents a property restriction in this model. If a resource * with the given uri exists in the model, it will be re-used. If not, a new one is created in * the updateable sub-graph of the ontology model. * </p> * * @param uri The uri for the restriction node, or null for an anonymous restriction. * @param p The property that is restricted by this restriction * @return A Restriction resource. */ @Override public Restriction createRestriction( String uri, Property p ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), uri ); if (p != null) { r.setOnProperty( p ); } return r; }
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); OntProperty p = m.createObjectProperty( NS + "p" ); OntProperty q = m.createObjectProperty( NS + "q" ); OntClass B = m.createClass( NS + "B" ); Restriction A = m.createAllValuesFromRestriction( NS + "A", p, B ); assertEquals( "Restriction should be on property p", p, A.getOnProperty() ); assertTrue( "Restriction should be on property p", A.onProperty( p ) ); assertTrue( "Restriction should not be on property q", !A.onProperty( q ) ); assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ON_PROPERTY() )); A.setOnProperty( q ); assertEquals( "Restriction should be on property q", q, A.getOnProperty() ); assertTrue( "Restriction should not be on property p", !A.onProperty( p ) ); assertTrue( "Restriction should not on property q", A.onProperty( q ) ); assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ON_PROPERTY() )); A.removeOnProperty( p ); assertTrue( "Should have q as on property", A.onProperty( q ) ); A.removeOnProperty( q ); assertTrue( "Should not have q as on property", !A.onProperty( q ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); OntProperty p = m.createObjectProperty( NS + "p" ); OntProperty q = m.createObjectProperty( NS + "q" ); OntClass B = m.createClass( NS + "B" ); Restriction A = m.createAllValuesFromRestriction( NS + "A", p, B ); assertEquals( "Restriction should be on property p", p, A.getOnProperty() ); assertTrue( "Restriction should be on property p", A.onProperty( p ) ); assertTrue( "Restriction should not be on property q", !A.onProperty( q ) ); assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ON_PROPERTY() )); A.setOnProperty( q ); assertEquals( "Restriction should be on property q", q, A.getOnProperty() ); assertTrue( "Restriction should not be on property p", !A.onProperty( p ) ); assertTrue( "Restriction should not on property q", A.onProperty( q ) ); assertEquals( "cardinality should be 1 ", 1, A.getCardinality( prof.ON_PROPERTY() )); A.removeOnProperty( p ); assertTrue( "Should have q as on property", A.onProperty( q ) ); A.removeOnProperty( q ); assertTrue( "Should not have q as on property", !A.onProperty( q ) ); } },