Changeset 301 for branches/branch-1.2/zoo-api/js
- Timestamp:
- Aug 5, 2011, 3:02:43 PM (13 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
branches/branch-1.2/zoo-api/js/ZOO-api.js
r217 r301 6067 6067 * needs to be interpreted. 6068 6068 */ 6069 Execute: function(inputs ) {6069 Execute: function(inputs,outputs) { 6070 6070 if (this.identifier == null) 6071 6071 return null; 6072 var body = new XML('<wps:Execute service="WPS" version="1.0.0" xmlns:wps="'+this.namespaces['wps']+'" xmlns:ows="'+this.namespaces['ows']+'" xmlns:xlink="'+this.namespaces['xlink']+'" xmlns:xsi="'+this.namespaces['xsi']+'" xsi:schemaLocation="'+this.schemaLocation+'"><ows:Identifier>'+this.identifier+'</ows:Identifier>'+this.buildDataInputsNode(inputs)+ '</wps:Execute>');6072 var body = new XML('<wps:Execute service="WPS" version="1.0.0" xmlns:wps="'+this.namespaces['wps']+'" xmlns:ows="'+this.namespaces['ows']+'" xmlns:xlink="'+this.namespaces['xlink']+'" xmlns:xsi="'+this.namespaces['xsi']+'" xsi:schemaLocation="'+this.schemaLocation+'"><ows:Identifier>'+this.identifier+'</ows:Identifier>'+this.buildDataInputsNode(inputs)+this.buildDataOutputsNode(outputs)+'</wps:Execute>'); 6073 6073 body = body.toXMLString(); 6074 6074 var response = ZOO.Request.Post(this.url,body,['Content-Type: text/xml; charset=UTF-8']); 6075 6075 return response; 6076 6076 }, 6077 /** 6078 * Property: buildInput 6079 * Object containing methods to build WPS inputs. 6080 */ 6081 buildInput: { 6082 /** 6083 * Method: buildInput.complex 6084 * Given an E4XElement representing the WPS complex data input. 6077 buildOutput:{ 6078 /** 6079 * Method: buildOutput.ResponseDocument 6080 * Given an E4XElement representing the WPS ResponseDocument output. 6085 6081 * 6086 6082 * Parameters: … … 6091 6087 * {E4XElement} A WPS Input node. 6092 6088 */ 6089 'ResponseDocument': function(identifier,obj) { 6090 var output = new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'"><wps:ResponseDocument><wps:Output'+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+(obj["asReference"]?' asReference="'+obj["asReference"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:Output></wps:ResponseDocument></wps:ResponseForm>'); 6091 if (obj.encoding) 6092 output.*::Data.*::ComplexData.@encoding = obj.encoding; 6093 if (obj.schema) 6094 output.*::Data.*::ComplexData.@schema = obj.schema; 6095 output = output.toXMLString(); 6096 return output; 6097 }, 6098 'RawDataOutput': function(identifier,obj) { 6099 var output = new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'"><wps:RawDataOutput><wps:Output '+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:Output></wps:RawDataOutput></wps:ResponseForm>'); 6100 if (obj.encoding) 6101 output.*::Data.*::ComplexData.@encoding = obj.encoding; 6102 if (obj.schema) 6103 output.*::Data.*::ComplexData.@schema = obj.schema; 6104 output = output.toXMLString(); 6105 return output; 6106 } 6107 6108 }, 6109 /** 6110 * Property: buildInput 6111 * Object containing methods to build WPS inputs. 6112 */ 6113 buildInput: { 6114 /** 6115 * Method: buildInput.complex 6116 * Given an E4XElement representing the WPS complex data input. 6117 * 6118 * Parameters: 6119 * identifier - {String} the input indetifier 6120 * data - {Object} A WPS complex data input. 6121 * 6122 * Returns: 6123 * {E4XElement} A WPS Input node. 6124 */ 6093 6125 'complex': function(identifier,data) { 6094 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:ComplexData> '+data.value+'</wps:ComplexData></wps:Data></wps:Input>');6095 input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : ' text/plain';6126 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:ComplexData><![CDATA['+data.value+']]></wps:ComplexData></wps:Data></wps:Input>'); 6127 input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6096 6128 if (data.encoding) 6097 6129 input.*::Data.*::ComplexData.@encoding = data.encoding; … … 6160 6192 return '<wps:DataInputs xmlns:wps="'+this.namespaces['wps']+'">'+inputsArray.join('\n')+'</wps:DataInputs>'; 6161 6193 }, 6194 6195 buildDataOutputsNode:function(outputs){ 6196 var data, builder, outputsArray=[]; 6197 for (var attr in outputs) { 6198 data = outputs[attr]; 6199 builder = this.buildOutput[data.type]; 6200 outputsArray.push(builder.apply(this,[attr,data])); 6201 } 6202 return outputsArray.join('\n'); 6203 }, 6204 6162 6205 CLASS_NAME: "ZOO.Process" 6163 6206 });
Note: See TracChangeset
for help on using the changeset viewer.