Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / schedule / schedule.controller.js
index 3cf566e..a439117 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa04b=['update','then','destroy','Scheduler','UserProfileResource','sendStatus','stack','name','send','index','map','Schedule','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','show','params','find','catch','create','body','user','get','role','UserProfileSection','userProfileId','autoAssociation','error','run','../../config/schedule','eml-format','rimraf','fast-json-patch','request-promise','moment','util','path','sox','to-csv','fs-extra','crypto','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','status','end','json','offset','undefined','count','set','Content-Range','apply','save'];(function(_0x43da39,_0x35bb58){var _0x54959e=function(_0x23ba2e){while(--_0x23ba2e){_0x43da39['push'](_0x43da39['shift']());}};_0x54959e(++_0x35bb58);}(_0xa04b,0x12e));var _0xba04=function(_0x157f6f,_0x140aa5){_0x157f6f=_0x157f6f-0x0;var _0x3ddb2d=_0xa04b[_0x157f6f];return _0x3ddb2d;};'use strict';var emlformat=require(_0xba04('0x0'));var rimraf=require(_0xba04('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xba04('0x2'));var rp=require(_0xba04('0x3'));var moment=require(_0xba04('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xba04('0x5'));var path=require(_0xba04('0x6'));var sox=require(_0xba04('0x7'));var csv=require(_0xba04('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xba04('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xba04('0xa'));var jsforce=require(_0xba04('0xb'));var deskjs=require(_0xba04('0xc'));var toCsv=require('to-csv');var querystring=require(_0xba04('0xd'));var Papa=require(_0xba04('0xe'));var Redis=require(_0xba04('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xba04('0x10'));var as=require(_0xba04('0x11'));var hardwareService=require(_0xba04('0x12'));var logger=require(_0xba04('0x13'))('api');var utils=require(_0xba04('0x14'));var config=require(_0xba04('0x15'));var licenseUtil=require(_0xba04('0x16'));var db=require(_0xba04('0x17'))['db'];function respondWithStatusCode(_0x417eec,_0x569e81){_0x569e81=_0x569e81||0xcc;return function(_0x3578cd){if(_0x3578cd){return _0x417eec['sendStatus'](_0x569e81);}return _0x417eec[_0xba04('0x18')](_0x569e81)[_0xba04('0x19')]();};}function respondWithResult(_0x5e6ece,_0x593058){_0x593058=_0x593058||0xc8;return function(_0x2ad405){if(_0x2ad405){return _0x5e6ece[_0xba04('0x18')](_0x593058)[_0xba04('0x1a')](_0x2ad405);}};}function respondWithFilteredResult(_0x1dc407,_0x14e501){return function(_0x18466e){if(_0x18466e){var _0xc8c54e=typeof _0x14e501[_0xba04('0x1b')]===_0xba04('0x1c')&&typeof _0x14e501['limit']===_0xba04('0x1c');var _0x23075b=_0x18466e[_0xba04('0x1d')];var _0x36453d=_0xc8c54e?0x0:_0x14e501['offset'];var _0x1cb82c=_0xc8c54e?_0x18466e[_0xba04('0x1d')]:_0x14e501['offset']+_0x14e501['limit'];var _0x1ef2fc;if(_0x1cb82c>=_0x23075b){_0x1cb82c=_0x23075b;_0x1ef2fc=0xc8;}else{_0x1ef2fc=0xce;}_0x1dc407[_0xba04('0x18')](_0x1ef2fc);return _0x1dc407[_0xba04('0x1e')](_0xba04('0x1f'),_0x36453d+'-'+_0x1cb82c+'/'+_0x23075b)[_0xba04('0x1a')](_0x18466e);}return null;};}function patchUpdates(_0x39eda8){return function(_0x3c5e0a){try{jsonpatch[_0xba04('0x20')](_0x3c5e0a,_0x39eda8,!![]);}catch(_0x12d76f){return BPromise['reject'](_0x12d76f);}return _0x3c5e0a[_0xba04('0x21')]();};}function saveUpdates(_0xfe7957,_0x12cb3f){return function(_0x229d80){if(_0x229d80){return _0x229d80[_0xba04('0x22')](_0xfe7957)[_0xba04('0x23')](function(_0x2f910c){return _0x2f910c;});}return null;};}function removeEntity(_0x3664fe,_0x322abb){return function(_0x51e46c){if(_0x51e46c){return _0x51e46c[_0xba04('0x24')]()['then'](function(){var _0x19e3e7=_0x51e46c['get']({'plain':!![]});var _0x3c4d31=_0xba04('0x25');return db[_0xba04('0x26')][_0xba04('0x24')]({'where':{'type':_0x3c4d31,'resourceId':_0x19e3e7['id']}})[_0xba04('0x23')](function(){return _0x51e46c;});})[_0xba04('0x23')](function(){_0x3664fe['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x12da03,_0x5d9e48){return function(_0x49083c){if(!_0x49083c){_0x12da03[_0xba04('0x27')](0x194);}return _0x49083c;};}function handleError(_0x308c1a,_0x35fb3d){_0x35fb3d=_0x35fb3d||0x1f4;return function(_0x1ccfef){logger['error'](_0x1ccfef[_0xba04('0x28')]);if(_0x1ccfef[_0xba04('0x29')]){delete _0x1ccfef[_0xba04('0x29')];}_0x308c1a[_0xba04('0x18')](_0x35fb3d)[_0xba04('0x2a')](_0x1ccfef);};}exports[_0xba04('0x2b')]=function(_0x5e04ba,_0x3c5861){var _0x6958={},_0x306b23={},_0x42dcd2={'count':0x0,'rows':[]};var _0x2b4584=_[_0xba04('0x2c')](db[_0xba04('0x2d')][_0xba04('0x2e')],function(_0x52949c){return{'name':_0x52949c['fieldName'],'type':_0x52949c[_0xba04('0x2f')][_0xba04('0x30')]};});_0x306b23[_0xba04('0x31')]=_['map'](_0x2b4584,_0xba04('0x29'));_0x306b23[_0xba04('0x32')]=_[_0xba04('0x33')](_0x5e04ba[_0xba04('0x32')]);_0x306b23[_0xba04('0x34')]=_[_0xba04('0x35')](_0x306b23[_0xba04('0x31')],_0x306b23['query']);_0x6958[_0xba04('0x36')]=_[_0xba04('0x35')](_0x306b23[_0xba04('0x31')],qs[_0xba04('0x37')](_0x5e04ba[_0xba04('0x32')][_0xba04('0x37')]));_0x6958[_0xba04('0x36')]=_0x6958[_0xba04('0x36')]['length']?_0x6958['attributes']:_0x306b23[_0xba04('0x31')];if(!_0x5e04ba[_0xba04('0x32')][_0xba04('0x38')](_0xba04('0x39'))){_0x6958['limit']=qs[_0xba04('0x3a')](_0x5e04ba[_0xba04('0x32')]['limit']);_0x6958[_0xba04('0x1b')]=qs[_0xba04('0x1b')](_0x5e04ba[_0xba04('0x32')]['offset']);}_0x6958[_0xba04('0x3b')]=qs[_0xba04('0x3c')](_0x5e04ba[_0xba04('0x32')][_0xba04('0x3c')]);_0x6958[_0xba04('0x3d')]=qs[_0xba04('0x34')](_['pick'](_0x5e04ba[_0xba04('0x32')],_0x306b23['filters']),_0x2b4584);if(_0x5e04ba[_0xba04('0x32')][_0xba04('0x3e')]){_0x6958[_0xba04('0x3d')]=_[_0xba04('0x3f')](_0x6958[_0xba04('0x3d')],{'$or':_['map'](_0x2b4584,function(_0x2568ae){if(_0x2568ae[_0xba04('0x2f')]!==_0xba04('0x40')){var _0x2d63f9={};_0x2d63f9[_0x2568ae[_0xba04('0x29')]]={'$like':'%'+_0x5e04ba[_0xba04('0x32')][_0xba04('0x3e')]+'%'};return _0x2d63f9;}})});}_0x6958=_[_0xba04('0x3f')]({},_0x6958,_0x5e04ba[_0xba04('0x41')]);var _0x57d850={'where':_0x6958[_0xba04('0x3d')]};return db['Schedule']['count'](_0x57d850)[_0xba04('0x23')](function(_0x361960){_0x42dcd2[_0xba04('0x1d')]=_0x361960;if(_0x5e04ba[_0xba04('0x32')][_0xba04('0x42')]){_0x6958[_0xba04('0x43')]=[{'all':!![]}];}return db['Schedule'][_0xba04('0x44')](_0x6958);})[_0xba04('0x23')](function(_0x17d104){_0x42dcd2['rows']=_0x17d104;return _0x42dcd2;})[_0xba04('0x23')](respondWithFilteredResult(_0x3c5861,_0x6958))['catch'](handleError(_0x3c5861,null));};exports[_0xba04('0x45')]=function(_0x4c66cf,_0x43928a){var _0x4e1dab={'raw':![],'where':{'id':_0x4c66cf[_0xba04('0x46')]['id']}},_0xbca2c7={};_0xbca2c7['model']=_[_0xba04('0x33')](db['Schedule']['rawAttributes']);_0xbca2c7[_0xba04('0x32')]=_['keys'](_0x4c66cf['query']);_0xbca2c7[_0xba04('0x34')]=_['intersection'](_0xbca2c7[_0xba04('0x31')],_0xbca2c7[_0xba04('0x32')]);_0x4e1dab[_0xba04('0x36')]=_['intersection'](_0xbca2c7[_0xba04('0x31')],qs[_0xba04('0x37')](_0x4c66cf[_0xba04('0x32')][_0xba04('0x37')]));_0x4e1dab[_0xba04('0x36')]=_0x4e1dab[_0xba04('0x36')]['length']?_0x4e1dab[_0xba04('0x36')]:_0xbca2c7[_0xba04('0x31')];if(_0x4c66cf[_0xba04('0x32')]['includeAll']){_0x4e1dab['include']=[{'all':!![]}];}_0x4e1dab=_[_0xba04('0x3f')]({},_0x4e1dab,_0x4c66cf[_0xba04('0x41')]);return db['Schedule'][_0xba04('0x47')](_0x4e1dab)[_0xba04('0x23')](handleEntityNotFound(_0x43928a,null))['then'](respondWithResult(_0x43928a,null))[_0xba04('0x48')](handleError(_0x43928a,null));};exports[_0xba04('0x49')]=function(_0x4ee1b6,_0xad8f89){return db[_0xba04('0x2d')][_0xba04('0x49')](_0x4ee1b6[_0xba04('0x4a')],{})[_0xba04('0x23')](function(_0x197401){var _0xcaf351=_0x4ee1b6[_0xba04('0x4b')][_0xba04('0x4c')]({'plain':!![]});if(!_0xcaf351)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xcaf351[_0xba04('0x4d')]===_0xba04('0x4b')){var _0x467ed5=_0x197401[_0xba04('0x4c')]({'plain':!![]});var _0x4717d6=_0xba04('0x25');return db[_0xba04('0x4e')]['find']({'where':{'name':_0x4717d6,'userProfileId':_0xcaf351[_0xba04('0x4f')]},'raw':!![]})[_0xba04('0x23')](function(_0x191442){if(_0x191442&&_0x191442[_0xba04('0x50')]===0x0){return db['UserProfileResource'][_0xba04('0x49')]({'name':_0x467ed5[_0xba04('0x29')],'resourceId':_0x467ed5['id'],'type':_0x191442[_0xba04('0x29')],'sectionId':_0x191442['id']},{})['then'](function(){return _0x197401;});}else{return _0x197401;}})['catch'](function(_0x1a65ff){logger[_0xba04('0x51')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1a65ff);throw _0x1a65ff;});}return _0x197401;})[_0xba04('0x23')](respondWithResult(_0xad8f89,0xc9))[_0xba04('0x48')](handleError(_0xad8f89,null));};exports[_0xba04('0x22')]=function(_0xe6399d,_0x3be390){if(_0xe6399d['body']['id']){delete _0xe6399d[_0xba04('0x4a')]['id'];}return db[_0xba04('0x2d')][_0xba04('0x47')]({'where':{'id':_0xe6399d[_0xba04('0x46')]['id']}})[_0xba04('0x23')](handleEntityNotFound(_0x3be390,null))['then'](saveUpdates(_0xe6399d[_0xba04('0x4a')],null))[_0xba04('0x23')](respondWithResult(_0x3be390,null))['catch'](handleError(_0x3be390,null));};exports[_0xba04('0x24')]=function(_0xd27b41,_0x2d7857){return db['Schedule']['find']({'where':{'id':_0xd27b41[_0xba04('0x46')]['id']}})['then'](handleEntityNotFound(_0x2d7857,null))['then'](removeEntity(_0x2d7857,null))['catch'](handleError(_0x2d7857,null));};exports[_0xba04('0x52')]=function(_0x27cd96,_0x12e5ca,_0x2dd540){var _0x4a3ebd=require(_0xba04('0x53'));return db[_0xba04('0x2d')][_0xba04('0x47')]({'where':{'id':_0x27cd96[_0xba04('0x46')]['id']},'raw':!![]})[_0xba04('0x23')](handleEntityNotFound(_0x12e5ca,null))[_0xba04('0x23')](function(){_0x4a3ebd['run'](_0x27cd96[_0xba04('0x46')]['id']);})[_0xba04('0x23')](respondWithStatusCode(_0x12e5ca,null))['catch'](handleError(_0x12e5ca,null));};
\ No newline at end of file
+var _0x03f4=['key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','merge','options','includeAll','include','rows','show','params','Schedule','find','catch','create','body','role','UserProfileSection','userProfileId','autoAssociation','run','../../config/schedule','eml-format','zip-dir','request-promise','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','save','update','then','destroy','get','Scheduler','UserProfileResource','sendStatus','error','stack','name','send','index','map','fieldName','type'];(function(_0x49d41c,_0x2bdc35){var _0xb64c5f=function(_0x28f535){while(--_0x28f535){_0x49d41c['push'](_0x49d41c['shift']());}};_0xb64c5f(++_0x2bdc35);}(_0x03f4,0xce));var _0x403f=function(_0xc3519a,_0x2bf606){_0xc3519a=_0xc3519a-0x0;var _0x1eda04=_0x03f4[_0xc3519a];return _0x1eda04;};'use strict';var emlformat=require(_0x403f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x403f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x403f('0x2'));var moment=require('moment');var BPromise=require(_0x403f('0x3'));var Mustache=require(_0x403f('0x4'));var util=require(_0x403f('0x5'));var path=require('path');var sox=require(_0x403f('0x6'));var csv=require(_0x403f('0x7'));var ejs=require(_0x403f('0x8'));var fs=require('fs');var fs_extra=require(_0x403f('0x9'));var _=require(_0x403f('0xa'));var squel=require(_0x403f('0xb'));var crypto=require(_0x403f('0xc'));var jsforce=require(_0x403f('0xd'));var deskjs=require(_0x403f('0xe'));var toCsv=require('to-csv');var querystring=require(_0x403f('0xf'));var Papa=require('papaparse');var Redis=require(_0x403f('0x10'));var authService=require(_0x403f('0x11'));var qs=require(_0x403f('0x12'));var as=require(_0x403f('0x13'));var hardwareService=require(_0x403f('0x14'));var logger=require(_0x403f('0x15'))(_0x403f('0x16'));var utils=require(_0x403f('0x17'));var config=require(_0x403f('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x403f('0x19'))['db'];function respondWithStatusCode(_0x11b06d,_0x8a85a0){_0x8a85a0=_0x8a85a0||0xcc;return function(_0xed4e75){if(_0xed4e75){return _0x11b06d['sendStatus'](_0x8a85a0);}return _0x11b06d[_0x403f('0x1a')](_0x8a85a0)[_0x403f('0x1b')]();};}function respondWithResult(_0x40ff07,_0x4a7e5c){_0x4a7e5c=_0x4a7e5c||0xc8;return function(_0x48f6b9){if(_0x48f6b9){return _0x40ff07['status'](_0x4a7e5c)[_0x403f('0x1c')](_0x48f6b9);}};}function respondWithFilteredResult(_0x2d3184,_0x510b79){return function(_0xf11dcd){if(_0xf11dcd){var _0x4a6853=typeof _0x510b79[_0x403f('0x1d')]===_0x403f('0x1e')&&typeof _0x510b79['limit']==='undefined';var _0x5914c2=_0xf11dcd[_0x403f('0x1f')];var _0x5da64b=_0x4a6853?0x0:_0x510b79['offset'];var _0x4ae3d2=_0x4a6853?_0xf11dcd[_0x403f('0x1f')]:_0x510b79[_0x403f('0x1d')]+_0x510b79[_0x403f('0x20')];var _0x39681c;if(_0x4ae3d2>=_0x5914c2){_0x4ae3d2=_0x5914c2;_0x39681c=0xc8;}else{_0x39681c=0xce;}_0x2d3184[_0x403f('0x1a')](_0x39681c);return _0x2d3184[_0x403f('0x21')](_0x403f('0x22'),_0x5da64b+'-'+_0x4ae3d2+'/'+_0x5914c2)[_0x403f('0x1c')](_0xf11dcd);}return null;};}function patchUpdates(_0x1661d8){return function(_0x1dde88){try{jsonpatch[_0x403f('0x23')](_0x1dde88,_0x1661d8,!![]);}catch(_0x3dc4a7){return BPromise['reject'](_0x3dc4a7);}return _0x1dde88[_0x403f('0x24')]();};}function saveUpdates(_0x3e93d1,_0x3825af){return function(_0x46ff78){if(_0x46ff78){return _0x46ff78[_0x403f('0x25')](_0x3e93d1)[_0x403f('0x26')](function(_0x5c33bf){return _0x5c33bf;});}return null;};}function removeEntity(_0x2e4fe6,_0x2977aa){return function(_0x21500c){if(_0x21500c){return _0x21500c[_0x403f('0x27')]()[_0x403f('0x26')](function(){var _0x52523c=_0x21500c[_0x403f('0x28')]({'plain':!![]});var _0x562462=_0x403f('0x29');return db[_0x403f('0x2a')][_0x403f('0x27')]({'where':{'type':_0x562462,'resourceId':_0x52523c['id']}})[_0x403f('0x26')](function(){return _0x21500c;});})[_0x403f('0x26')](function(){_0x2e4fe6[_0x403f('0x1a')](0xcc)[_0x403f('0x1b')]();});}};}function handleEntityNotFound(_0x42aee9,_0x2de6d5){return function(_0x3db145){if(!_0x3db145){_0x42aee9[_0x403f('0x2b')](0x194);}return _0x3db145;};}function handleError(_0x50c688,_0x3a1585){_0x3a1585=_0x3a1585||0x1f4;return function(_0x55e20d){logger[_0x403f('0x2c')](_0x55e20d[_0x403f('0x2d')]);if(_0x55e20d[_0x403f('0x2e')]){delete _0x55e20d[_0x403f('0x2e')];}_0x50c688[_0x403f('0x1a')](_0x3a1585)[_0x403f('0x2f')](_0x55e20d);};}exports[_0x403f('0x30')]=function(_0x1c7f41,_0x306dbb){var _0x5793eb={},_0x55cb5d={},_0x386611={'count':0x0,'rows':[]};var _0x3a9a4b=_[_0x403f('0x31')](db['Schedule']['rawAttributes'],function(_0x16af04){return{'name':_0x16af04[_0x403f('0x32')],'type':_0x16af04[_0x403f('0x33')][_0x403f('0x34')]};});_0x55cb5d[_0x403f('0x35')]=_['map'](_0x3a9a4b,_0x403f('0x2e'));_0x55cb5d['query']=_[_0x403f('0x36')](_0x1c7f41[_0x403f('0x37')]);_0x55cb5d['filters']=_[_0x403f('0x38')](_0x55cb5d[_0x403f('0x35')],_0x55cb5d[_0x403f('0x37')]);_0x5793eb[_0x403f('0x39')]=_[_0x403f('0x38')](_0x55cb5d[_0x403f('0x35')],qs[_0x403f('0x3a')](_0x1c7f41['query'][_0x403f('0x3a')]));_0x5793eb[_0x403f('0x39')]=_0x5793eb['attributes'][_0x403f('0x3b')]?_0x5793eb['attributes']:_0x55cb5d['model'];if(!_0x1c7f41['query'][_0x403f('0x3c')](_0x403f('0x3d'))){_0x5793eb[_0x403f('0x20')]=qs[_0x403f('0x20')](_0x1c7f41[_0x403f('0x37')][_0x403f('0x20')]);_0x5793eb[_0x403f('0x1d')]=qs[_0x403f('0x1d')](_0x1c7f41['query'][_0x403f('0x1d')]);}_0x5793eb[_0x403f('0x3e')]=qs[_0x403f('0x3f')](_0x1c7f41['query']['sort']);_0x5793eb['where']=qs[_0x403f('0x40')](_[_0x403f('0x41')](_0x1c7f41[_0x403f('0x37')],_0x55cb5d['filters']),_0x3a9a4b);if(_0x1c7f41[_0x403f('0x37')][_0x403f('0x42')]){_0x5793eb[_0x403f('0x43')]=_[_0x403f('0x44')](_0x5793eb[_0x403f('0x43')],{'$or':_['map'](_0x3a9a4b,function(_0x4ae18c){if(_0x4ae18c[_0x403f('0x33')]!=='VIRTUAL'){var _0x17f0f4={};_0x17f0f4[_0x4ae18c['name']]={'$like':'%'+_0x1c7f41[_0x403f('0x37')][_0x403f('0x42')]+'%'};return _0x17f0f4;}})});}_0x5793eb=_['merge']({},_0x5793eb,_0x1c7f41[_0x403f('0x45')]);var _0x30da2b={'where':_0x5793eb[_0x403f('0x43')]};return db['Schedule'][_0x403f('0x1f')](_0x30da2b)[_0x403f('0x26')](function(_0x24c37e){_0x386611[_0x403f('0x1f')]=_0x24c37e;if(_0x1c7f41[_0x403f('0x37')][_0x403f('0x46')]){_0x5793eb[_0x403f('0x47')]=[{'all':!![]}];}return db['Schedule']['findAll'](_0x5793eb);})[_0x403f('0x26')](function(_0x5d8101){_0x386611[_0x403f('0x48')]=_0x5d8101;return _0x386611;})[_0x403f('0x26')](respondWithFilteredResult(_0x306dbb,_0x5793eb))['catch'](handleError(_0x306dbb,null));};exports[_0x403f('0x49')]=function(_0x52901b,_0x2346e3){var _0xc31c98={'raw':![],'where':{'id':_0x52901b[_0x403f('0x4a')]['id']}},_0x51b7eb={};_0x51b7eb[_0x403f('0x35')]=_[_0x403f('0x36')](db[_0x403f('0x4b')]['rawAttributes']);_0x51b7eb[_0x403f('0x37')]=_[_0x403f('0x36')](_0x52901b[_0x403f('0x37')]);_0x51b7eb[_0x403f('0x40')]=_['intersection'](_0x51b7eb['model'],_0x51b7eb[_0x403f('0x37')]);_0xc31c98[_0x403f('0x39')]=_[_0x403f('0x38')](_0x51b7eb[_0x403f('0x35')],qs[_0x403f('0x3a')](_0x52901b['query'][_0x403f('0x3a')]));_0xc31c98[_0x403f('0x39')]=_0xc31c98[_0x403f('0x39')]['length']?_0xc31c98[_0x403f('0x39')]:_0x51b7eb['model'];if(_0x52901b[_0x403f('0x37')][_0x403f('0x46')]){_0xc31c98['include']=[{'all':!![]}];}_0xc31c98=_[_0x403f('0x44')]({},_0xc31c98,_0x52901b[_0x403f('0x45')]);return db[_0x403f('0x4b')][_0x403f('0x4c')](_0xc31c98)[_0x403f('0x26')](handleEntityNotFound(_0x2346e3,null))[_0x403f('0x26')](respondWithResult(_0x2346e3,null))[_0x403f('0x4d')](handleError(_0x2346e3,null));};exports['create']=function(_0x2febdd,_0x1b9101){return db[_0x403f('0x4b')][_0x403f('0x4e')](_0x2febdd[_0x403f('0x4f')],{})[_0x403f('0x26')](function(_0x5d12e6){var _0x224f2f=_0x2febdd['user'][_0x403f('0x28')]({'plain':!![]});if(!_0x224f2f)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x224f2f[_0x403f('0x50')]==='user'){var _0x46d865=_0x5d12e6[_0x403f('0x28')]({'plain':!![]});var _0xd3da08=_0x403f('0x29');return db[_0x403f('0x51')][_0x403f('0x4c')]({'where':{'name':_0xd3da08,'userProfileId':_0x224f2f[_0x403f('0x52')]},'raw':!![]})[_0x403f('0x26')](function(_0x3bb965){if(_0x3bb965&&_0x3bb965[_0x403f('0x53')]===0x0){return db['UserProfileResource'][_0x403f('0x4e')]({'name':_0x46d865['name'],'resourceId':_0x46d865['id'],'type':_0x3bb965[_0x403f('0x2e')],'sectionId':_0x3bb965['id']},{})[_0x403f('0x26')](function(){return _0x5d12e6;});}else{return _0x5d12e6;}})[_0x403f('0x4d')](function(_0xa24407){logger[_0x403f('0x2c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xa24407);throw _0xa24407;});}return _0x5d12e6;})[_0x403f('0x26')](respondWithResult(_0x1b9101,0xc9))['catch'](handleError(_0x1b9101,null));};exports[_0x403f('0x25')]=function(_0x431708,_0x3679de){if(_0x431708['body']['id']){delete _0x431708['body']['id'];}return db[_0x403f('0x4b')][_0x403f('0x4c')]({'where':{'id':_0x431708[_0x403f('0x4a')]['id']}})['then'](handleEntityNotFound(_0x3679de,null))[_0x403f('0x26')](saveUpdates(_0x431708[_0x403f('0x4f')],null))[_0x403f('0x26')](respondWithResult(_0x3679de,null))['catch'](handleError(_0x3679de,null));};exports[_0x403f('0x27')]=function(_0x5c101b,_0x3e71e6){return db[_0x403f('0x4b')][_0x403f('0x4c')]({'where':{'id':_0x5c101b[_0x403f('0x4a')]['id']}})[_0x403f('0x26')](handleEntityNotFound(_0x3e71e6,null))[_0x403f('0x26')](removeEntity(_0x3e71e6,null))[_0x403f('0x4d')](handleError(_0x3e71e6,null));};exports[_0x403f('0x54')]=function(_0x2616de,_0xf94f68,_0x5584b4){var _0x4b8e07=require(_0x403f('0x55'));return db[_0x403f('0x4b')]['find']({'where':{'id':_0x2616de['params']['id']},'raw':!![]})['then'](handleEntityNotFound(_0xf94f68,null))[_0x403f('0x26')](function(){_0x4b8e07[_0x403f('0x54')](_0x2616de[_0x403f('0x4a')]['id']);})[_0x403f('0x26')](respondWithStatusCode(_0xf94f68,null))[_0x403f('0x4d')](handleError(_0xf94f68,null));};
\ No newline at end of file