Package org.apache.clerezza.rdf.core

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


  public void testCustomReadWritePermissions() {
    UriRef graphUri = new UriRef("http://example.org/read-write-custom");
    TcManager.getInstance().getTcAccessController().setRequiredReadWritePermissionStrings(graphUri,
        Collections.singletonList("(java.io.FilePermission \"/etc\" \"write\")"));
    //new FilePermission("/etc", "write").toString()));
    TripleCollection ag = TcManager.getInstance().getTriples(new UriRef("urn:x-localinstance:/graph-access.graph"));
    System.out.print(ag.toString());
    TcManager.getInstance().createMGraph(graphUri);
  }
View Full Code Here


    Parser parser = Parser.getInstance();
    Graph deserializedGraphOld = parser.parse(
        getClass().getResourceAsStream(inputFileName), format);

    TripleCollection tc = new SimpleMGraph();
    tc.addAll(deserializedGraphOld);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ssp.serialize(baos, tc, "text/rdf+nt");

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
View Full Code Here

    }
  }

  @Override
  public Graph getGraph(UriRef name) throws NoSuchEntityException {
    TripleCollection tripleCollection = tripleMap.get(name);
    if (tripleCollection == null) {
      throw new NoSuchEntityException(name);
    } else if (Graph.class.isAssignableFrom(tripleCollection.getClass())) {
      return (Graph) tripleCollection;
    }
    throw new NoSuchEntityException(name);
  }
View Full Code Here

    throw new NoSuchEntityException(name);
  }

  @Override
  public MGraph getMGraph(UriRef name) throws NoSuchEntityException {
    TripleCollection tripleCollection = tripleMap.get(name);
    if (tripleCollection == null) {
      throw new NoSuchEntityException(name);
    } else if (MGraph.class.isAssignableFrom(tripleCollection.getClass())) {
      return (MGraph) tripleCollection;
    }
    throw new NoSuchEntityException(name);
  }
View Full Code Here

  }

  @Override
  public TripleCollection getTriples(UriRef name)
      throws NoSuchEntityException {
    TripleCollection tripleCollection = tripleMap.get(name);
    if (tripleCollection == null) {
      throw new NoSuchEntityException(name);
    } else {
      return tripleCollection;
    }
View Full Code Here

    Parser parser = Parser.getInstance();
    Graph deserializedGraphOld = parser.parse(
        getClass().getResourceAsStream(inputFileName), format);

    TripleCollection tc = new SimpleMGraph();
    tc.addAll(deserializedGraphOld);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    nts.serialize(baos, tc);

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
View Full Code Here

    {
      final Iterator<Triple> mGraphIterator = metaGraph.filter(null, RDF.type, BACKUP.MGraph);
      while (mGraphIterator.hasNext()) {
        GraphNode graphGN = new GraphNode(mGraphIterator.next().getSubject(), metaGraph);
        String fileName = graphGN.getLiterals(BACKUP.file).next().getLexicalForm();
        TripleCollection extracted = extractedTc.get(fileName);
       
        MGraph mGraph;
        boolean created = false;
        try {
          mGraph = target.getMGraph((UriRef)graphGN.getNode());
          try {
            mGraph.clear();
          } catch (UnsupportedOperationException ex) {
            log.warn("could not restore "+graphGN.getNode()+" as the exsting triple "
                + "collection could not be cleared");
            continue;
          }
        } catch (NoSuchEntityException ex) {
          mGraph = target.createMGraph((UriRef)graphGN.getNode());
          created = true;
        }
        try {
          mGraph.addAll(extracted);
        } catch (Exception ex) {
          String actionDone = created ? "created" : "cleared";
          log.error("after the mgraph "+graphGN.getNode()+" could successfully be "+actionDone
              + ", an exception occured adding the data", ex);
        }
      }
    }
    {
      final Iterator<Triple> graphIterator = metaGraph.filter(null, RDF.type, BACKUP.Graph);
      while (graphIterator.hasNext()) {
        GraphNode graphGN = new GraphNode(graphIterator.next().getSubject(), metaGraph);
        String fileName = graphGN.getLiterals(BACKUP.file).next().getLexicalForm();
        TripleCollection extracted = extractedTc.get(fileName);
        try {
          target.deleteTripleCollection((UriRef)graphGN.getNode());
        } catch (UnsupportedOperationException ex) {
          log.warn("could not restore "+graphGN.getNode()+" as the exsting triple "
              + "collection could not be deleted");
View Full Code Here

   
    Parser parser = Parser.getInstance();
    Graph tc1 = parser.parse(
        getClass().getResourceAsStream("documentation-example.nt"), SupportedFormat.N_TRIPLE);
    final Set<String> lines1 = serializeToLines(tc1);
    TripleCollection tc2 = new SimpleMGraph();
    tc2.addAll(tc1);
    //add <bundle:///intro> <http://clerezza.org/2009/08/documentation#after> <bundle://org.apache.clerezza.platform.documentation/intro> .
    tc2.add(new TripleImpl(new UriRef("bundle:///intro"),
        new UriRef("http://clerezza.org/2009/08/documentation#after"),
        new UriRef("bundle://org.apache.clerezza.platform.documentation/intro")));
    final Set<String> lines2 = serializeToLines(tc2);
    lines2.removeAll(lines1);
    Assert.assertEquals(1, lines2.size());
View Full Code Here

    mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
    mGraph = fileTcProvider.createMGraph(uriRefB1);
    mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));

    // get a MGraph
    TripleCollection tripleCollection2 = fileTcProvider.getTriples(uriRefB1);

    Iterator<Triple> iterator = tripleCollection2.iterator();
    assertEquals(new TripleImpl(uriRefB1, uriRefB1, uriRefB1), iterator.next());
    assertFalse(iterator.hasNext());
  }
View Full Code Here

    }
  }

  @Override
  public Graph getGraph(UriRef name) throws NoSuchEntityException {
    TripleCollection tripleCollection = tripleMap.get(name);
    if (tripleCollection == null) {
      throw new NoSuchEntityException(name);
    } else if (Graph.class.isAssignableFrom(tripleCollection.getClass())) {
      return (Graph) tripleCollection;
    }
    throw new NoSuchEntityException(name);
  }
View Full Code Here

TOP

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

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.