Package arq.cmd

Examples of arq.cmd.CmdException


        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
        {
            // OK - running a manifest
           
            if ( ! hasPositional() )
                throw new CmdException("No manifest file") ;

            String testfile = getPositionalArg(0) ;
            testfileAbs = IRIResolver.resolveGlobal(testfile) ;
           
            createEarlReport = contains(earlDecl) ;
View Full Code Here


        if ( contains(argTDB) ) x++ ;

        if ( fusekiConfigFile != null )
        {
            if ( x > 1 )
                throw new CmdException("Dataset specificed on the command line and also a configuration file specificed.") ;
        }
        else
        {
            if ( x == 0 )
                throw new CmdException("Required: either --config=FILE or one of --mem, --file, --loc or --desc") ;
        }

       
        TDB.setOptimizerWarningFlag(false) ;
       
        if ( contains(argMem) )
        {
            log.info("Dataset: in-memory") ;
            dsg = DatasetGraphFactory.createMem() ;
        }
        if ( contains(argFile) )
        {
            dsg = DatasetGraphFactory.createMem() ;
            // replace by RiotLoader after ARQ refresh.
            String filename = getValue(argFile) ;
            log.info("Dataset: in-memory: load file: "+filename) ;
            if ( ! FileOps.exists(filename) )
                throw new CmdException("File not found: "+filename) ;

            Lang language = Lang.guess(filename) ;
            if ( language == null )
                throw new CmdException("Can't guess language for file: "+filename) ;
            InputStream input = IO.openFile(filename) ;
           
            if ( language.isQuads() )
            {
                Sink<Quad> sink = new SinkQuadsToDataset(dsg) ;
                RiotLoader.readQuads(input, language, filename, sink) ;
            }
            else
            {
                Sink<Triple> sink = new SinkTriplesToGraph(dsg.getDefaultGraph()) ;
                RiotLoader.readTriples(input, language, filename, sink) ;
            }
        }
       
        if ( contains(argMemTDB) )
        {
            log.info("TDB dataset: in-memory") ;
            dsg = TDBFactory.createDatasetGraph() ;
        }
       
        if ( contains(argTDB) )
        {
            String dir = getValue(argTDB) ;
            log.info("TDB dataset: directory="+dir) ;
            if ( ! FileOps.exists(dir) )
                throw new CmdException("Directory not found: "+dir) ;
            dsg = TDBFactory.createDatasetGraph(dir) ;
        }
       
        // Otherwise
        if ( contains(assemblerDescDecl) )
        {
            log.info("Dataset from assembler") ;
            Dataset ds = modDataset.createDataset() ;
            if ( ds != null )
                dsg = ds.asDatasetGraph() ;
        }
       
        if ( contains(argFusekiConfig) )
        {
            if ( dsg != null )
                throw new CmdException("Dataset specificed on the command line and also a configuration file specificed.") ;
            fusekiConfigFile = getValue(argFusekiConfig) ;
        }
       
        if ( contains(argPort) )
        {
            String portStr = getValue(argPort) ;
            try {
                port = Integer.parseInt(portStr) ;
            } catch (NumberFormatException ex)
            {
                throw new CmdException(argPort.getKeyName()+" : bad port number: "+portStr) ;
            }
        }
       
        if ( contains(argMgtPort) )
        {
            String mgtPortStr = getValue(argMgtPort) ;
            try {
                mgtPort = Integer.parseInt(mgtPortStr) ;
            } catch (NumberFormatException ex)
            {
                throw new CmdException(argMgtPort.getKeyName()+" : bad port number: "+mgtPortStr) ;
            }
        }

        if ( contains(argHost) )
        {
          clientHost = getValue(argHost);
          try {
            InetAddress.getByName(clientHost);
          } catch (UnknownHostException e) {
            throw new CmdException("unknown host name");
          }
        }
           
        if ( fusekiConfigFile == null && dsg == null )
            throw new CmdException("No dataset defined and no configuration file: "+argUsage) ;
       
        if ( dsg != null )
        {
            if ( getPositional().size() == 0 )
                throw new CmdException("No dataset path name given") ;
            if ( getPositional().size() > )
                throw new CmdException("Multiple dataset path names given") ;
            datasetPath = getPositionalArg(0) ;
            if ( datasetPath.length() > 0 && ! datasetPath.startsWith("/") )
                throw new CmdException("Dataset path name must begin with a /: "+datasetPath) ;
           
            allowUpdate = contains(argAllowUpdate) ;
        }
       
        if ( contains(argTimeout) )
        {
            String str = getValue(argTimeout) ;
            ARQ.getContext().set(ARQ.queryTimeout, str) ;
        }
       
        if ( contains(argJettyConfig) )
        {
            jettyConfigFile = getValue(argJettyConfig) ;
            if ( !FileOps.exists(jettyConfigFile) )
                throw new CmdException("No such file: : "+jettyConfigFile) ;
        }
       
        if ( contains(argHome) )
        {
           List<String> args = super.getValues(argHome) ;
           homeDir = args.get(args.size()-1) ;
        }
       
        if ( contains(argPages) )
        {
           List<String> args = super.getValues(argPages) ;
           pagesDir = args.get(args.size()-1) ;
        }

        if ( contains(argGZip) )
        {
            if ( ! hasValueOfTrue(argGZip) && ! hasValueOfFalse(argGZip) )
                throw new CmdException(argGZip.getNames().get(0)+": Not understood: "+getValue(argGZip)) ;
            enableCompression = super.hasValueOfTrue(argGZip) ;
        }
    }
