public Union union( Graph X ) { return new Union( this, X ); }
public Union union( Graph X ) { return new Union( this, X ); }
/** Answer a new model that is the dynamic union of two other models. By <i>dynamic union</i>, we mean that changes to either <code>m1</code> or <code>m2</code> will be reflected in the result model, and <i>vice versa</i>: specifically, additions to and removals from the union will be implemented as operations on <code>m1</code> <strong>only</strong>. See also the behaviour of OntModel and the MultiUnion class. <p> <code>createUnion</code> only creates two-element unions. */ public static Model createUnion(Model m1, Model m2) { return createModelForGraph( new Union( m1.getGraph(), m2.getGraph() ) ); }
/** Answer a new model that is the dynamic union of two other models. By <i>dynamic union</i>, we mean that changes to either <code>m1</code> or <code>m2</code> will be reflected in the result model, and <i>vice versa</i>: specifically, additions to and removals from the union will be implemented as operations on <code>m1</code> <strong>only</strong>. See also the behaviour of OntModel and the MultiUnion class. <p> <code>createUnion</code> only creates two-element unions. */ public static Model createUnion(Model m1, Model m2) { return createModelForGraph( new Union( m1.getGraph(), m2.getGraph() ) ); }
@Override protected Union createNewGraph() { Graph[] g = { memGraph(), memGraph() }; Union u = new Union(g[0], g[1]); map.put(u, g); return u; }
@Override protected Union createNewGraph() { Graph[] g = { memGraph(), memGraph() }; Union u = new Union(g[0], g[1]); map.put(u, g); return u; }
@Override Graph getGraph() { return new Union(Factory.createGraphMem(), Factory.createGraphMem()); }};
@Override Graph getGraph() { return new Union(Factory.createGraphMem(), Factory.createGraphMem()); }};
@Override public Graph getGraph() { Graph gBase = graphWith( "" ), g1 = graphWith( "" ); return new Union( gBase, g1 ); }
public Union unionOf( String s1, String s2 ) { return new Union( graphWith( s1 ), graphWith ( s2 ) ); }
@Override public Graph getGraph() { Graph gBase = graphWith( "" ), g1 = graphWith( "" ); return new Union( gBase, g1 ); }
public Union unionOf( String s1, String s2 ) { return new Union( graphWith( s1 ), graphWith ( s2 ) ); }
@Test public void testDataPropertyDefinition() { final String ns = "foo://example#"; final String source1 = "@prefix owl: <http://www.w3.org/2002/07/owl#>.\r\n" + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\r\n" + "@prefix : <foo://example#>.\r\n" + ":C rdfs:subClassOf [\n" + " a owl:Class; \n" + " owl:intersectionOf( [\n" + " a owl:Restriction;\n" + " owl:onProperty :p ;\n" + " owl:minCardinality \"1\"\n" + " ] ) ] ."; final String source2 = "@prefix owl: <http://www.w3.org/2002/07/owl#>.\n" + "@prefix : <foo://example#>.\n" + ":p a owl:DatatypeProperty .\n"; final Model model1 = ModelFactory.createDefaultModel(); model1.read(new StringReader(source1), "", "N3"); final Model model2 = ModelFactory.createDefaultModel(); model2.read(new StringReader(source2), "", "N3"); final Model ordered = ModelFactory.createModelForGraph(new Union(model1.getGraph(), model2.getGraph())); final OntModel pellet = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, ordered); final Property p = pellet.getProperty(ns + "p"); assertTrue(pellet.contains(p, RDFS.range, RDFS.Literal)); }
@ContractTest public void testUnion() { Graph g1 = graphWith("x R y; p R q"); Graph g2 = graphWith("r Foo s; x R y"); Union u = new Union(g1, g2); assertContains("Union", "x R y", u); assertContains("Union", "p R q", u); assertContains("Union", "r Foo s", u); if (u.size() != 3) fail("oops: size of union is not 3"); u.add(triple("cats eat cheese")); assertContains("Union", "cats eat cheese", u); if (contains(g1, "cats eat cheese") == false && contains(g2, "cats eat cheese") == false) fail("oops: neither g1 nor g2 contains `cats eat cheese`"); }
@ContractTest public void testUnion() { Graph g1 = graphWith("x R y; p R q"); Graph g2 = graphWith("r Foo s; x R y"); Union u = new Union(g1, g2); assertContains("Union", "x R y", u); assertContains("Union", "p R q", u); assertContains("Union", "r Foo s", u); if (u.size() != 3) fail("oops: size of union is not 3"); u.add(triple("cats eat cheese")); assertContains("Union", "cats eat cheese", u); if (contains(g1, "cats eat cheese") == false && contains(g2, "cats eat cheese") == false) fail("oops: neither g1 nor g2 contains `cats eat cheese`"); }
public void testAdd() { Graph l = graphWith( "x R y" ); Graph r = graphWith( "x R y; p S q" ); Union u = new Union( l, r ); u.add( triple("x R y") ); assertIsomorphic( graphWith( "x R y" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); u.add( triple("p S q") ); assertIsomorphic( graphWith( "x R y; p S q" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); u.add( triple("r A s") ); assertIsomorphic( graphWith( "x R y; p S q; r A s" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); }
public void testUnionReflectsChangesToOperands() { Graph l = graphWith( "x R y" ); Graph r = graphWith( "x R y" ); Union u = new Union( l, r ); assertIsomorphic( graphWith( "x R y" ), u ); l.add( triple( "x R z" ) ); assertIsomorphic( graphWith( "x R y; x R z" ), u ); l.delete( triple( "x R y" ) ); assertIsomorphic( graphWith( "x R y; x R z" ), u ); r.add( triple( "p S q" ) ); assertIsomorphic( graphWith( "x R y; x R z; p S q" ), u ); r.delete( triple( "x R y" ) ); assertIsomorphic( graphWith( "x R z; p S q" ), u ); }
public void testUnionReflectsChangesToOperands() { Graph l = graphWith( "x R y" ); Graph r = graphWith( "x R y" ); Union u = new Union( l, r ); assertIsomorphic( graphWith( "x R y" ), u ); l.add( triple( "x R z" ) ); assertIsomorphic( graphWith( "x R y; x R z" ), u ); l.delete( triple( "x R y" ) ); assertIsomorphic( graphWith( "x R y; x R z" ), u ); r.add( triple( "p S q" ) ); assertIsomorphic( graphWith( "x R y; x R z; p S q" ), u ); r.delete( triple( "x R y" ) ); assertIsomorphic( graphWith( "x R z; p S q" ), u ); }
public void testAdd() { Graph l = graphWith( "x R y" ); Graph r = graphWith( "x R y; p S q" ); Union u = new Union( l, r ); u.add( triple("x R y") ); assertIsomorphic( graphWith( "x R y" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); u.add( triple("p S q") ); assertIsomorphic( graphWith( "x R y; p S q" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); u.add( triple("r A s") ); assertIsomorphic( graphWith( "x R y; p S q; r A s" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); }
public void testDelete() { Graph l = graphWith( "x R y; x R z" ); Graph r = graphWith( "x R y; p S q" ); Union u = new Union( l, r ); u.delete( triple( "r A s" ) ); assertIsomorphic( graphWith( "x R y; x R z" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); u.delete( triple( "x R z" ) ); assertIsomorphic( graphWith( "x R y" ), l); assertIsomorphic( graphWith( "x R y; p S q" ), r); u.delete( triple ( "p S q" ) ); assertIsomorphic( graphWith( "x R y" ), l); assertIsomorphic( graphWith( "x R y" ), r); u.delete( triple ( "x R y" ) ); assertIsomorphic( graphWith( "" ), l); assertIsomorphic( graphWith( "" ), r); } }