Package org.apache.clerezza.rdf.core

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


  public void siblingAddition() {
    MGraph base = new SimpleMGraph();
    Enricher siblingEnricher = new SiblingEnricher();
    TripleCollection enrichmentTriples = new EnrichmentTriples(base,
        Collections.singleton(siblingEnricher));
    NonLiteral grandMother = new UriRef("http://example.org/grand");
    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));
View Full Code Here


  public void cityWeather() {
    MGraph base = new SimpleMGraph();
    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",
View Full Code Here

    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

    }
    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

      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)));
      }
View Full Code Here

    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();) {
      NonLiteral titledContent = it.next().getSubject();
      if (docMGraph.filter(null, DISCOBITS.holds, titledContent).hasNext()) {
        continue;
      }
      triple = new TripleImpl(bundleUri, DOCUMENTATION.documentation,
          titledContent);
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;
    }
View Full Code Here

  private void process(Graph documentationGraph, File outputDir) throws IOException {
    Set<NonLiteral> docRoots = new HashSet<NonLiteral>();
    Iterator<Triple> titledContentTypeTriples =
        documentationGraph.filter(null, RDF.type, DISCOBITS.TitledContent);
    while (titledContentTypeTriples.hasNext()) {
      NonLiteral titleContent = titledContentTypeTriples.next().getSubject();
      if (!documentationGraph.filter(null, DISCOBITS.holds, titleContent).hasNext()) {
        docRoots.add(titleContent);
        System.out.println("doc root: " + titleContent);
      }
    }
View Full Code Here

   *    It is the responsibility of the calling function to set the write lock, if necessary.
   * @return
   */
  @Override
  public GraphNode addUserContext(final GraphNode node) { 
    final NonLiteral platformInstance = AccessController.doPrivileged(
      new PrivilegedAction<NonLiteral>() {
        @Override
        public NonLiteral run() {
          return (NonLiteral) platformConfig.getPlatformInstance().getNode();
        }
View Full Code Here

    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());
View Full Code Here

TOP

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

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.