Package com.hp.hpl.jena.query

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


            }
        }

        // Open the TDB dataset
        try {
            Dataset tdb = useMem ? TDBFactory.createDataset() : TDBFactory.createDataset(location);

            // Return a new connection for the TDB dataset
            return new TDBConnection(tdb, ResultSet.HOLD_CURSORS_OVER_COMMIT, true, compatibilityLevel);
        } catch (SQLException e) {
            throw e;
View Full Code Here


    public Dataset open(Assembler a, Resource root, Mode mode)
    {
        Resource dataset = GraphUtils.getResourceValue(root, pDataset) ;
        Resource index   = GraphUtils.getResourceValue(root, pIndex) ;
       
        Dataset ds = (Dataset)a.open(dataset) ;
        SpatialIndex textIndex = (SpatialIndex)a.open(index) ;
       
        Dataset dst = SpatialDatasetFactory.create(ds, textIndex) ;
        return dst ;
       
    }
View Full Code Here

        Model model = ModelFactory.createDefaultModel() ;
        RDFDataMgr.read(model, uri, uri, lang) ;
    }
   
    private void run4() {
        Dataset ds = DatasetFactory.createMem() ;
        RDFDataMgr.read(ds, uri, uri, lang) ;
    }
View Full Code Here

            throw ex ; }
    }
   
    private void run4()
    {
        Dataset ds = DatasetFactory.createMem() ;
        try {
            RDFDataMgr.read(ds, input) ;
            fail("Managed to read a bad evaluation test without error") ;
        }
        catch (JenaException ex) {}
View Full Code Here

    {
        Store store = SDBFactory.connectStore("Store/sdb-hsqldb-mem.ttl") ;
        store.getTableFormatter().format() ;
        store.getTableFormatter().addIndexes() ;
       
        Dataset ds = SDBFactory.connectDataset(store) ;
        DatasetGraph dsg = ds.asDatasetGraph() ;
        Quad quad = SSE.parseQuad("(<g> <s> <p> <o>)") ;
        dsg.add(quad) ;
        System.out.println("DONE") ;
        System.exit(0) ;
    }
View Full Code Here

        return DatasetAssemblerVocab.tDataset ;
    }

    @Override
    public Object open(Assembler a, Resource root, Mode mode) {
        Dataset ds = createDataset(a, root, mode) ;
        return ds ;
    }
View Full Code Here

    public Dataset createDataset(Assembler a, Resource root, Mode mode) {
        // 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 ( RDFNode n : nodes )
        {
            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 );
        }

        AssemblerUtils.setContext(root, ds.getContext()) ;
        return ds ;
    }
View Full Code Here

        }
        fail("Bad syntax test succeed in parsing the file") ;
    }
   
    private void run4() {
        Dataset ds = DatasetFactory.createMem() ;
        try {
            RDFDataMgr.read(ds, uri, uri, lang) ;
        } catch (RiotException ex) { return ; }
        catch (RuntimeException ex) {
            ex.printStackTrace(System.err) ;
View Full Code Here

    @Test public void writer10() { test("writer-rt-30.trig") ; }
   
    private void test(String filename)
    {
        String displayname = filename.substring(0, filename.lastIndexOf('.')) ;
        Dataset ds = readDataset(filename) ;
        Lang lang = format.getLang() ;

        WriterDatasetRIOT rs = RDFWriterRegistry.getWriterDatasetFactory(format).create(format) ;
        assertEquals(lang, rs.getLang()) ;

        ByteArrayOutputStream out = new ByteArrayOutputStream() ;
        RDFDataMgr.write(out, ds, format) ;
       
        if ( lang == Lang.RDFNULL )
            return ;
       
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()) ;
        String s = StrUtils.fromUTF8bytes(out.toByteArray()) ;
        if (false) {
            System.out.println(format.toString());
            System.out.println(s);
            System.out.println();
        }
        Dataset ds2 = DatasetFactory.createMem() ;
        try {
            RDFDataMgr.read(ds2, in, lang) ;
        } catch (RiotException ex)
        {
            System.out.println(displayname+" : "+format) ;
            System.out.println(s) ;
            throw ex ;
        }
       
        boolean b = IsoMatcher.isomorphic(ds.asDatasetGraph(), ds2.asDatasetGraph()) ;
        if ( ! b ) {
            System.out.println("Test: "+format.toString()) ;
            System.out.println("-- Input") ;
            RDFDataMgr.write(System.out, ds.asDatasetGraph(), Lang.NQUADS ) ;
            System.out.println("-- Written") ;
            System.out.println(s);
            System.out.println();
            System.out.println("-- Seen as") ;
            RDFDataMgr.write(System.out, ds2.asDatasetGraph(), Lang.NQUADS ) ;
            System.out.println("-------------") ;
        }
       
        assertTrue("Datasets are not isomorphic", b) ;
        //**** Test ds2 iso ds
View Full Code Here

    private void datasetJ2R(String inFile, String outFile)
    {
        inFile = DIR+inFile ;
        outFile = DIR+outFile ;
        Dataset ds1 = RDFDataMgr.loadDataset(inFile) ;
        Dataset ds2 = RDFDataMgr.loadDataset(outFile) ;
    }
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.