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

Examples of org.apache.clerezza.rdf.core.impl.SimpleMGraph.filter()


  predicates.add(new PropertyHolder(FOAF.lastName));

  List<VirtualProperty>  properties = new java.util.ArrayList<VirtualProperty>();
  properties.add(new JoinVirtualProperty(predicates));
    indexDefinitionManager.addDefinitionVirtual(FOAF.Person, properties);
    Iterator<Triple> typeStmtIter = indexManagerGraph.filter(null, RDF.type, CRIS.JoinVirtualProperty);
    Assert.assertTrue(typeStmtIter.hasNext());
    //Assert.assertEquals(manuallyCreatedGraph.getGraph, indexManagerGraph.getGraph)
  }
}
View Full Code Here


    ParsingProvider provider = new RdfJsonParsingProvider();
    InputStream jsonIn = getClass().getResourceAsStream("test-object-bnode.json");
    MGraph parsedMGraph = new SimpleMGraph();
    provider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
    Assert.assertEquals(parsedMGraph.size(), 1);
    Iterator<Triple> triples = parsedMGraph.filter(new UriRef("http://example.org/node1"),
        new UriRef("http://example.org/prop1"), null);
    Assert.assertTrue(triples.hasNext());
    Assert.assertTrue(triples.next().getObject() instanceof BNode);
  }
View Full Code Here

    ParsingProvider provider = new RdfJsonParsingProvider();
    InputStream jsonIn = getClass().getResourceAsStream("test-subject-bnode.json");
    MGraph parsedMGraph = new SimpleMGraph();
    provider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
    Assert.assertEquals(3, parsedMGraph.size());
    Iterator<Triple> triples = parsedMGraph.filter(null, new UriRef("http://example.org/prop1"),
        new UriRef("http://example.org/node1"));
    Assert.assertTrue(triples.hasNext());
    NonLiteral subject = triples.next().getSubject();
    Assert.assertTrue(subject instanceof BNode);
View Full Code Here

        new UriRef("http://example.org/node1"));
    Assert.assertTrue(triples.hasNext());
    NonLiteral subject = triples.next().getSubject();
    Assert.assertTrue(subject instanceof BNode);

    triples = parsedMGraph.filter(null, new UriRef("http://example.org/prop2"),
        new UriRef("http://example.org/node2"));
    Assert.assertTrue(triples.hasNext());
    Assert.assertTrue(subject.equals(triples.next().getSubject()));

    triples = parsedMGraph.filter(null, new UriRef("http://example.org/prop3"),
View Full Code Here

    triples = parsedMGraph.filter(null, new UriRef("http://example.org/prop2"),
        new UriRef("http://example.org/node2"));
    Assert.assertTrue(triples.hasNext());
    Assert.assertTrue(subject.equals(triples.next().getSubject()));

    triples = parsedMGraph.filter(null, new UriRef("http://example.org/prop3"),
        new UriRef("http://example.org/node3"));
    Assert.assertTrue(triples.hasNext());
    Assert.assertFalse(subject.equals(triples.next().getSubject()));
  }
View Full Code Here

    ParsingProvider provider = new RdfJsonParsingProvider();
    InputStream jsonIn = getClass().getResourceAsStream("test.json");
    MGraph deserializedMGraph = new SimpleMGraph();
    provider.parse(deserializedMGraph, jsonIn, "application/rdf+json", null);
    Assert.assertEquals(deserializedMGraph.size(), 6);
    Iterator<Triple> triples = deserializedMGraph.filter(new UriRef("http://base/child1"), null, null);
    while (triples.hasNext()) {
      UriRef uri = triples.next().getPredicate();
      Assert.assertEquals(uri.getUnicodeString(), "http://base/propertyB");
    }
  }
View Full Code Here

    @Override
    public MGraph annotateGraph(Graph rawRDF) {
        MGraph graph = new SimpleMGraph(rawRDF);
        LiteralFactory literalFactory = LiteralFactory.getInstance();
        Iterator<Triple> tripleIterator = graph.filter(null, targetResourcePredicate, targetResourceValue);
        List<NonLiteral> processedURIs = new ArrayList<NonLiteral>();

        // add cms object annotations
        while (tripleIterator.hasNext()) {
            Triple t = tripleIterator.next();
View Full Code Here

                /*
                 * if this object has already has name and path annotations, it means that it's already
                 * processed as child of another object. So, don't put new name annotations
                 */
                if (!graph.filter(subject, CMSAdapterVocabulary.CMS_OBJECT_NAME, null).hasNext()) {
                    graph.add(new TripleImpl(subject, CMSAdapterVocabulary.CMS_OBJECT_NAME, literalFactory
                            .createTypedLiteral(name)));
                }

                // check children and add child and parent annotations
View Full Code Here

                    MGraph metadata = new SimpleMGraph();
                    ContentStream cs = ((Document) child).getContentStream();
                    parser.parse(metadata, cs.getStream(), SupportedFormat.RDF_XML);

                    Iterator<Triple> triples = metadata.filter(null, null, null);
                    while (triples.hasNext()) {
                        Triple t = triples.next();
                        String predicate = t.getPredicate().getUnicodeString();
                        String shortPredicate = NamespaceEnum.getShortName(predicate);
                        if (shortPredicate.equals(predicate)) {
View Full Code Here

                    } else {
                        property = new UriRef(
                            NamespaceMappingUtils.getConfiguredUri(nsPrefixService, propertyString));
                        log.info("Iterate over values of property {}", property);
                    }
                    it = graph.filter(null, property, null);
                }
                while(it.hasNext()){
                    Resource value = it.next().getObject();
                    if(value instanceof Literal){
                        return ((Literal)value).getLexicalForm();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.