Search in sources :

Example 1 with UpdateProcessRemote

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();
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateProcessRemote(org.apache.jena.sparql.modify.UpdateProcessRemote)

Example 2 with UpdateProcessRemote

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);
    }
}
Also used : UpdateProcessRemote(org.apache.jena.sparql.modify.UpdateProcessRemote)

Example 3 with UpdateProcessRemote

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();
    }
}
Also used : StringWriter(java.io.StringWriter) UpdateRequest(org.apache.jena.update.UpdateRequest) Model(org.apache.jena.rdf.model.Model) UpdateProcessRemote(org.apache.jena.sparql.modify.UpdateProcessRemote)

Aggregations

UpdateProcessRemote (org.apache.jena.sparql.modify.UpdateProcessRemote)3 UpdateRequest (org.apache.jena.update.UpdateRequest)2 StringWriter (java.io.StringWriter)1 Model (org.apache.jena.rdf.model.Model)1