Package org.apache.clerezza.rdf.core

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


  }

  @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);
    Assert.assertEquals(10, mapping.size());
  }
View Full Code Here


  }

  @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

                getSpan(documentText, sel.end, sel.end + 50));
        selectorNode.addPropertyValue(AOSELECTORS.offset, sel.start);
        selectorNode.addPropertyValue(AOSELECTORS.range, sel.end);
      }

      TripleCollection tc = node.getGraph();
      for (Triple t : tc) {
        log.info(t.toString());
      }

View Full Code Here

    metaData.add(new IptcDataSet(IptcDataSet.KEYWORDS, "keyword1"));
    metaData.add(new IptcDataSet(IptcDataSet.KEYWORDS, "keyword2"));
    metaData.add(new IptcDataSet(IptcDataSet.KEYWORDS, "keyword3"));
    metaData.add(new IptcDataSet(IptcDataSet.CITY, "City"));
   
    TripleCollection tc = MetaDataUtils.convertIptcToXmp(metaData);

    Iterator<Triple> it = tc.filter(null, new UriRef(DC.subject.getURI()), null);
    it = tc.filter((NonLiteral) it.next().getObject(), null, null);
    while(it.hasNext()) {
      Triple triple = it.next();
      Assert.assertTrue(
          triple.getObject().toString().contains("keyword1") ||
          triple.getObject().toString().contains("keyword2") ||
          triple.getObject().toString().contains("keyword3") ||
          triple.getObject().toString().contains(RDF.Bag.getURI()));
    }

    Assert.assertTrue(tc.filter(null,
        new UriRef("http://ns.adobe.com/photoshop/1.0/City"),
        new PlainLiteralImpl("City")).hasNext());
  }
View Full Code Here

   
    MetaData<ExifTagDataSet> metaData2 = new MetaData<ExifTagDataSet>();
    metaData2.add(new ExifTagDataSet(ExifTagDataSet.UserComment, "Bla Bla Bla"));
    metaData2.add(new ExifTagDataSet(ExifTagDataSet.Artist, "Hans Wurst"));
   
    TripleCollection tc = MetaDataUtils.convertExifToXmp(metaData2);
   
    Iterator<Triple> it = tc.filter(null, new UriRef("http://ns.adobe.com/exif/1.0/UserComment"), null);
    it = tc.filter((NonLiteral) it.next().getObject(), null, null);
    while(it.hasNext()) {
      Triple triple = it.next();
      Assert.assertTrue(
          triple.getObject().toString().contains("Bla Bla Bla") ||
          triple.getObject().toString().contains(RDF.Alt.getURI()));
    }
   
    Assert.assertTrue(tc.filter(null,
        new UriRef("http://ns.adobe.com/tiff/1.0/Artist"),
        new PlainLiteralImpl("Hans Wurst")).hasNext());
   
  }
View Full Code Here

  private Language language;

  LanguageDescription(GraphNode resource) {
    this.resource = resource;
    Literal iso1Literal = null;
    TripleCollection configGraph = resource.getGraph();
    if (configGraph instanceof LockableMGraph) {
      LockableMGraph lockableConfigGraph = (LockableMGraph)configGraph;
      Lock readLock = lockableConfigGraph.getLock().readLock();
      readLock.lock();
      try {
View Full Code Here

   * @param lang the language in which the label should be.
   * @return
   */
  public String getLabel(Language lang) {
    Lock readLock = null;
    TripleCollection configGraph = resource.getGraph();
    if (configGraph instanceof LockableMGraph) {
      LockableMGraph lockableConfigGraph = (LockableMGraph)configGraph;
      readLock = lockableConfigGraph.getLock().readLock();
      readLock.lock();
    }
View Full Code Here

    }   
  }

  private GraphNode addLanguages(GraphNode node, NonLiteral platformInstance, List<LanguageDescription> languages,
      boolean copyToNode) {
    TripleCollection graph = node.getGraph();
    BNode listNode = new BNode();   
    RdfList list = new RdfList(listNode, graph);
    LockableMGraph configGraph = getConfigGraph();
    Lock readLock = configGraph.getLock().readLock();
    for (LanguageDescription languageDescription : languages) {
      NonLiteral languageUri = (NonLiteral) languageDescription.getResource().getNode();
      list.add(languageUri);
      if (copyToNode) {
        readLock.lock();
        try {
          graph.addAll(new GraphNode(languageUri, configGraph).getNodeContext());
        } finally {
          readLock.unlock();
        }
      }
    }
    node.addProperty(PLATFORM.instance, platformInstance);
    graph.add(new TripleImpl(platformInstance, RDF.type, PLATFORM.Instance));
    graph.add(new TripleImpl(platformInstance, PLATFORM.languages, listNode));
    graph.add(new TripleImpl(listNode, RDF.type, LANGUAGE.LanguageList));
    if (!copyToNode) {
      node = new GraphNode(node.getNode(), new UnionMGraph(graph, configGraph));
    }
    return node;
  }
View Full Code Here

    this.tcAccessController = tcAccessController;
  }

  @Override
  public Object getService(Bundle arg0, ServiceRegistration arg1) {
    TripleCollection tc =
        new SecuredTripleCollection(tcManager.getGraph(name), name,
        tcAccessController);
    return new SimpleGraph(tc);
  }
View Full Code Here

          mGraphCache.remove(name);
        } else {
          continue;
        }
      }
      TripleCollection triples = newProvider.getTriples(name);
      if (triples instanceof MGraph) {
        mGraphCache.put(name, new MGraphHolder(newProvider, ensureLockable((MGraph)triples)));
        mGraphAppears(name);
      } else {
        graphAppears(name);
View Full Code Here

TOP

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

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.