Package net.opengis.wps10

Examples of net.opengis.wps10.ExecuteResponseType


        Parser parser = new Parser(config);

        Object object = parser.parse(in);

        // try casting the response
        ExecuteResponseType exeResponse = null;
        if (object instanceof ExecuteResponseType)
        {
            exeResponse = (ExecuteResponseType) object;
        }

        // try to get the output datatype
        OutputDataType odt = (OutputDataType) exeResponse.getProcessOutputs().getOutput().get(0);
        String dataType = odt.getData().getLiteralData().getDataType();

        assertNotNull(dataType);

    }
View Full Code Here


        // perform the execution and grab the results
        Map<String, ProcessOutput> outputMap = executeInternal(request);
       
        // build the response
        Wps10Factory f = Wps10Factory.eINSTANCE;
        ExecuteResponseType response = f.createExecuteResponseType();
        response.setLang("en");
        if(request.getBaseUrl() != null) {
          response.setServiceInstance(ResponseUtils.appendQueryString(ResponseUtils.buildURL(request
                .getBaseUrl(), "ows", null, URLType.SERVICE), ""));
        }

        // process
        Name processName = Ows11Util.name(request.getIdentifier());
        ProcessFactory pf = Processors.createProcessFactory(processName);
        final ProcessBriefType process = f.createProcessBriefType();
        response.setProcess(process);
        process.setIdentifier(request.getIdentifier());
        process.setProcessVersion(pf.getVersion(processName));
        process.setTitle(Ows11Util.languageString(pf.getTitle(processName)));
        process.setAbstract(Ows11Util.languageString(pf.getDescription(processName)));

        // status
        response.setStatus(f.createStatusType());
        response.getStatus().setCreationTime(
                Converters.convert(started, XMLGregorianCalendar.class));
        response.getStatus().setProcessSucceeded("Process succeeded.");

        // inputs
        response.setDataInputs(f.createDataInputsType1());
        for (Iterator i = request.getDataInputs().getInput().iterator(); i.hasNext();) {
            InputType input = (InputType) i.next();
            response.getDataInputs().getInput().add(EMFUtils.clone(input, f, true));
        }

        // output definitions
        OutputDefinitionsType outputs = f.createOutputDefinitionsType();
        response.setOutputDefinitions(outputs);

        Map<String, Parameter<?>> outs = pf.getResultInfo(processName, null);
        Map<String, ProcessParameterIO> ppios = new HashMap();

        for (String key : outputMap.keySet()) {
            Parameter p = pf.getResultInfo(processName, null).get(key);
            if (p == null) {
                throw new WPSException("No such output: " + key);
            }

            // find the ppio
            String mime = outputMap.get(key).definition.getMimeType();
            ProcessParameterIO ppio = ProcessParameterIO.find(p, context, mime);
            if (ppio == null) {
                throw new WPSException("Unable to encode output: " + p.key);
            }
            ppios.put(p.key, ppio);

            DocumentOutputDefinitionType output = f.createDocumentOutputDefinitionType();
            outputs.getOutput().add(output);

            output.setIdentifier(Ows11Util.code(p.key));
            if (ppio instanceof ComplexPPIO) {
                output.setMimeType(((ComplexPPIO) ppio).getMimeType());
                if (ppio instanceof BinaryPPIO) {
                    output.setEncoding("base64");
                } else if (ppio instanceof XMLPPIO) {
                    output.setEncoding("utf-8");
                }
            }

            // TODO: better encoding handling + schema
        }

        // process outputs
        ProcessOutputsType1 processOutputs = f.createProcessOutputsType1();
        response.setProcessOutputs(processOutputs);

        for (String key : outputMap.keySet()) {
            OutputDataType output = f.createOutputDataType();
            output.setIdentifier(Ows11Util.code(key));
            output.setTitle(Ows11Util
View Full Code Here

    public ExecuteResponseType build() {
        ExecuteRequest helper = new ExecuteRequest(request);

        // build the response
        Wps10Factory f = Wps10Factory.eINSTANCE;
        ExecuteResponseType response = f.createExecuteResponseType();
        response.setLang("en");
        if (request.getBaseUrl() != null) {
            response.setServiceInstance(ResponseUtils.appendQueryString(
                    ResponseUtils.buildURL(request.getBaseUrl(), "ows", null, URLType.SERVICE), ""));
        }

        // process
        Name processName = helper.getProcessName();
        ProcessFactory pf = GeoServerProcessors.createProcessFactory(processName);
        final ProcessBriefType process = f.createProcessBriefType();
        response.setProcess(process);
        // damn blasted EMF changes the state of request if we set its identifier on
        // another object! (I guess, following some strict ownership rule...)
        process.setIdentifier((CodeType) EMFUtils.clone(request.getIdentifier(),
                Ows11Factory.eINSTANCE, true));
        process.setProcessVersion(pf.getVersion(processName));
        process.setTitle(Ows11Util.languageString(pf.getTitle(processName)));
        process.setAbstract(Ows11Util.languageString(pf.getDescription(processName)));

        // status
        response.setStatus(f.createStatusType());
        XMLGregorianCalendar gc = Converters.convert(created, XMLGregorianCalendar.class);
        response.getStatus().setCreationTime(gc);
        if (status == null) {
            if (exception != null) {
                setResponseFailed(response, getException(ProcessState.COMPLETED));
            } else if (outputs == null) {
                response.getStatus().setProcessAccepted("Process accepted.");
            } else {
                response.getStatus().setProcessSucceeded("Process succeeded.");
            }
        } else {
            if (status.getPhase() == ProcessState.QUEUED) {
                response.getStatus().setProcessAccepted("Process accepted.");
            } else if (status.getPhase() == ProcessState.RUNNING) {
                ProcessStartedType startedType = f.createProcessStartedType();
                int progressPercent = Math.round(status.getProgress());
                if(progressPercent < 0) {
                    LOGGER.warning("Progress reported is below zero, fixing it to 0: " + progressPercent);
                    progressPercent = 0;
                } else if(progressPercent > 100) {
                    LOGGER.warning("Progress reported is above 100, fixing it to 100: " + progressPercent);
                    progressPercent = 100;
                }
                startedType.setPercentCompleted(new BigInteger(String.valueOf(progressPercent)));
                startedType.setValue(status.getTask());
                response.getStatus().setProcessStarted(startedType);
            } else if (status.getPhase() == ProcessState.COMPLETED) {
                response.getStatus().setProcessSucceeded("Process succeeded.");
            } else {
                ServiceException reportException = getException(status.getPhase());
                setResponseFailed(response, reportException);
            }
        }

        // status location, if asynch
        if (helper.isAsynchronous() && request.getBaseUrl() != null && executionId != null) {
            Map<String, String> kvp = new LinkedHashMap<String, String>();
            kvp.put("service", "WPS");
            kvp.put("version", "1.0.0");
            kvp.put("request", "GetExecutionStatus");
            kvp.put("executionId", executionId);
            response.setStatusLocation(ResponseUtils.buildURL(request.getBaseUrl(), "ows", kvp, URLType.SERVICE));

        }

        // lineage, should be included only if requested, the response should contain it
        // even if the process is not done computing. From the spec:
        // * If lineage is "true" the server shall include in the execute response a complete copy
        // of
        // the DataInputs and OutputDefinition elements _as received in the execute request_.
        // *If lineage is "false" then/ these elements shall be omitted from the response
        if (helper.isLineageRequested()) {
            // inputs
            if (request.getDataInputs() != null && request.getDataInputs().getInput().size() > 0) {
                response.setDataInputs(f.createDataInputsType1());
                for (Iterator i = request.getDataInputs().getInput().iterator(); i.hasNext();) {
                    InputType input = (InputType) i.next();
                    response.getDataInputs().getInput().add(EMFUtils.clone(input, f, true));
                }
            }

            // output definitions, if any was requested explicitly
            List<DocumentOutputDefinitionType> outputList = helper.getRequestedOutputs();
            if (outputList != null) {
                OutputDefinitionsType outputs = f.createOutputDefinitionsType();
                response.setOutputDefinitions(outputs);
                for (DocumentOutputDefinitionType output : outputList) {
                    outputs.getOutput().add(EMFUtils.clone(output, f, true));
                }
            }
        }

        // process outputs
        if (exception == null && outputs != null) {
            ProcessOutputsType1 processOutputs = f.createProcessOutputsType1();
            response.setProcessOutputs(processOutputs);

            Map<String, Parameter<?>> resultInfo = pf.getResultInfo(processName, null);

            if (request.getResponseForm() != null
                    && request.getResponseForm().getResponseDocument() != null
View Full Code Here

        if (isStandardDocumentResponse(operation)) {
            // normal execute response encoding
            return standardResponse.getMimeType(value, operation);
        } else {
            // raw response, let's see what the output is
            ExecuteResponseType response = (ExecuteResponseType) value;
            if(response.getProcessOutputs() == null) {
                // just a status report or a failure report
                return "text/xml";
            }
            OutputDataType result = (OutputDataType) response.getProcessOutputs().getOutput().get(0);
            LiteralDataType literal = result.getData().getLiteralData();
            ComplexDataType complex = result.getData().getComplexData();
            if(literal != null) {
                // literals are encoded as plain strings
                return "text/plain";
View Full Code Here

    public String getAttachmentFileName(Object value, Operation operation) {
        if(isStandardDocumentResponse(operation)) {
            return "execute.xml";
        } else {
            ExecuteType execute = (ExecuteType) operation.getParameters()[0];
            ExecuteResponseType response = (ExecuteResponseType) value;
            if(response.getProcessOutputs() == null) {
                // just a status report or a failure report
                return "execute.xml";
            }
            OutputDataType result = (OutputDataType) response.getProcessOutputs().getOutput().get(0);
            String fname = result.getIdentifier().getValue();
            LiteralDataType literal = result.getData().getLiteralData();
            ComplexDataType complex = result.getData().getComplexData();
            String fext;
            // this is not the most robust way to get mime type...
View Full Code Here

    }

    @Override
    public void write(Object value, OutputStream output, Operation operation)
            throws IOException, ServiceException {
        ExecuteResponseType response = (ExecuteResponseType) value;
       
        // From the spec:
        // In the most primitive case, when a response form of ―RawDataOutput‖ is requested,
        // process execution is successful, and only one complex output is produced, then the
        // Execute operation response will consist simply of that one complex output in its raw form
        // returned directly to the client.
        // In all other cases, the response to a valid Execute operation request is an
        // ExecuteResponse XML document
        if (isStandardDocumentResponse(operation) ||
                response.getStatus().getProcessSucceeded() == null) {
            // normal execute response encoding
            standardResponse.write(value, output, operation);
        } else {
            // raw response, let's see what the output is
            OutputDataType result = (OutputDataType) response
                    .getProcessOutputs().getOutput().get(0);
            LiteralDataType literal = result.getData().getLiteralData();
            BoundingBoxType bbox = result.getData().getBoundingBoxData();
            if (literal != null) {
                writeLiteral(output, literal);
View Full Code Here

        this.executionManager = executionManager;
    }

    public Object run(GetExecutionStatusType request) {
        // see if the process is still in-flight
        ExecuteResponseType status = executionManager.getStatus(request.getExecutionId());
        if (status != null) {
            return status;
        }
       
        // otherwise check for a stored response
View Full Code Here

        void writeOutResponse(ExecuteResponseBuilder responseBuilder, File output)
                throws IOException {
            FileOutputStream fos = null;
            File tmpOutput = new File(output.getParent(), "tmp" + output.getName());
            try {
                ExecuteResponseType response = responseBuilder.build();
                XmlObjectEncodingResponse encoder = new XmlObjectEncodingResponse(
                        ExecuteResponseType.class, "ExecuteResponse", WPSConfiguration.class);

                fos = new FileOutputStream(tmpOutput);
                encoder.write(response, fos, null);
View Full Code Here

        if (execute.getResponseForm().getRawDataOutput() == null) {
            // normal execute response encoding
            return standardResponse.getMimeType(value, operation);
        } else {
            // raw response, let's see what the output is
            ExecuteResponseType response = (ExecuteResponseType) value;
            OutputDataType result = (OutputDataType) response
                    .getProcessOutputs().getOutput().get(0);
            LiteralDataType literal = result.getData().getLiteralData();
            if(literal != null) {
                // literals are encoded as plain strings
                return "text/plain";
            } else {
                // Execute should have properly setup the mime type
                OutputDefinitionType definition = (OutputDefinitionType) response
                    .getOutputDefinitions().getOutput().get(0);
                return definition.getMimeType();
            }
        }
View Full Code Here

        if (execute.getResponseForm().getRawDataOutput() == null) {
            // normal execute response encoding
            standardResponse.write(value, output, operation);
        } else {
            // raw response, let's see what the output is
            ExecuteResponseType response = (ExecuteResponseType) value;
            OutputDataType result = (OutputDataType) response
                    .getProcessOutputs().getOutput().get(0);
            LiteralDataType literal = result.getData().getLiteralData();
            BoundingBoxType bbox = result.getData().getBoundingBoxData();
            if (literal != null) {
                writeLiteral(output, literal);
View Full Code Here

TOP

Related Classes of net.opengis.wps10.ExecuteResponseType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.