Search in sources :

Example 11 with CmdException

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);
}
Also used : CmdException(org.apache.jena.cmd.CmdException) XLoaderFiles(org.apache.jena.tdb2.xloader.XLoaderFiles)

Example 12 with CmdException

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();
}
Also used : CmdException(org.apache.jena.cmd.CmdException)

Example 13 with CmdException

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));
}
Also used : CmdException(org.apache.jena.cmd.CmdException) Transactional(org.apache.jena.sparql.core.Transactional) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 14 with CmdException

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;
}
Also used : CmdException(org.apache.jena.cmd.CmdException) Syntax(org.apache.jena.query.Syntax)

Example 15 with CmdException

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);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) CmdException(org.apache.jena.cmd.CmdException) CmdException(org.apache.jena.cmd.CmdException) JenaException(org.apache.jena.shared.JenaException)

Aggregations

CmdException (org.apache.jena.cmd.CmdException)35 Lang (org.apache.jena.riot.Lang)8 JenaException (org.apache.jena.shared.JenaException)5 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)5 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)4 RiotException (org.apache.jena.riot.RiotException)4 ArgDecl (org.apache.jena.cmd.ArgDecl)3 Graph (org.apache.jena.graph.Graph)3 Node (org.apache.jena.graph.Node)3 ModDataset (arq.cmdline.ModDataset)2 PrintStream (java.io.PrintStream)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Function (java.util.function.Function)2 Stream (java.util.stream.Stream)2 StreamOps (org.apache.jena.atlas.lib.StreamOps)2 LogCtl (org.apache.jena.atlas.logging.LogCtl)2 CmdGeneral (org.apache.jena.cmd.CmdGeneral)2 TerminationException (org.apache.jena.cmd.TerminationException)2 DataAccessPoint (org.apache.jena.fuseki.server.DataAccessPoint)2