Package org.apache.clerezza.rdf.core

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


        return (NonLiteral) langListIter.next().getObject();
      }
    } finally {
      readLock.unlock();
    }
    BNode listNode = new BNode();
    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      systemGraph.add(new TripleImpl(instance, PLATFORM.languages, listNode));
    } finally {
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,
        literalFactory.createTypedLiteral("http://xmlns.com/foaf/0.1/"));
View Full Code Here

    l.lock();
   
    try {
      NonLiteral binding = getBindingWithValue(bindingValue, contentGraph);
      if (binding == null) {
        binding = new BNode();
      }
      GraphNode bindingNode;
      if (oldBindingValue != null) {
        NonLiteral oldBinding = getBindingWithValue(oldBindingValue, contentGraph);
        if (oldBinding != null) {
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();
    try {
      Iterator<Triple> greetings = contentGraph.filter(null, RDF.type, CURIE.CuriePrefixBinding);
View Full Code Here

*/
public class HashMatchingTest {

  @Test
  public void twoLine() throws GraphNotIsomorphicException {
    NonLiteral start1 = new BNode();
    MGraph tc1 = Utils4Testing.generateLine(4,start1);
    tc1.addAll(Utils4Testing.generateLine(5,start1));
    NonLiteral start2 = new BNode();
    MGraph tc2 = Utils4Testing.generateLine(5,start2);
    tc2.addAll(Utils4Testing.generateLine(4,start2));
    Assert.assertEquals(9, tc1.size());
    final Map<BNode, BNode> mapping = new HashMatching(tc1, tc2).getMatchings();
    Assert.assertNotNull(mapping);
View Full Code Here

  }

  @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

  }

  @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

    }
    return menus;
  }
 
  private NonLiteral asRdfList(SortedSet<Menu> menus, TripleCollection mGraph) {
    NonLiteral result = new BNode();
    RdfList list = new RdfList(result, mGraph);
    for (Menu menu : menus) {
      BNode node = new BNode();
      final String label = menu.root.getLabel();
      Literal labelLiteral = new PlainLiteralImpl(label);
      mGraph.add(new TripleImpl(node, RDFS.label,labelLiteral));
      final String description = menu.root.getDescription();
      if (description != null) {
View Full Code Here

    }
    return result;
  }

  private NonLiteral itemsAsRdfList(SortedSet<GlobalMenuItem> menus, TripleCollection mGraph) {
    NonLiteral result = new BNode();
    RdfList list = new RdfList(result, mGraph);
    for (GlobalMenuItem item : menus) {
      BNode node = new BNode();
      final String label = item.getLabel();
      Literal labelLiteral = new PlainLiteralImpl(label);
      mGraph.add(new TripleImpl(node, RDFS.label,labelLiteral));
      final String description = item.getDescription();
      if (description != null) {
View Full Code Here

      Graph context = objectGN.getNodeContext();
      Iterator<Triple> potentialIter = mGraph.filter(subject, triple.getPredicate(), null);
      while (potentialIter.hasNext()) {
        try {
          final Triple potentialTriple = potentialIter.next();
          BNode potentialMatch = (BNode)potentialTriple.getObject();
          final Graph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext();
          if (potentialContext.equals(context)) {
            removingTriples.addAll(potentialContext);
            unGroundedTriples.removeAll(context);
            continue OBJ_BNODE_LOOP;
          }
        } catch (ClassCastException e) {
          continue;
        }
      }
      throw new NoSuchSubGraphException();
    }
    SUBJ_BNODE_LOOP: while (true) {
      final Triple triple = getTripleWithBNodeSubject(unGroundedTriples);
      if (triple == null) {
        break;
      }
      final GraphNode subjectGN = new GraphNode(triple.getSubject(), unGroundedTriples);
      Resource object = triple.getObject();
      if (object instanceof BNode) {
        object = null;
      }
      Graph context = subjectGN.getNodeContext();
      Iterator<Triple> potentialIter = mGraph.filter(null, triple.getPredicate(), object);
      while (potentialIter.hasNext()) {
        try {
          final Triple potentialTriple = potentialIter.next();
          BNode potentialMatch = (BNode)potentialTriple.getSubject();
          final Graph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext();
          if (potentialContext.equals(context)) {
            removingTriples.addAll(potentialContext);
            unGroundedTriples.removeAll(context);
            continue SUBJ_BNODE_LOOP;
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.