use of org.eclipse.rdf4j.rio.RDFHandlerException in project rdf-transform by AtesComp.
the class PreviewRDFRecordVisitor method visit.
public boolean visit(Project theProject, Record theRecord) {
// Test for end of sample...
if (this.iLimit > 0 && this.iCount >= this.iLimit) {
// ...stop visitation process
return true;
}
try {
if (Util.isDebugMode())
PreviewRDFRecordVisitor.logger.info("DEBUG: Visiting Record: " + theRecord.recordIndex + " on count: " + this.iCount);
ParsedIRI baseIRI = this.getRDFTransform().getBaseIRI();
RepositoryConnection theConnection = this.getModel().getConnection();
ValueFactory theFactory = theConnection.getValueFactory();
List<ResourceNode> listRoots = this.getRDFTransform().getRoots();
for (ResourceNode root : listRoots) {
root.createStatements(baseIRI, theFactory, theConnection, theProject, theRecord);
if (Util.isDebugMode()) {
PreviewRDFRecordVisitor.logger.info("DEBUG: " + "Root: " + root.getNodeName() + "(" + root.getNodeType() + ") " + "Size: " + theConnection.size());
}
}
this.iCount += 1;
// Flush all statements...
this.flushStatements();
} catch (RepositoryException ex) {
PreviewRDFRecordVisitor.logger.error("Connection Issue: ", ex);
if (Util.isVerbose() || Util.isDebugMode())
ex.printStackTrace();
// ...stop visitation process
return true;
} catch (RDFHandlerException ex) {
PreviewRDFRecordVisitor.logger.error("Flush Issue: ", ex);
if (Util.isVerbose() || Util.isDebugMode())
ex.printStackTrace();
// ...stop visitation process
return true;
}
return false;
}
use of org.eclipse.rdf4j.rio.RDFHandlerException in project rdf-transform by AtesComp.
the class PreviewRDFRowVisitor method visit.
public boolean visit(Project theProject, int iRowIndex, Row theRow) {
// Test for end of sample...
if (this.iLimit > 0 && this.iCount >= this.iLimit) {
// ...stop visitation process
return true;
}
try {
if (Util.isDebugMode())
PreviewRDFRowVisitor.logger.info("DEBUG: Visiting Row: " + iRowIndex + " on count: " + this.iCount);
ParsedIRI baseIRI = this.getRDFTransform().getBaseIRI();
RepositoryConnection theConnection = this.getModel().getConnection();
ValueFactory theFactory = theConnection.getValueFactory();
List<ResourceNode> listRoots = this.getRDFTransform().getRoots();
for (ResourceNode root : listRoots) {
root.createStatements(baseIRI, theFactory, theConnection, theProject, iRowIndex);
if (Util.isDebugMode()) {
PreviewRDFRowVisitor.logger.info("DEBUG: " + "Root: " + root.getNodeName() + "(" + root.getNodeType() + ") " + "Size: " + theConnection.size());
}
}
this.iCount += 1;
this.flushStatements();
} catch (RepositoryException ex) {
PreviewRDFRowVisitor.logger.error("Connection Issue: ", ex);
if (Util.isVerbose() || Util.isDebugMode())
ex.printStackTrace();
// ...stop visitation process
return true;
} catch (RDFHandlerException ex) {
PreviewRDFRowVisitor.logger.error("Flush Issue: ", ex);
if (Util.isVerbose() || Util.isDebugMode())
ex.printStackTrace();
// ...stop visitation process
return true;
}
return false;
}
use of org.eclipse.rdf4j.rio.RDFHandlerException in project corese by Wimmics.
the class Rdf4jExperimentations method testRio.
@Test
public void testRio() throws IOException {
InputStream input_stream = Rdf4jExperimentations.class.getResourceAsStream("peopleWork.ttl");
CoreseModel model = new CoreseModel();
RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE);
rdfParser.setRDFHandler(new StatementCollector(model));
try {
rdfParser.parse(input_stream);
} catch (IOException e) {
// handle IO problems (e.g. the file could not be read)
} catch (RDFParseException e) {
// handle unrecoverable parse error
} catch (RDFHandlerException e) {
// handle a problem encountered by the RDFHandler
} finally {
try {
input_stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
URL url_output = Rdf4jExperimentations.class.getResource("peopleWorkResult.ttl");
FileOutputStream out = new FileOutputStream(url_output.getPath());
try {
Rio.write(model, out, RDFFormat.TURTLE);
} finally {
out.close();
}
}
use of org.eclipse.rdf4j.rio.RDFHandlerException in project incubator-streampipes by apache.
the class Deployment method getDescriptionAsJsonLd.
@POST
@Path("/description/jsonld")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response getDescriptionAsJsonLd(@FormDataParam("config") String config, @FormDataParam("model") String model) {
DeploymentConfiguration deploymentConfig = fromJson(config);
NamedStreamPipesEntity element = getElement(deploymentConfig, model);
try {
return Response.ok(JsonLdUtils.asString(new JsonLdTransformer().toJsonLd(element))).build();
} catch (RDFHandlerException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException | InvalidRdfException e) {
return Response.serverError().build();
}
}
use of org.eclipse.rdf4j.rio.RDFHandlerException in project ldp-coap-framework by sisinflab-swot.
the class CoAPLDPResourceManager method getFullResourceTuple.
private String getFullResourceTuple(String res, RDFFormat format) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
RDFWriter writer = Rio.createWriter(format, out);
writer.startRDF();
for (String prefix : ns.keySet()) {
writer.handleNamespace(prefix, ns.get(prefix));
}
writeStatement(writer, res);
writer.endRDF();
return out.toString();
} catch (RepositoryException e) {
e.printStackTrace();
} catch (RDFHandlerException e) {
e.printStackTrace();
}
return null;
}
Aggregations