Package com.hp.hpl.jena.query

Examples of com.hp.hpl.jena.query.Dataset


    {
        // Expanding version.
        DatasetGraph dsg = DatasetGraphFactory.createMem() ;
        AssemblerUtils.setContext(root, dsg.getContext()) ;
       
        Dataset ds = DatasetFactory.create(dsg) ;

        // -------- Default graph
        // Can use ja:graph or ja:defaultGraph
        Resource dftGraph = GraphUtils.getResourceValue(root, DatasetAssemblerVocab.pDefaultGraph) ;
        if ( dftGraph == null )
            dftGraph = GraphUtils.getResourceValue(root, DatasetAssemblerVocab.pGraph) ;
       
        Model dftModel = null ;
        if ( dftGraph != null )
            dftModel = a.openModel(dftGraph) ;
        else
            // Assembler description did not define one - make a dummy.
            dftModel = GraphFactory.makePlainModel() ;

        ds.setDefaultModel(dftModel) ;

        // -------- Named graphs
        List<RDFNode> nodes = GraphUtils.multiValue(root, DatasetAssemblerVocab.pNamedGraph) ;
       
        for ( Iterator<RDFNode> iter= nodes.iterator() ; iter.hasNext() ; )
        {
            RDFNode n = iter.next();
            if ( ! ( n instanceof Resource ) )
                throw new DatasetAssemblerException(root, "Not a resource: "+FmtUtils.stringForRDFNode(n)) ;
            Resource r = (Resource)n ;

            String gName = GraphUtils.getAsStringValue(r, DatasetAssemblerVocab.pGraphName) ;
            Resource g = GraphUtils.getResourceValue(r, DatasetAssemblerVocab.pGraph) ;
            if ( g == null )
            {
                g = GraphUtils.getResourceValue(r, DatasetAssemblerVocab.pGraphAlt) ;
                if ( g != null )
                    Log.warn(this, "Use of old vocabulary: use :graph not :graphData") ;
                else
                    throw new DatasetAssemblerException(root, "no graph for: "+gName) ;
            }
           
            Model m = a.openModel(g) ;
            ds.addNamedModel(gName, m) ;
        }
       
        return ds ;
    }
View Full Code Here


    public static Dataset createDataset(List<String> uriList, List<String> namedSourceList,
                                        FileManager fileManager, String baseURI)
    {
        // Fixed dataset - any GRAPH <notThere> in a query must return no match.
        Dataset ds = DatasetFactory.createMemFixed() ;
        addInGraphs(ds, uriList, namedSourceList, fileManager, baseURI) ;
        return ds ;
    }
View Full Code Here

       
    }
   
    public static void backup(Location location, OutputStream backupfile)
    {
        Dataset ds = TDBFactory.createDataset(location) ;
        StoreConnection sConn = StoreConnection.make(location) ;
        DatasetGraphTxn dsg = sConn.begin(ReadWrite.READ, "backup") ;
        RDFDataMgr.write(backupfile, dsg, Lang.NQUADS) ;
        dsg.end();
    }
View Full Code Here

    }
   
    public static boolean containsGraph(Store store, Node graphNode)
    {
        String qs = "SELECT * { GRAPH "+FmtUtils.stringForNode(graphNode)+" { ?s ?p ?o }} LIMIT 1" ;
        Dataset ds = SDBFactory.connectDataset(store) ;
        QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ;
        ResultSet rs = qExec.execSelect() ;
        boolean b = rs.hasNext() ;
        qExec.close();
        return b ;
View Full Code Here

            graphName = getValue(argNamedGraph) ;
    }
   
    protected Model getModel()
    {
        Dataset ds = tdbDatasetAssembler.getDataset() ;
       
        if ( graphName != null )
        {
            Model m = ds.getNamedModel(graphName) ;
            if ( m == null )
                throw new CmdException("No such named graph (is this a TDB dataset?)") ;
            return m ;
        }
        else
            return ds.getDefaultModel() ;
    }
View Full Code Here

            graphName = getAsStringValue(root, pGraphName2) ;

        if ( root.hasProperty(pIndex) )
            Log.warn(this, "Custom indexes not implemented yet - ignored") ;

        final Dataset ds ;
       
        if ( locationDir != null )
        {
            Location location = new Location(locationDir) ;
            ds = TDBFactory.createDataset(location) ;
        }
        else
            ds = DatasetAssemblerTDB.make(dataset) ;

        try {
            if ( graphName != null )
                return ds.getNamedModel(graphName) ;
            else
                return ds.getDefaultModel() ;
        } catch (RuntimeException ex)
        {
            ex.printStackTrace(System.err) ;
            throw ex ;
        }
View Full Code Here

              (namedGraphURLs == null || namedGraphURLs.size() == 0 ) )
            return null ;
       
        // This can auto-add graphs.
        DatasetGraph dsg = DatasetGraphFactory.createMem() ;
        Dataset ds = DatasetFactory.create(dsg) ;
        addGraphs(ds) ;
        dataset = ds ;
        return dataset ;
    }
View Full Code Here

        {
            System.err.println("No query expression to execute") ;
            throw new TerminationException(9) ;
        }

        Dataset dataset = modDataset.getDataset() ;
        // Check there is a dataset.
        if ( dataset == null )
            dataset = DatasetFactory.createMem() ;

        modTime.startTimer() ;
        DatasetGraph dsg = dataset.asDatasetGraph() ;

        if ( printOp || printPlan )
        {
            if ( printOp )
            {
View Full Code Here

  /** Create a memory Dataset and read in some data
     * @see #read(Dataset,String)
     */
    public static Dataset loadDataset(String uri)
  {
        Dataset ds = createDataset() ;
        read(ds, uri) ;
        return ds ;
    }
View Full Code Here

  /** Create a memory Dataset and read in some data
     * @see #read(Dataset,String,Lang)
     */
    public static Dataset loadDataset(String uri, Lang lang)
  {
        Dataset ds = createDataset() ;
        read(ds, uri, lang) ;
        return ds ;
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.query.Dataset

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.