Changeset 879 for branches


Ignore:
Timestamp:
Sep 12, 2018, 3:57:33 PM (6 years ago)
Author:
djay
Message:

Fix problem for running Execute request from a JavaScript? ZOO-Service returning multiple outputs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-api/js/ZOO-api.js

    r625 r879  
    36783678        }
    36793679        var builder = this.parseData[data.localName().toLowerCase()];
    3680         if (builder)
     3680        if (builder){
    36813681          res.push(builder.apply(this,[data]));
     3682        }
    36823683        else
    36833684          res.push(null);
     3685        data=null;
    36843686      }
    36853687      return res.length>1?res:res[0];
     
    37403742     * {Object} A WPS reference response.
    37413743     */
    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()};
    37443748      return result;
    37453749    }
     
    61686172    body = body.toXMLString();
    61696173    var headers=['Content-Type: text/xml; charset=UTF-8'];
    6170       if(arguments.length>2){
    6171         headers[headers.length]=arguments[2];
    6172       }
     6174    if(arguments.length>2){
     6175      headers[headers.length]=arguments[2];
     6176    }
    61736177    var response = ZOO.Request.Post(this.url,body,headers);
    61746178    return response;
     
    61876191     */
    61886192    '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>');
    61906199      if (obj.encoding)
    61916200        output.*::Data.*::ComplexData.@encoding = obj.encoding;
     
    61946203      output = output.toXMLString();
    61956204      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;
    62056205    }
    62066206
     
    62236223     */
    62246224    '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>');
    62266226      if(data.xlink)
    6227         input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json';
     6227        input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json';
    62286228      else
    6229         input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json';
     6229        input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json';
    62306230      if (data.encoding)
    62316231        input.*::Data.*::ComplexData.@encoding = data.encoding;
     
    62336233        input.*::Data.*::ComplexData.@schema = data.schema;
    62346234      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;
    62366239    },
    62376240    /**
     
    62616264     */
    62626265    '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();
    62826283        }
    6283        
     6284        return inputf;
     6285      }
    62846286    }
    62856287  },
     
    63106312
    63116313  buildDataOutputsNode:function(outputs){
    6312     var data, builder, outputsArray=[];
     6314    var data, builder, outputsArray=[[],[]];
    63136315    for (var attr in outputs) {
    63146316      data = outputs[attr];
    63156317      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();
    63196338  },
    63206339
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png