Package org.apache.clerezza.rdf.core

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


    Assert.assertEquals("noproblem", writer.toString());
  }

  @Test
  public void loopWithEmptyList() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };

    NonLiteral listNode1 = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDF.value, listNode1));
    List<Resource> list1 = new RdfList(listNode1, mGraph);
    list1.add(new PlainLiteralImpl("first"));
    list1.add(new PlainLiteralImpl("second"));
    list1.add(new PlainLiteralImpl("third"));

    NonLiteral listNode2 = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDF.value, listNode2));
    RdfList.createEmptyList(listNode2, mGraph);

    GraphNode node = new GraphNode(resource, mGraph);

    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);
View Full Code Here


      Response r = Response.status(Response.Status.BAD_REQUEST)
          .entity("must specify a graph name")
          .type(MediaType.TEXT_PLAIN_TYPE).build();
      throw new WebApplicationException(r);
    }
    TripleCollection result = tcManager.getTriples(name);
    logger.debug("Got graph of size {} ", result.size());
    int i = 1;
    if (logger.isDebugEnabled()) {
      for (Triple triple : result) {
        logger.debug("({}) with triples {}", i++, triple.toString());
      }
View Full Code Here

  public void getGraphFromA() {
    Graph graphA = graphAccess.getGraph(uriRefA);
    Iterator<Triple> iterator = graphA.iterator();
    assertEquals(new TripleImpl(uriRefA, uriRefA, uriRefA), iterator.next());
    assertFalse(iterator.hasNext());
    TripleCollection triplesA = graphAccess.getTriples(uriRefA);
    iterator = triplesA.iterator();
    assertEquals(new TripleImpl(uriRefA, uriRefA, uriRefA), iterator.next());
    assertFalse(iterator.hasNext());
  }
View Full Code Here

  public void getGraphFromB() {
    Graph graphA = graphAccess.getGraph(uriRefB);
    Iterator<Triple> iterator = graphA.iterator();
    assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
    assertFalse(iterator.hasNext());
    TripleCollection triplesA = graphAccess.getTriples(uriRefB);
    iterator = triplesA.iterator();
    assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
    assertFalse(iterator.hasNext());
  }
View Full Code Here

    graphAccess.unbindWeightedTcProvider(weightedA);
    Graph graphA = graphAccess.getGraph(uriRefA);
    Iterator<Triple> iterator = graphA.iterator();
    assertEquals(new TripleImpl(uriRefA1, uriRefA1, uriRefA1), iterator.next());
    assertFalse(iterator.hasNext());
    TripleCollection triplesA = graphAccess.getTriples(uriRefA);
    iterator = triplesA.iterator();
    assertEquals(new TripleImpl(uriRefA1, uriRefA1, uriRefA1), iterator.next());
    assertFalse(iterator.hasNext());
  }
View Full Code Here

          FOAF.Person, null, MediaType.APPLICATION_XHTML_XML_TYPE,
          true);
    } catch (URISyntaxException ex) {
      throw new WebApplicationException(ex);
    }
    TripleCollection tc;
    try {
      tcManager.getMGraph(graphName);
    } catch (NoSuchEntityException nsee) {
      tc = tcManager.createMGraph(graphName);
      InputStream fin = null;
      fin = getClass().getResourceAsStream("data.turtle");
      Parser parser = Parser.getInstance();
      tc.addAll(parser.parse(fin, "text/turtle"));
    }
  }
View Full Code Here

    graphAccess.bindWeightedTcProvider(weightedAHeavy);
    Graph graphA = graphAccess.getGraph(uriRefA);
    Iterator<Triple> iterator = graphA.iterator();
    assertEquals(new TripleImpl(uriRefAHeavy, uriRefAHeavy, uriRefAHeavy), iterator.next());
    assertFalse(iterator.hasNext());
    TripleCollection triplesA = graphAccess.getTriples(uriRefA);
    iterator = triplesA.iterator();
    assertEquals(new TripleImpl(uriRefAHeavy, uriRefAHeavy, uriRefAHeavy), iterator.next());
    assertFalse(iterator.hasNext());
    graphAccess.unbindWeightedTcProvider(weightedAHeavy);
  }
View Full Code Here

    return type.isAssignableFrom(TripleCollection.class);
  }

  @Override
  public TripleCollection readFrom(Class<TripleCollection> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
    TripleCollection result = new SimpleMGraph();
    return parser.parse(entityStream, mediaType.toString());
  }
View Full Code Here

  public void setUriInfo(UriInfo uriInfo) {
    this.uriInfo = uriInfo;
  }

  private TripleCollection getExpandedContext(GraphNode node) {
    final TripleCollection result = new SimpleMGraph(node.getNodeContext());
    final Set<Resource> expandedResources = new HashSet<Resource>();
    expandedResources.add(node.getNode());
    while (true) {
      Set<Resource> additionalExpansionRes = getAdditionalExpansionResources(result);
      additionalExpansionRes.removeAll(expandedResources);
      if (additionalExpansionRes.size() == 0) {
        return result;
      }
      for (Resource resource : additionalExpansionRes) {
        final GraphNode additionalNode = new GraphNode(resource, node.getGraph());
        result.addAll(additionalNode.getNodeContext());
        expandedResources.add(resource);
      }
    }
  }
View Full Code Here

    private Map<PropertyKey, List<ExpandedNode>> children;
    private List<Resource> list = null;

    private ExpandedNode(Resource value) {
      this.value = value;
      final TripleCollection tc = expandedNode.node.getGraph();
      doListInitialization(tc);
    }
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.