Built motion from commit 3d3e98f2.|2.6.29
[motion2.git] / server / api / interval / interval.controller.js
index 2b78257..68cfab3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xed29=['count','offset','limit','set','Content-Range','reject','save','update','then','destroy','get','Intervals','UserProfileResource','end','sendStatus','error','stack','name','send','Interval','fieldName','type','key','model','map','query','keys','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','intersection','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','addInterval','getIntervals','findOne','filters','addIntervals','transaction','bulkCreate','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/license/util','../../components/extensions/rewrite','status','json','undefined'];(function(_0x438988,_0x2a86cf){var _0x1ce59f=function(_0x26f36a){while(--_0x26f36a){_0x438988['push'](_0x438988['shift']());}};_0x1ce59f(++_0x2a86cf);}(_0xed29,0x1ac));var _0x9ed2=function(_0x23bb07,_0x2d8a9b){_0x23bb07=_0x23bb07-0x0;var _0x3577df=_0xed29[_0x23bb07];return _0x3577df;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9ed2('0x0'));var zipdir=require(_0x9ed2('0x1'));var jsonpatch=require(_0x9ed2('0x2'));var rp=require('request-promise');var moment=require(_0x9ed2('0x3'));var BPromise=require(_0x9ed2('0x4'));var Mustache=require(_0x9ed2('0x5'));var util=require(_0x9ed2('0x6'));var path=require('path');var sox=require(_0x9ed2('0x7'));var csv=require('to-csv');var ejs=require(_0x9ed2('0x8'));var fs=require('fs');var fs_extra=require(_0x9ed2('0x9'));var _=require(_0x9ed2('0xa'));var squel=require('squel');var crypto=require(_0x9ed2('0xb'));var jsforce=require(_0x9ed2('0xc'));var deskjs=require(_0x9ed2('0xd'));var toCsv=require(_0x9ed2('0xe'));var querystring=require(_0x9ed2('0xf'));var Papa=require(_0x9ed2('0x10'));var Redis=require(_0x9ed2('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x9ed2('0x12'));var as=require(_0x9ed2('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9ed2('0x14'))(_0x9ed2('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x9ed2('0x16'));var db=require('../../mysqldb')['db'];var extensions=require(_0x9ed2('0x17'));function respondWithStatusCode(_0x5718fb,_0xf7938e){_0xf7938e=_0xf7938e||0xcc;return function(_0x2c4849){if(_0x2c4849){return _0x5718fb['sendStatus'](_0xf7938e);}return _0x5718fb[_0x9ed2('0x18')](_0xf7938e)['end']();};}function respondWithResult(_0x122499,_0x3cc39c){_0x3cc39c=_0x3cc39c||0xc8;return function(_0xf1ea96){if(_0xf1ea96){return _0x122499[_0x9ed2('0x18')](_0x3cc39c)[_0x9ed2('0x19')](_0xf1ea96);}};}function respondWithFilteredResult(_0x4ff6cb,_0x4ffa88){return function(_0x5c1838){if(_0x5c1838){var _0x361b93=typeof _0x4ffa88['offset']==='undefined'&&typeof _0x4ffa88['limit']===_0x9ed2('0x1a');var _0x4a815b=_0x5c1838[_0x9ed2('0x1b')];var _0x3d7612=_0x361b93?0x0:_0x4ffa88['offset'];var _0x201831=_0x361b93?_0x5c1838[_0x9ed2('0x1b')]:_0x4ffa88[_0x9ed2('0x1c')]+_0x4ffa88[_0x9ed2('0x1d')];var _0x1af579;if(_0x201831>=_0x4a815b){_0x201831=_0x4a815b;_0x1af579=0xc8;}else{_0x1af579=0xce;}_0x4ff6cb[_0x9ed2('0x18')](_0x1af579);return _0x4ff6cb[_0x9ed2('0x1e')](_0x9ed2('0x1f'),_0x3d7612+'-'+_0x201831+'/'+_0x4a815b)[_0x9ed2('0x19')](_0x5c1838);}return null;};}function patchUpdates(_0x11f522){return function(_0x287bb3){try{jsonpatch['apply'](_0x287bb3,_0x11f522,!![]);}catch(_0x518b26){return BPromise[_0x9ed2('0x20')](_0x518b26);}return _0x287bb3[_0x9ed2('0x21')]();};}function saveUpdates(_0x59d05a,_0x4fa8b3){return function(_0x15a803){if(_0x15a803){return _0x15a803[_0x9ed2('0x22')](_0x59d05a)[_0x9ed2('0x23')](function(_0x4d6c3c){return _0x4d6c3c;});}return null;};}function removeEntity(_0x508b41,_0x4663b2){return function(_0x458a69){if(_0x458a69){return _0x458a69[_0x9ed2('0x24')]()['then'](function(){var _0x36d974=_0x458a69[_0x9ed2('0x25')]({'plain':!![]});var _0x451d2f=_0x9ed2('0x26');return db[_0x9ed2('0x27')][_0x9ed2('0x24')]({'where':{'type':_0x451d2f,'resourceId':_0x36d974['id']}})[_0x9ed2('0x23')](function(){return _0x458a69;});})['then'](function(){_0x508b41[_0x9ed2('0x18')](0xcc)[_0x9ed2('0x28')]();});}};}function handleEntityNotFound(_0x30d330,_0x116957){return function(_0x405e1a){if(!_0x405e1a){_0x30d330[_0x9ed2('0x29')](0x194);}return _0x405e1a;};}function handleError(_0x53f34a,_0x1390c0){_0x1390c0=_0x1390c0||0x1f4;return function(_0x1d9dec){logger[_0x9ed2('0x2a')](_0x1d9dec[_0x9ed2('0x2b')]);if(_0x1d9dec[_0x9ed2('0x2c')]){delete _0x1d9dec[_0x9ed2('0x2c')];}_0x53f34a['status'](_0x1390c0)[_0x9ed2('0x2d')](_0x1d9dec);};}exports['index']=function(_0x57a587,_0x134e6d){var _0x98c51c={},_0x3cfb95={},_0x216624={'count':0x0,'rows':[]};var _0x264568=_['map'](db[_0x9ed2('0x2e')]['rawAttributes'],function(_0x9854e3){return{'name':_0x9854e3[_0x9ed2('0x2f')],'type':_0x9854e3[_0x9ed2('0x30')][_0x9ed2('0x31')]};});_0x3cfb95[_0x9ed2('0x32')]=_[_0x9ed2('0x33')](_0x264568,_0x9ed2('0x2c'));_0x3cfb95[_0x9ed2('0x34')]=_[_0x9ed2('0x35')](_0x57a587[_0x9ed2('0x34')]);_0x3cfb95['filters']=_['intersection'](_0x3cfb95[_0x9ed2('0x32')],_0x3cfb95['query']);_0x98c51c[_0x9ed2('0x36')]=_['intersection'](_0x3cfb95['model'],qs['fields'](_0x57a587[_0x9ed2('0x34')][_0x9ed2('0x37')]));_0x98c51c[_0x9ed2('0x36')]=_0x98c51c[_0x9ed2('0x36')][_0x9ed2('0x38')]?_0x98c51c[_0x9ed2('0x36')]:_0x3cfb95[_0x9ed2('0x32')];if(!_0x57a587[_0x9ed2('0x34')][_0x9ed2('0x39')](_0x9ed2('0x3a'))){_0x98c51c[_0x9ed2('0x1d')]=qs['limit'](_0x57a587[_0x9ed2('0x34')][_0x9ed2('0x1d')]);_0x98c51c[_0x9ed2('0x1c')]=qs[_0x9ed2('0x1c')](_0x57a587['query']['offset']);}_0x98c51c[_0x9ed2('0x3b')]=qs[_0x9ed2('0x3c')](_0x57a587[_0x9ed2('0x34')]['sort']);_0x98c51c[_0x9ed2('0x3d')]=qs['filters'](_[_0x9ed2('0x3e')](_0x57a587[_0x9ed2('0x34')],_0x3cfb95['filters']),_0x264568);if(_0x57a587[_0x9ed2('0x34')][_0x9ed2('0x3f')]){_0x98c51c[_0x9ed2('0x3d')]=_[_0x9ed2('0x40')](_0x98c51c[_0x9ed2('0x3d')],{'$or':_[_0x9ed2('0x33')](_0x264568,function(_0xdf60b7){if(_0xdf60b7[_0x9ed2('0x30')]!==_0x9ed2('0x41')){var _0x3b2e59={};_0x3b2e59[_0xdf60b7[_0x9ed2('0x2c')]]={'$like':'%'+_0x57a587[_0x9ed2('0x34')][_0x9ed2('0x3f')]+'%'};return _0x3b2e59;}})});}_0x98c51c=_[_0x9ed2('0x40')]({},_0x98c51c,_0x57a587[_0x9ed2('0x42')]);var _0x46e3eb={'where':_0x98c51c[_0x9ed2('0x3d')]};return db[_0x9ed2('0x2e')][_0x9ed2('0x1b')](_0x46e3eb)[_0x9ed2('0x23')](function(_0x1086a1){_0x216624[_0x9ed2('0x1b')]=_0x1086a1;if(_0x57a587['query'][_0x9ed2('0x43')]){_0x98c51c[_0x9ed2('0x44')]=[{'all':!![]}];}return db['Interval'][_0x9ed2('0x45')](_0x98c51c);})['then'](function(_0x59bd90){_0x216624[_0x9ed2('0x46')]=_0x59bd90;return _0x216624;})['then'](respondWithFilteredResult(_0x134e6d,_0x98c51c))[_0x9ed2('0x47')](handleError(_0x134e6d,null));};exports[_0x9ed2('0x48')]=function(_0x47940a,_0x598d06){var _0x3d69b7={'raw':!![],'where':{'id':_0x47940a[_0x9ed2('0x49')]['id']}},_0x5f415c={};_0x5f415c[_0x9ed2('0x32')]=_[_0x9ed2('0x35')](db[_0x9ed2('0x2e')][_0x9ed2('0x4a')]);_0x5f415c[_0x9ed2('0x34')]=_[_0x9ed2('0x35')](_0x47940a[_0x9ed2('0x34')]);_0x5f415c['filters']=_[_0x9ed2('0x4b')](_0x5f415c['model'],_0x5f415c[_0x9ed2('0x34')]);_0x3d69b7[_0x9ed2('0x36')]=_[_0x9ed2('0x4b')](_0x5f415c[_0x9ed2('0x32')],qs['fields'](_0x47940a[_0x9ed2('0x34')][_0x9ed2('0x37')]));_0x3d69b7[_0x9ed2('0x36')]=_0x3d69b7['attributes'][_0x9ed2('0x38')]?_0x3d69b7['attributes']:_0x5f415c[_0x9ed2('0x32')];if(_0x47940a[_0x9ed2('0x34')][_0x9ed2('0x43')]){_0x3d69b7[_0x9ed2('0x44')]=[{'all':!![]}];}_0x3d69b7=_[_0x9ed2('0x40')]({},_0x3d69b7,_0x47940a[_0x9ed2('0x42')]);return db['Interval'][_0x9ed2('0x4c')](_0x3d69b7)[_0x9ed2('0x23')](handleEntityNotFound(_0x598d06,null))[_0x9ed2('0x23')](respondWithResult(_0x598d06,null))['catch'](handleError(_0x598d06,null));};exports[_0x9ed2('0x4d')]=function(_0x50d62a,_0xd63bfa){return db[_0x9ed2('0x2e')][_0x9ed2('0x4d')](_0x50d62a['body'],{})[_0x9ed2('0x23')](function(_0x6c9330){var _0x711f07=_0x50d62a[_0x9ed2('0x4e')][_0x9ed2('0x25')]({'plain':!![]});if(!_0x711f07)throw new Error(_0x9ed2('0x4f'));if(_0x711f07['role']===_0x9ed2('0x4e')){var _0x3ef66f=_0x6c9330[_0x9ed2('0x25')]({'plain':!![]});var _0x4beca2=_0x9ed2('0x26');return db[_0x9ed2('0x50')][_0x9ed2('0x4c')]({'where':{'name':_0x4beca2,'userProfileId':_0x711f07['userProfileId']},'raw':!![]})[_0x9ed2('0x23')](function(_0x53da27){if(_0x53da27&&_0x53da27[_0x9ed2('0x51')]===0x0){return db[_0x9ed2('0x27')]['create']({'name':_0x3ef66f[_0x9ed2('0x2c')],'resourceId':_0x3ef66f['id'],'type':_0x53da27[_0x9ed2('0x2c')],'sectionId':_0x53da27['id']},{})[_0x9ed2('0x23')](function(){return _0x6c9330;});}else{return _0x6c9330;}})[_0x9ed2('0x47')](function(_0x5f1f9b){logger['error'](_0x9ed2('0x52'),_0x5f1f9b);throw _0x5f1f9b;});}return _0x6c9330;})[_0x9ed2('0x23')](respondWithResult(_0xd63bfa,0xc9))['catch'](handleError(_0xd63bfa,null));};exports[_0x9ed2('0x22')]=function(_0x106579,_0x51e5f1){if(_0x106579[_0x9ed2('0x53')]['id']){delete _0x106579[_0x9ed2('0x53')]['id'];}return db[_0x9ed2('0x2e')][_0x9ed2('0x4c')]({'where':{'id':_0x106579[_0x9ed2('0x49')]['id']}})[_0x9ed2('0x23')](handleEntityNotFound(_0x51e5f1,null))[_0x9ed2('0x23')](saveUpdates(_0x106579[_0x9ed2('0x53')],null))[_0x9ed2('0x23')](respondWithResult(_0x51e5f1,null))[_0x9ed2('0x47')](handleError(_0x51e5f1,null));};exports[_0x9ed2('0x24')]=function(_0x1b4825,_0x41518c){return db['Interval'][_0x9ed2('0x4c')]({'where':{'id':_0x1b4825[_0x9ed2('0x49')]['id']}})[_0x9ed2('0x23')](handleEntityNotFound(_0x41518c,null))[_0x9ed2('0x23')](removeEntity(_0x41518c,null))[_0x9ed2('0x47')](handleError(_0x41518c,null));};exports[_0x9ed2('0x54')]=function(_0x44cbf4,_0x4ee512,_0x5bae1e){if(_0x44cbf4[_0x9ed2('0x53')]['id']){delete _0x44cbf4[_0x9ed2('0x53')]['id'];}return db[_0x9ed2('0x2e')][_0x9ed2('0x4c')]({'where':{'id':_0x44cbf4[_0x9ed2('0x49')]['id']}})[_0x9ed2('0x23')](handleEntityNotFound(_0x4ee512,null))['then'](function(_0x5e2ba2){if(_0x5e2ba2){_0x44cbf4[_0x9ed2('0x53')]['IntervalId']=_0x5e2ba2['id'];return db[_0x9ed2('0x2e')][_0x9ed2('0x4d')](_0x44cbf4[_0x9ed2('0x53')]);}})[_0x9ed2('0x23')](respondWithResult(_0x4ee512,null))['catch'](handleError(_0x4ee512,null));};exports[_0x9ed2('0x55')]=function(_0x574a67,_0x57f5fb,_0x4c7001){var _0x3e9910={};var _0xe852d8={};var _0x113beb;var _0x16bef8;return db[_0x9ed2('0x2e')][_0x9ed2('0x56')]({'where':{'id':_0x574a67[_0x9ed2('0x49')]['id']}})[_0x9ed2('0x23')](handleEntityNotFound(_0x57f5fb,null))[_0x9ed2('0x23')](function(_0xbc03d){if(_0xbc03d){_0x113beb=_0xbc03d;_0xe852d8[_0x9ed2('0x32')]=_[_0x9ed2('0x35')](db[_0x9ed2('0x2e')][_0x9ed2('0x4a')]);_0xe852d8['query']=_['keys'](_0x574a67['query']);_0xe852d8[_0x9ed2('0x57')]=_[_0x9ed2('0x4b')](_0xe852d8[_0x9ed2('0x32')],_0xe852d8['query']);_0x3e9910[_0x9ed2('0x36')]=_[_0x9ed2('0x4b')](_0xe852d8[_0x9ed2('0x32')],qs['fields'](_0x574a67[_0x9ed2('0x34')][_0x9ed2('0x37')]));_0x3e9910['attributes']=_0x3e9910['attributes'][_0x9ed2('0x38')]?_0x3e9910[_0x9ed2('0x36')]:_0xe852d8[_0x9ed2('0x32')];_0x3e9910['order']=qs[_0x9ed2('0x3c')](_0x574a67[_0x9ed2('0x34')][_0x9ed2('0x3c')]);_0x3e9910[_0x9ed2('0x3d')]=qs[_0x9ed2('0x57')](_[_0x9ed2('0x3e')](_0x574a67[_0x9ed2('0x34')],_0xe852d8[_0x9ed2('0x57')]));if(_0x574a67[_0x9ed2('0x34')]['filter']){_0x3e9910[_0x9ed2('0x3d')]=_[_0x9ed2('0x40')](_0x3e9910[_0x9ed2('0x3d')],{'$or':_[_0x9ed2('0x33')](_0x3e9910[_0x9ed2('0x36')],function(_0x2a549c){var _0x5f0429={};_0x5f0429[_0x2a549c]={'$like':'%'+_0x574a67['query'][_0x9ed2('0x3f')]+'%'};return _0x5f0429;})});}_0x3e9910=_[_0x9ed2('0x40')]({},_0x3e9910,_0x574a67[_0x9ed2('0x42')]);return _0x113beb[_0x9ed2('0x55')](_0x3e9910);}})['then'](function(_0x489026){if(_0x489026){_0x16bef8=_0x489026[_0x9ed2('0x38')];if(!_0x574a67[_0x9ed2('0x34')]['hasOwnProperty'](_0x9ed2('0x3a'))){_0x3e9910[_0x9ed2('0x1d')]=qs[_0x9ed2('0x1d')](_0x574a67[_0x9ed2('0x34')][_0x9ed2('0x1d')]);_0x3e9910[_0x9ed2('0x1c')]=qs['offset'](_0x574a67[_0x9ed2('0x34')]['offset']);}return _0x113beb[_0x9ed2('0x55')](_0x3e9910);}})['then'](function(_0x9e0216){if(_0x9e0216){return _0x9e0216?{'count':_0x16bef8,'rows':_0x9e0216}:null;}})[_0x9ed2('0x23')](respondWithResult(_0x57f5fb,null))[_0x9ed2('0x47')](handleError(_0x57f5fb,null));};exports[_0x9ed2('0x58')]=function(_0x3baf2f,_0x152afb,_0x48fb13){return db[_0x9ed2('0x2e')][_0x9ed2('0x56')]({'where':{'id':_0x3baf2f[_0x9ed2('0x49')]['id']}})[_0x9ed2('0x23')](handleEntityNotFound(_0x152afb,null))[_0x9ed2('0x23')](function(_0x3a543a){if(_0x3a543a){return db['sequelize'][_0x9ed2('0x59')](function(_0x537945){return db[_0x9ed2('0x2e')][_0x9ed2('0x24')]({'where':{'IntervalId':_0x3baf2f[_0x9ed2('0x49')]['id']},'transaction':_0x537945})[_0x9ed2('0x23')](function(_0x14609f){var _0x860f75=_[_0x9ed2('0x33')](_0x3baf2f[_0x9ed2('0x53')],function(_0x29c416){delete _0x29c416['id'];_0x29c416['IntervalId']=_0x3baf2f[_0x9ed2('0x49')]['id'];return _0x29c416;});return db[_0x9ed2('0x2e')][_0x9ed2('0x5a')](_0x860f75,{'transaction':_0x537945});});})[_0x9ed2('0x23')](function(){return db[_0x9ed2('0x2e')][_0x9ed2('0x45')]({'where':{'IntervalId':_0x3baf2f['params']['id']}});});}})['then'](respondWithResult(_0x152afb,null))[_0x9ed2('0x47')](handleError(_0x152afb,null));};
\ No newline at end of file
+var _0xabf3=['map','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','Interval','includeAll','include','findAll','rows','catch','params','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','name','error','find','addInterval','getIntervals','findOne','sequelize','transaction','IntervalId','bulkCreate','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','update','then','destroy','get','Intervals','UserProfileResource','stack','send','index'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0xabf3,0x8b));var _0x3abf=function(_0x35ba41,_0x2a6d94){_0x35ba41=_0x35ba41-0x0;var _0x4ae7a2=_0xabf3[_0x35ba41];return _0x4ae7a2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x3abf('0x0'));var zipdir=require(_0x3abf('0x1'));var jsonpatch=require(_0x3abf('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x3abf('0x3'));var Mustache=require(_0x3abf('0x4'));var util=require(_0x3abf('0x5'));var path=require(_0x3abf('0x6'));var sox=require(_0x3abf('0x7'));var csv=require(_0x3abf('0x8'));var ejs=require(_0x3abf('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3abf('0xa'));var squel=require('squel');var crypto=require(_0x3abf('0xb'));var jsforce=require(_0x3abf('0xc'));var deskjs=require(_0x3abf('0xd'));var toCsv=require(_0x3abf('0x8'));var querystring=require(_0x3abf('0xe'));var Papa=require(_0x3abf('0xf'));var Redis=require(_0x3abf('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x3abf('0x11'));var as=require(_0x3abf('0x12'));var hardwareService=require(_0x3abf('0x13'));var logger=require('../../config/logger')(_0x3abf('0x14'));var utils=require('../../config/utils');var config=require(_0x3abf('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x3abf('0x16'))['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x19f4c3,_0x374b28){_0x374b28=_0x374b28||0xcc;return function(_0x1d4a5f){if(_0x1d4a5f){return _0x19f4c3[_0x3abf('0x17')](_0x374b28);}return _0x19f4c3[_0x3abf('0x18')](_0x374b28)[_0x3abf('0x19')]();};}function respondWithResult(_0x1b8be6,_0x4a8f73){_0x4a8f73=_0x4a8f73||0xc8;return function(_0x243372){if(_0x243372){return _0x1b8be6['status'](_0x4a8f73)[_0x3abf('0x1a')](_0x243372);}};}function respondWithFilteredResult(_0x4963ba,_0x3079b9){return function(_0x571f3a){if(_0x571f3a){var _0x34cdf6=typeof _0x3079b9[_0x3abf('0x1b')]===_0x3abf('0x1c')&&typeof _0x3079b9[_0x3abf('0x1d')]===_0x3abf('0x1c');var _0x54edfa=_0x571f3a['count'];var _0x1187ca=_0x34cdf6?0x0:_0x3079b9['offset'];var _0x549ed4=_0x34cdf6?_0x571f3a[_0x3abf('0x1e')]:_0x3079b9[_0x3abf('0x1b')]+_0x3079b9['limit'];var _0x56a9f8;if(_0x549ed4>=_0x54edfa){_0x549ed4=_0x54edfa;_0x56a9f8=0xc8;}else{_0x56a9f8=0xce;}_0x4963ba[_0x3abf('0x18')](_0x56a9f8);return _0x4963ba['set'](_0x3abf('0x1f'),_0x1187ca+'-'+_0x549ed4+'/'+_0x54edfa)[_0x3abf('0x1a')](_0x571f3a);}return null;};}function patchUpdates(_0x11766d){return function(_0x1a938d){try{jsonpatch[_0x3abf('0x20')](_0x1a938d,_0x11766d,!![]);}catch(_0x513bbd){return BPromise[_0x3abf('0x21')](_0x513bbd);}return _0x1a938d['save']();};}function saveUpdates(_0x1f9572,_0x3d77ec){return function(_0x46cf75){if(_0x46cf75){return _0x46cf75[_0x3abf('0x22')](_0x1f9572)[_0x3abf('0x23')](function(_0x2b577a){return _0x2b577a;});}return null;};}function removeEntity(_0x323da5,_0x1c675d){return function(_0x79b257){if(_0x79b257){return _0x79b257[_0x3abf('0x24')]()[_0x3abf('0x23')](function(){var _0x2160ea=_0x79b257[_0x3abf('0x25')]({'plain':!![]});var _0x4d9bc3=_0x3abf('0x26');return db[_0x3abf('0x27')]['destroy']({'where':{'type':_0x4d9bc3,'resourceId':_0x2160ea['id']}})[_0x3abf('0x23')](function(){return _0x79b257;});})[_0x3abf('0x23')](function(){_0x323da5[_0x3abf('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x44b76d,_0x3bda7d){return function(_0x6701d4){if(!_0x6701d4){_0x44b76d['sendStatus'](0x194);}return _0x6701d4;};}function handleError(_0x2cb41b,_0x547ce3){_0x547ce3=_0x547ce3||0x1f4;return function(_0x31dfe4){logger['error'](_0x31dfe4[_0x3abf('0x28')]);if(_0x31dfe4['name']){delete _0x31dfe4['name'];}_0x2cb41b[_0x3abf('0x18')](_0x547ce3)[_0x3abf('0x29')](_0x31dfe4);};}exports[_0x3abf('0x2a')]=function(_0x5ef4ed,_0x3c677b){var _0x236e33={},_0x5dee69={},_0x3d46ac={'count':0x0,'rows':[]};var _0x5b149f=_[_0x3abf('0x2b')](db['Interval'][_0x3abf('0x2c')],function(_0x3fd307){return{'name':_0x3fd307[_0x3abf('0x2d')],'type':_0x3fd307[_0x3abf('0x2e')][_0x3abf('0x2f')]};});_0x5dee69[_0x3abf('0x30')]=_['map'](_0x5b149f,'name');_0x5dee69[_0x3abf('0x31')]=_[_0x3abf('0x32')](_0x5ef4ed[_0x3abf('0x31')]);_0x5dee69[_0x3abf('0x33')]=_['intersection'](_0x5dee69[_0x3abf('0x30')],_0x5dee69[_0x3abf('0x31')]);_0x236e33[_0x3abf('0x34')]=_[_0x3abf('0x35')](_0x5dee69['model'],qs[_0x3abf('0x36')](_0x5ef4ed[_0x3abf('0x31')]['fields']));_0x236e33['attributes']=_0x236e33['attributes'][_0x3abf('0x37')]?_0x236e33['attributes']:_0x5dee69[_0x3abf('0x30')];if(!_0x5ef4ed[_0x3abf('0x31')][_0x3abf('0x38')](_0x3abf('0x39'))){_0x236e33[_0x3abf('0x1d')]=qs[_0x3abf('0x1d')](_0x5ef4ed['query']['limit']);_0x236e33[_0x3abf('0x1b')]=qs['offset'](_0x5ef4ed[_0x3abf('0x31')][_0x3abf('0x1b')]);}_0x236e33[_0x3abf('0x3a')]=qs[_0x3abf('0x3b')](_0x5ef4ed[_0x3abf('0x31')][_0x3abf('0x3b')]);_0x236e33[_0x3abf('0x3c')]=qs[_0x3abf('0x33')](_[_0x3abf('0x3d')](_0x5ef4ed[_0x3abf('0x31')],_0x5dee69[_0x3abf('0x33')]),_0x5b149f);if(_0x5ef4ed[_0x3abf('0x31')][_0x3abf('0x3e')]){_0x236e33[_0x3abf('0x3c')]=_[_0x3abf('0x3f')](_0x236e33[_0x3abf('0x3c')],{'$or':_[_0x3abf('0x2b')](_0x5b149f,function(_0x31bc77){if(_0x31bc77[_0x3abf('0x2e')]!==_0x3abf('0x40')){var _0x132480={};_0x132480[_0x31bc77['name']]={'$like':'%'+_0x5ef4ed['query'][_0x3abf('0x3e')]+'%'};return _0x132480;}})});}_0x236e33=_['merge']({},_0x236e33,_0x5ef4ed[_0x3abf('0x41')]);var _0x4fbe0e={'where':_0x236e33[_0x3abf('0x3c')]};return db[_0x3abf('0x42')]['count'](_0x4fbe0e)[_0x3abf('0x23')](function(_0x20efe8){_0x3d46ac[_0x3abf('0x1e')]=_0x20efe8;if(_0x5ef4ed['query'][_0x3abf('0x43')]){_0x236e33[_0x3abf('0x44')]=[{'all':!![]}];}return db[_0x3abf('0x42')][_0x3abf('0x45')](_0x236e33);})[_0x3abf('0x23')](function(_0x5646e6){_0x3d46ac[_0x3abf('0x46')]=_0x5646e6;return _0x3d46ac;})['then'](respondWithFilteredResult(_0x3c677b,_0x236e33))[_0x3abf('0x47')](handleError(_0x3c677b,null));};exports['show']=function(_0x42e0da,_0x7aed49){var _0x4e338d={'raw':!![],'where':{'id':_0x42e0da[_0x3abf('0x48')]['id']}},_0x59a591={};_0x59a591['model']=_[_0x3abf('0x32')](db[_0x3abf('0x42')][_0x3abf('0x2c')]);_0x59a591[_0x3abf('0x31')]=_[_0x3abf('0x32')](_0x42e0da[_0x3abf('0x31')]);_0x59a591[_0x3abf('0x33')]=_[_0x3abf('0x35')](_0x59a591[_0x3abf('0x30')],_0x59a591[_0x3abf('0x31')]);_0x4e338d[_0x3abf('0x34')]=_[_0x3abf('0x35')](_0x59a591[_0x3abf('0x30')],qs['fields'](_0x42e0da['query'][_0x3abf('0x36')]));_0x4e338d[_0x3abf('0x34')]=_0x4e338d[_0x3abf('0x34')][_0x3abf('0x37')]?_0x4e338d['attributes']:_0x59a591[_0x3abf('0x30')];if(_0x42e0da[_0x3abf('0x31')][_0x3abf('0x43')]){_0x4e338d[_0x3abf('0x44')]=[{'all':!![]}];}_0x4e338d=_[_0x3abf('0x3f')]({},_0x4e338d,_0x42e0da[_0x3abf('0x41')]);return db[_0x3abf('0x42')]['find'](_0x4e338d)['then'](handleEntityNotFound(_0x7aed49,null))[_0x3abf('0x23')](respondWithResult(_0x7aed49,null))[_0x3abf('0x47')](handleError(_0x7aed49,null));};exports['create']=function(_0x7f6c61,_0x298a49){return db[_0x3abf('0x42')][_0x3abf('0x49')](_0x7f6c61[_0x3abf('0x4a')],{})[_0x3abf('0x23')](function(_0x35634a){var _0x4a48c6=_0x7f6c61['user'][_0x3abf('0x25')]({'plain':!![]});if(!_0x4a48c6)throw new Error(_0x3abf('0x4b'));if(_0x4a48c6[_0x3abf('0x4c')]===_0x3abf('0x4d')){var _0x31377c=_0x35634a[_0x3abf('0x25')]({'plain':!![]});var _0x170769=_0x3abf('0x26');return db[_0x3abf('0x4e')]['find']({'where':{'name':_0x170769,'userProfileId':_0x4a48c6[_0x3abf('0x4f')]},'raw':!![]})[_0x3abf('0x23')](function(_0x9739b7){if(_0x9739b7&&_0x9739b7[_0x3abf('0x50')]===0x0){return db[_0x3abf('0x27')][_0x3abf('0x49')]({'name':_0x31377c[_0x3abf('0x51')],'resourceId':_0x31377c['id'],'type':_0x9739b7[_0x3abf('0x51')],'sectionId':_0x9739b7['id']},{})[_0x3abf('0x23')](function(){return _0x35634a;});}else{return _0x35634a;}})[_0x3abf('0x47')](function(_0x3c922e){logger[_0x3abf('0x52')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3c922e);throw _0x3c922e;});}return _0x35634a;})[_0x3abf('0x23')](respondWithResult(_0x298a49,0xc9))[_0x3abf('0x47')](handleError(_0x298a49,null));};exports[_0x3abf('0x22')]=function(_0xa4efe4,_0x5c1e20){if(_0xa4efe4['body']['id']){delete _0xa4efe4[_0x3abf('0x4a')]['id'];}return db[_0x3abf('0x42')][_0x3abf('0x53')]({'where':{'id':_0xa4efe4[_0x3abf('0x48')]['id']}})[_0x3abf('0x23')](handleEntityNotFound(_0x5c1e20,null))[_0x3abf('0x23')](saveUpdates(_0xa4efe4['body'],null))[_0x3abf('0x23')](respondWithResult(_0x5c1e20,null))[_0x3abf('0x47')](handleError(_0x5c1e20,null));};exports[_0x3abf('0x24')]=function(_0x398261,_0x421347){return db['Interval']['find']({'where':{'id':_0x398261[_0x3abf('0x48')]['id']}})[_0x3abf('0x23')](handleEntityNotFound(_0x421347,null))['then'](removeEntity(_0x421347,null))[_0x3abf('0x47')](handleError(_0x421347,null));};exports[_0x3abf('0x54')]=function(_0x179d1b,_0x292e93,_0x2cd2c3){if(_0x179d1b['body']['id']){delete _0x179d1b[_0x3abf('0x4a')]['id'];}return db[_0x3abf('0x42')][_0x3abf('0x53')]({'where':{'id':_0x179d1b[_0x3abf('0x48')]['id']}})[_0x3abf('0x23')](handleEntityNotFound(_0x292e93,null))[_0x3abf('0x23')](function(_0x281b4d){if(_0x281b4d){_0x179d1b['body']['IntervalId']=_0x281b4d['id'];return db[_0x3abf('0x42')][_0x3abf('0x49')](_0x179d1b[_0x3abf('0x4a')]);}})[_0x3abf('0x23')](respondWithResult(_0x292e93,null))[_0x3abf('0x47')](handleError(_0x292e93,null));};exports[_0x3abf('0x55')]=function(_0x2a7269,_0x5806e2,_0x34e39b){var _0x63ca0a={};var _0x365a49={};var _0x5bb2a0;var _0x56da6b;return db[_0x3abf('0x42')][_0x3abf('0x56')]({'where':{'id':_0x2a7269[_0x3abf('0x48')]['id']}})['then'](handleEntityNotFound(_0x5806e2,null))[_0x3abf('0x23')](function(_0x13c4b1){if(_0x13c4b1){_0x5bb2a0=_0x13c4b1;_0x365a49[_0x3abf('0x30')]=_['keys'](db['Interval']['rawAttributes']);_0x365a49[_0x3abf('0x31')]=_['keys'](_0x2a7269[_0x3abf('0x31')]);_0x365a49['filters']=_[_0x3abf('0x35')](_0x365a49[_0x3abf('0x30')],_0x365a49[_0x3abf('0x31')]);_0x63ca0a[_0x3abf('0x34')]=_[_0x3abf('0x35')](_0x365a49[_0x3abf('0x30')],qs[_0x3abf('0x36')](_0x2a7269[_0x3abf('0x31')][_0x3abf('0x36')]));_0x63ca0a[_0x3abf('0x34')]=_0x63ca0a[_0x3abf('0x34')][_0x3abf('0x37')]?_0x63ca0a[_0x3abf('0x34')]:_0x365a49[_0x3abf('0x30')];_0x63ca0a['order']=qs['sort'](_0x2a7269[_0x3abf('0x31')][_0x3abf('0x3b')]);_0x63ca0a[_0x3abf('0x3c')]=qs[_0x3abf('0x33')](_[_0x3abf('0x3d')](_0x2a7269[_0x3abf('0x31')],_0x365a49['filters']));if(_0x2a7269['query'][_0x3abf('0x3e')]){_0x63ca0a[_0x3abf('0x3c')]=_['merge'](_0x63ca0a[_0x3abf('0x3c')],{'$or':_[_0x3abf('0x2b')](_0x63ca0a[_0x3abf('0x34')],function(_0x45e29d){var _0x51bc74={};_0x51bc74[_0x45e29d]={'$like':'%'+_0x2a7269['query'][_0x3abf('0x3e')]+'%'};return _0x51bc74;})});}_0x63ca0a=_['merge']({},_0x63ca0a,_0x2a7269[_0x3abf('0x41')]);return _0x5bb2a0[_0x3abf('0x55')](_0x63ca0a);}})[_0x3abf('0x23')](function(_0x3470f9){if(_0x3470f9){_0x56da6b=_0x3470f9[_0x3abf('0x37')];if(!_0x2a7269[_0x3abf('0x31')]['hasOwnProperty'](_0x3abf('0x39'))){_0x63ca0a[_0x3abf('0x1d')]=qs[_0x3abf('0x1d')](_0x2a7269[_0x3abf('0x31')]['limit']);_0x63ca0a[_0x3abf('0x1b')]=qs['offset'](_0x2a7269[_0x3abf('0x31')]['offset']);}return _0x5bb2a0[_0x3abf('0x55')](_0x63ca0a);}})[_0x3abf('0x23')](function(_0x35fa4c){if(_0x35fa4c){return _0x35fa4c?{'count':_0x56da6b,'rows':_0x35fa4c}:null;}})[_0x3abf('0x23')](respondWithResult(_0x5806e2,null))[_0x3abf('0x47')](handleError(_0x5806e2,null));};exports['addIntervals']=function(_0x1e7eab,_0x892947,_0x3392a9){return db[_0x3abf('0x42')][_0x3abf('0x56')]({'where':{'id':_0x1e7eab[_0x3abf('0x48')]['id']}})['then'](handleEntityNotFound(_0x892947,null))[_0x3abf('0x23')](function(_0x50372e){if(_0x50372e){return db[_0x3abf('0x57')][_0x3abf('0x58')](function(_0x4dc4b0){return db[_0x3abf('0x42')][_0x3abf('0x24')]({'where':{'IntervalId':_0x1e7eab[_0x3abf('0x48')]['id']},'transaction':_0x4dc4b0})[_0x3abf('0x23')](function(_0x3197a1){var _0x1f3724=_[_0x3abf('0x2b')](_0x1e7eab[_0x3abf('0x4a')],function(_0x5dc157){delete _0x5dc157['id'];_0x5dc157[_0x3abf('0x59')]=_0x1e7eab[_0x3abf('0x48')]['id'];return _0x5dc157;});return db[_0x3abf('0x42')][_0x3abf('0x5a')](_0x1f3724,{'transaction':_0x4dc4b0});});})[_0x3abf('0x23')](function(){return db['Interval'][_0x3abf('0x45')]({'where':{'IntervalId':_0x1e7eab[_0x3abf('0x48')]['id']}});});}})[_0x3abf('0x23')](respondWithResult(_0x892947,null))[_0x3abf('0x47')](handleError(_0x892947,null));};
\ No newline at end of file