Changeset 917 for trunk/zoo-project/zoo-api/js
- Timestamp:
- May 7, 2019, 2:17:08 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
False
/branches/prototype-v0 merged eligible
-
Property
svn:mergeinfo
set to
False
-
trunk/zoo-project/zoo-api/js/ZOO-api.js
r828 r917 3686 3686 } 3687 3687 var builder = this.parseData[data.localName().toLowerCase()]; 3688 if (builder) 3688 if (builder){ 3689 3689 res.push(builder.apply(this,[data])); 3690 } 3690 3691 else 3691 3692 res.push(null); 3693 data=null; 3692 3694 } 3693 3695 return res.length>1?res:res[0]; 3694 } else 3695 return null; 3696 } 3697 else{ 3698 var hasPercentCompleted=true; 3699 var status = node.*::Status.*::ProcessStarted; 3700 var msg = node.*::Status.*::ProcessStarted.*::*[0]; 3701 if(!status || !msg){ 3702 status = node.*::Status.*::ProcessAccepted; 3703 msg = node.*::Status.*::ProcessAccepted.*::*[0]; 3704 msg=msg.toString(); 3705 hasPercentCompleted=false; 3706 }else 3707 msg=msg.toString(); 3708 if(status!=null && node.@statusLocation){ 3709 var res={"status": node.@statusLocation.toXMLString(), "message": msg}; 3710 if(hasPercentCompleted) 3711 res["percentCompleted"]=status.@percentCompleted.toXMLString(); 3712 return res; 3713 }else 3714 return null; 3715 } 3696 3716 }, 3697 3717 /** … … 3748 3768 * {Object} A WPS reference response. 3749 3769 */ 3750 'reference': function(node) { 3751 var result = {type:'reference',value:node.@href}; 3770 'reference': function(lnode) { 3771 var lhref=lnode.@href; 3772 var lmimeType=lnode.@mimeType; 3773 var result = {type:'reference',value:lhref.toXMLString(),mimeType:lmimeType.toXMLString()}; 3752 3774 return result; 3753 3775 } … … 6147 6169 identifier: null, 6148 6170 /** 6171 * Property: async 6172 * {Bool} Define if the process should run asyncrhonously (true) or not (false, default). 6173 */ 6174 async: null, 6175 /** 6149 6176 * Constructor: ZOO.Process 6150 6177 * Create a new Process … … 6158 6185 this.url = url; 6159 6186 this.identifier = identifier; 6187 this.async = (arguments.length>2?arguments[2]:false); 6160 6188 }, 6161 6189 /** … … 6173 6201 if (this.identifier == null) 6174 6202 return null; 6175 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>');6203 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>'); 6176 6204 body = body.toXMLString(); 6177 6205 var headers=['Content-Type: text/xml; charset=UTF-8']; 6178 6179 6180 6206 if(arguments.length>2){ 6207 headers[headers.length]=arguments[2]; 6208 } 6181 6209 var response = ZOO.Request.Post(this.url,body,headers); 6182 6210 return response; … … 6195 6223 */ 6196 6224 'ResponseDocument': function(identifier,obj) { 6197 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>'); 6225 var output = new XML('<wps:Output xmlns:wps="'+this.namespaces['wps']+'" '+(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>'); 6226 output = output.toXMLString(); 6227 return output; 6228 }, 6229 'RawDataOutput': function(identifier,obj) { 6230 var output = new XML('<wps:RawDataOutput xmlns:wps="'+this.namespaces['wps']+'" '+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:RawDataOutput>'); 6198 6231 if (obj.encoding) 6199 6232 output.*::Data.*::ComplexData.@encoding = obj.encoding; … … 6202 6235 output = output.toXMLString(); 6203 6236 return output; 6204 },6205 'RawDataOutput': function(identifier,obj) {6206 var output = new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'"><wps:RawDataOutput '+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:RawDataOutput></wps:ResponseForm>');6207 if (obj.encoding)6208 output.*::Data.*::ComplexData.@encoding = obj.encoding;6209 if (obj.schema)6210 output.*::Data.*::ComplexData.@schema = obj.schema;6211 output = output.toXMLString();6212 return output;6213 6237 } 6214 6238 … … 6231 6255 */ 6232 6256 'complex': function(identifier,data) { 6233 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier>'+(data.value?'<wps:Data><wps:ComplexData ><![CDATA['+data.value+']]></wps:ComplexData></wps:Data>':(data.xlink?'<wps:Reference xmlns:xlink="'+this.namespaces['xlink']+'" xlink:href="'+data.xlink+'" mimeType="'+data.mimeType+'" />':''))+'</wps:Input>');6257 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier>'+(data.value?'<wps:Data><wps:ComplexData '+(data.mimeType?'mimeType="'+data.mimeType+'"':"")+'><![CDATA['+data.value+']]></wps:ComplexData></wps:Data>':(data.xlink?'<wps:Reference xmlns:xlink="'+this.namespaces['xlink']+'" xlink:href="'+data.xlink+'" mimeType="'+data.mimeType+'" />':''))+'</wps:Input>'); 6234 6258 if(data.xlink) 6235 6259 input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6236 6260 else 6237 6261 input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6238 6262 if (data.encoding) 6239 6263 input.*::Data.*::ComplexData.@encoding = data.encoding; … … 6241 6265 input.*::Data.*::ComplexData.@schema = data.schema; 6242 6266 input = input.toXMLString(); 6243 return input; 6267 if(data.value) 6268 return (('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier>'+(data.value?'<wps:Data><wps:ComplexData '+(data.mimeType?'mimeType="'+data.mimeType+'"':"")+'><![CDATA['+data.value+']]></wps:ComplexData></wps:Data>':(data.xlink?'<wps:Reference xmlns:xlink="'+this.namespaces['xlink']+'" xlink:href="'+data.xlink+'" mimeType="'+data.mimeType+'" />':''))+'</wps:Input>')); 6269 else 6270 return input; 6244 6271 }, 6245 6272 /** … … 6269 6296 */ 6270 6297 'literal': function(identifier,data) { 6271 if(data && !eval(data["isArray"])){ 6272 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value+'</wps:LiteralData></wps:Data></wps:Input>'); 6273 if (data.type) 6274 input.*::Data.*::LiteralData.@dataType = data.type; 6275 if (data.uom) 6276 input.*::Data.*::LiteralData.@uom = data.uom; 6277 input = input.toXMLString(); 6278 return input; 6279 }else if(data){ 6280 var inputf=""; 6281 for(i=0;i<parseInt(data["length"]);i++){ 6282 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value[i]+'</wps:LiteralData></wps:Data></wps:Input>'); 6283 if (data.type) 6284 input.*::Data.*::LiteralData.@dataType = data.type; 6285 if (data.uom) 6286 input.*::Data.*::LiteralData.@uom = data.uom; 6287 inputf += input.toXMLString(); 6288 } 6289 return inputf; 6298 if(data && !eval(data["isArray"])){ 6299 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value+'</wps:LiteralData></wps:Data></wps:Input>'); 6300 if (data.type) 6301 input.*::Data.*::LiteralData.@dataType = data.type; 6302 if (data.uom) 6303 input.*::Data.*::LiteralData.@uom = data.uom; 6304 input = input.toXMLString(); 6305 return input; 6306 }else if(data){ 6307 var inputf=""; 6308 for(i=0;i<parseInt(data["length"]);i++){ 6309 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value[i]+'</wps:LiteralData></wps:Data></wps:Input>'); 6310 if (data.type) 6311 input.*::Data.*::LiteralData.@dataType = data.type; 6312 if (data.uom) 6313 input.*::Data.*::LiteralData.@uom = data.uom; 6314 inputf += input.toXMLString(); 6290 6315 } 6291 6316 return inputf; 6317 } 6292 6318 } 6293 6319 }, … … 6318 6344 6319 6345 buildDataOutputsNode:function(outputs){ 6320 var data, builder, outputsArray=[ ];6346 var data, builder, outputsArray=[[],[]]; 6321 6347 for (var attr in outputs) { 6322 6348 data = outputs[attr]; 6323 6349 builder = this.buildOutput[data.type]; 6324 outputsArray.push(builder.apply(this,[attr,data])); 6325 } 6326 return outputsArray.join('\n'); 6350 if(data.type=="ResponseDocument") 6351 outputsArray[0].push(builder.apply(this,[attr,data])); 6352 else 6353 outputsArray[1].push(builder.apply(this,[attr,data])); 6354 } 6355 var responseDocuments=(outputsArray[0].length>0? 6356 new XML('<wps:ResponseDocument '+(this.async?'storeExecuteResponse="true" status="true"':'')+' xmlns:wps="'+this.namespaces['wps']+'">'+ 6357 outputsArray[0].join('\n')+ 6358 '</wps:ResponseDocument>') 6359 : 6360 null); 6361 var rawDataOutputs=(outputsArray[1].length>0? 6362 outputsArray[1].join('\n') 6363 : 6364 null); 6365 var res=new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'">'+ 6366 (responseDocuments!=null?responseDocuments.toXMLString():"")+ 6367 (rawDataOutputs!=null?rawDataOutputs:"")+ 6368 '</wps:ResponseForm>'); 6369 return res.toXMLString(); 6327 6370 }, 6328 6371
Note: See TracChangeset
for help on using the changeset viewer.