Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / interval / interval.controller.js
index 7695ca1..8c2744c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x22a7=['sort','where','pick','filter','merge','VIRTUAL','options','count','includeAll','include','findAll','catch','show','params','keys','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','addInterval','IntervalId','getIntervals','findOne','addIntervals','sequelize','transaction','bulkCreate','eml-format','rimraf','zip-dir','request-promise','moment','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','json','offset','undefined','limit','set','reject','update','then','get','Intervals','UserProfileResource','error','stack','name','send','index','Interval','rawAttributes','fieldName','type','map','query','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order'];(function(_0x4b055c,_0x4b870b){var _0x4b62bb=function(_0x4884c2){while(--_0x4884c2){_0x4b055c['push'](_0x4b055c['shift']());}};_0x4b62bb(++_0x4b870b);}(_0x22a7,0x18c));var _0x722a=function(_0xdef99e,_0x2050b8){_0xdef99e=_0xdef99e-0x0;var _0x395cd8=_0x22a7[_0xdef99e];return _0x395cd8;};'use strict';var emlformat=require(_0x722a('0x0'));var rimraf=require(_0x722a('0x1'));var zipdir=require(_0x722a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x722a('0x3'));var moment=require(_0x722a('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x722a('0x5'));var util=require('util');var path=require(_0x722a('0x6'));var sox=require(_0x722a('0x7'));var csv=require(_0x722a('0x8'));var ejs=require(_0x722a('0x9'));var fs=require('fs');var fs_extra=require(_0x722a('0xa'));var _=require(_0x722a('0xb'));var squel=require(_0x722a('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x722a('0xd'));var toCsv=require('to-csv');var querystring=require(_0x722a('0xe'));var Papa=require(_0x722a('0xf'));var Redis=require('ioredis');var authService=require(_0x722a('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x722a('0x11'));var hardwareService=require(_0x722a('0x12'));var logger=require(_0x722a('0x13'))(_0x722a('0x14'));var utils=require('../../config/utils');var config=require(_0x722a('0x15'));var licenseUtil=require(_0x722a('0x16'));var db=require(_0x722a('0x17'))['db'];var extensions=require(_0x722a('0x18'));function respondWithStatusCode(_0x5df41b,_0x40eb26){_0x40eb26=_0x40eb26||0xcc;return function(_0x4f6799){if(_0x4f6799){return _0x5df41b[_0x722a('0x19')](_0x40eb26);}return _0x5df41b[_0x722a('0x1a')](_0x40eb26)[_0x722a('0x1b')]();};}function respondWithResult(_0x289715,_0x59b432){_0x59b432=_0x59b432||0xc8;return function(_0x3aeea2){if(_0x3aeea2){return _0x289715[_0x722a('0x1a')](_0x59b432)[_0x722a('0x1c')](_0x3aeea2);}};}function respondWithFilteredResult(_0x1240f3,_0x571dc4){return function(_0x1149d3){if(_0x1149d3){var _0x54ba83=typeof _0x571dc4[_0x722a('0x1d')]===_0x722a('0x1e')&&typeof _0x571dc4[_0x722a('0x1f')]===_0x722a('0x1e');var _0x57b546=_0x1149d3['count'];var _0x454a40=_0x54ba83?0x0:_0x571dc4['offset'];var _0x1395c6=_0x54ba83?_0x1149d3['count']:_0x571dc4[_0x722a('0x1d')]+_0x571dc4[_0x722a('0x1f')];var _0x2b8d4c;if(_0x1395c6>=_0x57b546){_0x1395c6=_0x57b546;_0x2b8d4c=0xc8;}else{_0x2b8d4c=0xce;}_0x1240f3[_0x722a('0x1a')](_0x2b8d4c);return _0x1240f3[_0x722a('0x20')]('Content-Range',_0x454a40+'-'+_0x1395c6+'/'+_0x57b546)[_0x722a('0x1c')](_0x1149d3);}return null;};}function patchUpdates(_0x3ff736){return function(_0x459581){try{jsonpatch['apply'](_0x459581,_0x3ff736,!![]);}catch(_0x78144a){return BPromise[_0x722a('0x21')](_0x78144a);}return _0x459581['save']();};}function saveUpdates(_0x3dc85e,_0x49b724){return function(_0x12e5cb){if(_0x12e5cb){return _0x12e5cb[_0x722a('0x22')](_0x3dc85e)[_0x722a('0x23')](function(_0x4f3fb4){return _0x4f3fb4;});}return null;};}function removeEntity(_0x25e952,_0x2d49c7){return function(_0x54bc92){if(_0x54bc92){return _0x54bc92['destroy']()[_0x722a('0x23')](function(){var _0x1cd9d8=_0x54bc92[_0x722a('0x24')]({'plain':!![]});var _0x257643=_0x722a('0x25');return db[_0x722a('0x26')]['destroy']({'where':{'type':_0x257643,'resourceId':_0x1cd9d8['id']}})[_0x722a('0x23')](function(){return _0x54bc92;});})[_0x722a('0x23')](function(){_0x25e952[_0x722a('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x337bca,_0x5bdbe5){return function(_0x26b454){if(!_0x26b454){_0x337bca['sendStatus'](0x194);}return _0x26b454;};}function handleError(_0x4ea210,_0x44da09){_0x44da09=_0x44da09||0x1f4;return function(_0x5c17a3){logger[_0x722a('0x27')](_0x5c17a3[_0x722a('0x28')]);if(_0x5c17a3[_0x722a('0x29')]){delete _0x5c17a3['name'];}_0x4ea210[_0x722a('0x1a')](_0x44da09)[_0x722a('0x2a')](_0x5c17a3);};}exports[_0x722a('0x2b')]=function(_0x56164b,_0x5f181a){var _0x4bc800={},_0x4f7274={},_0x14e48d={'count':0x0,'rows':[]};var _0x44f9dc=_['map'](db[_0x722a('0x2c')][_0x722a('0x2d')],function(_0x191728){return{'name':_0x191728[_0x722a('0x2e')],'type':_0x191728[_0x722a('0x2f')]['key']};});_0x4f7274['model']=_[_0x722a('0x30')](_0x44f9dc,'name');_0x4f7274['query']=_['keys'](_0x56164b[_0x722a('0x31')]);_0x4f7274[_0x722a('0x32')]=_[_0x722a('0x33')](_0x4f7274['model'],_0x4f7274[_0x722a('0x31')]);_0x4bc800[_0x722a('0x34')]=_[_0x722a('0x33')](_0x4f7274[_0x722a('0x35')],qs[_0x722a('0x36')](_0x56164b[_0x722a('0x31')]['fields']));_0x4bc800['attributes']=_0x4bc800[_0x722a('0x34')][_0x722a('0x37')]?_0x4bc800[_0x722a('0x34')]:_0x4f7274['model'];if(!_0x56164b[_0x722a('0x31')][_0x722a('0x38')](_0x722a('0x39'))){_0x4bc800[_0x722a('0x1f')]=qs[_0x722a('0x1f')](_0x56164b[_0x722a('0x31')][_0x722a('0x1f')]);_0x4bc800[_0x722a('0x1d')]=qs['offset'](_0x56164b[_0x722a('0x31')]['offset']);}_0x4bc800[_0x722a('0x3a')]=qs[_0x722a('0x3b')](_0x56164b[_0x722a('0x31')]['sort']);_0x4bc800[_0x722a('0x3c')]=qs[_0x722a('0x32')](_[_0x722a('0x3d')](_0x56164b[_0x722a('0x31')],_0x4f7274[_0x722a('0x32')]),_0x44f9dc);if(_0x56164b[_0x722a('0x31')][_0x722a('0x3e')]){_0x4bc800[_0x722a('0x3c')]=_[_0x722a('0x3f')](_0x4bc800[_0x722a('0x3c')],{'$or':_[_0x722a('0x30')](_0x44f9dc,function(_0x1c337c){if(_0x1c337c['type']!==_0x722a('0x40')){var _0x3ebb89={};_0x3ebb89[_0x1c337c[_0x722a('0x29')]]={'$like':'%'+_0x56164b['query'][_0x722a('0x3e')]+'%'};return _0x3ebb89;}})});}_0x4bc800=_[_0x722a('0x3f')]({},_0x4bc800,_0x56164b[_0x722a('0x41')]);var _0x3f1b91={'where':_0x4bc800[_0x722a('0x3c')]};return db[_0x722a('0x2c')]['count'](_0x3f1b91)['then'](function(_0x3ea8e1){_0x14e48d[_0x722a('0x42')]=_0x3ea8e1;if(_0x56164b[_0x722a('0x31')][_0x722a('0x43')]){_0x4bc800[_0x722a('0x44')]=[{'all':!![]}];}return db[_0x722a('0x2c')][_0x722a('0x45')](_0x4bc800);})[_0x722a('0x23')](function(_0x2aa0ab){_0x14e48d['rows']=_0x2aa0ab;return _0x14e48d;})['then'](respondWithFilteredResult(_0x5f181a,_0x4bc800))[_0x722a('0x46')](handleError(_0x5f181a,null));};exports[_0x722a('0x47')]=function(_0x4fd028,_0x47ff00){var _0x115406={'raw':!![],'where':{'id':_0x4fd028[_0x722a('0x48')]['id']}},_0x18d1a5={};_0x18d1a5[_0x722a('0x35')]=_[_0x722a('0x49')](db[_0x722a('0x2c')]['rawAttributes']);_0x18d1a5['query']=_[_0x722a('0x49')](_0x4fd028[_0x722a('0x31')]);_0x18d1a5[_0x722a('0x32')]=_[_0x722a('0x33')](_0x18d1a5['model'],_0x18d1a5[_0x722a('0x31')]);_0x115406['attributes']=_[_0x722a('0x33')](_0x18d1a5[_0x722a('0x35')],qs['fields'](_0x4fd028[_0x722a('0x31')][_0x722a('0x36')]));_0x115406[_0x722a('0x34')]=_0x115406[_0x722a('0x34')][_0x722a('0x37')]?_0x115406[_0x722a('0x34')]:_0x18d1a5[_0x722a('0x35')];if(_0x4fd028['query'][_0x722a('0x43')]){_0x115406[_0x722a('0x44')]=[{'all':!![]}];}_0x115406=_[_0x722a('0x3f')]({},_0x115406,_0x4fd028[_0x722a('0x41')]);return db[_0x722a('0x2c')][_0x722a('0x4a')](_0x115406)[_0x722a('0x23')](handleEntityNotFound(_0x47ff00,null))['then'](respondWithResult(_0x47ff00,null))[_0x722a('0x46')](handleError(_0x47ff00,null));};exports[_0x722a('0x4b')]=function(_0x5d2d0a,_0x2bf0b0){return db[_0x722a('0x2c')]['create'](_0x5d2d0a[_0x722a('0x4c')],{})[_0x722a('0x23')](function(_0x537bf9){var _0x723d50=_0x5d2d0a[_0x722a('0x4d')][_0x722a('0x24')]({'plain':!![]});if(!_0x723d50)throw new Error(_0x722a('0x4e'));if(_0x723d50[_0x722a('0x4f')]==='user'){var _0x2fd4e5=_0x537bf9[_0x722a('0x24')]({'plain':!![]});var _0x10836a=_0x722a('0x25');return db['UserProfileSection'][_0x722a('0x4a')]({'where':{'name':_0x10836a,'userProfileId':_0x723d50[_0x722a('0x50')]},'raw':!![]})['then'](function(_0x53964e){if(_0x53964e&&_0x53964e['autoAssociation']===0x0){return db[_0x722a('0x26')][_0x722a('0x4b')]({'name':_0x2fd4e5[_0x722a('0x29')],'resourceId':_0x2fd4e5['id'],'type':_0x53964e[_0x722a('0x29')],'sectionId':_0x53964e['id']},{})[_0x722a('0x23')](function(){return _0x537bf9;});}else{return _0x537bf9;}})['catch'](function(_0x1117b0){logger[_0x722a('0x27')](_0x722a('0x51'),_0x1117b0);throw _0x1117b0;});}return _0x537bf9;})['then'](respondWithResult(_0x2bf0b0,0xc9))[_0x722a('0x46')](handleError(_0x2bf0b0,null));};exports['update']=function(_0x2928d2,_0x5f0a46){if(_0x2928d2[_0x722a('0x4c')]['id']){delete _0x2928d2[_0x722a('0x4c')]['id'];}return db[_0x722a('0x2c')][_0x722a('0x4a')]({'where':{'id':_0x2928d2[_0x722a('0x48')]['id']}})[_0x722a('0x23')](handleEntityNotFound(_0x5f0a46,null))[_0x722a('0x23')](saveUpdates(_0x2928d2[_0x722a('0x4c')],null))[_0x722a('0x23')](respondWithResult(_0x5f0a46,null))[_0x722a('0x46')](handleError(_0x5f0a46,null));};exports[_0x722a('0x52')]=function(_0x48a58c,_0x120a54){return db[_0x722a('0x2c')]['find']({'where':{'id':_0x48a58c[_0x722a('0x48')]['id']}})['then'](handleEntityNotFound(_0x120a54,null))[_0x722a('0x23')](removeEntity(_0x120a54,null))['catch'](handleError(_0x120a54,null));};exports[_0x722a('0x53')]=function(_0x38f463,_0x3e6c82,_0x1b7093){if(_0x38f463[_0x722a('0x4c')]['id']){delete _0x38f463[_0x722a('0x4c')]['id'];}return db[_0x722a('0x2c')][_0x722a('0x4a')]({'where':{'id':_0x38f463[_0x722a('0x48')]['id']}})['then'](handleEntityNotFound(_0x3e6c82,null))[_0x722a('0x23')](function(_0x10b7fe){if(_0x10b7fe){_0x38f463[_0x722a('0x4c')][_0x722a('0x54')]=_0x10b7fe['id'];return db[_0x722a('0x2c')][_0x722a('0x4b')](_0x38f463[_0x722a('0x4c')]);}})[_0x722a('0x23')](respondWithResult(_0x3e6c82,null))['catch'](handleError(_0x3e6c82,null));};exports[_0x722a('0x55')]=function(_0x491551,_0x270615,_0xbdf41c){var _0x3cdbd9={};var _0x24a4a8={};var _0x37b447;var _0x2c414b;return db[_0x722a('0x2c')][_0x722a('0x56')]({'where':{'id':_0x491551['params']['id']}})[_0x722a('0x23')](handleEntityNotFound(_0x270615,null))[_0x722a('0x23')](function(_0x436f22){if(_0x436f22){_0x37b447=_0x436f22;_0x24a4a8['model']=_[_0x722a('0x49')](db[_0x722a('0x2c')][_0x722a('0x2d')]);_0x24a4a8[_0x722a('0x31')]=_[_0x722a('0x49')](_0x491551[_0x722a('0x31')]);_0x24a4a8[_0x722a('0x32')]=_[_0x722a('0x33')](_0x24a4a8[_0x722a('0x35')],_0x24a4a8[_0x722a('0x31')]);_0x3cdbd9[_0x722a('0x34')]=_[_0x722a('0x33')](_0x24a4a8[_0x722a('0x35')],qs[_0x722a('0x36')](_0x491551[_0x722a('0x31')][_0x722a('0x36')]));_0x3cdbd9['attributes']=_0x3cdbd9['attributes']['length']?_0x3cdbd9[_0x722a('0x34')]:_0x24a4a8[_0x722a('0x35')];_0x3cdbd9[_0x722a('0x3a')]=qs[_0x722a('0x3b')](_0x491551[_0x722a('0x31')][_0x722a('0x3b')]);_0x3cdbd9[_0x722a('0x3c')]=qs[_0x722a('0x32')](_['pick'](_0x491551[_0x722a('0x31')],_0x24a4a8['filters']));if(_0x491551[_0x722a('0x31')][_0x722a('0x3e')]){_0x3cdbd9['where']=_['merge'](_0x3cdbd9[_0x722a('0x3c')],{'$or':_[_0x722a('0x30')](_0x3cdbd9[_0x722a('0x34')],function(_0x4ab318){var _0x3cff64={};_0x3cff64[_0x4ab318]={'$like':'%'+_0x491551[_0x722a('0x31')]['filter']+'%'};return _0x3cff64;})});}_0x3cdbd9=_[_0x722a('0x3f')]({},_0x3cdbd9,_0x491551['options']);return _0x37b447[_0x722a('0x55')](_0x3cdbd9);}})['then'](function(_0x3ae0dc){if(_0x3ae0dc){_0x2c414b=_0x3ae0dc[_0x722a('0x37')];if(!_0x491551[_0x722a('0x31')][_0x722a('0x38')]('nolimit')){_0x3cdbd9[_0x722a('0x1f')]=qs[_0x722a('0x1f')](_0x491551[_0x722a('0x31')][_0x722a('0x1f')]);_0x3cdbd9[_0x722a('0x1d')]=qs['offset'](_0x491551[_0x722a('0x31')][_0x722a('0x1d')]);}return _0x37b447[_0x722a('0x55')](_0x3cdbd9);}})[_0x722a('0x23')](function(_0x3554fe){if(_0x3554fe){return _0x3554fe?{'count':_0x2c414b,'rows':_0x3554fe}:null;}})[_0x722a('0x23')](respondWithResult(_0x270615,null))[_0x722a('0x46')](handleError(_0x270615,null));};exports[_0x722a('0x57')]=function(_0x151192,_0x99593a,_0x1f4ccf){return db[_0x722a('0x2c')][_0x722a('0x56')]({'where':{'id':_0x151192[_0x722a('0x48')]['id']}})[_0x722a('0x23')](handleEntityNotFound(_0x99593a,null))[_0x722a('0x23')](function(_0x2539d4){if(_0x2539d4){return db[_0x722a('0x58')][_0x722a('0x59')](function(_0x5fe5cb){return db[_0x722a('0x2c')][_0x722a('0x52')]({'where':{'IntervalId':_0x151192[_0x722a('0x48')]['id']},'transaction':_0x5fe5cb})[_0x722a('0x23')](function(_0x356e7b){var _0x20ef94=_[_0x722a('0x30')](_0x151192[_0x722a('0x4c')],function(_0x38b252){delete _0x38b252['id'];_0x38b252['IntervalId']=_0x151192['params']['id'];return _0x38b252;});return db['Interval'][_0x722a('0x5a')](_0x20ef94,{'transaction':_0x5fe5cb});});})[_0x722a('0x23')](function(){return db[_0x722a('0x2c')]['findAll']({'where':{'IntervalId':_0x151192[_0x722a('0x48')]['id']}});});}})[_0x722a('0x23')](respondWithResult(_0x99593a,null))[_0x722a('0x46')](handleError(_0x99593a,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