@Override public boolean initialize( FeatureTypeInfo info, DataAccess<? extends FeatureType, ? extends Feature> dataAccess, Name temporaryName) throws IOException { StoredQueryConfiguration sqc = info.getMetadata() .get( FeatureTypeInfo.STORED_QUERY_CONFIGURATION, StoredQueryConfiguration.class); WFSDataStore wstore = (WFSDataStore) dataAccess; String localPart = info.getName(); boolean usesTemporary = false; if (temporaryName != null) { localPart = temporaryName.getLocalPart(); usesTemporary = true; } if (!wstore.getConfiguredStoredQueries().containsValue(localPart)) { wstore.addStoredQuery(localPart, sqc.getStoredQueryId()); } return usesTemporary; }
public CascadedWFSStoredQueryEditPage( FeatureTypeInfo type, ResourceConfigurationPage previousPage) throws IOException { super(type.getStore().getWorkspace().getName(), type.getStore().getName(), type.getName()); this.editableType = type; this.configuration = (StoredQueryConfiguration) type.getMetadata().get(FeatureTypeInfo.STORED_QUERY_CONFIGURATION); this.storedQueryId = this.configuration.getStoredQueryId(); this.previousPage = previousPage; parameterProvider.refreshItems(configuration.getStoredQueryId()); }
String storedQueryId, ParameterExpressionType pet, StoredQueryParameterAttribute attr) { if (!storedQueryId.equals(configuration.getStoredQueryId())) { throw new RuntimeException( "Programming error! Stored query ids do not match: '" + storedQueryId + "' vs '" + configuration.getStoredQueryId() + "'");
@Override protected void onSave() { // TODO: check stuff before saving StoredQuery selection = (StoredQuery) storedQueriesDropDown.getDefaultModelObject(); StoredQueryConfiguration config = createStoredQueryConfiguration( parameterProvider.getItems(), selection.storedQueryId); try { DataStoreInfo dsInfo = getCatalog().getStore(storeId, DataStoreInfo.class); WFSDataStore directDs = getContentDataStore(); DataAccess<?, ?> da = dsInfo.getDataStore(null); Name typeName = directDs.addStoredQuery(getNativeName(), config.getStoredQueryId()); CatalogBuilder builder = new CatalogBuilder(getCatalog()); builder.setStore(dsInfo); FeatureTypeInfo fti = builder.buildFeatureType(da.getFeatureSource(typeName)); fti.getMetadata().put(FeatureTypeInfo.STORED_QUERY_CONFIGURATION, config); 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, e.getMessage()).getString()); } }