private void printRestrictions() { TBoxReasonerModule reasoner = ApplicationUtils.instance().getTBoxReasonerModule(); for (Restriction rest : reasoner.listRestrictions() ) { if (rest.isAllValuesFromRestriction()) { log.trace("All values from: "); AllValuesFromRestriction avfr = rest.asAllValuesFromRestriction(); Resource res = avfr.getAllValuesFrom(); if (res.canAs(OntClass.class)) { OntClass resClass = res.as(OntClass.class); for (Resource inst : resClass.listInstances().toList() ) { log.trace(" -"+inst.getURI()); } } } else if (rest.isSomeValuesFromRestriction()) { log.trace("Some values from: "); } else if (rest.isHasValueRestriction()) { log.trace("Has value: "); } log.trace("On property "+rest.getOnProperty().getURI()); for (Resource inst : rest.listInstances().toList() ) { log.trace(" "+inst.getURI()); } } }
try { results.add("XX"); Property onProperty = rest.getOnProperty(); ObjectProperty op = opDao.getObjectPropertyByURI(onProperty.getURI()); results.add(op.getPickListName());
if (cls.isRestriction()) { Restriction rest = cls.asRestriction(); OntProperty onProperty = rest.getOnProperty(); StringBuilder labelStr = new StringBuilder(); labelStr.append("restriction on ").append(getLabelOrId(onProperty)).append(": ");
OntProperty onProperty = rest.getOnProperty(); if (onProperty != null) { Resource[] ranges = new Resource[2];
@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 ) ); } },
if (cls.isRestriction()) { Restriction rest = cls.asRestriction(); OntProperty onProperty = rest.getOnProperty(); String labelStr = "restriction on " + getLabelOrId(onProperty) + ": "; if (rest.isAllValuesFromRestriction() || rest.isSomeValuesFromRestriction()) {