View Full Code Here

        }
       
        Lang lang = selectLang(filename, ct, RDFLanguages.NQUADS)
        LangHandler handler = dispatch.get(lang) ;
        if ( handler == null )
            throw new CmdException("Undefined language: "+lang) ;
       
        // If multiple files, choose the overall labels.
        if ( langHandlerOverall == null )
            langHandlerOverall = handler ;
        else
View Full Code Here

            String[] x = getValue(argRepeat).split(",") ;
            if ( x.length == 1 )
            {
                try { repeatCount = Integer.parseInt(x[0]) ; }
                catch (NumberFormatException ex)
                { throw new CmdException("Can't parse "+x[0]+" in arg "+getValue(argRepeat)+" as an integer") ; }
               
            }
            else if ( x.length == 2 )
            {
                try { warmupCount = Integer.parseInt(x[0]) ; }
                catch (NumberFormatException ex)
                { throw new CmdException("Can't parse "+x[0]+" in arg "+getValue(argRepeat)+" as an integer") ; }
                try { repeatCount = Integer.parseInt(x[1]) ; }
                catch (NumberFormatException ex)
                { throw new CmdException("Can't parse "+x[1]+" in arg "+getValue(argRepeat)+" as an integer") ; }
            }
            else
                throw new CmdException("Wrong format for repeat count: "+getValue(argRepeat)) ;
        }
        if ( isVerbose() )
            ARQ.getContext().setTrue(ARQ.symLogExec) ;
       
        if ( hasArg(argExplain) )
            ARQ.setExecutionLogging(Explain.InfoLevel.ALL) ;
       
        if ( hasArg(argOptimize) )
        {
            String x1 = getValue(argOptimize) ;
            if ( hasValueOfTrue(argOptimize) || x1.equalsIgnoreCase("on") || x1.equalsIgnoreCase("yes") )
                queryOptimization = true ;
            else if ( hasValueOfFalse(argOptimize) || x1.equalsIgnoreCase("off") || x1.equalsIgnoreCase("no") )
                queryOptimization = false ;
            else throw new CmdException("Optimization flag must be true/false/on/off/yes/no. Found: "+getValue(argOptimize)) ;
        }
    }
View Full Code Here

            ex.printStackTrace(System.err) ;
        }
        catch (QueryException qEx)
        {
            //System.err.println(qEx.getMessage()) ;
            throw new CmdException("Query Exeception", qEx) ;
        }
        catch (JenaException ex) { throw ex ; }
        catch (CmdException ex) { throw ex ; }
        catch (Exception ex)
        {
            throw new CmdException("Exception", ex) ;
        }
    }   
View Full Code Here

    @Override
    protected void processModulesAndArgs()
    {
        super.processModulesAndArgs() ;
        if ( modRemote.getServiceURL() == null )
            throw new CmdException("No SPARQL endpoint specificied") ;
    }
View Full Code Here

                HttpQuery.urlLimit = 0 ;

            QueryExecUtils.executeQuery(query, qe, modResults.getResultsFormat()) ;
        } catch (QueryExceptionHTTP ex)
        {
            throw new CmdException("HTTP Exeception", ex) ;
        }
        catch (Exception ex)
        {
            System.out.flush() ;
            ex.printStackTrace(System.err) ;
View Full Code Here

            else if ( arg.equalsIgnoreCase("Op"))       { printOp = true ; }
            else if ( arg.equalsIgnoreCase("SqlNode"))  { printSqlNode = true ; }
            else if ( arg.equalsIgnoreCase("sql"))      { printSQL = true ; }
            else if ( arg.equalsIgnoreCase("plan"))     { printPlan = true ; }
            else
                throw new CmdException("Not a recognized print form: "+arg+" : Choices are: query, prefix, op, sqlNode, sql") ;
        }
    }
View Full Code Here

    }
       
    @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 = new Location(locationString) ;
View Full Code Here

            cl.process() ;
        } catch (IllegalArgumentException ex)
        {
            System.err.println(ex.getMessage()) ;
            usage(System.err) ;
            throw new CmdException() ;
        }

        if ( cl.contains(helpDecl) )
        {
            usage() ;
View Full Code Here

TOP

Related Classes of arq.cmd.CmdException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.