Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index fa53e40..dc2e039 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3ff1=['squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','status','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','then','end','sendStatus','error','stack','name','send','map','AnalyticTreeReport','rawAttributes','fieldName','type','model','query','keys','intersection','fields','attributes','length','nolimit','order','sort','filters','pick','filter','where','merge','options','includeAll','include','findAll','rows','catch','show','params','find','body','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash'];(function(_0x2a5651,_0x4b9dfa){var _0xcf4e0b=function(_0x1f9c18){while(--_0x1f9c18){_0x2a5651['push'](_0x2a5651['shift']());}};_0xcf4e0b(++_0x4b9dfa);}(_0x3ff1,0xd0));var _0x13ff=function(_0x5efb91,_0x39b378){_0x5efb91=_0x5efb91-0x0;var _0x57ff36=_0x3ff1[_0x5efb91];return _0x57ff36;};'use strict';var emlformat=require(_0x13ff('0x0'));var rimraf=require(_0x13ff('0x1'));var zipdir=require(_0x13ff('0x2'));var jsonpatch=require(_0x13ff('0x3'));var rp=require(_0x13ff('0x4'));var moment=require(_0x13ff('0x5'));var BPromise=require(_0x13ff('0x6'));var Mustache=require(_0x13ff('0x7'));var util=require(_0x13ff('0x8'));var path=require('path');var sox=require(_0x13ff('0x9'));var csv=require(_0x13ff('0xa'));var ejs=require(_0x13ff('0xb'));var fs=require('fs');var fs_extra=require(_0x13ff('0xc'));var _=require(_0x13ff('0xd'));var squel=require(_0x13ff('0xe'));var crypto=require(_0x13ff('0xf'));var jsforce=require('jsforce');var deskjs=require(_0x13ff('0x10'));var toCsv=require(_0x13ff('0xa'));var querystring=require(_0x13ff('0x11'));var Papa=require('papaparse');var Redis=require(_0x13ff('0x12'));var authService=require(_0x13ff('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x13ff('0x14'));var logger=require(_0x13ff('0x15'))('api');var utils=require(_0x13ff('0x16'));var config=require(_0x13ff('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2352a7,_0x39e8a5){_0x39e8a5=_0x39e8a5||0xcc;return function(_0x21adfa){if(_0x21adfa){return _0x2352a7['sendStatus'](_0x39e8a5);}return _0x2352a7['status'](_0x39e8a5)['end']();};}function respondWithResult(_0x2a93fb,_0x257af3){_0x257af3=_0x257af3||0xc8;return function(_0xe80015){if(_0xe80015){return _0x2a93fb[_0x13ff('0x18')](_0x257af3)['json'](_0xe80015);}};}function respondWithFilteredResult(_0x379d58,_0x2740a8){return function(_0x5f2bdf){if(_0x5f2bdf){var _0x3b529d=typeof _0x2740a8[_0x13ff('0x19')]===_0x13ff('0x1a')&&typeof _0x2740a8[_0x13ff('0x1b')]==='undefined';var _0x240f05=_0x5f2bdf[_0x13ff('0x1c')];var _0x2440e9=_0x3b529d?0x0:_0x2740a8['offset'];var _0x262056=_0x3b529d?_0x5f2bdf[_0x13ff('0x1c')]:_0x2740a8[_0x13ff('0x19')]+_0x2740a8[_0x13ff('0x1b')];var _0x399a58;if(_0x262056>=_0x240f05){_0x262056=_0x240f05;_0x399a58=0xc8;}else{_0x399a58=0xce;}_0x379d58[_0x13ff('0x18')](_0x399a58);return _0x379d58[_0x13ff('0x1d')](_0x13ff('0x1e'),_0x2440e9+'-'+_0x262056+'/'+_0x240f05)[_0x13ff('0x1f')](_0x5f2bdf);}return null;};}function patchUpdates(_0x58e0ea){return function(_0xc27205){try{jsonpatch[_0x13ff('0x20')](_0xc27205,_0x58e0ea,!![]);}catch(_0xd89295){return BPromise[_0x13ff('0x21')](_0xd89295);}return _0xc27205[_0x13ff('0x22')]();};}function saveUpdates(_0xa7ab1a,_0x27876e){return function(_0x46f3e5){if(_0x46f3e5){return _0x46f3e5[_0x13ff('0x23')](_0xa7ab1a)[_0x13ff('0x24')](function(_0x686019){return _0x686019;});}return null;};}function removeEntity(_0x5b5d91,_0x268ccc){return function(_0x2f1b0d){if(_0x2f1b0d){return _0x2f1b0d['destroy']()[_0x13ff('0x24')](function(){_0x5b5d91['status'](0xcc)[_0x13ff('0x25')]();});}};}function handleEntityNotFound(_0x178baa,_0x3ace5a){return function(_0x367bc9){if(!_0x367bc9){_0x178baa[_0x13ff('0x26')](0x194);}return _0x367bc9;};}function handleError(_0x386e4c,_0x32cf49){_0x32cf49=_0x32cf49||0x1f4;return function(_0xdbc369){logger[_0x13ff('0x27')](_0xdbc369[_0x13ff('0x28')]);if(_0xdbc369[_0x13ff('0x29')]){delete _0xdbc369[_0x13ff('0x29')];}_0x386e4c[_0x13ff('0x18')](_0x32cf49)[_0x13ff('0x2a')](_0xdbc369);};}exports['index']=function(_0x21a766,_0x3eae4f){var _0x514578={},_0x234960={},_0xa1c997={'count':0x0,'rows':[]};var _0x1bc2b1=_[_0x13ff('0x2b')](db[_0x13ff('0x2c')][_0x13ff('0x2d')],function(_0x3f9e94){return{'name':_0x3f9e94[_0x13ff('0x2e')],'type':_0x3f9e94[_0x13ff('0x2f')]['key']};});_0x234960[_0x13ff('0x30')]=_[_0x13ff('0x2b')](_0x1bc2b1,_0x13ff('0x29'));_0x234960[_0x13ff('0x31')]=_[_0x13ff('0x32')](_0x21a766['query']);_0x234960['filters']=_[_0x13ff('0x33')](_0x234960[_0x13ff('0x30')],_0x234960[_0x13ff('0x31')]);_0x514578['attributes']=_['intersection'](_0x234960['model'],qs[_0x13ff('0x34')](_0x21a766[_0x13ff('0x31')][_0x13ff('0x34')]));_0x514578[_0x13ff('0x35')]=_0x514578[_0x13ff('0x35')][_0x13ff('0x36')]?_0x514578[_0x13ff('0x35')]:_0x234960[_0x13ff('0x30')];if(!_0x21a766[_0x13ff('0x31')]['hasOwnProperty'](_0x13ff('0x37'))){_0x514578[_0x13ff('0x1b')]=qs[_0x13ff('0x1b')](_0x21a766['query'][_0x13ff('0x1b')]);_0x514578[_0x13ff('0x19')]=qs['offset'](_0x21a766[_0x13ff('0x31')][_0x13ff('0x19')]);}_0x514578[_0x13ff('0x38')]=qs[_0x13ff('0x39')](_0x21a766[_0x13ff('0x31')]['sort']);_0x514578['where']=qs[_0x13ff('0x3a')](_[_0x13ff('0x3b')](_0x21a766[_0x13ff('0x31')],_0x234960['filters']),_0x1bc2b1);if(_0x21a766['query'][_0x13ff('0x3c')]){_0x514578[_0x13ff('0x3d')]=_[_0x13ff('0x3e')](_0x514578[_0x13ff('0x3d')],{'$or':_['map'](_0x1bc2b1,function(_0x6b14c5){if(_0x6b14c5['type']!=='VIRTUAL'){var _0x3b9aad={};_0x3b9aad[_0x6b14c5[_0x13ff('0x29')]]={'$like':'%'+_0x21a766['query'][_0x13ff('0x3c')]+'%'};return _0x3b9aad;}})});}_0x514578=_[_0x13ff('0x3e')]({},_0x514578,_0x21a766[_0x13ff('0x3f')]);var _0x549d72={'where':_0x514578[_0x13ff('0x3d')]};return db[_0x13ff('0x2c')][_0x13ff('0x1c')](_0x549d72)['then'](function(_0x30bff7){_0xa1c997[_0x13ff('0x1c')]=_0x30bff7;if(_0x21a766['query'][_0x13ff('0x40')]){_0x514578[_0x13ff('0x41')]=[{'all':!![]}];}return db[_0x13ff('0x2c')][_0x13ff('0x42')](_0x514578);})[_0x13ff('0x24')](function(_0x2eef82){_0xa1c997[_0x13ff('0x43')]=_0x2eef82;return _0xa1c997;})['then'](respondWithFilteredResult(_0x3eae4f,_0x514578))[_0x13ff('0x44')](handleError(_0x3eae4f,null));};exports[_0x13ff('0x45')]=function(_0x91196e,_0x594a8e){var _0x552d7d={'raw':!![],'where':{'id':_0x91196e[_0x13ff('0x46')]['id']}},_0x2a98bf={};_0x2a98bf['model']=_[_0x13ff('0x32')](db[_0x13ff('0x2c')]['rawAttributes']);_0x2a98bf[_0x13ff('0x31')]=_[_0x13ff('0x32')](_0x91196e[_0x13ff('0x31')]);_0x2a98bf[_0x13ff('0x3a')]=_[_0x13ff('0x33')](_0x2a98bf['model'],_0x2a98bf['query']);_0x552d7d[_0x13ff('0x35')]=_[_0x13ff('0x33')](_0x2a98bf[_0x13ff('0x30')],qs[_0x13ff('0x34')](_0x91196e[_0x13ff('0x31')][_0x13ff('0x34')]));_0x552d7d[_0x13ff('0x35')]=_0x552d7d['attributes'][_0x13ff('0x36')]?_0x552d7d['attributes']:_0x2a98bf[_0x13ff('0x30')];if(_0x91196e[_0x13ff('0x31')][_0x13ff('0x40')]){_0x552d7d[_0x13ff('0x41')]=[{'all':!![]}];}_0x552d7d=_[_0x13ff('0x3e')]({},_0x552d7d,_0x91196e['options']);return db[_0x13ff('0x2c')][_0x13ff('0x47')](_0x552d7d)[_0x13ff('0x24')](handleEntityNotFound(_0x594a8e,null))['then'](respondWithResult(_0x594a8e,null))[_0x13ff('0x44')](handleError(_0x594a8e,null));};exports['create']=function(_0x4d60f6,_0x306363){return db[_0x13ff('0x2c')]['create'](_0x4d60f6[_0x13ff('0x48')],{})[_0x13ff('0x24')](respondWithResult(_0x306363,0xc9))['catch'](handleError(_0x306363,null));};exports['update']=function(_0x4ce620,_0x25453e){if(_0x4ce620[_0x13ff('0x48')]['id']){delete _0x4ce620[_0x13ff('0x48')]['id'];}return db[_0x13ff('0x2c')][_0x13ff('0x47')]({'where':{'id':_0x4ce620[_0x13ff('0x46')]['id']}})[_0x13ff('0x24')](handleEntityNotFound(_0x25453e,null))[_0x13ff('0x24')](saveUpdates(_0x4ce620[_0x13ff('0x48')],null))[_0x13ff('0x24')](respondWithResult(_0x25453e,null))[_0x13ff('0x44')](handleError(_0x25453e,null));};exports[_0x13ff('0x49')]=function(_0x217ca5,_0x1d6b33){return db[_0x13ff('0x2c')][_0x13ff('0x47')]({'where':{'id':_0x217ca5[_0x13ff('0x46')]['id']}})['then'](handleEntityNotFound(_0x1d6b33,null))[_0x13ff('0x24')](removeEntity(_0x1d6b33,null))[_0x13ff('0x44')](handleError(_0x1d6b33,null));};
\ No newline at end of file
+var _0x9518=['key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','where','pick','filter','merge','VIRTUAL','AnalyticTreeReport','count','include','findAll','rows','show','params','find','create','catch','body','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','status','json','offset','undefined','set','Content-Range','apply','reject','save','update','then','sendStatus','error','stack','name','send','index','rawAttributes','fieldName','type'];(function(_0x3d40eb,_0x49b32e){var _0x87f08f=function(_0x49f562){while(--_0x49f562){_0x3d40eb['push'](_0x3d40eb['shift']());}};_0x87f08f(++_0x49b32e);}(_0x9518,0x6b));var _0x8951=function(_0x2d69e1,_0x43f881){_0x2d69e1=_0x2d69e1-0x0;var _0x9b5140=_0x9518[_0x2d69e1];return _0x9b5140;};'use strict';var emlformat=require(_0x8951('0x0'));var rimraf=require(_0x8951('0x1'));var zipdir=require(_0x8951('0x2'));var jsonpatch=require(_0x8951('0x3'));var rp=require(_0x8951('0x4'));var moment=require(_0x8951('0x5'));var BPromise=require(_0x8951('0x6'));var Mustache=require('mustache');var util=require(_0x8951('0x7'));var path=require('path');var sox=require(_0x8951('0x8'));var csv=require(_0x8951('0x9'));var ejs=require(_0x8951('0xa'));var fs=require('fs');var fs_extra=require(_0x8951('0xb'));var _=require(_0x8951('0xc'));var squel=require(_0x8951('0xd'));var crypto=require(_0x8951('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x8951('0x9'));var querystring=require('querystring');var Papa=require(_0x8951('0xf'));var Redis=require(_0x8951('0x10'));var authService=require(_0x8951('0x11'));var qs=require(_0x8951('0x12'));var as=require(_0x8951('0x13'));var hardwareService=require(_0x8951('0x14'));var logger=require(_0x8951('0x15'))('api');var utils=require(_0x8951('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x8951('0x17'));var db=require(_0x8951('0x18'))['db'];function respondWithStatusCode(_0x422f30,_0x5717fb){_0x5717fb=_0x5717fb||0xcc;return function(_0x53d7ab){if(_0x53d7ab){return _0x422f30['sendStatus'](_0x5717fb);}return _0x422f30[_0x8951('0x19')](_0x5717fb)['end']();};}function respondWithResult(_0x1ccac7,_0x569ffa){_0x569ffa=_0x569ffa||0xc8;return function(_0x17aa88){if(_0x17aa88){return _0x1ccac7[_0x8951('0x19')](_0x569ffa)[_0x8951('0x1a')](_0x17aa88);}};}function respondWithFilteredResult(_0x5080cc,_0x234049){return function(_0x1796c4){if(_0x1796c4){var _0x332aaa=typeof _0x234049[_0x8951('0x1b')]===_0x8951('0x1c')&&typeof _0x234049['limit']===_0x8951('0x1c');var _0x173f4d=_0x1796c4['count'];var _0xed8aa3=_0x332aaa?0x0:_0x234049['offset'];var _0x57a9b9=_0x332aaa?_0x1796c4['count']:_0x234049[_0x8951('0x1b')]+_0x234049['limit'];var _0x1578fe;if(_0x57a9b9>=_0x173f4d){_0x57a9b9=_0x173f4d;_0x1578fe=0xc8;}else{_0x1578fe=0xce;}_0x5080cc[_0x8951('0x19')](_0x1578fe);return _0x5080cc[_0x8951('0x1d')](_0x8951('0x1e'),_0xed8aa3+'-'+_0x57a9b9+'/'+_0x173f4d)['json'](_0x1796c4);}return null;};}function patchUpdates(_0x53f891){return function(_0x3bcbff){try{jsonpatch[_0x8951('0x1f')](_0x3bcbff,_0x53f891,!![]);}catch(_0x1b5ae5){return BPromise[_0x8951('0x20')](_0x1b5ae5);}return _0x3bcbff[_0x8951('0x21')]();};}function saveUpdates(_0x3781dd,_0x19231b){return function(_0x28dcee){if(_0x28dcee){return _0x28dcee[_0x8951('0x22')](_0x3781dd)[_0x8951('0x23')](function(_0x95bff0){return _0x95bff0;});}return null;};}function removeEntity(_0x364541,_0x35ad04){return function(_0x32a2cd){if(_0x32a2cd){return _0x32a2cd['destroy']()['then'](function(){_0x364541[_0x8951('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x13f444,_0x4c899d){return function(_0x1005e9){if(!_0x1005e9){_0x13f444[_0x8951('0x24')](0x194);}return _0x1005e9;};}function handleError(_0x3a7c72,_0x1898d8){_0x1898d8=_0x1898d8||0x1f4;return function(_0x122d99){logger[_0x8951('0x25')](_0x122d99[_0x8951('0x26')]);if(_0x122d99['name']){delete _0x122d99[_0x8951('0x27')];}_0x3a7c72[_0x8951('0x19')](_0x1898d8)[_0x8951('0x28')](_0x122d99);};}exports[_0x8951('0x29')]=function(_0x321861,_0x27c05e){var _0x3787d3={},_0x2453c3={},_0x3b3ebb={'count':0x0,'rows':[]};var _0x115862=_['map'](db['AnalyticTreeReport'][_0x8951('0x2a')],function(_0x2f4261){return{'name':_0x2f4261[_0x8951('0x2b')],'type':_0x2f4261[_0x8951('0x2c')][_0x8951('0x2d')]};});_0x2453c3[_0x8951('0x2e')]=_[_0x8951('0x2f')](_0x115862,_0x8951('0x27'));_0x2453c3[_0x8951('0x30')]=_[_0x8951('0x31')](_0x321861[_0x8951('0x30')]);_0x2453c3[_0x8951('0x32')]=_[_0x8951('0x33')](_0x2453c3[_0x8951('0x2e')],_0x2453c3[_0x8951('0x30')]);_0x3787d3[_0x8951('0x34')]=_[_0x8951('0x33')](_0x2453c3[_0x8951('0x2e')],qs['fields'](_0x321861[_0x8951('0x30')][_0x8951('0x35')]));_0x3787d3[_0x8951('0x34')]=_0x3787d3[_0x8951('0x34')][_0x8951('0x36')]?_0x3787d3[_0x8951('0x34')]:_0x2453c3[_0x8951('0x2e')];if(!_0x321861['query'][_0x8951('0x37')](_0x8951('0x38'))){_0x3787d3[_0x8951('0x39')]=qs['limit'](_0x321861['query'][_0x8951('0x39')]);_0x3787d3[_0x8951('0x1b')]=qs[_0x8951('0x1b')](_0x321861[_0x8951('0x30')][_0x8951('0x1b')]);}_0x3787d3[_0x8951('0x3a')]=qs['sort'](_0x321861['query']['sort']);_0x3787d3[_0x8951('0x3b')]=qs[_0x8951('0x32')](_[_0x8951('0x3c')](_0x321861[_0x8951('0x30')],_0x2453c3[_0x8951('0x32')]),_0x115862);if(_0x321861['query'][_0x8951('0x3d')]){_0x3787d3[_0x8951('0x3b')]=_[_0x8951('0x3e')](_0x3787d3[_0x8951('0x3b')],{'$or':_[_0x8951('0x2f')](_0x115862,function(_0x304d81){if(_0x304d81[_0x8951('0x2c')]!==_0x8951('0x3f')){var _0x53d489={};_0x53d489[_0x304d81['name']]={'$like':'%'+_0x321861[_0x8951('0x30')][_0x8951('0x3d')]+'%'};return _0x53d489;}})});}_0x3787d3=_['merge']({},_0x3787d3,_0x321861['options']);var _0x3fea04={'where':_0x3787d3[_0x8951('0x3b')]};return db[_0x8951('0x40')][_0x8951('0x41')](_0x3fea04)[_0x8951('0x23')](function(_0x48b18c){_0x3b3ebb[_0x8951('0x41')]=_0x48b18c;if(_0x321861['query']['includeAll']){_0x3787d3[_0x8951('0x42')]=[{'all':!![]}];}return db[_0x8951('0x40')][_0x8951('0x43')](_0x3787d3);})[_0x8951('0x23')](function(_0x4a726d){_0x3b3ebb[_0x8951('0x44')]=_0x4a726d;return _0x3b3ebb;})[_0x8951('0x23')](respondWithFilteredResult(_0x27c05e,_0x3787d3))['catch'](handleError(_0x27c05e,null));};exports[_0x8951('0x45')]=function(_0x337745,_0x317f9b){var _0x5a79f9={'raw':!![],'where':{'id':_0x337745[_0x8951('0x46')]['id']}},_0x1a0ab9={};_0x1a0ab9['model']=_['keys'](db[_0x8951('0x40')][_0x8951('0x2a')]);_0x1a0ab9[_0x8951('0x30')]=_[_0x8951('0x31')](_0x337745[_0x8951('0x30')]);_0x1a0ab9['filters']=_[_0x8951('0x33')](_0x1a0ab9[_0x8951('0x2e')],_0x1a0ab9[_0x8951('0x30')]);_0x5a79f9[_0x8951('0x34')]=_[_0x8951('0x33')](_0x1a0ab9[_0x8951('0x2e')],qs[_0x8951('0x35')](_0x337745[_0x8951('0x30')][_0x8951('0x35')]));_0x5a79f9[_0x8951('0x34')]=_0x5a79f9[_0x8951('0x34')]['length']?_0x5a79f9[_0x8951('0x34')]:_0x1a0ab9[_0x8951('0x2e')];if(_0x337745[_0x8951('0x30')]['includeAll']){_0x5a79f9[_0x8951('0x42')]=[{'all':!![]}];}_0x5a79f9=_[_0x8951('0x3e')]({},_0x5a79f9,_0x337745['options']);return db[_0x8951('0x40')][_0x8951('0x47')](_0x5a79f9)['then'](handleEntityNotFound(_0x317f9b,null))[_0x8951('0x23')](respondWithResult(_0x317f9b,null))['catch'](handleError(_0x317f9b,null));};exports[_0x8951('0x48')]=function(_0x2bc500,_0x23e773){return db[_0x8951('0x40')][_0x8951('0x48')](_0x2bc500['body'],{})['then'](respondWithResult(_0x23e773,0xc9))[_0x8951('0x49')](handleError(_0x23e773,null));};exports[_0x8951('0x22')]=function(_0x54de26,_0x51f7e8){if(_0x54de26[_0x8951('0x4a')]['id']){delete _0x54de26[_0x8951('0x4a')]['id'];}return db[_0x8951('0x40')][_0x8951('0x47')]({'where':{'id':_0x54de26[_0x8951('0x46')]['id']}})[_0x8951('0x23')](handleEntityNotFound(_0x51f7e8,null))[_0x8951('0x23')](saveUpdates(_0x54de26[_0x8951('0x4a')],null))['then'](respondWithResult(_0x51f7e8,null))['catch'](handleError(_0x51f7e8,null));};exports[_0x8951('0x4b')]=function(_0x5be030,_0x2d15b4){return db['AnalyticTreeReport']['find']({'where':{'id':_0x5be030[_0x8951('0x46')]['id']}})[_0x8951('0x23')](handleEntityNotFound(_0x2d15b4,null))[_0x8951('0x23')](removeEntity(_0x2d15b4,null))[_0x8951('0x49')](handleError(_0x2d15b4,null));};
\ No newline at end of file