use of org.apache.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 org.apache.jena.cmd.CmdException in project jena by apache.
the class tdbdump method exec.
@Override
protected void exec() {
DatasetGraph dsg = getDatasetGraph();
// 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());
RDFFormat fmtFinal = fmt;
Txn.executeRead(dsg, () -> RDFDataMgr.write(System.out, dsg, fmtFinal));
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class CmdNodeTableBuilder method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
if (!super.contains(argLocation))
throw new CmdException("Required: --loc DIR");
// if ( !super.contains(argTriplesOut) ) throw new CmdException("Required: --triples FILE") ;
// if ( !super.contains(argQuadsOut) ) throw new CmdException("Required: --quads FILE") ;
locationString = super.getValue(argLocation);
location = Location.create(locationString);
dataFileTriples = super.getValue(argTriplesOut);
if (dataFileTriples == null)
dataFileTriples = location.getPath("triples", "tmp");
dataFileQuads = super.getValue(argQuadsOut);
if (dataFileQuads == null)
dataFileQuads = location.getPath("quads", "tmp");
if (Objects.equals(dataFileTriples, dataFileQuads))
cmdError("Triples and Quads work files are the same");
if (super.contains(argNoStats))
collectStats = false;
// datafiles = getPositionalOrStdin() ;
datafiles = getPositional();
if (datafiles.isEmpty())
datafiles = Arrays.asList("-");
// ---- Checking.
for (String filename : datafiles) {
Lang lang = RDFLanguages.filenameToLang(filename, RDFLanguages.NQUADS);
if (lang == null)
// Does not happen due to default above.
cmdError("File suffix not recognized: " + filename);
if (!filename.equals("-") && !FileOps.exists(filename))
cmdError("File does not exist: " + filename);
}
}
use of org.apache.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 org.apache.jena.cmd.CmdException in project jena by apache.
the class tdbloader method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
super.processModulesAndArgs();
if (super.contains(argSyntax)) {
String syntax = super.getValue(argSyntax);
Lang lang$ = RDFLanguages.nameToLang(syntax);
if (lang$ == null)
throw new CmdException("Can not detemine the syntax from '" + syntax + "'");
this.lang = lang$;
}
}
Aggregations