private static boolean hasWMSParam( Map<String, Parameter<?>> processInfo, String name, Class<?> type) { Parameter<?> param = processInfo.get(name); if (param == null) return false; if (!param.getName().equals(name)) return false; if (!param.isRequired()) return false; if (!type.isAssignableFrom(param.getType())) return false; return true; }
private String getInputLayerParameter(Map<String, Parameter<?>> paramInfo) { for (Map.Entry<String, Parameter<?>> entry : paramInfo.entrySet()) { if (entry.getValue() != null) { final Class<?> type = entry.getValue().getType(); if (GridCoverage2D.class.isAssignableFrom(type) || FeatureCollection.class.isAssignableFrom(type) || GridCoverage2DReader.class.isAssignableFrom(type)) { return entry.getKey(); } } } return null; }
private static boolean hasWMSParam( Map<String, Parameter<?>> processInfo, String name, Class<?> type) { Parameter<?> param = processInfo.get(name); if (param == null) return false; if (!param.getName().equals(name)) return false; if (!param.isRequired()) return false; if (!type.isAssignableFrom(param.getType())) return false; return true; }
private Object parseParameter(Parameter<?> parameter, String value) { Class target = parameter.getType(); // for searches on array types if (target != null && target.isArray()) { target = target.getComponentType(); } Object converted = Converters.convert(value, target, SAFE_CONVERSION_HINTS); if (converted == null) { throw new OWS20Exception( "Value '" + value + "' of key " + parameter.key + " cannot be converted to a " + parameter.getType().getSimpleName(), OWSExceptionCode.InvalidParameterValue, parameter.key); } return converted; }
/** * Extracts the a map of process input parameters that should be filled with the chosen output * mime type for RawData outputs, the map goes from the output result name to the input that * will receive the user chosen mime type * * @param resultInfo */ public static Map<String, String> getOutputMimeParameters(Name processName, ProcessFactory pf) { Map<String, Parameter<?>> resultInfo = pf.getResultInfo(processName, null); Map<String, String> result = new HashMap<String, String>(); for (Parameter p : resultInfo.values()) { if (RawData.class.isAssignableFrom(p.getType())) { String attribute = (String) p.metadata.get(SELECTION_ATTRIBUTE); if (attribute != null) { if (result.containsValue(attribute)) { LOGGER.warning( "In process " + processName + " two raw results parameter are using the same input attribute " + attribute + " to notify the process of the user chosen mime type"); } else { result.put(p.key, attribute); } } } } return result; }
@Override public Map<String, Parameter<?>> getOutputs(ScriptEngine engine) throws ScriptException { Map<String, Parameter<?>> outputs = super.getOutputs(engine); // Convert all output Parameters from GeoScript types to GeoTools Types for (Map.Entry<String, Parameter<?>> entry : outputs.entrySet()) { String key = entry.getKey(); Parameter param = entry.getValue(); Class clazz = geoscript.process.Process.convertGeoScriptToGeoToolsClass(param.getType()); param = changeParamType(param, clazz); outputs.put(key, param); } return outputs; }
private static boolean isVectorSource(Expression tranformation) { // instanceof is sufficient for null check if (tranformation instanceof ProcessFunction) { ProcessFunction processFunction = (ProcessFunction) tranformation; Name processName = processFunction.getProcessName(); Map<String, org.geotools.data.Parameter<?>> params = Processors.getParameterInfo(processName); for (org.geotools.data.Parameter<?> param : params.values()) { if (SimpleFeatureCollection.class.isAssignableFrom(param.getType())) { return true; } } } return false; }
@Override public Map<String, Parameter<?>> getInputs(ScriptEngine engine) throws ScriptException { Map<String, Parameter<?>> inputs = super.getInputs(engine); // Convert all input Parameters from GeoScript types to GeoTools Types for (Map.Entry<String, Parameter<?>> entry : inputs.entrySet()) { String key = entry.getKey(); Parameter param = entry.getValue(); Class clazz = geoscript.process.Process.convertGeoScriptToGeoToolsClass(param.getType()); param = changeParamType(param, clazz); inputs.put(key, param); } return inputs; }
"Output %s declared type %s but returned %s", output.getName(), output.getType().getSimpleName(), obj.getClass().getSimpleName()));
private Filter buildEoFilter(Parameter<?> parameter, Object value) { // support two types of filters, equality and range filters Class<?> type = parameter.getType(); PropertyName pn = OpenSearchParameters.getFilterPropertyFor( gs.getService(OSEOInfo.class), FF, parameter); if (value instanceof String[]) { String[] values = (String[]) value; List<Filter> filters = new ArrayList<>(); for (String v : values) { Filter filter = buildEOFilterForSingleValue(parameter, v, type, pn); filters.add(filter); } return FF.and(filters); } else { return buildEOFilterForSingleValue(parameter, (String) value, type, pn); } }
Class type = param.getType(); if (Integer.class == type) { map.put("pattern", "[+-][0-9]+");
assertEquals( "geom description", "The target geometry.", geomParam.getDescription().toString()); assertEquals("geom type", Geometry.class, geomParam.getType()); "The distance by which to buffer the geometry.", distance.getDescription().toString()); assertEquals("distance type", Double.class, distance.getType());
assertEquals("first title", "First Operand", first.getTitle().toString()); assertEquals("first description", "The first operand.", first.getDescription().toString()); assertEquals("first type", Float.class, first.getType()); assertEquals( "second description", "The second operand.", second.getDescription().toString()); assertEquals("second type", Float.class, second.getType()); "The sum of the two inputs", sumParam.getDescription().toString()); assertEquals("sum type", Float.class, sumParam.getType());