1 appDS2.factory('raptorReportFactory', function($http, $q) {
3 getDefinitionByReportId: function(reportId) {
6 url: "report/wizard/retrieve_def_tab_wise_data/"+reportId,
7 }).then(function(response) {
8 if (typeof response.data === 'object') {
11 return $q.reject("raptorReportFactory: getDefinitionByReportId did not return a valid JSON object.");
13 }, function(response) {
14 // something went wrong
15 return $q.reject("raptorReportFactory: getDefinitionByReportId callback failed");
18 getDefinitionByReportId: function(reportId) {
21 url: "report/wizard/retrieve_def_tab_wise_data/"+reportId,
22 }).then(function(response) {
23 if (typeof response.data === 'object') {
26 return $q.reject("raptorReportFactory: getDefinitionByReportId did not return a valid JSON object.");
28 }, function(response) {
29 // something went wrong
30 return $q.reject("raptorReportFactory: getDefinitionByReportId callback failed");
33 getDefinitionInSession: function() {
36 url: "report/wizard/retrieve_def_tab_wise_data/InSession",
37 }).then(function(response) {
38 if (typeof response.data === 'object') {
41 return $q.reject("raptorReportFactory: getDefinitionInSession did not return a valid JSON object.");
43 }, function(response) {
44 // something went wrong
45 return $q.reject("raptorReportFactory: getDefinitionInSession callback failed");
49 createNewDefinition: function() {
52 url: "report/wizard/retrieve_def_tab_wise_data/Create",
53 }).then(function(response) {
54 if (typeof response.data === 'object') {
57 return $q.reject("raptorReportFactory: createNewDefinition did not return a valid JSON object.");
59 }, function(response) {
60 // something went wrong
61 return $q.reject("raptorReportFactory: createNewDefinition callback failed");
64 updateDefinition: function(updatedJson,isUpdate) {
67 url: (isUpdate?("report/wizard/save_def_tab_data/"+updatedJson.reportId):"report/wizard/save_def_tab_data/Create"),
69 }).then(function(response) {
70 if (typeof response.data === 'object') {
73 return $q.reject("raptorReportFactory: updateDefinition did not return a valid JSON object.");
76 }, function(response) {
77 // something went wrong
78 return $q.reject("raptorReportFactory: updateDefinition callback failed");
81 saveNewDefinition: function(updatedJson) {
84 url: "report/wizard/save_def_tab_data/InSession",
86 }).then(function(response) {
87 if (typeof response.data === 'object') {
90 return $q.reject("raptorReportFactory: saveNewDefinition did not return a valid JSON object.");
92 }, function(response) {
93 // something went wrong
94 return $q.reject("raptorReportFactory: saveNewDefinition callback failed");
97 getSqlInSession: function() {
100 url: "report/wizard/retrieve_sql_tab_wise_data/InSession",
101 }).then(function(response) {
102 if (typeof response.data === 'object') {
103 return response.data;
105 return $q.reject("raptorReportFactory: getSqlInSession did not return a valid JSON object.");
107 }, function(response) {
108 // something went wrong
109 return $q.reject("raptorReportFactory: getSqlInSession callback failed");
112 testRunSQL: function(queryJSON) {
115 url: "report/wizard/retrieve_data/true",
117 }).then(function(response) {
118 if (typeof response.data === 'object') {
119 return JSON.parse(response.data.data.elements);
121 return $q.reject("raptorReportFactory: testRunSQL did not return a valid JSON object.");
123 return response.data;
124 }, function(response) {
125 // something went wrong
126 return $q.reject("raptorReportFactory: testRunSQL callback failed");
129 formFieldVerifySQL: function(queryJSON) {
132 url: "report/wizard/retrieve_data/false",
134 }).then(function(response) {
135 if (typeof response.data === 'object') {
136 return JSON.parse(response.data.data.elements);
138 return $q.reject("raptorReportFactory: formFieldVerifySQL did not return a valid JSON object.");
140 return response.data;
141 }, function(response) {
142 // something went wrong
143 return $q.reject("raptorReportFactory: formFieldVerifySQL callback failed");
146 getColumnList: function() {
149 url: "report/wizard/list_columns",
150 }).then(function(response) {
151 if (typeof response.data === 'object') {
152 return response.data;
154 return $q.reject("raptorReportFactory: getColumnList did not return a valid JSON object.");
156 return response.data;
157 }, function(response) {
158 // something went wrong
159 return $q.reject("raptorReportFactory: getColumnList callback failed");
162 getDrillDownReportList: function() {
165 url: "report/wizard/list_drilldown_reports",
166 }).then(function(response) {
167 if (typeof response.data === 'object') {
168 return response.data;
170 return $q.reject("raptorReportFactory: getDrillDownReportList did not return a valid JSON object.");
172 return response.data;
173 }, function(response) {
174 // something went wrong
175 return $q.reject("raptorReportFactory: getDrillDownReportList callback failed");
178 getTotalColList: function() {
181 url: "report/wizard/list_drilldown_reports",
182 }).then(function(response) {
183 if (typeof response.data === 'object') {
184 return response.data;
186 return $q.reject("raptorReportFactory: getDrillDownReportList did not return a valid JSON object.");
188 return response.data;
189 }, function(response) {
190 // something went wrong
191 return $q.reject("raptorReportFactory: getDrillDownReportList callback failed");
194 getTotalForTheColList : function(){
197 url: "report/wizard/retrieveTotalForTheColList",
198 }).then(function(response) {
199 if (typeof response.data === 'object') {
200 return response.data;
202 return $q.reject("raptorReportFactory: retrieveTotalForTheColList did not return a valid JSON object.");
204 return response.data;
205 }, function(response) {
206 // something went wrong
207 return $q.reject("raptorReportFactory: retrieveTotalForTheColList callback failed");
210 getChildReportFormField: function(reportId) {
213 url: "report/wizard/list_child_report_ff/"+reportId,
214 }).then(function(response) {
215 if (typeof response.data === 'object') {
216 return response.data;
218 return $q.reject("raptorReportFactory: getDrillDownReportList did not return a valid JSON object.");
220 return response.data;
221 }, function(response) {
222 // something went wrong
223 return $q.reject("raptorReportFactory: getDrillDownReportList callback failed");
226 getChildReportColumn: function(reportId) {
229 url: "report/wizard/list_child_report_col/"+reportId,
230 }).then(function(response) {
231 if (typeof response.data === 'object') {
232 return response.data;
234 return $q.reject("raptorReportFactory: getChildReportColumn did not return a valid JSON object.");
236 return response.data;
237 }, function(response) {
238 // something went wrong
239 return $q.reject("raptorReportFactory: getChildReportColumn callback failed");
242 getColumnEditInfoById: function(columnId){
245 url: "report/wizard/retrieve_col_tab_wise_data/"+columnId,
246 }).then(function(response) {
247 if (typeof response.data === 'object') {
248 return response.data;
250 return $q.reject("raptorReportFactory: getColumnEditInfoById did not return a valid JSON object.");
252 }, function(response) {
253 // something went wrong
254 return $q.reject("raptorReportFactory: getColumnEditInfoById callback failed");
257 saveColumnEditInfo: function(updatedColumnJson){
260 url: "report/wizard/save_col_tab_data",
261 data: updatedColumnJson
262 }).then(function(response) {
263 if (typeof response.data === 'object') {
264 return response.data;
266 return $q.reject("raptorReportFactory: saveColumnEditInfo did not return a valid JSON object.");
268 }, function(response) {
269 // something went wrong
270 return $q.reject("raptorReportFactory: saveColumnEditInfo callback failed");
273 postImportXml: function(importXMLJSON){
276 url: "report/wizard/import_report",
278 }).then(function(response) {
279 if (typeof response.data === 'object') {
280 return response.data;
282 return $q.reject("raptorReportFactory: importXml did not return a valid JSON object.");
284 }, function(response) {
285 // something went wrong
286 return $q.reject("raptorReportFactory: importXml callback failed");
289 copyReportById: function(reportId) {
292 url: "report/wizard/copy_report/"+reportId,
293 }).then(function(response) {
294 if (typeof response.data === 'object') {
295 return response.data;
297 return $q.reject("raptorReportFactory: copyReportById did not return a valid JSON object.");
299 }, function(response) {
300 // something went wrong
301 return $q.reject("raptorReportFactory: copyReportById callback failed");
304 saveFormFieldEditInfo: function(updatedFormFieldJson){
307 url: "report/wizard/save_formfield_tab_data",
308 data: updatedFormFieldJson
309 }).then(function(response) {
310 if (typeof response.data === 'object') {
311 return response.data;
313 return $q.reject("raptorReportFactory: saveFormFieldEditInfo did not return a valid JSON object.");
315 }, function(response) {
316 // something went wrong
317 return $q.reject("raptorReportFactory: saveFormFieldEditInfo callback failed");
320 addFormFieldEditInfo: function(addFormFieldJson){
323 url: "report/wizard/add_formfield_tab_data",
324 data: addFormFieldJson
325 }).then(function(response) {
326 if (typeof response.data === 'object') {
327 return response.data;
329 return $q.reject("raptorReportFactory: saveFormFieldEditInfo did not return a valid JSON object.");
331 }, function(response) {
332 // something went wrong
333 return $q.reject("raptorReportFactory: saveFormFieldEditInfo callback failed");
337 getFormFieldList: function() {
340 url: "report/wizard/list_formfields",
341 }).then(function(response) {
342 if (typeof response.data === 'object') {
343 return response.data;
345 return $q.reject("raptorReportFactory: getFormFieldList did not return a valid JSON object.");
347 }, function(response) {
348 // something went wrong
349 return $q.reject("raptorReportFactory: getFormFieldList callback failed");
352 getFormFieldEditInfoById: function(fieldId){
355 url: "report/wizard/retrieve_form_tab_wise_data/"+fieldId,
356 }).then(function(response) {
357 if (typeof response.data === 'object') {
358 return response.data;
360 return $q.reject("raptorReportFactory: getColumnEditInfoById did not return a valid JSON object.");
362 return response.data;
363 }, function(response) {
364 // something went wrong
365 return $q.reject("raptorReportFactory: getFormFieldEditInfoById callback failed");
368 deleteFormFieldById: function(fieldId){
371 url: "report/wizard/retrieve_form_tab_wise_data/"+fieldId+"/delete",
372 }).then(function(response) {
373 if (typeof response.data === 'object') {
374 return response.data;
376 return $q.reject("raptorReportFactory: deleteFormFieldById did not return a valid JSON object.");
378 return response.data;
379 }, function(response) {
380 // something went wrong
381 return $q.reject("raptorReportFactory: deleteFormFieldById callback failed");
384 getColumns: function() {
386 .get('raptor.htm?action=report.search.execute&r_page=0')
387 .then(function(response) {
388 if (typeof response.data === 'object') {
389 return response.data;
391 return $q.reject("raptorReportFactory: getColumns did not return a valid JSON object.");
393 }, function(response) {
394 // something went wrong
395 return $q.reject("raptorReportFactory: getColumns callback failed");
399 getSearchData : function() {
401 .get('raptor.htm?action=report.search.execute&r_page=0')
402 .then(function(response) {
403 if (typeof response.data === 'object') {
404 return response.data;
406 return $q.reject("raptorReportFactory: getSearchData did not return a valid JSON object.");
408 }, function(response) {
409 // something went wrong
410 return $q.reject("raptorReportFactory: getSearchData callback failed");
414 getSecurityReportOwnerList: function() {
416 .get('report/wizard/security/retrieveReportOwner')
417 .then(function(response) {
418 if (typeof response.data === 'object') {
419 return response.data;
421 return $q.reject("raptorReportFactory: getSecurityReportOwnerList did not return a valid JSON object.");
423 }, function(response) {
424 // something went wrong
425 return $q.reject("raptorReportFactory: getSecurityReportOwnerList callback failed");
428 getReportRoleList: function() {
430 .get('report/wizard/security/retrieveReportRoleList')
431 .then(function(response) {
432 if (typeof response.data === 'object') {
433 return response.data;
435 return $q.reject("raptorReportFactory: getReportRoleList did not return a valid JSON object.");
437 }, function(response) {
438 // something went wrong
439 return $q.reject("raptorReportFactory: getReportRoleList callback failed");
442 getReportSecurityInfo: function() {
444 .get('report/wizard/security/getReportSecurityInfo')
445 .then(function(response) {
446 if (typeof response.data === 'object') {
447 return response.data;
449 return $q.reject("raptorReportFactory: getReportSecurityInfo did not return a valid JSON object.");
451 }, function(response) {
452 // something went wrong
453 return $q.reject("raptorReportFactory: getReportSecurityInfo callback failed");
456 getReportSecurityUsers: function() {
458 .get('report/wizard/security/retrieveReportUserList')
459 .then(function(response) {
460 if (typeof response.data === 'object') {
461 return response.data;
463 return $q.reject("raptorReportFactory: getReportSecurityUsers did not return a valid JSON object.");
465 }, function(response) {
466 // something went wrong
467 return $q.reject("raptorReportFactory: getReportSecurityUsers callback failed");
471 getReportSecurityRoles: function() {
473 .get('report/wizard/security/getReportSecurityRoles')
474 .then(function(response) {
475 if (typeof response.data === 'object') {
476 return response.data;
478 return $q.reject("raptorReportFactory: getReportSecurityUsers did not return a valid JSON object.");
480 }, function(response) {
481 // something went wrong
482 return $q.reject("raptorReportFactory: getReportSecurityUsers callback failed");
487 getSearchDataAtPage : function(pageSearchParameter) {
489 .get('raptor.htm?action=report.search.execute&r_page='+pageSearchParameter)
490 .then(function(response) {
491 if (typeof response.data === 'object') {
492 return response.data;
494 return $q.reject("raptorReportFactory: getSearchDataAtPage did not return a valid JSON object.");
496 }, function(response) {
497 // something went wrong
498 return $q.reject("raptorReportFactory: getSearchDataAtPage callback failed");
501 setDrillDownPopupOptions: function(drillDownURL,drillDownParams) {
502 this.drillDownURL = drillDownURL;
503 this.drillDownParams = drillDownParams;
505 getReportDeleteStatus : function(deleteUrl) {
506 return $http.get(deleteUrl).then(function(response) {
507 if (typeof response.data === 'object') {
508 return response.data;
510 return $q.reject("raptorReportFactory: getReportDeleteStatus did not return a valid JSON object.");
513 }, function(response) {
514 // something went wrong
515 return $q.reject("raptorReportFactory: getReportDeleteStatus callback failed");
518 addReportSecurityUser: function(UserId) {
521 url: "report/security/addReportUser",
523 }).then(function(response) {
524 if (typeof response.data === 'object') {
525 return response.data;
527 return $q.reject("raptorReportFactory: addReportSecurityUser did not return a valid JSON object.");
529 }, function(response) {
530 // something went wrong
531 return $q.reject("raptorReportFactory: saveNewDefinition callback failed");
534 removeReportSecurityUser: function(UserId) {
537 url: "report/security/removeReportUser",
539 }).then(function(response) {
540 if (typeof response.data === 'object') {
541 return response.data;
543 return $q.reject("raptorReportFactory: removeReportSecurityUser did not return a valid JSON object.");
545 }, function(response) {
546 // something went wrong
547 return $q.reject("raptorReportFactory: saveNewDefinition callback failed");
550 addReportSecurityRole: function(RoleId) {
553 url: "report/security/addReportRole",
555 }).then(function(response) {
556 if (typeof response.data === 'object') {
557 return response.data;
559 return $q.reject("raptorReportFactory: addReportSecurityRole did not return a valid JSON object.");
561 }, function(response) {
562 // something went wrong
563 return $q.reject("raptorReportFactory: saveNewDefinition callback failed");
566 removeReportSecurityRole: function(RoleId) {
569 url: "report/security/removeReportRole",
571 }).then(function(response) {
572 if (typeof response.data === 'object') {
573 return response.data;
575 return $q.reject("raptorReportFactory: removeReportSecurityRole did not return a valid JSON object.");
577 }, function(response) {
578 // something went wrong
579 return $q.reject("raptorReportFactory: removeReportSecurityRole callback failed");
582 updateReportSecurityInfo: function(securityInfo) {
585 url: "report/security/updateReportSecurityInfo",
587 }).then(function(response) {
588 if (typeof response.data === 'object') {
589 return response.data;
591 return $q.reject("raptorReportFactory: updateReportSecurityInfo did not return a valid JSON object.");
593 }, function(response) {
594 // something went wrong
595 return $q.reject("raptorReportFactory: updateReportSecurityInfo callback failed");
598 getReportLogs: function(reportId) {
601 url: "report/wizard/get_report_log/"+reportId
602 }).then(function(response) {
603 if (typeof response.data === 'object') {
604 return response.data;
606 return $q.reject("raptorReportFactory: getReportLogs did not return a valid JSON object.");
608 }, function(response) {
609 // something went wrong
610 return $q.reject("raptorReportFactory: getReportLogs callback failed");
614 toggleUserEditAccess: function(reportUser) {
615 var readOnly = reportUser.accessAllowed?"N":"Y";
618 url:"report/security/toggleUserEditAccess/"+reportUser.id,
620 }).then(function(response) {
621 if (typeof response.data === 'object') {
622 return response.data;
624 return $q.reject("raptorReportFactory: toggleUserEditAccess did not return a valid JSON object.");
626 }, function(response) {
627 // something went wrong
628 return $q.reject("raptorReportFactory: toggleUserEditAccess callback failed");
631 toggleRoleEditAccess: function(reportRole) {
632 var readOnly = reportRole.accessAllowed?"N":"Y";
635 url:"report/security/toggleRoleEditAccess/"+reportRole.id,
637 }).then(function(response) {
638 if (typeof response.data === 'object') {
639 return response.data;
641 return $q.reject("raptorReportFactory: toggleRoleEditAccess did not return a valid JSON object.");
643 }, function(response) {
644 // something went wrong
645 return $q.reject("raptorReportFactory: toggleRoleEditAccess callback failed");
648 resetSecurityLoadingCounter: function() {
649 this.securityPageApiCounter = 0;
650 this.securityPageApiTotalCount = 5;
652 icrementSecurityLoadingCounter: function() {
653 this.securityPageApiCounter = this.securityPageApiCounter+1;
655 checkSecurityLoadingCounter: function() {
656 return (this.securityPageApiCounter ==this.securityPageApiTotalCount);
658 getDrillDownParamDef: function(param) {
661 url: "report/wizard/drill_down_param/"+param
662 }).then(function(response) {
663 if (typeof response.data === 'object') {
664 return response.data;
666 return $q.reject("raptorReportFactory: getDrillDownParamDef did not return a valid JSON object.");
668 }, function(response) {
669 // something went wrong
670 return $q.reject("raptorReportFactory: getDrillDownParamDef callback failed");