Package net.opengis.wps10

Examples of net.opengis.wps10.OutputDataType


        // check result correctness
        EList outputs = executeResponse.getProcessOutputs().getOutput();
        assertTrue(!outputs.isEmpty());

        OutputDataType output = (OutputDataType) outputs.get(0);
        LiteralDataType literalData = output.getData().getLiteralData();
        String value = literalData.getValue();
        Double result = new Double(value);
        Double expected = 77.84 + 40039.229;
        assertEquals(result, expected);
View Full Code Here


            assertNotNull(executeResponse);
        }

        // check result correctness
        assertEquals(1, executeResponse.getProcessOutputs().getOutput().size());
        OutputDataType output = (OutputDataType) executeResponse.getProcessOutputs().getOutput().get(0);
       
        assertEquals("result", output.getIdentifier().getValue());
        assertEquals("application/arcgrid", output.getReference().getMimeType());
        assertNotNull(output.getReference().getHref());
       
        URL dataURL = new URL(output.getReference().getHref());
        BufferedReader reader = new BufferedReader(new InputStreamReader(dataURL.openStream()));
        StringBuilder sb = new StringBuilder();
        String line = null;
        int count = 0;
        while((line = reader.readLine()) != null && count <= 5) {
View Full Code Here

        }

        Iterator iterator = outputs.iterator();
        while (iterator.hasNext())
        {
            OutputDataType odt = (OutputDataType) iterator.next();
            DataType data = odt.getData();
            ComplexDataType complexData = data.getComplexData();
            LiteralDataType literalData = data.getLiteralData();
            if (literalData != null)
            {
                // use the converters api to try and create an object of the type
                // we want (default to the String value if it failed).
                Object value = literalData.getValue();
                if (literalData.getDataType() != null)
                {
                    Class type = getLiteralTypeFromReference(literalData.getDataType());
                    Object convertedValue = Converters.convert(literalData.getValue(), type);
                    if (convertedValue != null)
                    {
                        value = convertedValue;
                    }
                }
                map.put(odt.getIdentifier().getValue(), value);
            }
            else if (complexData != null)
            {
                // if we have a list of values for this output, store it as a arraylist
                EList datas = complexData.getData();
                if (datas.size() > 1)
                {
                    Iterator iterator2 = datas.iterator();
                    List<Object> values = new ArrayList<Object>();
                    while (iterator2.hasNext())
                    {
                        Object value = iterator2.next();
                        values.add(value);
                    }
                    map.put(odt.getIdentifier().getValue(), values);
                }
                else
                {
                    map.put(odt.getIdentifier().getValue(), datas.get(0));
                }
            }

        }
View Full Code Here

        ExecuteResponseType response = f.createExecuteResponseType();

        ProcessOutputsType1 outputs = f.createProcessOutputsType1();
        response.setProcessOutputs(outputs);

        OutputDataType output = f.createOutputDataType();
        outputs.getOutput().add(output);

        LanguageStringType title = Ows11Factory.eINSTANCE.createLanguageStringType();
        output.setTitle(title);
        title.setValue("foo");

        DataType data = f.createDataType();
        output.setData(data);

        ComplexDataType cdata = f.createComplexDataType();
        data.setComplexData(cdata);
        //cdata.getData().add(new GeometryFactory().createPoint(new Coordinate(1, 1)));
View Full Code Here

        {
            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

        // 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
                    .languageString(pf.getResultInfo(processName, null).get(key).description));
            processOutputs.getOutput().add(output);

            final Object o = outputMap.get(key).object;
            ProcessParameterIO ppio = ppios.get(key);

            if (ppio instanceof ReferencePPIO) {
                // encode as a reference
                OutputReferenceType ref = f.createOutputReferenceType();
                output.setReference(ref);

                ref.setMimeType(outputMap.get(key).definition.getMimeType());
                ref.setHref(((ReferencePPIO) ppio).encode(o).toString());
            } else {
                // encode as data
                DataType data = f.createDataType();
                output.setData(data);

                try {
                  if (ppio instanceof LiteralPPIO) {
                      LiteralDataType literal = f.createLiteralDataType();
                      data.setLiteralData(literal);
View Full Code Here

                        throw new WPSException("Unknown output " + key + " possible values are: "
                                + resultInfo.keySet());
                    }

                    String mimeType = odt.getMimeType();
                    OutputDataType output = encodeOutput(key, outputParam, mimeType, odt.isAsReference());
                    processOutputs.getOutput().add(output);
                }
            } else {
                // encode all as inline for the moment
                for (String key : outputs.keySet()) {
                    Parameter<?> outputParam = resultInfo.get(key);
                    OutputDataType output = encodeOutput(key, outputParam, null, false);
                    processOutputs.getOutput().add(output);
                }
            }
        }
View Full Code Here

    }

    OutputDataType encodeOutput(String key, Parameter<?> outputParam, String mimeType,
            boolean reference) {
        Wps10Factory f = Wps10Factory.eINSTANCE;
        OutputDataType output = f.createOutputDataType();
        output.setIdentifier(Ows11Util.code(key));
        output.setTitle(Ows11Util.languageString(outputParam.description));

        final Object o = outputs.get(key);
        if (mimeType == null) {
            mimeType = getOutputMimeType(key);
        }
        ProcessParameterIO ppio = ProcessParameterIO.find(outputParam, context, mimeType);

        if (ppio == null) {
            throw new WPSException("Don't know how to encode output " + key + " in mime type "
                    + mimeType);
        }

        try {
            if (reference && ppio instanceof ComplexPPIO) {
                // encode as reference
                OutputReferenceType outputReference = f.createOutputReferenceType();
                output.setReference(outputReference);
               
                ComplexPPIO cppio = (ComplexPPIO) ppio;
                File file = resourceManager.getOutputFile(executionId, key + "." + cppio.getFileExtension());
               
                // write out the file
                FileOutputStream fos = null;
                try {
                    fos = new FileOutputStream(file);
                    cppio.encode(o, fos);
                } finally {
                    IOUtils.closeQuietly(fos);
                }
               
                // create the link
                Map<String, String> kvp = new LinkedHashMap<String, String>();
                kvp.put("service", "WPS");
                kvp.put("version", "1.0.0");
                kvp.put("request", "GetExecutionResult");
                kvp.put("executionId", executionId);
                kvp.put("outputId", file.getName());
                if(o instanceof RawData) {
                  RawData rawData = (RawData) o;
                  kvp.put("mimetype", rawData.getMimeType());
                } else {
                  kvp.put("mimetype", cppio.getMimeType());
                }
                outputReference.setHref(ResponseUtils.buildURL(request.getBaseUrl(), "ows", kvp, URLType.SERVICE));
                outputReference.setMimeType(cppio.getMimeType());
            } else {
                // encode as data
                DataType data = f.createDataType();
                output.setData(data);

                if (ppio instanceof LiteralPPIO) {
                    LiteralDataType literal = f.createLiteralDataType();
                    data.setLiteralData(literal);
View Full Code Here

            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";
            } else if(complex != null) {
                // Execute should have properly setup the mime type
View Full Code Here

            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...
            if (literal != null) {
                fext = "txt";
            } else if(complex != null) {
                String mimeType = result.getData().getComplexData().getMimeType();
                if (mimeType == null) {
                    fext = "txt";
                } else {
                    fext = mimeType.split("/")[1].toLowerCase();
                }
View Full Code Here

TOP

Related Classes of net.opengis.wps10.OutputDataType

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.