Package org.apache.clerezza.rdf.core.impl

Examples of org.apache.clerezza.rdf.core.impl.SimpleMGraph


   
    @Test
    public void serializeGraph() {
        final String uriString = "http://example.org/foo#bar";
        UriRef uri = new UriRef(uriString);
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uri, uri, new PlainLiteralImpl("bla bla")));
        com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
        Model model = ModelFactory.createModelForGraph(graph);
        StringWriter writer = new StringWriter();
        model.write(writer);
        Assert.assertTrue(writer.toString().contains("about=\""+uriString));
View Full Code Here


    }
   
    @Test
    public void graphSize() {
        UriRef uri = new UriRef("http://example.org/foo#bar");
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uri, uri, new PlainLiteralImpl("bla bla")));
        com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
        Assert.assertEquals(1, graph.size());
    }
View Full Code Here

        Assert.assertEquals(1, graph.size());
    }

    @Test
    public void modifyingJenaGraph() {
        MGraph mGraph = new SimpleMGraph();
        com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
        Model model = ModelFactory.createModelForGraph(graph);
        model.add(RDFS.Class, RDF.type, RDFS.Class);
        Assert.assertEquals(1, mGraph.size());
    }
View Full Code Here

        Assert.assertEquals(1, mGraph.size());
    }
   
    @Test
    public void typedLiterals() {
        MGraph mGraph = new SimpleMGraph();
        com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
        Model model = ModelFactory.createModelForGraph(graph);
        Literal typedLiteral = model.createTypedLiteral("<elem>foo</elem>", XMLLiteralType.theXMLLiteralType);
        model.add(RDFS.Class, RDFS.label, typedLiteral);
        Assert.assertEquals(1, mGraph.size());
        StmtIterator iter = model.listStatements(RDFS.Class, RDFS.label, (Resource)null);
        Assert.assertTrue(iter.hasNext());
        RDFNode gotObject = iter.nextStatement().getObject();
        Assert.assertEquals(typedLiteral, gotObject);
    }
View Full Code Here

        Assert.assertEquals(typedLiteral, gotObject);
    }
   
    @Test
    public void reifications() {
        MGraph mGraph = new SimpleMGraph();
        com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
        //Model memModel = ModelFactory.createDefaultModel();
        Model model = ModelFactory.createModelForGraph(graph);
        model.add(RDFS.Resource, RDF.type, RDFS.Resource);
        Resource bnode = model.createResource();
View Full Code Here

        if (tcDir.exists()) {
            throw new EntityAlreadyExistsException(name);
        }

        if (triples == null) {
            triples = new SimpleMGraph();
        }
        tcDir.mkdirs();
        File otimizationIndicator = new File(tcDir, "fixed.opt");
        try {
            otimizationIndicator.createNewFile();
View Full Code Here

    @Test
    public void testGetTriples() {
        TcProvider simpleTcmProvider = getInstance();
        // add Graphs
        MGraph mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
        simpleTcmProvider.createGraph(uriRefA, mGraph);
        mGraph = new SimpleMGraph();
        mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB));
        simpleTcmProvider.createGraph(uriRefB, mGraph);
        // add MGraphs
        mGraph = simpleTcmProvider.createMGraph(uriRefA1);
        mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
        mGraph = simpleTcmProvider.createMGraph(uriRefB1);
        mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));

        // get a Graph
        TripleCollection tripleCollection = simpleTcmProvider.getTriples(uriRefA);
        // get a MGraph
        TripleCollection tripleCollection2 = simpleTcmProvider.getTriples(uriRefB1);
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 {
View Full Code Here

    }

    private TripleCollection createTestTripleCollection(Triple t) {
        Set<Triple> ts = new HashSet<Triple>();
        ts.add(t);
        return new SimpleMGraph(ts);
    }
View Full Code Here

        MGraph mGraph = getEmptyMGraph();
        TestGraphListener listener = new TestGraphListener();
        mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
        mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
        mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
        MGraph triples = new SimpleMGraph();
        triples.add(trpl1);
        triples.add(trpl2);
        triples.add(trpl3);
        triples.add(trpl4);
        mGraph.addAll(triples);
        List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
        Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
        Assert.assertEquals(3, cumulatedEvents.size());
        Assert.assertTrue(cumulatedEvents.get(0) instanceof AddEvent);
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.impl.SimpleMGraph

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.