1 /**
  2 * @fileOverview JavaScript representation of the Finesse Not Ready Reason Code collection
  3 * object which contains a list of Not Ready Reason Codes objects.
  4  *
  5  * @name finesse.restservices.NotReadyReasonCodes
  6  * @requires finesse.clientservices.ClientServices
  7  * @requires Cl 
  8  * @requires finesse.FinesseBase
  9  * @requires finesse.restservices.RestBase
 10  * @requires finesse.restservices.Dialog
 11  * @requires finesse.restservices.RestCollectionBase
 12  */
 13 
 14 var finesse = finesse || {};
 15 finesse.restservices = finesse.restservices || {};
 16 
 17 /** @private */
 18 finesse.restservices.NotReadyReasonCodes = finesse.restservices.RestCollectionBase.extend(/** @lends finesse.restservices.NotReadyReasonCodes.prototype */{
 19 
 20     /**
 21      * @class
 22      * JavaScript representation of a NotReadyReasonCodes collection object. Also exposes
 23      * methods to operate on the object against the server.
 24      *
 25      * @param {Object} options
 26      *     An object with the following properties:<ul>
 27      *         <li><b>id:</b> The id of the object being constructed</li>
 28      *         <li><b>onLoad(this): (optional)</b> when the object is successfully loaded from the server</li>
 29      *         <li><b>onChange(this): (optional)</b> when an update notification of the object is received</li>
 30      *         <li><b>onAdd(this): (optional)</b> when a notification that the object is created is received</li>
 31      *         <li><b>onDelete(this): (optional)</b> when a notification that the object is deleted is received</li>
 32      *         <li><b>onError(rsp): (optional)</b> if loading of the object fails, invoked with the error response object:<ul>
 33      *             <li><b>status:</b> {Number} The HTTP status code returned</li>
 34      *             <li><b>content:</b> {String} Raw string of response</li>
 35      *             <li><b>object:</b> {Object} Parsed object of response</li>
 36      *             <li><b>error:</b> {Object} Wrapped exception that was caught:<ul>
 37      *                 <li><b>errorType:</b> {String} Type of error that was caught</li>
 38      *                 <li><b>errorMessage:</b> {String} Message associated with error</li>
 39      *             </ul></li>
 40      *         </ul></li>
 41      *         <li><b>parentObj: (optional)</b> The parent object</li></ul>
 42      * @constructs finesse.restservices.NotReadyReasonCodes
 43      **/
 44     init: function (options) {
 45         this._super(options);
 46     },
 47 
 48     /**
 49      * @private
 50      * Gets the REST class for the current object - this is the NotReadyReasonCodes class.
 51      */
 52     getRestClass: function () {
 53         return finesse.restservices.NotReadyReasonCodes;
 54     },
 55 
 56     /**
 57      * @private
 58      * Gets the REST class for the objects that make up the collection. - this
 59      * is the NotReadyReasonCode class.
 60      */
 61     getRestItemClass: function () {
 62         return finesse.restservices.NotReadyReasonCode;
 63     },
 64 
 65     /**
 66      * @private
 67      * Gets the REST type for the current object - this is a "ReasonCodes".
 68      */
 69     getRestType: function () {
 70         return "ReasonCodes";
 71     },
 72 
 73     /**
 74      * Overrides the parent class.  Returns the url for the NotReadyReasonCodes resource
 75      */
 76     getRestUrl: function () {
 77         var restObj = this._restObj,
 78             restUrl = "";
 79         //Prepend the base REST object if one was provided.
 80         //Otherwise prepend with the default webapp name.
 81         if (restObj instanceof finesse.restservices.RestBase) {
 82             restUrl += restObj.getRestUrl();
 83         }
 84         else {
 85             restUrl += "/finesse/api";
 86         }
 87         //Append the REST type.
 88         restUrl += "/ReasonCodes?category=NOT_READY";
 89         //Append ID if it is not undefined, null, or empty.
 90         if (this._id) {
 91             restUrl += "/" + this._id;
 92         }
 93         return restUrl;
 94     },
 95     
 96     /**
 97      * @private
 98      * Gets the REST type for the objects that make up the collection - this is "ReasonCode".
 99      */
100     getRestItemType: function () {
101         return "ReasonCode";
102     },
103 
104     /**
105      * @private
106      * Override default to indicates that the collection supports making
107      * requests.
108      */
109     supportsRequests: true,
110 
111     /**
112      * @private
113      * Override default to indicate that this object doesn't support subscriptions.
114      */
115     supportsRestItemSubscriptions: false,
116 
117     /**
118      * Retrieve the Not Ready Reason Codes.
119      *
120      * @returns {finesse.restservices.NotReadyReasonCodes}
121      *     This ReadyReasonCodes object to allow cascading.
122      */
123     get: function () {
124         // set loaded to false so it will rebuild the collection after the get
125         this._loaded = false;
126         // reset collection
127         this._collection = {};
128         // perform get
129         this._synchronize();
130         return this;
131     }
132 });