Package org.apache.clerezza.rdf.core

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


    Assert.assertEquals("\"A RESOURCE\"", writer.toString());
  }

  @Test
  public void multiple() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("another resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

    StringReader reader = new StringReader("Multiple\n${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#} ${loop}\t${rdfs:comment}\n${/loop}");
    StringWriter writer = new StringWriter();
View Full Code Here


    Assert.assertTrue(writer.toString().contains("\"a resource\"") && writer.toString().contains("\"another resource\""));
  }

  @Test
  public void fieldTest() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}${if rdfs:comment}yes${/if} and ${if rdfs:label}yes${else}no${/if}");
    StringWriter writer = new StringWriter();
View Full Code Here

    Assert.assertEquals("yes and no", writer.toString());
  }

  @Test
  public void fieldTest2() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);
    /* without the final access to field it does not work,
    field access in if-conditins does not count for loops*/
    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}${loop}${if rdfs:comment}${rdfs:comment}${/if} and ${if rdfs:label}yes${else}no${/if}${rdfs:comment}${/loop}");
View Full Code Here

    Assert.assertEquals("\"a resource\" and no\"a resource\"", writer.toString());
  }

  @Test
  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));

      GraphNode node = new GraphNode(document, mGraph);
      DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

      String templateString =
View Full Code Here

    }
  }

  @Test
  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));

      GraphNode node = new GraphNode(document, mGraph);
      DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

      String templateString =
View Full Code Here

    }
  }

  @Test
  public void rdfListAsPropertyValue() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    NonLiteral listNode = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDF.value, listNode));
    List<Resource> list = new RdfList(listNode, mGraph);
    list.add(new PlainLiteralImpl("first"));
    list.add(new PlainLiteralImpl("second"));
    list.add(new PlainLiteralImpl("third"));
    GraphNode node = new GraphNode(resource, mGraph);
View Full Code Here

    Assert.assertEquals("\"first\"\"second\"\"third\"", writer.toString());
  }

  @Test
  public void rdfListAsRoot() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    List<Resource> list = new RdfList(resource, mGraph);
    list.add(new PlainLiteralImpl("first"));
    list.add(new PlainLiteralImpl("second"));
View Full Code Here

    Assert.assertEquals("\"first\"\"second\"\"third\"", writer.toString());
  }

  @Test
  public void rdfListAsRootElementProperties() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    List<Resource> list = new RdfList(resource, mGraph);
    list.add(createLabeledRes("first", mGraph));
    list.add(createLabeledRes("second", mGraph));
View Full Code Here

    Assert.assertEquals("\"first\"\"second\"\"third\"", writer.toString());
  }

  @Test
  public void rdfListAsRootElementPropertiesWithPresenceTest() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    List<Resource> list = new RdfList(resource, mGraph);
    list.add(createLabeledRes("first", mGraph));
    list.add(createLabeledRes("second", mGraph));
View Full Code Here

    Assert.assertEquals("\"first\"\"second\"\"third\"", writer.toString());
  }

  @Test
  public void compareFunctionResultInIf() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode();
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}" +
        "${if getAudio(\"foo/bar\") = \"audio\"}noproblem${/if}");
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.