Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / interval / interval.controller.js
index 82ab243..0bdce6f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf103=['transaction','bulkCreate','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','json','offset','limit','set','apply','update','then','destroy','Intervals','UserProfileResource','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','merge','VIRTUAL','filter','options','Interval','count','includeAll','include','findAll','rows','catch','show','params','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addInterval','IntervalId','findOne','getIntervals','addIntervals','sequelize'];(function(_0x2b31a8,_0x28b862){var _0x1175a5=function(_0x2cdb5d){while(--_0x2cdb5d){_0x2b31a8['push'](_0x2b31a8['shift']());}};_0x1175a5(++_0x28b862);}(_0xf103,0x1d8));var _0x3f10=function(_0x7fa69e,_0x33129f){_0x7fa69e=_0x7fa69e-0x0;var _0x5a7fb3=_0xf103[_0x7fa69e];return _0x5a7fb3;};'use strict';var pdf=require(_0x3f10('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x3f10('0x1'));var zipdir=require(_0x3f10('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x3f10('0x3'));var moment=require(_0x3f10('0x4'));var BPromise=require(_0x3f10('0x5'));var Mustache=require(_0x3f10('0x6'));var util=require(_0x3f10('0x7'));var path=require(_0x3f10('0x8'));var sox=require(_0x3f10('0x9'));var csv=require(_0x3f10('0xa'));var ejs=require(_0x3f10('0xb'));var fs=require('fs');var _=require(_0x3f10('0xc'));var squel=require(_0x3f10('0xd'));var crypto=require('crypto');var jsforce=require(_0x3f10('0xe'));var deskjs=require(_0x3f10('0xf'));var toCsv=require(_0x3f10('0xa'));var querystring=require(_0x3f10('0x10'));var Papa=require(_0x3f10('0x11'));var Redis=require(_0x3f10('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x3f10('0x13'));var as=require(_0x3f10('0x14'));var hardwareService=require(_0x3f10('0x15'));var logger=require(_0x3f10('0x16'))('api');var utils=require(_0x3f10('0x17'));var config=require(_0x3f10('0x18'));var licenseUtil=require(_0x3f10('0x19'));var db=require(_0x3f10('0x1a'))['db'];var extensions=require(_0x3f10('0x1b'));function respondWithStatusCode(_0x41ee83,_0x206478){_0x206478=_0x206478||0xcc;return function(_0x3aa227){if(_0x3aa227){return _0x41ee83[_0x3f10('0x1c')](_0x206478);}return _0x41ee83[_0x3f10('0x1d')](_0x206478)[_0x3f10('0x1e')]();};}function respondWithResult(_0x45b92d,_0x2e5bb3){_0x2e5bb3=_0x2e5bb3||0xc8;return function(_0x4ba605){if(_0x4ba605){return _0x45b92d[_0x3f10('0x1d')](_0x2e5bb3)[_0x3f10('0x1f')](_0x4ba605);}};}function respondWithFilteredResult(_0x5d3bb5,_0x2dc344){return function(_0x356b89){if(_0x356b89){var _0x4b1567=_0x356b89['count'],_0x48a406=_0x2dc344[_0x3f10('0x20')],_0x469ee5=_0x2dc344[_0x3f10('0x20')]+_0x2dc344[_0x3f10('0x21')],_0xcffedf;if(_0x469ee5>=_0x4b1567){_0x469ee5=_0x4b1567;_0xcffedf=0xc8;}else{_0xcffedf=0xce;}_0x5d3bb5[_0x3f10('0x1d')](_0xcffedf);return _0x5d3bb5[_0x3f10('0x22')]('Content-Range',_0x48a406+'-'+_0x469ee5+'/'+_0x4b1567)[_0x3f10('0x1f')](_0x356b89);}return null;};}function patchUpdates(_0x4d353a){return function(_0x1ed7ea){try{jsonpatch[_0x3f10('0x23')](_0x1ed7ea,_0x4d353a,!![]);}catch(_0x2440ed){return BPromise['reject'](_0x2440ed);}return _0x1ed7ea['save']();};}function saveUpdates(_0x22a09b,_0x512f8b){return function(_0x149415){if(_0x149415){return _0x149415[_0x3f10('0x24')](_0x22a09b)[_0x3f10('0x25')](function(_0x3de5f7){return _0x3de5f7;});}return null;};}function removeEntity(_0x865f1a,_0x20ea34){return function(_0x357846){if(_0x357846){return _0x357846[_0x3f10('0x26')]()[_0x3f10('0x25')](function(){var _0x56d406=_0x357846['get']({'plain':!![]});var _0x3019a3=_0x3f10('0x27');return db[_0x3f10('0x28')][_0x3f10('0x26')]({'where':{'type':_0x3019a3,'resourceId':_0x56d406['id']}})[_0x3f10('0x25')](function(){return _0x357846;});})[_0x3f10('0x25')](function(){_0x865f1a['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2e4f26,_0x26d546){return function(_0xbb800b){if(!_0xbb800b){_0x2e4f26[_0x3f10('0x1c')](0x194);}return _0xbb800b;};}function handleError(_0x13e3f0,_0x1b18ca){_0x1b18ca=_0x1b18ca||0x1f4;return function(_0x418531){logger[_0x3f10('0x29')](_0x418531[_0x3f10('0x2a')]);if(_0x418531[_0x3f10('0x2b')]){delete _0x418531[_0x3f10('0x2b')];}_0x13e3f0[_0x3f10('0x1d')](_0x1b18ca)[_0x3f10('0x2c')](_0x418531);};}exports['index']=function(_0x2ed369,_0xc81215){var _0xa2381d={},_0x190fe2={},_0x15cbd7={'count':0x0,'rows':[]};var _0x2f9e41=_[_0x3f10('0x2d')](db['Interval'][_0x3f10('0x2e')],function(_0x3f7f72){return{'name':_0x3f7f72[_0x3f10('0x2f')],'type':_0x3f7f72[_0x3f10('0x30')][_0x3f10('0x31')]};});_0x190fe2[_0x3f10('0x32')]=_[_0x3f10('0x2d')](_0x2f9e41,'name');_0x190fe2['query']=_[_0x3f10('0x33')](_0x2ed369[_0x3f10('0x34')]);_0x190fe2['filters']=_[_0x3f10('0x35')](_0x190fe2[_0x3f10('0x32')],_0x190fe2[_0x3f10('0x34')]);_0xa2381d[_0x3f10('0x36')]=_[_0x3f10('0x35')](_0x190fe2[_0x3f10('0x32')],qs[_0x3f10('0x37')](_0x2ed369[_0x3f10('0x34')][_0x3f10('0x37')]));_0xa2381d[_0x3f10('0x36')]=_0xa2381d[_0x3f10('0x36')][_0x3f10('0x38')]?_0xa2381d['attributes']:_0x190fe2['model'];if(!_0x2ed369['query'][_0x3f10('0x39')](_0x3f10('0x3a'))){_0xa2381d['limit']=qs[_0x3f10('0x21')](_0x2ed369[_0x3f10('0x34')]['limit']);_0xa2381d[_0x3f10('0x20')]=qs[_0x3f10('0x20')](_0x2ed369['query'][_0x3f10('0x20')]);}_0xa2381d[_0x3f10('0x3b')]=qs['sort'](_0x2ed369[_0x3f10('0x34')][_0x3f10('0x3c')]);_0xa2381d[_0x3f10('0x3d')]=qs[_0x3f10('0x3e')](_[_0x3f10('0x3f')](_0x2ed369[_0x3f10('0x34')],_0x190fe2[_0x3f10('0x3e')]),_0x2f9e41);if(_0x2ed369['query']['filter']){_0xa2381d[_0x3f10('0x3d')]=_[_0x3f10('0x40')](_0xa2381d[_0x3f10('0x3d')],{'$or':_[_0x3f10('0x2d')](_0x2f9e41,function(_0x445b55){if(_0x445b55[_0x3f10('0x30')]!==_0x3f10('0x41')){var _0x56731b={};_0x56731b[_0x445b55['name']]={'$like':'%'+_0x2ed369[_0x3f10('0x34')][_0x3f10('0x42')]+'%'};return _0x56731b;}})});}_0xa2381d=_['merge']({},_0xa2381d,_0x2ed369[_0x3f10('0x43')]);var _0x5f4a91={'where':_0xa2381d['where']};return db[_0x3f10('0x44')][_0x3f10('0x45')](_0x5f4a91)[_0x3f10('0x25')](function(_0x1128ee){_0x15cbd7['count']=_0x1128ee;if(_0x2ed369[_0x3f10('0x34')][_0x3f10('0x46')]){_0xa2381d[_0x3f10('0x47')]=[{'all':!![]}];}return db[_0x3f10('0x44')][_0x3f10('0x48')](_0xa2381d);})[_0x3f10('0x25')](function(_0x4fb513){_0x15cbd7[_0x3f10('0x49')]=_0x4fb513;return _0x15cbd7;})[_0x3f10('0x25')](respondWithFilteredResult(_0xc81215,_0xa2381d))[_0x3f10('0x4a')](handleError(_0xc81215,null));};exports[_0x3f10('0x4b')]=function(_0x3efa3f,_0x4743b8){var _0xcf2b4b={'raw':!![],'where':{'id':_0x3efa3f[_0x3f10('0x4c')]['id']}},_0x246363={};_0x246363[_0x3f10('0x32')]=_[_0x3f10('0x33')](db['Interval']['rawAttributes']);_0x246363[_0x3f10('0x34')]=_['keys'](_0x3efa3f['query']);_0x246363[_0x3f10('0x3e')]=_[_0x3f10('0x35')](_0x246363[_0x3f10('0x32')],_0x246363[_0x3f10('0x34')]);_0xcf2b4b[_0x3f10('0x36')]=_[_0x3f10('0x35')](_0x246363[_0x3f10('0x32')],qs['fields'](_0x3efa3f[_0x3f10('0x34')][_0x3f10('0x37')]));_0xcf2b4b[_0x3f10('0x36')]=_0xcf2b4b[_0x3f10('0x36')][_0x3f10('0x38')]?_0xcf2b4b['attributes']:_0x246363[_0x3f10('0x32')];if(_0x3efa3f[_0x3f10('0x34')][_0x3f10('0x46')]){_0xcf2b4b[_0x3f10('0x47')]=[{'all':!![]}];}_0xcf2b4b=_[_0x3f10('0x40')]({},_0xcf2b4b,_0x3efa3f[_0x3f10('0x43')]);return db[_0x3f10('0x44')][_0x3f10('0x4d')](_0xcf2b4b)[_0x3f10('0x25')](handleEntityNotFound(_0x4743b8,null))[_0x3f10('0x25')](respondWithResult(_0x4743b8,null))[_0x3f10('0x4a')](handleError(_0x4743b8,null));};exports[_0x3f10('0x4e')]=function(_0x34fc51,_0x6dc87d){return db[_0x3f10('0x44')]['create'](_0x34fc51[_0x3f10('0x4f')],{})[_0x3f10('0x25')](function(_0x12f1cb){var _0xccc35a=_0x34fc51[_0x3f10('0x50')][_0x3f10('0x51')]({'plain':!![]});if(!_0xccc35a)throw new Error(_0x3f10('0x52'));if(_0xccc35a['role']===_0x3f10('0x50')){var _0x2e2af9=_0x12f1cb['get']({'plain':!![]});var _0x235913=_0x3f10('0x27');return db[_0x3f10('0x53')][_0x3f10('0x4d')]({'where':{'name':_0x235913,'userProfileId':_0xccc35a['userProfileId']},'raw':!![]})['then'](function(_0x3f649e){if(_0x3f649e&&_0x3f649e[_0x3f10('0x54')]===0x0){return db[_0x3f10('0x28')][_0x3f10('0x4e')]({'name':_0x2e2af9['name'],'resourceId':_0x2e2af9['id'],'type':_0x3f649e['name'],'sectionId':_0x3f649e['id']},{})[_0x3f10('0x25')](function(){return _0x12f1cb;});}else{return _0x12f1cb;}})[_0x3f10('0x4a')](function(_0x54810f){logger[_0x3f10('0x29')](_0x3f10('0x55'),_0x54810f);throw _0x54810f;});}return _0x12f1cb;})[_0x3f10('0x25')](respondWithResult(_0x6dc87d,0xc9))['catch'](handleError(_0x6dc87d,null));};exports[_0x3f10('0x24')]=function(_0x4517ff,_0x2e1f9d){if(_0x4517ff[_0x3f10('0x4f')]['id']){delete _0x4517ff[_0x3f10('0x4f')]['id'];}return db[_0x3f10('0x44')][_0x3f10('0x4d')]({'where':{'id':_0x4517ff[_0x3f10('0x4c')]['id']}})[_0x3f10('0x25')](handleEntityNotFound(_0x2e1f9d,null))[_0x3f10('0x25')](saveUpdates(_0x4517ff[_0x3f10('0x4f')],null))[_0x3f10('0x25')](respondWithResult(_0x2e1f9d,null))[_0x3f10('0x4a')](handleError(_0x2e1f9d,null));};exports[_0x3f10('0x26')]=function(_0x7e1968,_0x1e4509){return db[_0x3f10('0x44')][_0x3f10('0x4d')]({'where':{'id':_0x7e1968['params']['id']}})['then'](handleEntityNotFound(_0x1e4509,null))[_0x3f10('0x25')](removeEntity(_0x1e4509,null))['catch'](handleError(_0x1e4509,null));};exports[_0x3f10('0x56')]=function(_0x1cc0eb,_0x24bc75,_0x3ccf2f){if(_0x1cc0eb[_0x3f10('0x4f')]['id']){delete _0x1cc0eb[_0x3f10('0x4f')]['id'];}return db[_0x3f10('0x44')][_0x3f10('0x4d')]({'where':{'id':_0x1cc0eb['params']['id']}})[_0x3f10('0x25')](handleEntityNotFound(_0x24bc75,null))[_0x3f10('0x25')](function(_0x5322a7){if(_0x5322a7){_0x1cc0eb['body'][_0x3f10('0x57')]=_0x5322a7['id'];return db[_0x3f10('0x44')]['create'](_0x1cc0eb[_0x3f10('0x4f')]);}})['then'](respondWithResult(_0x24bc75,null))[_0x3f10('0x4a')](handleError(_0x24bc75,null));};exports['getIntervals']=function(_0x497ea9,_0x129784,_0x427040){var _0x12b8f2={};var _0x276aae={};var _0x23fe44;var _0x1a11d6;return db[_0x3f10('0x44')][_0x3f10('0x58')]({'where':{'id':_0x497ea9[_0x3f10('0x4c')]['id']}})[_0x3f10('0x25')](handleEntityNotFound(_0x129784,null))['then'](function(_0x27859b){if(_0x27859b){_0x23fe44=_0x27859b;_0x276aae[_0x3f10('0x32')]=_[_0x3f10('0x33')](db[_0x3f10('0x44')]['rawAttributes']);_0x276aae[_0x3f10('0x34')]=_[_0x3f10('0x33')](_0x497ea9[_0x3f10('0x34')]);_0x276aae[_0x3f10('0x3e')]=_['intersection'](_0x276aae[_0x3f10('0x32')],_0x276aae[_0x3f10('0x34')]);_0x12b8f2[_0x3f10('0x36')]=_['intersection'](_0x276aae[_0x3f10('0x32')],qs[_0x3f10('0x37')](_0x497ea9['query'][_0x3f10('0x37')]));_0x12b8f2[_0x3f10('0x36')]=_0x12b8f2['attributes']['length']?_0x12b8f2['attributes']:_0x276aae['model'];_0x12b8f2[_0x3f10('0x3b')]=qs[_0x3f10('0x3c')](_0x497ea9[_0x3f10('0x34')][_0x3f10('0x3c')]);_0x12b8f2[_0x3f10('0x3d')]=qs[_0x3f10('0x3e')](_[_0x3f10('0x3f')](_0x497ea9[_0x3f10('0x34')],_0x276aae[_0x3f10('0x3e')]));if(_0x497ea9['query']['filter']){_0x12b8f2['where']=_[_0x3f10('0x40')](_0x12b8f2[_0x3f10('0x3d')],{'$or':_[_0x3f10('0x2d')](_0x12b8f2[_0x3f10('0x36')],function(_0xe646a){var _0x535166={};_0x535166[_0xe646a]={'$like':'%'+_0x497ea9[_0x3f10('0x34')][_0x3f10('0x42')]+'%'};return _0x535166;})});}_0x12b8f2=_['merge']({},_0x12b8f2,_0x497ea9[_0x3f10('0x43')]);return _0x23fe44[_0x3f10('0x59')](_0x12b8f2);}})[_0x3f10('0x25')](function(_0x1837ea){if(_0x1837ea){_0x1a11d6=_0x1837ea[_0x3f10('0x38')];if(!_0x497ea9[_0x3f10('0x34')][_0x3f10('0x39')](_0x3f10('0x3a'))){_0x12b8f2[_0x3f10('0x21')]=qs['limit'](_0x497ea9['query'][_0x3f10('0x21')]);_0x12b8f2['offset']=qs['offset'](_0x497ea9[_0x3f10('0x34')]['offset']);}return _0x23fe44[_0x3f10('0x59')](_0x12b8f2);}})['then'](function(_0x5c1199){if(_0x5c1199){return _0x5c1199?{'count':_0x1a11d6,'rows':_0x5c1199}:null;}})[_0x3f10('0x25')](respondWithResult(_0x129784,null))[_0x3f10('0x4a')](handleError(_0x129784,null));};exports[_0x3f10('0x5a')]=function(_0x3d1bd6,_0xffb68e,_0x52099c){return db['Interval'][_0x3f10('0x58')]({'where':{'id':_0x3d1bd6[_0x3f10('0x4c')]['id']}})[_0x3f10('0x25')](handleEntityNotFound(_0xffb68e,null))['then'](function(_0x21e4f1){if(_0x21e4f1){return db[_0x3f10('0x5b')][_0x3f10('0x5c')](function(_0x2acafd){return db['Interval'][_0x3f10('0x26')]({'where':{'IntervalId':_0x3d1bd6[_0x3f10('0x4c')]['id']},'transaction':_0x2acafd})[_0x3f10('0x25')](function(_0x4539f2){var _0x9c464e=_[_0x3f10('0x2d')](_0x3d1bd6['body'],function(_0x175796){delete _0x175796['id'];_0x175796[_0x3f10('0x57')]=_0x3d1bd6['params']['id'];return _0x175796;});return db[_0x3f10('0x44')][_0x3f10('0x5d')](_0x9c464e,{'transaction':_0x2acafd});});})[_0x3f10('0x25')](function(){return db['Interval'][_0x3f10('0x48')]({'where':{'IntervalId':_0x3d1bd6['params']['id']}});});}})[_0x3f10('0x25')](respondWithResult(_0xffb68e,null))['catch'](handleError(_0xffb68e,null));};
\ No newline at end of file
+var _0xa8c2=['path','sox','to-csv','ejs','lodash','squel','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','save','then','destroy','get','Intervals','error','stack','name','send','index','map','Interval','fieldName','type','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','rows','rawAttributes','find','catch','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileResource','update','body','params','addInterval','getIntervals','findOne','sequelize','transaction','IntervalId','bulkCreate','findAll','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util'];(function(_0x5a36e1,_0x3f552b){var _0x284436=function(_0x5b56b4){while(--_0x5b56b4){_0x5a36e1['push'](_0x5a36e1['shift']());}};_0x284436(++_0x3f552b);}(_0xa8c2,0xff));var _0x2a8c=function(_0x463a03,_0x13914f){_0x463a03=_0x463a03-0x0;var _0x5baa30=_0xa8c2[_0x463a03];return _0x5baa30;};'use strict';var emlformat=require(_0x2a8c('0x0'));var rimraf=require(_0x2a8c('0x1'));var zipdir=require(_0x2a8c('0x2'));var jsonpatch=require(_0x2a8c('0x3'));var rp=require(_0x2a8c('0x4'));var moment=require(_0x2a8c('0x5'));var BPromise=require(_0x2a8c('0x6'));var Mustache=require(_0x2a8c('0x7'));var util=require(_0x2a8c('0x8'));var path=require(_0x2a8c('0x9'));var sox=require(_0x2a8c('0xa'));var csv=require(_0x2a8c('0xb'));var ejs=require(_0x2a8c('0xc'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x2a8c('0xd'));var squel=require(_0x2a8c('0xe'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x2a8c('0xf'));var Redis=require(_0x2a8c('0x10'));var authService=require(_0x2a8c('0x11'));var qs=require(_0x2a8c('0x12'));var as=require(_0x2a8c('0x13'));var hardwareService=require(_0x2a8c('0x14'));var logger=require(_0x2a8c('0x15'))('api');var utils=require(_0x2a8c('0x16'));var config=require(_0x2a8c('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x41a415,_0x3faaaf){_0x3faaaf=_0x3faaaf||0xcc;return function(_0xfe5d42){if(_0xfe5d42){return _0x41a415[_0x2a8c('0x18')](_0x3faaaf);}return _0x41a415[_0x2a8c('0x19')](_0x3faaaf)[_0x2a8c('0x1a')]();};}function respondWithResult(_0x485299,_0x5ef278){_0x5ef278=_0x5ef278||0xc8;return function(_0xcf7ba4){if(_0xcf7ba4){return _0x485299[_0x2a8c('0x19')](_0x5ef278)[_0x2a8c('0x1b')](_0xcf7ba4);}};}function respondWithFilteredResult(_0x373360,_0x5019a2){return function(_0x3e9e40){if(_0x3e9e40){var _0x385531=typeof _0x5019a2[_0x2a8c('0x1c')]===_0x2a8c('0x1d')&&typeof _0x5019a2['limit']==='undefined';var _0x1d7c2c=_0x3e9e40[_0x2a8c('0x1e')];var _0x5b49d3=_0x385531?0x0:_0x5019a2[_0x2a8c('0x1c')];var _0x2adbaf=_0x385531?_0x3e9e40[_0x2a8c('0x1e')]:_0x5019a2['offset']+_0x5019a2[_0x2a8c('0x1f')];var _0x3ad641;if(_0x2adbaf>=_0x1d7c2c){_0x2adbaf=_0x1d7c2c;_0x3ad641=0xc8;}else{_0x3ad641=0xce;}_0x373360[_0x2a8c('0x19')](_0x3ad641);return _0x373360[_0x2a8c('0x20')](_0x2a8c('0x21'),_0x5b49d3+'-'+_0x2adbaf+'/'+_0x1d7c2c)[_0x2a8c('0x1b')](_0x3e9e40);}return null;};}function patchUpdates(_0x4c5c96){return function(_0x386457){try{jsonpatch[_0x2a8c('0x22')](_0x386457,_0x4c5c96,!![]);}catch(_0x53261d){return BPromise['reject'](_0x53261d);}return _0x386457[_0x2a8c('0x23')]();};}function saveUpdates(_0x349501,_0x5ac2ff){return function(_0x346251){if(_0x346251){return _0x346251['update'](_0x349501)[_0x2a8c('0x24')](function(_0x1ee313){return _0x1ee313;});}return null;};}function removeEntity(_0x4f59c4,_0x453ecb){return function(_0x2c9b1a){if(_0x2c9b1a){return _0x2c9b1a[_0x2a8c('0x25')]()[_0x2a8c('0x24')](function(){var _0x1d4fb2=_0x2c9b1a[_0x2a8c('0x26')]({'plain':!![]});var _0x4136de=_0x2a8c('0x27');return db['UserProfileResource'][_0x2a8c('0x25')]({'where':{'type':_0x4136de,'resourceId':_0x1d4fb2['id']}})[_0x2a8c('0x24')](function(){return _0x2c9b1a;});})[_0x2a8c('0x24')](function(){_0x4f59c4['status'](0xcc)[_0x2a8c('0x1a')]();});}};}function handleEntityNotFound(_0x352560,_0x548aeb){return function(_0x257206){if(!_0x257206){_0x352560[_0x2a8c('0x18')](0x194);}return _0x257206;};}function handleError(_0xe24de7,_0x23f087){_0x23f087=_0x23f087||0x1f4;return function(_0x4cd18f){logger[_0x2a8c('0x28')](_0x4cd18f[_0x2a8c('0x29')]);if(_0x4cd18f[_0x2a8c('0x2a')]){delete _0x4cd18f[_0x2a8c('0x2a')];}_0xe24de7['status'](_0x23f087)[_0x2a8c('0x2b')](_0x4cd18f);};}exports[_0x2a8c('0x2c')]=function(_0x32630d,_0x2b46ce){var _0x24a843={},_0x27bc62={},_0x5a99b4={'count':0x0,'rows':[]};var _0x3d9cfc=_[_0x2a8c('0x2d')](db[_0x2a8c('0x2e')]['rawAttributes'],function(_0x4acf21){return{'name':_0x4acf21[_0x2a8c('0x2f')],'type':_0x4acf21[_0x2a8c('0x30')]['key']};});_0x27bc62[_0x2a8c('0x31')]=_[_0x2a8c('0x2d')](_0x3d9cfc,_0x2a8c('0x2a'));_0x27bc62['query']=_[_0x2a8c('0x32')](_0x32630d[_0x2a8c('0x33')]);_0x27bc62[_0x2a8c('0x34')]=_['intersection'](_0x27bc62[_0x2a8c('0x31')],_0x27bc62[_0x2a8c('0x33')]);_0x24a843[_0x2a8c('0x35')]=_[_0x2a8c('0x36')](_0x27bc62[_0x2a8c('0x31')],qs['fields'](_0x32630d[_0x2a8c('0x33')][_0x2a8c('0x37')]));_0x24a843[_0x2a8c('0x35')]=_0x24a843[_0x2a8c('0x35')][_0x2a8c('0x38')]?_0x24a843[_0x2a8c('0x35')]:_0x27bc62['model'];if(!_0x32630d['query'][_0x2a8c('0x39')](_0x2a8c('0x3a'))){_0x24a843[_0x2a8c('0x1f')]=qs['limit'](_0x32630d[_0x2a8c('0x33')]['limit']);_0x24a843['offset']=qs[_0x2a8c('0x1c')](_0x32630d[_0x2a8c('0x33')][_0x2a8c('0x1c')]);}_0x24a843[_0x2a8c('0x3b')]=qs['sort'](_0x32630d[_0x2a8c('0x33')][_0x2a8c('0x3c')]);_0x24a843[_0x2a8c('0x3d')]=qs['filters'](_[_0x2a8c('0x3e')](_0x32630d[_0x2a8c('0x33')],_0x27bc62['filters']),_0x3d9cfc);if(_0x32630d[_0x2a8c('0x33')][_0x2a8c('0x3f')]){_0x24a843[_0x2a8c('0x3d')]=_[_0x2a8c('0x40')](_0x24a843[_0x2a8c('0x3d')],{'$or':_[_0x2a8c('0x2d')](_0x3d9cfc,function(_0x41a513){if(_0x41a513[_0x2a8c('0x30')]!==_0x2a8c('0x41')){var _0x9191ca={};_0x9191ca[_0x41a513[_0x2a8c('0x2a')]]={'$like':'%'+_0x32630d['query'][_0x2a8c('0x3f')]+'%'};return _0x9191ca;}})});}_0x24a843=_['merge']({},_0x24a843,_0x32630d[_0x2a8c('0x42')]);var _0x359770={'where':_0x24a843[_0x2a8c('0x3d')]};return db[_0x2a8c('0x2e')]['count'](_0x359770)[_0x2a8c('0x24')](function(_0x212e68){_0x5a99b4[_0x2a8c('0x1e')]=_0x212e68;if(_0x32630d[_0x2a8c('0x33')][_0x2a8c('0x43')]){_0x24a843[_0x2a8c('0x44')]=[{'all':!![]}];}return db['Interval']['findAll'](_0x24a843);})[_0x2a8c('0x24')](function(_0x3e77db){_0x5a99b4[_0x2a8c('0x45')]=_0x3e77db;return _0x5a99b4;})[_0x2a8c('0x24')](respondWithFilteredResult(_0x2b46ce,_0x24a843))['catch'](handleError(_0x2b46ce,null));};exports['show']=function(_0x17bbe8,_0x1d3d9e){var _0xdc5639={'raw':!![],'where':{'id':_0x17bbe8['params']['id']}},_0x48e16c={};_0x48e16c[_0x2a8c('0x31')]=_[_0x2a8c('0x32')](db[_0x2a8c('0x2e')][_0x2a8c('0x46')]);_0x48e16c[_0x2a8c('0x33')]=_[_0x2a8c('0x32')](_0x17bbe8[_0x2a8c('0x33')]);_0x48e16c[_0x2a8c('0x34')]=_[_0x2a8c('0x36')](_0x48e16c['model'],_0x48e16c['query']);_0xdc5639[_0x2a8c('0x35')]=_['intersection'](_0x48e16c[_0x2a8c('0x31')],qs[_0x2a8c('0x37')](_0x17bbe8[_0x2a8c('0x33')][_0x2a8c('0x37')]));_0xdc5639[_0x2a8c('0x35')]=_0xdc5639['attributes']['length']?_0xdc5639[_0x2a8c('0x35')]:_0x48e16c[_0x2a8c('0x31')];if(_0x17bbe8[_0x2a8c('0x33')][_0x2a8c('0x43')]){_0xdc5639[_0x2a8c('0x44')]=[{'all':!![]}];}_0xdc5639=_[_0x2a8c('0x40')]({},_0xdc5639,_0x17bbe8[_0x2a8c('0x42')]);return db[_0x2a8c('0x2e')][_0x2a8c('0x47')](_0xdc5639)[_0x2a8c('0x24')](handleEntityNotFound(_0x1d3d9e,null))[_0x2a8c('0x24')](respondWithResult(_0x1d3d9e,null))[_0x2a8c('0x48')](handleError(_0x1d3d9e,null));};exports[_0x2a8c('0x49')]=function(_0x42d782,_0x1e74d6){return db[_0x2a8c('0x2e')][_0x2a8c('0x49')](_0x42d782['body'],{})['then'](function(_0xfee574){var _0x507bef=_0x42d782[_0x2a8c('0x4a')][_0x2a8c('0x26')]({'plain':!![]});if(!_0x507bef)throw new Error(_0x2a8c('0x4b'));if(_0x507bef['role']==='user'){var _0x5f1e1a=_0xfee574[_0x2a8c('0x26')]({'plain':!![]});var _0x5b6e88=_0x2a8c('0x27');return db['UserProfileSection'][_0x2a8c('0x47')]({'where':{'name':_0x5b6e88,'userProfileId':_0x507bef['userProfileId']},'raw':!![]})[_0x2a8c('0x24')](function(_0x49ccdb){if(_0x49ccdb&&_0x49ccdb['autoAssociation']===0x0){return db[_0x2a8c('0x4c')]['create']({'name':_0x5f1e1a['name'],'resourceId':_0x5f1e1a['id'],'type':_0x49ccdb['name'],'sectionId':_0x49ccdb['id']},{})['then'](function(){return _0xfee574;});}else{return _0xfee574;}})[_0x2a8c('0x48')](function(_0x1f0cfc){logger[_0x2a8c('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1f0cfc);throw _0x1f0cfc;});}return _0xfee574;})['then'](respondWithResult(_0x1e74d6,0xc9))[_0x2a8c('0x48')](handleError(_0x1e74d6,null));};exports[_0x2a8c('0x4d')]=function(_0x44aba5,_0x23d096){if(_0x44aba5[_0x2a8c('0x4e')]['id']){delete _0x44aba5['body']['id'];}return db[_0x2a8c('0x2e')][_0x2a8c('0x47')]({'where':{'id':_0x44aba5[_0x2a8c('0x4f')]['id']}})[_0x2a8c('0x24')](handleEntityNotFound(_0x23d096,null))[_0x2a8c('0x24')](saveUpdates(_0x44aba5[_0x2a8c('0x4e')],null))[_0x2a8c('0x24')](respondWithResult(_0x23d096,null))['catch'](handleError(_0x23d096,null));};exports[_0x2a8c('0x25')]=function(_0x31808d,_0x3e90bc){return db[_0x2a8c('0x2e')][_0x2a8c('0x47')]({'where':{'id':_0x31808d[_0x2a8c('0x4f')]['id']}})['then'](handleEntityNotFound(_0x3e90bc,null))['then'](removeEntity(_0x3e90bc,null))['catch'](handleError(_0x3e90bc,null));};exports[_0x2a8c('0x50')]=function(_0x485159,_0x57f702,_0x23b07a){if(_0x485159[_0x2a8c('0x4e')]['id']){delete _0x485159[_0x2a8c('0x4e')]['id'];}return db['Interval']['find']({'where':{'id':_0x485159['params']['id']}})[_0x2a8c('0x24')](handleEntityNotFound(_0x57f702,null))[_0x2a8c('0x24')](function(_0x299b7f){if(_0x299b7f){_0x485159['body']['IntervalId']=_0x299b7f['id'];return db[_0x2a8c('0x2e')]['create'](_0x485159[_0x2a8c('0x4e')]);}})[_0x2a8c('0x24')](respondWithResult(_0x57f702,null))[_0x2a8c('0x48')](handleError(_0x57f702,null));};exports[_0x2a8c('0x51')]=function(_0x5a33db,_0x6636ea,_0xfda042){var _0x2df024={};var _0x490a57={};var _0x32019c;var _0x4f0f87;return db[_0x2a8c('0x2e')][_0x2a8c('0x52')]({'where':{'id':_0x5a33db[_0x2a8c('0x4f')]['id']}})['then'](handleEntityNotFound(_0x6636ea,null))[_0x2a8c('0x24')](function(_0x17839d){if(_0x17839d){_0x32019c=_0x17839d;_0x490a57[_0x2a8c('0x31')]=_[_0x2a8c('0x32')](db[_0x2a8c('0x2e')][_0x2a8c('0x46')]);_0x490a57['query']=_['keys'](_0x5a33db[_0x2a8c('0x33')]);_0x490a57['filters']=_['intersection'](_0x490a57[_0x2a8c('0x31')],_0x490a57[_0x2a8c('0x33')]);_0x2df024[_0x2a8c('0x35')]=_[_0x2a8c('0x36')](_0x490a57['model'],qs[_0x2a8c('0x37')](_0x5a33db[_0x2a8c('0x33')][_0x2a8c('0x37')]));_0x2df024[_0x2a8c('0x35')]=_0x2df024[_0x2a8c('0x35')][_0x2a8c('0x38')]?_0x2df024[_0x2a8c('0x35')]:_0x490a57[_0x2a8c('0x31')];_0x2df024[_0x2a8c('0x3b')]=qs[_0x2a8c('0x3c')](_0x5a33db[_0x2a8c('0x33')][_0x2a8c('0x3c')]);_0x2df024[_0x2a8c('0x3d')]=qs['filters'](_['pick'](_0x5a33db[_0x2a8c('0x33')],_0x490a57[_0x2a8c('0x34')]));if(_0x5a33db['query'][_0x2a8c('0x3f')]){_0x2df024['where']=_[_0x2a8c('0x40')](_0x2df024[_0x2a8c('0x3d')],{'$or':_[_0x2a8c('0x2d')](_0x2df024[_0x2a8c('0x35')],function(_0xd6e6bf){var _0x2e6347={};_0x2e6347[_0xd6e6bf]={'$like':'%'+_0x5a33db['query'][_0x2a8c('0x3f')]+'%'};return _0x2e6347;})});}_0x2df024=_['merge']({},_0x2df024,_0x5a33db[_0x2a8c('0x42')]);return _0x32019c[_0x2a8c('0x51')](_0x2df024);}})['then'](function(_0xc06154){if(_0xc06154){_0x4f0f87=_0xc06154['length'];if(!_0x5a33db['query']['hasOwnProperty'](_0x2a8c('0x3a'))){_0x2df024[_0x2a8c('0x1f')]=qs[_0x2a8c('0x1f')](_0x5a33db['query']['limit']);_0x2df024['offset']=qs[_0x2a8c('0x1c')](_0x5a33db[_0x2a8c('0x33')][_0x2a8c('0x1c')]);}return _0x32019c['getIntervals'](_0x2df024);}})[_0x2a8c('0x24')](function(_0x3ef560){if(_0x3ef560){return _0x3ef560?{'count':_0x4f0f87,'rows':_0x3ef560}:null;}})[_0x2a8c('0x24')](respondWithResult(_0x6636ea,null))[_0x2a8c('0x48')](handleError(_0x6636ea,null));};exports['addIntervals']=function(_0x4f879f,_0x16a5a5,_0x2d773b){return db[_0x2a8c('0x2e')][_0x2a8c('0x52')]({'where':{'id':_0x4f879f['params']['id']}})[_0x2a8c('0x24')](handleEntityNotFound(_0x16a5a5,null))['then'](function(_0x7c2502){if(_0x7c2502){return db[_0x2a8c('0x53')][_0x2a8c('0x54')](function(_0x3b8320){return db['Interval']['destroy']({'where':{'IntervalId':_0x4f879f['params']['id']},'transaction':_0x3b8320})['then'](function(_0x58c305){var _0x29ae77=_[_0x2a8c('0x2d')](_0x4f879f[_0x2a8c('0x4e')],function(_0x206a00){delete _0x206a00['id'];_0x206a00[_0x2a8c('0x55')]=_0x4f879f[_0x2a8c('0x4f')]['id'];return _0x206a00;});return db['Interval'][_0x2a8c('0x56')](_0x29ae77,{'transaction':_0x3b8320});});})['then'](function(){return db[_0x2a8c('0x2e')][_0x2a8c('0x57')]({'where':{'IntervalId':_0x4f879f[_0x2a8c('0x4f')]['id']}});});}})[_0x2a8c('0x24')](respondWithResult(_0x16a5a5,null))[_0x2a8c('0x48')](handleError(_0x16a5a5,null));};
\ No newline at end of file