Skip to content

Commit

Permalink
Get the InputStream directly, do not unmarshal to String
Browse files Browse the repository at this point in the history
  • Loading branch information
carenini committed Dec 17, 2019
1 parent c31ec56 commit 7255810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class RMLProcessor implements Processor{
public void process(Exchange exchange) throws Exception {
Repository repo=null;
Message in = exchange.getIn();
String incoming_message = in.getBody(String.class);
InputStream incoming_message = in.getBody(InputStream.class);
String stream_label=null;

// RML Processor configuration
Expand All @@ -73,7 +73,7 @@ public void process(Exchange exchange) throws Exception {
log.info("RML label: "+stream_label);
repo=exchange.getProperty(ProcessorConstants.CONTEXT_GRAPH, RDFGraph.class).getRepository();

streamsMap.put("stream://"+stream_label, new ByteArrayInputStream(incoming_message.getBytes()));
streamsMap.put("stream://"+stream_label, incoming_message);

// RML mappings execution
try (RepositoryConnection con = repo.getConnection()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package it.cefriel.chimera.processor.rdf4j;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.apache.camel.Exchange;
Expand All @@ -41,19 +40,17 @@ public class TurtleDataParser implements Processor{
public void process(Exchange exchange) throws Exception {
Repository repo=null;
RDFParser rdfParser = null;
InputStream inStream = null;
Model model = new LinkedHashModel();
ValueFactory vf = SimpleValueFactory.getInstance();

Message in = exchange.getIn();
String input_msg=in.getBody(String.class);
InputStream input_msg=in.getBody(InputStream.class);
repo=exchange.getProperty(ProcessorConstants.CONTEXT_GRAPH, RDFGraph.class).getRepository();

try (RepositoryConnection con = repo.getConnection()) {
rdfParser=Rio.createParser(RDFFormat.TURTLE);
rdfParser.setRDFHandler(new StatementCollector(model));
inStream=new ByteArrayInputStream(input_msg.getBytes());
rdfParser.parse(inStream, "http://www.cefriel.com/knowledgetech");
rdfParser.parse(input_msg, "http://www.cefriel.com/knowledgetech");
con.add(model, vf.createIRI("http://www.cefriel.com/knowledgetech"));

}
Expand Down

0 comments on commit 7255810

Please sign in to comment.