public <T> Parameter<T> parameter( String name, Class<T> type, InternationalString title, InternationalString description, boolean required, int minOccurs, int maxOccurs, T defaultValue) { return new org.geotools.data.Parameter<T>( name, type, title, description, required, minOccurs, maxOccurs, defaultValue, 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; }
void convertAndAdd(Object val, Parameter<?> p, List<Expression> valueArgs) { // handle collection case if (p.getMaxOccurs() > 1 && val instanceof Collection) { for (Object o : (Collection<?>) val) { // just add directly valueArgs.add(factory.filter.literal(o)); } } else if (val instanceof Map) { YamlMap map = YamlMap.<Map<?, ?>>create((Map<?, ?>) val).map(); valueArgs.add(process(map)); } else { // just add directly valueArgs.add(factory.filter.literal(val)); } } }
private String getPrimary(Map<String, Parameter<?>> resultInfo) { if (resultInfo.size() == 1) { return resultInfo.keySet().iterator().next(); } else { for (Parameter<?> param : resultInfo.values()) { if (param.isRequired()) { return param.getName(); } } } return null; } }
/** * Create a new Parameter with all of the values of the given Parameter except for it's Type * * @param param A Parameter * @param type The new Class type * @return A new Parameter */ private Parameter changeParamType(Parameter param, Class type) { return new Parameter( param.getName(), type, param.getTitle(), param.getDescription(), param.isRequired(), param.getMinOccurs(), param.getMaxOccurs(), param.getDefaultValue(), null); } }
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; }
assertTrue("geom in inputs", inputs.containsKey("geom")); Parameter<?> geomParam = inputs.get("geom"); assertEquals("geom title", "Input Geometry", geomParam.getTitle().toString()); assertEquals( "geom description", "The target geometry.", geomParam.getDescription().toString()); assertEquals("geom type", Geometry.class, geomParam.getType()); assertEquals("distance title", "Buffer Distance", distance.getTitle().toString()); assertEquals( "distance description", "The distance by which to buffer the geometry.", distance.getDescription().toString()); assertEquals("distance type", Double.class, distance.getType());
int maxOccurs = param.getMaxOccurs(); if (validators != null) { metadataClone.put(VALIDATORS_KEY, validators); new Parameter( param.key, param.type,
if (all.isEmpty()) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "No PPIO found for the parameter " + p.getName()); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log( Level.FINE, "Trying to search for a PPIO for the parameter " + p.getName()); LOGGER.log(Level.FINE, "Unable to find a PPIO for the parameter " + p.getName());
private Parameter<?> getPrimary(Map<String, Parameter<?>> resultInfo) { if (resultInfo == null) { return null; } if (resultInfo.size() == 1) { return resultInfo.values().iterator().next(); } else { for (Parameter<?> param : resultInfo.values()) { if (param.isRequired()) { return param; } } } return null; }
Object value = input.get(p.key); if (value == null && p.getDefaultValue() != null) { value = p.getDefaultValue();
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; }
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 title", "Second Operand", second.getTitle().toString()); assertEquals( "second description", "The second operand.", second.getDescription().toString()); assertEquals("second type", Float.class, second.getType()); assertEquals("sum title", "Sum", sumParam.getTitle().toString()); assertEquals( "sum description", "The sum of the two inputs", sumParam.getDescription().toString()); assertEquals("sum type", Float.class, sumParam.getType());
private String getPrimary(Map<String, Parameter<?>> resultInfo) { if(resultInfo.size() == 1) { return resultInfo.get(0).getName(); } else { for (Parameter<?> param : resultInfo.values()) { if(param.isRequired()) { return param.getName(); } } } return null; }
/** * Named parameter (argument or result). * * @param name name of parameter * @param type type of parameter * @return parameter description */ public static <T> Parameter<T> parameter(String name, Class<T> type) { return new org.geotools.data.Parameter<T>(name, type); } /**
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; }
/** * 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; }
private String getPrimary(Map<String, Parameter<?>> resultInfo) { if(resultInfo.size() == 1) { return resultInfo.values().iterator().next().getName(); } else { for (Parameter<?> param : resultInfo.values()) { if(param.isRequired()) { return param.getName(); } } } return null; }
void convertAndAdd(Object val, Parameter<?> p, List<Expression> valueArgs) { // handle collection case if (p.getMaxOccurs() > 1 && val instanceof Collection) { for (Object o : (Collection<?>) val) { // just add directly valueArgs.add(factory.filter.literal(o)); } } else if (val instanceof Map) { YamlMap map = YamlMap.<Map<?, ?>>create((Map<?, ?>) val).map(); valueArgs.add(process(map)); } else { // just add directly valueArgs.add(factory.filter.literal(val)); } } }