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

		createNewDefinition: function() {
			return $http({
				method: "GET",
                url: "report/wizard/retrieve_tab_wise_data/Def/Create",			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: createNewDefinition did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: createNewDefinition callback failed");
			});			
		},
		updateDefinition: function(updatedJson,isUpdate) {
			return $http({
				method: "POST",
                url: (isUpdate?("report/wizard/save_def_tab_data/"+updatedJson.reportId):"report/wizard/save_def_tab_data/Create"),
                data: updatedJson			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: updateDefinition did not return a valid JSON object.");
				}
				return response.data;
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: updateDefinition callback failed");
			});
		},
		saveNewDefinition: function(updatedJson) {
			return $http({
				method: "POST",
                url: "report/wizard/save_def_tab_data/InSession",
                data: updatedJson			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: saveNewDefinition did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: saveNewDefinition callback failed");
			});
		},		
		getSqlInSession: function() {
			return $http({
				method: "GET",
                url: "report/wizard/retrieve_tab_wise_data/Sql/InSession",			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: getSqlInSession did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: getSqlInSession callback failed");
			});			
		},		
		testRunSQL: function(queryJSON) {
			return $http({
				method: "POST",
                url: "report/wizard/retrieve_data/true",
                data: queryJSON			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: testRunSQL did not return a valid JSON object.");
				}
				return response.data;
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: testRunSQL callback failed");
			});
		},		
		formFieldVerifySQL: function(queryJSON) {
			return $http({
				method: "POST",
                url: "report/wizard/retrieve_data/false",
                data: queryJSON			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: formFieldVerifySQL did not return a valid JSON object.");
				}
				return response.data;
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: formFieldVerifySQL callback failed");				
			});
		},
		getColumnList: function() {
			return $http({
				method: "GET",
                url: "report/wizard/list_columns",
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: getColumnList did not return a valid JSON object.");
				}
				return response.data;
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: getColumnList callback failed");				
			});
		},
		
		getColumnEditInfoById: function(columnId){
			return $http({
				method: "GET",
                url: "report/wizard/retrieve_tab_wise_data/ColEdit/"+columnId,
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: getColumnEditInfoById did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory:  getColumnEditInfoById callback failed");				
			});			
		},
		saveColumnEditInfo: function(updatedColumnJson){
			return $http({
				method: "POST",
                url: "report/wizard/save_col_tab_data",
                data: updatedColumnJson
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: saveColumnEditInfo did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: saveColumnEditInfo callback failed");
			});			
		},		
		postImportXml: function(importXMLJSON){
			return $http({
				method: "POST",
                url: "report/wizard/import_report",
                data: importXMLJSON
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: importXml did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: importXml callback failed");
			});			
		},
		copyReportById: function(reportId) {
			return $http({
				method: "GET",
                url: "report/wizard/copy_report/"+reportId,			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: copyReportById did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: copyReportById callback failed");
			});			
		},				
		saveFormFieldEditInfo: function(updatedFormFieldJson){
			return $http({
				method: "POST",
                url: "report/wizard/save_formfield_tab_data",
                data: updatedFormFieldJson
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: saveFormFieldEditInfo did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: saveFormFieldEditInfo callback failed");
			});			
		},
		getFormFieldList: function() {
			return $http({
				method: "GET",
                url: "report/wizard/list_formfields",			
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: getFormFieldList did not return a valid JSON object.");
				}
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: getFormFieldList callback failed");				
			});			
		},
		getFormFieldEditInfoById: function(fieldId){
			return $http({
				method: "GET",
                url: "report/wizard/retrieve_tab_wise_data/FormEdit/"+fieldId,
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: getColumnEditInfoById did not return a valid JSON object.");
				}
				return response.data;
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: getFormFieldEditInfoById callback failed");				
			});			
		},		
		deleteFormFieldById: function(fieldId){
			return $http({
				method: "GET",
                url: "report/wizard/retrieve_tab_wise_data/FormEdit/delete/"+fieldId,
			}).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: deleteFormFieldById did not return a valid JSON object.");
				}
				return response.data;
			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: deleteFormFieldById callback failed");				
			});			
		},		
		getColumns: function() {
			return $http
					.get('raptor.htm?action=report.search.execute&r_page=0')
					.then(function(response) {
						if (typeof response.data === 'object') {
							return response.data;
						} else {
							return $q.reject("raptorReportFactory: getColumns did not return a valid JSON object.");
						}
					}, function(response) {
						// something went wrong
						return $q.reject("raptorReportFactory: getColumns callback failed");				
					});
		},
		
		getSearchData : function() {
			return $http
					.get('raptor.htm?action=report.search.execute&r_page=0')
					.then(function(response) {
						if (typeof response.data === 'object') {
							return response.data;
						} else {
							return $q.reject("raptorReportFactory: getSearchData did not return a valid JSON object.");
						}
					}, function(response) {
						// something went wrong
						return $q.reject("raptorReportFactory: getSearchData callback failed");				
					});
		},

		getSearchDataAtPage : function(pageSearchParameter) {
			return $http
					.get('raptor.htm?action=report.search.execute&r_page='+pageSearchParameter)
					.then(function(response) {
						if (typeof response.data === 'object') {
							return response.data;
						} else {
							return $q.reject("raptorReportFactory: getSearchDataAtPage did not return a valid JSON object.");
						}
					}, function(response) {
						// something went wrong
						return $q.reject("raptorReportFactory: getSearchDataAtPage callback failed");				
					});
		},
		getReportDeleteStatus : function(deleteUrl) {
			return $http.get(deleteUrl).then(function(response) {
				if (typeof response.data === 'object') {
					return response.data;
				} else {
					return $q.reject("raptorReportFactory: getReportDeleteStatus did not return a valid JSON object.");
				}

			}, function(response) {
				// something went wrong
				return $q.reject("raptorReportFactory: getReportDeleteStatus callback failed");				
			});
		}
	};
});