Package org.apache.clerezza.rdf.core

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


    Assert.assertEquals(4, mapping.size());
  }

  @Test
  public void test11() {
    NonLiteral crossing1 = new BNode();
    TripleCollection tc1 = generateCircle(2,crossing1);
    tc1.addAll(generateCircle(4,crossing1));
    NonLiteral crossing2 = new BNode();
    TripleCollection tc2 = generateCircle(3,crossing2);
    tc2.addAll(generateCircle(3,crossing2));
    Assert.assertEquals(6, tc1.size());
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNull(mapping);
View Full Code Here


    Assert.assertNull(mapping);
  }

  @Test
  public void test12() {
    NonLiteral start1 = new BNode();
    TripleCollection tc1 = Utils4Testing.generateLine(4,start1);
    tc1.addAll(Utils4Testing.generateLine(5,start1));
    NonLiteral start2 = new BNode();
    TripleCollection tc2 = Utils4Testing.generateLine(5,start2);
    tc2.addAll(Utils4Testing.generateLine(4,start2));
    Assert.assertEquals(9, tc1.size());
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNotNull(mapping);
View Full Code Here

    Assert.assertEquals(10, mapping.size());
  }

  @Test
  public void test13() {
    NonLiteral start1 = new BNode();
    TripleCollection tc1 = Utils4Testing.generateLine(4,start1);
    tc1.addAll(Utils4Testing.generateLine(5,start1));
    NonLiteral start2 = new BNode();
    TripleCollection tc2 = Utils4Testing.generateLine(3,start2);
    tc2.addAll(Utils4Testing.generateLine(3,start2));
    Assert.assertEquals(9, tc1.size());
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNull(mapping);
View Full Code Here

  }

  private GraphNode createNode(String graphName) {
    final TcManager tcManager = TcManager.getInstance();
    final UriRef mGraphName = new UriRef(graphName);
    return new GraphNode(new BNode(), tcManager.createMGraph(mGraphName));
  }
View Full Code Here

    while (forwardProperties.hasNext()) {
      Triple triple = forwardProperties.next();
      result.add(triple);
      Resource object = triple.getObject();
      if (object instanceof BNode) {
        BNode bNodeObject = (BNode) object;
        if (!dontExpand.contains(bNodeObject)) {
          dontExpand.add(bNodeObject);
          result.addAll(getContextOf(bNodeObject, dontExpand, graph));
        }
      }
    }
    Iterator<Triple> backwardProperties = graph.filter(null, null, node);
    while (backwardProperties.hasNext()) {
      Triple triple = backwardProperties.next();
      result.add(triple);
      NonLiteral subject = triple.getSubject();
      if (subject instanceof BNode) {
        BNode bNodeSubject = (BNode) subject;
        if (!dontExpand.contains(bNodeSubject)) {
          dontExpand.add(bNodeSubject);
          result.addAll(getContextOf(bNodeSubject, dontExpand, graph));
        }
      }
View Full Code Here

      final UriRef predicate, final Resource object,
      final TripleCollection base) {
    Set<Triple> resultSet = new HashSet<Triple>();
    if (classCityFilter.accept(subject, base)) {
      if (predicate.equals(weatherProperty)) {
        BNode weatherNode = getWeatherNode(subject);
        resultSet.add(new TripleImpl(subject, predicate, weatherNode));
      }
    } else {
      NonLiteral city = null;
      Collection<NonLiteral> obsoleteCities = new ArrayList<NonLiteral>();
      for (Map.Entry<NonLiteral, WeakReference<BNode>> entry : cityWeatherMap.entrySet()) {
        BNode node = entry.getValue().get();
        if (node == null) {
          obsoleteCities.add(entry.getKey());
        }
        if (node.equals(subject)) {
          city = entry.getKey();
          break;
        }
      }
      for (NonLiteral nonLiteral : obsoleteCities) {
View Full Code Here

   * @return
   */
  private synchronized BNode getWeatherNode(NonLiteral city) {
    WeakReference<BNode> nodeRef =  cityWeatherMap.get(city);
    if (nodeRef != null) {
      BNode node = nodeRef.get();
      if (node != null) {
        return node;
      }
    }
    BNode newNode =  createLocalBNode();
    cityWeatherMap.put(city, new WeakReference<BNode>(newNode));
    return newNode;
  }
View Full Code Here

    // This is creating the Graph for the annotation in Annotation Ontology format
    final TcManager tcManager = TcManager.getInstance();
    final UriRef mGraphName = new UriRef(graphName);

    GraphNode node = new GraphNode(new BNode(), tcManager.createMGraph(mGraphName));
    Lock lock = node.writeLock();
    try {
      lock.lock();

      SelectorRegistry selectorRegistry = new SelectorRegistry();
View Full Code Here

    return sb.toString();
  }

  @Override
  public GraphNode getExceptionGraphNode() {
    GraphNode result = new GraphNode(new BNode(), new SimpleMGraph());
    result.addProperty(RDF.type, TYPERENDERING.Exception);
    LiteralFactory factory = LiteralFactory.getInstance();
    result.addProperty(TYPERENDERING.errorSource, new UriRef(renderingSpecification.toString()));
    if (lineNumber != -1) {
      result.addProperty(TYPERENDERING.line, factory.createTypedLiteral(new Integer(lineNumber)));
View Full Code Here

      throw new IllegalArgumentException();
    }
    MGraph result = new SimpleMGraph();
    NonLiteral lastNode = firstNode;
    for (int i = 0; i < size; i++) {
      final BNode newNode = new BNode();
      result.add(new TripleImpl(lastNode, u1, newNode));
      lastNode = newNode;
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.BNode

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.