Package org.apache.clerezza.rdf.core

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


    }
  }
  private static void replaceNode(MGraph mGraph, BNode bNode, NonLiteral replacementNode) {
    Set<Triple> triplesToRemove = new HashSet<Triple>();
    for (Triple triple : mGraph) {
      Triple replacementTriple = getReplacement(triple, bNode, replacementNode);
      if (replacementTriple != null) {
        triplesToRemove.add(triple);
        mGraph.add(replacementTriple);
      }
    }
View Full Code Here


  private Collection<OntologyResource> getResourcesOfType(UriRef type, Collection<OntologyResource> ignore) {
    Set<OntologyResource> result = new HashSet<OntologyResource>();
    Iterator<Triple> classStatemente = schemaGraph.filter(null, RDF.type,
        type);
    while (classStatemente.hasNext()) {
      Triple triple = classStatemente.next();
      NonLiteral classResource = triple.getSubject();
      if (classResource instanceof BNode) {
        if (type !=null) System.err.println("Ignoring anonymous resource of type " + type.getUnicodeString());
        else System.err.println("Ignoring anonymous resource");
        for (Triple contextTriple : getNodeContext(classResource, schemaGraph)) {
          System.err.println(contextTriple);
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));
View Full Code Here

   * @param bundle
   * @param docMGraph
   */
  private void addAdditionalTriples(Bundle bundle, MGraph docMGraph) {
    UriRef bundleUri = new UriRef(bundle.getLocation());
    Triple triple = new TripleImpl(bundleUri, RDF.type, OSGI.Bundle);
    docMGraph.add(triple);
    Iterator<Triple> titledContents = docMGraph.filter(null, RDF.type,
        DISCOBITS.TitledContent);
    Set<Triple> newTriples = new HashSet<Triple>();
    for (Iterator<Triple> it = titledContents; it.hasNext();) {
View Full Code Here

   * Add or removes randomly a triple.
   *
   * @return the triple that was added or removed.
   */
  public Triple evolve() {
    Triple triple;
    int random = rollDice(2);
    if (random == 0 && size() != 0) {
      triple = getRandomTriple();
      remove(triple);
    } else {
View Full Code Here

   * Removes a random triple.
   *
   * @return the triple that was removed.
   */
  public Triple removeRandomTriple() {
    Triple randomTriple = getRandomTriple();
    remove(randomTriple);
    return randomTriple;
  }
View Full Code Here

   * Adds a random triple.
   *
   * @return the triple that was added.
   */
  public Triple addRandomTriple() {
    Triple randomTriple;
    do {
     randomTriple = createRandomTriple();
    } while(contains(randomTriple));
   
    add(randomTriple);
View Full Code Here

    }
    throw new RuntimeException("in createRandomResource()");
  }

  private Resource getExistingResource() {
    Triple triple = getRandomTriple();
    if (triple == null) {
      return null;
    }
    switch (rollDice(3)) {
      case 0:
        return triple.getSubject();
      case 1:
        return triple.getPredicate();
      case 2:
        return triple.getObject();
    }
    return null;
  }
View Full Code Here

    if (size == 0) {
      return null;
    }
    Iterator<Triple> triples = iterator();
    while (triples.hasNext()) {
      Triple triple = triples.next();
      if (rollDice(this.size()) == 0) {
        return triple;
      }
    }
    return getRandomTriple();
View Full Code Here

    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

TOP

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

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.