Search in sources :

Example 21 with CmdException

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();
    }
}
Also used : IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) CmdException(org.apache.jena.cmd.CmdException) UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateLoad(org.apache.jena.sparql.modify.request.UpdateLoad) Node(org.apache.jena.graph.Node)

Example 22 with CmdException

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);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) ResultSetException(org.apache.jena.sparql.resultset.ResultSetException) CmdException(org.apache.jena.cmd.CmdException) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) QueryCheckException(org.apache.jena.sparql.core.QueryCheckException) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) CmdException(org.apache.jena.cmd.CmdException) QueryCheckException(org.apache.jena.sparql.core.QueryCheckException) ResultSetException(org.apache.jena.sparql.resultset.ResultSetException) JenaException(org.apache.jena.shared.JenaException)

Example 23 with CmdException

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);
    }
}
Also used : Query(org.apache.jena.query.Query) CmdException(org.apache.jena.cmd.CmdException) QueryExecutionHTTP(org.apache.jena.sparql.exec.http.QueryExecutionHTTP) QueryExceptionHTTP(org.apache.jena.sparql.engine.http.QueryExceptionHTTP) QuerySendMode(org.apache.jena.sparql.exec.http.QuerySendMode) CmdException(org.apache.jena.cmd.CmdException)

Example 24 with CmdException

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

Example 25 with CmdException

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

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