Examples of VirtualTable


Examples of org.geotools.jdbc.VirtualTable

        return new H2TestSetup();
    }
   
    public void testVariableListener() throws Exception {
        // setup a virtual table using the user variable
        VirtualTable vt = new VirtualTable("ft1var", "select * from  \"geotools\".\"ft1\" where \"doubleProperty\" > @MYVAR");
        dataStore.addVirtualTable(vt);
       
        // setup a listener that uses said variable
        SetVariableListener listener = new SetVariableListener();
        dataStore.getConnectionLifecycleListeners().add(listener);
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

            do {
                vtName = UUID.randomUUID().toString();
            } while (Arrays.asList(ds.getTypeNames()).contains(vtName));

            // try adding the vt and see if that works
            VirtualTable vt = new VirtualTable(vtName, sql);
            paramProvider.updateVirtualTable(vt);
            ds.addVirtualTable(vt);
            return guessFeatureType(ds, vt.getName(), guessGeometrySrid);
        } finally {
            if(vtName != null) {
                ds.removeVirtualTable(vtName);
            }
           
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

            do {
                vtName = UUID.randomUUID().toString();
            } while (Arrays.asList(ds.getTypeNames()).contains(vtName));

            // try adding the vt and see if that works
            ds.addVirtualTable(new VirtualTable(vtName, vt));
            return ds.getSchema(vtName);
        } finally {
            if(vtName != null) {
                ds.removeVirtualTable(vtName);
            }
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

            do {
                vtName = UUID.randomUUID().toString();
            } while (Arrays.asList(ds.getTypeNames()).contains(vtName));

            // try adding the vt and see if that works
            VirtualTable vt = new VirtualTable(vtName, virtualTable);
            // hide the primary key definitions or we'll loose some columns
            vt.setPrimaryKeyColumns(Collections.EMPTY_LIST);
            ds.addVirtualTable(vt);
            return guessFeatureType(ds, vt.getName(), guessGeometrySrid);
        } finally {
            if(vtName != null) {
                ds.removeVirtualTable(name);
            }
           
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

            store.closeSafe(cx);
        }
    }

    protected VirtualTable buildVirtualTable() {
        VirtualTable vt = new VirtualTable(name, sql);
        attProvider.fillVirtualTable(vt);
        paramProvider.updateVirtualTable(vt);
        return vt;
    }
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

            String vtName = (String) validatable.getValue();
           
            final DataStoreInfo store = getCatalog().getStore(storeId, DataStoreInfo.class);
            List<FeatureTypeInfo> ftis = getCatalog().getResourcesByStore(store, FeatureTypeInfo.class);
            for (FeatureTypeInfo curr : ftis) {
                VirtualTable currvt = curr.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, VirtualTable.class);
                if(currvt != null) {
                    if(typeInfoId == null || !typeInfoId.equals(curr.getId())) {
                        if(currvt.getName().equals(vtName)) {
                            Map<String, String> map = new HashMap<String, String>();
                            map.put("name", vtName);
                            map.put("typeName", curr.getName());
                            error(validatable, "duplicateSqlViewName", map);
                            return;
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

                   
                    //grab the underlying feature type
                    DataAccess<? extends FeatureType, ? extends Feature> dataAccess = getDataStore(info.getStore());
                   
                    // sql view handling
                    VirtualTable vt = null;
                    String vtName = null;
                    if(dataAccess instanceof JDBCDataStore && info.getMetadata() != null &&
                            (info.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE) instanceof VirtualTable)) {
                        JDBCDataStore jstore = (JDBCDataStore) dataAccess;
                        vt = info.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, VirtualTable.class);
                       
                        if(!cacheable) {
                            // use a highly random name, we don't want to actually add the
                            // virtual table to the store as this feature type is not cacheable,
                            // it is "dirty" or un-saved. The renaming below will take care
                            // of making the user see the actual name
                            final String[] typeNames = jstore.getTypeNames();
                            do {
                                vtName = UUID.randomUUID().toString();
                            } while (Arrays.asList(typeNames).contains(vtName));
   
                            // try adding the vt and see if that works
                            jstore.addVirtualTable(new VirtualTable(vtName, vt));
                            ft = jstore.getSchema(vtName);
                        } else {
                            vtName = vt.getName();
                            jstore.addVirtualTable(vt);
                            ft = jstore.getSchema(vt.getName());
                        }
                    } else {
                        ft = dataAccess.getSchema(info.getQualifiedNativeName());
                    }
                   
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

        SimpleFeatureSource fs;
       
        // sql view handling
        if(dataStore instanceof JDBCDataStore && info.getMetadata() != null &&
                info.getMetadata().containsKey(FeatureTypeInfo.JDBC_VIRTUAL_TABLE)) {
            VirtualTable vt = (VirtualTable) info.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE);
            JDBCDataStore jstore = (JDBCDataStore) dataStore;
            jstore.addVirtualTable(vt);
        }
               
        //
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

    }

    @Override
    protected void onSave() {
        try {
            VirtualTable vt = buildVirtualTable();
            DataStoreInfo dsInfo = getCatalog().getStore(storeId, DataStoreInfo.class);
            JDBCDataStore ds = (JDBCDataStore) dsInfo.getDataStore(null);
            ds.addVirtualTable(vt);

            CatalogBuilder builder = new CatalogBuilder(getCatalog());
            builder.setStore(dsInfo);
            FeatureTypeInfo fti = builder.buildFeatureType(ds.getFeatureSource(vt.getName()));
            fti.getMetadata().put(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, vt);
            LayerInfo layerInfo = builder.buildLayer(fti);
            setResponsePage(new ResourceConfigurationPage(layerInfo, true));
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Failed to create feature type", e);
View Full Code Here

Examples of org.geotools.jdbc.VirtualTable

        DataStoreInfo ds = cFactory.createDataStore();
        ds.setWorkspace( ws );
        ds.setName( "foo" );
        catalog.add( ds );
       
        VirtualTable vt = new VirtualTable("riverReduced",
                "select a, b, c * %mulparam% \n from table \n where x > 1 %andparam%");
        vt.addGeometryMetadatata("geom", LineString.class, 4326);
        vt.setPrimaryKeyColumns(Arrays.asList("a", "b"));
        vt.addParameter(new VirtualTableParameter("mulparam", "1", new RegexpValidator("\\d+")));
        vt.addParameter(new VirtualTableParameter("andparam", null));
       
        FeatureTypeInfo ft = cFactory.createFeatureType();
        ft.setStore( ds );
        ft.setNamespace( ns );
        ft.setName( "ft" );
        ft.setAbstract( "abstract");
        ft.setSRS( "EPSG:4326");
        ft.setNativeCRS( CRS.decode( "EPSG:4326") );
        ft.getMetadata().put(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, vt);
        catalog.add( ft );
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        persister.save(ft, out);
       
        // System.out.println(out.toString());
       
        persister.setCatalog( catalog );
        ft = persister.load( in( out ) , FeatureTypeInfo.class );
        VirtualTable vt2 = (VirtualTable) ft.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE);
        assertNotNull(vt2);
        assertEquals(vt, vt2);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.