use of org.apache.jena.cmd.CmdException in project jena by apache.
the class AbstractCmdxLoad method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
if (!super.hasArg(argLocation))
throw new CmdException("Required: --loc=");
location = super.getValue(argLocation);
tmpdir = super.getValue(argTmpdir);
indexName = super.getValue(argIndex);
if (location != null)
checkDirectory(location);
if (tmpdir != null)
checkDirectory(tmpdir);
else
tmpdir = location;
filenames = new ArrayList<>(super.getPositional());
if (super.contains(argSortThreads)) {
String str = super.getValue(argSortThreads);
try {
sortThreads = Integer.parseInt(str);
} catch (NumberFormatException ex) {
throw new CmdException("--threads :: Failed to parse '" + str + "' as an integer");
}
}
subCheckArgs();
loaderFiles = new XLoaderFiles(tmpdir);
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class load method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
if (containsMultiple(graphNameArg))
throw new CmdException("At most one --graph allowed");
graphName = getValue(graphNameArg);
loadFiles = super.getPositional();
dump = contains(dumpArg);
super.processModulesAndArgs();
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class update method execUpdate.
// Subclass for specialised commands making common updates more convenient
@Override
protected void execUpdate(DatasetGraph graphStore) {
if (requestFiles.size() == 0 && getPositional().size() == 0)
throw new CmdException("Nothing to do");
Transactional transactional = graphStore;
for (String filename : requestFiles) Txn.executeWrite(transactional, () -> execOneFile(filename, graphStore));
for (String requestString : super.getPositional()) {
String requestString2 = indirect(requestString);
Txn.executeWrite(transactional, () -> execOne(requestString2, graphStore));
}
if (!(transactional instanceof DatasetGraph))
// Unlikely/impossible in Jena 3.7.0 onwards.
SystemARQ.sync(graphStore);
if (dump)
Txn.executeRead(transactional, () -> RDFDataMgr.write(System.out, graphStore, Lang.TRIG));
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class uparse method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
requestFiles = getValues(fileArg);
super.processModulesAndArgs();
if (super.cmdStrictMode)
updateSyntax = Syntax.syntaxSPARQL_11;
if (contains(argDeclFixup))
// Fixup undeclared prefix names.
ARQ.set(ARQ.fixupUndefinedPrefixes, true);
// Set syntax
if (super.contains(syntaxArg)) {
// short name
String s = super.getValue(syntaxArg);
Syntax syn = Syntax.lookup(s);
if (syn == null)
super.cmdError("Unrecognized syntax: " + s);
updateSyntax = syn;
}
for (String arg : getValues(argDeclPrint)) {
if (arg.equalsIgnoreCase("query"))
printUpdate = true;
else if (arg.equalsIgnoreCase("none"))
printNone = true;
else
throw new CmdException("Not a recognized print form: " + arg + " : Choices are: update, none");
}
if (!printUpdate && !printNone)
printUpdate = true;
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class ModDatasetGeneral method addGraphs.
protected void addGraphs(Dataset ds) {
try {
if (hasEntries(dataURLs)) {
if (ds.supportsTransactions()) {
Txn.executeWrite(ds, () -> {
for (String url : dataURLs) RDFDataMgr.read(ds, url);
});
} else {
for (String url : dataURLs) RDFDataMgr.read(ds, url);
}
}
if (hasEntries(graphURLs) || hasEntries(namedGraphURLs)) {
// Resolve named graph URLs so the graphname is an absolute IRI.
List<String> x = ListUtils.toList(namedGraphURLs.stream().map(IRILib::filenameToIRI));
DatasetUtils.addInGraphs(ds, graphURLs, x, null);
}
} catch (JenaException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Error creating dataset", ex);
}
}
Aggregations