Package org.apache.clerezza.rdf.core

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


        datasetLock.writeLock().lock();
        try {
            if(graphNames.contains(name) || mGraphNames.contains(name) || name.equals(defaultGraphName)){
                throw new EntityAlreadyExistsException(name);
            }
            MGraph graph = getModelGraph(name,true,true).getMGraph();
            mGraphNames.add(name);
            try {
                writeMGraphConfig();
            } catch (IOException e) {
                throw new IllegalStateException("Unable to wirte MGraphName config file '"
View Full Code Here


        datasetLock.writeLock().lock();
        try {
            if(isExistingGraphName(name)){
                throw new EntityAlreadyExistsException(name);
            }
            MGraph graph = getModelGraph(name,true,true).getMGraph();
            addToIndex( name, Symbols.MGraph);
            return graph;
        } finally {
            datasetLock.writeLock().unlock();
        }
View Full Code Here

     * Removes a graphanem from the index of graphnames
     * @param graphName name of the graph to remove
     * @param graphType resource type of the graph to remove.
     */
    private void removeFromIndex(UriRef graphName, UriRef graphType) {
        MGraph index = graphNameIndex.getMGraph();
        Iterator<Triple> triplesToRemove = index.filter(graphName, RDF.type, graphType);
        for( ; triplesToRemove.hasNext(); ) {
            triplesToRemove.next();
            triplesToRemove.remove();
        }
        graphNameIndex.sync();
View Full Code Here

        }
        graphNameIndex.sync();
    }
   
    private void removeDefaultGraphFromIndex() {
      MGraph index = graphNameIndex.getMGraph();
      Iterator<Triple> triplesToRemove = index.filter(null, RDF.type, Symbols.Default);
      for( ; triplesToRemove.hasNext(); ) {
          Triple triple = triplesToRemove.next();
          triplesToRemove.remove();
          removeFromIndex( UriRef.class.cast(triple.getSubject()), Symbols.Graph );
      }
View Full Code Here

   
    @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

        try {
            otimizationIndicator.createNewFile();
        } 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

TOP

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

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.