Return two types of data

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Return two types of data

sammeek
Hi Board,

I am trying to return two types of data (Complex and Literal) using the java client. My process snippet is:

                LOGGER.warn("resultFeatureCollection Size " + list.size());
                //output data here
               
               
               
                HashMap<String, IData> results = new HashMap<String, IData>();
               
                results.put("result", new GTVectorDataBinding ((FeatureCollection) obsFC));
                results.put("metadata", new LiteralStringBinding(metadata));
               
                LOGGER.warn(metadata);

               
               
                return results;

And client is:

 if (responseObject instanceof ExecuteResponseDocument) {
                        ExecuteResponseDocument response = (ExecuteResponseDocument) responseObject;
                        ExecuteResponseAnalyser analyser = new ExecuteResponseAnalyser(
                                        execute, response, processDescription);
                        OutputDataType[] dataType = new OutputDataType[2];
                       
                        dataType = response.getExecuteResponse().getProcessOutputs().getOutputArray();
                       
                       
                        IData[] dataReturn = new IData[2];
                       
                        Object data =  analyser.getComplexData("result",
                                        GTVectorDataBinding.class);
                        dataReturn[0] = (IData) data;
                 
                   if (dataType.isSetComplexData()) {

                            ExecuteResponseAnalyser analyser2 = new ExecuteResponseAnalyser(
                                            execute, response, processDescription);

                            data = analyser.getComplexData("metadata",
                                            LiteralStringBinding.class);
                            dataReturn[1] = (IData) data;
                    } else if (dataType.isSetLiteralData()) {
                            //and then just get the StringValue
                            data = dataType.getLiteralData().getStringValue();
                            dataReturn[1] = (IData) data;
                    }
                       
                       
                       
                        return dataReturn;
                }

for some reason, I can get it to return the ComplexData but not the literal data.

Any ideas?

Reply | Threaded
Open this post in threaded view
|

Re: Return two types of data

BenjaminPross
Hello Sam,

I am afraid there is no convenience method to extract LiteralData in the
ExecuteResponseAnalyser.

You could try something like this (if there is to be only one
LiteralOutput):

             XObject data = XPathAPI.eval(response.getDomNode(),
"//wps:LiteralData");
             String outputValue = data.toString();

or (old school):

             String literalDataID = "metadata";

             String literalDataValue = "";

             OutputDataType[] outputDatatypes =
response.getExecuteResponse()
                     .getProcessOutputs().getOutputArray();

             for (OutputDataType outputDataType : outputDatatypes) {

                 if (outputDataType.isSetData()
                         && outputDataType.getData().isSetLiteralData()) {

                     LiteralDataType literalData =
outputDataType.getData().getLiteralData();

                     if (outputDataType.getIdentifier().getStringValue()
                             .equals(literalDataID)) {
                         literalDataValue = literalData.getStringValue();
                     }
                 }
             }

Hope this helps. And if you have a GitHub account, feel free to create
an issue about the missing functionality here:
https://github.com/52North/WPS/issues

Cheers,

Benjamin

Am 31.07.2014 13:59, schrieb sammeek:

> Hi Board,
>
> I am trying to return two types of data (Complex and Literal) using the java
> client. My process snippet is:
>
> LOGGER.warn("resultFeatureCollection Size " + list.size());
> //output data here
>
>
>
> HashMap<String, IData> results = new HashMap<String, IData>();
>
> results.put("result", new GTVectorDataBinding ((FeatureCollection)
> obsFC));
> results.put("metadata", new LiteralStringBinding(metadata));
>
> LOGGER.warn(metadata);
>
>
>
> return results;
>
> And client is:
>
>   if (responseObject instanceof ExecuteResponseDocument) {
>                          ExecuteResponseDocument response =
> (ExecuteResponseDocument) responseObject;
>                          ExecuteResponseAnalyser analyser = new
> ExecuteResponseAnalyser(
>                                          execute, response,
> processDescription);
>                          OutputDataType[] dataType = new OutputDataType[2];
>                          
>                          dataType =
> response.getExecuteResponse().getProcessOutputs().getOutputArray();
>                          
>                        
>                          IData[] dataReturn = new IData[2];
>                          
>                          Object data =  analyser.getComplexData("result",
>                                          GTVectorDataBinding.class);
>                          dataReturn[0] = (IData) data;
>                    
>                     if (dataType.isSetComplexData()) {
>
>                              ExecuteResponseAnalyser analyser2 = new
> ExecuteResponseAnalyser(
>                                              execute, response,
> processDescription);
>
>                              data = analyser.getComplexData("metadata",
>                                              LiteralStringBinding.class);
>                              dataReturn[1] = (IData) data;
>                      } else if (dataType.isSetLiteralData()) {
>                              //and then just get the StringValue
>                              data =
> dataType.getLiteralData().getStringValue();
>                              dataReturn[1] = (IData) data;
>                      }
>                        
>                        
>                        
>                          return dataReturn;
>                  }
>
> for some reason, I can get it to return the ComplexData but not the literal
> data.
>
> Any ideas?
>
>
>
>
>
> --
> View this message in context: http://geoprocessing.forum.52north.org/Return-two-types-of-data-tp4025721.html
> Sent from the 52° North - Geoprocessing Community Forum mailing list archive at Nabble.com.
> _______________________________________________
> Geoprocessingservices mailing list
> [hidden email]
> http://list.52north.org/mailman/listinfo/geoprocessingservices
> http://geoprocessing.forum.52north.org


--
Benjamin Proß
Software Engineer
52°North Geoprocessing Community

52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
Fon: +49-(0)-251–396371-42
Fax: +49-(0)-251–396371-11
[hidden email]
http://52north.org/

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849

_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Reply | Threaded
Open this post in threaded view
|

Re: Return two types of data

sammeek
Hi Benjamin,

I am creating this process as a test, what I actually need to do it return the data and a metadata record (probably xml). Does this same apply? Or is that complex data, and if so does it require a different parser?

Sam
Reply | Threaded
Open this post in threaded view
|

Re: Return two types of data

BenjaminPross
Hi Sam,

If you want to return xml metadata as a separate output, you should use
complexdata.
As this will most likely follow a custom schema, you will not be able to
use a standard WPS parser, but you could access the nodes using XPath.
If you will not use xml for the metadata, you could use the
Stringbinding and access it as discussed earlier.

Cheers,

Benjamin

Am 31.07.2014 14:57, schrieb sammeek:

> Hi Benjamin,
>
> I am creating this process as a test, what I actually need to do it return
> the data and a metadata record (probably xml). Does this same apply? Or is
> that complex data, and if so does it require a different parser?
>
> Sam
>
>
>
> --
> View this message in context: http://geoprocessing.forum.52north.org/Return-two-types-of-data-tp4025721p4025724.html
> Sent from the 52° North - Geoprocessing Community Forum mailing list archive at Nabble.com.
> _______________________________________________
> Geoprocessingservices mailing list
> [hidden email]
> http://list.52north.org/mailman/listinfo/geoprocessingservices
> http://geoprocessing.forum.52north.org


--
Benjamin Proß
Software Engineer
52°North Geoprocessing Community

52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
Fon: +49-(0)-251–396371-42
Fax: +49-(0)-251–396371-11
[hidden email]
http://52north.org/

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849

_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org