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

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


    Lock l = permissionMGraph.getLock().writeLock();
    l.lock();
    try {
      removeExistingRequiredReadPermissions(tripleCollectionUri, permissionMGraph);
      final NonLiteral permissionList = createList(permissionDescriptions.iterator(), permissionMGraph);
      permissionMGraph.add(new TripleImpl(tripleCollectionUri,
          readPermissionListProperty, permissionList));
    } finally {
      l.unlock();
    }
  }
View Full Code Here


    Lock l = permissionMGraph.getLock().writeLock();
    l.lock();
    try {
      removeExistingRequiredReadPermissions(tripleCollectionUri, permissionMGraph);
      final NonLiteral permissionList = createList(permissionDescriptions.iterator(), permissionMGraph);
      permissionMGraph.add(new TripleImpl(tripleCollectionUri,
          readWritePermissionListProperty, permissionList));
    } finally {
      l.unlock();
    }
  }
View Full Code Here

  private NonLiteral createList(Iterator<String> iterator, LockableMGraph permissionMGraph) {
    if (!iterator.hasNext()) {
      return rdfNil;
    }
    final BNode result = new BNode();
    permissionMGraph.add(new TripleImpl(result, first,
        LiteralFactory.getInstance().createTypedLiteral(iterator.next())));
    permissionMGraph.add(new TripleImpl(result, rest,
        createList(iterator, permissionMGraph)));
    return result;

  }
View Full Code Here

    mGraph.removeAll(triplesToRemove);
  }
  private static Triple getReplacement(Triple triple, BNode bNode, NonLiteral replacementNode) {
    if (triple.getSubject().equals(bNode)) {
      if (triple.getObject().equals(bNode)) {
        return new TripleImpl(replacementNode, triple.getPredicate(), replacementNode);
      } else {
        return new TripleImpl(replacementNode, triple.getPredicate(), triple.getObject());
      }
    } else {
      if (triple.getObject().equals(bNode)) {
        return new TripleImpl(triple.getSubject(), triple.getPredicate(), replacementNode);
      } else {
        return null;
      }
    }
  }
View Full Code Here

    NonLiteral mother = new UriRef("http://example.org/mother");
    NonLiteral me = new UriRef("http://example.org/me");
    NonLiteral sister = new UriRef("http://example.org/sister");
    NonLiteral uncle = new UriRef("http://example.org/uncle");
    NonLiteral cousin = new UriRef("http://example.org/cousin");
    base.add(new TripleImpl(me, SiblingEnricher.parentProperty, mother));
    base.add(new TripleImpl(sister, SiblingEnricher.parentProperty, mother));
    base.add(new TripleImpl(mother, SiblingEnricher.parentProperty, grandMother));
    base.add(new TripleImpl(uncle, SiblingEnricher.parentProperty, grandMother));
    base.add(new TripleImpl(cousin, SiblingEnricher.parentProperty, uncle));
    Assert.assertTrue(enrichmentTriples.filter(sister, SiblingEnricher.siblingProperty, me).hasNext());
    Assert.assertTrue(enrichmentTriples.filter(uncle, SiblingEnricher.siblingProperty, mother).hasNext());
    Assert.assertFalse(enrichmentTriples.filter(uncle, SiblingEnricher.siblingProperty, sister).hasNext());
  }
View Full Code Here

    Enricher cityEnricher = new CityWeatherEnricher();
    TripleCollection enrichmentTriples = new EnrichmentTriples(base,
        Collections.singleton(cityEnricher));
    NonLiteral london = new UriRef("http://example.org/london");
    NonLiteral me = new UriRef("http://example.org/me");
    base.add(new TripleImpl(me, RDF.type, FOAF.Agent));
    base.add(new TripleImpl(london, RDF.type, CityWeatherEnricher.classCity));
    Assert.assertTrue(enrichmentTriples.filter(london, CityWeatherEnricher.weatherProperty, null).hasNext());
    GraphNode node = new GraphNode(london, enrichmentTriples);
    Assert.assertEquals("0.51",
        node.getObjectNodes(CityWeatherEnricher.weatherProperty).next()
        .getLiterals(CityWeatherEnricher.humidityProperty).next().getLexicalForm());
View Full Code Here

      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) {
        cityWeatherMap.remove(nonLiteral);
      }
      if (predicate.equals(temperatureProperty) || (predicate == null)) {
        resultSet.add(new TripleImpl(subject,
            temperatureProperty, LiteralFactory.getInstance().createTypedLiteral((double)city.toString().length())));
      }
      if (predicate.equals(humidityProperty) || (predicate == null)) {
        resultSet.add(new TripleImpl(subject,
            humidityProperty, LiteralFactory.getInstance().createTypedLiteral(0.51)));
      }
    }
    return resultSet.iterator();
  }
View Full Code Here

  }

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

  }

  @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

  }

  @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

TOP

Related Classes of org.apache.clerezza.rdf.core.impl.TripleImpl

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.