Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / interval / interval.controller.js
index 5363c19..8c2744c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xeab7=['api','../../config/environment','../../config/license/util','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','json','offset','limit','count','set','reject','save','update','then','get','destroy','error','name','send','index','map','Interval','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','pick','merge','filter','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','IntervalId','getIntervals','findOne','nolimit','addIntervals','sequelize','transaction','bulkCreate','eml-format','request-promise','moment','mustache','sox','to-csv','ejs','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger'];(function(_0x2f3947,_0x2ee083){var _0x3e6ab7=function(_0x4057c0){while(--_0x4057c0){_0x2f3947['push'](_0x2f3947['shift']());}};_0x3e6ab7(++_0x2ee083);}(_0xeab7,0x99));var _0x7eab=function(_0x3cb2bb,_0x13c4bb){_0x3cb2bb=_0x3cb2bb-0x0;var _0x4165bc=_0xeab7[_0x3cb2bb];return _0x4165bc;};'use strict';var emlformat=require(_0x7eab('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x7eab('0x1'));var moment=require(_0x7eab('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x7eab('0x3'));var util=require('util');var path=require('path');var sox=require(_0x7eab('0x4'));var csv=require(_0x7eab('0x5'));var ejs=require(_0x7eab('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x7eab('0x7'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x7eab('0x8'));var toCsv=require(_0x7eab('0x5'));var querystring=require(_0x7eab('0x9'));var Papa=require(_0x7eab('0xa'));var Redis=require(_0x7eab('0xb'));var authService=require(_0x7eab('0xc'));var qs=require(_0x7eab('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x7eab('0xe'))(_0x7eab('0xf'));var utils=require('../../config/utils');var config=require(_0x7eab('0x10'));var licenseUtil=require(_0x7eab('0x11'));var db=require(_0x7eab('0x12'))['db'];var extensions=require(_0x7eab('0x13'));function respondWithStatusCode(_0x56940f,_0x46c19a){_0x46c19a=_0x46c19a||0xcc;return function(_0x2dfd7d){if(_0x2dfd7d){return _0x56940f[_0x7eab('0x14')](_0x46c19a);}return _0x56940f[_0x7eab('0x15')](_0x46c19a)[_0x7eab('0x16')]();};}function respondWithResult(_0x2e724d,_0x2dc32a){_0x2dc32a=_0x2dc32a||0xc8;return function(_0x36640a){if(_0x36640a){return _0x2e724d[_0x7eab('0x15')](_0x2dc32a)[_0x7eab('0x17')](_0x36640a);}};}function respondWithFilteredResult(_0x43c621,_0x417ef8){return function(_0x5ed450){if(_0x5ed450){var _0xefdf34=typeof _0x417ef8[_0x7eab('0x18')]==='undefined'&&typeof _0x417ef8[_0x7eab('0x19')]==='undefined';var _0x6c1d63=_0x5ed450[_0x7eab('0x1a')];var _0x404f54=_0xefdf34?0x0:_0x417ef8[_0x7eab('0x18')];var _0x3429ae=_0xefdf34?_0x5ed450[_0x7eab('0x1a')]:_0x417ef8[_0x7eab('0x18')]+_0x417ef8[_0x7eab('0x19')];var _0x379d1b;if(_0x3429ae>=_0x6c1d63){_0x3429ae=_0x6c1d63;_0x379d1b=0xc8;}else{_0x379d1b=0xce;}_0x43c621['status'](_0x379d1b);return _0x43c621[_0x7eab('0x1b')]('Content-Range',_0x404f54+'-'+_0x3429ae+'/'+_0x6c1d63)[_0x7eab('0x17')](_0x5ed450);}return null;};}function patchUpdates(_0x3bc9b2){return function(_0x4628c4){try{jsonpatch['apply'](_0x4628c4,_0x3bc9b2,!![]);}catch(_0x5000e0){return BPromise[_0x7eab('0x1c')](_0x5000e0);}return _0x4628c4[_0x7eab('0x1d')]();};}function saveUpdates(_0x5e9726,_0x233af9){return function(_0x1ce4b6){if(_0x1ce4b6){return _0x1ce4b6[_0x7eab('0x1e')](_0x5e9726)['then'](function(_0x3c8cae){return _0x3c8cae;});}return null;};}function removeEntity(_0x478726,_0x8c47d2){return function(_0xfffc23){if(_0xfffc23){return _0xfffc23['destroy']()[_0x7eab('0x1f')](function(){var _0x558914=_0xfffc23[_0x7eab('0x20')]({'plain':!![]});var _0x502296='Intervals';return db['UserProfileResource'][_0x7eab('0x21')]({'where':{'type':_0x502296,'resourceId':_0x558914['id']}})[_0x7eab('0x1f')](function(){return _0xfffc23;});})[_0x7eab('0x1f')](function(){_0x478726[_0x7eab('0x15')](0xcc)[_0x7eab('0x16')]();});}};}function handleEntityNotFound(_0x33d010,_0x258c1f){return function(_0x482a88){if(!_0x482a88){_0x33d010[_0x7eab('0x14')](0x194);}return _0x482a88;};}function handleError(_0x22ce2d,_0x462f2){_0x462f2=_0x462f2||0x1f4;return function(_0x3e7d3c){logger[_0x7eab('0x22')](_0x3e7d3c['stack']);if(_0x3e7d3c['name']){delete _0x3e7d3c[_0x7eab('0x23')];}_0x22ce2d[_0x7eab('0x15')](_0x462f2)[_0x7eab('0x24')](_0x3e7d3c);};}exports[_0x7eab('0x25')]=function(_0x1bfc5e,_0x3caf62){var _0x411f48={},_0xf1de02={},_0x54f264={'count':0x0,'rows':[]};var _0x21741c=_[_0x7eab('0x26')](db[_0x7eab('0x27')][_0x7eab('0x28')],function(_0x433472){return{'name':_0x433472[_0x7eab('0x29')],'type':_0x433472[_0x7eab('0x2a')][_0x7eab('0x2b')]};});_0xf1de02[_0x7eab('0x2c')]=_[_0x7eab('0x26')](_0x21741c,_0x7eab('0x23'));_0xf1de02[_0x7eab('0x2d')]=_[_0x7eab('0x2e')](_0x1bfc5e[_0x7eab('0x2d')]);_0xf1de02[_0x7eab('0x2f')]=_['intersection'](_0xf1de02['model'],_0xf1de02[_0x7eab('0x2d')]);_0x411f48[_0x7eab('0x30')]=_[_0x7eab('0x31')](_0xf1de02['model'],qs[_0x7eab('0x32')](_0x1bfc5e[_0x7eab('0x2d')][_0x7eab('0x32')]));_0x411f48[_0x7eab('0x30')]=_0x411f48['attributes'][_0x7eab('0x33')]?_0x411f48[_0x7eab('0x30')]:_0xf1de02[_0x7eab('0x2c')];if(!_0x1bfc5e['query'][_0x7eab('0x34')]('nolimit')){_0x411f48[_0x7eab('0x19')]=qs[_0x7eab('0x19')](_0x1bfc5e[_0x7eab('0x2d')][_0x7eab('0x19')]);_0x411f48[_0x7eab('0x18')]=qs[_0x7eab('0x18')](_0x1bfc5e[_0x7eab('0x2d')][_0x7eab('0x18')]);}_0x411f48[_0x7eab('0x35')]=qs['sort'](_0x1bfc5e[_0x7eab('0x2d')][_0x7eab('0x36')]);_0x411f48[_0x7eab('0x37')]=qs[_0x7eab('0x2f')](_[_0x7eab('0x38')](_0x1bfc5e[_0x7eab('0x2d')],_0xf1de02[_0x7eab('0x2f')]),_0x21741c);if(_0x1bfc5e['query']['filter']){_0x411f48[_0x7eab('0x37')]=_[_0x7eab('0x39')](_0x411f48[_0x7eab('0x37')],{'$or':_[_0x7eab('0x26')](_0x21741c,function(_0x5841e9){if(_0x5841e9[_0x7eab('0x2a')]!=='VIRTUAL'){var _0x4fbdd4={};_0x4fbdd4[_0x5841e9['name']]={'$like':'%'+_0x1bfc5e[_0x7eab('0x2d')][_0x7eab('0x3a')]+'%'};return _0x4fbdd4;}})});}_0x411f48=_[_0x7eab('0x39')]({},_0x411f48,_0x1bfc5e[_0x7eab('0x3b')]);var _0x5105cd={'where':_0x411f48[_0x7eab('0x37')]};return db[_0x7eab('0x27')][_0x7eab('0x1a')](_0x5105cd)[_0x7eab('0x1f')](function(_0x599363){_0x54f264[_0x7eab('0x1a')]=_0x599363;if(_0x1bfc5e['query'][_0x7eab('0x3c')]){_0x411f48['include']=[{'all':!![]}];}return db[_0x7eab('0x27')][_0x7eab('0x3d')](_0x411f48);})['then'](function(_0x57cce2){_0x54f264[_0x7eab('0x3e')]=_0x57cce2;return _0x54f264;})[_0x7eab('0x1f')](respondWithFilteredResult(_0x3caf62,_0x411f48))[_0x7eab('0x3f')](handleError(_0x3caf62,null));};exports[_0x7eab('0x40')]=function(_0x16e585,_0x3a4627){var _0x1d01db={'raw':!![],'where':{'id':_0x16e585[_0x7eab('0x41')]['id']}},_0x4cef7e={};_0x4cef7e['model']=_[_0x7eab('0x2e')](db['Interval'][_0x7eab('0x28')]);_0x4cef7e['query']=_[_0x7eab('0x2e')](_0x16e585[_0x7eab('0x2d')]);_0x4cef7e[_0x7eab('0x2f')]=_[_0x7eab('0x31')](_0x4cef7e[_0x7eab('0x2c')],_0x4cef7e[_0x7eab('0x2d')]);_0x1d01db[_0x7eab('0x30')]=_[_0x7eab('0x31')](_0x4cef7e[_0x7eab('0x2c')],qs[_0x7eab('0x32')](_0x16e585[_0x7eab('0x2d')]['fields']));_0x1d01db[_0x7eab('0x30')]=_0x1d01db[_0x7eab('0x30')][_0x7eab('0x33')]?_0x1d01db[_0x7eab('0x30')]:_0x4cef7e['model'];if(_0x16e585[_0x7eab('0x2d')][_0x7eab('0x3c')]){_0x1d01db[_0x7eab('0x42')]=[{'all':!![]}];}_0x1d01db=_[_0x7eab('0x39')]({},_0x1d01db,_0x16e585[_0x7eab('0x3b')]);return db[_0x7eab('0x27')][_0x7eab('0x43')](_0x1d01db)[_0x7eab('0x1f')](handleEntityNotFound(_0x3a4627,null))[_0x7eab('0x1f')](respondWithResult(_0x3a4627,null))[_0x7eab('0x3f')](handleError(_0x3a4627,null));};exports['create']=function(_0x3437cb,_0x25d37e){return db[_0x7eab('0x27')][_0x7eab('0x44')](_0x3437cb[_0x7eab('0x45')],{})[_0x7eab('0x1f')](function(_0xf9c3af){var _0x1a1759=_0x3437cb[_0x7eab('0x46')][_0x7eab('0x20')]({'plain':!![]});if(!_0x1a1759)throw new Error(_0x7eab('0x47'));if(_0x1a1759[_0x7eab('0x48')]===_0x7eab('0x46')){var _0x32bfe0=_0xf9c3af[_0x7eab('0x20')]({'plain':!![]});var _0x2cd97e='Intervals';return db[_0x7eab('0x49')]['find']({'where':{'name':_0x2cd97e,'userProfileId':_0x1a1759['userProfileId']},'raw':!![]})['then'](function(_0xb8ed15){if(_0xb8ed15&&_0xb8ed15['autoAssociation']===0x0){return db[_0x7eab('0x4a')][_0x7eab('0x44')]({'name':_0x32bfe0['name'],'resourceId':_0x32bfe0['id'],'type':_0xb8ed15[_0x7eab('0x23')],'sectionId':_0xb8ed15['id']},{})[_0x7eab('0x1f')](function(){return _0xf9c3af;});}else{return _0xf9c3af;}})[_0x7eab('0x3f')](function(_0x5b31f1){logger[_0x7eab('0x22')](_0x7eab('0x4b'),_0x5b31f1);throw _0x5b31f1;});}return _0xf9c3af;})['then'](respondWithResult(_0x25d37e,0xc9))['catch'](handleError(_0x25d37e,null));};exports[_0x7eab('0x1e')]=function(_0x53c096,_0x479a36){if(_0x53c096[_0x7eab('0x45')]['id']){delete _0x53c096[_0x7eab('0x45')]['id'];}return db['Interval'][_0x7eab('0x43')]({'where':{'id':_0x53c096[_0x7eab('0x41')]['id']}})[_0x7eab('0x1f')](handleEntityNotFound(_0x479a36,null))[_0x7eab('0x1f')](saveUpdates(_0x53c096[_0x7eab('0x45')],null))[_0x7eab('0x1f')](respondWithResult(_0x479a36,null))[_0x7eab('0x3f')](handleError(_0x479a36,null));};exports['destroy']=function(_0x388406,_0x5c1113){return db[_0x7eab('0x27')][_0x7eab('0x43')]({'where':{'id':_0x388406['params']['id']}})[_0x7eab('0x1f')](handleEntityNotFound(_0x5c1113,null))[_0x7eab('0x1f')](removeEntity(_0x5c1113,null))['catch'](handleError(_0x5c1113,null));};exports['addInterval']=function(_0x5d30e2,_0x2137c0,_0x98e03b){if(_0x5d30e2[_0x7eab('0x45')]['id']){delete _0x5d30e2['body']['id'];}return db[_0x7eab('0x27')]['find']({'where':{'id':_0x5d30e2['params']['id']}})['then'](handleEntityNotFound(_0x2137c0,null))[_0x7eab('0x1f')](function(_0x97c5a6){if(_0x97c5a6){_0x5d30e2[_0x7eab('0x45')][_0x7eab('0x4c')]=_0x97c5a6['id'];return db['Interval'][_0x7eab('0x44')](_0x5d30e2[_0x7eab('0x45')]);}})[_0x7eab('0x1f')](respondWithResult(_0x2137c0,null))[_0x7eab('0x3f')](handleError(_0x2137c0,null));};exports[_0x7eab('0x4d')]=function(_0x5928fa,_0x2924de,_0x5d7864){var _0x4c4dfb={};var _0x471684={};var _0x426252;var _0x193744;return db[_0x7eab('0x27')][_0x7eab('0x4e')]({'where':{'id':_0x5928fa['params']['id']}})[_0x7eab('0x1f')](handleEntityNotFound(_0x2924de,null))[_0x7eab('0x1f')](function(_0x36f6a7){if(_0x36f6a7){_0x426252=_0x36f6a7;_0x471684[_0x7eab('0x2c')]=_['keys'](db[_0x7eab('0x27')][_0x7eab('0x28')]);_0x471684[_0x7eab('0x2d')]=_[_0x7eab('0x2e')](_0x5928fa['query']);_0x471684[_0x7eab('0x2f')]=_[_0x7eab('0x31')](_0x471684[_0x7eab('0x2c')],_0x471684[_0x7eab('0x2d')]);_0x4c4dfb[_0x7eab('0x30')]=_[_0x7eab('0x31')](_0x471684[_0x7eab('0x2c')],qs['fields'](_0x5928fa['query'][_0x7eab('0x32')]));_0x4c4dfb[_0x7eab('0x30')]=_0x4c4dfb['attributes']['length']?_0x4c4dfb[_0x7eab('0x30')]:_0x471684[_0x7eab('0x2c')];_0x4c4dfb[_0x7eab('0x35')]=qs[_0x7eab('0x36')](_0x5928fa[_0x7eab('0x2d')][_0x7eab('0x36')]);_0x4c4dfb[_0x7eab('0x37')]=qs['filters'](_[_0x7eab('0x38')](_0x5928fa[_0x7eab('0x2d')],_0x471684['filters']));if(_0x5928fa['query'][_0x7eab('0x3a')]){_0x4c4dfb[_0x7eab('0x37')]=_['merge'](_0x4c4dfb[_0x7eab('0x37')],{'$or':_[_0x7eab('0x26')](_0x4c4dfb['attributes'],function(_0x3fa99b){var _0x4f3ac9={};_0x4f3ac9[_0x3fa99b]={'$like':'%'+_0x5928fa[_0x7eab('0x2d')][_0x7eab('0x3a')]+'%'};return _0x4f3ac9;})});}_0x4c4dfb=_[_0x7eab('0x39')]({},_0x4c4dfb,_0x5928fa[_0x7eab('0x3b')]);return _0x426252['getIntervals'](_0x4c4dfb);}})[_0x7eab('0x1f')](function(_0x435173){if(_0x435173){_0x193744=_0x435173[_0x7eab('0x33')];if(!_0x5928fa[_0x7eab('0x2d')]['hasOwnProperty'](_0x7eab('0x4f'))){_0x4c4dfb[_0x7eab('0x19')]=qs[_0x7eab('0x19')](_0x5928fa[_0x7eab('0x2d')][_0x7eab('0x19')]);_0x4c4dfb['offset']=qs[_0x7eab('0x18')](_0x5928fa['query'][_0x7eab('0x18')]);}return _0x426252[_0x7eab('0x4d')](_0x4c4dfb);}})[_0x7eab('0x1f')](function(_0x39b66f){if(_0x39b66f){return _0x39b66f?{'count':_0x193744,'rows':_0x39b66f}:null;}})[_0x7eab('0x1f')](respondWithResult(_0x2924de,null))[_0x7eab('0x3f')](handleError(_0x2924de,null));};exports[_0x7eab('0x50')]=function(_0x27384e,_0x519d3c,_0x2e9988){return db[_0x7eab('0x27')][_0x7eab('0x4e')]({'where':{'id':_0x27384e['params']['id']}})[_0x7eab('0x1f')](handleEntityNotFound(_0x519d3c,null))[_0x7eab('0x1f')](function(_0x226bd6){if(_0x226bd6){return db[_0x7eab('0x51')][_0x7eab('0x52')](function(_0x5916a1){return db['Interval']['destroy']({'where':{'IntervalId':_0x27384e[_0x7eab('0x41')]['id']},'transaction':_0x5916a1})[_0x7eab('0x1f')](function(_0x9de6b2){var _0x171d77=_['map'](_0x27384e[_0x7eab('0x45')],function(_0x445d7d){delete _0x445d7d['id'];_0x445d7d[_0x7eab('0x4c')]=_0x27384e[_0x7eab('0x41')]['id'];return _0x445d7d;});return db[_0x7eab('0x27')][_0x7eab('0x53')](_0x171d77,{'transaction':_0x5916a1});});})[_0x7eab('0x1f')](function(){return db[_0x7eab('0x27')][_0x7eab('0x3d')]({'where':{'IntervalId':_0x27384e['params']['id']}});});}})[_0x7eab('0x1f')](respondWithResult(_0x519d3c,null))['catch'](handleError(_0x519d3c,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