Search in sources :

Example 1 with ContentItemBackend

use of org.apache.stanbol.enhancer.ldpath.backend.ContentItemBackend in project stanbol by apache.

the class ContentItemBackendTest method testContentWithAdditionalMetadata.

@Test
public void testContentWithAdditionalMetadata() throws IOException, LDPathParseException {
    byte[] content = "text content".getBytes();
    IRI uri = ContentItemHelper.makeDefaultUrn(content);
    ContentItem contentItem = ciFactory.createContentItem(uri, new ByteArraySource(content, "text/plain; charset=UTF-8"));
    Graph tc = new SimpleGraph();
    Literal literal = LiteralFactory.getInstance().createTypedLiteral("Michael Jackson");
    IRI subject = new IRI("dummyUri");
    tc.add(new TripleImpl(subject, new IRI("http://xmlns.com/foaf/0.1/givenName"), literal));
    contentItem.addPart(new IRI(uri.getUnicodeString() + "_additionalMetadata"), tc);
    ContentItemBackend ciBackend = new ContentItemBackend(contentItem, true);
    LDPath<RDFTerm> ldPath = new LDPath<RDFTerm>(ciBackend, EnhancerLDPath.getConfig());
    Collection<RDFTerm> result = ldPath.pathQuery(subject, "foaf:givenName", null);
    assertTrue("Additional metadata cannot be found", result.contains(literal));
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) LDPath(org.apache.marmotta.ldpath.LDPath) RDFTerm(org.apache.clerezza.commons.rdf.RDFTerm) IndexedGraph(org.apache.stanbol.commons.indexedgraph.IndexedGraph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) Graph(org.apache.clerezza.commons.rdf.Graph) Literal(org.apache.clerezza.commons.rdf.Literal) ContentItemBackend(org.apache.stanbol.enhancer.ldpath.backend.ContentItemBackend) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl) ContentItem(org.apache.stanbol.enhancer.servicesapi.ContentItem) ByteArraySource(org.apache.stanbol.enhancer.servicesapi.impl.ByteArraySource) Test(org.junit.Test)

Aggregations

Graph (org.apache.clerezza.commons.rdf.Graph)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 Literal (org.apache.clerezza.commons.rdf.Literal)1 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)1 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)1 SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)1 LDPath (org.apache.marmotta.ldpath.LDPath)1 IndexedGraph (org.apache.stanbol.commons.indexedgraph.IndexedGraph)1 ContentItemBackend (org.apache.stanbol.enhancer.ldpath.backend.ContentItemBackend)1 ContentItem (org.apache.stanbol.enhancer.servicesapi.ContentItem)1 ByteArraySource (org.apache.stanbol.enhancer.servicesapi.impl.ByteArraySource)1 Test (org.junit.Test)1