Built motion from commit 5b761a7b.|2.5.36
[motion2.git] / server / api / interval / interval.controller.js
index 71de23d..e71ea0d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfcef=['set','Content-Range','apply','reject','save','then','get','UserProfileResource','error','stack','name','send','map','Interval','rawAttributes','fieldName','key','query','keys','filters','intersection','model','attributes','length','hasOwnProperty','nolimit','limit','offset','order','sort','filter','where','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','show','params','fields','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Intervals','UserProfileSection','find','userProfileId','autoAssociation','update','addInterval','IntervalId','getIntervals','findOne','addIntervals','sequelize','transaction','destroy','bulkCreate','html-pdf','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','count'];(function(_0x189f54,_0x5f03d1){var _0x44e446=function(_0x27139b){while(--_0x27139b){_0x189f54['push'](_0x189f54['shift']());}};_0x44e446(++_0x5f03d1);}(_0xfcef,0x1bc));var _0xffce=function(_0x87523,_0x29ce7e){_0x87523=_0x87523-0x0;var _0x565bba=_0xfcef[_0x87523];return _0x565bba;};'use strict';var pdf=require(_0xffce('0x0'));var emlformat=require(_0xffce('0x1'));var rimraf=require(_0xffce('0x2'));var zipdir=require(_0xffce('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xffce('0x4'));var moment=require('moment');var BPromise=require(_0xffce('0x5'));var Mustache=require(_0xffce('0x6'));var util=require(_0xffce('0x7'));var path=require(_0xffce('0x8'));var sox=require(_0xffce('0x9'));var csv=require(_0xffce('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xffce('0xb'));var squel=require(_0xffce('0xc'));var crypto=require(_0xffce('0xd'));var jsforce=require(_0xffce('0xe'));var deskjs=require(_0xffce('0xf'));var toCsv=require(_0xffce('0xa'));var querystring=require(_0xffce('0x10'));var Papa=require(_0xffce('0x11'));var Redis=require(_0xffce('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xffce('0x13'));var as=require(_0xffce('0x14'));var hardwareService=require(_0xffce('0x15'));var logger=require(_0xffce('0x16'))(_0xffce('0x17'));var utils=require(_0xffce('0x18'));var config=require(_0xffce('0x19'));var db=require(_0xffce('0x1a'))['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x15e521,_0x1a0d55){_0x1a0d55=_0x1a0d55||0xcc;return function(_0x5677e7){if(_0x5677e7){return _0x15e521[_0xffce('0x1b')](_0x1a0d55);}return _0x15e521['status'](_0x1a0d55)[_0xffce('0x1c')]();};}function respondWithResult(_0x17f18d,_0x18e56a){_0x18e56a=_0x18e56a||0xc8;return function(_0x5350b9){if(_0x5350b9){return _0x17f18d[_0xffce('0x1d')](_0x18e56a)['json'](_0x5350b9);}};}function respondWithFilteredResult(_0x363b9,_0x446bdf){return function(_0x271814){if(_0x271814){var _0x59fc54=_0x271814[_0xffce('0x1e')],_0xfb5b5e=_0x446bdf['offset'],_0x1c17c6=_0x446bdf['offset']+_0x446bdf['limit'],_0x3fb2c1;if(_0x1c17c6>=_0x59fc54){_0x1c17c6=_0x59fc54;_0x3fb2c1=0xc8;}else{_0x3fb2c1=0xce;}_0x363b9[_0xffce('0x1d')](_0x3fb2c1);return _0x363b9[_0xffce('0x1f')](_0xffce('0x20'),_0xfb5b5e+'-'+_0x1c17c6+'/'+_0x59fc54)['json'](_0x271814);}return null;};}function patchUpdates(_0x337c3e){return function(_0x43abef){try{jsonpatch[_0xffce('0x21')](_0x43abef,_0x337c3e,!![]);}catch(_0x3d968b){return BPromise[_0xffce('0x22')](_0x3d968b);}return _0x43abef[_0xffce('0x23')]();};}function saveUpdates(_0x427d3e,_0x2c4527){return function(_0x2631e7){if(_0x2631e7){return _0x2631e7['update'](_0x427d3e)['then'](function(_0x142098){return _0x142098;});}return null;};}function removeEntity(_0x485d3a,_0x3ce45d){return function(_0x3f5272){if(_0x3f5272){return _0x3f5272['destroy']()[_0xffce('0x24')](function(){var _0x5c8576=_0x3f5272[_0xffce('0x25')]({'plain':!![]});var _0x2e7fe8='Intervals';return db[_0xffce('0x26')]['destroy']({'where':{'type':_0x2e7fe8,'resourceId':_0x5c8576['id']}})['then'](function(){return _0x3f5272;});})['then'](function(){_0x485d3a[_0xffce('0x1d')](0xcc)[_0xffce('0x1c')]();});}};}function handleEntityNotFound(_0x1ae614,_0x2b8179){return function(_0x2d7329){if(!_0x2d7329){_0x1ae614[_0xffce('0x1b')](0x194);}return _0x2d7329;};}function handleError(_0xd1cd61,_0xf68181){_0xf68181=_0xf68181||0x1f4;return function(_0x1fba7d){logger[_0xffce('0x27')](_0x1fba7d[_0xffce('0x28')]);if(_0x1fba7d[_0xffce('0x29')]){delete _0x1fba7d['name'];}_0xd1cd61[_0xffce('0x1d')](_0xf68181)[_0xffce('0x2a')](_0x1fba7d);};}exports['index']=function(_0xe75f86,_0x52c08c){var _0x652be0={},_0x13396b={},_0x2526f6={'count':0x0,'rows':[]};var _0x25dac2=_[_0xffce('0x2b')](db[_0xffce('0x2c')][_0xffce('0x2d')],function(_0x4ae90c){return{'name':_0x4ae90c[_0xffce('0x2e')],'type':_0x4ae90c['type'][_0xffce('0x2f')]};});_0x13396b['model']=_['map'](_0x25dac2,_0xffce('0x29'));_0x13396b[_0xffce('0x30')]=_[_0xffce('0x31')](_0xe75f86[_0xffce('0x30')]);_0x13396b[_0xffce('0x32')]=_[_0xffce('0x33')](_0x13396b[_0xffce('0x34')],_0x13396b['query']);_0x652be0['attributes']=_[_0xffce('0x33')](_0x13396b['model'],qs['fields'](_0xe75f86[_0xffce('0x30')]['fields']));_0x652be0[_0xffce('0x35')]=_0x652be0[_0xffce('0x35')][_0xffce('0x36')]?_0x652be0[_0xffce('0x35')]:_0x13396b[_0xffce('0x34')];if(!_0xe75f86[_0xffce('0x30')][_0xffce('0x37')](_0xffce('0x38'))){_0x652be0['limit']=qs['limit'](_0xe75f86['query'][_0xffce('0x39')]);_0x652be0[_0xffce('0x3a')]=qs[_0xffce('0x3a')](_0xe75f86[_0xffce('0x30')]['offset']);}_0x652be0[_0xffce('0x3b')]=qs['sort'](_0xe75f86[_0xffce('0x30')][_0xffce('0x3c')]);_0x652be0['where']=qs[_0xffce('0x32')](_['pick'](_0xe75f86[_0xffce('0x30')],_0x13396b[_0xffce('0x32')]),_0x25dac2);if(_0xe75f86[_0xffce('0x30')][_0xffce('0x3d')]){_0x652be0[_0xffce('0x3e')]=_[_0xffce('0x3f')](_0x652be0[_0xffce('0x3e')],{'$or':_[_0xffce('0x2b')](_0x25dac2,function(_0x5482f9){if(_0x5482f9[_0xffce('0x40')]!==_0xffce('0x41')){var _0x41ef79={};_0x41ef79[_0x5482f9[_0xffce('0x29')]]={'$like':'%'+_0xe75f86[_0xffce('0x30')][_0xffce('0x3d')]+'%'};return _0x41ef79;}})});}_0x652be0=_[_0xffce('0x3f')]({},_0x652be0,_0xe75f86[_0xffce('0x42')]);var _0x2ae165={'where':_0x652be0[_0xffce('0x3e')]};return db[_0xffce('0x2c')]['count'](_0x2ae165)['then'](function(_0xa473f0){_0x2526f6[_0xffce('0x1e')]=_0xa473f0;if(_0xe75f86[_0xffce('0x30')][_0xffce('0x43')]){_0x652be0[_0xffce('0x44')]=[{'all':!![]}];}return db[_0xffce('0x2c')][_0xffce('0x45')](_0x652be0);})[_0xffce('0x24')](function(_0x31d7e8){_0x2526f6[_0xffce('0x46')]=_0x31d7e8;return _0x2526f6;})[_0xffce('0x24')](respondWithFilteredResult(_0x52c08c,_0x652be0))['catch'](handleError(_0x52c08c,null));};exports[_0xffce('0x47')]=function(_0x132356,_0x5d58f5){var _0x2b388b={'raw':!![],'where':{'id':_0x132356[_0xffce('0x48')]['id']}},_0x22be56={};_0x22be56[_0xffce('0x34')]=_[_0xffce('0x31')](db[_0xffce('0x2c')][_0xffce('0x2d')]);_0x22be56[_0xffce('0x30')]=_['keys'](_0x132356['query']);_0x22be56[_0xffce('0x32')]=_[_0xffce('0x33')](_0x22be56['model'],_0x22be56['query']);_0x2b388b[_0xffce('0x35')]=_['intersection'](_0x22be56[_0xffce('0x34')],qs[_0xffce('0x49')](_0x132356[_0xffce('0x30')]['fields']));_0x2b388b[_0xffce('0x35')]=_0x2b388b['attributes'][_0xffce('0x36')]?_0x2b388b[_0xffce('0x35')]:_0x22be56[_0xffce('0x34')];if(_0x132356[_0xffce('0x30')][_0xffce('0x43')]){_0x2b388b[_0xffce('0x44')]=[{'all':!![]}];}_0x2b388b=_[_0xffce('0x3f')]({},_0x2b388b,_0x132356[_0xffce('0x42')]);return db['Interval']['find'](_0x2b388b)[_0xffce('0x24')](handleEntityNotFound(_0x5d58f5,null))['then'](respondWithResult(_0x5d58f5,null))[_0xffce('0x4a')](handleError(_0x5d58f5,null));};exports[_0xffce('0x4b')]=function(_0x1bc478,_0x457948){return db[_0xffce('0x2c')][_0xffce('0x4b')](_0x1bc478[_0xffce('0x4c')],{})[_0xffce('0x24')](function(_0x12e3da){var _0x1b2db4=_0x1bc478[_0xffce('0x4d')]['get']({'plain':!![]});if(!_0x1b2db4)throw new Error(_0xffce('0x4e'));if(_0x1b2db4[_0xffce('0x4f')]==='user'){var _0x12aa81=_0x12e3da[_0xffce('0x25')]({'plain':!![]});var _0x32564a=_0xffce('0x50');return db[_0xffce('0x51')][_0xffce('0x52')]({'where':{'name':_0x32564a,'userProfileId':_0x1b2db4[_0xffce('0x53')]},'raw':!![]})[_0xffce('0x24')](function(_0x427694){if(_0x427694&&_0x427694[_0xffce('0x54')]===0x0){return db[_0xffce('0x26')]['create']({'name':_0x12aa81[_0xffce('0x29')],'resourceId':_0x12aa81['id'],'type':_0x427694['name'],'sectionId':_0x427694['id']},{})['then'](function(){return _0x12e3da;});}else{return _0x12e3da;}})[_0xffce('0x4a')](function(_0xeda8c1){logger[_0xffce('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xeda8c1);throw _0xeda8c1;});}return _0x12e3da;})[_0xffce('0x24')](respondWithResult(_0x457948,0xc9))['catch'](handleError(_0x457948,null));};exports[_0xffce('0x55')]=function(_0x5c4f37,_0x4912b3){if(_0x5c4f37[_0xffce('0x4c')]['id']){delete _0x5c4f37['body']['id'];}return db[_0xffce('0x2c')][_0xffce('0x52')]({'where':{'id':_0x5c4f37[_0xffce('0x48')]['id']}})[_0xffce('0x24')](handleEntityNotFound(_0x4912b3,null))[_0xffce('0x24')](saveUpdates(_0x5c4f37[_0xffce('0x4c')],null))[_0xffce('0x24')](respondWithResult(_0x4912b3,null))[_0xffce('0x4a')](handleError(_0x4912b3,null));};exports['destroy']=function(_0x12fcbf,_0x56ee60){return db[_0xffce('0x2c')][_0xffce('0x52')]({'where':{'id':_0x12fcbf[_0xffce('0x48')]['id']}})['then'](handleEntityNotFound(_0x56ee60,null))['then'](removeEntity(_0x56ee60,null))[_0xffce('0x4a')](handleError(_0x56ee60,null));};exports[_0xffce('0x56')]=function(_0x88f93f,_0x3eb96d,_0x4ca0b0){if(_0x88f93f[_0xffce('0x4c')]['id']){delete _0x88f93f[_0xffce('0x4c')]['id'];}return db[_0xffce('0x2c')][_0xffce('0x52')]({'where':{'id':_0x88f93f['params']['id']}})[_0xffce('0x24')](handleEntityNotFound(_0x3eb96d,null))['then'](function(_0x2ed1ca){if(_0x2ed1ca){_0x88f93f[_0xffce('0x4c')][_0xffce('0x57')]=_0x2ed1ca['id'];return db['Interval'][_0xffce('0x4b')](_0x88f93f[_0xffce('0x4c')]);}})[_0xffce('0x24')](respondWithResult(_0x3eb96d,null))[_0xffce('0x4a')](handleError(_0x3eb96d,null));};exports[_0xffce('0x58')]=function(_0x5b116d,_0x4dcc93,_0x173586){var _0x17d8ba={};var _0x59c4d9={};var _0x5af18e;var _0x2f28db;return db[_0xffce('0x2c')][_0xffce('0x59')]({'where':{'id':_0x5b116d[_0xffce('0x48')]['id']}})[_0xffce('0x24')](handleEntityNotFound(_0x4dcc93,null))['then'](function(_0x34fdef){if(_0x34fdef){_0x5af18e=_0x34fdef;_0x59c4d9[_0xffce('0x34')]=_['keys'](db[_0xffce('0x2c')][_0xffce('0x2d')]);_0x59c4d9[_0xffce('0x30')]=_[_0xffce('0x31')](_0x5b116d[_0xffce('0x30')]);_0x59c4d9[_0xffce('0x32')]=_[_0xffce('0x33')](_0x59c4d9[_0xffce('0x34')],_0x59c4d9[_0xffce('0x30')]);_0x17d8ba[_0xffce('0x35')]=_['intersection'](_0x59c4d9[_0xffce('0x34')],qs[_0xffce('0x49')](_0x5b116d[_0xffce('0x30')][_0xffce('0x49')]));_0x17d8ba[_0xffce('0x35')]=_0x17d8ba[_0xffce('0x35')][_0xffce('0x36')]?_0x17d8ba['attributes']:_0x59c4d9[_0xffce('0x34')];_0x17d8ba[_0xffce('0x3b')]=qs['sort'](_0x5b116d[_0xffce('0x30')]['sort']);_0x17d8ba['where']=qs[_0xffce('0x32')](_['pick'](_0x5b116d[_0xffce('0x30')],_0x59c4d9['filters']));if(_0x5b116d[_0xffce('0x30')]['filter']){_0x17d8ba[_0xffce('0x3e')]=_['merge'](_0x17d8ba['where'],{'$or':_[_0xffce('0x2b')](_0x17d8ba['attributes'],function(_0x5a144d){var _0x29ecc9={};_0x29ecc9[_0x5a144d]={'$like':'%'+_0x5b116d['query'][_0xffce('0x3d')]+'%'};return _0x29ecc9;})});}_0x17d8ba=_[_0xffce('0x3f')]({},_0x17d8ba,_0x5b116d[_0xffce('0x42')]);return _0x5af18e[_0xffce('0x58')](_0x17d8ba);}})[_0xffce('0x24')](function(_0x307737){if(_0x307737){_0x2f28db=_0x307737['length'];if(!_0x5b116d['query']['hasOwnProperty'](_0xffce('0x38'))){_0x17d8ba[_0xffce('0x39')]=qs[_0xffce('0x39')](_0x5b116d[_0xffce('0x30')]['limit']);_0x17d8ba[_0xffce('0x3a')]=qs[_0xffce('0x3a')](_0x5b116d[_0xffce('0x30')][_0xffce('0x3a')]);}return _0x5af18e['getIntervals'](_0x17d8ba);}})[_0xffce('0x24')](function(_0x5171cf){if(_0x5171cf){return _0x5171cf?{'count':_0x2f28db,'rows':_0x5171cf}:null;}})['then'](respondWithResult(_0x4dcc93,null))[_0xffce('0x4a')](handleError(_0x4dcc93,null));};exports[_0xffce('0x5a')]=function(_0x2c3563,_0x510a30,_0x4ed6f1){return db[_0xffce('0x2c')][_0xffce('0x59')]({'where':{'id':_0x2c3563['params']['id']}})[_0xffce('0x24')](handleEntityNotFound(_0x510a30,null))[_0xffce('0x24')](function(_0x45aa5a){if(_0x45aa5a){return db[_0xffce('0x5b')][_0xffce('0x5c')](function(_0x18ba70){return db[_0xffce('0x2c')][_0xffce('0x5d')]({'where':{'IntervalId':_0x2c3563[_0xffce('0x48')]['id']},'transaction':_0x18ba70})['then'](function(_0x3b37e2){var _0x17df7c=_[_0xffce('0x2b')](_0x2c3563['body'],function(_0x28dc85){delete _0x28dc85['id'];_0x28dc85[_0xffce('0x57')]=_0x2c3563[_0xffce('0x48')]['id'];return _0x28dc85;});return db[_0xffce('0x2c')][_0xffce('0x5e')](_0x17df7c,{'transaction':_0x18ba70});});})['then'](function(){return db[_0xffce('0x2c')]['findAll']({'where':{'IntervalId':_0x2c3563[_0xffce('0x48')]['id']}});});}})[_0xffce('0x24')](respondWithResult(_0x510a30,null))[_0xffce('0x4a')](handleError(_0x510a30,null));};
\ No newline at end of file
+var _0xa0b5=['Interval','rawAttributes','fieldName','type','key','keys','filters','intersection','model','query','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Intervals','UserProfileSection','catch','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','addInterval','IntervalId','findOne','getIntervals','nolimit','sequelize','transaction','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','squel','crypto','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','../../components/extensions/rewrite','sendStatus','status','end','offset','undefined','limit','json','apply','update','then','destroy','UserProfileResource','stack','name','send','index','map'];(function(_0x3ba566,_0x5e009d){var _0x480317=function(_0x2fc8de){while(--_0x2fc8de){_0x3ba566['push'](_0x3ba566['shift']());}};_0x480317(++_0x5e009d);}(_0xa0b5,0x183));var _0x5a0b=function(_0x5ed215,_0x3e16cc){_0x5ed215=_0x5ed215-0x0;var _0xecda20=_0xa0b5[_0x5ed215];return _0xecda20;};'use strict';var emlformat=require(_0x5a0b('0x0'));var rimraf=require(_0x5a0b('0x1'));var zipdir=require(_0x5a0b('0x2'));var jsonpatch=require(_0x5a0b('0x3'));var rp=require(_0x5a0b('0x4'));var moment=require(_0x5a0b('0x5'));var BPromise=require(_0x5a0b('0x6'));var Mustache=require(_0x5a0b('0x7'));var util=require('util');var path=require(_0x5a0b('0x8'));var sox=require('sox');var csv=require(_0x5a0b('0x9'));var ejs=require(_0x5a0b('0xa'));var fs=require('fs');var fs_extra=require(_0x5a0b('0xb'));var _=require('lodash');var squel=require(_0x5a0b('0xc'));var crypto=require(_0x5a0b('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x5a0b('0x9'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x5a0b('0xe'));var qs=require(_0x5a0b('0xf'));var as=require(_0x5a0b('0x10'));var hardwareService=require(_0x5a0b('0x11'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x5a0b('0x12'));var licenseUtil=require(_0x5a0b('0x13'));var db=require('../../mysqldb')['db'];var extensions=require(_0x5a0b('0x14'));function respondWithStatusCode(_0x586a10,_0x11aef2){_0x11aef2=_0x11aef2||0xcc;return function(_0x58b7c0){if(_0x58b7c0){return _0x586a10[_0x5a0b('0x15')](_0x11aef2);}return _0x586a10[_0x5a0b('0x16')](_0x11aef2)[_0x5a0b('0x17')]();};}function respondWithResult(_0x32d49b,_0x42cea3){_0x42cea3=_0x42cea3||0xc8;return function(_0x2c5194){if(_0x2c5194){return _0x32d49b['status'](_0x42cea3)['json'](_0x2c5194);}};}function respondWithFilteredResult(_0x4fa3c7,_0x501c18){return function(_0x295a72){if(_0x295a72){var _0x34d1cc=typeof _0x501c18[_0x5a0b('0x18')]===_0x5a0b('0x19')&&typeof _0x501c18[_0x5a0b('0x1a')]===_0x5a0b('0x19');var _0x1f551e=_0x295a72['count'];var _0xcdbbdd=_0x34d1cc?0x0:_0x501c18['offset'];var _0x397af0=_0x34d1cc?_0x295a72['count']:_0x501c18['offset']+_0x501c18[_0x5a0b('0x1a')];var _0x56196e;if(_0x397af0>=_0x1f551e){_0x397af0=_0x1f551e;_0x56196e=0xc8;}else{_0x56196e=0xce;}_0x4fa3c7[_0x5a0b('0x16')](_0x56196e);return _0x4fa3c7['set']('Content-Range',_0xcdbbdd+'-'+_0x397af0+'/'+_0x1f551e)[_0x5a0b('0x1b')](_0x295a72);}return null;};}function patchUpdates(_0x439114){return function(_0x5db9c0){try{jsonpatch[_0x5a0b('0x1c')](_0x5db9c0,_0x439114,!![]);}catch(_0x94c370){return BPromise['reject'](_0x94c370);}return _0x5db9c0['save']();};}function saveUpdates(_0x3ec5c2,_0xb4d3fc){return function(_0x522633){if(_0x522633){return _0x522633[_0x5a0b('0x1d')](_0x3ec5c2)[_0x5a0b('0x1e')](function(_0x59461b){return _0x59461b;});}return null;};}function removeEntity(_0x161ae1,_0x3cabff){return function(_0x24dff7){if(_0x24dff7){return _0x24dff7[_0x5a0b('0x1f')]()[_0x5a0b('0x1e')](function(){var _0x423fc7=_0x24dff7['get']({'plain':!![]});var _0x3668ac='Intervals';return db[_0x5a0b('0x20')][_0x5a0b('0x1f')]({'where':{'type':_0x3668ac,'resourceId':_0x423fc7['id']}})[_0x5a0b('0x1e')](function(){return _0x24dff7;});})['then'](function(){_0x161ae1[_0x5a0b('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x21da2d,_0x4bf205){return function(_0x409e81){if(!_0x409e81){_0x21da2d[_0x5a0b('0x15')](0x194);}return _0x409e81;};}function handleError(_0x494004,_0x554e6e){_0x554e6e=_0x554e6e||0x1f4;return function(_0x36620a){logger['error'](_0x36620a[_0x5a0b('0x21')]);if(_0x36620a[_0x5a0b('0x22')]){delete _0x36620a[_0x5a0b('0x22')];}_0x494004[_0x5a0b('0x16')](_0x554e6e)[_0x5a0b('0x23')](_0x36620a);};}exports[_0x5a0b('0x24')]=function(_0x38a4e9,_0xba65fa){var _0xc70f12={},_0x183bc9={},_0x4f6535={'count':0x0,'rows':[]};var _0x138100=_[_0x5a0b('0x25')](db[_0x5a0b('0x26')][_0x5a0b('0x27')],function(_0xc2babc){return{'name':_0xc2babc[_0x5a0b('0x28')],'type':_0xc2babc[_0x5a0b('0x29')][_0x5a0b('0x2a')]};});_0x183bc9['model']=_['map'](_0x138100,'name');_0x183bc9['query']=_[_0x5a0b('0x2b')](_0x38a4e9['query']);_0x183bc9[_0x5a0b('0x2c')]=_[_0x5a0b('0x2d')](_0x183bc9[_0x5a0b('0x2e')],_0x183bc9[_0x5a0b('0x2f')]);_0xc70f12[_0x5a0b('0x30')]=_[_0x5a0b('0x2d')](_0x183bc9[_0x5a0b('0x2e')],qs[_0x5a0b('0x31')](_0x38a4e9[_0x5a0b('0x2f')][_0x5a0b('0x31')]));_0xc70f12[_0x5a0b('0x30')]=_0xc70f12[_0x5a0b('0x30')][_0x5a0b('0x32')]?_0xc70f12[_0x5a0b('0x30')]:_0x183bc9[_0x5a0b('0x2e')];if(!_0x38a4e9[_0x5a0b('0x2f')][_0x5a0b('0x33')]('nolimit')){_0xc70f12[_0x5a0b('0x1a')]=qs['limit'](_0x38a4e9[_0x5a0b('0x2f')][_0x5a0b('0x1a')]);_0xc70f12[_0x5a0b('0x18')]=qs[_0x5a0b('0x18')](_0x38a4e9['query']['offset']);}_0xc70f12[_0x5a0b('0x34')]=qs[_0x5a0b('0x35')](_0x38a4e9[_0x5a0b('0x2f')]['sort']);_0xc70f12[_0x5a0b('0x36')]=qs['filters'](_[_0x5a0b('0x37')](_0x38a4e9[_0x5a0b('0x2f')],_0x183bc9['filters']),_0x138100);if(_0x38a4e9[_0x5a0b('0x2f')][_0x5a0b('0x38')]){_0xc70f12['where']=_[_0x5a0b('0x39')](_0xc70f12[_0x5a0b('0x36')],{'$or':_[_0x5a0b('0x25')](_0x138100,function(_0x21bfac){if(_0x21bfac[_0x5a0b('0x29')]!==_0x5a0b('0x3a')){var _0x387038={};_0x387038[_0x21bfac['name']]={'$like':'%'+_0x38a4e9['query'][_0x5a0b('0x38')]+'%'};return _0x387038;}})});}_0xc70f12=_[_0x5a0b('0x39')]({},_0xc70f12,_0x38a4e9[_0x5a0b('0x3b')]);var _0x31cbbd={'where':_0xc70f12[_0x5a0b('0x36')]};return db[_0x5a0b('0x26')]['count'](_0x31cbbd)[_0x5a0b('0x1e')](function(_0x430f4c){_0x4f6535['count']=_0x430f4c;if(_0x38a4e9['query'][_0x5a0b('0x3c')]){_0xc70f12[_0x5a0b('0x3d')]=[{'all':!![]}];}return db[_0x5a0b('0x26')][_0x5a0b('0x3e')](_0xc70f12);})[_0x5a0b('0x1e')](function(_0x1755f0){_0x4f6535[_0x5a0b('0x3f')]=_0x1755f0;return _0x4f6535;})[_0x5a0b('0x1e')](respondWithFilteredResult(_0xba65fa,_0xc70f12))['catch'](handleError(_0xba65fa,null));};exports[_0x5a0b('0x40')]=function(_0x41e414,_0x1dfc4e){var _0x34ec24={'raw':!![],'where':{'id':_0x41e414[_0x5a0b('0x41')]['id']}},_0x21422c={};_0x21422c[_0x5a0b('0x2e')]=_[_0x5a0b('0x2b')](db['Interval']['rawAttributes']);_0x21422c[_0x5a0b('0x2f')]=_[_0x5a0b('0x2b')](_0x41e414['query']);_0x21422c['filters']=_[_0x5a0b('0x2d')](_0x21422c[_0x5a0b('0x2e')],_0x21422c[_0x5a0b('0x2f')]);_0x34ec24['attributes']=_[_0x5a0b('0x2d')](_0x21422c[_0x5a0b('0x2e')],qs[_0x5a0b('0x31')](_0x41e414[_0x5a0b('0x2f')][_0x5a0b('0x31')]));_0x34ec24[_0x5a0b('0x30')]=_0x34ec24[_0x5a0b('0x30')]['length']?_0x34ec24[_0x5a0b('0x30')]:_0x21422c[_0x5a0b('0x2e')];if(_0x41e414['query']['includeAll']){_0x34ec24[_0x5a0b('0x3d')]=[{'all':!![]}];}_0x34ec24=_[_0x5a0b('0x39')]({},_0x34ec24,_0x41e414[_0x5a0b('0x3b')]);return db[_0x5a0b('0x26')]['find'](_0x34ec24)[_0x5a0b('0x1e')](handleEntityNotFound(_0x1dfc4e,null))[_0x5a0b('0x1e')](respondWithResult(_0x1dfc4e,null))['catch'](handleError(_0x1dfc4e,null));};exports['create']=function(_0x160956,_0x15a096){return db['Interval'][_0x5a0b('0x42')](_0x160956[_0x5a0b('0x43')],{})[_0x5a0b('0x1e')](function(_0x1908f0){var _0x3d7312=_0x160956[_0x5a0b('0x44')][_0x5a0b('0x45')]({'plain':!![]});if(!_0x3d7312)throw new Error(_0x5a0b('0x46'));if(_0x3d7312[_0x5a0b('0x47')]==='user'){var _0xc29da2=_0x1908f0[_0x5a0b('0x45')]({'plain':!![]});var _0x9a53a6=_0x5a0b('0x48');return db[_0x5a0b('0x49')]['find']({'where':{'name':_0x9a53a6,'userProfileId':_0x3d7312['userProfileId']},'raw':!![]})[_0x5a0b('0x1e')](function(_0x31cc4f){if(_0x31cc4f&&_0x31cc4f['autoAssociation']===0x0){return db[_0x5a0b('0x20')][_0x5a0b('0x42')]({'name':_0xc29da2[_0x5a0b('0x22')],'resourceId':_0xc29da2['id'],'type':_0x31cc4f['name'],'sectionId':_0x31cc4f['id']},{})[_0x5a0b('0x1e')](function(){return _0x1908f0;});}else{return _0x1908f0;}})[_0x5a0b('0x4a')](function(_0x1757a0){logger[_0x5a0b('0x4b')](_0x5a0b('0x4c'),_0x1757a0);throw _0x1757a0;});}return _0x1908f0;})[_0x5a0b('0x1e')](respondWithResult(_0x15a096,0xc9))[_0x5a0b('0x4a')](handleError(_0x15a096,null));};exports[_0x5a0b('0x1d')]=function(_0x3dde98,_0x48fe15){if(_0x3dde98['body']['id']){delete _0x3dde98[_0x5a0b('0x43')]['id'];}return db[_0x5a0b('0x26')][_0x5a0b('0x4d')]({'where':{'id':_0x3dde98['params']['id']}})[_0x5a0b('0x1e')](handleEntityNotFound(_0x48fe15,null))[_0x5a0b('0x1e')](saveUpdates(_0x3dde98[_0x5a0b('0x43')],null))[_0x5a0b('0x1e')](respondWithResult(_0x48fe15,null))[_0x5a0b('0x4a')](handleError(_0x48fe15,null));};exports[_0x5a0b('0x1f')]=function(_0x1b23e7,_0x44b071){return db['Interval'][_0x5a0b('0x4d')]({'where':{'id':_0x1b23e7[_0x5a0b('0x41')]['id']}})[_0x5a0b('0x1e')](handleEntityNotFound(_0x44b071,null))[_0x5a0b('0x1e')](removeEntity(_0x44b071,null))[_0x5a0b('0x4a')](handleError(_0x44b071,null));};exports[_0x5a0b('0x4e')]=function(_0x3a758d,_0x419b59,_0x2bb111){if(_0x3a758d[_0x5a0b('0x43')]['id']){delete _0x3a758d['body']['id'];}return db[_0x5a0b('0x26')]['find']({'where':{'id':_0x3a758d['params']['id']}})['then'](handleEntityNotFound(_0x419b59,null))[_0x5a0b('0x1e')](function(_0x4ba45b){if(_0x4ba45b){_0x3a758d[_0x5a0b('0x43')][_0x5a0b('0x4f')]=_0x4ba45b['id'];return db[_0x5a0b('0x26')][_0x5a0b('0x42')](_0x3a758d[_0x5a0b('0x43')]);}})['then'](respondWithResult(_0x419b59,null))[_0x5a0b('0x4a')](handleError(_0x419b59,null));};exports['getIntervals']=function(_0x1b5e34,_0x2c7e30,_0x4bf8e1){var _0x12887d={};var _0x55042e={};var _0x1a273f;var _0x357acc;return db[_0x5a0b('0x26')][_0x5a0b('0x50')]({'where':{'id':_0x1b5e34[_0x5a0b('0x41')]['id']}})['then'](handleEntityNotFound(_0x2c7e30,null))[_0x5a0b('0x1e')](function(_0x31344b){if(_0x31344b){_0x1a273f=_0x31344b;_0x55042e[_0x5a0b('0x2e')]=_['keys'](db[_0x5a0b('0x26')][_0x5a0b('0x27')]);_0x55042e[_0x5a0b('0x2f')]=_[_0x5a0b('0x2b')](_0x1b5e34[_0x5a0b('0x2f')]);_0x55042e['filters']=_[_0x5a0b('0x2d')](_0x55042e[_0x5a0b('0x2e')],_0x55042e[_0x5a0b('0x2f')]);_0x12887d['attributes']=_[_0x5a0b('0x2d')](_0x55042e[_0x5a0b('0x2e')],qs[_0x5a0b('0x31')](_0x1b5e34[_0x5a0b('0x2f')][_0x5a0b('0x31')]));_0x12887d[_0x5a0b('0x30')]=_0x12887d['attributes'][_0x5a0b('0x32')]?_0x12887d['attributes']:_0x55042e['model'];_0x12887d[_0x5a0b('0x34')]=qs['sort'](_0x1b5e34[_0x5a0b('0x2f')][_0x5a0b('0x35')]);_0x12887d[_0x5a0b('0x36')]=qs['filters'](_[_0x5a0b('0x37')](_0x1b5e34[_0x5a0b('0x2f')],_0x55042e[_0x5a0b('0x2c')]));if(_0x1b5e34['query'][_0x5a0b('0x38')]){_0x12887d[_0x5a0b('0x36')]=_['merge'](_0x12887d[_0x5a0b('0x36')],{'$or':_['map'](_0x12887d['attributes'],function(_0x5ab7fa){var _0x11780d={};_0x11780d[_0x5ab7fa]={'$like':'%'+_0x1b5e34[_0x5a0b('0x2f')][_0x5a0b('0x38')]+'%'};return _0x11780d;})});}_0x12887d=_['merge']({},_0x12887d,_0x1b5e34['options']);return _0x1a273f[_0x5a0b('0x51')](_0x12887d);}})['then'](function(_0x117788){if(_0x117788){_0x357acc=_0x117788[_0x5a0b('0x32')];if(!_0x1b5e34['query']['hasOwnProperty'](_0x5a0b('0x52'))){_0x12887d[_0x5a0b('0x1a')]=qs[_0x5a0b('0x1a')](_0x1b5e34[_0x5a0b('0x2f')]['limit']);_0x12887d[_0x5a0b('0x18')]=qs[_0x5a0b('0x18')](_0x1b5e34[_0x5a0b('0x2f')][_0x5a0b('0x18')]);}return _0x1a273f['getIntervals'](_0x12887d);}})[_0x5a0b('0x1e')](function(_0x5e6905){if(_0x5e6905){return _0x5e6905?{'count':_0x357acc,'rows':_0x5e6905}:null;}})[_0x5a0b('0x1e')](respondWithResult(_0x2c7e30,null))[_0x5a0b('0x4a')](handleError(_0x2c7e30,null));};exports['addIntervals']=function(_0x1743f2,_0x564ce5,_0x2fe0c9){return db[_0x5a0b('0x26')]['findOne']({'where':{'id':_0x1743f2[_0x5a0b('0x41')]['id']}})[_0x5a0b('0x1e')](handleEntityNotFound(_0x564ce5,null))[_0x5a0b('0x1e')](function(_0x35dcd2){if(_0x35dcd2){return db[_0x5a0b('0x53')][_0x5a0b('0x54')](function(_0x2c0fc5){return db[_0x5a0b('0x26')][_0x5a0b('0x1f')]({'where':{'IntervalId':_0x1743f2[_0x5a0b('0x41')]['id']},'transaction':_0x2c0fc5})[_0x5a0b('0x1e')](function(_0x4a402f){var _0x378e5e=_[_0x5a0b('0x25')](_0x1743f2[_0x5a0b('0x43')],function(_0x12931f){delete _0x12931f['id'];_0x12931f[_0x5a0b('0x4f')]=_0x1743f2[_0x5a0b('0x41')]['id'];return _0x12931f;});return db[_0x5a0b('0x26')]['bulkCreate'](_0x378e5e,{'transaction':_0x2c0fc5});});})[_0x5a0b('0x1e')](function(){return db[_0x5a0b('0x26')][_0x5a0b('0x3e')]({'where':{'IntervalId':_0x1743f2['params']['id']}});});}})[_0x5a0b('0x1e')](respondWithResult(_0x564ce5,null))[_0x5a0b('0x4a')](handleError(_0x564ce5,null));};
\ No newline at end of file