use of org.apache.jena.riot.system.StreamRDF in project jena by apache.
the class REST_Quads_RW method doPutPostNonTxn.
private void doPutPostNonTxn(HttpAction action, boolean clearFirst) {
DatasetGraph dsgTmp = DatasetGraphFactory.create();
StreamRDF dest = StreamRDFLib.dataset(dsgTmp);
UploadDetails details;
try {
details = Upload.incomingData(action, dest);
} catch (RiotException ex) {
ServletOps.errorBadRequest(ex.getMessage());
return;
}
// Now insert into dataset
action.beginWrite();
try {
DatasetGraph dsg = action.getActiveDSG();
if (clearFirst)
dsg.clear();
FusekiLib.addDataInto(dsgTmp, dsg);
action.commit();
ServletOps.success(action);
} catch (Exception ex) {
// but it might and there is no harm safely trying.
try {
action.abort();
} catch (Exception ex2) {
}
ServletOps.errorOccurred(ex.getMessage());
} finally {
action.endWrite();
}
ServletOps.uploadResponse(action, details);
}
use of org.apache.jena.riot.system.StreamRDF in project jena by apache.
the class GraphLoadUtils method readUtil.
// ** Worker.
private static void readUtil(Graph graph, String uri, int limit) {
StreamRDF sink = StreamRDFLib.graph(graph);
sink = new StreamRDFLimited(sink, limit);
RDFParser.source(uri).streamManager(Fuseki.webStreamManager).parse(sink);
}
use of org.apache.jena.riot.system.StreamRDF in project jena by apache.
the class SPARQL_GSP_RW method addDataIntoNonTxn.
/** Add data where the destination does not support full transactions.
* In particular, with no abort, and actions probably going to the real storage
* parse errors can lead to partial updates. Instead, parse to a temporary
* graph, then insert that data.
* @param action
* @param cleanDest Whether to remove data first (true = PUT, false = POST)
* @return whether the target existed beforehand.
*/
protected static UploadDetails addDataIntoNonTxn(HttpAction action, boolean overwrite) {
Graph graphTmp = GraphFactory.createGraphMem();
StreamRDF dest = StreamRDFLib.graph(graphTmp);
UploadDetails details;
try {
details = Upload.incomingData(action, dest);
} catch (RiotException ex) {
ServletOps.errorBadRequest(ex.getMessage());
return null;
}
// Now insert into dataset
action.beginWrite();
Target target = determineTarget(action);
boolean existedBefore = false;
try {
if (action.log.isDebugEnabled())
action.log.debug(" ->" + target);
existedBefore = target.exists();
if (overwrite && existedBefore)
clearGraph(target);
FusekiLib.addDataInto(graphTmp, target.dsg, target.graphName);
details.setExistedBefore(existedBefore);
action.commit();
return details;
} catch (Exception ex) {
// but it might and there is no harm safely trying.
try {
action.abort();
} catch (Exception ex2) {
}
ServletOps.errorOccurred(ex.getMessage());
return null;
} finally {
action.endWrite();
}
}
use of org.apache.jena.riot.system.StreamRDF in project jena by apache.
the class infer method exec.
@Override
protected void exec() {
StreamRDF sink = StreamRDFLib.writer(System.out);
sink = InfFactory.inf(sink, vocab);
List<String> files = getPositionalOrStdin();
if (files.isEmpty())
files.add("-");
for (String fn : files) processFile(fn, sink);
IO.flush(System.out);
}
use of org.apache.jena.riot.system.StreamRDF in project jena by apache.
the class ParserTestBaseLib method parseDataset.
/** Parse for a language - convert errors and warning to ErrorHandlerEx */
static DatasetGraph parseDataset(Lang lang, String... strings) {
DatasetGraph dsg = DatasetGraphFactory.create();
StreamRDF dest = StreamRDFLib.dataset(dsg);
parse(lang, dest, strings);
return dsg;
}
Aggregations