Package com.hp.hpl.jena.graph.compose

Examples of com.hp.hpl.jena.graph.compose.MultiUnion


        {
        StmtIterator oit = model.listStatements( null, OWL.imports, (RDFNode) null );
        StmtIterator jit = model.listStatements( null, JA.imports, (RDFNode) null );
        if (oit.hasNext() || jit.hasNext())
            {
            MultiUnion g = new MultiUnion( new Graph[] { model.getGraph() } );
            addImportedGraphs( fm, loading, oit, g );
            addImportedGraphs( fm, loading, jit, g );
            return ModelFactory.createModelForGraph( g );
            }
        else
View Full Code Here


     * together with an additional set of data premises. The default
     * implementation loses ALL partial deductions so far. Some subclasses
     * may be able to a more efficient job.
     */
    public InfGraph cloneWithPremises(Graph premises) {
        MultiUnion union = new MultiUnion();
        Graph raw = getRawGraph();
        union.addGraph( raw );
        union.setBaseGraph( raw );
        union.addGraph( premises );
        Graph schema = getSchemaGraph();
        if (schema != null) {
            if (schema instanceof BaseInfGraph) {
                BaseInfGraph ischema = (BaseInfGraph)schema;
                Graph sschema = ischema.getSchemaGraph();
                if (sschema != null) union.addGraph( sschema );
                Graph rschema = ischema.getRawGraph();
                if (rschema != null) union.addGraph( rschema );
            }
           
        }
        return getReasoner().bind(union);
    }
View Full Code Here

    public void testAdd() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
        Graph g2 = graphWith( "x p y; z p a" );         // intersects with g1
       
        MultiUnion m = new MultiUnion( new Graph[] {g0, g1} );
       
        int s0 = g0.size();
        int s1 = g1.size();
        int s2 = g2.size();
        int m0 = m.size();

        // add a triple to the union
        m.add( triple( "a q b" ) );
       
        assertEquals( "m.size should have increased by one", m0 + 1, m.size() );
        assertEquals( "g0.size should have increased by one", s0 + 1, g0.size() );
        assertEquals( "g1 size should be constant", s1, g1.size() );
       
        // change the designated receiver and try again
        m.setBaseGraph( g1 );
       
        s0 = g0.size();
        s1 = g1.size();
        s2 = g2.size();
        m0 = m.size();
       
        m.add( triple( "a1 q b1" ));

        assertEquals( "m.size should have increased by one", m0 + 1, m.size() );
        assertEquals( "g0 size should be constant", s0, g0.size() );
        assertEquals( "g1.size should have increased by one", s1 + 1, g1.size() );
       
        // check that we can't make g2 the designated updater
        boolean expected = false;
        try {
            m.setBaseGraph( g2 );
        }
        catch (IllegalArgumentException e) {
            expected = true;
        }
        assertTrue( "Should not have been able to make g2 the updater", expected );
View Full Code Here

   
    public void testDelete() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
       
        MultiUnion m = new MultiUnion( new Graph[] {g0, g1} );
       
        checkDeleteSizes( 1, 2, 3, g0, g1, m );
       
        m.delete( triple( "x p y") );
        checkDeleteSizes( 0, 2, 2, g0, g1, m );

        m.delete( triple( "x p y") );
        checkDeleteSizes( 0, 2, 2, g0, g1, m );

        m.setBaseGraph( g1 );

        m.delete( triple( "x p z") );
        checkDeleteSizes( 0, 1, 1, g0, g1, m );

        m.delete( triple( "z p zz") );
        checkDeleteSizes( 0, 0, 0, g0, g1, m );
    }
View Full Code Here

   
    public void testContains() {
        Graph g0 = graphWith( "x p y" );
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
       
        MultiUnion m = new MultiUnion( new Graph[] {g0, g1} );
        assertTrue( "m should contain triple", m.contains( triple( "x p y ")));      
        assertTrue( "m should contain triple", m.contains( triple( "x p z ")));      
        assertTrue( "m should contain triple", m.contains( triple( "z p zz ")));      
       
        assertFalse( "m should not contain triple", m.contains( triple( "zz p z ")));      
    }
View Full Code Here

   
   
    /* Test using a model to wrap a multi union */
    public void testModel()  {
        Graph g0 = graphWith( "x p y" );
        MultiUnion u = new MultiUnion( new Graph[] {g0} );
       
        Model m = ModelFactory.createModelForGraph( u );
       
        assertEquals( "Model size not correct", 1, m.size() );
       
        Graph g1 = graphWith( "x p z; z p zz" );        // disjoint with g0
        u.addGraph( g1 );       
       
        assertEquals( "Model size not correct", 3, m.size() );
       
        // adds one more statement to the model
        m.read( getFileName("ontology/list0.rdf") );
View Full Code Here

    public TestMultiUnionReifier( String name )
        { super( name ); }

    public void testX()
        {
        MultiUnion mu = multi( "a P b; !b Q c; ~c R d", "" );
        for (ExtendedIterator<Triple> it = GraphUtil.findAll( mu ); it.hasNext();)
            {
            System.err.println( "]]  " + it.next() );
            }
        }
View Full Code Here

        }

    private MultiUnion multi( String a, String b )
        {
        Graph A = graph( a ), B = graph( b );
        return new MultiUnion( new Graph[] {A, B} );
        }
View Full Code Here

     * @param spec The model spec to interpret
     * @param base The base model, or null
     */
    private static Graph generateGraph( OntModelSpec spec, Graph base ) {
        // create a empty union graph
        MultiUnion u = new MultiUnion();
        u.addGraph( base );
        u.setBaseGraph( base );

        Reasoner r = spec.getReasoner();
        // if we have a reasoner in the spec, bind to the union graph and return
        return r == null ? (Graph) u : r.bind( u );
    }
View Full Code Here

    List<Graph> unitedGraphs = new ArrayList<Graph>();
    unitedGraphs.add(graph);
    for (Bundle installedBundle : installedBundles) {
      unitedGraphs.addAll(getBundleGraphs(installedBundle));
    }
    Graph result = new MultiUnion(unitedGraphs.iterator());
    log.info(("returning graph of size "+result.size()));
    return result;

  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.graph.compose.MultiUnion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.