use of org.apache.jena.cmd.CmdException in project jena by apache.
the class load method execUpdate.
@Override
protected void execUpdate(DatasetGraph dataset) {
if (loadFiles.size() == 0)
throw new CmdException("Nothing to do");
UpdateRequest req = new UpdateRequest();
for (String filename : loadFiles) {
UpdateLoad loadReq = new UpdateLoad(filename, graphName);
req.add(loadReq);
}
if (true) {
// Need a better way
monitor(dataset.getDefaultGraph());
for (Iterator<Node> iter = dataset.listGraphNodes(); iter.hasNext(); ) {
Graph g = dataset.getGraph(iter.next());
monitor(g);
}
}
UpdateExec.newBuilder().update(req).dataset(dataset).execute();
if (dump) {
IndentedWriter out = IndentedWriter.stdout;
SSE.write(dataset);
out.flush();
}
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class qparse method exec.
@Override
protected void exec() {
try {
Query query = modQuery.getQuery();
try {
LogCtl.disable(QueryParserBase.ParserLoggerName);
QueryUtils.checkQuery(query, true);
} catch (QueryCheckException ex) {
System.err.println();
System.err.println("**** Check failure: " + ex.getMessage());
if (ex.getCause() != null)
ex.getCause().printStackTrace(System.err);
} finally {
LogCtl.setLevel(QueryParserBase.ParserLoggerName, "INFO");
}
// Print the query out in some syntax
if (printQuery) {
divider();
modOutput.output(query);
}
// Print internal forms.
if (printOp) {
divider();
modOutput.outputOp(query, false);
}
if (printQuad) {
divider();
modOutput.outputQuad(query, false);
}
if (printOpt) {
divider();
modOutput.outputOp(query, true);
}
if (printQuadOpt) {
divider();
modOutput.outputQuad(query, true);
}
if (printPlan) {
divider();
// This forces internal query initialization - must be after QueryUtils.checkQuery
QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.createGeneral());
QueryOutputUtils.printPlan(query, qExec);
}
} catch (ARQInternalErrorException intEx) {
System.err.println(intEx.getMessage());
if (intEx.getCause() != null) {
System.err.println("Cause:");
intEx.getCause().printStackTrace(System.err);
System.err.println();
}
intEx.printStackTrace(System.err);
} catch (ResultSetException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
} catch (QueryException qEx) {
// System.err.println(qEx.getMessage()) ;
throw new CmdException("Query Exeception", qEx);
} catch (JenaException ex) {
ex.printStackTrace();
throw ex;
} catch (CmdException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Exception", ex);
}
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class rsparql method exec.
@Override
protected void exec() {
Query query = modQuery.getQuery();
try {
String serviceURL = modRemote.getServiceURL();
QuerySendMode sendMode = modRemote.usePost() ? QuerySendMode.asPost : QuerySendMode.systemDefault;
QueryExecutionHTTP qe = QueryExecutionHTTPBuilder.create().endpoint(serviceURL).query(query).sendMode(sendMode).build();
QueryExecUtils.executeQuery(query, qe, modResults.getResultsFormat());
} catch (QueryExceptionHTTP ex) {
throw new CmdException("HTTP Exception", ex);
} catch (Exception ex) {
System.out.flush();
ex.printStackTrace(System.err);
}
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class tdbloader method exec.
@Override
protected void exec() {
if (isVerbose()) {
System.out.println("Java maximum memory: " + Runtime.getRuntime().maxMemory());
System.out.println(ARQ.getContext());
}
if (isVerbose())
showProgress = true;
if (isQuiet())
showProgress = false;
List<String> urls = getPositional();
if (urls.size() != 0)
checkFiles(urls);
if (graphName == null) {
if (urls.size() == 0)
loadQuadsStdin();
else
loadQuads(urls);
return;
}
for (String url : urls) {
Lang lang = RDFLanguages.filenameToLang(url);
if (lang != null && RDFLanguages.isQuads(lang)) {
throw new CmdException("Warning: Quads format given - only the default graph is loaded into the graph for --graph");
}
}
loadTriples(graphName, urls);
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class ModTDBAssembler method processArgs.
@Override
public void processArgs(CmdArgModule cmdLine) {
int count = 0;
modLocation.processArgs(cmdLine);
super.processArgs(cmdLine);
if (super.getAssemblerFile() != null)
count++;
if (modLocation.getLocation() != null)
count++;
if (count == 0) {
useDefaultAssemblerFile = true;
// throw new CmdException("No assembler file and no location") ;
}
if (count > 1)
throw new CmdException("Only one of an assembler file and a location");
}
Aggregations