@Override public List<VClass> getUnionComponents() { List<VClass> unionComponents = new ArrayList<VClass>(); if (isUnion()) { UnionClass union = this.cls.as(UnionClass.class); Iterator<? extends OntClass> opIt = union.listOperands(); while(opIt.hasNext()) { OntClass component = opIt.next(); if (!component.isAnon()) { unionComponents.add(new VClassJena(component, this.webappDaoFactory)); } } } return unionComponents; }
for (OntClass operand : u.listOperands().toList()) { VClass vc = new VClassJena(operand, getWebappDaoFactory()); ents.addAll(getIndividualsByVClass(vc));
UnionClass icls = cls.as(UnionClass.class); for (Iterator<? extends OntClass> operandIt = icls.listOperands(); operandIt.hasNext();) { OntClass operand = operandIt.next(); labelStr.append(getLabelForClass(operand, withPrefix, forPickList));
for (OntClass operand : u.listOperands().toList()) { VClass vc = new VClassJena(operand, getWebappDaoFactory()); ents.addAll(getIndividualsByVClass(vc));
/** * Bug report from David A Bigwood */ public void test_domainInf() { // create an OntModel OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF, null ); // populate the model with stuff String NS = "http://m3t4.com/ont/#"; OntClass c1 = m.createClass( NS + "c1" ); OntClass c2 = m.createClass( NS + "c2" ); OntClass c3 = m.createClass( NS + "c3" ); OntProperty p1 = m.createObjectProperty( NS + "p1" ); // create a union class to contain the union operands UnionClass uc = m.createUnionClass(null, null); // add an operand uc.addOperand( c1 ); assertEquals( "Size should be 1", 1, uc.getOperands().size() ); assertTrue( "uc should have c1 as union member", uc.getOperands().contains( c1 ) ); // add another operand uc.addOperand( c2 ); assertEquals( "Size should be 2", 2, uc.getOperands().size() ); TestUtil.assertIteratorValues(this, uc.listOperands(), new Object[] { c1, c2 } ); // add a third operand uc.addOperand( c3 ); assertEquals( "Size should be 3", 3, uc.getOperands().size() ); TestUtil.assertIteratorValues(this, uc.listOperands(), new Object[] { c1, c2, c3} ); // add union class as domain of a property p1.addDomain(uc); }
/** * Bug report from David A Bigwood */ public void test_domainInf() { // create an OntModel OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF, null ); // populate the model with stuff String NS = "http://m3t4.com/ont/#"; OntClass c1 = m.createClass( NS + "c1" ); OntClass c2 = m.createClass( NS + "c2" ); OntClass c3 = m.createClass( NS + "c3" ); OntProperty p1 = m.createObjectProperty( NS + "p1" ); // create a union class to contain the union operands UnionClass uc = m.createUnionClass(null, null); // add an operand uc.addOperand( c1 ); assertEquals( "Size should be 1", 1, uc.getOperands().size() ); assertTrue( "uc should have c1 as union member", uc.getOperands().contains( c1 ) ); // add another operand uc.addOperand( c2 ); assertEquals( "Size should be 2", 2, uc.getOperands().size() ); TestUtil.assertIteratorValues(this, uc.listOperands(), new Object[] { c1, c2 } ); // add a third operand uc.addOperand( c3 ); assertEquals( "Size should be 3", 3, uc.getOperands().size() ); TestUtil.assertIteratorValues(this, uc.listOperands(), new Object[] { c1, c2, c3} ); // add union class as domain of a property p1.addDomain(uc); }
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) { OntClass operand = (OntClass) operandIt.next(); labelStr.append(getLabelForClass(operand, withPrefix, forPickList, wadf));
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); UnionClass A = m.createUnionClass( NS + "A", null ); OntClass B = m.createClass( NS + "B" ); OntClass C = m.createClass( NS + "C" ); A.addOperand( B ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have a as union member", A.getOperands().contains( B ) ); A.addOperand( C ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 2", 2, A.getOperands().size() ); iteratorTest( A.listOperands(), new Object[] {B,C} ); ClosableIterator<? extends Resource> i = A.listOperands(); assertTrue( "Argument should be an OntClass", i.next() instanceof OntClass ); i.close(); A.setOperands( m.createList( new RDFNode[] {C} ) ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have C in the union", A.hasOperand( C ) ); assertTrue( "A should not have B in the union", !A.hasOperand( B ) ); A.removeOperand( B ); assertTrue( "Should have C as an operand", A.hasOperand( C ) ); A.removeOperand( C ); assertTrue( "Should not have C as an operand", !A.hasOperand( C ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); UnionClass A = m.createUnionClass( NS + "A", null ); OntClass B = m.createClass( NS + "B" ); OntClass C = m.createClass( NS + "C" ); A.addOperand( B ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have a as union member", A.getOperands().contains( B ) ); A.addOperand( C ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 2", 2, A.getOperands().size() ); iteratorTest( A.listOperands(), new Object[] {B,C} ); ClosableIterator<? extends Resource> i = A.listOperands(); assertTrue( "Argument should be an OntClass", i.next() instanceof OntClass ); i.close(); A.setOperands( m.createList( new RDFNode[] {C} ) ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.UNION_OF() ) ); assertEquals( "Size should be 1", 1, A.getOperands().size() ); assertTrue( "A should have C in the union", A.hasOperand( C ) ); assertTrue( "A should not have B in the union", !A.hasOperand( B ) ); A.removeOperand( B ); assertTrue( "Should have C as an operand", A.hasOperand( C ) ); A.removeOperand( C ); assertTrue( "Should not have C as an operand", !A.hasOperand( C ) ); } },