Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / interval / interval.controller.js
index 5f6c5fe..8c2744c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7773=['api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','get','UserProfileResource','name','send','index','map','Interval','rawAttributes','fieldName','key','query','keys','intersection','attributes','model','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','includeAll','then','show','params','include','find','catch','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','Intervals','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','IntervalId','create','getIntervals','findOne','addIntervals','sequelize','transaction','bulkCreate','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger'];(function(_0x462da0,_0x56fcbf){var _0xccb0a3=function(_0x10032c){while(--_0x10032c){_0x462da0['push'](_0x462da0['shift']());}};_0xccb0a3(++_0x56fcbf);}(_0x7773,0x155));var _0x3777=function(_0x46698a,_0x8de1e4){_0x46698a=_0x46698a-0x0;var _0x356db0=_0x7773[_0x46698a];return _0x356db0;};'use strict';var emlformat=require(_0x3777('0x0'));var rimraf=require(_0x3777('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3777('0x2'));var rp=require(_0x3777('0x3'));var moment=require(_0x3777('0x4'));var BPromise=require(_0x3777('0x5'));var Mustache=require(_0x3777('0x6'));var util=require(_0x3777('0x7'));var path=require(_0x3777('0x8'));var sox=require(_0x3777('0x9'));var csv=require(_0x3777('0xa'));var ejs=require(_0x3777('0xb'));var fs=require('fs');var fs_extra=require(_0x3777('0xc'));var _=require(_0x3777('0xd'));var squel=require(_0x3777('0xe'));var crypto=require(_0x3777('0xf'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x3777('0xa'));var querystring=require(_0x3777('0x10'));var Papa=require(_0x3777('0x11'));var Redis=require(_0x3777('0x12'));var authService=require(_0x3777('0x13'));var qs=require(_0x3777('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3777('0x15'));var logger=require(_0x3777('0x16'))(_0x3777('0x17'));var utils=require(_0x3777('0x18'));var config=require(_0x3777('0x19'));var licenseUtil=require(_0x3777('0x1a'));var db=require('../../mysqldb')['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x59bdd2,_0x5abd94){_0x5abd94=_0x5abd94||0xcc;return function(_0x24c2f6){if(_0x24c2f6){return _0x59bdd2[_0x3777('0x1b')](_0x5abd94);}return _0x59bdd2[_0x3777('0x1c')](_0x5abd94)[_0x3777('0x1d')]();};}function respondWithResult(_0x551133,_0x194dea){_0x194dea=_0x194dea||0xc8;return function(_0x2aff32){if(_0x2aff32){return _0x551133[_0x3777('0x1c')](_0x194dea)[_0x3777('0x1e')](_0x2aff32);}};}function respondWithFilteredResult(_0x5c42d7,_0x3a7e2e){return function(_0x268484){if(_0x268484){var _0x4fc403=typeof _0x3a7e2e[_0x3777('0x1f')]===_0x3777('0x20')&&typeof _0x3a7e2e[_0x3777('0x21')]===_0x3777('0x20');var _0x57afc4=_0x268484[_0x3777('0x22')];var _0x23bae3=_0x4fc403?0x0:_0x3a7e2e[_0x3777('0x1f')];var _0x26dfc8=_0x4fc403?_0x268484[_0x3777('0x22')]:_0x3a7e2e[_0x3777('0x1f')]+_0x3a7e2e[_0x3777('0x21')];var _0x11e519;if(_0x26dfc8>=_0x57afc4){_0x26dfc8=_0x57afc4;_0x11e519=0xc8;}else{_0x11e519=0xce;}_0x5c42d7[_0x3777('0x1c')](_0x11e519);return _0x5c42d7[_0x3777('0x23')](_0x3777('0x24'),_0x23bae3+'-'+_0x26dfc8+'/'+_0x57afc4)['json'](_0x268484);}return null;};}function patchUpdates(_0x17ba12){return function(_0x412f6c){try{jsonpatch[_0x3777('0x25')](_0x412f6c,_0x17ba12,!![]);}catch(_0x5e354d){return BPromise[_0x3777('0x26')](_0x5e354d);}return _0x412f6c['save']();};}function saveUpdates(_0x1197b2,_0x2345be){return function(_0x2046bf){if(_0x2046bf){return _0x2046bf[_0x3777('0x27')](_0x1197b2)['then'](function(_0x324360){return _0x324360;});}return null;};}function removeEntity(_0x3444a4,_0x42cc4f){return function(_0x42d08d){if(_0x42d08d){return _0x42d08d[_0x3777('0x28')]()['then'](function(){var _0x34ad30=_0x42d08d[_0x3777('0x29')]({'plain':!![]});var _0x1b4c9e='Intervals';return db[_0x3777('0x2a')]['destroy']({'where':{'type':_0x1b4c9e,'resourceId':_0x34ad30['id']}})['then'](function(){return _0x42d08d;});})['then'](function(){_0x3444a4[_0x3777('0x1c')](0xcc)[_0x3777('0x1d')]();});}};}function handleEntityNotFound(_0x36063c,_0x4d189f){return function(_0x1e8409){if(!_0x1e8409){_0x36063c[_0x3777('0x1b')](0x194);}return _0x1e8409;};}function handleError(_0x125391,_0x7d9d98){_0x7d9d98=_0x7d9d98||0x1f4;return function(_0x526a49){logger['error'](_0x526a49['stack']);if(_0x526a49['name']){delete _0x526a49[_0x3777('0x2b')];}_0x125391[_0x3777('0x1c')](_0x7d9d98)[_0x3777('0x2c')](_0x526a49);};}exports[_0x3777('0x2d')]=function(_0x29ec22,_0x31e991){var _0x5aa5bc={},_0x5a7e4b={},_0x5188b1={'count':0x0,'rows':[]};var _0x1b2352=_[_0x3777('0x2e')](db[_0x3777('0x2f')][_0x3777('0x30')],function(_0x540377){return{'name':_0x540377[_0x3777('0x31')],'type':_0x540377['type'][_0x3777('0x32')]};});_0x5a7e4b['model']=_['map'](_0x1b2352,_0x3777('0x2b'));_0x5a7e4b[_0x3777('0x33')]=_[_0x3777('0x34')](_0x29ec22[_0x3777('0x33')]);_0x5a7e4b['filters']=_[_0x3777('0x35')](_0x5a7e4b['model'],_0x5a7e4b[_0x3777('0x33')]);_0x5aa5bc[_0x3777('0x36')]=_[_0x3777('0x35')](_0x5a7e4b[_0x3777('0x37')],qs['fields'](_0x29ec22[_0x3777('0x33')][_0x3777('0x38')]));_0x5aa5bc[_0x3777('0x36')]=_0x5aa5bc['attributes'][_0x3777('0x39')]?_0x5aa5bc[_0x3777('0x36')]:_0x5a7e4b[_0x3777('0x37')];if(!_0x29ec22[_0x3777('0x33')][_0x3777('0x3a')]('nolimit')){_0x5aa5bc[_0x3777('0x21')]=qs['limit'](_0x29ec22[_0x3777('0x33')]['limit']);_0x5aa5bc[_0x3777('0x1f')]=qs[_0x3777('0x1f')](_0x29ec22[_0x3777('0x33')][_0x3777('0x1f')]);}_0x5aa5bc[_0x3777('0x3b')]=qs[_0x3777('0x3c')](_0x29ec22[_0x3777('0x33')][_0x3777('0x3c')]);_0x5aa5bc[_0x3777('0x3d')]=qs[_0x3777('0x3e')](_[_0x3777('0x3f')](_0x29ec22['query'],_0x5a7e4b['filters']),_0x1b2352);if(_0x29ec22[_0x3777('0x33')][_0x3777('0x40')]){_0x5aa5bc[_0x3777('0x3d')]=_['merge'](_0x5aa5bc[_0x3777('0x3d')],{'$or':_['map'](_0x1b2352,function(_0x18e835){if(_0x18e835['type']!==_0x3777('0x41')){var _0x131e0a={};_0x131e0a[_0x18e835[_0x3777('0x2b')]]={'$like':'%'+_0x29ec22[_0x3777('0x33')][_0x3777('0x40')]+'%'};return _0x131e0a;}})});}_0x5aa5bc=_[_0x3777('0x42')]({},_0x5aa5bc,_0x29ec22[_0x3777('0x43')]);var _0x4c843f={'where':_0x5aa5bc[_0x3777('0x3d')]};return db['Interval'][_0x3777('0x22')](_0x4c843f)['then'](function(_0x47ac71){_0x5188b1[_0x3777('0x22')]=_0x47ac71;if(_0x29ec22['query'][_0x3777('0x44')]){_0x5aa5bc['include']=[{'all':!![]}];}return db['Interval']['findAll'](_0x5aa5bc);})['then'](function(_0x19e7c4){_0x5188b1['rows']=_0x19e7c4;return _0x5188b1;})[_0x3777('0x45')](respondWithFilteredResult(_0x31e991,_0x5aa5bc))['catch'](handleError(_0x31e991,null));};exports[_0x3777('0x46')]=function(_0x1975a5,_0x2e6d61){var _0x2a3e1f={'raw':!![],'where':{'id':_0x1975a5[_0x3777('0x47')]['id']}},_0x403f86={};_0x403f86[_0x3777('0x37')]=_[_0x3777('0x34')](db[_0x3777('0x2f')][_0x3777('0x30')]);_0x403f86[_0x3777('0x33')]=_['keys'](_0x1975a5['query']);_0x403f86[_0x3777('0x3e')]=_[_0x3777('0x35')](_0x403f86[_0x3777('0x37')],_0x403f86['query']);_0x2a3e1f[_0x3777('0x36')]=_['intersection'](_0x403f86[_0x3777('0x37')],qs[_0x3777('0x38')](_0x1975a5[_0x3777('0x33')][_0x3777('0x38')]));_0x2a3e1f[_0x3777('0x36')]=_0x2a3e1f[_0x3777('0x36')][_0x3777('0x39')]?_0x2a3e1f[_0x3777('0x36')]:_0x403f86[_0x3777('0x37')];if(_0x1975a5[_0x3777('0x33')][_0x3777('0x44')]){_0x2a3e1f[_0x3777('0x48')]=[{'all':!![]}];}_0x2a3e1f=_['merge']({},_0x2a3e1f,_0x1975a5[_0x3777('0x43')]);return db['Interval'][_0x3777('0x49')](_0x2a3e1f)['then'](handleEntityNotFound(_0x2e6d61,null))[_0x3777('0x45')](respondWithResult(_0x2e6d61,null))[_0x3777('0x4a')](handleError(_0x2e6d61,null));};exports['create']=function(_0x64174f,_0x5c88b9){return db[_0x3777('0x2f')]['create'](_0x64174f[_0x3777('0x4b')],{})[_0x3777('0x45')](function(_0x235bb1){var _0x4ab955=_0x64174f[_0x3777('0x4c')][_0x3777('0x29')]({'plain':!![]});if(!_0x4ab955)throw new Error(_0x3777('0x4d'));if(_0x4ab955['role']===_0x3777('0x4c')){var _0x2de815=_0x235bb1[_0x3777('0x29')]({'plain':!![]});var _0x21bcd4=_0x3777('0x4e');return db[_0x3777('0x4f')][_0x3777('0x49')]({'where':{'name':_0x21bcd4,'userProfileId':_0x4ab955[_0x3777('0x50')]},'raw':!![]})[_0x3777('0x45')](function(_0x1bbfae){if(_0x1bbfae&&_0x1bbfae[_0x3777('0x51')]===0x0){return db[_0x3777('0x2a')]['create']({'name':_0x2de815[_0x3777('0x2b')],'resourceId':_0x2de815['id'],'type':_0x1bbfae['name'],'sectionId':_0x1bbfae['id']},{})[_0x3777('0x45')](function(){return _0x235bb1;});}else{return _0x235bb1;}})[_0x3777('0x4a')](function(_0x57e774){logger['error'](_0x3777('0x52'),_0x57e774);throw _0x57e774;});}return _0x235bb1;})[_0x3777('0x45')](respondWithResult(_0x5c88b9,0xc9))[_0x3777('0x4a')](handleError(_0x5c88b9,null));};exports[_0x3777('0x27')]=function(_0x5da048,_0x2e54a6){if(_0x5da048[_0x3777('0x4b')]['id']){delete _0x5da048[_0x3777('0x4b')]['id'];}return db[_0x3777('0x2f')][_0x3777('0x49')]({'where':{'id':_0x5da048[_0x3777('0x47')]['id']}})['then'](handleEntityNotFound(_0x2e54a6,null))[_0x3777('0x45')](saveUpdates(_0x5da048[_0x3777('0x4b')],null))['then'](respondWithResult(_0x2e54a6,null))[_0x3777('0x4a')](handleError(_0x2e54a6,null));};exports[_0x3777('0x28')]=function(_0x5b77a7,_0x19ba23){return db['Interval']['find']({'where':{'id':_0x5b77a7[_0x3777('0x47')]['id']}})['then'](handleEntityNotFound(_0x19ba23,null))[_0x3777('0x45')](removeEntity(_0x19ba23,null))['catch'](handleError(_0x19ba23,null));};exports['addInterval']=function(_0x2f8a9b,_0x5e2ea2,_0x33e8a2){if(_0x2f8a9b['body']['id']){delete _0x2f8a9b[_0x3777('0x4b')]['id'];}return db[_0x3777('0x2f')][_0x3777('0x49')]({'where':{'id':_0x2f8a9b[_0x3777('0x47')]['id']}})[_0x3777('0x45')](handleEntityNotFound(_0x5e2ea2,null))[_0x3777('0x45')](function(_0x5e0996){if(_0x5e0996){_0x2f8a9b[_0x3777('0x4b')][_0x3777('0x53')]=_0x5e0996['id'];return db['Interval'][_0x3777('0x54')](_0x2f8a9b['body']);}})[_0x3777('0x45')](respondWithResult(_0x5e2ea2,null))[_0x3777('0x4a')](handleError(_0x5e2ea2,null));};exports[_0x3777('0x55')]=function(_0x2c9edc,_0x5351a2,_0x582cdb){var _0xae74a5={};var _0x5455b0={};var _0x3fa648;var _0x2d5852;return db[_0x3777('0x2f')][_0x3777('0x56')]({'where':{'id':_0x2c9edc[_0x3777('0x47')]['id']}})[_0x3777('0x45')](handleEntityNotFound(_0x5351a2,null))[_0x3777('0x45')](function(_0x6cbd50){if(_0x6cbd50){_0x3fa648=_0x6cbd50;_0x5455b0['model']=_[_0x3777('0x34')](db[_0x3777('0x2f')][_0x3777('0x30')]);_0x5455b0['query']=_[_0x3777('0x34')](_0x2c9edc['query']);_0x5455b0[_0x3777('0x3e')]=_[_0x3777('0x35')](_0x5455b0[_0x3777('0x37')],_0x5455b0[_0x3777('0x33')]);_0xae74a5[_0x3777('0x36')]=_['intersection'](_0x5455b0[_0x3777('0x37')],qs[_0x3777('0x38')](_0x2c9edc[_0x3777('0x33')]['fields']));_0xae74a5['attributes']=_0xae74a5['attributes'][_0x3777('0x39')]?_0xae74a5[_0x3777('0x36')]:_0x5455b0[_0x3777('0x37')];_0xae74a5[_0x3777('0x3b')]=qs[_0x3777('0x3c')](_0x2c9edc[_0x3777('0x33')][_0x3777('0x3c')]);_0xae74a5[_0x3777('0x3d')]=qs[_0x3777('0x3e')](_[_0x3777('0x3f')](_0x2c9edc[_0x3777('0x33')],_0x5455b0['filters']));if(_0x2c9edc[_0x3777('0x33')]['filter']){_0xae74a5[_0x3777('0x3d')]=_[_0x3777('0x42')](_0xae74a5['where'],{'$or':_[_0x3777('0x2e')](_0xae74a5['attributes'],function(_0x356e8a){var _0x58ed3a={};_0x58ed3a[_0x356e8a]={'$like':'%'+_0x2c9edc['query'][_0x3777('0x40')]+'%'};return _0x58ed3a;})});}_0xae74a5=_[_0x3777('0x42')]({},_0xae74a5,_0x2c9edc[_0x3777('0x43')]);return _0x3fa648[_0x3777('0x55')](_0xae74a5);}})[_0x3777('0x45')](function(_0x63a4cf){if(_0x63a4cf){_0x2d5852=_0x63a4cf[_0x3777('0x39')];if(!_0x2c9edc[_0x3777('0x33')]['hasOwnProperty']('nolimit')){_0xae74a5['limit']=qs['limit'](_0x2c9edc['query']['limit']);_0xae74a5[_0x3777('0x1f')]=qs[_0x3777('0x1f')](_0x2c9edc[_0x3777('0x33')]['offset']);}return _0x3fa648[_0x3777('0x55')](_0xae74a5);}})[_0x3777('0x45')](function(_0x465ba7){if(_0x465ba7){return _0x465ba7?{'count':_0x2d5852,'rows':_0x465ba7}:null;}})['then'](respondWithResult(_0x5351a2,null))[_0x3777('0x4a')](handleError(_0x5351a2,null));};exports[_0x3777('0x57')]=function(_0x20d1d5,_0x3429fc,_0x8f5ada){return db[_0x3777('0x2f')]['findOne']({'where':{'id':_0x20d1d5[_0x3777('0x47')]['id']}})['then'](handleEntityNotFound(_0x3429fc,null))[_0x3777('0x45')](function(_0x2dca7e){if(_0x2dca7e){return db[_0x3777('0x58')][_0x3777('0x59')](function(_0x211c92){return db[_0x3777('0x2f')][_0x3777('0x28')]({'where':{'IntervalId':_0x20d1d5[_0x3777('0x47')]['id']},'transaction':_0x211c92})[_0x3777('0x45')](function(_0x3bc051){var _0x58601e=_[_0x3777('0x2e')](_0x20d1d5['body'],function(_0x2921ef){delete _0x2921ef['id'];_0x2921ef[_0x3777('0x53')]=_0x20d1d5[_0x3777('0x47')]['id'];return _0x2921ef;});return db['Interval'][_0x3777('0x5a')](_0x58601e,{'transaction':_0x211c92});});})['then'](function(){return db[_0x3777('0x2f')]['findAll']({'where':{'IntervalId':_0x20d1d5[_0x3777('0x47')]['id']}});});}})[_0x3777('0x45')](respondWithResult(_0x3429fc,null))[_0x3777('0x4a')](handleError(_0x3429fc,null));};
\ No newline at end of file
+var _0x8f22=['nolimit','order','sort','filter','where','merge','VIRTUAL','options','include','rows','catch','show','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addInterval','IntervalId','getIntervals','length','addIntervals','findOne','sequelize','transaction','findAll','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','json','undefined','count','offset','limit','set','Content-Range','update','then','destroy','get','Intervals','UserProfileResource','stack','name','send','map','Interval','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty'];(function(_0x47cf83,_0x1a543a){var _0xa72a8d=function(_0x2d67de){while(--_0x2d67de){_0x47cf83['push'](_0x47cf83['shift']());}};_0xa72a8d(++_0x1a543a);}(_0x8f22,0x7f));var _0x28f2=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0x8f22[_0x42cae2];return _0x5f256f;};'use strict';var emlformat=require(_0x28f2('0x0'));var rimraf=require(_0x28f2('0x1'));var zipdir=require(_0x28f2('0x2'));var jsonpatch=require(_0x28f2('0x3'));var rp=require(_0x28f2('0x4'));var moment=require(_0x28f2('0x5'));var BPromise=require(_0x28f2('0x6'));var Mustache=require(_0x28f2('0x7'));var util=require(_0x28f2('0x8'));var path=require(_0x28f2('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x28f2('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x28f2('0xb'));var squel=require(_0x28f2('0xc'));var crypto=require(_0x28f2('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x28f2('0xe'));var toCsv=require(_0x28f2('0xf'));var querystring=require(_0x28f2('0x10'));var Papa=require(_0x28f2('0x11'));var Redis=require(_0x28f2('0x12'));var authService=require(_0x28f2('0x13'));var qs=require(_0x28f2('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x28f2('0x15'));var logger=require(_0x28f2('0x16'))('api');var utils=require(_0x28f2('0x17'));var config=require(_0x28f2('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x28f2('0x19'))['db'];var extensions=require(_0x28f2('0x1a'));function respondWithStatusCode(_0x2a4d14,_0x268740){_0x268740=_0x268740||0xcc;return function(_0x2e4c08){if(_0x2e4c08){return _0x2a4d14[_0x28f2('0x1b')](_0x268740);}return _0x2a4d14[_0x28f2('0x1c')](_0x268740)[_0x28f2('0x1d')]();};}function respondWithResult(_0x4c6f1f,_0xc6565f){_0xc6565f=_0xc6565f||0xc8;return function(_0x42aea7){if(_0x42aea7){return _0x4c6f1f[_0x28f2('0x1c')](_0xc6565f)[_0x28f2('0x1e')](_0x42aea7);}};}function respondWithFilteredResult(_0x5e4f05,_0x594fba){return function(_0x3ddc8c){if(_0x3ddc8c){var _0x85d59d=typeof _0x594fba['offset']===_0x28f2('0x1f')&&typeof _0x594fba['limit']===_0x28f2('0x1f');var _0x4dc07f=_0x3ddc8c[_0x28f2('0x20')];var _0x4c080e=_0x85d59d?0x0:_0x594fba[_0x28f2('0x21')];var _0x64fbb6=_0x85d59d?_0x3ddc8c[_0x28f2('0x20')]:_0x594fba[_0x28f2('0x21')]+_0x594fba[_0x28f2('0x22')];var _0x160a68;if(_0x64fbb6>=_0x4dc07f){_0x64fbb6=_0x4dc07f;_0x160a68=0xc8;}else{_0x160a68=0xce;}_0x5e4f05[_0x28f2('0x1c')](_0x160a68);return _0x5e4f05[_0x28f2('0x23')](_0x28f2('0x24'),_0x4c080e+'-'+_0x64fbb6+'/'+_0x4dc07f)['json'](_0x3ddc8c);}return null;};}function patchUpdates(_0x47846e){return function(_0x4e1d7e){try{jsonpatch['apply'](_0x4e1d7e,_0x47846e,!![]);}catch(_0x27dd54){return BPromise['reject'](_0x27dd54);}return _0x4e1d7e['save']();};}function saveUpdates(_0x5989ad,_0x929569){return function(_0x1242c9){if(_0x1242c9){return _0x1242c9[_0x28f2('0x25')](_0x5989ad)[_0x28f2('0x26')](function(_0xe5a5dd){return _0xe5a5dd;});}return null;};}function removeEntity(_0x2405aa,_0x431875){return function(_0x4a6f71){if(_0x4a6f71){return _0x4a6f71[_0x28f2('0x27')]()['then'](function(){var _0x39dc5d=_0x4a6f71[_0x28f2('0x28')]({'plain':!![]});var _0x3cff60=_0x28f2('0x29');return db[_0x28f2('0x2a')][_0x28f2('0x27')]({'where':{'type':_0x3cff60,'resourceId':_0x39dc5d['id']}})['then'](function(){return _0x4a6f71;});})[_0x28f2('0x26')](function(){_0x2405aa['status'](0xcc)[_0x28f2('0x1d')]();});}};}function handleEntityNotFound(_0x5886ca,_0x5313d1){return function(_0xe4ea88){if(!_0xe4ea88){_0x5886ca[_0x28f2('0x1b')](0x194);}return _0xe4ea88;};}function handleError(_0xf8b431,_0x18cecf){_0x18cecf=_0x18cecf||0x1f4;return function(_0x3ac616){logger['error'](_0x3ac616[_0x28f2('0x2b')]);if(_0x3ac616[_0x28f2('0x2c')]){delete _0x3ac616[_0x28f2('0x2c')];}_0xf8b431[_0x28f2('0x1c')](_0x18cecf)[_0x28f2('0x2d')](_0x3ac616);};}exports['index']=function(_0x5eed50,_0x4eb584){var _0x53b98f={},_0x47db44={},_0x4aca93={'count':0x0,'rows':[]};var _0x3fe261=_[_0x28f2('0x2e')](db[_0x28f2('0x2f')][_0x28f2('0x30')],function(_0x134d46){return{'name':_0x134d46[_0x28f2('0x31')],'type':_0x134d46[_0x28f2('0x32')][_0x28f2('0x33')]};});_0x47db44[_0x28f2('0x34')]=_[_0x28f2('0x2e')](_0x3fe261,_0x28f2('0x2c'));_0x47db44[_0x28f2('0x35')]=_['keys'](_0x5eed50[_0x28f2('0x35')]);_0x47db44[_0x28f2('0x36')]=_[_0x28f2('0x37')](_0x47db44[_0x28f2('0x34')],_0x47db44['query']);_0x53b98f[_0x28f2('0x38')]=_[_0x28f2('0x37')](_0x47db44[_0x28f2('0x34')],qs[_0x28f2('0x39')](_0x5eed50[_0x28f2('0x35')][_0x28f2('0x39')]));_0x53b98f[_0x28f2('0x38')]=_0x53b98f[_0x28f2('0x38')]['length']?_0x53b98f[_0x28f2('0x38')]:_0x47db44[_0x28f2('0x34')];if(!_0x5eed50['query'][_0x28f2('0x3a')](_0x28f2('0x3b'))){_0x53b98f[_0x28f2('0x22')]=qs[_0x28f2('0x22')](_0x5eed50[_0x28f2('0x35')]['limit']);_0x53b98f['offset']=qs[_0x28f2('0x21')](_0x5eed50['query'][_0x28f2('0x21')]);}_0x53b98f[_0x28f2('0x3c')]=qs['sort'](_0x5eed50[_0x28f2('0x35')][_0x28f2('0x3d')]);_0x53b98f['where']=qs[_0x28f2('0x36')](_['pick'](_0x5eed50['query'],_0x47db44[_0x28f2('0x36')]),_0x3fe261);if(_0x5eed50['query'][_0x28f2('0x3e')]){_0x53b98f[_0x28f2('0x3f')]=_[_0x28f2('0x40')](_0x53b98f[_0x28f2('0x3f')],{'$or':_['map'](_0x3fe261,function(_0x4b132d){if(_0x4b132d[_0x28f2('0x32')]!==_0x28f2('0x41')){var _0x1cac9c={};_0x1cac9c[_0x4b132d[_0x28f2('0x2c')]]={'$like':'%'+_0x5eed50[_0x28f2('0x35')][_0x28f2('0x3e')]+'%'};return _0x1cac9c;}})});}_0x53b98f=_['merge']({},_0x53b98f,_0x5eed50[_0x28f2('0x42')]);var _0x1828ac={'where':_0x53b98f[_0x28f2('0x3f')]};return db[_0x28f2('0x2f')]['count'](_0x1828ac)[_0x28f2('0x26')](function(_0x406686){_0x4aca93[_0x28f2('0x20')]=_0x406686;if(_0x5eed50[_0x28f2('0x35')]['includeAll']){_0x53b98f[_0x28f2('0x43')]=[{'all':!![]}];}return db[_0x28f2('0x2f')]['findAll'](_0x53b98f);})[_0x28f2('0x26')](function(_0x4f9d89){_0x4aca93[_0x28f2('0x44')]=_0x4f9d89;return _0x4aca93;})['then'](respondWithFilteredResult(_0x4eb584,_0x53b98f))[_0x28f2('0x45')](handleError(_0x4eb584,null));};exports[_0x28f2('0x46')]=function(_0x3e7420,_0x19be18){var _0x3a78ba={'raw':!![],'where':{'id':_0x3e7420['params']['id']}},_0x2ac45d={};_0x2ac45d[_0x28f2('0x34')]=_['keys'](db[_0x28f2('0x2f')][_0x28f2('0x30')]);_0x2ac45d[_0x28f2('0x35')]=_['keys'](_0x3e7420[_0x28f2('0x35')]);_0x2ac45d['filters']=_[_0x28f2('0x37')](_0x2ac45d[_0x28f2('0x34')],_0x2ac45d[_0x28f2('0x35')]);_0x3a78ba['attributes']=_[_0x28f2('0x37')](_0x2ac45d[_0x28f2('0x34')],qs[_0x28f2('0x39')](_0x3e7420[_0x28f2('0x35')]['fields']));_0x3a78ba[_0x28f2('0x38')]=_0x3a78ba['attributes']['length']?_0x3a78ba[_0x28f2('0x38')]:_0x2ac45d[_0x28f2('0x34')];if(_0x3e7420[_0x28f2('0x35')][_0x28f2('0x47')]){_0x3a78ba[_0x28f2('0x43')]=[{'all':!![]}];}_0x3a78ba=_[_0x28f2('0x40')]({},_0x3a78ba,_0x3e7420[_0x28f2('0x42')]);return db[_0x28f2('0x2f')][_0x28f2('0x48')](_0x3a78ba)[_0x28f2('0x26')](handleEntityNotFound(_0x19be18,null))['then'](respondWithResult(_0x19be18,null))[_0x28f2('0x45')](handleError(_0x19be18,null));};exports['create']=function(_0xa6b9e2,_0x106fb7){return db[_0x28f2('0x2f')][_0x28f2('0x49')](_0xa6b9e2[_0x28f2('0x4a')],{})[_0x28f2('0x26')](function(_0x3fe42c){var _0x3794a7=_0xa6b9e2[_0x28f2('0x4b')][_0x28f2('0x28')]({'plain':!![]});if(!_0x3794a7)throw new Error(_0x28f2('0x4c'));if(_0x3794a7[_0x28f2('0x4d')]===_0x28f2('0x4b')){var _0x73dae2=_0x3fe42c[_0x28f2('0x28')]({'plain':!![]});var _0x5a98de=_0x28f2('0x29');return db[_0x28f2('0x4e')]['find']({'where':{'name':_0x5a98de,'userProfileId':_0x3794a7[_0x28f2('0x4f')]},'raw':!![]})[_0x28f2('0x26')](function(_0x46650c){if(_0x46650c&&_0x46650c[_0x28f2('0x50')]===0x0){return db[_0x28f2('0x2a')][_0x28f2('0x49')]({'name':_0x73dae2[_0x28f2('0x2c')],'resourceId':_0x73dae2['id'],'type':_0x46650c[_0x28f2('0x2c')],'sectionId':_0x46650c['id']},{})[_0x28f2('0x26')](function(){return _0x3fe42c;});}else{return _0x3fe42c;}})[_0x28f2('0x45')](function(_0x114ced){logger[_0x28f2('0x51')](_0x28f2('0x52'),_0x114ced);throw _0x114ced;});}return _0x3fe42c;})[_0x28f2('0x26')](respondWithResult(_0x106fb7,0xc9))['catch'](handleError(_0x106fb7,null));};exports[_0x28f2('0x25')]=function(_0x996ee6,_0x4e099c){if(_0x996ee6[_0x28f2('0x4a')]['id']){delete _0x996ee6[_0x28f2('0x4a')]['id'];}return db[_0x28f2('0x2f')][_0x28f2('0x48')]({'where':{'id':_0x996ee6['params']['id']}})[_0x28f2('0x26')](handleEntityNotFound(_0x4e099c,null))[_0x28f2('0x26')](saveUpdates(_0x996ee6[_0x28f2('0x4a')],null))[_0x28f2('0x26')](respondWithResult(_0x4e099c,null))[_0x28f2('0x45')](handleError(_0x4e099c,null));};exports['destroy']=function(_0x55f2c8,_0x43a5a7){return db[_0x28f2('0x2f')][_0x28f2('0x48')]({'where':{'id':_0x55f2c8[_0x28f2('0x53')]['id']}})['then'](handleEntityNotFound(_0x43a5a7,null))[_0x28f2('0x26')](removeEntity(_0x43a5a7,null))[_0x28f2('0x45')](handleError(_0x43a5a7,null));};exports[_0x28f2('0x54')]=function(_0x30162e,_0x153337,_0x2017db){if(_0x30162e[_0x28f2('0x4a')]['id']){delete _0x30162e[_0x28f2('0x4a')]['id'];}return db['Interval']['find']({'where':{'id':_0x30162e[_0x28f2('0x53')]['id']}})[_0x28f2('0x26')](handleEntityNotFound(_0x153337,null))[_0x28f2('0x26')](function(_0xd1de07){if(_0xd1de07){_0x30162e[_0x28f2('0x4a')][_0x28f2('0x55')]=_0xd1de07['id'];return db[_0x28f2('0x2f')][_0x28f2('0x49')](_0x30162e[_0x28f2('0x4a')]);}})['then'](respondWithResult(_0x153337,null))[_0x28f2('0x45')](handleError(_0x153337,null));};exports[_0x28f2('0x56')]=function(_0x5b6745,_0x1e0f07,_0x41c7fc){var _0x38bff4={};var _0x3c271f={};var _0x28c76c;var _0x13cbd9;return db[_0x28f2('0x2f')]['findOne']({'where':{'id':_0x5b6745[_0x28f2('0x53')]['id']}})['then'](handleEntityNotFound(_0x1e0f07,null))[_0x28f2('0x26')](function(_0x10ebb6){if(_0x10ebb6){_0x28c76c=_0x10ebb6;_0x3c271f[_0x28f2('0x34')]=_['keys'](db[_0x28f2('0x2f')][_0x28f2('0x30')]);_0x3c271f['query']=_['keys'](_0x5b6745['query']);_0x3c271f[_0x28f2('0x36')]=_[_0x28f2('0x37')](_0x3c271f['model'],_0x3c271f[_0x28f2('0x35')]);_0x38bff4['attributes']=_[_0x28f2('0x37')](_0x3c271f['model'],qs[_0x28f2('0x39')](_0x5b6745[_0x28f2('0x35')][_0x28f2('0x39')]));_0x38bff4[_0x28f2('0x38')]=_0x38bff4[_0x28f2('0x38')][_0x28f2('0x57')]?_0x38bff4[_0x28f2('0x38')]:_0x3c271f['model'];_0x38bff4[_0x28f2('0x3c')]=qs[_0x28f2('0x3d')](_0x5b6745[_0x28f2('0x35')]['sort']);_0x38bff4[_0x28f2('0x3f')]=qs['filters'](_['pick'](_0x5b6745[_0x28f2('0x35')],_0x3c271f['filters']));if(_0x5b6745['query'][_0x28f2('0x3e')]){_0x38bff4['where']=_[_0x28f2('0x40')](_0x38bff4[_0x28f2('0x3f')],{'$or':_['map'](_0x38bff4[_0x28f2('0x38')],function(_0x3b5391){var _0x3cff9f={};_0x3cff9f[_0x3b5391]={'$like':'%'+_0x5b6745['query'][_0x28f2('0x3e')]+'%'};return _0x3cff9f;})});}_0x38bff4=_[_0x28f2('0x40')]({},_0x38bff4,_0x5b6745[_0x28f2('0x42')]);return _0x28c76c['getIntervals'](_0x38bff4);}})[_0x28f2('0x26')](function(_0x28e985){if(_0x28e985){_0x13cbd9=_0x28e985[_0x28f2('0x57')];if(!_0x5b6745[_0x28f2('0x35')][_0x28f2('0x3a')](_0x28f2('0x3b'))){_0x38bff4[_0x28f2('0x22')]=qs[_0x28f2('0x22')](_0x5b6745[_0x28f2('0x35')]['limit']);_0x38bff4[_0x28f2('0x21')]=qs[_0x28f2('0x21')](_0x5b6745['query']['offset']);}return _0x28c76c['getIntervals'](_0x38bff4);}})[_0x28f2('0x26')](function(_0x53e85b){if(_0x53e85b){return _0x53e85b?{'count':_0x13cbd9,'rows':_0x53e85b}:null;}})[_0x28f2('0x26')](respondWithResult(_0x1e0f07,null))[_0x28f2('0x45')](handleError(_0x1e0f07,null));};exports[_0x28f2('0x58')]=function(_0x25cc97,_0x5bdceb,_0x18947f){return db[_0x28f2('0x2f')][_0x28f2('0x59')]({'where':{'id':_0x25cc97[_0x28f2('0x53')]['id']}})[_0x28f2('0x26')](handleEntityNotFound(_0x5bdceb,null))[_0x28f2('0x26')](function(_0x198d6f){if(_0x198d6f){return db[_0x28f2('0x5a')][_0x28f2('0x5b')](function(_0x590ec1){return db[_0x28f2('0x2f')][_0x28f2('0x27')]({'where':{'IntervalId':_0x25cc97['params']['id']},'transaction':_0x590ec1})['then'](function(_0x185382){var _0x104640=_[_0x28f2('0x2e')](_0x25cc97[_0x28f2('0x4a')],function(_0x3d53a9){delete _0x3d53a9['id'];_0x3d53a9[_0x28f2('0x55')]=_0x25cc97[_0x28f2('0x53')]['id'];return _0x3d53a9;});return db['Interval']['bulkCreate'](_0x104640,{'transaction':_0x590ec1});});})[_0x28f2('0x26')](function(){return db['Interval'][_0x28f2('0x5c')]({'where':{'IntervalId':_0x25cc97[_0x28f2('0x53')]['id']}});});}})[_0x28f2('0x26')](respondWithResult(_0x5bdceb,null))[_0x28f2('0x45')](handleError(_0x5bdceb,null));};
\ No newline at end of file