Package org.apache.clerezza.rdf.core

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


      revokedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0], rdfXmlType, null, new ByteArrayInputStream(revokedString.getBytes()));
    } catch (IOException ex) {
      logger.error("reading graph {}", ex);
      throw new WebApplicationException(ex, 500);
    }
    final MGraph mGraph = graphUri == null ? cgProvider.getContentGraph() :
      tcManager.getMGraph(graphUri);
    try {
      MGraphUtils.removeSubGraph(mGraph, revokedGraph);
    } catch (NoSuchSubGraphException ex) {
      throw new RuntimeException(ex);
    }
    mGraph.addAll(assertedGraph);
  }
View Full Code Here


    }
  }

  @Override
  public  void remove(NonLiteral node) {
    MGraph mGraph = getMGraph();   
    Iterator<Triple> properties = mGraph.filter(node, null, null);
    //copying properties to set, as we're modifying underlying graph
    Set<Triple> propertiesSet = new HashSet<Triple>();
    while (properties.hasNext()) {
      propertiesSet.add(properties.next());
    }
View Full Code Here

    graphNode.deleteNodeContext();
  }

  @Override
  public byte[] getData(UriRef uriRef) {
    MGraph mGraph = getMGraph();
    GraphNode node = new GraphNode(uriRef, mGraph);
    final InfoDiscobit infoDiscobit = InfoDiscobit.createInstance(node);
    if (infoDiscobit == null) {
      return null;
    }
View Full Code Here

    return infoDiscobit.getData();
  }

  @Override
  public MediaType getMediaType(UriRef uriRef) {
    MGraph mGraph = getMGraph();
    GraphNode node = new GraphNode(uriRef, mGraph);
    final InfoDiscobit infoDiscobit = InfoDiscobit.createInstance(node);
    if (infoDiscobit == null) {
      return null;
    }
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

  @Path("script-overview")
  public GraphNode overview(
      @QueryParam(value = "script") UriRef script) {

    AccessController.checkPermission(new ScriptManagerAppPermission());
    MGraph contentGraph = cgProvider.getContentGraph();
    BNode resultResource = new BNode();
    MGraph resultGraph = new SimpleMGraph();
   
    GraphNode scriptNode = null;
    if(script != null){
      scriptNode = getScript(script);
      resultGraph.add(new TripleImpl(resultResource,
          SCRIPTMANAGER.script,
          scriptNode.getNode()));
    }
    resultGraph.add(new TripleImpl(resultResource,
        RDF.type,
        PLATFORM.HeadedPage));
    resultGraph.add(new TripleImpl(resultResource,
        RDF.type,
        SCRIPTMANAGER.ScriptManagerOverviewPage));
    GraphNode scriptList = getScriptList(resultResource);

    UnionMGraph unionGraph = null;
View Full Code Here

  public GraphNode getScript(
      @QueryParam(value = "script") UriRef scriptUri){

    AccessController.checkPermission(new ScriptManagerAppPermission());
    BNode resource = new BNode();
    MGraph resultGraph = new SimpleMGraph();


    resultGraph.add(new TripleImpl(resource,
        SCRIPTMANAGER.script,
        scriptUri));
    resultGraph.add(new TripleImpl(resource,
        RDF.type,
        SCRIPTMANAGER.SelectedScript));
    resultGraph.add(new TripleImpl(scriptUri,
        SCRIPTMANAGER.code,
        new PlainLiteralImpl(
          new String(contentHandler.getData(scriptUri)))));

    GraphNode scriptLanguageList = getScriptLanguageList(resource);
View Full Code Here

    if(resource == null) {
      resource = new BNode();
    }

    BNode resultResource = new BNode();
    MGraph contentGraph = cgProvider.getContentGraph();
   
    MGraph additionGraph = new SimpleMGraph();

    UnionMGraph resultGraph = new UnionMGraph(additionGraph, contentGraph);

    RdfList list = RdfList.createEmptyList(resultResource, additionGraph);
    resultGraph.add(new TripleImpl(resource,
View Full Code Here

  @GET
  @Path("script-install")
  public GraphNode install() {

    AccessController.checkPermission(new ScriptManagerAppPermission());
    MGraph contentGraph = cgProvider.getContentGraph();
    BNode resultResource = new BNode();
    MGraph resultGraph = new SimpleMGraph();
    resultGraph.add(new TripleImpl(resultResource,
        RDF.type,
        SCRIPTMANAGER.ScriptManagerInstallPage));
    resultGraph.add(new TripleImpl(resultResource,
        RDF.type, PLATFORM.HeadedPage));
   
    GraphNode languageList = getScriptLanguageList(resultResource);
   
    GraphNode scriptList = getScriptList(resultResource);
View Full Code Here

   */
  protected abstract MGraph getEmptyMGraph();
 
  @Test
  public void testAddCountAndGetTriples() {
    MGraph graph = getEmptyMGraph();
    Assert.assertEquals(0, graph.size());
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
    graph.add(triple1);
    Assert.assertEquals(1, graph.size());
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, uriRef1);
    Assert.assertTrue(tripleIter.hasNext());
    Triple tripleGot = tripleIter.next();
    Assert.assertEquals(triple1, tripleGot);
    Assert.assertFalse(tripleIter.hasNext());
    BNode bnode = new BNode() {};
    graph.add(new TripleImpl(bnode, uriRef1, uriRef3));
    graph.add(new TripleImpl(bnode, uriRef1, uriRef4));
    tripleIter = graph.filter(null, uriRef1, null);
    Set<NonLiteral> subjectInMatchingTriples = new HashSet<NonLiteral>();
    Set<Resource> objectsInMatchingTriples = new HashSet<Resource>();
    while (tripleIter.hasNext()) {
      Triple triple = tripleIter.next();
      subjectInMatchingTriples.add(triple.getSubject());
      objectsInMatchingTriples.add(triple.getObject());
    }
    Assert.assertEquals(1, subjectInMatchingTriples.size());
    Assert.assertEquals(2, objectsInMatchingTriples.size());
    Set<Resource> expectedObjects = new HashSet<Resource>();
    expectedObjects.add(uriRef3);
    expectedObjects.add(uriRef4);
    Assert.assertEquals(expectedObjects, objectsInMatchingTriples);
    graph.add(new TripleImpl(bnode, uriRef4, bnode));
    tripleIter = graph.filter(null, uriRef4, null);
    Assert.assertTrue(tripleIter.hasNext());
    Triple retrievedTriple = tripleIter.next();
    Assert.assertFalse(tripleIter.hasNext());
    Assert.assertEquals(retrievedTriple.getSubject(), retrievedTriple.getObject());
    tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
    retrievedTriple = tripleIter.next();
    Assert.assertFalse(tripleIter.hasNext());
    Assert.assertEquals(retrievedTriple.getSubject(), retrievedTriple.getObject());
  }
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.