public ParameterMapping getStoredQueryParameterMapping(String parameterName) { ParameterMapping ret = null; if (this.config == null || this.config.getStoredQueryParameterMappings() == null) { return ret; } for (ParameterMapping sqpm : this.config.getStoredQueryParameterMappings()) { if (sqpm.getParameterName().equals(parameterName)) { ret = sqpm; break; } } return ret; }
@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; }
static StoredQueryConfiguration createStoredQueryConfiguration( List<StoredQueryParameterAttribute> items, String storedQueryId) { StoredQueryConfiguration ret = new StoredQueryConfiguration(); ret.setStoredQueryId(storedQueryId); for (StoredQueryParameterAttribute i : items) { ParameterMapping mapping; String name = i.getParameterName(); switch (i.getMappingType()) { case BLOCKED: mapping = new ParameterMappingBlockValue(name); break; case DEFAULT: mapping = new ParameterMappingDefaultValue(name, false, i.getValue()); break; case STATIC: mapping = new ParameterMappingDefaultValue(name, true, i.getValue()); break; case EXPRESSION_CQL: mapping = new ParameterMappingExpressionValue(name, "CQL", i.getValue()); break; case NONE: default: mapping = null; } if (mapping != null) { ret.getStoredQueryParameterMappings().add(mapping); } } return ret; }
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() + "'"); if (configuration.getStoredQueryParameterMappings() != null) { for (ParameterMapping pm : configuration.getStoredQueryParameterMappings()) { if (pm.getParameterName().equals(pet.getName())) { mapping = pm;
@Test public void testSerialization() throws Exception { StoredQueryConfiguration mockConfiguration = new StoredQueryConfiguration(); + "',', strConCat(" + "numberFormat('0.00000000000', bboxMaxX), ',EPSG:4258')))))))"); mockConfiguration.getStoredQueryParameterMappings().add(param1); mockConfiguration.getStoredQueryParameterMappings().add(param2);
public ParameterMapping getStoredQueryParameterMapping(String parameterName) { ParameterMapping ret = null; if (this.config == null || this.config.getStoredQueryParameterMappings() == null) { return ret; } for (ParameterMapping sqpm : this.config.getStoredQueryParameterMappings()) { if (sqpm.getParameterName().equals(parameterName)) { ret = sqpm; break; } } return ret; }
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()); }
assertEquals(2, configuration.getStoredQueryParameterMappings().size()); assertEquals( ParameterMappingExpressionValue.class, configuration.getStoredQueryParameterMappings().get(0).getClass()); assertEquals( ParameterMappingDefaultValue.class, configuration.getStoredQueryParameterMappings().get(1).getClass()); configuration.getStoredQueryParameterMappings().get(0); assertEquals("bbox", map1.getParameterName()); assertEquals("CQL", map1.getExpressionLanguage()); configuration.getStoredQueryParameterMappings().get(1); assertEquals("timestep", map2.getParameterName()); assertEquals("720", map2.getDefaultValue());
@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()); } }