Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 3f6cac7..b530bb5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb40e=['set','Content-Range','apply','save','update','then','error','stack','name','send','index','AnalyticTreeReport','fieldName','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','type','options','count','include','findAll','rows','catch','show','params','rawAttributes','create','body','find','rimraf','zip-dir','fast-json-patch','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit'];(function(_0x1e3a27,_0x44ab11){var _0x141fe2=function(_0x297e8f){while(--_0x297e8f){_0x1e3a27['push'](_0x1e3a27['shift']());}};_0x141fe2(++_0x44ab11);}(_0xb40e,0xb7));var _0xeb40=function(_0x546aaf,_0x1ed138){_0x546aaf=_0x546aaf-0x0;var _0x1cbf6d=_0xb40e[_0x546aaf];return _0x1cbf6d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xeb40('0x0'));var zipdir=require(_0xeb40('0x1'));var jsonpatch=require(_0xeb40('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xeb40('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0xeb40('0x4'));var sox=require(_0xeb40('0x5'));var csv=require(_0xeb40('0x6'));var ejs=require(_0xeb40('0x7'));var fs=require('fs');var fs_extra=require(_0xeb40('0x8'));var _=require(_0xeb40('0x9'));var squel=require(_0xeb40('0xa'));var crypto=require(_0xeb40('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xeb40('0xc'));var toCsv=require('to-csv');var querystring=require(_0xeb40('0xd'));var Papa=require(_0xeb40('0xe'));var Redis=require(_0xeb40('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xeb40('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xeb40('0x11'))(_0xeb40('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xeb40('0x13'))['db'];function respondWithStatusCode(_0x528898,_0x14076b){_0x14076b=_0x14076b||0xcc;return function(_0x17b5af){if(_0x17b5af){return _0x528898[_0xeb40('0x14')](_0x14076b);}return _0x528898['status'](_0x14076b)[_0xeb40('0x15')]();};}function respondWithResult(_0x44d4d9,_0x4a2115){_0x4a2115=_0x4a2115||0xc8;return function(_0x394640){if(_0x394640){return _0x44d4d9[_0xeb40('0x16')](_0x4a2115)[_0xeb40('0x17')](_0x394640);}};}function respondWithFilteredResult(_0x205fa7,_0x4b38f5){return function(_0x2bda72){if(_0x2bda72){var _0x50dd31=typeof _0x4b38f5[_0xeb40('0x18')]==='undefined'&&typeof _0x4b38f5['limit']===_0xeb40('0x19');var _0x487db2=_0x2bda72['count'];var _0x19f1c7=_0x50dd31?0x0:_0x4b38f5[_0xeb40('0x18')];var _0x41f03f=_0x50dd31?_0x2bda72['count']:_0x4b38f5['offset']+_0x4b38f5[_0xeb40('0x1a')];var _0x1731f6;if(_0x41f03f>=_0x487db2){_0x41f03f=_0x487db2;_0x1731f6=0xc8;}else{_0x1731f6=0xce;}_0x205fa7[_0xeb40('0x16')](_0x1731f6);return _0x205fa7[_0xeb40('0x1b')](_0xeb40('0x1c'),_0x19f1c7+'-'+_0x41f03f+'/'+_0x487db2)[_0xeb40('0x17')](_0x2bda72);}return null;};}function patchUpdates(_0xe30623){return function(_0x1f2bd1){try{jsonpatch[_0xeb40('0x1d')](_0x1f2bd1,_0xe30623,!![]);}catch(_0x1536f5){return BPromise['reject'](_0x1536f5);}return _0x1f2bd1[_0xeb40('0x1e')]();};}function saveUpdates(_0x70c33d,_0x5e45b2){return function(_0x2ad65c){if(_0x2ad65c){return _0x2ad65c[_0xeb40('0x1f')](_0x70c33d)['then'](function(_0x46a3ac){return _0x46a3ac;});}return null;};}function removeEntity(_0x19e95e,_0x1dfbf3){return function(_0x33b2c4){if(_0x33b2c4){return _0x33b2c4['destroy']()[_0xeb40('0x20')](function(){_0x19e95e[_0xeb40('0x16')](0xcc)[_0xeb40('0x15')]();});}};}function handleEntityNotFound(_0x33dd47,_0x952148){return function(_0x3da60f){if(!_0x3da60f){_0x33dd47[_0xeb40('0x14')](0x194);}return _0x3da60f;};}function handleError(_0x57e9bf,_0x459012){_0x459012=_0x459012||0x1f4;return function(_0x3d5172){logger[_0xeb40('0x21')](_0x3d5172[_0xeb40('0x22')]);if(_0x3d5172[_0xeb40('0x23')]){delete _0x3d5172[_0xeb40('0x23')];}_0x57e9bf[_0xeb40('0x16')](_0x459012)[_0xeb40('0x24')](_0x3d5172);};}exports[_0xeb40('0x25')]=function(_0x57aed2,_0x47f389){var _0x6d501f={},_0x14ecd2={},_0xc36f57={'count':0x0,'rows':[]};var _0x410437=_['map'](db[_0xeb40('0x26')]['rawAttributes'],function(_0xe68618){return{'name':_0xe68618[_0xeb40('0x27')],'type':_0xe68618['type'][_0xeb40('0x28')]};});_0x14ecd2[_0xeb40('0x29')]=_[_0xeb40('0x2a')](_0x410437,_0xeb40('0x23'));_0x14ecd2[_0xeb40('0x2b')]=_[_0xeb40('0x2c')](_0x57aed2[_0xeb40('0x2b')]);_0x14ecd2[_0xeb40('0x2d')]=_[_0xeb40('0x2e')](_0x14ecd2[_0xeb40('0x29')],_0x14ecd2[_0xeb40('0x2b')]);_0x6d501f[_0xeb40('0x2f')]=_[_0xeb40('0x2e')](_0x14ecd2['model'],qs[_0xeb40('0x30')](_0x57aed2[_0xeb40('0x2b')][_0xeb40('0x30')]));_0x6d501f[_0xeb40('0x2f')]=_0x6d501f[_0xeb40('0x2f')][_0xeb40('0x31')]?_0x6d501f['attributes']:_0x14ecd2[_0xeb40('0x29')];if(!_0x57aed2['query'][_0xeb40('0x32')]('nolimit')){_0x6d501f[_0xeb40('0x1a')]=qs[_0xeb40('0x1a')](_0x57aed2[_0xeb40('0x2b')]['limit']);_0x6d501f['offset']=qs['offset'](_0x57aed2[_0xeb40('0x2b')][_0xeb40('0x18')]);}_0x6d501f[_0xeb40('0x33')]=qs['sort'](_0x57aed2[_0xeb40('0x2b')][_0xeb40('0x34')]);_0x6d501f[_0xeb40('0x35')]=qs[_0xeb40('0x2d')](_[_0xeb40('0x36')](_0x57aed2['query'],_0x14ecd2[_0xeb40('0x2d')]),_0x410437);if(_0x57aed2[_0xeb40('0x2b')][_0xeb40('0x37')]){_0x6d501f[_0xeb40('0x35')]=_[_0xeb40('0x38')](_0x6d501f[_0xeb40('0x35')],{'$or':_['map'](_0x410437,function(_0x49773f){if(_0x49773f[_0xeb40('0x39')]!=='VIRTUAL'){var _0x33063f={};_0x33063f[_0x49773f['name']]={'$like':'%'+_0x57aed2[_0xeb40('0x2b')][_0xeb40('0x37')]+'%'};return _0x33063f;}})});}_0x6d501f=_[_0xeb40('0x38')]({},_0x6d501f,_0x57aed2[_0xeb40('0x3a')]);var _0x2db190={'where':_0x6d501f[_0xeb40('0x35')]};return db['AnalyticTreeReport']['count'](_0x2db190)[_0xeb40('0x20')](function(_0x151aad){_0xc36f57[_0xeb40('0x3b')]=_0x151aad;if(_0x57aed2['query']['includeAll']){_0x6d501f[_0xeb40('0x3c')]=[{'all':!![]}];}return db['AnalyticTreeReport'][_0xeb40('0x3d')](_0x6d501f);})[_0xeb40('0x20')](function(_0x2eed0f){_0xc36f57[_0xeb40('0x3e')]=_0x2eed0f;return _0xc36f57;})[_0xeb40('0x20')](respondWithFilteredResult(_0x47f389,_0x6d501f))[_0xeb40('0x3f')](handleError(_0x47f389,null));};exports[_0xeb40('0x40')]=function(_0x3f81d5,_0x58fb72){var _0x3f052a={'raw':!![],'where':{'id':_0x3f81d5[_0xeb40('0x41')]['id']}},_0x2cec39={};_0x2cec39[_0xeb40('0x29')]=_[_0xeb40('0x2c')](db[_0xeb40('0x26')][_0xeb40('0x42')]);_0x2cec39[_0xeb40('0x2b')]=_['keys'](_0x3f81d5[_0xeb40('0x2b')]);_0x2cec39[_0xeb40('0x2d')]=_['intersection'](_0x2cec39[_0xeb40('0x29')],_0x2cec39['query']);_0x3f052a[_0xeb40('0x2f')]=_[_0xeb40('0x2e')](_0x2cec39[_0xeb40('0x29')],qs['fields'](_0x3f81d5[_0xeb40('0x2b')][_0xeb40('0x30')]));_0x3f052a[_0xeb40('0x2f')]=_0x3f052a['attributes'][_0xeb40('0x31')]?_0x3f052a['attributes']:_0x2cec39[_0xeb40('0x29')];if(_0x3f81d5[_0xeb40('0x2b')]['includeAll']){_0x3f052a['include']=[{'all':!![]}];}_0x3f052a=_[_0xeb40('0x38')]({},_0x3f052a,_0x3f81d5[_0xeb40('0x3a')]);return db[_0xeb40('0x26')]['find'](_0x3f052a)['then'](handleEntityNotFound(_0x58fb72,null))[_0xeb40('0x20')](respondWithResult(_0x58fb72,null))[_0xeb40('0x3f')](handleError(_0x58fb72,null));};exports['create']=function(_0x4594d0,_0x3e1c0a){return db[_0xeb40('0x26')][_0xeb40('0x43')](_0x4594d0[_0xeb40('0x44')],{})['then'](respondWithResult(_0x3e1c0a,0xc9))[_0xeb40('0x3f')](handleError(_0x3e1c0a,null));};exports[_0xeb40('0x1f')]=function(_0x366154,_0x3cb975){if(_0x366154[_0xeb40('0x44')]['id']){delete _0x366154['body']['id'];}return db[_0xeb40('0x26')][_0xeb40('0x45')]({'where':{'id':_0x366154[_0xeb40('0x41')]['id']}})[_0xeb40('0x20')](handleEntityNotFound(_0x3cb975,null))[_0xeb40('0x20')](saveUpdates(_0x366154[_0xeb40('0x44')],null))['then'](respondWithResult(_0x3cb975,null))[_0xeb40('0x3f')](handleError(_0x3cb975,null));};exports['destroy']=function(_0x41288f,_0x3709be){return db[_0xeb40('0x26')][_0xeb40('0x45')]({'where':{'id':_0x41288f[_0xeb40('0x41')]['id']}})[_0xeb40('0x20')](handleEntityNotFound(_0x3709be,null))[_0xeb40('0x20')](removeEntity(_0x3709be,null))[_0xeb40('0x3f')](handleError(_0x3709be,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