Changeset 879 for branches/prototype-v0
- Timestamp:
- Sep 12, 2018, 3:57:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-api/js/ZOO-api.js
r625 r879 3678 3678 } 3679 3679 var builder = this.parseData[data.localName().toLowerCase()]; 3680 if (builder) 3680 if (builder){ 3681 3681 res.push(builder.apply(this,[data])); 3682 } 3682 3683 else 3683 3684 res.push(null); 3685 data=null; 3684 3686 } 3685 3687 return res.length>1?res:res[0]; … … 3740 3742 * {Object} A WPS reference response. 3741 3743 */ 3742 'reference': function(node) { 3743 var result = {type:'reference',value:node.@href}; 3744 'reference': function(lnode) { 3745 var lhref=lnode.@href; 3746 var lmimeType=lnode.@mimeType; 3747 var result = {type:'reference',value:lhref.toXMLString(),mimeType:lmimeType.toXMLString()}; 3744 3748 return result; 3745 3749 } … … 6168 6172 body = body.toXMLString(); 6169 6173 var headers=['Content-Type: text/xml; charset=UTF-8']; 6170 6171 6172 6174 if(arguments.length>2){ 6175 headers[headers.length]=arguments[2]; 6176 } 6173 6177 var response = ZOO.Request.Post(this.url,body,headers); 6174 6178 return response; … … 6187 6191 */ 6188 6192 'ResponseDocument': function(identifier,obj) { 6189 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>'); 6193 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>'); 6194 output = output.toXMLString(); 6195 return output; 6196 }, 6197 'RawDataOutput': function(identifier,obj) { 6198 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>'); 6190 6199 if (obj.encoding) 6191 6200 output.*::Data.*::ComplexData.@encoding = obj.encoding; … … 6194 6203 output = output.toXMLString(); 6195 6204 return output; 6196 },6197 'RawDataOutput': function(identifier,obj) {6198 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>');6199 if (obj.encoding)6200 output.*::Data.*::ComplexData.@encoding = obj.encoding;6201 if (obj.schema)6202 output.*::Data.*::ComplexData.@schema = obj.schema;6203 output = output.toXMLString();6204 return output;6205 6205 } 6206 6206 … … 6223 6223 */ 6224 6224 'complex': function(identifier,data) { 6225 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>');6225 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>'); 6226 6226 if(data.xlink) 6227 6227 input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6228 6228 else 6229 6229 input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6230 6230 if (data.encoding) 6231 6231 input.*::Data.*::ComplexData.@encoding = data.encoding; … … 6233 6233 input.*::Data.*::ComplexData.@schema = data.schema; 6234 6234 input = input.toXMLString(); 6235 return input; 6235 if(data.value) 6236 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>')); 6237 else 6238 return input; 6236 6239 }, 6237 6240 /** … … 6261 6264 */ 6262 6265 'literal': function(identifier,data) { 6263 if(data && !eval(data["isArray"])){ 6264 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>'); 6265 if (data.type) 6266 input.*::Data.*::LiteralData.@dataType = data.type; 6267 if (data.uom) 6268 input.*::Data.*::LiteralData.@uom = data.uom; 6269 input = input.toXMLString(); 6270 return input; 6271 }else if(data){ 6272 var inputf=""; 6273 for(i=0;i<parseInt(data["length"]);i++){ 6274 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>'); 6275 if (data.type) 6276 input.*::Data.*::LiteralData.@dataType = data.type; 6277 if (data.uom) 6278 input.*::Data.*::LiteralData.@uom = data.uom; 6279 inputf += input.toXMLString(); 6280 } 6281 return inputf; 6266 if(data && !eval(data["isArray"])){ 6267 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>'); 6268 if (data.type) 6269 input.*::Data.*::LiteralData.@dataType = data.type; 6270 if (data.uom) 6271 input.*::Data.*::LiteralData.@uom = data.uom; 6272 input = input.toXMLString(); 6273 return input; 6274 }else if(data){ 6275 var inputf=""; 6276 for(i=0;i<parseInt(data["length"]);i++){ 6277 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>'); 6278 if (data.type) 6279 input.*::Data.*::LiteralData.@dataType = data.type; 6280 if (data.uom) 6281 input.*::Data.*::LiteralData.@uom = data.uom; 6282 inputf += input.toXMLString(); 6282 6283 } 6283 6284 return inputf; 6285 } 6284 6286 } 6285 6287 }, … … 6310 6312 6311 6313 buildDataOutputsNode:function(outputs){ 6312 var data, builder, outputsArray=[ ];6314 var data, builder, outputsArray=[[],[]]; 6313 6315 for (var attr in outputs) { 6314 6316 data = outputs[attr]; 6315 6317 builder = this.buildOutput[data.type]; 6316 outputsArray.push(builder.apply(this,[attr,data])); 6317 } 6318 return outputsArray.join('\n'); 6318 if(data.type=="ResponseDocument") 6319 outputsArray[0].push(builder.apply(this,[attr,data])); 6320 else 6321 outputsArray[1].push(builder.apply(this,[attr,data])); 6322 } 6323 var responseDocuments=(outputsArray[0].length>0? 6324 new XML('<wps:ResponseDocument xmlns:wps="'+this.namespaces['wps']+'">'+ 6325 outputsArray[0].join('\n')+ 6326 '</wps:ResponseDocument>') 6327 : 6328 null); 6329 var rawDataOutputs=(outputsArray[1].length>0? 6330 outputsArray[1].join('\n') 6331 : 6332 null); 6333 var res=new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'">'+ 6334 (responseDocuments!=null?responseDocuments.toXMLString():"")+ 6335 (rawDataOutputs!=null?rawDataOutputs:"")+ 6336 '</wps:ResponseForm>'); 6337 return res.toXMLString(); 6319 6338 }, 6320 6339
Note: See TracChangeset
for help on using the changeset viewer.