Source: Usage/RequestLog.js

/**
 *
 * @author Malcolm Haslam <mhaslam@runmyprocess.com>
 *
 * Copyright (C) 2013 Fujitsu RunMyProcess
 *
 * This file is part of RunMyProcess SDK-JS.
 *
 * RunMyProcess SDK-JS is free software: you can redistribute it and/or modify
 * it under the terms of the Apache License Version 2.0 (the "License");
 *
 *   You may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
 /**
  Create a new instance of RequestLog
      @constructor
	@property {Object} request - the objects request
    @property {Array} links - Contains the array of links
    @see ProjectApp
    @see Resource
	@example Load RequestLog
		var r = new RequestLog();
		r.load({
			period:"current",
			onSuccess:function(){
				alert(JSON.stringify(r.request));
			}
		});
 */
function RequestLog(){
	this.request=[];
    this.links = {};
	this.from;
	this.to;
};
/**
  @borrows
  Inherits Resource
*/
RequestLog.prototype = new  Resource();
/**
    Overrides Resource's loadPreset method.
    @method
    @see Resource#loadPreset
*/
RequestLog.prototype.loadPreset = function () {
    /**
        Overrides Resource's generateUrl method to return the request url
        @method
        @see Resource#generateUrl
    */
    this.generateUrl = function () {
        return  "logs/request/"+context.customer_id+"/";//?P_from="+this.from+"&P_to="+this.to;//HARDCODED
    };
};
/**
    Override Resource load method.
    @method
    @param {object} options - options to be used during the call<br/>
	@param {string} options.period - the period to load
    @param {Resource~onSuccess} options.onSuccess - a callback function called in case of a success
    @param {Resource~onFailure} [options.onFailure] - a callback function called in case of a failure
    @param {String} [options.baseUrl] - base URL. If not set the current base URL will be used
    @see Resource#load
 */
RequestLog.prototype.load = function(options){
    var loadOptions = {};
    var father = this;
    this.period = options.period;
	
	
	father.pagination = {};//remove current pagination
	father.filters = [];//remove current filters
	father.orderBy = [];//remove current orderBy
	father.mode = '';
	father.parameters = [];
	if(options.removeDefaultFilters) father.defaultFilters = [];
	father.loadPreset();
	if(!jQuery.isEmptyObject(options.pagination))father.pagination = options.pagination;
	if(options.mode)father.mode = options.mode;
	if(options.parameters)father.parameters = options.parameters;
	if(options.filters)father.filters = options.filters;
	if(options.orderBy)father.orderBy = options.orderBy;
	
	
	//loadOptions.filters = options.filters;
	//loadOptions.pagination = options.pagination;
    loadOptions.onSuccess = function(rObject){
			father.request = rObject.request;
            father.links = rObject.links;
            options.onSuccess(rObject);
    };
    loadOptions.onFailure = function(e){
            options.eObject=e;
            father.errorManager(options);
        };
    loadOptions.baseUrl = options.baseUrl || RMPApplication.getBaseUrl();
    father.straightLoad(loadOptions);
};