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

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


    Assert.assertNull(mapping);
  }

  @Test
  public void test3() {
    TripleCollection tc1 = new SimpleMGraph();
    tc1.add(new TripleImpl(u1, u1, u1));
    TripleCollection tc2 = new SimpleMGraph();
    tc2.add(new TripleImpl(u1, u1, u1));
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNotNull(mapping);
    Assert.assertEquals(0, mapping.size());
  }
View Full Code Here


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

  @Test
  public void test4() {
    TripleCollection tc1 = new SimpleMGraph();
    tc1.add(new TripleImpl(u1, u1, new BNode()));
    TripleCollection tc2 = new SimpleMGraph();
    tc2.add(new TripleImpl(u1, u1, new BNode()));
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNotNull(mapping);
    Assert.assertEquals(1, mapping.size());
  }
View Full Code Here

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

  @Test
  public void test5() {
    TripleCollection tc1 = new SimpleMGraph();
    tc1.add(new TripleImpl(new BNode(), u1, new BNode()));
    TripleCollection tc2 = new SimpleMGraph();
    tc2.add(new TripleImpl(new BNode(), u1, new BNode()));
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNotNull(mapping);
    Assert.assertEquals(2, mapping.size());
  }
View Full Code Here

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

  @Test
  public void test6() {
    TripleCollection tc1 = new SimpleMGraph();
    final BNode b11 = new BNode();
    tc1.add(new TripleImpl(new BNode(), u1,b11));
    tc1.add(new TripleImpl(new BNode(), u1,b11));
    TripleCollection tc2 = new SimpleMGraph();
    tc2.add(new TripleImpl(new BNode(), u1, new BNode()));
    final Map<BNode, BNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
    Assert.assertNull(mapping);
  }
View Full Code Here

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

  }

  private MGraph getContextOf(NonLiteral node, Set<BNode> dontExpand,
      Graph graph) {
    MGraph result = new SimpleMGraph();
    Iterator<Triple> forwardProperties = graph.filter(node, null, null);
    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));
        }
      }
    }
    return result;
  }
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

  static MGraph generateLine(int size, final NonLiteral firstNode) {
    if (size < 1) {
      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

  private MGraph getDocumentationMGraph(URL docUrl, String symbolicName) {
    try {
      Graph parsedGraph = parser.parse(docUrl.openStream(),
          SupportedFormat.N_TRIPLE);
      UriRef baseUri = config.getDefaultBaseUri();
      return new SimpleMGraph(new UriMutatorIterator(
          parsedGraph.iterator(), baseUri.getUnicodeString(), symbolicName));
    } catch (IOException ex) {
      logger.warn("Cannot parse documentation at URL: {}", docUrl);
      throw new RuntimeException(ex);
    }
View Full Code Here

  private UriRef fooTest = new UriRef("http://localhost:8282/foo/test/");
  private UriRef fooTestResource4 = new UriRef("http://localhost:8282/foo/test/resource4");
   
  @Test
  public void listPositionTest() throws Exception {
    MGraph mGraph = new SimpleMGraph();
    CollectionCreator collectionCreator = new CollectionCreator(mGraph);
    collectionCreator.createContainingCollections(fooTestResource4);
    Assert.assertTrue(mGraph.contains(new TripleImpl(fooTest, RDF.type, HIERARCHY.Collection)));
    Assert.assertTrue(mGraph.contains(new TripleImpl(fooTestResource4, HIERARCHY.parent, fooTest)));
    Assert.assertTrue(mGraph.contains(new TripleImpl(foo, HIERARCHY.parent, root)));
    Assert.assertTrue(mGraph.contains(new TripleImpl(root, RDF.type, HIERARCHY.Collection)));
    collectionCreator.createContainingCollections(fooResource);
    Assert.assertTrue(mGraph.contains(new TripleImpl(fooResource, HIERARCHY.parent, foo)));
  }
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.