Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.Graph


        //      because an equals check will not work with BNodes.
        Set<UriRef> graphNames = new HashSet<UriRef>();
        for( Iterator<Triple> iterator = graphNameIndex.getMGraph().iterator(); iterator.hasNext(); ) {
            Triple triple = iterator.next();
            UriRef graphName = new UriRef(triple.getSubject().toString());
            Graph currentGraph = getModelGraph(graphName, false, false).getGraph();
            if(graph.equals(currentGraph)){
                graphNames.add(graphName);
            }
        }
        return graphNames;
View Full Code Here


        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        MGraph mGraph = getMGraph(tcDir);
        mGraph.addAll(triples);
        Graph result = mGraph.getGraph();
       
        graphMap.put(name, result);
        return result;
    }
View Full Code Here

    public void testCreateGraph() {
        TcProvider simpleTcmProvider = getInstance();
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));

        Graph createdGraph = simpleTcmProvider.createGraph(uriRefA, mGraph);

        Iterator<Triple> iteratorInput = mGraph.iterator();
        Iterator<Triple> iteratorCreated = createdGraph.iterator();
        assertEquals(iteratorInput.next(), iteratorCreated.next());
        assertFalse(iteratorCreated.hasNext());

        try {
            simpleTcmProvider.createGraph(uriRefA, mGraph);
View Full Code Here

        simpleTcmProvider.createGraph(uriRefB, mGraph);
        mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));
        simpleTcmProvider.createGraph(uriRefB1, mGraph);

        Graph bGraph = simpleTcmProvider.getGraph(uriRefB);
        Iterator<Triple> iterator = bGraph.iterator();
        assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
        assertFalse(iterator.hasNext());
    }
View Full Code Here

    @Test
    public void testDeleteEntity() {
        TcProvider simpleTcmProvider = getInstance();
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
        Graph graph = mGraph.getGraph();
        simpleTcmProvider.createGraph(uriRefA, graph);
        simpleTcmProvider.createGraph(uriRefC, graph);

        simpleTcmProvider.deleteTripleCollection(uriRefA);
        try {
            simpleTcmProvider.getGraph(uriRefA);
            assertTrue(false);
        } catch (NoSuchEntityException e) {
            assertTrue(true);
        }

        // Check that graph is still available under uriRefC
        Graph cGraph = simpleTcmProvider.getGraph(uriRefC);
        assertNotNull(cGraph);
    }
View Full Code Here

        graph = provider.getMGraph(graphUriRef);
        assertNotNull(graph);
        //check that there is no such graph, but only the mgraph
        boolean expThrown = false;
        try {
            Graph g = provider.getGraph(graphUriRef);
        } catch(NoSuchEntityException e) {
            expThrown = true;
        }

        assertTrue(expThrown);
View Full Code Here

    @Test
    public void testCreateGraphExtended() throws Exception {

        TcProvider provider = getInstance();
        Graph graph = provider.createGraph(graphUriRef, null);

        assertNotNull(graph);

        //get a new provider and check that graph is there
        provider = getInstance();
View Full Code Here

    @Test
    public void testCreateGraphNoDuplicateNames() throws Exception {

        TcProvider provider = getInstance();
        Graph graph = provider.createGraph(graphUriRef, null);
        assertNotNull(graph);
        boolean expThrown = false;
        try {
            Graph other = provider.createGraph(otherGraphUriRef, null);
        } catch(EntityAlreadyExistsException eaee) {
            expThrown = true;
        }
        assertTrue(expThrown);
    }
View Full Code Here

        Triple t1 = createTestTriple();

        TcProvider provider = getInstance();

        Graph graph = provider.createGraph(graphUriRef, createTestTripleCollection(t1));

        assertEquals(1, graph.size());
        assertTrue(graph.contains(t1));
    }
View Full Code Here

        Set<Triple> t = new HashSet<Triple>();
        t.add(t1);

        TcProvider provider = getInstance();

        Graph graph = provider.createGraph(graphUriRef, createTestTripleCollection(t1));

        boolean expThrown = false;

        try {
            graph.add(t1);
        } catch(UnsupportedOperationException uoe) {
            expThrown = true;
        }

        assertTrue(expThrown);
        expThrown = false;

        try {
            graph.remove(t1);
        } catch(UnsupportedOperationException uoe) {
            expThrown = true;
        }

        assertTrue(expThrown);
        expThrown = false;

        try {
            graph.addAll(t);
        } catch(UnsupportedOperationException uoe) {
            expThrown = true;
        }

        assertTrue(expThrown);

        expThrown = false;

        try {
            graph.clear();
        } catch(UnsupportedOperationException uoe) {
            expThrown = true;
        }

        assertTrue(expThrown);

        expThrown = false;

        try {
            graph.removeAll(t);
        } catch(UnsupportedOperationException uoe) {
            expThrown = true;
        }

        assertTrue(expThrown);
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.Graph

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.