Package org.apache.clerezza.rdf.core.event

Examples of org.apache.clerezza.rdf.core.event.FilterTriple


  @Test
  public void graphEventTestClear() {
    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.add(trpl1);
    mGraph.add(trpl2);
    mGraph.add(trpl3);
    mGraph.add(trpl4);
    listener.resetCumulatedEvents();
View Full Code Here


  @Test
  public void graphEventTestWithDelay() throws Exception{
    MGraph mGraph = getEmptyMGraph();
    TestGraphListener listener = new TestGraphListener();
    mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null),
        1000);

    Triple triple0 = new TripleImpl(uriRef2, uriRef2, literal1);
    Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
    Triple triple2 = new TripleImpl(uriRef1, uriRef2, literal1);
View Full Code Here

        //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);
View Full Code Here

      @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());
View Full Code Here

        }
      }
    };

    baseGraph.addGraphListener(typeChangeListener, new FilterTriple(null, RDF.type, null));

    indexedPropertyChangeListener = new GraphListener() {

      @Override
      public void graphChanged(List<GraphEvent> events) {
        for (GraphEvent e : events) {
          logger.debug("Triple: " + e.getTriple());
          Triple triple = e.getTriple();

          UriRef predicate = triple.getPredicate();
          Set<VirtualProperty> vProperties = property2IncludingVProperty.get(predicate);

          List<Resource> indexedResources = new ArrayList<Resource>();
          logger.debug("Predicate: " + predicate);
          for (VirtualProperty vProperty : vProperties) {
            logger.debug("Subject: " + " " + triple.getSubject());
            followInversePaths(triple.getSubject(),
                vProperty.pathToIndexedResource(predicate), indexedResources);

          }
          for (Resource resource : indexedResources) {
            GraphNode node = new GraphNode(resource, e.getGraph());
            List<UriRef> types = new ArrayList<UriRef>();
            Lock lock = node.readLock();
            lock.lock();
            try {
              Iterator<Resource> resources = node.getObjects(RDF.type);
              while (resources.hasNext()) {
                Resource res = resources.next();
                if (res instanceof UriRef) {
                  types.add((UriRef) res);
                }
              }
            } finally {
              lock.unlock();
            }
            for (UriRef type : types) {
              if (type2IndexedProperties.containsKey(type)) {
                scheduleForReindex(resource);
              }
            }
          }

        }
      }
    };

    baseGraph.addGraphListener(indexedPropertyChangeListener,
        new FilterTriple(null, null, null) {

      @Override
      public boolean match(Triple triple) {
        UriRef predicate = triple.getPredicate();
        //check indirectly involved properties
View Full Code Here

                }
            }
        };

        baseGraph.addGraphListener(typeChangeListener, new FilterTriple(null, RDF.type, null));

        indexedPropertyChangeListener = new GraphListener() {

            @Override
            public void graphChanged(List<GraphEvent> events) {
                for (GraphEvent e : events) {
                    logger.debug("Triple: " + e.getTriple());
                    Triple triple = e.getTriple();

                    UriRef predicate = triple.getPredicate();
                    Set<VirtualProperty> vProperties = property2IncludingVProperty.get(predicate);

                    List<Resource> indexedResources = new ArrayList<Resource>();
                    logger.debug("Predicate: " + predicate);
                    for (VirtualProperty vProperty : vProperties) {
                        logger.debug("Subject: " + " " + triple.getSubject());
                        followInversePaths(triple.getSubject(),
                                vProperty.pathToIndexedResource(predicate), indexedResources);

                    }
                    for (Resource resource : indexedResources) {
                        GraphNode node = new GraphNode(resource, e.getGraph());
                        List<UriRef> types = new ArrayList<UriRef>();
                        Lock lock = node.readLock();
                        lock.lock();
                        try {
                            Iterator<Resource> resources = node.getObjects(RDF.type);
                            while (resources.hasNext()) {
                                Resource res = resources.next();
                                if (res instanceof UriRef) {
                                    types.add((UriRef) res);
                                }
                            }
                        } finally {
                            lock.unlock();
                        }
                        for (UriRef type : types) {
                            if (type2IndexedProperties.containsKey(type)) {
                                scheduleForReindex(resource);
                            }
                        }
                    }

                }
            }
        };

        baseGraph.addGraphListener(indexedPropertyChangeListener,
                new FilterTriple(null, null, null) {

            @Override
            public boolean match(Triple triple) {
                UriRef predicate = triple.getPredicate();
                //check indirectly involved properties
View Full Code Here

                //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);
View Full Code Here

            @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());
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.event.FilterTriple

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.