06324d393a58414c42bd0e09ad80463f3bef3d5a
[portal/sdk.git] /
1 appDS2.factory('raptorReportFactory', function($http, $q) {
2         return {
3                 getDefinitionByReportId: function(reportId) {
4                         return $http({
5                                 method: "GET",
6                 url: "report/wizard/retrieve_tab_wise_data/Def/"+reportId,                      
7                         }).then(function(response) {
8                                 if (typeof response.data === 'object') {
9                                         return response.data;
10                                 } else {
11                                         return $q.reject("raptorReportFactory: getDefinitionByReportId did not return a valid JSON object.");
12                                 }
13                         }, function(response) {
14                                 // something went wrong
15                                 return $q.reject("raptorReportFactory: getDefinitionByReportId callback failed");
16                         });                     
17                 },      
18                 getDefinitionInSession: function() {
19                         return $http({
20                                 method: "GET",
21                 url: "report/wizard/retrieve_tab_wise_data/Def/InSession",                      
22                         }).then(function(response) {
23                                 if (typeof response.data === 'object') {
24                                         return response.data;
25                                 } else {
26                                         return $q.reject("raptorReportFactory: getDefinitionInSession did not return a valid JSON object.");
27                                 }
28                         }, function(response) {
29                                 // something went wrong
30                                 return $q.reject("raptorReportFactory: getDefinitionInSession callback failed");
31                         });                     
32                 },                              
33
34                 createNewDefinition: function() {
35                         return $http({
36                                 method: "GET",
37                 url: "report/wizard/retrieve_tab_wise_data/Def/Create",                 
38                         }).then(function(response) {
39                                 if (typeof response.data === 'object') {
40                                         return response.data;
41                                 } else {
42                                         return $q.reject("raptorReportFactory: createNewDefinition did not return a valid JSON object.");
43                                 }
44                         }, function(response) {
45                                 // something went wrong
46                                 return $q.reject("raptorReportFactory: createNewDefinition callback failed");
47                         });                     
48                 },
49                 updateDefinition: function(updatedJson,isUpdate) {
50                         return $http({
51                                 method: "POST",
52                 url: (isUpdate?("report/wizard/save_def_tab_data/"+updatedJson.reportId):"report/wizard/save_def_tab_data/Create"),
53                 data: updatedJson                       
54                         }).then(function(response) {
55                                 if (typeof response.data === 'object') {
56                                         return response.data;
57                                 } else {
58                                         return $q.reject("raptorReportFactory: updateDefinition did not return a valid JSON object.");
59                                 }
60                                 return response.data;
61                         }, function(response) {
62                                 // something went wrong
63                                 return $q.reject("raptorReportFactory: updateDefinition callback failed");
64                         });
65                 },
66                 saveNewDefinition: function(updatedJson) {
67                         return $http({
68                                 method: "POST",
69                 url: "report/wizard/save_def_tab_data/InSession",
70                 data: updatedJson                       
71                         }).then(function(response) {
72                                 if (typeof response.data === 'object') {
73                                         return response.data;
74                                 } else {
75                                         return $q.reject("raptorReportFactory: saveNewDefinition did not return a valid JSON object.");
76                                 }
77                         }, function(response) {
78                                 // something went wrong
79                                 return $q.reject("raptorReportFactory: saveNewDefinition callback failed");
80                         });
81                 },              
82                 getSqlInSession: function() {
83                         return $http({
84                                 method: "GET",
85                 url: "report/wizard/retrieve_tab_wise_data/Sql/InSession",                      
86                         }).then(function(response) {
87                                 if (typeof response.data === 'object') {
88                                         return response.data;
89                                 } else {
90                                         return $q.reject("raptorReportFactory: getSqlInSession did not return a valid JSON object.");
91                                 }
92                         }, function(response) {
93                                 // something went wrong
94                                 return $q.reject("raptorReportFactory: getSqlInSession callback failed");
95                         });                     
96                 },              
97                 testRunSQL: function(queryJSON) {
98                         return $http({
99                                 method: "POST",
100                 url: "report/wizard/retrieve_data/true",
101                 data: queryJSON                 
102                         }).then(function(response) {
103                                 if (typeof response.data === 'object') {
104                                         return response.data;
105                                 } else {
106                                         return $q.reject("raptorReportFactory: testRunSQL did not return a valid JSON object.");
107                                 }
108                                 return response.data;
109                         }, function(response) {
110                                 // something went wrong
111                                 return $q.reject("raptorReportFactory: testRunSQL callback failed");
112                         });
113                 },              
114                 formFieldVerifySQL: function(queryJSON) {
115                         return $http({
116                                 method: "POST",
117                 url: "report/wizard/retrieve_data/false",
118                 data: queryJSON                 
119                         }).then(function(response) {
120                                 if (typeof response.data === 'object') {
121                                         return response.data;
122                                 } else {
123                                         return $q.reject("raptorReportFactory: formFieldVerifySQL did not return a valid JSON object.");
124                                 }
125                                 return response.data;
126                         }, function(response) {
127                                 // something went wrong
128                                 return $q.reject("raptorReportFactory: formFieldVerifySQL callback failed");                            
129                         });
130                 },
131                 getColumnList: function() {
132                         return $http({
133                                 method: "GET",
134                 url: "report/wizard/list_columns",
135                         }).then(function(response) {
136                                 if (typeof response.data === 'object') {
137                                         return response.data;
138                                 } else {
139                                         return $q.reject("raptorReportFactory: getColumnList did not return a valid JSON object.");
140                                 }
141                                 return response.data;
142                         }, function(response) {
143                                 // something went wrong
144                                 return $q.reject("raptorReportFactory: getColumnList callback failed");                         
145                         });
146                 },
147                 
148                 getColumnEditInfoById: function(columnId){
149                         return $http({
150                                 method: "GET",
151                 url: "report/wizard/retrieve_tab_wise_data/ColEdit/"+columnId,
152                         }).then(function(response) {
153                                 if (typeof response.data === 'object') {
154                                         return response.data;
155                                 } else {
156                                         return $q.reject("raptorReportFactory: getColumnEditInfoById did not return a valid JSON object.");
157                                 }
158                         }, function(response) {
159                                 // something went wrong
160                                 return $q.reject("raptorReportFactory:  getColumnEditInfoById callback failed");                                
161                         });                     
162                 },
163                 saveColumnEditInfo: function(updatedColumnJson){
164                         return $http({
165                                 method: "POST",
166                 url: "report/wizard/save_col_tab_data",
167                 data: updatedColumnJson
168                         }).then(function(response) {
169                                 if (typeof response.data === 'object') {
170                                         return response.data;
171                                 } else {
172                                         return $q.reject("raptorReportFactory: saveColumnEditInfo did not return a valid JSON object.");
173                                 }
174                         }, function(response) {
175                                 // something went wrong
176                                 return $q.reject("raptorReportFactory: saveColumnEditInfo callback failed");
177                         });                     
178                 },              
179                 postImportXml: function(importXMLJSON){
180                         return $http({
181                                 method: "POST",
182                 url: "report/wizard/import_report",
183                 data: importXMLJSON
184                         }).then(function(response) {
185                                 if (typeof response.data === 'object') {
186                                         return response.data;
187                                 } else {
188                                         return $q.reject("raptorReportFactory: importXml did not return a valid JSON object.");
189                                 }
190                         }, function(response) {
191                                 // something went wrong
192                                 return $q.reject("raptorReportFactory: importXml callback failed");
193                         });                     
194                 },
195                 copyReportById: function(reportId) {
196                         return $http({
197                                 method: "GET",
198                 url: "report/wizard/copy_report/"+reportId,                     
199                         }).then(function(response) {
200                                 if (typeof response.data === 'object') {
201                                         return response.data;
202                                 } else {
203                                         return $q.reject("raptorReportFactory: copyReportById did not return a valid JSON object.");
204                                 }
205                         }, function(response) {
206                                 // something went wrong
207                                 return $q.reject("raptorReportFactory: copyReportById callback failed");
208                         });                     
209                 },                              
210                 saveFormFieldEditInfo: function(updatedFormFieldJson){
211                         return $http({
212                                 method: "POST",
213                 url: "report/wizard/save_formfield_tab_data",
214                 data: updatedFormFieldJson
215                         }).then(function(response) {
216                                 if (typeof response.data === 'object') {
217                                         return response.data;
218                                 } else {
219                                         return $q.reject("raptorReportFactory: saveFormFieldEditInfo did not return a valid JSON object.");
220                                 }
221                         }, function(response) {
222                                 // something went wrong
223                                 return $q.reject("raptorReportFactory: saveFormFieldEditInfo callback failed");
224                         });                     
225                 },
226                 getFormFieldList: function() {
227                         return $http({
228                                 method: "GET",
229                 url: "report/wizard/list_formfields",                   
230                         }).then(function(response) {
231                                 if (typeof response.data === 'object') {
232                                         return response.data;
233                                 } else {
234                                         return $q.reject("raptorReportFactory: getFormFieldList did not return a valid JSON object.");
235                                 }
236                         }, function(response) {
237                                 // something went wrong
238                                 return $q.reject("raptorReportFactory: getFormFieldList callback failed");                              
239                         });                     
240                 },
241                 getFormFieldEditInfoById: function(fieldId){
242                         return $http({
243                                 method: "GET",
244                 url: "report/wizard/retrieve_tab_wise_data/FormEdit/"+fieldId,
245                         }).then(function(response) {
246                                 if (typeof response.data === 'object') {
247                                         return response.data;
248                                 } else {
249                                         return $q.reject("raptorReportFactory: getColumnEditInfoById did not return a valid JSON object.");
250                                 }
251                                 return response.data;
252                         }, function(response) {
253                                 // something went wrong
254                                 return $q.reject("raptorReportFactory: getFormFieldEditInfoById callback failed");                              
255                         });                     
256                 },              
257                 deleteFormFieldById: function(fieldId){
258                         return $http({
259                                 method: "GET",
260                 url: "report/wizard/retrieve_tab_wise_data/FormEdit/delete/"+fieldId,
261                         }).then(function(response) {
262                                 if (typeof response.data === 'object') {
263                                         return response.data;
264                                 } else {
265                                         return $q.reject("raptorReportFactory: deleteFormFieldById did not return a valid JSON object.");
266                                 }
267                                 return response.data;
268                         }, function(response) {
269                                 // something went wrong
270                                 return $q.reject("raptorReportFactory: deleteFormFieldById callback failed");                           
271                         });                     
272                 },              
273                 getColumns: function() {
274                         return $http
275                                         .get('raptor.htm?action=report.search.execute&r_page=0')
276                                         .then(function(response) {
277                                                 if (typeof response.data === 'object') {
278                                                         return response.data;
279                                                 } else {
280                                                         return $q.reject("raptorReportFactory: getColumns did not return a valid JSON object.");
281                                                 }
282                                         }, function(response) {
283                                                 // something went wrong
284                                                 return $q.reject("raptorReportFactory: getColumns callback failed");                            
285                                         });
286                 },
287                 
288                 getSearchData : function() {
289                         return $http
290                                         .get('raptor.htm?action=report.search.execute&r_page=0')
291                                         .then(function(response) {
292                                                 if (typeof response.data === 'object') {
293                                                         return response.data;
294                                                 } else {
295                                                         return $q.reject("raptorReportFactory: getSearchData did not return a valid JSON object.");
296                                                 }
297                                         }, function(response) {
298                                                 // something went wrong
299                                                 return $q.reject("raptorReportFactory: getSearchData callback failed");                         
300                                         });
301                 },
302
303                 getSearchDataAtPage : function(pageSearchParameter) {
304                         return $http
305                                         .get('raptor.htm?action=report.search.execute&r_page='+pageSearchParameter)
306                                         .then(function(response) {
307                                                 if (typeof response.data === 'object') {
308                                                         return response.data;
309                                                 } else {
310                                                         return $q.reject("raptorReportFactory: getSearchDataAtPage did not return a valid JSON object.");
311                                                 }
312                                         }, function(response) {
313                                                 // something went wrong
314                                                 return $q.reject("raptorReportFactory: getSearchDataAtPage callback failed");                           
315                                         });
316                 },
317                 getReportDeleteStatus : function(deleteUrl) {
318                         return $http.get(deleteUrl).then(function(response) {
319                                 if (typeof response.data === 'object') {
320                                         return response.data;
321                                 } else {
322                                         return $q.reject("raptorReportFactory: getReportDeleteStatus did not return a valid JSON object.");
323                                 }
324
325                         }, function(response) {
326                                 // something went wrong
327                                 return $q.reject("raptorReportFactory: getReportDeleteStatus callback failed");                         
328                         });
329                 }
330         };
331 });