1 define(['require','UserObject','WorkBookObject'], 
  2     function ( require, UserObject, WorkBookObject) {
  3 
  4 		/**
  5 		 * @description A Class to handle All Kind of Data Services Associated with Nexcel Sheet 
  6 		 * @name UserDataService
  7 		 * @class UserDataService
  8 		 * @example require('UserDataService')
  9 		 * @exports UserDataService
 10 		 * @version 1.0
 11 		 * @module UserDataService
 12 		 * @augments jquery
 13 		 * @augments UserObject
 14 		 * @augments WorkBookObject
 15 		 **/
 16 		var UserDataService = function(){
 17 			/**
 18 			 * 
 19 			 */
 20 			var url = window.location.pathname;
 21 			url = url.split('/');
 22 			url.splice(0,1);
 23 			url.splice(url.length-1,1);
 24 			var serviceUrl = window.location.protocol+'//'+window.location.host+"/"+url.join('/')+"/php/UserService.php?method=";
 25 			
 26 			/**
 27 			 * @name addFolder
 28 			 * @memberOf UserDataService
 29 			 * @method 
 30 			 * @return {Integer} groupId The unique identification for the group.
 31 			 * @description An Asynchronous process. It creates teh given folder in the server, and return with the folder id. As it is an Asynchronous process it calls the callback function to update in the ui.
 32 			 * @param name Name of the folder 
 33 			 * @param parentId the Parent folder Id 
 34 			 * @param callback The call back function will be called once the Asynchronous process is completed.
 35 			 * @function
 36 			 */
 37 			this.addFolder = function(name, parentId, callback){
 38 				console.log('Adding Work Book .....');
 39 				jQuery.ajax({
 40 					 type: "POST",
 41 					 url:  serviceUrl + UserObject.ADD_FOLDER,
 42 					 data: { "Folder": UserObject.Folder(-1, name, parentId).json()},
 43 					 success: function(result) {
 44 									console.log('Created Folder Succsessfully.....');
 45 									callback(JSON.parse(result));
 46 							  },
 47 					 async:   true
 48 				});   	  
 49 			};
 50 			
 51 			/**
 52 			 * @name renameWorkBook
 53 			 * @memberOf UserDataService
 54 			 * @method 
 55 			 * @return {Void}
 56 			 * @description An Asynchronous process. It updates teh name in the server with the new workbook name.
 57 			 * @param id The workbook Id 
 58 			 * @param name The new Name for teh workbook. 
 59 			 * @function
 60 			 */	
 61 			this.renameWorkBook = function(id, name){
 62 				console.log('Rename Work Book .....');
 63 				jQuery.ajax({
 64 					 type: "POST",
 65 					 url:  serviceUrl + WorkBookObject.RENAME_WORK_BOOK,
 66 					 data: { "WorkBook": WorkBookObject.WorkBook(id, name).json()},
 67 					 success: function(result) {
 68 									console.log('Renamed Work Book Succsessfully.....');
 69 							  },
 70 					 async:   true
 71 				});   	  
 72 			};
 73 			/**
 74 			 * @name login
 75 			 * @memberOf UserDataService
 76 			 * @method 
 77 			 * @return {Void}
 78 			 * @description An Asynchronous process to login the given user in the server and hence can keep the session maintained.
 79 			 * @param id The workbook Id 
 80 			 * @param name The new Name for teh workbook. 
 81 			 * @function
 82 			 */	
 83 			this.login = function(username, password){
 84 				console.log('Login Work Book .....');
 85 				jQuery.ajax({
 86 					 type: "POST",
 87 					 url:  serviceUrl + WorkBookObject.LOGIN,
 88 					 data: { "data": UserObject.Login(username,password).json()},
 89 					 success: function(result) {
 90 									console.log('Logged Into  Work Book Succsessfully.....');
 91 							  },
 92 					 async:   true
 93 				});   	  
 94 			};
 95 		};
 96 		return new UserDataService();
 97 	}
 98 );