/** * Look up an implementation of the named process on the classpath and describe the expected * results. * * <p>Note the expected results are generated in part by the input parameters provided; this is * to allow for processes where the output is controlled by the parameters (such as choosing a * greyscale or color raster product; or choosing the version of GML produced etc...). * * @param name Name of the Process * @param parameters * @return Description of the parameters required */ public static synchronized Map<String, Parameter<?>> getResultInfo( Name name, Map<String, Object> parameters) { ProcessFactory factory = createProcessFactory(name); if (factory == null) return null; return factory.getResultInfo(name, parameters); }
try { Map<String, Parameter<?>> resultInfo = factory.getResultInfo(processName, null); Parameter<?> result = getPrimary(resultInfo);
@Override public Map<String, Parameter<?>> perform( ProcessFactory f, Name oldName, Name newName, Object... args) { return f.getResultInfo(newName, (Map<String, Object>) args[0]); } },
public Map<String, Parameter<?>> getResultInfo(Name name, Map<String, Object> parameters) throws IllegalArgumentException { return delegate.getResultInfo(name, parameters); }
public Map<String, Parameter<?>> getResultInfo(Name name, Map<String, Object> parameters) throws IllegalArgumentException { if (selector.allowProcess(name)) { return delegate.getResultInfo(name, parameters); } else { return null; } }
public Map<String, Parameter<?>> getResultInfo(Name name, Map<String, Object> parameters) throws IllegalArgumentException { if (selector.allowProcess(name)) { return delegate.getResultInfo(name, parameters); } else { return null; } }
/** * Look up an implementation of the named process on the classpath and describe the expected * results. * <p> * Note the expected results are generated in part by the input parameters provided; this is to * allow for processes where the output is controlled by the parameters (such as choosing a * greyscale or color raster product; or choosing the version of GML produced etc...). * * @param name Name of the Process * @param parameters * @return Description of the parameters required */ public static synchronized Map<String, Parameter<?>> getResultInfo(Name name, Map<String, Object> parameters){ ProcessFactory factory = createProcessFactory( name ); if( factory == null ) return null; return factory.getResultInfo(name, parameters); }
/** * Returns the default mime type for the given raw result * * @param processName * @param pf * @param resultName */ public static String getDefaultMime(Name processName, ProcessFactory pf, String resultName) { Map<String, Parameter<?>> resultInfo = pf.getResultInfo(processName, null); Parameter<?> parameter = resultInfo.get(resultName); if (parameter == null) { LOGGER.warning( "Looked up raw result " + resultName + " in process " + processName + " but found none, returned default mime type"); return BINARY_MIME; } return getMimeTypes(parameter)[0]; } }
/** * 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; }
/** * Tests if all inputs and outputs of a Process are transmutable * * @param pf * @return */ public boolean isTransmutable(ProcessFactory pf, Name name) { for(Parameter<?> param : pf.getParameterInfo(name).values()) { try { this.getDefaultTransmuter(param.type); } catch(Exception e) { return false; } } for(Parameter<?> param : pf.getResultInfo(name, null).values()) { try { this.getDefaultTransmuter(param.type); } catch(Exception e) { return false; } } return true; } }
/** * Tests if all inputs and outputs of a Process are transmutable * * @param pf */ public boolean isTransmutable(ProcessFactory pf, Name name) { for (Parameter<?> param : pf.getParameterInfo(name).values()) { try { this.getDefaultTransmuter(param.type); } catch (Exception e) { return false; } } for (Parameter<?> param : pf.getResultInfo(name, null).values()) { try { this.getDefaultTransmuter(param.type); } catch (Exception e) { return false; } } return true; } }
private synchronized void init() { if(functionNames == null) { // collect and sort the factories to have a reproducable list of function names List<ProcessFactory> factories = new ArrayList<ProcessFactory>(Processors .getProcessFactories()); Collections.sort(factories, FACTORY_COMPARATOR); // collect name and params of all processes resulting in a single output processToFunction = new HashMap<Name,FunctionName>(); functionNames = new ArrayList<FunctionName>(); for (ProcessFactory factory : factories) { for (Name processName : factory.getNames()) { Map<String, Parameter<?>> resultInfo = factory.getResultInfo(processName, null); // check there is a single output if(getPrimary(resultInfo) != null) { Map<String, Parameter<?>> parameterInfo = factory.getParameterInfo(processName); List<String> argumentNames = new ArrayList<String>(parameterInfo.keySet()); FunctionName functionName = new FunctionNameImpl(processName, argumentNames); functionNames.add(functionName); processToFunction.put(processName, functionName); } } } // add the parameter function functionNames.add(new FunctionNameImpl(ParameterFunction.NAME, -1)); } }
boolean hasComplexOutputs() { ProcessFactory pf = Processors.createProcessFactory(request.getProcessName()); Map<String, Parameter<?>> resultInfo = pf.getResultInfo(request.getProcessName(), inputs); for (Parameter<?> param : resultInfo.values()) { List<ProcessParameterIO> ppios = ProcessParameterIO.findAll(param, applicationContext); for (ProcessParameterIO ppio : ppios) { if(ppio instanceof ComplexPPIO) { return true; } } } return false; }
boolean hasComplexOutputs() { ProcessFactory pf = GeoServerProcessors.createProcessFactory(request.getProcessName(), false); Map<String, Parameter<?>> resultInfo = pf.getResultInfo(request.getProcessName(), inputs); for (Parameter<?> param : resultInfo.values()) { List<ProcessParameterIO> ppios = ProcessParameterIO.findAll(param, applicationContext); for (ProcessParameterIO ppio : ppios) { if (ppio instanceof ComplexPPIO) { return true; } } } return false; }
for (Parameter<?> p : pf.getResultInfo(name, null).values()) { List<ProcessParameterIO> ppios = ProcessParameterIO.findAll(p, context); if (ppios.isEmpty()) {
/** * Ensures the requested output are valid * * @param inputs */ public void validateOutputs(Map inputs) { Map<String, Parameter<?>> resultInfo = pf.getResultInfo(getProcessName(), inputs); List<OutputDefinitionType> requestedOutputs = getRequestedOutputs(); if (requestedOutputs != null) { for (OutputDefinitionType output : requestedOutputs) { String outputIdentifier = output.getIdentifier().getValue(); if (!resultInfo.containsKey(outputIdentifier)) { String locator = output instanceof DocumentOutputDefinitionType ? "ResponseDocument" : "RawDataOutput"; throw new WPSException( "Unknow output " + outputIdentifier, ServiceException.INVALID_PARAMETER_VALUE, locator); } } } } }
execute.setResponseForm(parseResponseDocument(pf.getResultInfo(processName, null), (String) rawKvp.get("responseDocument"))); } else if(rawKvp.containsKey("rawDataOutput")) { execute.setResponseForm(parseRawDataOutput(pf.getResultInfo(processName, null), (String) rawKvp.get("rawDataOutput"))); } else { ResponseFormType responseForm = factory.createResponseFormType();
private void processOutputs(ProcessFactory pf, Name processName) { start("ProcessOutputs"); for (Parameter<?> outputIdentifier : pf.getResultInfo(processName, null).values()) { start("Output"); element("ows:Identifier", outputIdentifier.key); element("ows:Title", outputIdentifier.title.toString(this.locale)); element("ows:Abstract", outputIdentifier.description.toString(this.locale)); Transmuter transmuter = this.dataTransformer.getDefaultTransmuter(outputIdentifier.type); if (transmuter instanceof ComplexTransmuter) { start("ComplexOutput"); this.complexParameter((ComplexTransmuter) transmuter); end("ComplexOutput"); } else { this.literalData((LiteralTransmuter) transmuter); } end("Output"); } end("ProcessOutputs"); }
private void processOutputs(ProcessFactory pf, Name processName) { start("ProcessOutputs"); for (Parameter<?> outputIdentifier : pf.getResultInfo(processName, null).values()) { start("Output"); element("ows:Identifier", outputIdentifier.key); element("ows:Title", outputIdentifier.title.toString( this.locale)); element("ows:Abstract", outputIdentifier.description.toString(this.locale)); Transmuter transmuter = this.dataTransformer.getDefaultTransmuter(outputIdentifier.type); if (transmuter instanceof ComplexTransmuter) { start("ComplexOutput"); this.complexParameter((ComplexTransmuter)transmuter); end("ComplexOutput"); } else { this.literalData((LiteralTransmuter)transmuter); } end("Output"); } end("ProcessOutputs"); }
ProcessFactory factory = GeoServerProcessors.createProcessFactory(name, true); if (factory != null) { Map<String, Parameter<?>> resultInfo = factory.getResultInfo(name, null); Parameter p = resultInfo.get(result.getIdentifier().getValue()); if (p != null) {