/** * delivers just the URL of a referenced output identified by index * @param index index of the output * @return URL of the stored output * @throws WPSClientException */ public String getComplexReferenceByIndex(int index) throws WPSClientException { ExecuteResponseDocument doc = null; if(response instanceof ExecuteResponseDocument){ doc = (ExecuteResponseDocument) response; }else{ throw new WPSClientException("Output cannot be determined by index since it is either raw data or an exception report"); } OutputDataType[] outputs = doc.getExecuteResponse().getProcessOutputs().getOutputArray(); int counter = 0; for(OutputDataType output : outputs) { if(output.getReference() != null) { if(counter == index) { return output.getReference().getHref(); } counter ++; } } RuntimeException rte = new RuntimeException("No reference found in response"); LOGGER.error(rte.getMessage()); throw rte; }
}else if (response instanceof ExecuteResponseDocument){ ExecuteResponseDocument responseDocument = (ExecuteResponseDocument) response; OutputDataType[] processOutputs = responseDocument.getExecuteResponse().getProcessOutputs().getOutputArray(); for(OutputDataType processOutput : processOutputs){ if(processOutput.getIdentifier().getStringValue().equalsIgnoreCase(outputID)){
/** * delivers the parsed ComplexData by index * @param index index of the output element starting with 0 * @param binding Class of the output binding, e.g. GenericFileDataBinding * @return the parsed ComplexData in the requested format defined by the binding * @throws WPSClientException */ public IData getComplexDataByIndex(int index, Class<?> binding) throws WPSClientException { ExecuteResponseDocument doc = null; if(response instanceof ExecuteResponseDocument){ doc = (ExecuteResponseDocument) response; }else{ throw new WPSClientException("Output cannot be determined by index since it is either raw data or an exception report"); } OutputDataType[] outputs = doc.getExecuteResponse().getProcessOutputs().getOutputArray(); int counter = 0; for(OutputDataType output : outputs) { if(output.getData().getComplexData() != null) { if(counter == index) { return this.parseProcessOutput(output.getIdentifier().getStringValue(), binding); } counter ++; } } return null; }
private OutputDataType prepareOutput(ExecuteResponseDocument res){ OutputDataType output = res.getExecuteResponse().getProcessOutputs().addNewOutput(); CodeType identifierCode = output.addNewIdentifier(); identifierCode.setStringValue(id); output.setTitle(title); return output; }