use of org.apache.jena.sparql.lang.UpdateParser in project jena by apache.
the class UpdateAction method parseExecute.
/**
* Parse update operations into a GraphStore by parsing from an InputStream.
* @param usingList A list of USING or USING NAMED statements that be added to all {@link UpdateWithUsing} queries
* @param dataset The dataset to apply the changes to
* @param input The source of the update request (must be UTF-8).
* @param inputBinding Initial binding to be applied to Update operations that can apply an initial binding
* (i.e. UpdateDeleteWhere, UpdateModify). May be <code>null</code>
* @param baseURI The base URI for resolving relative URIs (may be <code>null</code>)
* @param syntax The update language syntax
*/
public static void parseExecute(UsingList usingList, DatasetGraph dataset, InputStream input, Binding inputBinding, String baseURI, Syntax syntax) {
UpdateProcessorStreaming uProc = UpdateExecutionFactory.createStreaming(dataset, inputBinding);
if (uProc == null)
throw new ARQException("No suitable update procesors are registered/able to execute your updates");
uProc.startRequest();
try {
UpdateSink sink = new UsingUpdateSink(uProc.getUpdateSink(), usingList);
try {
UpdateParser parser = UpdateFactory.setupParser(sink.getPrologue(), baseURI, syntax);
parser.parse(sink, input);
} finally {
sink.close();
}
} finally {
uProc.finishRequest();
}
}
use of org.apache.jena.sparql.lang.UpdateParser in project jena by apache.
the class UpdateFactory method make.
// Worker.
/** Append update operations to a request */
private static void make(UpdateRequest request, String input, String baseURI, Syntax syntax) {
UpdateParser parser = setupParser(request, baseURI, syntax);
parser.parse(new UpdateRequestSink(request), input);
}
use of org.apache.jena.sparql.lang.UpdateParser in project jena by apache.
the class UpdateFactory method make.
/** Append update operations to a request */
private static void make(UpdateRequest request, UsingList usingList, InputStream input, String baseURI, Syntax syntax) {
UpdateParser parser = setupParser(request, baseURI, syntax);
UpdateSink sink = new UsingUpdateSink(new UpdateRequestSink(request), usingList);
try {
parser.parse(sink, input);
} finally {
sink.close();
}
}
use of org.apache.jena.sparql.lang.UpdateParser in project jena by apache.
the class UpdateFactory method setupParser.
/** Append update operations to a request */
protected static UpdateParser setupParser(Prologue prologue, String baseURI, Syntax syntax) {
UpdateParser parser = UpdateParser.createParser(syntax);
if (parser == null)
throw new UnsupportedOperationException("Unrecognized syntax for parsing update: " + syntax);
if (prologue.getResolver() == null) {
IRIResolver resolver = null;
try {
if (baseURI != null)
// Sort out the baseURI - if that fails, dump in a dummy one and continue.
resolver = IRIResolver.create(baseURI);
else
resolver = IRIResolver.create();
} catch (Exception ex) {
}
if (resolver == null)
resolver = IRIResolver.create("http://localhost/update/defaultBase#");
prologue.setResolver(resolver);
}
return parser;
}
Aggregations