Built motion from commit 97153652.|2.6.26
[motion2.git] / server / api / analyticExtractedReport / analyticExtractedReport.controller.js
index 000f8fc..37824b1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x759f=['catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','find','download','basename','savename','output','existsSync','root','server/files/reports','Sequelize','Report\x20not\x20found\x20or\x20empty','join','format','%s.%s','toLowerCase','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../mysqldb','status','json','count','offset','Content-Range','apply','reject','then','destroy','get','ExtractedReports','UserProfileResource','sendStatus','error','stack','name','send','index','map','AnalyticExtractedReport','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','nolimit','limit','order','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','params','length','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection'];(function(_0x1c1420,_0x725c67){var _0x135494=function(_0x59f14c){while(--_0x59f14c){_0x1c1420['push'](_0x1c1420['shift']());}};_0x135494(++_0x725c67);}(_0x759f,0xc9));var _0xf759=function(_0x5c3b45,_0x1ab73e){_0x5c3b45=_0x5c3b45-0x0;var _0x4fbd0b=_0x759f[_0x5c3b45];return _0x4fbd0b;};'use strict';var pdf=require(_0xf759('0x0'));var emlformat=require(_0xf759('0x1'));var rimraf=require(_0xf759('0x2'));var zipdir=require(_0xf759('0x3'));var jsonpatch=require(_0xf759('0x4'));var rp=require(_0xf759('0x5'));var moment=require(_0xf759('0x6'));var BPromise=require(_0xf759('0x7'));var Mustache=require(_0xf759('0x8'));var util=require(_0xf759('0x9'));var path=require(_0xf759('0xa'));var sox=require(_0xf759('0xb'));var csv=require(_0xf759('0xc'));var ejs=require(_0xf759('0xd'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xf759('0xe'));var jsforce=require(_0xf759('0xf'));var deskjs=require(_0xf759('0x10'));var toCsv=require(_0xf759('0xc'));var querystring=require(_0xf759('0x11'));var Papa=require(_0xf759('0x12'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xf759('0x13'));var as=require(_0xf759('0x14'));var hardwareService=require(_0xf759('0x15'));var logger=require('../../config/logger')(_0xf759('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0xf759('0x17'))['db'];function respondWithStatusCode(_0x1197ed,_0x5e5a35){_0x5e5a35=_0x5e5a35||0xcc;return function(_0x554eca){if(_0x554eca){return _0x1197ed['sendStatus'](_0x5e5a35);}return _0x1197ed[_0xf759('0x18')](_0x5e5a35)['end']();};}function respondWithResult(_0x1bb4ef,_0x42573b){_0x42573b=_0x42573b||0xc8;return function(_0x5efa8d){if(_0x5efa8d){return _0x1bb4ef['status'](_0x42573b)[_0xf759('0x19')](_0x5efa8d);}};}function respondWithFilteredResult(_0x17249a,_0x65a392){return function(_0x33fb44){if(_0x33fb44){var _0x13da01=_0x33fb44[_0xf759('0x1a')],_0x4d9cf0=_0x65a392[_0xf759('0x1b')],_0x52a22f=_0x65a392[_0xf759('0x1b')]+_0x65a392['limit'],_0x43f80c;if(_0x52a22f>=_0x13da01){_0x52a22f=_0x13da01;_0x43f80c=0xc8;}else{_0x43f80c=0xce;}_0x17249a['status'](_0x43f80c);return _0x17249a['set'](_0xf759('0x1c'),_0x4d9cf0+'-'+_0x52a22f+'/'+_0x13da01)[_0xf759('0x19')](_0x33fb44);}return null;};}function patchUpdates(_0x2d0e01){return function(_0x544cad){try{jsonpatch[_0xf759('0x1d')](_0x544cad,_0x2d0e01,!![]);}catch(_0x579dc2){return BPromise[_0xf759('0x1e')](_0x579dc2);}return _0x544cad['save']();};}function saveUpdates(_0x1d8f11,_0x4950ac){return function(_0x2814be){if(_0x2814be){return _0x2814be['update'](_0x1d8f11)[_0xf759('0x1f')](function(_0x59932e){return _0x59932e;});}return null;};}function removeEntity(_0x495e89,_0x52af87){return function(_0x2fff0d){if(_0x2fff0d){return _0x2fff0d[_0xf759('0x20')]()[_0xf759('0x1f')](function(){var _0x269f40=_0x2fff0d[_0xf759('0x21')]({'plain':!![]});var _0x331f13=_0xf759('0x22');return db[_0xf759('0x23')][_0xf759('0x20')]({'where':{'type':_0x331f13,'resourceId':_0x269f40['id']}})[_0xf759('0x1f')](function(){return _0x2fff0d;});})['then'](function(){_0x495e89['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x666f36,_0xccb116){return function(_0x1a6d83){if(!_0x1a6d83){_0x666f36[_0xf759('0x24')](0x194);}return _0x1a6d83;};}function handleError(_0x1e7f87,_0x56e470){_0x56e470=_0x56e470||0x1f4;return function(_0x1cb09e){logger[_0xf759('0x25')](_0x1cb09e[_0xf759('0x26')]);if(_0x1cb09e[_0xf759('0x27')]){delete _0x1cb09e[_0xf759('0x27')];}_0x1e7f87[_0xf759('0x18')](_0x56e470)[_0xf759('0x28')](_0x1cb09e);};}exports[_0xf759('0x29')]=function(_0x42b289,_0xe0a49){var _0x2bf70b={},_0x13a65f={},_0x22c92e={'count':0x0,'rows':[]};var _0x1a8385=_[_0xf759('0x2a')](db[_0xf759('0x2b')][_0xf759('0x2c')],function(_0x2f3094){return{'name':_0x2f3094[_0xf759('0x2d')],'type':_0x2f3094[_0xf759('0x2e')]['key']};});_0x13a65f[_0xf759('0x2f')]=_[_0xf759('0x2a')](_0x1a8385,_0xf759('0x27'));_0x13a65f[_0xf759('0x30')]=_[_0xf759('0x31')](_0x42b289[_0xf759('0x30')]);_0x13a65f[_0xf759('0x32')]=_[_0xf759('0x33')](_0x13a65f[_0xf759('0x2f')],_0x13a65f[_0xf759('0x30')]);_0x2bf70b[_0xf759('0x34')]=_['intersection'](_0x13a65f['model'],qs[_0xf759('0x35')](_0x42b289[_0xf759('0x30')][_0xf759('0x35')]));_0x2bf70b['attributes']=_0x2bf70b[_0xf759('0x34')]['length']?_0x2bf70b['attributes']:_0x13a65f[_0xf759('0x2f')];if(!_0x42b289[_0xf759('0x30')]['hasOwnProperty'](_0xf759('0x36'))){_0x2bf70b[_0xf759('0x37')]=qs[_0xf759('0x37')](_0x42b289[_0xf759('0x30')][_0xf759('0x37')]);_0x2bf70b[_0xf759('0x1b')]=qs[_0xf759('0x1b')](_0x42b289[_0xf759('0x30')][_0xf759('0x1b')]);}_0x2bf70b[_0xf759('0x38')]=qs['sort'](_0x42b289[_0xf759('0x30')]['sort']);_0x2bf70b[_0xf759('0x39')]=qs[_0xf759('0x32')](_[_0xf759('0x3a')](_0x42b289[_0xf759('0x30')],_0x13a65f['filters']),_0x1a8385);if(_0x42b289[_0xf759('0x30')]['filter']){_0x2bf70b[_0xf759('0x39')]=_[_0xf759('0x3b')](_0x2bf70b['where'],{'$or':_[_0xf759('0x2a')](_0x1a8385,function(_0x1fa190){if(_0x1fa190['type']!==_0xf759('0x3c')){var _0x540d1e={};_0x540d1e[_0x1fa190[_0xf759('0x27')]]={'$like':'%'+_0x42b289[_0xf759('0x30')][_0xf759('0x3d')]+'%'};return _0x540d1e;}})});}_0x2bf70b=_[_0xf759('0x3b')]({},_0x2bf70b,_0x42b289[_0xf759('0x3e')]);var _0x3fe491={'where':_0x2bf70b[_0xf759('0x39')]};return db['AnalyticExtractedReport']['count'](_0x3fe491)[_0xf759('0x1f')](function(_0x39af8c){_0x22c92e[_0xf759('0x1a')]=_0x39af8c;if(_0x42b289['query'][_0xf759('0x3f')]){_0x2bf70b[_0xf759('0x40')]=[{'all':!![]}];}return db[_0xf759('0x2b')][_0xf759('0x41')](_0x2bf70b);})[_0xf759('0x1f')](function(_0x5c67cc){_0x22c92e[_0xf759('0x42')]=_0x5c67cc;return _0x22c92e;})[_0xf759('0x1f')](respondWithFilteredResult(_0xe0a49,_0x2bf70b))['catch'](handleError(_0xe0a49,null));};exports['show']=function(_0xad3bf7,_0xebe103){var _0x22044d={'raw':!![],'where':{'id':_0xad3bf7[_0xf759('0x43')]['id']}},_0x50372a={};_0x50372a[_0xf759('0x2f')]=_[_0xf759('0x31')](db[_0xf759('0x2b')][_0xf759('0x2c')]);_0x50372a[_0xf759('0x30')]=_[_0xf759('0x31')](_0xad3bf7[_0xf759('0x30')]);_0x50372a[_0xf759('0x32')]=_[_0xf759('0x33')](_0x50372a[_0xf759('0x2f')],_0x50372a[_0xf759('0x30')]);_0x22044d[_0xf759('0x34')]=_[_0xf759('0x33')](_0x50372a[_0xf759('0x2f')],qs[_0xf759('0x35')](_0xad3bf7[_0xf759('0x30')][_0xf759('0x35')]));_0x22044d[_0xf759('0x34')]=_0x22044d[_0xf759('0x34')][_0xf759('0x44')]?_0x22044d[_0xf759('0x34')]:_0x50372a[_0xf759('0x2f')];if(_0xad3bf7[_0xf759('0x30')][_0xf759('0x3f')]){_0x22044d['include']=[{'all':!![]}];}_0x22044d=_[_0xf759('0x3b')]({},_0x22044d,_0xad3bf7[_0xf759('0x3e')]);return db[_0xf759('0x2b')]['find'](_0x22044d)[_0xf759('0x1f')](handleEntityNotFound(_0xebe103,null))[_0xf759('0x1f')](respondWithResult(_0xebe103,null))['catch'](handleError(_0xebe103,null));};exports[_0xf759('0x45')]=function(_0x541455,_0x2f1d25){return db[_0xf759('0x2b')][_0xf759('0x45')](_0x541455[_0xf759('0x46')],{})[_0xf759('0x1f')](function(_0x3f4fe0){var _0x128a48=_0x541455[_0xf759('0x47')][_0xf759('0x21')]({'plain':!![]});if(!_0x128a48)throw new Error(_0xf759('0x48'));if(_0x128a48[_0xf759('0x49')]===_0xf759('0x47')){var _0x354edb=_0x3f4fe0[_0xf759('0x21')]({'plain':!![]});var _0x32f470='ExtractedReports';return db[_0xf759('0x4a')]['find']({'where':{'name':_0x32f470,'userProfileId':_0x128a48['userProfileId']},'raw':!![]})[_0xf759('0x1f')](function(_0x3c75b8){if(_0x3c75b8&&_0x3c75b8['autoAssociation']===0x0){return db[_0xf759('0x23')]['create']({'name':_0x354edb[_0xf759('0x27')],'resourceId':_0x354edb['id'],'type':_0x3c75b8[_0xf759('0x27')],'sectionId':_0x3c75b8['id']},{})[_0xf759('0x1f')](function(){return _0x3f4fe0;});}else{return _0x3f4fe0;}})[_0xf759('0x4b')](function(_0x522ede){logger[_0xf759('0x25')](_0xf759('0x4c'),_0x522ede);throw _0x522ede;});}return _0x3f4fe0;})[_0xf759('0x1f')](respondWithResult(_0x2f1d25,0xc9))['catch'](handleError(_0x2f1d25,null));};exports[_0xf759('0x4d')]=function(_0x5d5c44,_0x193063){if(_0x5d5c44[_0xf759('0x46')]['id']){delete _0x5d5c44[_0xf759('0x46')]['id'];}return db[_0xf759('0x2b')][_0xf759('0x4e')]({'where':{'id':_0x5d5c44[_0xf759('0x43')]['id']}})[_0xf759('0x1f')](handleEntityNotFound(_0x193063,null))[_0xf759('0x1f')](saveUpdates(_0x5d5c44[_0xf759('0x46')],null))[_0xf759('0x1f')](respondWithResult(_0x193063,null))[_0xf759('0x4b')](handleError(_0x193063,null));};exports[_0xf759('0x20')]=function(_0x537e7d,_0x3e40d1){return db[_0xf759('0x2b')][_0xf759('0x4e')]({'where':{'id':_0x537e7d['params']['id']}})[_0xf759('0x1f')](handleEntityNotFound(_0x3e40d1,null))['then'](removeEntity(_0x3e40d1,null))[_0xf759('0x4b')](handleError(_0x3e40d1,null));};exports[_0xf759('0x4f')]=function(_0x2fc8c6,_0x4135d8,_0x1afb10){return db[_0xf759('0x2b')]['find']({'where':{'id':_0x2fc8c6['params']['id']},'attributes':[_0xf759('0x27'),_0xf759('0x50'),_0xf759('0x51'),_0xf759('0x52')],'raw':!![]})['then'](handleEntityNotFound(_0x4135d8,null))[_0xf759('0x1f')](function(_0x18e209){if(_0x18e209){if(!fs[_0xf759('0x53')](path['join'](config[_0xf759('0x54')],_0xf759('0x55'),_0x18e209[_0xf759('0x51')]))){throw new db[(_0xf759('0x56'))]['ValidationError'](_0xf759('0x57'));}if(_0x2fc8c6[_0xf759('0x30')]['exists']){return _0x4135d8[_0xf759('0x24')](0xc8);}return _0x4135d8['download'](path[_0xf759('0x58')](config[_0xf759('0x54')],_0xf759('0x55'),_0x18e209['savename']),util[_0xf759('0x59')](_0xf759('0x5a'),_0x18e209[_0xf759('0x50')]||_0x18e209[_0xf759('0x27')],_0x18e209[_0xf759('0x52')][_0xf759('0x5b')]()));}})['catch'](handleError(_0x4135d8,null));};
\ No newline at end of file
+var _0x0cd2=['get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','body','download','basename','savename','output','existsSync','server/files/reports','Sequelize','Report\x20not\x20found\x20or\x20empty','exists','root','format','%s.%s','toLowerCase','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','then','ExtractedReports','UserProfileResource','destroy','error','stack','name','send','index','map','AnalyticExtractedReport','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','show','params','keys','catch','create','user'];(function(_0xdbd0c8,_0x35da4c){var _0x2f23cf=function(_0x352ecb){while(--_0x352ecb){_0xdbd0c8['push'](_0xdbd0c8['shift']());}};_0x2f23cf(++_0x35da4c);}(_0x0cd2,0x78));var _0x20cd=function(_0x3959fc,_0x32b4f8){_0x3959fc=_0x3959fc-0x0;var _0x4e438e=_0x0cd2[_0x3959fc];return _0x4e438e;};'use strict';var emlformat=require(_0x20cd('0x0'));var rimraf=require(_0x20cd('0x1'));var zipdir=require(_0x20cd('0x2'));var jsonpatch=require(_0x20cd('0x3'));var rp=require(_0x20cd('0x4'));var moment=require(_0x20cd('0x5'));var BPromise=require(_0x20cd('0x6'));var Mustache=require(_0x20cd('0x7'));var util=require('util');var path=require(_0x20cd('0x8'));var sox=require(_0x20cd('0x9'));var csv=require('to-csv');var ejs=require(_0x20cd('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x20cd('0xb'));var crypto=require(_0x20cd('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x20cd('0xd'));var toCsv=require(_0x20cd('0xe'));var querystring=require(_0x20cd('0xf'));var Papa=require(_0x20cd('0x10'));var Redis=require(_0x20cd('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x20cd('0x12'));var as=require(_0x20cd('0x13'));var hardwareService=require(_0x20cd('0x14'));var logger=require(_0x20cd('0x15'))('api');var utils=require(_0x20cd('0x16'));var config=require(_0x20cd('0x17'));var licenseUtil=require(_0x20cd('0x18'));var db=require(_0x20cd('0x19'))['db'];function respondWithStatusCode(_0x236aaa,_0x4e05c1){_0x4e05c1=_0x4e05c1||0xcc;return function(_0x54793d){if(_0x54793d){return _0x236aaa[_0x20cd('0x1a')](_0x4e05c1);}return _0x236aaa[_0x20cd('0x1b')](_0x4e05c1)[_0x20cd('0x1c')]();};}function respondWithResult(_0x4a9c61,_0x648885){_0x648885=_0x648885||0xc8;return function(_0x4017c3){if(_0x4017c3){return _0x4a9c61[_0x20cd('0x1b')](_0x648885)[_0x20cd('0x1d')](_0x4017c3);}};}function respondWithFilteredResult(_0x5eecb8,_0x2eac98){return function(_0x35016d){if(_0x35016d){var _0x3269af=typeof _0x2eac98[_0x20cd('0x1e')]===_0x20cd('0x1f')&&typeof _0x2eac98[_0x20cd('0x20')]===_0x20cd('0x1f');var _0x2bdabf=_0x35016d[_0x20cd('0x21')];var _0x87aafa=_0x3269af?0x0:_0x2eac98[_0x20cd('0x1e')];var _0x50666e=_0x3269af?_0x35016d[_0x20cd('0x21')]:_0x2eac98[_0x20cd('0x1e')]+_0x2eac98[_0x20cd('0x20')];var _0x14d4f1;if(_0x50666e>=_0x2bdabf){_0x50666e=_0x2bdabf;_0x14d4f1=0xc8;}else{_0x14d4f1=0xce;}_0x5eecb8[_0x20cd('0x1b')](_0x14d4f1);return _0x5eecb8[_0x20cd('0x22')](_0x20cd('0x23'),_0x87aafa+'-'+_0x50666e+'/'+_0x2bdabf)[_0x20cd('0x1d')](_0x35016d);}return null;};}function patchUpdates(_0xafa0b7){return function(_0x4db5f4){try{jsonpatch[_0x20cd('0x24')](_0x4db5f4,_0xafa0b7,!![]);}catch(_0x521218){return BPromise['reject'](_0x521218);}return _0x4db5f4[_0x20cd('0x25')]();};}function saveUpdates(_0x27238d,_0x5511a4){return function(_0x3328f5){if(_0x3328f5){return _0x3328f5[_0x20cd('0x26')](_0x27238d)[_0x20cd('0x27')](function(_0x587e53){return _0x587e53;});}return null;};}function removeEntity(_0x2f5a89,_0x5e0a22){return function(_0x1d6e1){if(_0x1d6e1){return _0x1d6e1['destroy']()[_0x20cd('0x27')](function(){var _0x4cdeed=_0x1d6e1['get']({'plain':!![]});var _0x3672c6=_0x20cd('0x28');return db[_0x20cd('0x29')][_0x20cd('0x2a')]({'where':{'type':_0x3672c6,'resourceId':_0x4cdeed['id']}})['then'](function(){return _0x1d6e1;});})[_0x20cd('0x27')](function(){_0x2f5a89[_0x20cd('0x1b')](0xcc)[_0x20cd('0x1c')]();});}};}function handleEntityNotFound(_0x5397fa,_0x48b83f){return function(_0x4d097f){if(!_0x4d097f){_0x5397fa[_0x20cd('0x1a')](0x194);}return _0x4d097f;};}function handleError(_0x50a5d3,_0x17220d){_0x17220d=_0x17220d||0x1f4;return function(_0x40b41f){logger[_0x20cd('0x2b')](_0x40b41f[_0x20cd('0x2c')]);if(_0x40b41f[_0x20cd('0x2d')]){delete _0x40b41f['name'];}_0x50a5d3[_0x20cd('0x1b')](_0x17220d)[_0x20cd('0x2e')](_0x40b41f);};}exports[_0x20cd('0x2f')]=function(_0x559521,_0xf66613){var _0x2fa96d={},_0x112bec={},_0x20fa63={'count':0x0,'rows':[]};var _0x3f552c=_[_0x20cd('0x30')](db[_0x20cd('0x31')][_0x20cd('0x32')],function(_0x4498d9){return{'name':_0x4498d9[_0x20cd('0x33')],'type':_0x4498d9[_0x20cd('0x34')][_0x20cd('0x35')]};});_0x112bec[_0x20cd('0x36')]=_[_0x20cd('0x30')](_0x3f552c,_0x20cd('0x2d'));_0x112bec['query']=_['keys'](_0x559521[_0x20cd('0x37')]);_0x112bec[_0x20cd('0x38')]=_[_0x20cd('0x39')](_0x112bec[_0x20cd('0x36')],_0x112bec['query']);_0x2fa96d[_0x20cd('0x3a')]=_[_0x20cd('0x39')](_0x112bec[_0x20cd('0x36')],qs[_0x20cd('0x3b')](_0x559521[_0x20cd('0x37')][_0x20cd('0x3b')]));_0x2fa96d['attributes']=_0x2fa96d[_0x20cd('0x3a')][_0x20cd('0x3c')]?_0x2fa96d[_0x20cd('0x3a')]:_0x112bec[_0x20cd('0x36')];if(!_0x559521[_0x20cd('0x37')][_0x20cd('0x3d')](_0x20cd('0x3e'))){_0x2fa96d[_0x20cd('0x20')]=qs[_0x20cd('0x20')](_0x559521[_0x20cd('0x37')]['limit']);_0x2fa96d[_0x20cd('0x1e')]=qs[_0x20cd('0x1e')](_0x559521[_0x20cd('0x37')][_0x20cd('0x1e')]);}_0x2fa96d[_0x20cd('0x3f')]=qs[_0x20cd('0x40')](_0x559521['query'][_0x20cd('0x40')]);_0x2fa96d[_0x20cd('0x41')]=qs[_0x20cd('0x38')](_[_0x20cd('0x42')](_0x559521[_0x20cd('0x37')],_0x112bec[_0x20cd('0x38')]),_0x3f552c);if(_0x559521[_0x20cd('0x37')][_0x20cd('0x43')]){_0x2fa96d[_0x20cd('0x41')]=_[_0x20cd('0x44')](_0x2fa96d[_0x20cd('0x41')],{'$or':_[_0x20cd('0x30')](_0x3f552c,function(_0x1de35e){if(_0x1de35e[_0x20cd('0x34')]!==_0x20cd('0x45')){var _0x4019b2={};_0x4019b2[_0x1de35e[_0x20cd('0x2d')]]={'$like':'%'+_0x559521[_0x20cd('0x37')][_0x20cd('0x43')]+'%'};return _0x4019b2;}})});}_0x2fa96d=_[_0x20cd('0x44')]({},_0x2fa96d,_0x559521['options']);var _0x144260={'where':_0x2fa96d[_0x20cd('0x41')]};return db[_0x20cd('0x31')][_0x20cd('0x21')](_0x144260)[_0x20cd('0x27')](function(_0x13ac3b){_0x20fa63[_0x20cd('0x21')]=_0x13ac3b;if(_0x559521[_0x20cd('0x37')][_0x20cd('0x46')]){_0x2fa96d[_0x20cd('0x47')]=[{'all':!![]}];}return db['AnalyticExtractedReport']['findAll'](_0x2fa96d);})[_0x20cd('0x27')](function(_0x2a8a90){_0x20fa63['rows']=_0x2a8a90;return _0x20fa63;})[_0x20cd('0x27')](respondWithFilteredResult(_0xf66613,_0x2fa96d))['catch'](handleError(_0xf66613,null));};exports[_0x20cd('0x48')]=function(_0x14a9d5,_0x2b91d8){var _0x4371a9={'raw':!![],'where':{'id':_0x14a9d5[_0x20cd('0x49')]['id']}},_0x44bf52={};_0x44bf52[_0x20cd('0x36')]=_[_0x20cd('0x4a')](db[_0x20cd('0x31')]['rawAttributes']);_0x44bf52['query']=_[_0x20cd('0x4a')](_0x14a9d5['query']);_0x44bf52[_0x20cd('0x38')]=_[_0x20cd('0x39')](_0x44bf52[_0x20cd('0x36')],_0x44bf52[_0x20cd('0x37')]);_0x4371a9['attributes']=_[_0x20cd('0x39')](_0x44bf52[_0x20cd('0x36')],qs['fields'](_0x14a9d5[_0x20cd('0x37')][_0x20cd('0x3b')]));_0x4371a9[_0x20cd('0x3a')]=_0x4371a9['attributes'][_0x20cd('0x3c')]?_0x4371a9[_0x20cd('0x3a')]:_0x44bf52[_0x20cd('0x36')];if(_0x14a9d5[_0x20cd('0x37')][_0x20cd('0x46')]){_0x4371a9['include']=[{'all':!![]}];}_0x4371a9=_[_0x20cd('0x44')]({},_0x4371a9,_0x14a9d5['options']);return db[_0x20cd('0x31')]['find'](_0x4371a9)['then'](handleEntityNotFound(_0x2b91d8,null))[_0x20cd('0x27')](respondWithResult(_0x2b91d8,null))[_0x20cd('0x4b')](handleError(_0x2b91d8,null));};exports['create']=function(_0x28eaeb,_0x4ffb22){return db[_0x20cd('0x31')][_0x20cd('0x4c')](_0x28eaeb['body'],{})[_0x20cd('0x27')](function(_0x4e934c){var _0x63830a=_0x28eaeb[_0x20cd('0x4d')][_0x20cd('0x4e')]({'plain':!![]});if(!_0x63830a)throw new Error(_0x20cd('0x4f'));if(_0x63830a[_0x20cd('0x50')]===_0x20cd('0x4d')){var _0xe35381=_0x4e934c['get']({'plain':!![]});var _0x7ad8cb=_0x20cd('0x28');return db[_0x20cd('0x51')][_0x20cd('0x52')]({'where':{'name':_0x7ad8cb,'userProfileId':_0x63830a[_0x20cd('0x53')]},'raw':!![]})[_0x20cd('0x27')](function(_0x46e44c){if(_0x46e44c&&_0x46e44c[_0x20cd('0x54')]===0x0){return db[_0x20cd('0x29')][_0x20cd('0x4c')]({'name':_0xe35381['name'],'resourceId':_0xe35381['id'],'type':_0x46e44c[_0x20cd('0x2d')],'sectionId':_0x46e44c['id']},{})[_0x20cd('0x27')](function(){return _0x4e934c;});}else{return _0x4e934c;}})[_0x20cd('0x4b')](function(_0x34df8d){logger[_0x20cd('0x2b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x34df8d);throw _0x34df8d;});}return _0x4e934c;})['then'](respondWithResult(_0x4ffb22,0xc9))[_0x20cd('0x4b')](handleError(_0x4ffb22,null));};exports['update']=function(_0x57fa01,_0x46964f){if(_0x57fa01[_0x20cd('0x55')]['id']){delete _0x57fa01['body']['id'];}return db[_0x20cd('0x31')][_0x20cd('0x52')]({'where':{'id':_0x57fa01[_0x20cd('0x49')]['id']}})[_0x20cd('0x27')](handleEntityNotFound(_0x46964f,null))[_0x20cd('0x27')](saveUpdates(_0x57fa01[_0x20cd('0x55')],null))[_0x20cd('0x27')](respondWithResult(_0x46964f,null))['catch'](handleError(_0x46964f,null));};exports[_0x20cd('0x2a')]=function(_0x1eacf9,_0x245073){return db[_0x20cd('0x31')]['find']({'where':{'id':_0x1eacf9['params']['id']}})['then'](handleEntityNotFound(_0x245073,null))['then'](removeEntity(_0x245073,null))[_0x20cd('0x4b')](handleError(_0x245073,null));};exports[_0x20cd('0x56')]=function(_0x424bd9,_0x2b1288,_0x1c3dbb){return db[_0x20cd('0x31')][_0x20cd('0x52')]({'where':{'id':_0x424bd9['params']['id']},'attributes':['name',_0x20cd('0x57'),_0x20cd('0x58'),_0x20cd('0x59')],'raw':!![]})[_0x20cd('0x27')](handleEntityNotFound(_0x2b1288,null))['then'](function(_0x3b8f62){if(_0x3b8f62){if(!fs[_0x20cd('0x5a')](path['join'](config['root'],_0x20cd('0x5b'),_0x3b8f62[_0x20cd('0x58')]))){throw new db[(_0x20cd('0x5c'))]['ValidationError'](_0x20cd('0x5d'));}if(_0x424bd9[_0x20cd('0x37')][_0x20cd('0x5e')]){return _0x2b1288['sendStatus'](0xc8);}return _0x2b1288['download'](path['join'](config[_0x20cd('0x5f')],_0x20cd('0x5b'),_0x3b8f62[_0x20cd('0x58')]),util[_0x20cd('0x60')](_0x20cd('0x61'),_0x3b8f62[_0x20cd('0x57')]||_0x3b8f62[_0x20cd('0x2d')],_0x3b8f62[_0x20cd('0x59')][_0x20cd('0x62')]()));}})[_0x20cd('0x4b')](handleError(_0x2b1288,null));};
\ No newline at end of file