Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / api / analyticExtractedReport / analyticExtractedReport.controller.js
index 172c38b..800bc5c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9c97=['key','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','map','merge','options','AnalyticExtractedReport','includeAll','include','rows','show','find','catch','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','body','params','download','basename','savename','output','existsSync','join','root','Sequelize','ValidationError','Report\x20not\x20found\x20or\x20empty','exists','format','%s.%s','toLowerCase','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','sox','to-csv','ejs','fs-extra','squel','crypto','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','status','end','json','offset','limit','count','set','save','update','destroy','get','ExtractedReports','UserProfileResource','then','sendStatus','stack','name','send','index','rawAttributes','fieldName'];(function(_0x307194,_0x5aebd0){var _0x4c9683=function(_0x43e29f){while(--_0x43e29f){_0x307194['push'](_0x307194['shift']());}};_0x4c9683(++_0x5aebd0);}(_0x9c97,0x8e));var _0x79c9=function(_0x43ae49,_0x358bf4){_0x43ae49=_0x43ae49-0x0;var _0xd1b8d=_0x9c97[_0x43ae49];return _0xd1b8d;};'use strict';var emlformat=require(_0x79c9('0x0'));var rimraf=require(_0x79c9('0x1'));var zipdir=require(_0x79c9('0x2'));var jsonpatch=require(_0x79c9('0x3'));var rp=require(_0x79c9('0x4'));var moment=require(_0x79c9('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x79c9('0x6'));var util=require('util');var path=require('path');var sox=require(_0x79c9('0x7'));var csv=require(_0x79c9('0x8'));var ejs=require(_0x79c9('0x9'));var fs=require('fs');var fs_extra=require(_0x79c9('0xa'));var _=require('lodash');var squel=require(_0x79c9('0xb'));var crypto=require(_0x79c9('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x79c9('0x8'));var querystring=require(_0x79c9('0xd'));var Papa=require('papaparse');var Redis=require(_0x79c9('0xe'));var authService=require(_0x79c9('0xf'));var qs=require(_0x79c9('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x79c9('0x11'));var logger=require(_0x79c9('0x12'))(_0x79c9('0x13'));var utils=require('../../config/utils');var config=require(_0x79c9('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x124c53,_0x1b6b77){_0x1b6b77=_0x1b6b77||0xcc;return function(_0x3c2dcc){if(_0x3c2dcc){return _0x124c53['sendStatus'](_0x1b6b77);}return _0x124c53[_0x79c9('0x15')](_0x1b6b77)[_0x79c9('0x16')]();};}function respondWithResult(_0x4d094d,_0x16b866){_0x16b866=_0x16b866||0xc8;return function(_0x23eed2){if(_0x23eed2){return _0x4d094d['status'](_0x16b866)[_0x79c9('0x17')](_0x23eed2);}};}function respondWithFilteredResult(_0x1f20cd,_0x27d21c){return function(_0x3d0def){if(_0x3d0def){var _0x1981ad=typeof _0x27d21c[_0x79c9('0x18')]==='undefined'&&typeof _0x27d21c[_0x79c9('0x19')]==='undefined';var _0x456f1a=_0x3d0def[_0x79c9('0x1a')];var _0x3d2267=_0x1981ad?0x0:_0x27d21c['offset'];var _0x42ebf1=_0x1981ad?_0x3d0def[_0x79c9('0x1a')]:_0x27d21c[_0x79c9('0x18')]+_0x27d21c[_0x79c9('0x19')];var _0x443759;if(_0x42ebf1>=_0x456f1a){_0x42ebf1=_0x456f1a;_0x443759=0xc8;}else{_0x443759=0xce;}_0x1f20cd['status'](_0x443759);return _0x1f20cd[_0x79c9('0x1b')]('Content-Range',_0x3d2267+'-'+_0x42ebf1+'/'+_0x456f1a)[_0x79c9('0x17')](_0x3d0def);}return null;};}function patchUpdates(_0x1af90d){return function(_0x3993a9){try{jsonpatch['apply'](_0x3993a9,_0x1af90d,!![]);}catch(_0x9c9f69){return BPromise['reject'](_0x9c9f69);}return _0x3993a9[_0x79c9('0x1c')]();};}function saveUpdates(_0x40fedd,_0x4052b5){return function(_0x400979){if(_0x400979){return _0x400979[_0x79c9('0x1d')](_0x40fedd)['then'](function(_0x16e300){return _0x16e300;});}return null;};}function removeEntity(_0x402f06,_0x57108d){return function(_0x329756){if(_0x329756){return _0x329756[_0x79c9('0x1e')]()['then'](function(){var _0x36dd06=_0x329756[_0x79c9('0x1f')]({'plain':!![]});var _0x38efe9=_0x79c9('0x20');return db[_0x79c9('0x21')][_0x79c9('0x1e')]({'where':{'type':_0x38efe9,'resourceId':_0x36dd06['id']}})['then'](function(){return _0x329756;});})[_0x79c9('0x22')](function(){_0x402f06['status'](0xcc)[_0x79c9('0x16')]();});}};}function handleEntityNotFound(_0x16a3dc,_0xc5598b){return function(_0x4f0f0b){if(!_0x4f0f0b){_0x16a3dc[_0x79c9('0x23')](0x194);}return _0x4f0f0b;};}function handleError(_0x51ac2e,_0x51162){_0x51162=_0x51162||0x1f4;return function(_0x240b83){logger['error'](_0x240b83[_0x79c9('0x24')]);if(_0x240b83[_0x79c9('0x25')]){delete _0x240b83[_0x79c9('0x25')];}_0x51ac2e['status'](_0x51162)[_0x79c9('0x26')](_0x240b83);};}exports[_0x79c9('0x27')]=function(_0x18f764,_0x266cd9){var _0x3e56ea={},_0x1ca451={},_0x461bb8={'count':0x0,'rows':[]};var _0x1af1be=_['map'](db['AnalyticExtractedReport'][_0x79c9('0x28')],function(_0x4a0752){return{'name':_0x4a0752[_0x79c9('0x29')],'type':_0x4a0752['type'][_0x79c9('0x2a')]};});_0x1ca451[_0x79c9('0x2b')]=_['map'](_0x1af1be,_0x79c9('0x25'));_0x1ca451[_0x79c9('0x2c')]=_[_0x79c9('0x2d')](_0x18f764['query']);_0x1ca451['filters']=_['intersection'](_0x1ca451[_0x79c9('0x2b')],_0x1ca451[_0x79c9('0x2c')]);_0x3e56ea[_0x79c9('0x2e')]=_[_0x79c9('0x2f')](_0x1ca451[_0x79c9('0x2b')],qs[_0x79c9('0x30')](_0x18f764[_0x79c9('0x2c')][_0x79c9('0x30')]));_0x3e56ea['attributes']=_0x3e56ea['attributes'][_0x79c9('0x31')]?_0x3e56ea[_0x79c9('0x2e')]:_0x1ca451['model'];if(!_0x18f764[_0x79c9('0x2c')][_0x79c9('0x32')](_0x79c9('0x33'))){_0x3e56ea[_0x79c9('0x19')]=qs[_0x79c9('0x19')](_0x18f764[_0x79c9('0x2c')][_0x79c9('0x19')]);_0x3e56ea[_0x79c9('0x18')]=qs['offset'](_0x18f764['query'][_0x79c9('0x18')]);}_0x3e56ea[_0x79c9('0x34')]=qs[_0x79c9('0x35')](_0x18f764['query'][_0x79c9('0x35')]);_0x3e56ea[_0x79c9('0x36')]=qs['filters'](_[_0x79c9('0x37')](_0x18f764['query'],_0x1ca451[_0x79c9('0x38')]),_0x1af1be);if(_0x18f764['query'][_0x79c9('0x39')]){_0x3e56ea[_0x79c9('0x36')]=_['merge'](_0x3e56ea[_0x79c9('0x36')],{'$or':_[_0x79c9('0x3a')](_0x1af1be,function(_0x38eb42){if(_0x38eb42['type']!=='VIRTUAL'){var _0x202ba4={};_0x202ba4[_0x38eb42[_0x79c9('0x25')]]={'$like':'%'+_0x18f764[_0x79c9('0x2c')][_0x79c9('0x39')]+'%'};return _0x202ba4;}})});}_0x3e56ea=_[_0x79c9('0x3b')]({},_0x3e56ea,_0x18f764[_0x79c9('0x3c')]);var _0x598aa={'where':_0x3e56ea[_0x79c9('0x36')]};return db[_0x79c9('0x3d')][_0x79c9('0x1a')](_0x598aa)[_0x79c9('0x22')](function(_0x3f110e){_0x461bb8[_0x79c9('0x1a')]=_0x3f110e;if(_0x18f764[_0x79c9('0x2c')][_0x79c9('0x3e')]){_0x3e56ea[_0x79c9('0x3f')]=[{'all':!![]}];}return db['AnalyticExtractedReport']['findAll'](_0x3e56ea);})[_0x79c9('0x22')](function(_0x10a3d2){_0x461bb8[_0x79c9('0x40')]=_0x10a3d2;return _0x461bb8;})[_0x79c9('0x22')](respondWithFilteredResult(_0x266cd9,_0x3e56ea))['catch'](handleError(_0x266cd9,null));};exports[_0x79c9('0x41')]=function(_0x170a37,_0x78d571){var _0x23ba77={'raw':!![],'where':{'id':_0x170a37['params']['id']}},_0x3b652a={};_0x3b652a['model']=_[_0x79c9('0x2d')](db[_0x79c9('0x3d')][_0x79c9('0x28')]);_0x3b652a[_0x79c9('0x2c')]=_['keys'](_0x170a37['query']);_0x3b652a[_0x79c9('0x38')]=_[_0x79c9('0x2f')](_0x3b652a['model'],_0x3b652a['query']);_0x23ba77['attributes']=_[_0x79c9('0x2f')](_0x3b652a[_0x79c9('0x2b')],qs[_0x79c9('0x30')](_0x170a37[_0x79c9('0x2c')]['fields']));_0x23ba77['attributes']=_0x23ba77['attributes'][_0x79c9('0x31')]?_0x23ba77[_0x79c9('0x2e')]:_0x3b652a[_0x79c9('0x2b')];if(_0x170a37['query']['includeAll']){_0x23ba77['include']=[{'all':!![]}];}_0x23ba77=_['merge']({},_0x23ba77,_0x170a37[_0x79c9('0x3c')]);return db['AnalyticExtractedReport'][_0x79c9('0x42')](_0x23ba77)[_0x79c9('0x22')](handleEntityNotFound(_0x78d571,null))[_0x79c9('0x22')](respondWithResult(_0x78d571,null))[_0x79c9('0x43')](handleError(_0x78d571,null));};exports['create']=function(_0xd05427,_0x126cc7){return db[_0x79c9('0x3d')][_0x79c9('0x44')](_0xd05427['body'],{})[_0x79c9('0x22')](function(_0x3ca751){var _0x2ece90=_0xd05427[_0x79c9('0x45')][_0x79c9('0x1f')]({'plain':!![]});if(!_0x2ece90)throw new Error(_0x79c9('0x46'));if(_0x2ece90[_0x79c9('0x47')]===_0x79c9('0x45')){var _0x1a516e=_0x3ca751['get']({'plain':!![]});var _0x4924f1=_0x79c9('0x20');return db[_0x79c9('0x48')][_0x79c9('0x42')]({'where':{'name':_0x4924f1,'userProfileId':_0x2ece90[_0x79c9('0x49')]},'raw':!![]})[_0x79c9('0x22')](function(_0xd38f4c){if(_0xd38f4c&&_0xd38f4c[_0x79c9('0x4a')]===0x0){return db[_0x79c9('0x21')]['create']({'name':_0x1a516e[_0x79c9('0x25')],'resourceId':_0x1a516e['id'],'type':_0xd38f4c[_0x79c9('0x25')],'sectionId':_0xd38f4c['id']},{})[_0x79c9('0x22')](function(){return _0x3ca751;});}else{return _0x3ca751;}})['catch'](function(_0x568b8c){logger[_0x79c9('0x4b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x568b8c);throw _0x568b8c;});}return _0x3ca751;})[_0x79c9('0x22')](respondWithResult(_0x126cc7,0xc9))[_0x79c9('0x43')](handleError(_0x126cc7,null));};exports[_0x79c9('0x1d')]=function(_0xfd22c6,_0x58260b){if(_0xfd22c6['body']['id']){delete _0xfd22c6[_0x79c9('0x4c')]['id'];}return db[_0x79c9('0x3d')]['find']({'where':{'id':_0xfd22c6[_0x79c9('0x4d')]['id']}})[_0x79c9('0x22')](handleEntityNotFound(_0x58260b,null))['then'](saveUpdates(_0xfd22c6['body'],null))[_0x79c9('0x22')](respondWithResult(_0x58260b,null))[_0x79c9('0x43')](handleError(_0x58260b,null));};exports['destroy']=function(_0x487f92,_0xbbce50){return db[_0x79c9('0x3d')][_0x79c9('0x42')]({'where':{'id':_0x487f92[_0x79c9('0x4d')]['id']}})[_0x79c9('0x22')](handleEntityNotFound(_0xbbce50,null))['then'](removeEntity(_0xbbce50,null))[_0x79c9('0x43')](handleError(_0xbbce50,null));};exports[_0x79c9('0x4e')]=function(_0x3ca078,_0x1e7898,_0x3a77ad){return db['AnalyticExtractedReport']['find']({'where':{'id':_0x3ca078[_0x79c9('0x4d')]['id']},'attributes':[_0x79c9('0x25'),_0x79c9('0x4f'),_0x79c9('0x50'),_0x79c9('0x51')],'raw':!![]})[_0x79c9('0x22')](handleEntityNotFound(_0x1e7898,null))[_0x79c9('0x22')](function(_0x2a0eb7){if(_0x2a0eb7){if(!fs[_0x79c9('0x52')](path[_0x79c9('0x53')](config[_0x79c9('0x54')],'server/files/reports',_0x2a0eb7[_0x79c9('0x50')]))){throw new db[(_0x79c9('0x55'))][(_0x79c9('0x56'))](_0x79c9('0x57'));}if(_0x3ca078[_0x79c9('0x2c')][_0x79c9('0x58')]){return _0x1e7898[_0x79c9('0x23')](0xc8);}return _0x1e7898[_0x79c9('0x4e')](path[_0x79c9('0x53')](config['root'],'server/files/reports',_0x2a0eb7[_0x79c9('0x50')]),util[_0x79c9('0x59')](_0x79c9('0x5a'),_0x2a0eb7[_0x79c9('0x4f')]||_0x2a0eb7[_0x79c9('0x25')],_0x2a0eb7[_0x79c9('0x51')][_0x79c9('0x5b')]()));}})[_0x79c9('0x43')](handleError(_0x1e7898,null));};
\ No newline at end of file
+var _0x2f11=['user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','savename','output','join','root','Sequelize','ValidationError','Report\x20not\x20found\x20or\x20empty','exists','%s.%s','toLowerCase','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','apply','reject','update','then','destroy','get','UserProfileResource','error','stack','name','send','index','map','AnalyticExtractedReport','rawAttributes','fieldName','type','key','model','query','keys','attributes','intersection','fields','length','order','sort','filters','pick','filter','where','merge','VIRTUAL','includeAll','findAll','catch','show','params','include','find','create','role'];(function(_0x19a7ba,_0x517aef){var _0x230c13=function(_0x33e4aa){while(--_0x33e4aa){_0x19a7ba['push'](_0x19a7ba['shift']());}};_0x230c13(++_0x517aef);}(_0x2f11,0xcc));var _0x12f1=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0x2f11[_0x3bf83f];return _0x22c4a9;};'use strict';var emlformat=require(_0x12f1('0x0'));var rimraf=require(_0x12f1('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x12f1('0x2'));var rp=require(_0x12f1('0x3'));var moment=require('moment');var BPromise=require(_0x12f1('0x4'));var Mustache=require(_0x12f1('0x5'));var util=require(_0x12f1('0x6'));var path=require(_0x12f1('0x7'));var sox=require(_0x12f1('0x8'));var csv=require(_0x12f1('0x9'));var ejs=require(_0x12f1('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x12f1('0xb'));var squel=require(_0x12f1('0xc'));var crypto=require(_0x12f1('0xd'));var jsforce=require(_0x12f1('0xe'));var deskjs=require(_0x12f1('0xf'));var toCsv=require(_0x12f1('0x9'));var querystring=require(_0x12f1('0x10'));var Papa=require(_0x12f1('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x12f1('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x12f1('0x13'));var logger=require(_0x12f1('0x14'))(_0x12f1('0x15'));var utils=require(_0x12f1('0x16'));var config=require(_0x12f1('0x17'));var licenseUtil=require(_0x12f1('0x18'));var db=require(_0x12f1('0x19'))['db'];function respondWithStatusCode(_0x51897a,_0x283105){_0x283105=_0x283105||0xcc;return function(_0x398261){if(_0x398261){return _0x51897a[_0x12f1('0x1a')](_0x283105);}return _0x51897a['status'](_0x283105)[_0x12f1('0x1b')]();};}function respondWithResult(_0x3f3405,_0x49bf6e){_0x49bf6e=_0x49bf6e||0xc8;return function(_0x4793d0){if(_0x4793d0){return _0x3f3405[_0x12f1('0x1c')](_0x49bf6e)[_0x12f1('0x1d')](_0x4793d0);}};}function respondWithFilteredResult(_0x5ad5a2,_0x2e167a){return function(_0x553a6c){if(_0x553a6c){var _0x2ef174=typeof _0x2e167a[_0x12f1('0x1e')]==='undefined'&&typeof _0x2e167a[_0x12f1('0x1f')]===_0x12f1('0x20');var _0xea2598=_0x553a6c[_0x12f1('0x21')];var _0x3b80c2=_0x2ef174?0x0:_0x2e167a[_0x12f1('0x1e')];var _0x2e9f1d=_0x2ef174?_0x553a6c[_0x12f1('0x21')]:_0x2e167a['offset']+_0x2e167a['limit'];var _0x164c55;if(_0x2e9f1d>=_0xea2598){_0x2e9f1d=_0xea2598;_0x164c55=0xc8;}else{_0x164c55=0xce;}_0x5ad5a2[_0x12f1('0x1c')](_0x164c55);return _0x5ad5a2[_0x12f1('0x22')](_0x12f1('0x23'),_0x3b80c2+'-'+_0x2e9f1d+'/'+_0xea2598)[_0x12f1('0x1d')](_0x553a6c);}return null;};}function patchUpdates(_0x5e807d){return function(_0x5ad5c7){try{jsonpatch[_0x12f1('0x24')](_0x5ad5c7,_0x5e807d,!![]);}catch(_0x3672b7){return BPromise[_0x12f1('0x25')](_0x3672b7);}return _0x5ad5c7['save']();};}function saveUpdates(_0x1226b8,_0xde26f4){return function(_0x4d0856){if(_0x4d0856){return _0x4d0856[_0x12f1('0x26')](_0x1226b8)[_0x12f1('0x27')](function(_0x38f759){return _0x38f759;});}return null;};}function removeEntity(_0x3cc332,_0x4c39d9){return function(_0x344c7f){if(_0x344c7f){return _0x344c7f[_0x12f1('0x28')]()[_0x12f1('0x27')](function(){var _0x4ff7c3=_0x344c7f[_0x12f1('0x29')]({'plain':!![]});var _0x534217='ExtractedReports';return db[_0x12f1('0x2a')][_0x12f1('0x28')]({'where':{'type':_0x534217,'resourceId':_0x4ff7c3['id']}})[_0x12f1('0x27')](function(){return _0x344c7f;});})['then'](function(){_0x3cc332[_0x12f1('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5856c0,_0x1f9702){return function(_0xbbb8d){if(!_0xbbb8d){_0x5856c0[_0x12f1('0x1a')](0x194);}return _0xbbb8d;};}function handleError(_0x3e7cbd,_0x5449f0){_0x5449f0=_0x5449f0||0x1f4;return function(_0x387a43){logger[_0x12f1('0x2b')](_0x387a43[_0x12f1('0x2c')]);if(_0x387a43[_0x12f1('0x2d')]){delete _0x387a43[_0x12f1('0x2d')];}_0x3e7cbd[_0x12f1('0x1c')](_0x5449f0)[_0x12f1('0x2e')](_0x387a43);};}exports[_0x12f1('0x2f')]=function(_0x459624,_0x533934){var _0x4711f4={},_0x1943ef={},_0x22d249={'count':0x0,'rows':[]};var _0x377e20=_[_0x12f1('0x30')](db[_0x12f1('0x31')][_0x12f1('0x32')],function(_0x1e372f){return{'name':_0x1e372f[_0x12f1('0x33')],'type':_0x1e372f[_0x12f1('0x34')][_0x12f1('0x35')]};});_0x1943ef[_0x12f1('0x36')]=_[_0x12f1('0x30')](_0x377e20,_0x12f1('0x2d'));_0x1943ef[_0x12f1('0x37')]=_[_0x12f1('0x38')](_0x459624[_0x12f1('0x37')]);_0x1943ef['filters']=_['intersection'](_0x1943ef[_0x12f1('0x36')],_0x1943ef[_0x12f1('0x37')]);_0x4711f4[_0x12f1('0x39')]=_[_0x12f1('0x3a')](_0x1943ef[_0x12f1('0x36')],qs[_0x12f1('0x3b')](_0x459624['query'][_0x12f1('0x3b')]));_0x4711f4[_0x12f1('0x39')]=_0x4711f4[_0x12f1('0x39')][_0x12f1('0x3c')]?_0x4711f4[_0x12f1('0x39')]:_0x1943ef['model'];if(!_0x459624['query']['hasOwnProperty']('nolimit')){_0x4711f4[_0x12f1('0x1f')]=qs['limit'](_0x459624[_0x12f1('0x37')][_0x12f1('0x1f')]);_0x4711f4[_0x12f1('0x1e')]=qs[_0x12f1('0x1e')](_0x459624[_0x12f1('0x37')][_0x12f1('0x1e')]);}_0x4711f4[_0x12f1('0x3d')]=qs[_0x12f1('0x3e')](_0x459624[_0x12f1('0x37')][_0x12f1('0x3e')]);_0x4711f4['where']=qs[_0x12f1('0x3f')](_[_0x12f1('0x40')](_0x459624[_0x12f1('0x37')],_0x1943ef[_0x12f1('0x3f')]),_0x377e20);if(_0x459624[_0x12f1('0x37')][_0x12f1('0x41')]){_0x4711f4[_0x12f1('0x42')]=_[_0x12f1('0x43')](_0x4711f4[_0x12f1('0x42')],{'$or':_[_0x12f1('0x30')](_0x377e20,function(_0x14bd5c){if(_0x14bd5c['type']!==_0x12f1('0x44')){var _0x36de04={};_0x36de04[_0x14bd5c[_0x12f1('0x2d')]]={'$like':'%'+_0x459624['query'][_0x12f1('0x41')]+'%'};return _0x36de04;}})});}_0x4711f4=_[_0x12f1('0x43')]({},_0x4711f4,_0x459624['options']);var _0x2fc405={'where':_0x4711f4[_0x12f1('0x42')]};return db[_0x12f1('0x31')][_0x12f1('0x21')](_0x2fc405)[_0x12f1('0x27')](function(_0x4642ac){_0x22d249[_0x12f1('0x21')]=_0x4642ac;if(_0x459624[_0x12f1('0x37')][_0x12f1('0x45')]){_0x4711f4['include']=[{'all':!![]}];}return db[_0x12f1('0x31')][_0x12f1('0x46')](_0x4711f4);})[_0x12f1('0x27')](function(_0x178a6c){_0x22d249['rows']=_0x178a6c;return _0x22d249;})[_0x12f1('0x27')](respondWithFilteredResult(_0x533934,_0x4711f4))[_0x12f1('0x47')](handleError(_0x533934,null));};exports[_0x12f1('0x48')]=function(_0x3d3ddb,_0x44cb7b){var _0x565663={'raw':!![],'where':{'id':_0x3d3ddb[_0x12f1('0x49')]['id']}},_0x9a81ea={};_0x9a81ea[_0x12f1('0x36')]=_['keys'](db['AnalyticExtractedReport'][_0x12f1('0x32')]);_0x9a81ea[_0x12f1('0x37')]=_[_0x12f1('0x38')](_0x3d3ddb['query']);_0x9a81ea[_0x12f1('0x3f')]=_['intersection'](_0x9a81ea[_0x12f1('0x36')],_0x9a81ea[_0x12f1('0x37')]);_0x565663[_0x12f1('0x39')]=_[_0x12f1('0x3a')](_0x9a81ea[_0x12f1('0x36')],qs[_0x12f1('0x3b')](_0x3d3ddb[_0x12f1('0x37')]['fields']));_0x565663['attributes']=_0x565663[_0x12f1('0x39')][_0x12f1('0x3c')]?_0x565663['attributes']:_0x9a81ea[_0x12f1('0x36')];if(_0x3d3ddb['query']['includeAll']){_0x565663[_0x12f1('0x4a')]=[{'all':!![]}];}_0x565663=_[_0x12f1('0x43')]({},_0x565663,_0x3d3ddb['options']);return db['AnalyticExtractedReport'][_0x12f1('0x4b')](_0x565663)[_0x12f1('0x27')](handleEntityNotFound(_0x44cb7b,null))[_0x12f1('0x27')](respondWithResult(_0x44cb7b,null))[_0x12f1('0x47')](handleError(_0x44cb7b,null));};exports[_0x12f1('0x4c')]=function(_0x2cbe99,_0x561ff1){return db[_0x12f1('0x31')]['create'](_0x2cbe99['body'],{})[_0x12f1('0x27')](function(_0x4a6f10){var _0x302825=_0x2cbe99['user']['get']({'plain':!![]});if(!_0x302825)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x302825[_0x12f1('0x4d')]===_0x12f1('0x4e')){var _0x5ed6ae=_0x4a6f10['get']({'plain':!![]});var _0x2aec0b='ExtractedReports';return db[_0x12f1('0x4f')][_0x12f1('0x4b')]({'where':{'name':_0x2aec0b,'userProfileId':_0x302825[_0x12f1('0x50')]},'raw':!![]})[_0x12f1('0x27')](function(_0xf20dda){if(_0xf20dda&&_0xf20dda[_0x12f1('0x51')]===0x0){return db[_0x12f1('0x2a')][_0x12f1('0x4c')]({'name':_0x5ed6ae[_0x12f1('0x2d')],'resourceId':_0x5ed6ae['id'],'type':_0xf20dda[_0x12f1('0x2d')],'sectionId':_0xf20dda['id']},{})['then'](function(){return _0x4a6f10;});}else{return _0x4a6f10;}})[_0x12f1('0x47')](function(_0x2f8e93){logger['error'](_0x12f1('0x52'),_0x2f8e93);throw _0x2f8e93;});}return _0x4a6f10;})[_0x12f1('0x27')](respondWithResult(_0x561ff1,0xc9))[_0x12f1('0x47')](handleError(_0x561ff1,null));};exports[_0x12f1('0x26')]=function(_0x442f2f,_0x40196f){if(_0x442f2f[_0x12f1('0x53')]['id']){delete _0x442f2f[_0x12f1('0x53')]['id'];}return db[_0x12f1('0x31')][_0x12f1('0x4b')]({'where':{'id':_0x442f2f[_0x12f1('0x49')]['id']}})[_0x12f1('0x27')](handleEntityNotFound(_0x40196f,null))[_0x12f1('0x27')](saveUpdates(_0x442f2f[_0x12f1('0x53')],null))[_0x12f1('0x27')](respondWithResult(_0x40196f,null))[_0x12f1('0x47')](handleError(_0x40196f,null));};exports['destroy']=function(_0x1d2aba,_0x42fb33){return db[_0x12f1('0x31')]['find']({'where':{'id':_0x1d2aba['params']['id']}})[_0x12f1('0x27')](handleEntityNotFound(_0x42fb33,null))[_0x12f1('0x27')](removeEntity(_0x42fb33,null))[_0x12f1('0x47')](handleError(_0x42fb33,null));};exports['download']=function(_0x320415,_0x94a647,_0x2eed8c){return db['AnalyticExtractedReport'][_0x12f1('0x4b')]({'where':{'id':_0x320415[_0x12f1('0x49')]['id']},'attributes':[_0x12f1('0x2d'),'basename',_0x12f1('0x54'),_0x12f1('0x55')],'raw':!![]})[_0x12f1('0x27')](handleEntityNotFound(_0x94a647,null))['then'](function(_0x48dda0){if(_0x48dda0){if(!fs['existsSync'](path[_0x12f1('0x56')](config[_0x12f1('0x57')],'server/files/reports',_0x48dda0[_0x12f1('0x54')]))){throw new db[(_0x12f1('0x58'))][(_0x12f1('0x59'))](_0x12f1('0x5a'));}if(_0x320415['query'][_0x12f1('0x5b')]){return _0x94a647['sendStatus'](0xc8);}return _0x94a647['download'](path[_0x12f1('0x56')](config['root'],'server/files/reports',_0x48dda0['savename']),util['format'](_0x12f1('0x5c'),_0x48dda0['basename']||_0x48dda0[_0x12f1('0x2d')],_0x48dda0[_0x12f1('0x55')][_0x12f1('0x5d')]()));}})['catch'](handleError(_0x94a647,null));};
\ No newline at end of file