use of org.apache.jena.sparql.modify.UpdateProcessRemote in project webofneeds by researchstudio-sat.
the class SparqlService method executeUpdateQuery.
/**
* Execute a SPARQL Update query.
*
* @param updateQuery
*/
public void executeUpdateQuery(String updateQuery) {
log.debug("Update SPARQL Endpoint: {}", sparqlEndpoint);
log.debug("Execute query: {}", updateQuery);
UpdateRequest query = UpdateFactory.create(updateQuery);
UpdateProcessRemote riStore = (UpdateProcessRemote) UpdateExecutionFactory.createRemote(query, sparqlEndpoint);
riStore.execute();
}
use of org.apache.jena.sparql.modify.UpdateProcessRemote in project webofneeds by researchstudio-sat.
the class SparqlService method executeUpdate.
public void executeUpdate(UpdateRequest updateRequest) {
try {
if (logger.isDebugEnabled()) {
logger.debug("Update SPARQL Endpoint: {}", sparqlEndpoint);
logger.debug("number of updates: {}", updateRequest.getOperations().size());
}
UpdateProcessRemote riStore = (UpdateProcessRemote) UpdateExecutionFactory.createRemote(updateRequest, sparqlEndpoint);
riStore.execute();
} catch (Exception e) {
logger.warn("Error sending update request: {} ", updateRequest, e);
}
}
use of org.apache.jena.sparql.modify.UpdateProcessRemote in project webofneeds by researchstudio-sat.
the class SparqlUpdateCrawlerCallback method onDatasetCrawled.
@Override
public void onDatasetCrawled(final URI uri, final Dataset dataset) {
if (null == sparqlEndpoint) {
logger.warn("no SPARQL endpoint defined");
return;
}
Iterator<String> graphNames = dataset.listNames();
while (graphNames.hasNext()) {
StringBuilder quadpatterns = new StringBuilder();
String graphName = graphNames.next();
Model model = dataset.getNamedModel(graphName);
StringWriter sw = new StringWriter();
RDFDataMgr.write(sw, model, Lang.NTRIPLES);
quadpatterns.append("\nINSERT DATA { GRAPH <").append(graphName).append("> { ").append(sw).append("}};\n");
logger.info(quadpatterns.toString());
UpdateRequest update = UpdateFactory.create(quadpatterns.toString());
UpdateProcessRemote riStore = (UpdateProcessRemote) UpdateExecutionFactory.createRemote(update, sparqlEndpoint);
riStore.execute();
}
}
Aggregations