use of jena.cmd.CmdException in project jena by apache.
the class qtest method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
super.processModulesAndArgs();
if (contains(queryDecl) || contains(dataDecl) || contains(resultDecl)) {
if (!(contains(queryDecl) && contains(dataDecl) && contains(resultDecl)))
throw new CmdException("Must give query, data and result to run a single test");
String query = getValue(queryDecl);
String data = getValue(dataDecl);
String result = getValue(resultDecl);
suite = ScriptTestSuiteFactory.make(query, data, result);
} else if (contains(allDecl)) {
execAllTests = true;
} else if (contains(wgDecl)) {
execDAWGTests = true;
} else {
if (!hasPositional())
throw new CmdException("No manifest file");
testfile = getPositionalArg(0);
createEarlReport = contains(earlDecl);
}
}
use of 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");
}
use of jena.cmd.CmdException in project jena by apache.
the class ModTDBDataset method createDataset.
@Override
public Dataset createDataset() {
if (inMemFile != null) {
Dataset ds = TDBFactory.createDataset();
RDFDataMgr.read(ds, inMemFile);
return ds;
}
if (modAssembler.getAssemblerFile() != null) {
Dataset thing = null;
// Two variants: plain dataset with a TDB graph or a TDB dataset.
try {
thing = (Dataset) AssemblerUtils.build(modAssembler.getAssemblerFile(), VocabTDB.tDatasetTDB);
if (thing != null && !(thing.asDatasetGraph() instanceof DatasetGraphTransaction))
Log.warn(this, "Unexpected: Not a TDB dataset for type DatasetTDB");
if (thing == null)
// Should use assembler inheritance but how do we assert the subclass relationship in a program?
thing = (Dataset) AssemblerUtils.build(modAssembler.getAssemblerFile(), DatasetAssemblerVocab.tDataset);
} catch (JenaException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Error creating", ex);
}
return thing;
}
if (modAssembler.getLocation() == null)
throw new CmdException("No assembler file nor location provided");
// No assembler - use location to find a database.
Dataset ds = TDBFactory.createDataset(modAssembler.getLocation());
return ds;
}
use of jena.cmd.CmdException in project jena by apache.
the class tdbdump method exec.
@Override
protected void exec() {
DatasetGraph dsg = super.getDatasetGraphTDB();
// Prefer stream over fully pretty output formats.
RDFFormat fmt = modLangOutput.getOutputStreamFormat();
//if ( fmt != null && StreamRDFWriter.registered(fmt) )
if (fmt == null)
fmt = modLangOutput.getOutputFormatted();
if (fmt == null)
// Default.
fmt = RDFFormat.NQUADS;
if (!RDFLanguages.isQuads(fmt.getLang()))
throw new CmdException("Databases can be dumped only in quad formats (e.g. Trig, N-Quads), not " + fmt.getLang());
RDFDataMgr.write(System.out, dsg, fmt);
}
use of 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(ParserBase.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(ParserBase.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);
}
}
Aggregations