/** * Returns the default style name, or an empty string if set to use the layer specified default */ public String getRealDefault() { // Bypass the special processing this class normally does on the default value return super.getDefaultValue(); }
@Override public String getDefaultValue() { checkInitialized(); String name = super.getDefaultValue(); if (name.isEmpty()) { // Default is not set so use the default from the layer if (defaultStyle == null) return ""; return defaultStyle; } else { // Default is set so use it return name; } }
/** * @return a list with an empty string for the default style, and any other style name verbatim */ private List<String> getStyles(List<ParameterFilter> parameterFilters) { List<String> styles = new ArrayList<String>(2); styles.add(""); // the default style if (parameterFilters != null) { for (ParameterFilter filter : parameterFilters) { if (!"STYLES".equalsIgnoreCase(filter.getKey())) { continue; } final String defaultStyle = filter.getDefaultValue(); for (String style : filter.getLegalValues()) { if (!defaultStyle.equals(style)) { styles.add(style); } } } } return styles; }
/** * @return a list with an empty string for the default style, and any other style name verbatim */ private List<String> getStyles(List<ParameterFilter> parameterFilters) { List<String> styles = new ArrayList<String>(2); styles.add("");// the default style if (parameterFilters != null) { for (ParameterFilter filter : parameterFilters) { if (!"STYLES".equalsIgnoreCase(filter.getKey())) { continue; } final String defaultStyle = filter.getDefaultValue(); for (String style : filter.getLegalValues()) { if (!defaultStyle.equals(style)) { styles.add(style); } } } } return styles; }
/** * Is the given value exactly a value that could be produced by the filter. * * @param value * @return * @throws ParameterException */ public boolean isFilteredValue(final String value) { if (Objects.equal(value, this.getDefaultValue())) { return true; } if (Optional.ofNullable(this.getLegalValues()) .map(values -> values.contains(value)) .orElse(false)) { return true; } try { return Objects.equal(value, this.apply(value)); } catch (ParameterException ex) { return false; } } }
/** * @return default parameter filters, with keys normalized to upper case, or an empty map if no * parameter filters are defined */ public Map<String, String> getDefaultParameterFilters() { if (defaultParameterFilterValues == null) { List<ParameterFilter> parameterFilters = getParameterFilters(); if (parameterFilters == null || parameterFilters.size() == 0) { defaultParameterFilterValues = Collections.emptyMap(); } else { Map<String, String> defaults = new HashMap<String, String>(); for (ParameterFilter parameterFilter : parameterFilters) { String key = parameterFilter.getKey().toUpperCase(); String defaultValue = decodeDimensionValue(parameterFilter.getDefaultValue()); defaults.put(key, defaultValue); } defaultParameterFilterValues = Collections.unmodifiableMap(defaults); } } return defaultParameterFilterValues; }
private static Set<String> getCachedStyles(final TileLayer l) { Set<String> cachedStyles = new HashSet<String>(); String defaultStyle = l.getStyles(); if (defaultStyle != null) { cachedStyles.add(defaultStyle); } List<ParameterFilter> parameterFilters = l.getParameterFilters(); if (parameterFilters != null) { for (ParameterFilter pf : parameterFilters) { if (!"STYLES".equalsIgnoreCase(pf.getKey())) { continue; } cachedStyles.add(pf.getDefaultValue()); cachedStyles.addAll(pf.getLegalValues()); break; } } if (cachedStyles.isEmpty()) { cachedStyles.add(""); } return cachedStyles; } }
/** * Returns the names of the styles for the layer, including the default style * * @param layerName */ private Set<String> getCachedStyles(final String layerName) { final TileLayer l = getTileLayerByName(layerName); Set<String> cachedStyles = new HashSet<String>(); String defaultStyle = l.getStyles(); if (defaultStyle != null) { cachedStyles.add(defaultStyle); } List<ParameterFilter> parameterFilters = l.getParameterFilters(); if (parameterFilters != null) { for (ParameterFilter pf : parameterFilters) { if (!"STYLES".equalsIgnoreCase(pf.getKey())) { continue; } cachedStyles.add(pf.getDefaultValue()); cachedStyles.addAll(pf.getLegalValues()); break; } } return cachedStyles; }
/** * Returns the names of the styles for the layer, including the default style * * @param layerName * @return */ private Set<String> getCachedStyles(final String layerName) { final TileLayer l = getTileLayerByName(layerName); Set<String> cachedStyles = new HashSet<String>(); String defaultStyle = l.getStyles(); if (defaultStyle != null) { cachedStyles.add(defaultStyle); } List<ParameterFilter> parameterFilters = l.getParameterFilters(); if (parameterFilters != null) { for (ParameterFilter pf : parameterFilters) { if (!"STYLES".equalsIgnoreCase(pf.getKey())) { continue; } cachedStyles.add(pf.getDefaultValue()); cachedStyles.addAll(pf.getLegalValues()); break; } } return cachedStyles; }
Assert.notNull(pf); String key = pf.getKey(); String defaultValue = pf.getDefaultValue(); List<String> legalValues = pf.getLegalValues(); doc.append("<tr><td>").append(key.toUpperCase()).append(": ").append("</td><td>");
private void dimensionDescription(XMLBuilder xml, ParameterFilter filter, List<String> values) throws IOException { xml.indentElement("Dimension"); xml.simpleElement("ows:Identifier", filter.getKey(), false); String defaultStr = TileLayer.encodeDimensionValue(filter.getDefaultValue()); xml.simpleElement("Default", defaultStr, false); Iterator<String> iter = values.iterator(); while (iter.hasNext()) { String value = TileLayer.encodeDimensionValue(iter.next()); xml.simpleElement("Value", value, false); } xml.endElement("Dimension"); }
Assert.notNull(pf); String key = pf.getKey(); String defaultValue = pf.getDefaultValue(); List<String> legalValues = pf.getLegalValues(); doc.append("<tr><td>").append(key.toUpperCase()).append(": ").append("</td><td>");
Assert.notNull(pf); String key = pf.getKey(); String defaultValue = pf.getDefaultValue(); List<String> legalValues = pf.getLegalValues(); doc.append("<tr><td>").append(key.toUpperCase()).append(": ").append("</td><td>");
@Override public StyleParameterFilter clone() { StyleParameterFilter clone = new StyleParameterFilter(); clone.setDefaultValue( super.getDefaultValue()); // Want to get the configured value so use super clone.setKey(getKey()); clone.allowedStyles = getStyles(); clone.availableStyles = availableStyles; clone.defaultStyle = defaultStyle; return clone; }
public void testGetModifiableParameters() throws GeoWebCacheException { layerInfoTileLayer = new GeoServerTileLayer(layerInfo, defaults, gridSetBroker); ParameterFilter stylesParamFilter = layerInfoTileLayer.getParameterFilters().get(0); List<String> legalValues = stylesParamFilter.getLegalValues(); Map<String, String> requestParams; Map<String, String> modifiedParams; requestParams = Collections.singletonMap("sTyLeS", ""); modifiedParams = layerInfoTileLayer.getModifiableParameters(requestParams, "UTF-8"); assertEquals(0, modifiedParams.size()); for (String legalStyle : legalValues) { requestParams = new HashMap<String, String>(); requestParams.put("sTyLeS", legalStyle); modifiedParams = layerInfoTileLayer.getModifiableParameters(requestParams, "UTF-8"); if (legalStyle.equals(stylesParamFilter.getDefaultValue())) { assertEquals(0, modifiedParams.size()); } else { assertEquals(Collections.singletonMap("STYLES", legalStyle), modifiedParams); } } }
String defVal = stylesFilter.getDefaultValue(); if (defVal == null) { if (defStyle != null) {
when(styleFilter.getDefaultValue()).thenReturn("Foo"); when(styleFilter.getLegalValues()).thenReturn(Arrays.asList("Foo", "Bar", "Baz"));
when(styleFilter.getDefaultValue()).thenReturn("Foo"); when(styleFilter.getLegalValues()).thenReturn(Arrays.asList("Foo", "Bar", "Baz")); when(elevationDimension.getDefaultValue()).thenReturn("0"); when(elevationDimension.getLegalValues()) .thenReturn(Arrays.asList("0", "200", "400", "600")); when(timeDimension.getDefaultValue()).thenReturn("2016-02-23T03:00:00.00"); when(timeDimension.getLegalValues()).thenReturn(Collections.<String>emptyList());
when(styleFilter.getDefaultValue()).thenReturn("Foo"); when(styleFilter.getLegalValues()).thenReturn(null);
when(styleFilter.getDefaultValue()).thenReturn("Foo"); when(styleFilter.getLegalValues()).thenReturn(Collections.<String>emptyList());