dojox/data/util/JsonQuery.js

  • Provides:

    • dojox.data.util.JsonQuery
  • dojox.data.util.JsonQuery

    • type
      Function
    • summary
  • dojox.data.util.JsonQuery.useFullIdInQueries

    • summary
  • dojox.data.util.JsonQuery._toJsonQuery

    • type
      Function
    • parameters:
      • args: (typeof )
      • jsonQueryPagination: (typeof )
    • source: [view]
        var first = true;
        var self = this;
        function buildQuery(path, query){
         var isDataItem = query.__id;
         if(isDataItem){
          // it is a reference to a persisted object, need to make it a query by id
          var newQuery = {};
          newQuery[self.idAttribute] = self.useFullIdInQueries ? query.__id : query[self.idAttribute];
          query = newQuery;
         }
         for(var i in query){
          // iterate through each property, adding them to the overall query
          var value = query[i];
          var newPath = path + (/^[a-zA-Z_][\w_]*$/.test(i) ? '.' + i : '[' + dojo._escapeString(i) + ']');
          if(value && typeof value == "object"){
           buildQuery(newPath, value);
          }else if(value!="*"){ // full wildcards can be ommitted
           jsonQuery += (first ? "" : "&") + newPath +
            ((!isDataItem && typeof value == "string" && args.queryOptions && args.queryOptions.ignoreCase) ? "~" : "=") +
             (self.simplifiedQuery ? encodeURIComponent(value) : dojo.toJson(value));
           first = false;
          }
         }
        }
        // performs conversion of Dojo Data query objects and sort arrays to JSONQuery strings
        if(args.query && typeof args.query == "object"){
         // convert Dojo Data query objects to JSONQuery
         var jsonQuery = "[?(";
         buildQuery("@", args.query);
         if(!first){
          // use ' instead of " for quoting in JSONQuery, and end with ]
          jsonQuery += ")]";
         }else{
          jsonQuery = "";
         }
         args.queryStr = jsonQuery.replace(/\\"|"/g,function(t){return t == '"' ? "'" : t;});
        }else if(!args.query || args.query == '*'){
         args.query = "";
        }

        
        var sort = args.sort;
        if(sort){
         // if we have a sort order, add that to the JSONQuery expression
         args.queryStr = args.queryStr || (typeof args.query == 'string' ? args.query : "");
         first = true;
         for(i = 0; i < sort.length; i++){
          args.queryStr += (first ? '[' : ',') + (sort[i].descending ? '\\' : '/') + "@[" + dojo._escapeString(sort[i].attribute) + "]";
          first = false;
         }
         args.queryStr += ']';
        }
        // this is optional because with client side paging JSONQuery doesn't yield the total count
        if(jsonQueryPagination && (args.start || args.count)){
         // pagination
         args.queryStr = (args.queryStr || (typeof args.query == 'string' ? args.query : "")) +
          '[' + (args.start || '') + ':' + (args.count ? (args.start || 0) + args.count : '') + ']';
        }
        if(typeof args.queryStr == 'string'){
         args.queryStr = args.queryStr.replace(/\\"|"/g,function(t){return t == '"' ? "'" : t;});
         return args.queryStr;
        }
        return args.query;
    • summary
  • dojox.data.util.JsonQuery.jsonQueryPagination

    • summary
  • dojox.data.util.JsonQuery.fetch

    • type
      Function
    • parameters:
      • args: (typeof )
    • source: [view]
        this._toJsonQuery(args, this.jsonQueryPagination);
        return this.inherited(arguments);
    • summary
  • dojox.data.util.JsonQuery.isUpdateable

    • type
      Function
    • source: [view]
        return true;
    • summary
  • dojox.data.util.JsonQuery.matchesQuery

    • type
      Function
    • parameters:
      • item: (typeof )
      • request: (typeof )
    • source: [view]
        request._jsonQuery = request._jsonQuery || dojox.json.query(this._toJsonQuery(request));
        return request._jsonQuery([item]).length;
    • summary
  • dojox.data.util.JsonQuery.clientSideFetch

    • type
      Function
    • parameters:
      • request: (typeof Object)
      • baseResults: (typeof Array)
    • source: [view]
        request._jsonQuery = request._jsonQuery || dojox.json.query(this._toJsonQuery(request));
        // we use client side paging function here instead of JSON Query because we must also determine the total count
        return this.clientSidePaging(request, request._jsonQuery(baseResults));
    • summary
  • dojox.data.util.JsonQuery.querySuperSet

    • type
      Function
    • parameters:
      • argsSuper: (typeof )
      • argsSub: (typeof )
    • source: [view]
        if(!argsSuper.query){
         return argsSub.query;
        }
        return this.inherited(arguments);
    • summary
  • dojox.data.util

    • type
      Object
    • summary
  • dojox.data

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary