jstore.createVirtualTable(new VirtualTable(temporaryName.getLocalPart(), vt)); return true; } else { jstore.createVirtualTable(vt);
/** * Adds a virtual table to the data store. If a virtual table with the same name was registered * this method will replace it with the new one. * @param vt * * @throws IOException If the view definition is not valid * @deprecated Use createVirtualTable instead */ public void addVirtualTable(VirtualTable vtable) throws IOException { createVirtualTable(vtable); }
vt.addParameter(new VirtualTableParameter("name", "name-f001")); vt.addGeometryMetadatata("pointProperty", Point.class, 4326); jds.createVirtualTable(vt);
dataStore.createVirtualTable(vt); ContentFeatureSource fs = dataStore.getFeatureSource("invalid_attribute");
protected SimpleFeatureType getFeatureType(VirtualTable vt) throws IOException { // check out if the view can be used JDBCDataStore ds = (JDBCDataStore) getCatalog().getDataStore(storeId).getDataStore(null); String vtName = null; try { // use a highly random name do { vtName = UUID.randomUUID().toString(); } while (Arrays.asList(ds.getTypeNames()).contains(vtName)); // try adding the vt and see if that works ds.createVirtualTable(new VirtualTable(vtName, vt)); return ds.getSchema(vtName); } finally { if (vtName != null) { ds.dropVirtualTable(vtName); } } }
/** * Checks the view definition works as expected and returns the feature type guessed solely by * looking at the sql and the first row of its output * * @param newSchema * @throws IOException */ protected SimpleFeatureType testViewDefinition(boolean guessGeometrySrid) throws IOException { // check out if the view can be used JDBCDataStore ds = (JDBCDataStore) getCatalog().getDataStore(storeId).getDataStore(null); String vtName = null; try { // use a highly random name 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.createVirtualTable(vt); return guessFeatureType(ds, vt.getName(), guessGeometrySrid); } finally { if (vtName != null) { ds.dropVirtualTable(vtName); } } }
/** * Checks the view definition works as expected and returns the feature type guessed solely by * looking at the sql and the first row of its output * * @param newSchema * @throws IOException */ protected SimpleFeatureType testViewDefinition( VirtualTable virtualTable, boolean guessGeometrySrid) throws IOException { // check out if the view can be used JDBCDataStore ds = (JDBCDataStore) getCatalog().getDataStore(storeId).getDataStore(null); String vtName = null; try { // use a highly random name 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.emptyList()); vt.setEscapeSql(escapeSql); ds.createVirtualTable(vt); return guessFeatureType(ds, vt.getName(), guessGeometrySrid); } finally { if (vtName != null) { ds.dropVirtualTable(name); } } }
@Override protected void onSave() { try { VirtualTable vt = buildVirtualTable(); DataStoreInfo dsInfo = getCatalog().getStore(storeId, DataStoreInfo.class); JDBCDataStore ds = (JDBCDataStore) dsInfo.getDataStore(null); ds.createVirtualTable(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); error( new ParamResourceModel("creationFailure", this, getFirstErrorMessage(e)) .getString()); } }