Search in sources :

Example 21 with CmdException

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

Example 22 with CmdException

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

Example 23 with CmdException

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;
}
Also used : JenaException(org.apache.jena.shared.JenaException) CmdException(jena.cmd.CmdException) ModDataset(arq.cmdline.ModDataset) DatasetGraphTransaction(org.apache.jena.tdb.transaction.DatasetGraphTransaction) CmdException(jena.cmd.CmdException) JenaException(org.apache.jena.shared.JenaException)

Example 24 with CmdException

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

Example 25 with CmdException

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

Aggregations

CmdException (jena.cmd.CmdException)32 Lang (org.apache.jena.riot.Lang)8 Dataset (org.apache.jena.query.Dataset)6 Node (org.apache.jena.graph.Node)3 Model (org.apache.jena.rdf.model.Model)3 JenaException (org.apache.jena.shared.JenaException)3 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 ArgDecl (jena.cmd.ArgDecl)2 TerminationException (jena.cmd.TerminationException)2 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)2 Graph (org.apache.jena.graph.Graph)2 RiotException (org.apache.jena.riot.RiotException)2 PrefixMapping (org.apache.jena.shared.PrefixMapping)2 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)2 Transactional (org.apache.jena.sparql.core.Transactional)2 TransactionalNull (org.apache.jena.sparql.core.TransactionalNull)2 ResultSetException (org.apache.jena.sparql.resultset.ResultSetException)2 UpdateRequest (org.apache.jena.update.UpdateRequest)2 ModDataset (arq.cmdline.ModDataset)1 IOException (java.io.IOException)1