|
From: <svn...@os...> - 2012-01-04 11:40:22
|
Author: afabiani
Date: 2012-01-04 03:40:08 -0800 (Wed, 04 Jan 2012)
New Revision: 38455
Added:
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/request/AbstractGetExecutionStatusRequest.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/request/GetExecutionStatusRequest.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/response/GetExecutionStatusResponse.java
Modified:
trunk/modules/unsupported/wps/pom.xml
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPS.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPSGetCapabilitiesResponse.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/ProcessDescription.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/package-info.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPS1_0_0.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSFactory.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSProcess.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSSpecification.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSUtils.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WebProcessingService.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/package-info.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/request/AbstractExecuteProcessRequest.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/request/AbstractWPSRequest.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/request/ExecuteProcessRequest.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/request/package-info.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/response/DescribeProcessResponse.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/response/ExecuteProcessResponse.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/response/WPSGetCapabilitiesResponse.java
trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/response/package-info.java
trunk/modules/unsupported/wps/src/test/java/org/geotools/data/wps/OnlineWPSFactoryTest.java
trunk/modules/unsupported/wps/src/test/java/org/geotools/data/wps/OnlineWPSManualRequestTest.java
trunk/modules/unsupported/wps/src/test/java/org/geotools/data/wps/ParsingTest.java
Log:
- GEOT-3996 / GEOT-3997
Modified: trunk/modules/unsupported/wps/pom.xml
===================================================================
--- trunk/modules/unsupported/wps/pom.xml 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/pom.xml 2012-01-04 11:40:08 UTC (rev 38455)
@@ -96,6 +96,12 @@
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.geotools</groupId>
+ <artifactId>gt-postgis</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools.ogc</groupId>
@@ -119,6 +125,25 @@
</dependency>
<dependency>
<groupId>org.geotools</groupId>
+ <artifactId>gt-xml</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.geotools</groupId>
+ <artifactId>gt-wfs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.geotools.xsd</groupId>
+ <artifactId>gt-xsd-wfs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.geotools.ogc</groupId>
+ <artifactId>net.opengis.wfs</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.geotools</groupId>
<artifactId>gt-sample-data</artifactId>
<version>${project.version}</version>
<scope>test</scope>
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPS.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPS.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPS.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -3,7 +3,7 @@
* http://geotools.org
*
* (C) 2004-2008, Open Source Geospatial Foundation (OSGeo)
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
@@ -16,15 +16,10 @@
*/
package org.geotools.data.ows;
-import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -33,95 +28,153 @@
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.zip.GZIPInputStream;
import net.opengis.wps10.WPSCapabilitiesType;
import org.geotools.data.ResourceInfo;
import org.geotools.data.ServiceInfo;
-import org.geotools.data.ows.SimpleHttpClient.SimpleHTTPResponse;
import org.geotools.ows.ServiceException;
+
/**
- * This abstract class provides a building block for one to implement a
- * WPS client.
- *
+ * This abstract class provides a building block for one to implement a
+ * WPS client.
+ *
* This class provides version negotiation, Capabilities document retrieval,
* and a request/response infrastructure. Implementing subclasses need to
- * provide their own Specifications
- *
+ * provide their own Specifications
+ *
* @author gdavis
*
*
- *
- *
- *
* @source $URL$
*/
-public abstract class AbstractWPS<C extends WPSCapabilitiesType, R extends Object> {
+public abstract class AbstractWPS<C extends WPSCapabilitiesType, R extends Object>
+{
+
+ private static final Logger LOGGER = org.geotools.util.logging.Logging.getLogger("org.geotools.data.ows");
+ private HTTPClient httpClient;
protected final URL serverURL;
protected C capabilities;
protected ServiceInfo info;
- protected Map<R,ResourceInfo> resourceInfo = new HashMap<R,ResourceInfo>();
-
+ protected Map<R, ResourceInfo> resourceInfo = new HashMap<R, ResourceInfo>();
+
/** Contains the specifications that are to be used with this service */
protected Specification[] specs;
protected Specification specification;
-
- private static final Logger LOGGER = org.geotools.util.logging.Logging.getLogger("org.geotools.data.ows");
/**
* Set up the specifications used and retrieve the Capabilities document
* given by serverURL.
- *
+ *
* @param serverURL a URL that points to the capabilities document of a server
* @throws IOException if there is an error communicating with the server
* @throws ServiceException if the server responds with an error
*/
- public AbstractWPS( final URL serverURL ) throws IOException, ServiceException {
- if (serverURL == null) {
- throw new NullPointerException("ServerURL cannot be null");
- }
-
- this.serverURL = serverURL;
+ public AbstractWPS(final URL serverURL) throws IOException, ServiceException
+ {
+ this(serverURL, new SimpleHttpClient(), null);
- setupSpecifications();
-
capabilities = negotiateVersion();
- if (capabilities == null) {
- throw new ServiceException("Unable to retrieve or parse Capabilities document.");
+ if (capabilities == null)
+ {
+ throw new ServiceException("Unable to retrieve or parse Capabilities document.");
}
+ else if (capabilities != null)
+ {
+ setupSpecification(capabilities);
+ }
}
- public AbstractWPS(C capabilties, URL serverURL) {
- if (capabilties == null) {
- throw new NullPointerException("Capabilities cannot be null.");
- }
-
- if (serverURL == null) {
- throw new NullPointerException("ServerURL cannot be null");
- }
-
- setupSpecifications();
-
- for (int i = 0; i < specs.length; i++) {
- if (specs[i].getVersion().equals(capabilties.getVersion())) {
- specification = specs[i];
- break;
- }
- }
-
- if (specification == null) {
- specification = specs[specs.length-1];
- LOGGER.warning("Unable to choose a specification based on cached capabilities. "
- +"Arbitrarily choosing spec '"+specification.getVersion()+"'.");
- }
-
- this.serverURL = serverURL;
- this.capabilities = capabilties;
- }
+ /**
+ * @throws IOException
+ * @throws ServiceException
+ * @deprecated use {@link #AbstractWPS(OWSConfig)}
+ */
+ public AbstractWPS(final URL serverURL, int requestTimeout) throws ServiceException, IOException
+ {
+ this(serverURL, new SimpleHttpClient(), null);
+ this.httpClient.setConnectTimeout(requestTimeout);
+ this.httpClient.setReadTimeout(requestTimeout);
+ }
/**
+ * @deprecated use {@link #AbstractWPS(OWSConfig, Capabilities)}
+ */
+ public AbstractWPS(C capabilties, URL serverURL) throws ServiceException, IOException
+ {
+ this(serverURL, new SimpleHttpClient(), capabilties);
+ }
+
+ public AbstractWPS(final URL serverURL, final HTTPClient httpClient,
+ final C capabilities) throws ServiceException, IOException
+ {
+ if (serverURL == null)
+ {
+ throw new NullPointerException("serverURL");
+ }
+ if (httpClient == null)
+ {
+ throw new NullPointerException("httpClient");
+ }
+
+ this.serverURL = serverURL;
+ this.httpClient = httpClient;
+
+ setupSpecifications();
+
+ if (capabilities != null)
+ {
+ setupSpecification(capabilities);
+
+ this.capabilities = capabilities;
+ }
+ else
+ {
+ this.capabilities = negotiateVersion();
+ if (this.capabilities == null)
+ {
+ throw new ServiceException("Unable to retrieve or parse Capabilities document.");
+ }
+ setupSpecification(this.capabilities);
+ }
+
+ }
+
+ /**
+ * @param capabilities
+ */
+ private void setupSpecification(final C capabilities)
+ {
+ for (int i = 0; i < specs.length; i++)
+ {
+ if (specs[i].getVersion().equals(capabilities.getVersion()))
+ {
+ specification = specs[i];
+
+ break;
+ }
+ }
+
+ if (specification == null)
+ {
+ specification = specs[specs.length - 1];
+ LOGGER.warning("Unable to choose a specification based on cached capabilities. " +
+ "Arbitrarily choosing spec '" + specification.getVersion() + "'.");
+ }
+ }
+
+ public void setHttpClient(HTTPClient httpClient)
+ {
+ this.httpClient = httpClient;
+ }
+
+ public HTTPClient getHTTPClient()
+ {
+ return this.httpClient;
+ }
+
+ /**
* Description of this service.
* <p>
* Provides a very quick description of the service, for more information
@@ -129,34 +182,44 @@
* <p>
* @return description of this service.
*/
- public ServiceInfo getInfo(){
- synchronized ( capabilities ){
- if( info == null ){
+ public ServiceInfo getInfo()
+ {
+ synchronized (capabilities)
+ {
+ if (info == null)
+ {
info = createInfo();
}
+
return info;
- }
+ }
}
+
/**
* Implemented by a subclass to describe service
* @return ServiceInfo
*/
protected abstract ServiceInfo createInfo();
- public ResourceInfo getInfo( R resource ){
- synchronized ( capabilities ){
- if( !resourceInfo.containsKey( resource ) ){
- resourceInfo.put( resource, createInfo( resource ) );
+ public ResourceInfo getInfo(R resource)
+ {
+ synchronized (capabilities)
+ {
+ if (!resourceInfo.containsKey(resource))
+ {
+ resourceInfo.put(resource, createInfo(resource));
}
}
- return resourceInfo.get( resource );
+
+ return resourceInfo.get(resource);
}
-
- protected abstract ResourceInfo createInfo(R resource );
-
- private void syncrhonized( Capabilities capabilities2 ) {
- // TODO Auto-generated method stub
+ protected abstract ResourceInfo createInfo(R resource);
+
+
+ private void syncrhonized(Capabilities capabilities2)
+ {
+ // TODO Auto-generated method stub
}
/**
@@ -183,26 +246,28 @@
* </ul>
* </p>
* <p>
- * The OGC tells us to repeat this process (or give up). This means we are
- * actually going to come up with a bit of setup cost in figuring out our
+ * The OGC tells us to repeat this process (or give up). This means we are
+ * actually going to come up with a bit of setup cost in figuring out our
* GetCapabilities request. This means that it is possible that we may make
- * multiple requests before being satisfied with a response.
- *
- * Also, if we are unable to parse a given version for some reason,
+ * multiple requests before being satisfied with a response.
+ *
+ * Also, if we are unable to parse a given version for some reason,
* for example, malformed XML, we will request a lower version until
* we have run out of versions to request with. Thus, a server that does
- * not play nicely may take some time to parse and might not even
+ * not play nicely may take some time to parse and might not even
* succeed.
- *
+ *
* @return a capabilities object that represents the Capabilities on the server
* @throws IOException if there is an error communicating with the server, or the XML cannot be parsed
* @throws ServiceException if the server returns a ServiceException
*/
- protected C negotiateVersion() throws IOException, ServiceException {
+ protected C negotiateVersion() throws IOException, ServiceException
+ {
List versions = new ArrayList(specs.length);
Exception exception = null;
- for( int i = 0; i < specs.length; i++ ) {
+ for (int i = 0; i < specs.length; i++)
+ {
versions.add(i, specs[i].getVersion());
}
@@ -211,80 +276,101 @@
int test = maxClient;
- while( (minClient <= test) && (test <= maxClient) ) {
+ while ((minClient <= test) && (test <= maxClient))
+ {
Specification tempSpecification = specs[test];
String clientVersion = tempSpecification.getVersion();
GetCapabilitiesRequest request = tempSpecification.createGetCapabilitiesRequest(serverURL);
- //Grab document
+ // Grab document
C tempCapabilities;
- try {
+ try
+ {
tempCapabilities = (C) issueRequest(request).getCapabilities();
- } catch (ServiceException e) {
- tempCapabilities = null;
- exception = e;
}
+ catch (ServiceException e)
+ {
+ tempCapabilities = null;
+ exception = e;
+ }
int compare = -1;
- String serverVersion = clientVersion; //Ignored if caps is null
+ String serverVersion = clientVersion; // Ignored if caps is null
- if (tempCapabilities != null) {
+ if (tempCapabilities != null)
+ {
serverVersion = tempCapabilities.getVersion();
compare = serverVersion.compareTo(clientVersion);
}
- if (compare == 0) {
- //we have an exact match and have capabilities as well!
+ if (compare == 0)
+ {
+ // we have an exact match and have capabilities as well!
this.specification = tempSpecification;
return tempCapabilities;
}
- if (tempCapabilities != null && versions.contains(serverVersion)) {
+ if ((tempCapabilities != null) && versions.contains(serverVersion))
+ {
// we can communicate with this server
int index = versions.indexOf(serverVersion);
this.specification = specs[index];
return tempCapabilities;
- } else if (compare < 0) {
+ }
+ else if (compare < 0)
+ {
// server responded lower then we asked - and we don't understand.
maxClient = test - 1; // set current version as limit
// lets try and go one lower?
- //
+ //
clientVersion = before(versions, serverVersion);
- if (clientVersion == null) {
- if (exception != null) {
- if (exception instanceof ServiceException) {
- throw (ServiceException) exception;
- }
+ if (clientVersion == null)
+ {
+ if (exception != null)
+ {
+ if (exception instanceof ServiceException)
+ {
+ throw (ServiceException) exception;
+ }
+
IOException e = new IOException(exception.getMessage());
throw e;
}
+
return null; // do not know any lower version numbers
}
test = versions.indexOf(clientVersion);
- } else {
+ }
+ else
+ {
// server responsed higher than we asked - and we don't understand
minClient = test + 1; // set current version as lower limit
// lets try and go one higher
clientVersion = after(versions, serverVersion);
- if (clientVersion == null) {
- if (exception != null) {
- if (exception instanceof ServiceException) {
- throw (ServiceException) exception;
- }
+ if (clientVersion == null)
+ {
+ if (exception != null)
+ {
+ if (exception instanceof ServiceException)
+ {
+ throw (ServiceException) exception;
+ }
+
IOException e = new IOException(exception.getMessage());
throw e;
}
+
return null; // do not know any lower version numbers
}
@@ -293,33 +379,40 @@
}
// could not talk to this server
- if (exception != null) {
+ if (exception != null)
+ {
IOException e = new IOException(exception.getMessage());
throw e;
}
+
return null;
}
/**
* Utility method returning the known version, just before the provided version
- *
+ *
* @param known List<String> of all known versions
* @param version the boundary condition
* @return the version just below the provided boundary version
*/
- String before( List known, String version ) {
- if (known.isEmpty()) {
+ String before(List known, String version)
+ {
+ if (known.isEmpty())
+ {
return null;
}
String before = null;
- for( Iterator i = known.iterator(); i.hasNext(); ) {
+ for (Iterator i = known.iterator(); i.hasNext();)
+ {
String test = (String) i.next();
- if (test.compareTo(version) < 0) {
+ if (test.compareTo(version) < 0)
+ {
- if ((before == null) || (before.compareTo(test) < 0)) {
+ if ((before == null) || (before.compareTo(test) < 0))
+ {
before = test;
}
}
@@ -330,23 +423,28 @@
/**
* Utility method returning the known version, just after the provided version
- *
+ *
* @param known a List<String> of all known versions
* @param version the boundary condition
* @return a version just after the provided boundary condition
*/
- String after( List known, String version ) {
- if (known.isEmpty()) {
+ String after(List known, String version)
+ {
+ if (known.isEmpty())
+ {
return null;
}
String after = null;
- for( Iterator i = known.iterator(); i.hasNext(); ) {
+ for (Iterator i = known.iterator(); i.hasNext();)
+ {
String test = (String) i.next();
- if (test.compareTo(version) > 0) {
- if ((after == null) || (after.compareTo(test) < 0)) {
+ if (test.compareTo(version) > 0)
+ {
+ if ((after == null) || (after.compareTo(test) < 0))
+ {
after = test;
}
}
@@ -358,68 +456,56 @@
/**
* Issues a request to the server and returns that server's response. It
* asks the server to send the response gzipped to provide a faster transfer
- * time.
- *
+ * time.
+ *
* @param request the request to be issued
* @return a response from the server, which is created according to the specific Request
* @throws IOException if there was a problem communicating with the server
* @throws ServiceException if the server responds with an exception or returns bad content
*/
- protected Response internalIssueRequest( Request request ) throws IOException, ServiceException {
- URL finalURL = request.getFinalURL();
+ protected Response internalIssueRequest(Request request) throws IOException, ServiceException
+ {
+ final URL finalURL = request.getFinalURL();
- HttpURLConnection connection = (HttpURLConnection) finalURL.openConnection();
-
- connection.addRequestProperty("Accept-Encoding", "gzip");
-
- if (request.requiresPost()) {
- connection.setRequestMethod("POST");
- connection.setDoOutput(true);
- connection.setRequestProperty("Content-type", request.getPostContentType());
+ final HTTPResponse httpResponse;
- OutputStream outputStream = connection.getOutputStream();
+ if (request.requiresPost())
+ {
- if (LOGGER.isLoggable(Level.FINE)) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- request.performPostOutput(out);
-
- InputStream in = new ByteArrayInputStream(out.toByteArray());
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ final String postContentType = request.getPostContentType();
- PrintStream stream = new PrintStream(outputStream);
-
- StringBuffer postText = new StringBuffer();
-
- while (reader.ready()) {
- String input = reader.readLine();
- postText = postText.append(input);
- stream.println(input);
- }
- LOGGER.fine(postText.toString());
- //System.out.println(postText);
-
- stream.close();
- out.close();
- in.close();
- } else {
- request.performPostOutput(outputStream);
- }
-
- outputStream.flush();
- outputStream.close();
- } else {
- connection.setRequestMethod("GET");
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ request.performPostOutput(out);
+
+ InputStream in = new ByteArrayInputStream(out.toByteArray());
+
+ try
+ {
+ httpResponse = httpClient.post(finalURL, in, postContentType);
+ }
+ finally
+ {
+ in.close();
+ }
}
-
- HTTPResponse httpResponse = new SimpleHttpClient.SimpleHTTPResponse(connection);
- return request.createResponse(httpResponse);
+ else
+ {
+ httpResponse = httpClient.get(finalURL);
+ }
+
+ final Response response = request.createResponse(httpResponse);
+
+ return response;
}
-
- public AbstractWPSGetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request) throws IOException, ServiceException {
- return (AbstractWPSGetCapabilitiesResponse) internalIssueRequest(request);
+
+ public AbstractWPSGetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request) throws IOException,
+ ServiceException
+ {
+ return (AbstractWPSGetCapabilitiesResponse) internalIssueRequest(request);
}
-
- public void setLoggingLevel(Level newLevel) {
- LOGGER.setLevel(newLevel);
+
+ public void setLoggingLevel(Level newLevel)
+ {
+ LOGGER.setLevel(newLevel);
}
}
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPSGetCapabilitiesResponse.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPSGetCapabilitiesResponse.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/AbstractWPSGetCapabilitiesResponse.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -3,7 +3,7 @@
* http://geotools.org
*
* (C) 2004-2008, Open Source Geospatial Foundation (OSGeo)
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
@@ -23,10 +23,11 @@
import org.geotools.ows.ServiceException;
+
/**
* Base class for WPS GetCapabilities responses. They should typically attempt to
- * parse the Capabilities document in inputStream in the constructor.
- *
+ * parse the Capabilities document in inputStream in the constructor.
+ *
* @author gdavis
*
*
@@ -34,23 +35,27 @@
*
* @source $URL$
*/
-public abstract class AbstractWPSGetCapabilitiesResponse extends Response {
+public abstract class AbstractWPSGetCapabilitiesResponse extends Response
+{
- protected WPSCapabilitiesType capabilities;
- protected ExceptionReportType excepResponse;
+ protected WPSCapabilitiesType capabilities;
+ protected ExceptionReportType excepResponse;
- public AbstractWPSGetCapabilitiesResponse(HTTPResponse response) throws ServiceException, IOException {
- super(response);
- }
-
- /**
- * Returns the capabilities object parsed during the response
- */
- public WPSCapabilitiesType getCapabilities() {
- return capabilities;
- }
-
- public ExceptionReportType getExceptionResponse() {
+ public AbstractWPSGetCapabilitiesResponse(HTTPResponse httpResponse) throws ServiceException, IOException
+ {
+ super(httpResponse);
+ }
+
+ /**
+ * Returns the capabilities object parsed during the response
+ */
+ public WPSCapabilitiesType getCapabilities()
+ {
+ return capabilities;
+ }
+
+ public ExceptionReportType getExceptionResponse()
+ {
return excepResponse;
- }
+ }
}
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/ProcessDescription.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/ProcessDescription.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/ProcessDescription.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -3,7 +3,7 @@
* http://geotools.org
*
* (C) 2004-2008, Open Source Geospatial Foundation (OSGeo)
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/package-info.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/package-info.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/ows/package-info.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -16,9 +16,9 @@
*/
/**
* package to build WPS requests.
- *
- * This portion of the program was contributed by Sejong University and funded
- * by Seoul R&BD 10540. Any official publishing of the produced result is
+ *
+ * This portion of the program was contributed by Sejong University and funded
+ * by Seoul R&BD 10540. Any official publishing of the produced result is
* requested to retain the aforementioned acknowledgment.
*/
package org.geotools.data.ows;
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPS1_0_0.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPS1_0_0.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPS1_0_0.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -3,7 +3,7 @@
* http://geotools.org
*
* (C) 2004-2008, Open Source Geospatial Foundation (OSGeo)
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
@@ -17,29 +17,46 @@
package org.geotools.data.wps;
import java.io.IOException;
+import java.math.BigInteger;
import java.net.URL;
+import java.util.List;
import java.util.Properties;
+import net.opengis.ows11.BoundingBoxType;
+import net.opengis.ows11.CodeType;
+import net.opengis.ows11.Ows11Factory;
+import net.opengis.wps10.DataType;
+import net.opengis.wps10.DocumentOutputDefinitionType;
+import net.opengis.wps10.LiteralDataType;
+import net.opengis.wps10.OutputDefinitionType;
+import net.opengis.wps10.ResponseDocumentType;
+import net.opengis.wps10.ResponseFormType;
+import net.opengis.wps10.Wps10Factory;
+
import org.geotools.data.ows.AbstractGetCapabilitiesRequest;
import org.geotools.data.ows.GetCapabilitiesRequest;
import org.geotools.data.ows.HTTPResponse;
import org.geotools.data.ows.Response;
import org.geotools.data.wps.request.AbstractDescribeProcessRequest;
import org.geotools.data.wps.request.AbstractExecuteProcessRequest;
+import org.geotools.data.wps.request.AbstractGetExecutionStatusRequest;
import org.geotools.data.wps.request.DescribeProcessRequest;
import org.geotools.data.wps.request.ExecuteProcessRequest;
+import org.geotools.data.wps.request.GetExecutionStatusRequest;
import org.geotools.data.wps.response.DescribeProcessResponse;
import org.geotools.data.wps.response.ExecuteProcessResponse;
+import org.geotools.data.wps.response.GetExecutionStatusResponse;
import org.geotools.data.wps.response.WPSGetCapabilitiesResponse;
import org.geotools.ows.ServiceException;
+
/**
* Provides support for the Web Processing Service 1.0.0 Specification.
* <p>
- * WPS1_0_0 provides both name and version information that may be checked against
+ * WPS1_0_0 provides both name and version information that may be checked against
* a GetCapabilities document during version negotiation.
* </p>
- *
+ *
* @author gdavis
*
*
@@ -47,121 +64,254 @@
*
* @source $URL$
*/
-public class WPS1_0_0 extends WPSSpecification {
+public class WPS1_0_0 extends WPSSpecification
+{
+ private static final Wps10Factory wpsFactory = Wps10Factory.eINSTANCE;
+
+ private static String processKey(String key)
+ {
+ return key.trim().toLowerCase();
+ }
+
/**
* Public constructor creates the WMS1_0_0 object.
*/
- public WPS1_0_0() {
+ public WPS1_0_0()
+ {
}
/**
* Expected version attribute for root element.
- *
+ *
* @return the expect version value for this specification
*/
- public String getVersion() {
- return "1.0.0"; //$NON-NLS-1$
+ public String getVersion()
+ {
+ return "1.0.0"; // $NON-NLS-1$
}
-
+
/**
* Create a request for performing GetCapabilities requests on a 1.0.0 server.
- *
+ *
* @see org.geotools.data.wps.WPSSpecification#createGetCapabilitiesRequest(java.net.URL)
* @param server a URL that points to the 1.0.0 server
* @return a AbstractGetCapabilitiesRequest object that can provide a valid request
*/
- public GetCapabilitiesRequest createGetCapabilitiesRequest( URL server ) {
+ public GetCapabilitiesRequest createGetCapabilitiesRequest(URL server)
+ {
return new GetCapsRequest(server);
}
-
- private static String processKey(String key) {
- return key.trim().toLowerCase();
+
+ @Override
+ public DescribeProcessRequest createDescribeProcessRequest(
+ URL onlineResource) throws UnsupportedOperationException
+ {
+ return new InternalDescribeProcessRequest(onlineResource, null);
}
+ @Override
+ public ExecuteProcessRequest createExecuteProcessRequest(URL onlineResource) throws UnsupportedOperationException
+ {
+ return new InternalExecuteProcessRequest(onlineResource, null);
+ }
+
+ @Override
+ public GetExecutionStatusRequest createGetExecutionStatusRequest(URL onlineResource)
+ throws UnsupportedOperationException
+ {
+ return new InternalGetExecutionStatusRequest(onlineResource, null);
+ }
+
+ @Override
+ public DataType createLiteralInputValue(String literalValue)
+ {
+ DataType literalInputValue = wpsFactory.createDataType();
+ LiteralDataType literalDataType = wpsFactory.createLiteralDataType();
+ literalDataType.setValue(literalValue);
+ literalInputValue.setLiteralData(literalDataType);
+
+ return literalInputValue;
+ }
+
+ @Override
+ public DataType createBoundingBoxInputValue(String crs, int dimensions, List<Double> lowerCorner,
+ List<Double> upperCorner)
+ {
+ DataType bbox = wpsFactory.createDataType();
+ BoundingBoxType bboxType = Ows11Factory.eINSTANCE.createBoundingBoxType();
+ bboxType.setCrs(crs);
+ bboxType.setDimensions(BigInteger.valueOf(dimensions));
+ bboxType.setLowerCorner(lowerCorner);
+ bboxType.setUpperCorner(upperCorner);
+ bbox.setBoundingBoxData(bboxType);
+
+ return bbox;
+ }
+
+ @Override
+ public ResponseFormType createResponseForm(ResponseDocumentType responseDoc,
+ OutputDefinitionType rawOutput)
+ {
+ ResponseFormType responseForm = wpsFactory.createResponseFormType();
+
+ if (responseDoc != null)
+ {
+ responseForm.setResponseDocument(responseDoc);
+ }
+
+ if (rawOutput != null)
+ {
+ responseForm.setRawDataOutput(rawOutput);
+ }
+
+ return responseForm;
+ }
+
+ @Override
+ public OutputDefinitionType createOutputDefinitionType(String identifier)
+ {
+ CodeType inputType = Ows11Factory.eINSTANCE.createCodeType();
+ inputType.setValue(identifier);
+
+ OutputDefinitionType rawOutput = wpsFactory.createOutputDefinitionType();
+ rawOutput.setIdentifier(inputType);
+
+ return rawOutput;
+ }
+
+ @Override
+ public ResponseDocumentType createResponseDocumentType(boolean lineage, boolean status,
+ boolean storeExecuteResponse, String outputType)
+ {
+ ResponseDocumentType responseDoc = wpsFactory.createResponseDocumentType();
+ responseDoc.setLineage(lineage);
+ responseDoc.setStatus(status);
+ responseDoc.setStoreExecuteResponse(storeExecuteResponse);
+
+ if (outputType != null)
+ {
+ DocumentOutputDefinitionType output = wpsFactory.createDocumentOutputDefinitionType();
+ CodeType inputType = Ows11Factory.eINSTANCE.createCodeType();
+ inputType.setValue(outputType);
+ output.setIdentifier(inputType);
+ responseDoc.getOutput().add(output);
+ }
+
+ return responseDoc;
+ }
+
/**
* We need a custom request object.
*/
- static public class GetCapsRequest extends AbstractGetCapabilitiesRequest {
+ public static class GetCapsRequest extends AbstractGetCapabilitiesRequest
+ {
+
/**
* Construct a Request compatible with a 1.0.0 Web Process Server.
- *
+ *
* @param urlGetCapabilities URL of GetCapabilities document.
*/
- public GetCapsRequest( URL urlGetCapabilities ) {
+ public GetCapsRequest(URL urlGetCapabilities)
+ {
super(urlGetCapabilities);
}
- protected void initVersion() {
- properties.setProperty(VERSION, "1.0.0");
+ protected void initVersion()
+ {
+ properties.setProperty(VERSION, "1.0.0");
}
- protected void initRequest() {
+ protected void initRequest()
+ {
setProperty("REQUEST", "getCapabilities");
}
- protected void initService() {
- //The 1.0.0 specification does not use the service property
+ protected void initService()
+ {
+ // The 1.0.0 specification does not use the service property
}
- protected String processKey( String key ) {
+ protected String processKey(String key)
+ {
return WPS1_0_0.processKey(key);
}
-
- public Response createResponse(HTTPResponse response) throws ServiceException, IOException {
- return new WPSGetCapabilitiesResponse(response);
- }
+
+ public Response createResponse(HTTPResponse httpResponse) throws ServiceException, IOException
+ {
+ return new WPSGetCapabilitiesResponse(httpResponse);
+ }
}
- @Override
- public DescribeProcessRequest createDescribeProcessRequest(
- URL onlineResource) throws UnsupportedOperationException {
- return new InternalDescribeProcessRequest(onlineResource, null);
- }
-
- public static class InternalDescribeProcessRequest extends AbstractDescribeProcessRequest {
+ public static class InternalDescribeProcessRequest extends AbstractDescribeProcessRequest
+ {
/**
* @param onlineResource
* @param properties
*/
- public InternalDescribeProcessRequest( URL onlineResource, Properties properties ) {
+ public InternalDescribeProcessRequest(URL onlineResource, Properties properties)
+ {
super(onlineResource, properties);
}
- protected void initVersion() {
+ protected void initVersion()
+ {
setProperty(VERSION, "1.0.0");
}
-
- public Response createResponse(HTTPResponse response) throws ServiceException, IOException {
- return new DescribeProcessResponse(response);
- }
- }
- @Override
- public ExecuteProcessRequest createExecuteProcessRequest(URL onlineResource)
- throws UnsupportedOperationException {
- return new InternalExecuteProcessRequest(onlineResource, null);
- }
-
- public static class InternalExecuteProcessRequest extends AbstractExecuteProcessRequest {
-
+ public Response createResponse(HTTPResponse httpResponse) throws ServiceException, IOException
+ {
+ return new DescribeProcessResponse(httpResponse);
+ }
+ }
+
+ public static class InternalExecuteProcessRequest extends AbstractExecuteProcessRequest
+ {
+
/**
* @param onlineResource
* @param properties
*/
- public InternalExecuteProcessRequest( URL onlineResource, Properties properties ) {
+ public InternalExecuteProcessRequest(URL onlineResource, Properties properties)
+ {
super(onlineResource, properties);
}
- protected void initVersion() {
+ protected void initVersion()
+ {
setProperty(VERSION, "1.0.0");
}
-
- public Response createResponse(HTTPResponse response) throws ServiceException, IOException {
- return new ExecuteProcessResponse(response);
- }
-
- }
+
+ public Response createResponse(HTTPResponse httpResponse) throws ServiceException, IOException
+ {
+ return new ExecuteProcessResponse(httpResponse);
+ }
+
+ }
+
+ public static class InternalGetExecutionStatusRequest extends AbstractGetExecutionStatusRequest
+ {
+
+ /**
+ * @param onlineResource
+ * @param properties
+ */
+ public InternalGetExecutionStatusRequest(URL onlineResource, Properties properties)
+ {
+ super(onlineResource, properties);
+ }
+
+ protected void initVersion()
+ {
+ setProperty(VERSION, "1.0.0");
+ }
+
+ public Response createResponse(HTTPResponse httpResponse) throws ServiceException, IOException
+ {
+ return new GetExecutionStatusResponse(httpResponse);
+ }
+ }
+
}
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSFactory.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSFactory.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSFactory.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -3,7 +3,7 @@
* http://geotools.org
*
* (C) 2004-2008, Open Source Geospatial Foundation (OSGeo)
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
@@ -30,22 +30,24 @@
import org.geotools.text.Text;
import org.opengis.util.InternationalString;
+
/**
* This class acts as a ProcessFactory for any process. It handles converting related bean
* structures into a ProcessFactory object, and can be created from a describeprocess response and
* can be passed around as a process encompassing object for ease of use. This factory can make a
* representation of a process and its "execute" method will actually build a request to the server
* to execute the process and return the results.
- *
+ *
* @author GDavis
- *
*
*
*
*
+ *
* @source $URL$
*/
-public class WPSFactory extends SingleProcessFactory {
+public class WPSFactory extends SingleProcessFactory
+{
private ProcessDescriptionType pdt;
@@ -63,7 +65,8 @@
private Map<String, Parameter<?>> resultInfo = new TreeMap<String, Parameter<?>>();
- public WPSFactory(ProcessDescriptionType pdt, URL serverUrl) {
+ public WPSFactory(ProcessDescriptionType pdt, URL serverUrl)
+ {
this.pdt = pdt;
this.serverUrl = serverUrl;
buildValuesFromProcessDescriptionType();
@@ -71,14 +74,15 @@
/**
* Go through the ProcessDescriptionType object tree and set this flactory's values based on it.
- *
+ *
* @param pdt
*/
- private void buildValuesFromProcessDescriptionType() {
+ private void buildValuesFromProcessDescriptionType()
+ {
this.version = this.pdt.getProcessVersion();
this.title = this.pdt.getTitle().getValue();
this.identifier = this.pdt.getIdentifier().getValue();
- this.description = WPSUtils.isAbstractNull(this.pdt) ? "" : this.pdt.getAbstract().getValue();
+ this.description = WPSUtils.isAbstractNull(this.pdt) ? "" : this.pdt.getAbstract().getValue();
this.parameterInfo = WPSUtils.createInputParamMap(this.pdt, this.parameterInfo);
this.resultInfo = WPSUtils.createOutputParamMap(this.pdt, this.resultInfo);
}
@@ -86,45 +90,54 @@
/**
* Create a representation of a process
*/
- public Process create() {
+ public Process create()
+ {
return new WPSProcess(this);
}
- public InternationalString getDescription() {
+ public InternationalString getDescription()
+ {
return Text.text(description);
}
- public Map<String, Parameter<?>> getParameterInfo() {
+ public Map<String, Parameter<?>> getParameterInfo()
+ {
return Collections.unmodifiableMap(parameterInfo);
}
- public Map<String, Parameter<?>> getResultInfo(Map<String, Object> parameters)
- throws IllegalArgumentException {
+ public Map<String, Parameter<?>> getResultInfo(Map<String, Object> parameters) throws IllegalArgumentException
+ {
return Collections.unmodifiableMap(resultInfo);
}
- public InternationalString getTitle() {
+ public InternationalString getTitle()
+ {
return Text.text(title);
}
- public String getIdentifier() {
+ public String getIdentifier()
+ {
return identifier;
}
- public String getVersion() {
+ public String getVersion()
+ {
return version;
}
- public boolean supportsProgress() {
+ public boolean supportsProgress()
+ {
// unknown, so return false
return false;
}
- public ProcessDescriptionType getProcessDescriptionType() {
+ public ProcessDescriptionType getProcessDescriptionType()
+ {
return this.pdt;
}
- public URL getServerURL() {
+ public URL getServerURL()
+ {
return this.serverUrl;
}
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSProcess.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSProcess.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSProcess.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -94,35 +94,33 @@
// loop through each expected input in the describeprocess, and set it
// based on what we have in the provided input map.
- if (pdt.getDataInputs()!=null){
- EList inputs = pdt.getDataInputs().getInput();
- Iterator iterator = inputs.iterator();
- while (iterator.hasNext()) {
- InputDescriptionType idt = (InputDescriptionType) iterator.next();
- String identifier = idt.getIdentifier().getValue();
- Object inputValue = input.get(identifier);
- if (inputValue != null) {
- // if our value is some sort of collection, then created multiple
- // dataTypes for this inputdescriptiontype.
- List<DataType> list = new ArrayList<DataType>();
- if (inputValue instanceof Map) {
- for (Object inVal : ((Map)inputValue).values()) {
- DataType createdInput = WPSUtils.createInputDataType(inVal, idt);
- list.add(createdInput);
- }
- } else if (inputValue instanceof Collection) {
- for (Object inVal : (Collection)inputValue) {
- DataType createdInput = WPSUtils.createInputDataType(inVal, idt);
- list.add(createdInput);
- }
- } else {
- // our value is a single object so create a single datatype for it
- DataType createdInput = WPSUtils.createInputDataType(inputValue, idt);
+ EList inputs = pdt.getDataInputs().getInput();
+ Iterator iterator = inputs.iterator();
+ while (iterator.hasNext()) {
+ InputDescriptionType idt = (InputDescriptionType) iterator.next();
+ String identifier = idt.getIdentifier().getValue();
+ Object inputValue = input.get(identifier);
+ if (inputValue != null) {
+ // if our value is some sort of collection, then created multiple
+ // dataTypes for this inputdescriptiontype.
+ List<DataType> list = new ArrayList<DataType>();
+ if (inputValue instanceof Map) {
+ for (Object inVal : ((Map)inputValue).values()) {
+ DataType createdInput = WPSUtils.createInputDataType(inVal, idt);
list.add(createdInput);
}
- // add the input to the execute request
- exeRequest.addInput(identifier, list);
+ } else if (inputValue instanceof Collection) {
+ for (Object inVal : (Collection)inputValue) {
+ DataType createdInput = WPSUtils.createInputDataType(inVal, idt);
+ list.add(createdInput);
+ }
+ } else {
+ // our value is a single object so create a single datatype for it
+ DataType createdInput = WPSUtils.createInputDataType(inputValue, idt);
+ list.add(createdInput);
}
+ // add the input to the execute request
+ exeRequest.addInput(identifier, list);
}
}
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSSpecification.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSSpecification.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSSpecification.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -3,7 +3,7 @@
* http://geotools.org
*
* (C) 2004-2008, Open Source Geospatial Foundation (OSGeo)
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
@@ -17,37 +17,63 @@
package org.geotools.data.wps;
import java.net.URL;
+import java.util.List;
+import net.opengis.wps10.DataType;
+import net.opengis.wps10.OutputDefinitionType;
+import net.opengis.wps10.ResponseDocumentType;
+import net.opengis.wps10.ResponseFormType;
+
import org.geotools.data.ows.Specification;
import org.geotools.data.wps.request.DescribeProcessRequest;
import org.geotools.data.wps.request.ExecuteProcessRequest;
+import org.geotools.data.wps.request.GetExecutionStatusRequest;
/**
- *
*
+ *
* @source $URL$
*/
-public abstract class WPSSpecification extends Specification {
+public abstract class WPSSpecification extends Specification
+{
/**
* Creates a DescribeProcess request which can be used to retrieve
* information about a specific process on the WPS Server.
- *
+ *
* @param onlineResource the location where the request can be made
* @return a DescribeProcessRequest to be configured and then passed to the WPS Server
* @throws UnsupportedOperationException if the version of the specification doesn't support this request
*/
- public abstract DescribeProcessRequest createDescribeProcessRequest( URL onlineResource ) throws UnsupportedOperationException;
+ public abstract DescribeProcessRequest createDescribeProcessRequest(URL onlineResource)
+ throws UnsupportedOperationException;
/**
* Creates a Execute request which can be used to execute
* a specific process on the WPS Server.
- *
+ *
* @param onlineResource the location where the request can be made
* @return an ExecuteProcessRequest to be configured and then passed to the WPS Server
* @throws UnsupportedOperationException if the version of the specification doesn't support this request
*/
- public abstract ExecuteProcessRequest createExecuteProcessRequest( URL onlineResource ) throws UnsupportedOperationException;
-
- }
+ public abstract ExecuteProcessRequest createExecuteProcessRequest(URL onlineResource)
+ throws UnsupportedOperationException;
+
+ public abstract GetExecutionStatusRequest createGetExecutionStatusRequest(URL onlineResource)
+ throws UnsupportedOperationException;
+
+ public abstract DataType createLiteralInputValue(String literalValue);
+
+ public abstract DataType createBoundingBoxInputValue(String crs, int dimensions, List<Double> lowerCorner,
+ List<Double> upperCorner);
+
+ public abstract ResponseFormType createResponseForm(ResponseDocumentType responseDoc,
+ OutputDefinitionType rawOutput);
+
+ public abstract ResponseDocumentType createResponseDocumentType(boolean lineage, boolean status,
+ boolean storeExecuteResponse, String outputType);
+
+ public abstract OutputDefinitionType createOutputDefinitionType(String identifier);
+
+}
Modified: trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSUtils.java
===================================================================
--- trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSUtils.java 2011-12-29 14:27:14 UTC (rev 38454)
+++ trunk/modules/unsupported/wps/src/main/java/org/geotools/data/wps/WPSUtils.java 2012-01-04 11:40:08 UTC (rev 38455)
@@ -22,6 +22,8 @@
import java.util.Map;
import java.util.TreeMap;
+import com.vividsolutions.jts.geom.Geometry;
+
import net.opengis.wps10.ComplexDataCombinationsType;
import net.opengis.wps10.ComplexDataDescriptionType;
import net.opengis.wps10.ComplexDataType;
@@ -47,11 +49,10 @@
import org.geotools.util.Converters;
import org.opengis.util.InternationalString;
-import com.vividsolutions.jts.geom.Geometry;
/**
* Contains helpful static util methods for the WPS module
- *
+ *
* @author gdavis
*
*
@@ -59,7 +60,8 @@
*
* @source $URL$
*/
-public class WPSUtils {
+public class WPSUtils
+{
/**
* static ints representing the input types
@@ -71,31 +73,40 @@
/**
* Creates a DataType input object from the given object and InputDescriptionType (from a
* describeprocess) and decides if the input is a literal or complex data based on its type.
- *
+ *
* @param obj
* the base input object
* @param idt
* input description type defining the input
* @return the created DataType input object
*/
- public static DataType createInputDataType(Object obj, InputDescriptionType idt) {
+ public static DataType createInputDataType(Object obj, InputDescriptionType idt)
+ {
int inputtype = 0;
// first try to figure out if the input is a literal or complex based
// on the data in the idt
LiteralInputType literalData = idt.getLiteralData();
SupportedComplexDataInputType complexData = idt.getComplexData();
- if (literalData != null) {
+ if (literalData != null)
+ {
inputtype = INPUTTYPE_LITERAL;
- } else if (complexData != null) {
+ }
+ else if (complexData != null)
+ {
inputtype = INPUTTYPE_COMPLEXDATA;
- } else {
+ }
+ else
+ {
// is the value a literal? Do a very basic test here for common
// literal types. TODO: figure out a more thorough test here
- if (obj instanceof String || obj instanceof Double || obj instanceof Float
- || obj instanceof Integer) {
+ if ((obj instanceof String) || (obj instanceof Double) || (obj instanceof Float) ||
+ (obj instanceof Integer))
+ {
inputtype = INPUTTYPE_LITERAL;
- } else {
+ }
+ else
+ {
// assume complex data
inputtype = INPUTTYPE_COMPLEXDATA;
}
@@ -103,10 +114,10 @@
// now create the input based on its type
String schema = null;
- if (inputtype == INPUTTYPE_COMPLEXDATA) {
+ if (inputtype == INPUTTYPE_COMPLEXDATA)
+ {
ComplexDataCombinationsType supported = complexData.getSupported();
- ComplexDataDescriptionType cddt = (ComplexDataDescriptionType) supported.getFormat()
- .get(0);
+ ComplexDataDescriptionType cddt = (ComplexDataDescriptionType) supported.getFormat().get(0);
schema = cddt.getSchema();
}
@@ -115,7 +126,7 @@
/**
* Creates a DataType input object from the given object, schema and type (complex or literal).
- *
+ *
* @param obj
* the base input object
* @param type
@@ -124,15 +135,19 @@
* only used for type complexdata
* @return the created DataType input object
*/
- public static DataType createInputDataType(Object obj, int type, String schema) {
+ public static DataType createInputDataType(Object obj, int type, String schema)
+ {
DataType dt = Wps10Factory.eINSTANCE.createDataType();
- if (type == INPUTTYPE_LITERAL) {
+ if (type == INPUTTYPE_LITERAL)
+ {
LiteralDataType ldt = Wps10Factory.eINSTANCE.createLiteralDataType();
ldt.setValue(obj.toString());
dt.setLiteralData(ldt);
- } else {
+ }
+ else
+ {
// assume complex data
ComplexDataType cdt = Wps10Factory.eINSTANCE.createComplexDataType();
@@ -142,47 +157,61 @@
// cdt.getMixed().add(obj);
cdt.getData().add(obj);
- if (schema != null) {
+ if (schema != null)
+ {
cdt.setSchema(schema);
}
dt.setComplexData(cdt);
}
+
return dt;
}
/**
* Create a map of <String name, Parameter> inputs for a process based on its describeProcess.
- *
+ *
* @param processDesc
* @param map
* add the inputs to the given map (create it if null)
* @return map of name,Parameter representing the input params for this process
*/
public static Map<String, Parameter<?>> createInputParamMap(ProcessDescriptionType processDesc,
- Map<String, Parameter<?>> map) {
- if (map == null) {
+ Map<String, Parameter<?>> map)
+ {
+ if (map == null)
+ {
map = new TreeMap<String, Parameter<?>>();
}
// loop through the process desc and setup each input param
DataInputsType dataInputs = processDesc.getDataInputs();
if (dataInputs == null)
+ {
return null;
+ }
+
EList inputs = dataInputs.getInput();
- if (inputs == null || inputs.isEmpty())
+ if ((inputs == null) || inputs.isEmpty())
+ {
return null;
+ }
+
Iterator iterator = inputs.iterator();
- while (iterator.hasNext()) {
+ while (iterator.hasNext())
+ {
InputDescriptionType idt = (InputDescriptionType) iterator.next();
// determine if the input is a literal or complex data, and from that
// find out what type the object should be
LiteralInputType literalData = idt.getLiteralData();
SupportedComplexDataInputType complexData = idt.getComplexData();
Class type = Object.class;
- if (literalData != null) {
+ if (literalData != null)
+ {
String reference = literalData.getDataType().getReference();
type = getLiteralTypeFromReference(reference);
- } else if (complexData != null) {
+ }
+ else if (complexData != null)
+ {
// TODO: get all supported types and determine how to handle that, not just the
// default.
ComplexDataDescriptionType format = complexData.getDefault().getFormat();
@@ -190,25 +219,31 @@
String mimetype = format.getMimeType();
String schema = format.getSchema();
if (encoding == null)
+ {
encoding = "";
+ }
if ...
[truncated message content] |