Built motion from commit 37e1ed56.|2.6.29
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 1e2a4be..e45aabf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0038=['findAll','rows','catch','params','find','create','body','destroy','rimraf','fast-json-patch','moment','mustache','util','path','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','error','stack','send','index','map','fieldName','type','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','name','options','AnalyticTreeReport','includeAll','include'];(function(_0x16b8e6,_0xce24fe){var _0xf5bab2=function(_0x5d21e2){while(--_0x5d21e2){_0x16b8e6['push'](_0x16b8e6['shift']());}};_0xf5bab2(++_0xce24fe);}(_0x0038,0x124));var _0x8003=function(_0x43b4f3,_0x22636e){_0x43b4f3=_0x43b4f3-0x0;var _0x31911f=_0x0038[_0x43b4f3];return _0x31911f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x8003('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8003('0x1'));var rp=require('request-promise');var moment=require(_0x8003('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x8003('0x3'));var util=require(_0x8003('0x4'));var path=require(_0x8003('0x5'));var sox=require('sox');var csv=require(_0x8003('0x6'));var ejs=require(_0x8003('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x8003('0x8'));var squel=require(_0x8003('0x9'));var crypto=require('crypto');var jsforce=require(_0x8003('0xa'));var deskjs=require(_0x8003('0xb'));var toCsv=require(_0x8003('0x6'));var querystring=require('querystring');var Papa=require(_0x8003('0xc'));var Redis=require(_0x8003('0xd'));var authService=require(_0x8003('0xe'));var qs=require(_0x8003('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x8003('0x10'));var config=require('../../config/environment');var licenseUtil=require(_0x8003('0x11'));var db=require(_0x8003('0x12'))['db'];function respondWithStatusCode(_0x2cc303,_0x2633d3){_0x2633d3=_0x2633d3||0xcc;return function(_0xcd86d5){if(_0xcd86d5){return _0x2cc303[_0x8003('0x13')](_0x2633d3);}return _0x2cc303[_0x8003('0x14')](_0x2633d3)[_0x8003('0x15')]();};}function respondWithResult(_0x4af77a,_0xae5de7){_0xae5de7=_0xae5de7||0xc8;return function(_0x325572){if(_0x325572){return _0x4af77a[_0x8003('0x14')](_0xae5de7)[_0x8003('0x16')](_0x325572);}};}function respondWithFilteredResult(_0xbad6b8,_0xbd4c1b){return function(_0x491028){if(_0x491028){var _0x537a0b=typeof _0xbd4c1b[_0x8003('0x17')]===_0x8003('0x18')&&typeof _0xbd4c1b[_0x8003('0x19')]===_0x8003('0x18');var _0xe70ae4=_0x491028[_0x8003('0x1a')];var _0x25334a=_0x537a0b?0x0:_0xbd4c1b[_0x8003('0x17')];var _0x2322f7=_0x537a0b?_0x491028[_0x8003('0x1a')]:_0xbd4c1b[_0x8003('0x17')]+_0xbd4c1b[_0x8003('0x19')];var _0x4caf87;if(_0x2322f7>=_0xe70ae4){_0x2322f7=_0xe70ae4;_0x4caf87=0xc8;}else{_0x4caf87=0xce;}_0xbad6b8[_0x8003('0x14')](_0x4caf87);return _0xbad6b8[_0x8003('0x1b')](_0x8003('0x1c'),_0x25334a+'-'+_0x2322f7+'/'+_0xe70ae4)[_0x8003('0x16')](_0x491028);}return null;};}function patchUpdates(_0x4e15a6){return function(_0x12aabc){try{jsonpatch[_0x8003('0x1d')](_0x12aabc,_0x4e15a6,!![]);}catch(_0x14d255){return BPromise[_0x8003('0x1e')](_0x14d255);}return _0x12aabc[_0x8003('0x1f')]();};}function saveUpdates(_0x378d3d,_0x584021){return function(_0x400f22){if(_0x400f22){return _0x400f22[_0x8003('0x20')](_0x378d3d)[_0x8003('0x21')](function(_0x68f1d2){return _0x68f1d2;});}return null;};}function removeEntity(_0x26e0de,_0x526742){return function(_0x13f421){if(_0x13f421){return _0x13f421['destroy']()[_0x8003('0x21')](function(){_0x26e0de[_0x8003('0x14')](0xcc)[_0x8003('0x15')]();});}};}function handleEntityNotFound(_0x3434f6,_0x187768){return function(_0x4fcf4d){if(!_0x4fcf4d){_0x3434f6[_0x8003('0x13')](0x194);}return _0x4fcf4d;};}function handleError(_0x8c0fad,_0x114809){_0x114809=_0x114809||0x1f4;return function(_0x454eb6){logger[_0x8003('0x22')](_0x454eb6[_0x8003('0x23')]);if(_0x454eb6['name']){delete _0x454eb6['name'];}_0x8c0fad['status'](_0x114809)[_0x8003('0x24')](_0x454eb6);};}exports[_0x8003('0x25')]=function(_0x378778,_0x3a7906){var _0x6da951={},_0x3939a6={},_0x3135ab={'count':0x0,'rows':[]};var _0x49334c=_[_0x8003('0x26')](db['AnalyticTreeReport']['rawAttributes'],function(_0x6b713d){return{'name':_0x6b713d[_0x8003('0x27')],'type':_0x6b713d[_0x8003('0x28')]['key']};});_0x3939a6[_0x8003('0x29')]=_[_0x8003('0x26')](_0x49334c,'name');_0x3939a6['query']=_[_0x8003('0x2a')](_0x378778[_0x8003('0x2b')]);_0x3939a6[_0x8003('0x2c')]=_[_0x8003('0x2d')](_0x3939a6[_0x8003('0x29')],_0x3939a6[_0x8003('0x2b')]);_0x6da951[_0x8003('0x2e')]=_['intersection'](_0x3939a6[_0x8003('0x29')],qs[_0x8003('0x2f')](_0x378778['query']['fields']));_0x6da951[_0x8003('0x2e')]=_0x6da951[_0x8003('0x2e')][_0x8003('0x30')]?_0x6da951['attributes']:_0x3939a6[_0x8003('0x29')];if(!_0x378778['query'][_0x8003('0x31')](_0x8003('0x32'))){_0x6da951[_0x8003('0x19')]=qs['limit'](_0x378778['query']['limit']);_0x6da951[_0x8003('0x17')]=qs[_0x8003('0x17')](_0x378778[_0x8003('0x2b')]['offset']);}_0x6da951[_0x8003('0x33')]=qs[_0x8003('0x34')](_0x378778['query']['sort']);_0x6da951[_0x8003('0x35')]=qs[_0x8003('0x2c')](_[_0x8003('0x36')](_0x378778[_0x8003('0x2b')],_0x3939a6['filters']),_0x49334c);if(_0x378778['query'][_0x8003('0x37')]){_0x6da951['where']=_[_0x8003('0x38')](_0x6da951[_0x8003('0x35')],{'$or':_[_0x8003('0x26')](_0x49334c,function(_0x6f0486){if(_0x6f0486[_0x8003('0x28')]!==_0x8003('0x39')){var _0x78264a={};_0x78264a[_0x6f0486[_0x8003('0x3a')]]={'$like':'%'+_0x378778['query'][_0x8003('0x37')]+'%'};return _0x78264a;}})});}_0x6da951=_['merge']({},_0x6da951,_0x378778[_0x8003('0x3b')]);var _0x1f568a={'where':_0x6da951[_0x8003('0x35')]};return db[_0x8003('0x3c')][_0x8003('0x1a')](_0x1f568a)[_0x8003('0x21')](function(_0x2e00d9){_0x3135ab['count']=_0x2e00d9;if(_0x378778[_0x8003('0x2b')][_0x8003('0x3d')]){_0x6da951[_0x8003('0x3e')]=[{'all':!![]}];}return db[_0x8003('0x3c')][_0x8003('0x3f')](_0x6da951);})[_0x8003('0x21')](function(_0x254867){_0x3135ab[_0x8003('0x40')]=_0x254867;return _0x3135ab;})['then'](respondWithFilteredResult(_0x3a7906,_0x6da951))[_0x8003('0x41')](handleError(_0x3a7906,null));};exports['show']=function(_0x4215cc,_0x8a975){var _0x102d48={'raw':!![],'where':{'id':_0x4215cc[_0x8003('0x42')]['id']}},_0xe0fcd={};_0xe0fcd['model']=_[_0x8003('0x2a')](db['AnalyticTreeReport']['rawAttributes']);_0xe0fcd['query']=_[_0x8003('0x2a')](_0x4215cc[_0x8003('0x2b')]);_0xe0fcd[_0x8003('0x2c')]=_['intersection'](_0xe0fcd[_0x8003('0x29')],_0xe0fcd['query']);_0x102d48[_0x8003('0x2e')]=_[_0x8003('0x2d')](_0xe0fcd[_0x8003('0x29')],qs[_0x8003('0x2f')](_0x4215cc[_0x8003('0x2b')][_0x8003('0x2f')]));_0x102d48[_0x8003('0x2e')]=_0x102d48[_0x8003('0x2e')][_0x8003('0x30')]?_0x102d48[_0x8003('0x2e')]:_0xe0fcd[_0x8003('0x29')];if(_0x4215cc[_0x8003('0x2b')][_0x8003('0x3d')]){_0x102d48[_0x8003('0x3e')]=[{'all':!![]}];}_0x102d48=_[_0x8003('0x38')]({},_0x102d48,_0x4215cc['options']);return db[_0x8003('0x3c')][_0x8003('0x43')](_0x102d48)[_0x8003('0x21')](handleEntityNotFound(_0x8a975,null))[_0x8003('0x21')](respondWithResult(_0x8a975,null))[_0x8003('0x41')](handleError(_0x8a975,null));};exports[_0x8003('0x44')]=function(_0x56a621,_0x40e0b8){return db[_0x8003('0x3c')]['create'](_0x56a621[_0x8003('0x45')],{})[_0x8003('0x21')](respondWithResult(_0x40e0b8,0xc9))['catch'](handleError(_0x40e0b8,null));};exports[_0x8003('0x20')]=function(_0x2e1a9b,_0x5c2119){if(_0x2e1a9b['body']['id']){delete _0x2e1a9b[_0x8003('0x45')]['id'];}return db['AnalyticTreeReport'][_0x8003('0x43')]({'where':{'id':_0x2e1a9b[_0x8003('0x42')]['id']}})['then'](handleEntityNotFound(_0x5c2119,null))['then'](saveUpdates(_0x2e1a9b['body'],null))[_0x8003('0x21')](respondWithResult(_0x5c2119,null))['catch'](handleError(_0x5c2119,null));};exports[_0x8003('0x46')]=function(_0x397a2c,_0x3f3a7f){return db[_0x8003('0x3c')][_0x8003('0x43')]({'where':{'id':_0x397a2c[_0x8003('0x42')]['id']}})['then'](handleEntityNotFound(_0x3f3a7f,null))[_0x8003('0x21')](removeEntity(_0x3f3a7f,null))[_0x8003('0x41')](handleError(_0x3f3a7f,null));};
\ No newline at end of file
+var _0x4bf9=['attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','keys','rawAttributes','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','ejs','fs-extra','squel','crypto','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','destroy','then','name','AnalyticTreeReport','fieldName','type','key','model','map','query','filters','intersection','fields'];(function(_0x583a1a,_0x2e69ba){var _0x3472c9=function(_0x4ed9d5){while(--_0x4ed9d5){_0x583a1a['push'](_0x583a1a['shift']());}};_0x3472c9(++_0x2e69ba);}(_0x4bf9,0x1d2));var _0x94bf=function(_0x337905,_0x46d5da){_0x337905=_0x337905-0x0;var _0x615bbd=_0x4bf9[_0x337905];return _0x615bbd;};'use strict';var emlformat=require(_0x94bf('0x0'));var rimraf=require(_0x94bf('0x1'));var zipdir=require(_0x94bf('0x2'));var jsonpatch=require(_0x94bf('0x3'));var rp=require(_0x94bf('0x4'));var moment=require('moment');var BPromise=require(_0x94bf('0x5'));var Mustache=require(_0x94bf('0x6'));var util=require('util');var path=require(_0x94bf('0x7'));var sox=require(_0x94bf('0x8'));var csv=require('to-csv');var ejs=require(_0x94bf('0x9'));var fs=require('fs');var fs_extra=require(_0x94bf('0xa'));var _=require('lodash');var squel=require(_0x94bf('0xb'));var crypto=require(_0x94bf('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x94bf('0xd'));var toCsv=require(_0x94bf('0xe'));var querystring=require(_0x94bf('0xf'));var Papa=require(_0x94bf('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x94bf('0x11'));var as=require(_0x94bf('0x12'));var hardwareService=require(_0x94bf('0x13'));var logger=require(_0x94bf('0x14'))(_0x94bf('0x15'));var utils=require(_0x94bf('0x16'));var config=require(_0x94bf('0x17'));var licenseUtil=require(_0x94bf('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5206ba,_0x1358da){_0x1358da=_0x1358da||0xcc;return function(_0x32979e){if(_0x32979e){return _0x5206ba[_0x94bf('0x19')](_0x1358da);}return _0x5206ba[_0x94bf('0x1a')](_0x1358da)[_0x94bf('0x1b')]();};}function respondWithResult(_0x3a09c8,_0x3a3b99){_0x3a3b99=_0x3a3b99||0xc8;return function(_0x3a2a63){if(_0x3a2a63){return _0x3a09c8[_0x94bf('0x1a')](_0x3a3b99)[_0x94bf('0x1c')](_0x3a2a63);}};}function respondWithFilteredResult(_0x413cb9,_0x33627f){return function(_0x6decae){if(_0x6decae){var _0x34c7d8=typeof _0x33627f['offset']===_0x94bf('0x1d')&&typeof _0x33627f[_0x94bf('0x1e')]===_0x94bf('0x1d');var _0x3596f2=_0x6decae[_0x94bf('0x1f')];var _0x5c689a=_0x34c7d8?0x0:_0x33627f[_0x94bf('0x20')];var _0x18400d=_0x34c7d8?_0x6decae[_0x94bf('0x1f')]:_0x33627f[_0x94bf('0x20')]+_0x33627f[_0x94bf('0x1e')];var _0x1a5174;if(_0x18400d>=_0x3596f2){_0x18400d=_0x3596f2;_0x1a5174=0xc8;}else{_0x1a5174=0xce;}_0x413cb9[_0x94bf('0x1a')](_0x1a5174);return _0x413cb9[_0x94bf('0x21')](_0x94bf('0x22'),_0x5c689a+'-'+_0x18400d+'/'+_0x3596f2)['json'](_0x6decae);}return null;};}function patchUpdates(_0x1cf472){return function(_0x493843){try{jsonpatch[_0x94bf('0x23')](_0x493843,_0x1cf472,!![]);}catch(_0x58c8d9){return BPromise[_0x94bf('0x24')](_0x58c8d9);}return _0x493843[_0x94bf('0x25')]();};}function saveUpdates(_0x460300,_0x3f70f7){return function(_0x3dc00d){if(_0x3dc00d){return _0x3dc00d[_0x94bf('0x26')](_0x460300)['then'](function(_0x327424){return _0x327424;});}return null;};}function removeEntity(_0x3f9b66,_0x575e94){return function(_0x263b53){if(_0x263b53){return _0x263b53[_0x94bf('0x27')]()[_0x94bf('0x28')](function(){_0x3f9b66['status'](0xcc)[_0x94bf('0x1b')]();});}};}function handleEntityNotFound(_0x267392,_0x19d62e){return function(_0x24814d){if(!_0x24814d){_0x267392[_0x94bf('0x19')](0x194);}return _0x24814d;};}function handleError(_0x3da807,_0x59a063){_0x59a063=_0x59a063||0x1f4;return function(_0xb0c9b6){logger['error'](_0xb0c9b6['stack']);if(_0xb0c9b6[_0x94bf('0x29')]){delete _0xb0c9b6[_0x94bf('0x29')];}_0x3da807[_0x94bf('0x1a')](_0x59a063)['send'](_0xb0c9b6);};}exports['index']=function(_0x56c504,_0x32d99b){var _0x28e2ef={},_0x2ea8cc={},_0x128281={'count':0x0,'rows':[]};var _0x1a4d34=_['map'](db[_0x94bf('0x2a')]['rawAttributes'],function(_0x2d9108){return{'name':_0x2d9108[_0x94bf('0x2b')],'type':_0x2d9108[_0x94bf('0x2c')][_0x94bf('0x2d')]};});_0x2ea8cc[_0x94bf('0x2e')]=_[_0x94bf('0x2f')](_0x1a4d34,_0x94bf('0x29'));_0x2ea8cc['query']=_['keys'](_0x56c504[_0x94bf('0x30')]);_0x2ea8cc[_0x94bf('0x31')]=_[_0x94bf('0x32')](_0x2ea8cc[_0x94bf('0x2e')],_0x2ea8cc[_0x94bf('0x30')]);_0x28e2ef['attributes']=_['intersection'](_0x2ea8cc[_0x94bf('0x2e')],qs[_0x94bf('0x33')](_0x56c504[_0x94bf('0x30')]['fields']));_0x28e2ef[_0x94bf('0x34')]=_0x28e2ef['attributes'][_0x94bf('0x35')]?_0x28e2ef[_0x94bf('0x34')]:_0x2ea8cc[_0x94bf('0x2e')];if(!_0x56c504[_0x94bf('0x30')][_0x94bf('0x36')](_0x94bf('0x37'))){_0x28e2ef[_0x94bf('0x1e')]=qs[_0x94bf('0x1e')](_0x56c504[_0x94bf('0x30')][_0x94bf('0x1e')]);_0x28e2ef[_0x94bf('0x20')]=qs[_0x94bf('0x20')](_0x56c504[_0x94bf('0x30')][_0x94bf('0x20')]);}_0x28e2ef[_0x94bf('0x38')]=qs[_0x94bf('0x39')](_0x56c504[_0x94bf('0x30')][_0x94bf('0x39')]);_0x28e2ef[_0x94bf('0x3a')]=qs['filters'](_['pick'](_0x56c504[_0x94bf('0x30')],_0x2ea8cc['filters']),_0x1a4d34);if(_0x56c504[_0x94bf('0x30')][_0x94bf('0x3b')]){_0x28e2ef['where']=_[_0x94bf('0x3c')](_0x28e2ef[_0x94bf('0x3a')],{'$or':_['map'](_0x1a4d34,function(_0x561783){if(_0x561783['type']!==_0x94bf('0x3d')){var _0x1ffd2e={};_0x1ffd2e[_0x561783[_0x94bf('0x29')]]={'$like':'%'+_0x56c504['query'][_0x94bf('0x3b')]+'%'};return _0x1ffd2e;}})});}_0x28e2ef=_['merge']({},_0x28e2ef,_0x56c504[_0x94bf('0x3e')]);var _0x4e0a9d={'where':_0x28e2ef[_0x94bf('0x3a')]};return db[_0x94bf('0x2a')][_0x94bf('0x1f')](_0x4e0a9d)[_0x94bf('0x28')](function(_0x1e36b4){_0x128281[_0x94bf('0x1f')]=_0x1e36b4;if(_0x56c504[_0x94bf('0x30')][_0x94bf('0x3f')]){_0x28e2ef[_0x94bf('0x40')]=[{'all':!![]}];}return db['AnalyticTreeReport'][_0x94bf('0x41')](_0x28e2ef);})[_0x94bf('0x28')](function(_0x25881d){_0x128281['rows']=_0x25881d;return _0x128281;})[_0x94bf('0x28')](respondWithFilteredResult(_0x32d99b,_0x28e2ef))[_0x94bf('0x42')](handleError(_0x32d99b,null));};exports[_0x94bf('0x43')]=function(_0x55baa6,_0x4dfc88){var _0xf6e680={'raw':!![],'where':{'id':_0x55baa6[_0x94bf('0x44')]['id']}},_0x104f1c={};_0x104f1c[_0x94bf('0x2e')]=_[_0x94bf('0x45')](db[_0x94bf('0x2a')][_0x94bf('0x46')]);_0x104f1c[_0x94bf('0x30')]=_[_0x94bf('0x45')](_0x55baa6[_0x94bf('0x30')]);_0x104f1c['filters']=_['intersection'](_0x104f1c[_0x94bf('0x2e')],_0x104f1c[_0x94bf('0x30')]);_0xf6e680[_0x94bf('0x34')]=_[_0x94bf('0x32')](_0x104f1c['model'],qs[_0x94bf('0x33')](_0x55baa6[_0x94bf('0x30')]['fields']));_0xf6e680[_0x94bf('0x34')]=_0xf6e680[_0x94bf('0x34')][_0x94bf('0x35')]?_0xf6e680[_0x94bf('0x34')]:_0x104f1c[_0x94bf('0x2e')];if(_0x55baa6['query'][_0x94bf('0x3f')]){_0xf6e680['include']=[{'all':!![]}];}_0xf6e680=_[_0x94bf('0x3c')]({},_0xf6e680,_0x55baa6[_0x94bf('0x3e')]);return db[_0x94bf('0x2a')][_0x94bf('0x47')](_0xf6e680)[_0x94bf('0x28')](handleEntityNotFound(_0x4dfc88,null))[_0x94bf('0x28')](respondWithResult(_0x4dfc88,null))[_0x94bf('0x42')](handleError(_0x4dfc88,null));};exports[_0x94bf('0x48')]=function(_0x440d74,_0x109a30){return db[_0x94bf('0x2a')][_0x94bf('0x48')](_0x440d74[_0x94bf('0x49')],{})[_0x94bf('0x28')](respondWithResult(_0x109a30,0xc9))[_0x94bf('0x42')](handleError(_0x109a30,null));};exports[_0x94bf('0x26')]=function(_0x37c6c0,_0x127d24){if(_0x37c6c0[_0x94bf('0x49')]['id']){delete _0x37c6c0['body']['id'];}return db[_0x94bf('0x2a')][_0x94bf('0x47')]({'where':{'id':_0x37c6c0['params']['id']}})['then'](handleEntityNotFound(_0x127d24,null))[_0x94bf('0x28')](saveUpdates(_0x37c6c0[_0x94bf('0x49')],null))[_0x94bf('0x28')](respondWithResult(_0x127d24,null))[_0x94bf('0x42')](handleError(_0x127d24,null));};exports[_0x94bf('0x27')]=function(_0xa5b547,_0x44db35){return db[_0x94bf('0x2a')]['find']({'where':{'id':_0xa5b547[_0x94bf('0x44')]['id']}})[_0x94bf('0x28')](handleEntityNotFound(_0x44db35,null))[_0x94bf('0x28')](removeEntity(_0x44db35,null))[_0x94bf('0x42')](handleError(_0x44db35,null));};
\ No newline at end of file