use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class UsageExamples method readTestData.
@BeforeClass
public static void readTestData() throws IOException {
//add the metadata
ParsingProvider parser = new JenaParserProvider();
//create the content Item with the HTML content
Graph rdfData = parseRdfData(parser, "example.rdf.zip");
IRI contentItemId = null;
Iterator<Triple> it = rdfData.filter(null, Properties.ENHANCER_EXTRACTED_FROM, null);
while (it.hasNext()) {
RDFTerm r = it.next().getObject();
if (contentItemId == null) {
if (r instanceof IRI) {
contentItemId = (IRI) r;
}
} else {
assertEquals("multiple ContentItems IDs contained in the RDF test data", contentItemId, r);
}
}
assertNotNull("RDF data doe not contain an Enhancement extracted form " + "the content item", contentItemId);
InputStream in = getTestResource("example.txt");
assertNotNull("Example Plain text content not found", in);
byte[] textData = IOUtils.toByteArray(in);
IOUtils.closeQuietly(in);
ci = ciFactory.createContentItem(contentItemId, new ByteArraySource(textData, "text/html; charset=UTF-8"));
ci.getMetadata().addAll(rdfData);
}
use of org.apache.clerezza.rdf.jena.parser.JenaParserProvider in project stanbol by apache.
the class ContentItemBackendTest method readTestData.
@BeforeClass
public static void readTestData() throws IOException {
//add the metadata
ParsingProvider parser = new JenaParserProvider();
//create the content Item with the HTML content
Graph rdfData = parseRdfData(parser, "metadata.rdf.zip");
IRI contentItemId = null;
Iterator<Triple> it = rdfData.filter(null, Properties.ENHANCER_EXTRACTED_FROM, null);
while (it.hasNext()) {
RDFTerm r = it.next().getObject();
if (contentItemId == null) {
if (r instanceof IRI) {
contentItemId = (IRI) r;
}
} else {
assertEquals("multiple ContentItems IDs contained in the RDF test data", contentItemId, r);
}
}
assertNotNull("RDF data doe not contain an Enhancement extracted form " + "the content item", contentItemId);
InputStream in = getTestResource("content.html");
assertNotNull("HTML content not found", in);
byte[] htmlData = IOUtils.toByteArray(in);
IOUtils.closeQuietly(in);
ci = ciFactory.createContentItem(contentItemId, new ByteArraySource(htmlData, "text/html; charset=UTF-8"));
htmlContent = new String(htmlData, UTF8);
//create a Blob with the text content
in = getTestResource("content.txt");
byte[] textData = IOUtils.toByteArray(in);
IOUtils.closeQuietly(in);
assertNotNull("Plain text content not found", in);
ci.addPart(new IRI(ci.getUri().getUnicodeString() + "_text"), ciFactory.createBlob(new ByteArraySource(textData, "text/plain; charset=UTF-8")));
textContent = new String(textData, UTF8);
//add the metadata
ci.getMetadata().addAll(rdfData);
}
Aggregations