Package org.apache.clerezza.rdf.core

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


  public void foaf() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    final Parser parser = Parser.getInstance();

    try {
      Graph deserializedGraph = parser.parse(getClass().getResourceAsStream("libby-foaf.rdf"), "application/rdf+xml");
      mGraph.addAll(deserializedGraph);
      UriRef document = new UriRef("http://swordfish.rdfweb.org/people/libby/rdfweb/webwho.xrdf");

      Assert.assertTrue((mGraph.size() > 0));
View Full Code Here


  public void foafSorted() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    final Parser parser = Parser.getInstance();

    try {
      Graph deserializedGraph = parser.parse(getClass().getResourceAsStream("libby-foaf.rdf"), "application/rdf+xml");
      mGraph.addAll(deserializedGraph);
      UriRef document = new UriRef("http://swordfish.rdfweb.org/people/libby/rdfweb/webwho.xrdf");

      Assert.assertTrue((mGraph.size() > 0));
View Full Code Here

    con.addRequestProperty("Accept", "application/rdf+xml");
    final InputStream inputStream = con.getInputStream();

    //get the singleton instance of Parser
    final Parser parser = Parser.getInstance();
    Graph deserializedGraph = parser.parse(inputStream, "application/rdf+xml");

    mGraph.addAll(deserializedGraph);
    for (GraphChangedListener graphChangedListener : graphChangedListeners) {
      graphChangedListener.graphChanged();
    }
View Full Code Here

    fileType = getMediaTypeForFileEnding(fileEnding);
    this.serializer = serializer;
    try {
      if (file.exists() && file.length() != 0) {
        InputStream fio = new FileInputStream(file);
        Graph graph = parser.parse(fio, fileType);
        addAllNoFileAccess(graph);
      } else {
        file.createNewFile();
      }
    } catch (IOException e) {
View Full Code Here

   *
   */
  @GET
  public GraphNode documentationPage(@Context UriInfo uriInfo) {
    TrailingSlash.enforcePresent(uriInfo);
    Graph documentations = tcManager.getGraph(
        DocumentationProvider.DOCUMENTATION_GRAPH_URI);   
    Collection<DocumentationItem> docItems = getDocItems(documentations);   
    List<DocumentationItem> sortedDocItems = sortDocItems(docItems);   
    MGraph mGraph = new SimpleMGraph();
    BNode orderedContent = createOrderedContent(sortedDocItems, mGraph);
View Full Code Here

  @Test
  public void RDFTestCases() {
    StableSerializerProvider ssp = new StableSerializerProvider();

    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());

    Graph deserializedGraphNew = parser.parse(bais, "text/rdf+nt");

    Assert.assertEquals(deserializedGraphOld, deserializedGraphNew);

  }
View Full Code Here

    try {
      // throws NoSuchEntityException if a TripleCollection with that name
      // already exists
      this.getTriples(name);
    } catch (NoSuchEntityException e) {
      Graph result;
      if (Graph.class.isAssignableFrom(triples.getClass())) {
        result = (Graph) triples;
      } else {
        result = new SimpleGraph(triples);
      }
View Full Code Here

    ZipInputStream compressedTcs = new ZipInputStream(backupData);

    Map<String, TripleCollection> extractedTc = new HashMap<String, TripleCollection>();
    String folder = "";
    ZipEntry entry;
    Graph metaGraph = null;
    while ((entry = compressedTcs.getNextEntry()) != null) {
      String entryName = entry.getName();
      if (entry.isDirectory()) {
        folder = entryName;
      } else {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int count;
        byte buffer[] = new byte[2048];
        while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
          baos.write(buffer, 0, count);
        }
        ByteArrayInputStream serializedGraph = new ByteArrayInputStream(
            baos.toByteArray());
        if (entryName.equals("triplecollections.nt")) {
          metaGraph = parser.parse(serializedGraph,
              SupportedFormat.N_TRIPLE, null);
        } else {
          Graph deserializedGraph = parser.parse(serializedGraph,
              SupportedFormat.N_TRIPLE, null);
          extractedTc.put(entryName, deserializedGraph);
        }
        baos.flush();
        baos.close();
View Full Code Here

  @Test
  public void RDFTestCases() {
    NTriplesSerializer nts = new NTriplesSerializer();

    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());

    Graph deserializedGraphNew = parser.parse(bais, "text/rdf+nt");

    Assert.assertEquals(deserializedGraphNew, deserializedGraphOld);
  }
View Full Code Here

 
  @Test
  public void RDFTestCases() throws Exception {
   
    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> .
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.