Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / interval / interval.controller.js
index 8f2b685..68fed4b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4f66=['../../mysqldb','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','get','Intervals','UserProfileResource','sendStatus','error','send','index','rawAttributes','fieldName','type','model','name','query','filters','attributes','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','options','Interval','findAll','rows','show','params','keys','includeAll','include','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addInterval','IntervalId','getIntervals','map','hasOwnProperty','addIntervals','findOne','sequelize','transaction','bulkCreate','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x43459b,_0x220fae){var _0x557c66=function(_0xc4fd96){while(--_0xc4fd96){_0x43459b['push'](_0x43459b['shift']());}};_0x557c66(++_0x220fae);}(_0x4f66,0x1b9));var _0x64f6=function(_0x111ce3,_0x5e12aa){_0x111ce3=_0x111ce3-0x0;var _0xd0c223=_0x4f66[_0x111ce3];return _0xd0c223;};'use strict';var pdf=require(_0x64f6('0x0'));var emlformat=require(_0x64f6('0x1'));var rimraf=require(_0x64f6('0x2'));var zipdir=require(_0x64f6('0x3'));var jsonpatch=require(_0x64f6('0x4'));var rp=require(_0x64f6('0x5'));var moment=require(_0x64f6('0x6'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x64f6('0x7'));var path=require(_0x64f6('0x8'));var sox=require(_0x64f6('0x9'));var csv=require(_0x64f6('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x64f6('0xb'));var squel=require('squel');var crypto=require(_0x64f6('0xc'));var jsforce=require(_0x64f6('0xd'));var deskjs=require(_0x64f6('0xe'));var toCsv=require(_0x64f6('0xa'));var querystring=require(_0x64f6('0xf'));var Papa=require(_0x64f6('0x10'));var Redis=require(_0x64f6('0x11'));var authService=require(_0x64f6('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x64f6('0x13'));var logger=require(_0x64f6('0x14'))(_0x64f6('0x15'));var utils=require(_0x64f6('0x16'));var config=require(_0x64f6('0x17'));var db=require(_0x64f6('0x18'))['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x38776f,_0x54c587){_0x54c587=_0x54c587||0xcc;return function(_0x3a24fd){if(_0x3a24fd){return _0x38776f['sendStatus'](_0x54c587);}return _0x38776f[_0x64f6('0x19')](_0x54c587)[_0x64f6('0x1a')]();};}function respondWithResult(_0x1e2e34,_0x20c973){_0x20c973=_0x20c973||0xc8;return function(_0x3b23d0){if(_0x3b23d0){return _0x1e2e34[_0x64f6('0x19')](_0x20c973)[_0x64f6('0x1b')](_0x3b23d0);}};}function respondWithFilteredResult(_0x316597,_0x3a8883){return function(_0x13c658){if(_0x13c658){var _0x18515f=_0x13c658[_0x64f6('0x1c')],_0x36cd81=_0x3a8883[_0x64f6('0x1d')],_0x576aeb=_0x3a8883[_0x64f6('0x1d')]+_0x3a8883[_0x64f6('0x1e')],_0x545d2a;if(_0x576aeb>=_0x18515f){_0x576aeb=_0x18515f;_0x545d2a=0xc8;}else{_0x545d2a=0xce;}_0x316597[_0x64f6('0x19')](_0x545d2a);return _0x316597[_0x64f6('0x1f')](_0x64f6('0x20'),_0x36cd81+'-'+_0x576aeb+'/'+_0x18515f)['json'](_0x13c658);}return null;};}function patchUpdates(_0x238e88){return function(_0x534bfe){try{jsonpatch['apply'](_0x534bfe,_0x238e88,!![]);}catch(_0x4b627a){return BPromise[_0x64f6('0x21')](_0x4b627a);}return _0x534bfe[_0x64f6('0x22')]();};}function saveUpdates(_0x773318,_0x3566d4){return function(_0x385d0f){if(_0x385d0f){return _0x385d0f[_0x64f6('0x23')](_0x773318)[_0x64f6('0x24')](function(_0x2fd208){return _0x2fd208;});}return null;};}function removeEntity(_0x28b974,_0x4eff98){return function(_0x9c950c){if(_0x9c950c){return _0x9c950c[_0x64f6('0x25')]()[_0x64f6('0x24')](function(){var _0x5cd616=_0x9c950c[_0x64f6('0x26')]({'plain':!![]});var _0x391483=_0x64f6('0x27');return db[_0x64f6('0x28')][_0x64f6('0x25')]({'where':{'type':_0x391483,'resourceId':_0x5cd616['id']}})['then'](function(){return _0x9c950c;});})['then'](function(){_0x28b974[_0x64f6('0x19')](0xcc)[_0x64f6('0x1a')]();});}};}function handleEntityNotFound(_0x24359f,_0x160255){return function(_0xea95a3){if(!_0xea95a3){_0x24359f[_0x64f6('0x29')](0x194);}return _0xea95a3;};}function handleError(_0x6952ea,_0x1774bb){_0x1774bb=_0x1774bb||0x1f4;return function(_0x5daf28){logger[_0x64f6('0x2a')](_0x5daf28['stack']);if(_0x5daf28['name']){delete _0x5daf28['name'];}_0x6952ea['status'](_0x1774bb)[_0x64f6('0x2b')](_0x5daf28);};}exports[_0x64f6('0x2c')]=function(_0x58dcbc,_0xc80291){var _0x23df17={},_0x45f0cb={},_0x348b97={'count':0x0,'rows':[]};var _0x147b38=_['map'](db['Interval'][_0x64f6('0x2d')],function(_0xaca904){return{'name':_0xaca904[_0x64f6('0x2e')],'type':_0xaca904[_0x64f6('0x2f')]['key']};});_0x45f0cb[_0x64f6('0x30')]=_['map'](_0x147b38,_0x64f6('0x31'));_0x45f0cb['query']=_['keys'](_0x58dcbc[_0x64f6('0x32')]);_0x45f0cb[_0x64f6('0x33')]=_['intersection'](_0x45f0cb[_0x64f6('0x30')],_0x45f0cb[_0x64f6('0x32')]);_0x23df17[_0x64f6('0x34')]=_[_0x64f6('0x35')](_0x45f0cb[_0x64f6('0x30')],qs[_0x64f6('0x36')](_0x58dcbc[_0x64f6('0x32')][_0x64f6('0x36')]));_0x23df17[_0x64f6('0x34')]=_0x23df17[_0x64f6('0x34')][_0x64f6('0x37')]?_0x23df17[_0x64f6('0x34')]:_0x45f0cb['model'];if(!_0x58dcbc[_0x64f6('0x32')]['hasOwnProperty'](_0x64f6('0x38'))){_0x23df17['limit']=qs[_0x64f6('0x1e')](_0x58dcbc[_0x64f6('0x32')]['limit']);_0x23df17[_0x64f6('0x1d')]=qs[_0x64f6('0x1d')](_0x58dcbc[_0x64f6('0x32')][_0x64f6('0x1d')]);}_0x23df17[_0x64f6('0x39')]=qs[_0x64f6('0x3a')](_0x58dcbc[_0x64f6('0x32')][_0x64f6('0x3a')]);_0x23df17[_0x64f6('0x3b')]=qs[_0x64f6('0x33')](_[_0x64f6('0x3c')](_0x58dcbc[_0x64f6('0x32')],_0x45f0cb[_0x64f6('0x33')]),_0x147b38);if(_0x58dcbc['query'][_0x64f6('0x3d')]){_0x23df17[_0x64f6('0x3b')]=_[_0x64f6('0x3e')](_0x23df17[_0x64f6('0x3b')],{'$or':_['map'](_0x147b38,function(_0x36693b){if(_0x36693b[_0x64f6('0x2f')]!=='VIRTUAL'){var _0x2a6131={};_0x2a6131[_0x36693b[_0x64f6('0x31')]]={'$like':'%'+_0x58dcbc[_0x64f6('0x32')]['filter']+'%'};return _0x2a6131;}})});}_0x23df17=_[_0x64f6('0x3e')]({},_0x23df17,_0x58dcbc[_0x64f6('0x3f')]);var _0x246c76={'where':_0x23df17[_0x64f6('0x3b')]};return db['Interval']['count'](_0x246c76)[_0x64f6('0x24')](function(_0x3cda9d){_0x348b97[_0x64f6('0x1c')]=_0x3cda9d;if(_0x58dcbc[_0x64f6('0x32')]['includeAll']){_0x23df17['include']=[{'all':!![]}];}return db[_0x64f6('0x40')][_0x64f6('0x41')](_0x23df17);})[_0x64f6('0x24')](function(_0x491266){_0x348b97[_0x64f6('0x42')]=_0x491266;return _0x348b97;})[_0x64f6('0x24')](respondWithFilteredResult(_0xc80291,_0x23df17))['catch'](handleError(_0xc80291,null));};exports[_0x64f6('0x43')]=function(_0x24a7e9,_0x3c81e7){var _0x3d45ad={'raw':!![],'where':{'id':_0x24a7e9[_0x64f6('0x44')]['id']}},_0x24d2a0={};_0x24d2a0['model']=_[_0x64f6('0x45')](db[_0x64f6('0x40')][_0x64f6('0x2d')]);_0x24d2a0['query']=_[_0x64f6('0x45')](_0x24a7e9[_0x64f6('0x32')]);_0x24d2a0[_0x64f6('0x33')]=_['intersection'](_0x24d2a0[_0x64f6('0x30')],_0x24d2a0[_0x64f6('0x32')]);_0x3d45ad[_0x64f6('0x34')]=_[_0x64f6('0x35')](_0x24d2a0[_0x64f6('0x30')],qs['fields'](_0x24a7e9[_0x64f6('0x32')]['fields']));_0x3d45ad[_0x64f6('0x34')]=_0x3d45ad[_0x64f6('0x34')][_0x64f6('0x37')]?_0x3d45ad['attributes']:_0x24d2a0[_0x64f6('0x30')];if(_0x24a7e9[_0x64f6('0x32')][_0x64f6('0x46')]){_0x3d45ad[_0x64f6('0x47')]=[{'all':!![]}];}_0x3d45ad=_[_0x64f6('0x3e')]({},_0x3d45ad,_0x24a7e9[_0x64f6('0x3f')]);return db[_0x64f6('0x40')]['find'](_0x3d45ad)[_0x64f6('0x24')](handleEntityNotFound(_0x3c81e7,null))[_0x64f6('0x24')](respondWithResult(_0x3c81e7,null))[_0x64f6('0x48')](handleError(_0x3c81e7,null));};exports[_0x64f6('0x49')]=function(_0x5c3b35,_0xa0126e){return db['Interval']['create'](_0x5c3b35[_0x64f6('0x4a')],{})[_0x64f6('0x24')](function(_0x967f71){var _0x5d53b3=_0x5c3b35[_0x64f6('0x4b')][_0x64f6('0x26')]({'plain':!![]});if(!_0x5d53b3)throw new Error(_0x64f6('0x4c'));if(_0x5d53b3[_0x64f6('0x4d')]==='user'){var _0x8b7298=_0x967f71['get']({'plain':!![]});var _0x5dda07='Intervals';return db[_0x64f6('0x4e')][_0x64f6('0x4f')]({'where':{'name':_0x5dda07,'userProfileId':_0x5d53b3[_0x64f6('0x50')]},'raw':!![]})[_0x64f6('0x24')](function(_0x5a5a53){if(_0x5a5a53&&_0x5a5a53[_0x64f6('0x51')]===0x0){return db[_0x64f6('0x28')][_0x64f6('0x49')]({'name':_0x8b7298[_0x64f6('0x31')],'resourceId':_0x8b7298['id'],'type':_0x5a5a53[_0x64f6('0x31')],'sectionId':_0x5a5a53['id']},{})[_0x64f6('0x24')](function(){return _0x967f71;});}else{return _0x967f71;}})[_0x64f6('0x48')](function(_0x549621){logger[_0x64f6('0x2a')](_0x64f6('0x52'),_0x549621);throw _0x549621;});}return _0x967f71;})[_0x64f6('0x24')](respondWithResult(_0xa0126e,0xc9))[_0x64f6('0x48')](handleError(_0xa0126e,null));};exports[_0x64f6('0x23')]=function(_0x47aa3e,_0x469f23){if(_0x47aa3e['body']['id']){delete _0x47aa3e[_0x64f6('0x4a')]['id'];}return db[_0x64f6('0x40')][_0x64f6('0x4f')]({'where':{'id':_0x47aa3e[_0x64f6('0x44')]['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x469f23,null))[_0x64f6('0x24')](saveUpdates(_0x47aa3e[_0x64f6('0x4a')],null))[_0x64f6('0x24')](respondWithResult(_0x469f23,null))[_0x64f6('0x48')](handleError(_0x469f23,null));};exports[_0x64f6('0x25')]=function(_0x55f720,_0x6624ce){return db[_0x64f6('0x40')][_0x64f6('0x4f')]({'where':{'id':_0x55f720[_0x64f6('0x44')]['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x6624ce,null))[_0x64f6('0x24')](removeEntity(_0x6624ce,null))[_0x64f6('0x48')](handleError(_0x6624ce,null));};exports[_0x64f6('0x53')]=function(_0x493b47,_0x15ef12,_0x135ad4){if(_0x493b47[_0x64f6('0x4a')]['id']){delete _0x493b47[_0x64f6('0x4a')]['id'];}return db[_0x64f6('0x40')][_0x64f6('0x4f')]({'where':{'id':_0x493b47[_0x64f6('0x44')]['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x15ef12,null))[_0x64f6('0x24')](function(_0x2fe582){if(_0x2fe582){_0x493b47[_0x64f6('0x4a')][_0x64f6('0x54')]=_0x2fe582['id'];return db['Interval'][_0x64f6('0x49')](_0x493b47[_0x64f6('0x4a')]);}})[_0x64f6('0x24')](respondWithResult(_0x15ef12,null))['catch'](handleError(_0x15ef12,null));};exports[_0x64f6('0x55')]=function(_0x351802,_0x22f946,_0x76e5a6){var _0x4ecf1f={};var _0x3bd22b={};var _0x5d172d;var _0x39e742;return db[_0x64f6('0x40')]['findOne']({'where':{'id':_0x351802['params']['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x22f946,null))['then'](function(_0x54c0ec){if(_0x54c0ec){_0x5d172d=_0x54c0ec;_0x3bd22b[_0x64f6('0x30')]=_['keys'](db[_0x64f6('0x40')]['rawAttributes']);_0x3bd22b[_0x64f6('0x32')]=_[_0x64f6('0x45')](_0x351802[_0x64f6('0x32')]);_0x3bd22b[_0x64f6('0x33')]=_[_0x64f6('0x35')](_0x3bd22b['model'],_0x3bd22b[_0x64f6('0x32')]);_0x4ecf1f[_0x64f6('0x34')]=_[_0x64f6('0x35')](_0x3bd22b[_0x64f6('0x30')],qs[_0x64f6('0x36')](_0x351802[_0x64f6('0x32')][_0x64f6('0x36')]));_0x4ecf1f['attributes']=_0x4ecf1f[_0x64f6('0x34')][_0x64f6('0x37')]?_0x4ecf1f[_0x64f6('0x34')]:_0x3bd22b[_0x64f6('0x30')];_0x4ecf1f['order']=qs[_0x64f6('0x3a')](_0x351802[_0x64f6('0x32')][_0x64f6('0x3a')]);_0x4ecf1f['where']=qs[_0x64f6('0x33')](_['pick'](_0x351802[_0x64f6('0x32')],_0x3bd22b[_0x64f6('0x33')]));if(_0x351802[_0x64f6('0x32')][_0x64f6('0x3d')]){_0x4ecf1f['where']=_[_0x64f6('0x3e')](_0x4ecf1f[_0x64f6('0x3b')],{'$or':_[_0x64f6('0x56')](_0x4ecf1f[_0x64f6('0x34')],function(_0x98bcb){var _0x3fbf34={};_0x3fbf34[_0x98bcb]={'$like':'%'+_0x351802['query'][_0x64f6('0x3d')]+'%'};return _0x3fbf34;})});}_0x4ecf1f=_['merge']({},_0x4ecf1f,_0x351802[_0x64f6('0x3f')]);return _0x5d172d['getIntervals'](_0x4ecf1f);}})[_0x64f6('0x24')](function(_0x382a93){if(_0x382a93){_0x39e742=_0x382a93['length'];if(!_0x351802[_0x64f6('0x32')][_0x64f6('0x57')](_0x64f6('0x38'))){_0x4ecf1f['limit']=qs[_0x64f6('0x1e')](_0x351802[_0x64f6('0x32')][_0x64f6('0x1e')]);_0x4ecf1f[_0x64f6('0x1d')]=qs[_0x64f6('0x1d')](_0x351802[_0x64f6('0x32')][_0x64f6('0x1d')]);}return _0x5d172d[_0x64f6('0x55')](_0x4ecf1f);}})['then'](function(_0x2d0bf9){if(_0x2d0bf9){return _0x2d0bf9?{'count':_0x39e742,'rows':_0x2d0bf9}:null;}})['then'](respondWithResult(_0x22f946,null))[_0x64f6('0x48')](handleError(_0x22f946,null));};exports[_0x64f6('0x58')]=function(_0x27fe94,_0x4c6113,_0x561de3){return db['Interval'][_0x64f6('0x59')]({'where':{'id':_0x27fe94['params']['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x4c6113,null))[_0x64f6('0x24')](function(_0x56fb40){if(_0x56fb40){return db[_0x64f6('0x5a')][_0x64f6('0x5b')](function(_0x50a9c8){return db[_0x64f6('0x40')][_0x64f6('0x25')]({'where':{'IntervalId':_0x27fe94[_0x64f6('0x44')]['id']},'transaction':_0x50a9c8})[_0x64f6('0x24')](function(_0xe41c96){var _0x3c26b5=_['map'](_0x27fe94[_0x64f6('0x4a')],function(_0x1659d5){delete _0x1659d5['id'];_0x1659d5[_0x64f6('0x54')]=_0x27fe94[_0x64f6('0x44')]['id'];return _0x1659d5;});return db['Interval'][_0x64f6('0x5c')](_0x3c26b5,{'transaction':_0x50a9c8});});})[_0x64f6('0x24')](function(){return db[_0x64f6('0x40')][_0x64f6('0x41')]({'where':{'IntervalId':_0x27fe94['params']['id']}});});}})[_0x64f6('0x24')](respondWithResult(_0x4c6113,null))[_0x64f6('0x48')](handleError(_0x4c6113,null));};
\ No newline at end of file
+var _0x7a3e=['params','rawAttributes','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','find','IntervalId','getIntervals','findOne','merge','addIntervals','sequelize','bulkCreate','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','ejs','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','offset','limit','json','apply','reject','save','update','destroy','then','get','Intervals','stack','name','send','index','map','Interval','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','filter','options','count','includeAll','include','findAll','rows','show'];(function(_0x21aec3,_0x5c97e9){var _0x288bbc=function(_0x2283fe){while(--_0x2283fe){_0x21aec3['push'](_0x21aec3['shift']());}};_0x288bbc(++_0x5c97e9);}(_0x7a3e,0xc6));var _0xe7a3=function(_0x5735f4,_0x462a3c){_0x5735f4=_0x5735f4-0x0;var _0x2abe19=_0x7a3e[_0x5735f4];return _0x2abe19;};'use strict';var pdf=require(_0xe7a3('0x0'));var emlformat=require(_0xe7a3('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xe7a3('0x2'));var jsonpatch=require(_0xe7a3('0x3'));var rp=require(_0xe7a3('0x4'));var moment=require(_0xe7a3('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xe7a3('0x6'));var util=require(_0xe7a3('0x7'));var path=require(_0xe7a3('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xe7a3('0x9'));var fs=require('fs');var _=require(_0xe7a3('0xa'));var squel=require(_0xe7a3('0xb'));var crypto=require(_0xe7a3('0xc'));var jsforce=require(_0xe7a3('0xd'));var deskjs=require(_0xe7a3('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xe7a3('0xf'));var authService=require(_0xe7a3('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xe7a3('0x11'))(_0xe7a3('0x12'));var utils=require('../../config/utils');var config=require(_0xe7a3('0x13'));var licenseUtil=require(_0xe7a3('0x14'));var db=require(_0xe7a3('0x15'))['db'];var extensions=require(_0xe7a3('0x16'));function respondWithStatusCode(_0x3ab6ab,_0x48e655){_0x48e655=_0x48e655||0xcc;return function(_0xd229ac){if(_0xd229ac){return _0x3ab6ab[_0xe7a3('0x17')](_0x48e655);}return _0x3ab6ab[_0xe7a3('0x18')](_0x48e655)[_0xe7a3('0x19')]();};}function respondWithResult(_0x2e1f01,_0x3814a1){_0x3814a1=_0x3814a1||0xc8;return function(_0x4a73b8){if(_0x4a73b8){return _0x2e1f01[_0xe7a3('0x18')](_0x3814a1)['json'](_0x4a73b8);}};}function respondWithFilteredResult(_0x65dd07,_0x425cf5){return function(_0x179306){if(_0x179306){var _0x470e35=_0x179306['count'],_0x23ef0b=_0x425cf5[_0xe7a3('0x1a')],_0x5b35b5=_0x425cf5[_0xe7a3('0x1a')]+_0x425cf5[_0xe7a3('0x1b')],_0x59cee9;if(_0x5b35b5>=_0x470e35){_0x5b35b5=_0x470e35;_0x59cee9=0xc8;}else{_0x59cee9=0xce;}_0x65dd07[_0xe7a3('0x18')](_0x59cee9);return _0x65dd07['set']('Content-Range',_0x23ef0b+'-'+_0x5b35b5+'/'+_0x470e35)[_0xe7a3('0x1c')](_0x179306);}return null;};}function patchUpdates(_0x1cdd8e){return function(_0x102080){try{jsonpatch[_0xe7a3('0x1d')](_0x102080,_0x1cdd8e,!![]);}catch(_0x3fbf6f){return BPromise[_0xe7a3('0x1e')](_0x3fbf6f);}return _0x102080[_0xe7a3('0x1f')]();};}function saveUpdates(_0x48936b,_0x5b4dcf){return function(_0x51f2a8){if(_0x51f2a8){return _0x51f2a8[_0xe7a3('0x20')](_0x48936b)['then'](function(_0x302b32){return _0x302b32;});}return null;};}function removeEntity(_0x4e9d43,_0x261618){return function(_0x230e50){if(_0x230e50){return _0x230e50[_0xe7a3('0x21')]()[_0xe7a3('0x22')](function(){var _0x331494=_0x230e50[_0xe7a3('0x23')]({'plain':!![]});var _0x33f63e=_0xe7a3('0x24');return db['UserProfileResource'][_0xe7a3('0x21')]({'where':{'type':_0x33f63e,'resourceId':_0x331494['id']}})[_0xe7a3('0x22')](function(){return _0x230e50;});})[_0xe7a3('0x22')](function(){_0x4e9d43['status'](0xcc)[_0xe7a3('0x19')]();});}};}function handleEntityNotFound(_0x104d79,_0x1f13dd){return function(_0x50a40e){if(!_0x50a40e){_0x104d79['sendStatus'](0x194);}return _0x50a40e;};}function handleError(_0x16e010,_0x2faccc){_0x2faccc=_0x2faccc||0x1f4;return function(_0x3383f8){logger['error'](_0x3383f8[_0xe7a3('0x25')]);if(_0x3383f8['name']){delete _0x3383f8[_0xe7a3('0x26')];}_0x16e010[_0xe7a3('0x18')](_0x2faccc)[_0xe7a3('0x27')](_0x3383f8);};}exports[_0xe7a3('0x28')]=function(_0x1580c6,_0x4a87aa){var _0xa691b9={},_0x3241b1={},_0x5f07d2={'count':0x0,'rows':[]};var _0x2aa72e=_[_0xe7a3('0x29')](db[_0xe7a3('0x2a')]['rawAttributes'],function(_0xb975a0){return{'name':_0xb975a0[_0xe7a3('0x2b')],'type':_0xb975a0[_0xe7a3('0x2c')][_0xe7a3('0x2d')]};});_0x3241b1[_0xe7a3('0x2e')]=_[_0xe7a3('0x29')](_0x2aa72e,_0xe7a3('0x26'));_0x3241b1[_0xe7a3('0x2f')]=_[_0xe7a3('0x30')](_0x1580c6['query']);_0x3241b1[_0xe7a3('0x31')]=_[_0xe7a3('0x32')](_0x3241b1['model'],_0x3241b1['query']);_0xa691b9[_0xe7a3('0x33')]=_[_0xe7a3('0x32')](_0x3241b1[_0xe7a3('0x2e')],qs[_0xe7a3('0x34')](_0x1580c6[_0xe7a3('0x2f')][_0xe7a3('0x34')]));_0xa691b9[_0xe7a3('0x33')]=_0xa691b9[_0xe7a3('0x33')][_0xe7a3('0x35')]?_0xa691b9[_0xe7a3('0x33')]:_0x3241b1[_0xe7a3('0x2e')];if(!_0x1580c6[_0xe7a3('0x2f')][_0xe7a3('0x36')](_0xe7a3('0x37'))){_0xa691b9[_0xe7a3('0x1b')]=qs[_0xe7a3('0x1b')](_0x1580c6[_0xe7a3('0x2f')][_0xe7a3('0x1b')]);_0xa691b9['offset']=qs['offset'](_0x1580c6[_0xe7a3('0x2f')][_0xe7a3('0x1a')]);}_0xa691b9[_0xe7a3('0x38')]=qs[_0xe7a3('0x39')](_0x1580c6['query'][_0xe7a3('0x39')]);_0xa691b9[_0xe7a3('0x3a')]=qs[_0xe7a3('0x31')](_[_0xe7a3('0x3b')](_0x1580c6[_0xe7a3('0x2f')],_0x3241b1[_0xe7a3('0x31')]),_0x2aa72e);if(_0x1580c6[_0xe7a3('0x2f')]['filter']){_0xa691b9[_0xe7a3('0x3a')]=_['merge'](_0xa691b9[_0xe7a3('0x3a')],{'$or':_[_0xe7a3('0x29')](_0x2aa72e,function(_0x549bf7){if(_0x549bf7[_0xe7a3('0x2c')]!==_0xe7a3('0x3c')){var _0x4dbaf5={};_0x4dbaf5[_0x549bf7[_0xe7a3('0x26')]]={'$like':'%'+_0x1580c6['query'][_0xe7a3('0x3d')]+'%'};return _0x4dbaf5;}})});}_0xa691b9=_['merge']({},_0xa691b9,_0x1580c6[_0xe7a3('0x3e')]);var _0x1a64cc={'where':_0xa691b9[_0xe7a3('0x3a')]};return db[_0xe7a3('0x2a')][_0xe7a3('0x3f')](_0x1a64cc)[_0xe7a3('0x22')](function(_0x3e9a46){_0x5f07d2['count']=_0x3e9a46;if(_0x1580c6[_0xe7a3('0x2f')][_0xe7a3('0x40')]){_0xa691b9[_0xe7a3('0x41')]=[{'all':!![]}];}return db[_0xe7a3('0x2a')][_0xe7a3('0x42')](_0xa691b9);})[_0xe7a3('0x22')](function(_0x3c8c3a){_0x5f07d2[_0xe7a3('0x43')]=_0x3c8c3a;return _0x5f07d2;})[_0xe7a3('0x22')](respondWithFilteredResult(_0x4a87aa,_0xa691b9))['catch'](handleError(_0x4a87aa,null));};exports[_0xe7a3('0x44')]=function(_0x2040cd,_0x492f2a){var _0x4c012f={'raw':!![],'where':{'id':_0x2040cd[_0xe7a3('0x45')]['id']}},_0x590aef={};_0x590aef[_0xe7a3('0x2e')]=_[_0xe7a3('0x30')](db[_0xe7a3('0x2a')][_0xe7a3('0x46')]);_0x590aef['query']=_[_0xe7a3('0x30')](_0x2040cd[_0xe7a3('0x2f')]);_0x590aef[_0xe7a3('0x31')]=_['intersection'](_0x590aef[_0xe7a3('0x2e')],_0x590aef['query']);_0x4c012f[_0xe7a3('0x33')]=_['intersection'](_0x590aef['model'],qs[_0xe7a3('0x34')](_0x2040cd[_0xe7a3('0x2f')]['fields']));_0x4c012f[_0xe7a3('0x33')]=_0x4c012f[_0xe7a3('0x33')][_0xe7a3('0x35')]?_0x4c012f[_0xe7a3('0x33')]:_0x590aef[_0xe7a3('0x2e')];if(_0x2040cd['query']['includeAll']){_0x4c012f[_0xe7a3('0x41')]=[{'all':!![]}];}_0x4c012f=_['merge']({},_0x4c012f,_0x2040cd[_0xe7a3('0x3e')]);return db[_0xe7a3('0x2a')]['find'](_0x4c012f)['then'](handleEntityNotFound(_0x492f2a,null))[_0xe7a3('0x22')](respondWithResult(_0x492f2a,null))['catch'](handleError(_0x492f2a,null));};exports[_0xe7a3('0x47')]=function(_0x478ae2,_0x1b03ca){return db[_0xe7a3('0x2a')]['create'](_0x478ae2['body'],{})[_0xe7a3('0x22')](function(_0x3d2af7){var _0x2b3ecf=_0x478ae2[_0xe7a3('0x48')][_0xe7a3('0x23')]({'plain':!![]});if(!_0x2b3ecf)throw new Error(_0xe7a3('0x49'));if(_0x2b3ecf[_0xe7a3('0x4a')]==='user'){var _0x56eb68=_0x3d2af7[_0xe7a3('0x23')]({'plain':!![]});var _0xec0996=_0xe7a3('0x24');return db[_0xe7a3('0x4b')]['find']({'where':{'name':_0xec0996,'userProfileId':_0x2b3ecf[_0xe7a3('0x4c')]},'raw':!![]})[_0xe7a3('0x22')](function(_0x5958b4){if(_0x5958b4&&_0x5958b4[_0xe7a3('0x4d')]===0x0){return db['UserProfileResource']['create']({'name':_0x56eb68[_0xe7a3('0x26')],'resourceId':_0x56eb68['id'],'type':_0x5958b4['name'],'sectionId':_0x5958b4['id']},{})[_0xe7a3('0x22')](function(){return _0x3d2af7;});}else{return _0x3d2af7;}})[_0xe7a3('0x4e')](function(_0x1853a3){logger['error'](_0xe7a3('0x4f'),_0x1853a3);throw _0x1853a3;});}return _0x3d2af7;})[_0xe7a3('0x22')](respondWithResult(_0x1b03ca,0xc9))[_0xe7a3('0x4e')](handleError(_0x1b03ca,null));};exports[_0xe7a3('0x20')]=function(_0x48f6c3,_0x3ed02f){if(_0x48f6c3[_0xe7a3('0x50')]['id']){delete _0x48f6c3['body']['id'];}return db['Interval'][_0xe7a3('0x51')]({'where':{'id':_0x48f6c3['params']['id']}})[_0xe7a3('0x22')](handleEntityNotFound(_0x3ed02f,null))[_0xe7a3('0x22')](saveUpdates(_0x48f6c3[_0xe7a3('0x50')],null))['then'](respondWithResult(_0x3ed02f,null))[_0xe7a3('0x4e')](handleError(_0x3ed02f,null));};exports[_0xe7a3('0x21')]=function(_0x247fa5,_0x5657ea){return db[_0xe7a3('0x2a')][_0xe7a3('0x51')]({'where':{'id':_0x247fa5['params']['id']}})[_0xe7a3('0x22')](handleEntityNotFound(_0x5657ea,null))[_0xe7a3('0x22')](removeEntity(_0x5657ea,null))[_0xe7a3('0x4e')](handleError(_0x5657ea,null));};exports['addInterval']=function(_0xf5b5ec,_0xc57d41,_0x2ecab0){if(_0xf5b5ec[_0xe7a3('0x50')]['id']){delete _0xf5b5ec[_0xe7a3('0x50')]['id'];}return db[_0xe7a3('0x2a')]['find']({'where':{'id':_0xf5b5ec[_0xe7a3('0x45')]['id']}})['then'](handleEntityNotFound(_0xc57d41,null))[_0xe7a3('0x22')](function(_0x403d86){if(_0x403d86){_0xf5b5ec[_0xe7a3('0x50')][_0xe7a3('0x52')]=_0x403d86['id'];return db[_0xe7a3('0x2a')]['create'](_0xf5b5ec[_0xe7a3('0x50')]);}})[_0xe7a3('0x22')](respondWithResult(_0xc57d41,null))['catch'](handleError(_0xc57d41,null));};exports[_0xe7a3('0x53')]=function(_0x1207bc,_0x492a97,_0x30ae51){var _0x3f2145={};var _0x353675={};var _0x5a3402;var _0xf755d0;return db[_0xe7a3('0x2a')][_0xe7a3('0x54')]({'where':{'id':_0x1207bc[_0xe7a3('0x45')]['id']}})[_0xe7a3('0x22')](handleEntityNotFound(_0x492a97,null))[_0xe7a3('0x22')](function(_0x51dd48){if(_0x51dd48){_0x5a3402=_0x51dd48;_0x353675['model']=_[_0xe7a3('0x30')](db['Interval'][_0xe7a3('0x46')]);_0x353675[_0xe7a3('0x2f')]=_['keys'](_0x1207bc[_0xe7a3('0x2f')]);_0x353675[_0xe7a3('0x31')]=_[_0xe7a3('0x32')](_0x353675[_0xe7a3('0x2e')],_0x353675[_0xe7a3('0x2f')]);_0x3f2145[_0xe7a3('0x33')]=_['intersection'](_0x353675[_0xe7a3('0x2e')],qs[_0xe7a3('0x34')](_0x1207bc['query']['fields']));_0x3f2145[_0xe7a3('0x33')]=_0x3f2145['attributes'][_0xe7a3('0x35')]?_0x3f2145[_0xe7a3('0x33')]:_0x353675[_0xe7a3('0x2e')];_0x3f2145['order']=qs['sort'](_0x1207bc['query'][_0xe7a3('0x39')]);_0x3f2145['where']=qs[_0xe7a3('0x31')](_[_0xe7a3('0x3b')](_0x1207bc['query'],_0x353675['filters']));if(_0x1207bc[_0xe7a3('0x2f')][_0xe7a3('0x3d')]){_0x3f2145[_0xe7a3('0x3a')]=_[_0xe7a3('0x55')](_0x3f2145['where'],{'$or':_[_0xe7a3('0x29')](_0x3f2145[_0xe7a3('0x33')],function(_0x2f8cf8){var _0x1804fc={};_0x1804fc[_0x2f8cf8]={'$like':'%'+_0x1207bc[_0xe7a3('0x2f')]['filter']+'%'};return _0x1804fc;})});}_0x3f2145=_[_0xe7a3('0x55')]({},_0x3f2145,_0x1207bc[_0xe7a3('0x3e')]);return _0x5a3402['getIntervals'](_0x3f2145);}})[_0xe7a3('0x22')](function(_0x570711){if(_0x570711){_0xf755d0=_0x570711[_0xe7a3('0x35')];if(!_0x1207bc[_0xe7a3('0x2f')]['hasOwnProperty'](_0xe7a3('0x37'))){_0x3f2145[_0xe7a3('0x1b')]=qs[_0xe7a3('0x1b')](_0x1207bc[_0xe7a3('0x2f')][_0xe7a3('0x1b')]);_0x3f2145['offset']=qs['offset'](_0x1207bc['query'][_0xe7a3('0x1a')]);}return _0x5a3402[_0xe7a3('0x53')](_0x3f2145);}})[_0xe7a3('0x22')](function(_0x225fa7){if(_0x225fa7){return _0x225fa7?{'count':_0xf755d0,'rows':_0x225fa7}:null;}})[_0xe7a3('0x22')](respondWithResult(_0x492a97,null))[_0xe7a3('0x4e')](handleError(_0x492a97,null));};exports[_0xe7a3('0x56')]=function(_0x5510b3,_0x4e51fd,_0x43ffbf){return db[_0xe7a3('0x2a')][_0xe7a3('0x54')]({'where':{'id':_0x5510b3[_0xe7a3('0x45')]['id']}})['then'](handleEntityNotFound(_0x4e51fd,null))[_0xe7a3('0x22')](function(_0x57b9b5){if(_0x57b9b5){return db[_0xe7a3('0x57')]['transaction'](function(_0x497ad6){return db['Interval'][_0xe7a3('0x21')]({'where':{'IntervalId':_0x5510b3[_0xe7a3('0x45')]['id']},'transaction':_0x497ad6})[_0xe7a3('0x22')](function(_0x1ca6fc){var _0x782c69=_[_0xe7a3('0x29')](_0x5510b3[_0xe7a3('0x50')],function(_0x3f465d){delete _0x3f465d['id'];_0x3f465d[_0xe7a3('0x52')]=_0x5510b3['params']['id'];return _0x3f465d;});return db[_0xe7a3('0x2a')][_0xe7a3('0x58')](_0x782c69,{'transaction':_0x497ad6});});})[_0xe7a3('0x22')](function(){return db[_0xe7a3('0x2a')][_0xe7a3('0x42')]({'where':{'IntervalId':_0x5510b3[_0xe7a3('0x45')]['id']}});});}})['then'](respondWithResult(_0x4e51fd,null))[_0xe7a3('0x4e')](handleError(_0x4e51fd,null));};
\ No newline at end of file