Ignore:
Timestamp:
May 7, 2019, 2:17:08 PM (6 years ago)
Author:
djay
Message:

Merge prototype-v0 branch in trunk

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/zoo-project/zoo-api/js/ZOO-api.js

    r828 r917  
    36863686        }
    36873687        var builder = this.parseData[data.localName().toLowerCase()];
    3688         if (builder)
     3688        if (builder){
    36893689          res.push(builder.apply(this,[data]));
     3690        }
    36903691        else
    36913692          res.push(null);
     3693        data=null;
    36923694      }
    36933695      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    }
    36963716  },
    36973717  /**
     
    37483768     * {Object} A WPS reference response.
    37493769     */
    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()};
    37523774      return result;
    37533775    }
     
    61476169  identifier: null,
    61486170  /**
     6171   * Property: async
     6172   * {Bool} Define if the process should run asyncrhonously (true) or not (false, default).
     6173   */
     6174  async: null,
     6175  /**
    61496176   * Constructor: ZOO.Process
    61506177   * Create a new Process
     
    61586185    this.url = url;
    61596186    this.identifier = identifier;
     6187    this.async = (arguments.length>2?arguments[2]:false);
    61606188  },
    61616189  /**
     
    61736201    if (this.identifier == null)
    61746202      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>');
    61766204    body = body.toXMLString();
    61776205    var headers=['Content-Type: text/xml; charset=UTF-8'];
    6178       if(arguments.length>2){
    6179         headers[headers.length]=arguments[2];
    6180       }
     6206    if(arguments.length>2){
     6207      headers[headers.length]=arguments[2];
     6208    }
    61816209    var response = ZOO.Request.Post(this.url,body,headers);
    61826210    return response;
     
    61956223     */
    61966224    '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>');
    61986231      if (obj.encoding)
    61996232        output.*::Data.*::ComplexData.@encoding = obj.encoding;
     
    62026235      output = output.toXMLString();
    62036236      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;
    62136237    }
    62146238
     
    62316255     */
    62326256    '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>');
    62346258      if(data.xlink)
    6235         input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json';
     6259        input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json';
    62366260      else
    6237         input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json';
     6261        input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json';
    62386262      if (data.encoding)
    62396263        input.*::Data.*::ComplexData.@encoding = data.encoding;
     
    62416265        input.*::Data.*::ComplexData.@schema = data.schema;
    62426266      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;
    62446271    },
    62456272    /**
     
    62696296     */
    62706297    '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();
    62906315        }
    6291        
     6316        return inputf;
     6317      }
    62926318    }
    62936319  },
     
    63186344
    63196345  buildDataOutputsNode:function(outputs){
    6320     var data, builder, outputsArray=[];
     6346    var data, builder, outputsArray=[[],[]];
    63216347    for (var attr in outputs) {
    63226348      data = outputs[attr];
    63236349      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();
    63276370  },
    63286371
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