Cache of DescribeProcess responses on the client.
This commit is contained in:
@@ -18,8 +18,9 @@ OpenLayers.WPSClient = OpenLayers.Class({
|
||||
*
|
||||
* Properties:
|
||||
* url - {String} the url of the server
|
||||
* knownProcesses: {Object} Cache of DescribeProcess responses, keyed by
|
||||
* process identifier.
|
||||
* version - {String} WPS version of the server
|
||||
* describeProcessResponse - {Object} Cache of DescribeProcess responses,
|
||||
* keyed by process identifier.
|
||||
*/
|
||||
servers: null,
|
||||
|
||||
@@ -61,7 +62,8 @@ OpenLayers.WPSClient = OpenLayers.Class({
|
||||
for (var s in options.servers) {
|
||||
this.servers[s] = typeof options.servers[s] == 'string' ? {
|
||||
url: options.servers[s],
|
||||
version: '1.0.0'
|
||||
version: '1.0.0',
|
||||
describeProcessResponse: {}
|
||||
} : options.servers[s];
|
||||
}
|
||||
},
|
||||
|
||||
@@ -84,15 +84,23 @@ OpenLayers.WPSProcess = OpenLayers.Class({
|
||||
/**
|
||||
* Method: describe
|
||||
* Issues a DescribeProcess request asynchronously and fires the
|
||||
* 'describeProcess' event as soon as the response is available in
|
||||
* 'describeprocess' event as soon as the response is available in
|
||||
* <description>.
|
||||
*/
|
||||
describe: function() {
|
||||
if (this._describePending || this.description) {
|
||||
var server = this.client.servers[this.server];
|
||||
if (this.description !== null) {
|
||||
return;
|
||||
} else if (server.describeProcessResponse[this.identifier] === null) {
|
||||
// pending request
|
||||
return;
|
||||
} else if (this.identifier in server.describeProcessResponse) {
|
||||
// process description already cached on client
|
||||
this.parseDescription();
|
||||
return;
|
||||
}
|
||||
this._describePending = true;
|
||||
var server = this.client.servers[this.server];
|
||||
// set to null so we know a describeFeature request is pending
|
||||
server.describeProcessResponse[this.identifier] = null;
|
||||
OpenLayers.Request.GET({
|
||||
url: server.url,
|
||||
params: {
|
||||
@@ -101,13 +109,7 @@ OpenLayers.WPSProcess = OpenLayers.Class({
|
||||
REQUEST: 'DescribeProcess',
|
||||
IDENTIFIER: this.identifier
|
||||
},
|
||||
success: function(response) {
|
||||
this.description = new OpenLayers.Format.WPSDescribeProcess()
|
||||
.read(response.responseText)
|
||||
.processDescriptions[this.identifier];
|
||||
delete this._describePending;
|
||||
this.events.triggerEvent('describeprocess');
|
||||
},
|
||||
success: this.parseDescription,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
@@ -165,6 +167,23 @@ OpenLayers.WPSProcess = OpenLayers.Class({
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: parseDescription
|
||||
*
|
||||
* Parameters:
|
||||
* response - {Object}
|
||||
*/
|
||||
parseDescription: function(response) {
|
||||
var server = this.client.servers[this.server];
|
||||
if (response) {
|
||||
server.describeProcessResponse[this.identifier] = response.responseText;
|
||||
}
|
||||
this.description = new OpenLayers.Format.WPSDescribeProcess()
|
||||
.read(server.describeProcessResponse[this.identifier])
|
||||
.processDescriptions[this.identifier];
|
||||
this.events.triggerEvent('describeprocess');
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setInputData
|
||||
* Sets the data for a single input
|
||||
|
||||
Reference in New Issue
Block a user