Package org.apache.clerezza.rdf.core.impl

Examples of org.apache.clerezza.rdf.core.impl.SimpleMGraph


  protected void unbindContextProvider(UserContextProvider provider) {
    contextProviders.remove(provider);
  }

  private GraphNode getUserContext() {
    GraphNode contextNode = new GraphNode(new BNode(), new SimpleMGraph());
    synchronized(contextProviders) {
      Iterator<UserContextProvider> providersIter = contextProviders.iterator();
      while (providersIter.hasNext()) {
        UserContextProvider userContextProvider = providersIter.next();
        contextNode = userContextProvider.addUserContext(contextNode);
View Full Code Here


    MGraph mGraph = getEmptyMGraph();
    TestGraphListener listener = new TestGraphListener();
    mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
    mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
    mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
    MGraph triples = new SimpleMGraph();
    triples.add(trpl1);
    triples.add(trpl2);
    triples.add(trpl3);
    triples.add(trpl4);
    mGraph.addAll(triples);
    List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
    Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
    Assert.assertEquals(3, cumulatedEvents.size());
    Assert.assertTrue(cumulatedEvents.get(0) instanceof AddEvent);
View Full Code Here

    URL config = getClass().getResource("lingvoj.rdf");
    if (config == null) {
      throw new RuntimeException("no file found");
    }
    try {
      MGraph lingvojMGraph = new SimpleMGraph();
      parser.parse(lingvojMGraph, config.openStream(), SupportedFormat.RDF_XML, null);
      lingvojGraph = lingvojMGraph.getGraph();
      softLingvojGraph = new SoftReference<Graph>(lingvojGraph);
      return lingvojGraph;
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
View Full Code Here

    final Graph graph = Parser.getInstance()
        .parse(getClass().getResourceAsStream("systemgraph.nt"),
            "text/rdf+n3");   
    this.permissionDefinitions = new PermissionDefinitions(
        new SimpleMGraph(graph.iterator()));

    this.allPermissions = new PermissionInfo[] {
        new PermissionInfo(
            "(java.io.FilePermission \"file:///home/foo/-\" \"read,write,delete\")"),
        new PermissionInfo(
View Full Code Here

    try {
      //getting the tBox here means no read right on Tbox is necessary
      //when smushing
      tBox = tcManager.getTriples(tBoxName);
    } catch (NoSuchEntityException e) {
      tBox = new SimpleMGraph();
      tBox.add(new TripleImpl(FOAF.mbox, RDF.type, OWL.InverseFunctionalProperty));
      tBox.add(new TripleImpl(FOAF.mbox_sha1sum, RDF.type, OWL.InverseFunctionalProperty));
      tBox.add(new TripleImpl(PLATFORM.userName, RDF.type, OWL.InverseFunctionalProperty));
      tBox = tcManager.createGraph(tBoxName, tBox);
    }
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
  @Path("new")
  public GraphNode emptyPrefixBinding() {
    MGraph resultMGraph = new SimpleMGraph();
    GraphNode result = new GraphNode(new BNode(), resultMGraph);
    result.addProperty(RDF.type, CURIE.CuriePrefixBinding);
    result.addProperty(CURIE.prefix,
        literalFactory.createTypedLiteral("foaf"));
    result.addProperty(CURIE.binding,
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.impl.SimpleMGraph

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.