Package org.apache.clerezza.rdf.core

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


        // check if another WeightedTcProvider has the TripleCollection.
        // And if so register as service.
        for (WeightedTcProvider provider : providerList) {
          try {
            TripleCollection triples = provider.getTriples(name);
            if (triples instanceof MGraph) {
              mGraphCache.put(name, new MGraphHolder(provider, ensureLockable((MGraph)triples)));
              mGraphAppears(name);
            } else {
              graphAppears(name);
View Full Code Here


  }

  @Override
  public TripleCollection getTriples(UriRef name)
      throws NoSuchEntityException {
    TripleCollection result;
    for (WeightedTcProvider provider : providerList) {
      try {
        result = provider.getTriples(name);
        if (!(result instanceof MGraph)) {
          return result;
View Full Code Here

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

    // get a Graph
    TripleCollection tripleCollection = simpleTcmProvider.getTriples(uriRefA);
    // get a MGraph
    TripleCollection tripleCollection2 = simpleTcmProvider.getTriples(uriRefB1);

    Iterator<Triple> iterator = tripleCollection.iterator();
    assertEquals(new TripleImpl(uriRefA, uriRefA, uriRefA), iterator.next());
    assertFalse(iterator.hasNext());

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

//  }

  @Test
  public void testGraphDeletion() throws Exception {

    TripleCollection triples = createTestTripleCollection(createTestTriple());

    TcProvider provider = getInstance();
    UriRef name1 = new UriRef("http://myGraph1");
    Graph graph = provider.createGraph(name1, triples);
View Full Code Here

  @Test
  public void testGetTriplesGraph() throws Exception {
    TcProvider provider = getInstance();
    Graph graph = provider.createGraph(graphUriRef,
        createTestTripleCollection(createTestTriple()));
    TripleCollection tc = provider.getTriples(graphUriRef);
    assertNotNull(tc);
  }
View Full Code Here

  public void testGetTriplesMGraph() throws Exception {
    TcProvider provider = getInstance();

    MGraph graph = provider.createMGraph(graphUriRef);

    TripleCollection tc = provider.getTriples(graphUriRef);
    assertNotNull(tc);
  }
View Full Code Here

*
* @author reto
*/
public class NotificationTest {
  @Test public void getEventsTogether() throws Exception {
    final TripleCollection tc = new SimpleMGraph();
    final List<List<GraphEvent>> eventChunks = new ArrayList<List<GraphEvent>>();
    GraphListener myGraphListener = new GraphListener() {
      @Override
      public void graphChanged(List<GraphEvent> events) {
        eventChunks.add(events);
        //the following causes an event to be added to events
        //(the List we already got)! This is because it doesn't wait
        //on a synhronized(this) as we are already in an evnet dispatch
        //thread
        //tc.add(generateTriple());
      }
    };
    tc.addGraphListener(myGraphListener, new FilterTriple(null, null, null),
        500);
    for (int i = 0; i < 100; i++) {
      tc.add(generateTriple());
    }
    Thread.sleep(600);
    Assert.assertEquals(1, eventChunks.size());
    Assert.assertEquals(100, eventChunks.get(0).size());
    tc.add(generateTriple());
    Thread.sleep(600);
    Assert.assertEquals(2, eventChunks.size());
    Assert.assertEquals(1, eventChunks.get(1).size());
  }
View Full Code Here

    Assert.assertEquals(1, eventChunks.get(1).size());
  }


  @Test public void synchroneousEvents() throws Exception {
    final TripleCollection tc = new SimpleMGraph();
    final List<List<GraphEvent>> eventChunks = new ArrayList<List<GraphEvent>>();
    GraphListener myGraphListener = new GraphListener() {
      @Override
      public void graphChanged(List<GraphEvent> events) {
        eventChunks.add(events);
      }
    };
    tc.addGraphListener(myGraphListener, new FilterTriple(null, null, null),
        0);
    for (int i = 0; i < 100; i++) {
      tc.add(generateTriple());
    }
    Assert.assertEquals(100, eventChunks.size());
    Assert.assertEquals(1, eventChunks.get(97).size());
    tc.add(generateTriple());
    Assert.assertEquals(101, eventChunks.size());
    Assert.assertEquals(1, eventChunks.get(100).size());
  }
View Full Code Here

  }

  @GET
  public GraphNode list(@Context UriInfo uriInfo) {
    TrailingSlash.enforcePresent(uriInfo);
    TripleCollection resultGraph = new SimpleMGraph();
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    GraphNode result = new GraphNode(new BNode(), new UnionMGraph(resultGraph, contentGraph));
    RdfList list = new RdfList(result);   
    Lock l = contentGraph.getLock().readLock();
    l.lock();
View Full Code Here

  }

  @GET
  @Path("get")
  public GraphNode getSingle(@QueryParam("binding") String bindingValue) {
    TripleCollection resultGraph = new SimpleMGraph();
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    MGraph unionMGraph = new UnionMGraph(resultGraph, contentGraph);
    Lock l = contentGraph.getLock().readLock();
    l.lock();
    try {
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.