Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 6cdbcc3..b530bb5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7254=['catch','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','save','destroy','then','error','stack','name','AnalyticTreeReport','rawAttributes','type','key','map','query','intersection','model','attributes','fields','length','nolimit','order','sort','where','filters','pick','merge','options','include','findAll','rows','show','keys','includeAll','find','create','body','update','params'];(function(_0x3afff2,_0x548209){var _0x5c6b79=function(_0xdd7ec5){while(--_0xdd7ec5){_0x3afff2['push'](_0x3afff2['shift']());}};_0x5c6b79(++_0x548209);}(_0x7254,0xdf));var _0x4725=function(_0xa8e00c,_0x5d45d0){_0xa8e00c=_0xa8e00c-0x0;var _0x317f3b=_0x7254[_0xa8e00c];return _0x317f3b;};'use strict';var pdf=require(_0x4725('0x0'));var emlformat=require(_0x4725('0x1'));var rimraf=require(_0x4725('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x4725('0x3'));var rp=require(_0x4725('0x4'));var moment=require(_0x4725('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x4725('0x6'));var util=require(_0x4725('0x7'));var path=require(_0x4725('0x8'));var sox=require('sox');var csv=require(_0x4725('0x9'));var ejs=require(_0x4725('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x4725('0xb'));var crypto=require(_0x4725('0xc'));var jsforce=require(_0x4725('0xd'));var deskjs=require(_0x4725('0xe'));var toCsv=require(_0x4725('0x9'));var querystring=require(_0x4725('0xf'));var Papa=require(_0x4725('0x10'));var Redis=require(_0x4725('0x11'));var authService=require(_0x4725('0x12'));var qs=require(_0x4725('0x13'));var as=require(_0x4725('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x4725('0x15'))(_0x4725('0x16'));var utils=require(_0x4725('0x17'));var config=require(_0x4725('0x18'));var licenseUtil=require(_0x4725('0x19'));var db=require(_0x4725('0x1a'))['db'];function respondWithStatusCode(_0x38c80a,_0x4842de){_0x4842de=_0x4842de||0xcc;return function(_0x461872){if(_0x461872){return _0x38c80a[_0x4725('0x1b')](_0x4842de);}return _0x38c80a[_0x4725('0x1c')](_0x4842de)[_0x4725('0x1d')]();};}function respondWithResult(_0x972b3,_0x110ff4){_0x110ff4=_0x110ff4||0xc8;return function(_0x13ae34){if(_0x13ae34){return _0x972b3[_0x4725('0x1c')](_0x110ff4)['json'](_0x13ae34);}};}function respondWithFilteredResult(_0x59bc79,_0x3e2bdb){return function(_0x31b216){if(_0x31b216){var _0x4976b6=_0x31b216[_0x4725('0x1e')],_0x87cc97=_0x3e2bdb['offset'],_0x5a5356=_0x3e2bdb[_0x4725('0x1f')]+_0x3e2bdb[_0x4725('0x20')],_0x1d913d;if(_0x5a5356>=_0x4976b6){_0x5a5356=_0x4976b6;_0x1d913d=0xc8;}else{_0x1d913d=0xce;}_0x59bc79[_0x4725('0x1c')](_0x1d913d);return _0x59bc79[_0x4725('0x21')](_0x4725('0x22'),_0x87cc97+'-'+_0x5a5356+'/'+_0x4976b6)[_0x4725('0x23')](_0x31b216);}return null;};}function patchUpdates(_0x54de2e){return function(_0x533418){try{jsonpatch[_0x4725('0x24')](_0x533418,_0x54de2e,!![]);}catch(_0x5f386b){return BPromise['reject'](_0x5f386b);}return _0x533418[_0x4725('0x25')]();};}function saveUpdates(_0x505731,_0x2a84ed){return function(_0x544e6b){if(_0x544e6b){return _0x544e6b['update'](_0x505731)['then'](function(_0x15aa27){return _0x15aa27;});}return null;};}function removeEntity(_0x5a0696,_0x7d906){return function(_0x2e0cb8){if(_0x2e0cb8){return _0x2e0cb8[_0x4725('0x26')]()[_0x4725('0x27')](function(){_0x5a0696[_0x4725('0x1c')](0xcc)[_0x4725('0x1d')]();});}};}function handleEntityNotFound(_0x5655b3,_0x3d61e4){return function(_0x2cca7d){if(!_0x2cca7d){_0x5655b3['sendStatus'](0x194);}return _0x2cca7d;};}function handleError(_0x59a243,_0x1e3876){_0x1e3876=_0x1e3876||0x1f4;return function(_0x350b90){logger[_0x4725('0x28')](_0x350b90[_0x4725('0x29')]);if(_0x350b90['name']){delete _0x350b90[_0x4725('0x2a')];}_0x59a243[_0x4725('0x1c')](_0x1e3876)['send'](_0x350b90);};}exports['index']=function(_0x3cfc71,_0x9c99){var _0x359617={},_0x23eece={},_0x19f9e4={'count':0x0,'rows':[]};var _0x40d08d=_['map'](db[_0x4725('0x2b')][_0x4725('0x2c')],function(_0x120783){return{'name':_0x120783['fieldName'],'type':_0x120783[_0x4725('0x2d')][_0x4725('0x2e')]};});_0x23eece['model']=_[_0x4725('0x2f')](_0x40d08d,_0x4725('0x2a'));_0x23eece[_0x4725('0x30')]=_['keys'](_0x3cfc71[_0x4725('0x30')]);_0x23eece['filters']=_[_0x4725('0x31')](_0x23eece[_0x4725('0x32')],_0x23eece[_0x4725('0x30')]);_0x359617[_0x4725('0x33')]=_['intersection'](_0x23eece[_0x4725('0x32')],qs[_0x4725('0x34')](_0x3cfc71[_0x4725('0x30')][_0x4725('0x34')]));_0x359617[_0x4725('0x33')]=_0x359617[_0x4725('0x33')][_0x4725('0x35')]?_0x359617[_0x4725('0x33')]:_0x23eece[_0x4725('0x32')];if(!_0x3cfc71[_0x4725('0x30')]['hasOwnProperty'](_0x4725('0x36'))){_0x359617[_0x4725('0x20')]=qs['limit'](_0x3cfc71[_0x4725('0x30')][_0x4725('0x20')]);_0x359617[_0x4725('0x1f')]=qs[_0x4725('0x1f')](_0x3cfc71['query'][_0x4725('0x1f')]);}_0x359617[_0x4725('0x37')]=qs[_0x4725('0x38')](_0x3cfc71[_0x4725('0x30')]['sort']);_0x359617[_0x4725('0x39')]=qs[_0x4725('0x3a')](_[_0x4725('0x3b')](_0x3cfc71['query'],_0x23eece[_0x4725('0x3a')]),_0x40d08d);if(_0x3cfc71['query']['filter']){_0x359617[_0x4725('0x39')]=_[_0x4725('0x3c')](_0x359617[_0x4725('0x39')],{'$or':_[_0x4725('0x2f')](_0x40d08d,function(_0x4afd14){if(_0x4afd14[_0x4725('0x2d')]!=='VIRTUAL'){var _0x27fb0b={};_0x27fb0b[_0x4afd14[_0x4725('0x2a')]]={'$like':'%'+_0x3cfc71[_0x4725('0x30')]['filter']+'%'};return _0x27fb0b;}})});}_0x359617=_[_0x4725('0x3c')]({},_0x359617,_0x3cfc71[_0x4725('0x3d')]);var _0x5ae5df={'where':_0x359617['where']};return db['AnalyticTreeReport'][_0x4725('0x1e')](_0x5ae5df)[_0x4725('0x27')](function(_0x1a1ad4){_0x19f9e4[_0x4725('0x1e')]=_0x1a1ad4;if(_0x3cfc71[_0x4725('0x30')]['includeAll']){_0x359617[_0x4725('0x3e')]=[{'all':!![]}];}return db[_0x4725('0x2b')][_0x4725('0x3f')](_0x359617);})[_0x4725('0x27')](function(_0xed827){_0x19f9e4[_0x4725('0x40')]=_0xed827;return _0x19f9e4;})['then'](respondWithFilteredResult(_0x9c99,_0x359617))['catch'](handleError(_0x9c99,null));};exports[_0x4725('0x41')]=function(_0x2ce8a7,_0x139a21){var _0x3a3a05={'raw':!![],'where':{'id':_0x2ce8a7['params']['id']}},_0x596b78={};_0x596b78['model']=_[_0x4725('0x42')](db['AnalyticTreeReport'][_0x4725('0x2c')]);_0x596b78[_0x4725('0x30')]=_[_0x4725('0x42')](_0x2ce8a7[_0x4725('0x30')]);_0x596b78[_0x4725('0x3a')]=_[_0x4725('0x31')](_0x596b78[_0x4725('0x32')],_0x596b78[_0x4725('0x30')]);_0x3a3a05[_0x4725('0x33')]=_[_0x4725('0x31')](_0x596b78[_0x4725('0x32')],qs[_0x4725('0x34')](_0x2ce8a7[_0x4725('0x30')][_0x4725('0x34')]));_0x3a3a05['attributes']=_0x3a3a05[_0x4725('0x33')][_0x4725('0x35')]?_0x3a3a05[_0x4725('0x33')]:_0x596b78[_0x4725('0x32')];if(_0x2ce8a7['query'][_0x4725('0x43')]){_0x3a3a05['include']=[{'all':!![]}];}_0x3a3a05=_[_0x4725('0x3c')]({},_0x3a3a05,_0x2ce8a7['options']);return db[_0x4725('0x2b')][_0x4725('0x44')](_0x3a3a05)[_0x4725('0x27')](handleEntityNotFound(_0x139a21,null))[_0x4725('0x27')](respondWithResult(_0x139a21,null))['catch'](handleError(_0x139a21,null));};exports['create']=function(_0x3079b2,_0x351fc7){return db['AnalyticTreeReport'][_0x4725('0x45')](_0x3079b2[_0x4725('0x46')],{})[_0x4725('0x27')](respondWithResult(_0x351fc7,0xc9))['catch'](handleError(_0x351fc7,null));};exports[_0x4725('0x47')]=function(_0x5dccf6,_0x1e7ff9){if(_0x5dccf6[_0x4725('0x46')]['id']){delete _0x5dccf6[_0x4725('0x46')]['id'];}return db[_0x4725('0x2b')][_0x4725('0x44')]({'where':{'id':_0x5dccf6[_0x4725('0x48')]['id']}})['then'](handleEntityNotFound(_0x1e7ff9,null))[_0x4725('0x27')](saveUpdates(_0x5dccf6[_0x4725('0x46')],null))[_0x4725('0x27')](respondWithResult(_0x1e7ff9,null))[_0x4725('0x49')](handleError(_0x1e7ff9,null));};exports['destroy']=function(_0x39b1f6,_0x43b99a){return db[_0x4725('0x2b')][_0x4725('0x44')]({'where':{'id':_0x39b1f6[_0x4725('0x48')]['id']}})[_0x4725('0x27')](handleEntityNotFound(_0x43b99a,null))['then'](removeEntity(_0x43b99a,null))['catch'](handleError(_0x43b99a,null));};
\ No newline at end of file
+var _0x280f=['moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','limit','count','offset','set','Content-Range','apply','save','update','then','destroy','end','stack','name','send','index','AnalyticTreeReport','rawAttributes','model','map','query','filters','intersection','fields','hasOwnProperty','nolimit','order','sort','where','filter','type','merge','options','includeAll','include','findAll','rows','catch','keys','attributes','length','find','create','body','params','eml-format','rimraf','zip-dir','fast-json-patch','request-promise'];(function(_0x1ba52b,_0xe8055a){var _0xf14517=function(_0x33bb2e){while(--_0x33bb2e){_0x1ba52b['push'](_0x1ba52b['shift']());}};_0xf14517(++_0xe8055a);}(_0x280f,0xdc));var _0xf280=function(_0x2718c7,_0x5a1636){_0x2718c7=_0x2718c7-0x0;var _0x59d89c=_0x280f[_0x2718c7];return _0x59d89c;};'use strict';var emlformat=require(_0xf280('0x0'));var rimraf=require(_0xf280('0x1'));var zipdir=require(_0xf280('0x2'));var jsonpatch=require(_0xf280('0x3'));var rp=require(_0xf280('0x4'));var moment=require(_0xf280('0x5'));var BPromise=require(_0xf280('0x6'));var Mustache=require(_0xf280('0x7'));var util=require(_0xf280('0x8'));var path=require(_0xf280('0x9'));var sox=require(_0xf280('0xa'));var csv=require(_0xf280('0xb'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf280('0xc'));var _=require(_0xf280('0xd'));var squel=require('squel');var crypto=require(_0xf280('0xe'));var jsforce=require(_0xf280('0xf'));var deskjs=require(_0xf280('0x10'));var toCsv=require(_0xf280('0xb'));var querystring=require('querystring');var Papa=require(_0xf280('0x11'));var Redis=require(_0xf280('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xf280('0x13'));var as=require(_0xf280('0x14'));var hardwareService=require(_0xf280('0x15'));var logger=require(_0xf280('0x16'))(_0xf280('0x17'));var utils=require(_0xf280('0x18'));var config=require(_0xf280('0x19'));var licenseUtil=require(_0xf280('0x1a'));var db=require(_0xf280('0x1b'))['db'];function respondWithStatusCode(_0x3006a6,_0x2247e5){_0x2247e5=_0x2247e5||0xcc;return function(_0x3652d4){if(_0x3652d4){return _0x3006a6[_0xf280('0x1c')](_0x2247e5);}return _0x3006a6['status'](_0x2247e5)['end']();};}function respondWithResult(_0x1b4b75,_0x23f85c){_0x23f85c=_0x23f85c||0xc8;return function(_0x299de3){if(_0x299de3){return _0x1b4b75[_0xf280('0x1d')](_0x23f85c)[_0xf280('0x1e')](_0x299de3);}};}function respondWithFilteredResult(_0x2c00e5,_0x363049){return function(_0x3eeecc){if(_0x3eeecc){var _0x4dd261=typeof _0x363049['offset']==='undefined'&&typeof _0x363049[_0xf280('0x1f')]==='undefined';var _0x5d7427=_0x3eeecc[_0xf280('0x20')];var _0x4d7745=_0x4dd261?0x0:_0x363049['offset'];var _0x71208=_0x4dd261?_0x3eeecc[_0xf280('0x20')]:_0x363049[_0xf280('0x21')]+_0x363049[_0xf280('0x1f')];var _0x6b9c21;if(_0x71208>=_0x5d7427){_0x71208=_0x5d7427;_0x6b9c21=0xc8;}else{_0x6b9c21=0xce;}_0x2c00e5[_0xf280('0x1d')](_0x6b9c21);return _0x2c00e5[_0xf280('0x22')](_0xf280('0x23'),_0x4d7745+'-'+_0x71208+'/'+_0x5d7427)['json'](_0x3eeecc);}return null;};}function patchUpdates(_0x377f76){return function(_0x46d975){try{jsonpatch[_0xf280('0x24')](_0x46d975,_0x377f76,!![]);}catch(_0x274dc8){return BPromise['reject'](_0x274dc8);}return _0x46d975[_0xf280('0x25')]();};}function saveUpdates(_0x42c42e,_0x5aeea1){return function(_0x414d92){if(_0x414d92){return _0x414d92[_0xf280('0x26')](_0x42c42e)[_0xf280('0x27')](function(_0x56bad9){return _0x56bad9;});}return null;};}function removeEntity(_0x249904,_0x171e73){return function(_0xf76d3b){if(_0xf76d3b){return _0xf76d3b[_0xf280('0x28')]()[_0xf280('0x27')](function(){_0x249904[_0xf280('0x1d')](0xcc)[_0xf280('0x29')]();});}};}function handleEntityNotFound(_0x5595ab,_0x38d9c7){return function(_0x416a3b){if(!_0x416a3b){_0x5595ab[_0xf280('0x1c')](0x194);}return _0x416a3b;};}function handleError(_0x66b8fc,_0x22c5a1){_0x22c5a1=_0x22c5a1||0x1f4;return function(_0x3b7232){logger['error'](_0x3b7232[_0xf280('0x2a')]);if(_0x3b7232[_0xf280('0x2b')]){delete _0x3b7232[_0xf280('0x2b')];}_0x66b8fc[_0xf280('0x1d')](_0x22c5a1)[_0xf280('0x2c')](_0x3b7232);};}exports[_0xf280('0x2d')]=function(_0x4d407b,_0x5125b8){var _0x128d0f={},_0x22ef11={},_0x27b6a3={'count':0x0,'rows':[]};var _0x1a2e92=_['map'](db[_0xf280('0x2e')][_0xf280('0x2f')],function(_0x375058){return{'name':_0x375058['fieldName'],'type':_0x375058['type']['key']};});_0x22ef11[_0xf280('0x30')]=_[_0xf280('0x31')](_0x1a2e92,_0xf280('0x2b'));_0x22ef11[_0xf280('0x32')]=_['keys'](_0x4d407b[_0xf280('0x32')]);_0x22ef11[_0xf280('0x33')]=_[_0xf280('0x34')](_0x22ef11[_0xf280('0x30')],_0x22ef11[_0xf280('0x32')]);_0x128d0f['attributes']=_[_0xf280('0x34')](_0x22ef11[_0xf280('0x30')],qs[_0xf280('0x35')](_0x4d407b[_0xf280('0x32')][_0xf280('0x35')]));_0x128d0f['attributes']=_0x128d0f['attributes']['length']?_0x128d0f['attributes']:_0x22ef11[_0xf280('0x30')];if(!_0x4d407b[_0xf280('0x32')][_0xf280('0x36')](_0xf280('0x37'))){_0x128d0f[_0xf280('0x1f')]=qs[_0xf280('0x1f')](_0x4d407b[_0xf280('0x32')]['limit']);_0x128d0f['offset']=qs[_0xf280('0x21')](_0x4d407b[_0xf280('0x32')]['offset']);}_0x128d0f[_0xf280('0x38')]=qs[_0xf280('0x39')](_0x4d407b['query'][_0xf280('0x39')]);_0x128d0f[_0xf280('0x3a')]=qs[_0xf280('0x33')](_['pick'](_0x4d407b[_0xf280('0x32')],_0x22ef11[_0xf280('0x33')]),_0x1a2e92);if(_0x4d407b[_0xf280('0x32')][_0xf280('0x3b')]){_0x128d0f[_0xf280('0x3a')]=_['merge'](_0x128d0f[_0xf280('0x3a')],{'$or':_[_0xf280('0x31')](_0x1a2e92,function(_0x1f90af){if(_0x1f90af[_0xf280('0x3c')]!=='VIRTUAL'){var _0x5a0bd9={};_0x5a0bd9[_0x1f90af['name']]={'$like':'%'+_0x4d407b['query'][_0xf280('0x3b')]+'%'};return _0x5a0bd9;}})});}_0x128d0f=_[_0xf280('0x3d')]({},_0x128d0f,_0x4d407b[_0xf280('0x3e')]);var _0x495ef4={'where':_0x128d0f[_0xf280('0x3a')]};return db[_0xf280('0x2e')][_0xf280('0x20')](_0x495ef4)['then'](function(_0x1c4612){_0x27b6a3[_0xf280('0x20')]=_0x1c4612;if(_0x4d407b[_0xf280('0x32')][_0xf280('0x3f')]){_0x128d0f[_0xf280('0x40')]=[{'all':!![]}];}return db['AnalyticTreeReport'][_0xf280('0x41')](_0x128d0f);})[_0xf280('0x27')](function(_0x425f7b){_0x27b6a3[_0xf280('0x42')]=_0x425f7b;return _0x27b6a3;})[_0xf280('0x27')](respondWithFilteredResult(_0x5125b8,_0x128d0f))[_0xf280('0x43')](handleError(_0x5125b8,null));};exports['show']=function(_0x3a4d31,_0x15e8a9){var _0x5a4c59={'raw':!![],'where':{'id':_0x3a4d31['params']['id']}},_0x371d3b={};_0x371d3b[_0xf280('0x30')]=_[_0xf280('0x44')](db[_0xf280('0x2e')][_0xf280('0x2f')]);_0x371d3b['query']=_['keys'](_0x3a4d31[_0xf280('0x32')]);_0x371d3b[_0xf280('0x33')]=_[_0xf280('0x34')](_0x371d3b['model'],_0x371d3b[_0xf280('0x32')]);_0x5a4c59[_0xf280('0x45')]=_['intersection'](_0x371d3b[_0xf280('0x30')],qs[_0xf280('0x35')](_0x3a4d31[_0xf280('0x32')]['fields']));_0x5a4c59['attributes']=_0x5a4c59['attributes'][_0xf280('0x46')]?_0x5a4c59[_0xf280('0x45')]:_0x371d3b[_0xf280('0x30')];if(_0x3a4d31[_0xf280('0x32')][_0xf280('0x3f')]){_0x5a4c59[_0xf280('0x40')]=[{'all':!![]}];}_0x5a4c59=_[_0xf280('0x3d')]({},_0x5a4c59,_0x3a4d31[_0xf280('0x3e')]);return db[_0xf280('0x2e')][_0xf280('0x47')](_0x5a4c59)[_0xf280('0x27')](handleEntityNotFound(_0x15e8a9,null))[_0xf280('0x27')](respondWithResult(_0x15e8a9,null))[_0xf280('0x43')](handleError(_0x15e8a9,null));};exports[_0xf280('0x48')]=function(_0x212c7f,_0x17df68){return db[_0xf280('0x2e')][_0xf280('0x48')](_0x212c7f['body'],{})[_0xf280('0x27')](respondWithResult(_0x17df68,0xc9))[_0xf280('0x43')](handleError(_0x17df68,null));};exports[_0xf280('0x26')]=function(_0x7706e9,_0x3ad9fd){if(_0x7706e9[_0xf280('0x49')]['id']){delete _0x7706e9[_0xf280('0x49')]['id'];}return db[_0xf280('0x2e')][_0xf280('0x47')]({'where':{'id':_0x7706e9[_0xf280('0x4a')]['id']}})[_0xf280('0x27')](handleEntityNotFound(_0x3ad9fd,null))[_0xf280('0x27')](saveUpdates(_0x7706e9['body'],null))[_0xf280('0x27')](respondWithResult(_0x3ad9fd,null))[_0xf280('0x43')](handleError(_0x3ad9fd,null));};exports[_0xf280('0x28')]=function(_0x4174da,_0xbf05){return db[_0xf280('0x2e')][_0xf280('0x47')]({'where':{'id':_0x4174da[_0xf280('0x4a')]['id']}})[_0xf280('0x27')](handleEntityNotFound(_0xbf05,null))[_0xf280('0x27')](removeEntity(_0xbf05,null))[_0xf280('0x43')](handleError(_0xbf05,null));};
\ No newline at end of file