Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / variable / variable.controller.js
index 045c836..3a0705b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbb9c=['path','to-csv','ejs','fs-extra','squel','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','apply','reject','update','then','destroy','UserProfileResource','stack','name','send','map','Variable','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','include','findAll','rows','catch','show','params','includeAll','find','create','body','user','get','role','Variables','userProfileId','autoAssociation','rimraf','zip-dir','request-promise','bluebird','mustache','util'];(function(_0x827aa0,_0x26f731){var _0x5a8a43=function(_0x6dff55){while(--_0x6dff55){_0x827aa0['push'](_0x827aa0['shift']());}};_0x5a8a43(++_0x26f731);}(_0xbb9c,0x1d4));var _0xcbb9=function(_0x3a902a,_0xca8442){_0x3a902a=_0x3a902a-0x0;var _0x24f2d5=_0xbb9c[_0x3a902a];return _0x24f2d5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xcbb9('0x0'));var zipdir=require(_0xcbb9('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xcbb9('0x2'));var moment=require('moment');var BPromise=require(_0xcbb9('0x3'));var Mustache=require(_0xcbb9('0x4'));var util=require(_0xcbb9('0x5'));var path=require(_0xcbb9('0x6'));var sox=require('sox');var csv=require(_0xcbb9('0x7'));var ejs=require(_0xcbb9('0x8'));var fs=require('fs');var fs_extra=require(_0xcbb9('0x9'));var _=require('lodash');var squel=require(_0xcbb9('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xcbb9('0x7'));var querystring=require(_0xcbb9('0xb'));var Papa=require(_0xcbb9('0xc'));var Redis=require(_0xcbb9('0xd'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xcbb9('0xe'));var hardwareService=require(_0xcbb9('0xf'));var logger=require(_0xcbb9('0x10'))(_0xcbb9('0x11'));var utils=require(_0xcbb9('0x12'));var config=require(_0xcbb9('0x13'));var licenseUtil=require(_0xcbb9('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3d6e5c,_0xd7da87){_0xd7da87=_0xd7da87||0xcc;return function(_0x580431){if(_0x580431){return _0x3d6e5c[_0xcbb9('0x15')](_0xd7da87);}return _0x3d6e5c[_0xcbb9('0x16')](_0xd7da87)[_0xcbb9('0x17')]();};}function respondWithResult(_0x1d6c57,_0x5e5005){_0x5e5005=_0x5e5005||0xc8;return function(_0x21333f){if(_0x21333f){return _0x1d6c57['status'](_0x5e5005)['json'](_0x21333f);}};}function respondWithFilteredResult(_0x16b695,_0x43ce95){return function(_0x3ad523){if(_0x3ad523){var _0x1783b4=typeof _0x43ce95['offset']===_0xcbb9('0x18')&&typeof _0x43ce95[_0xcbb9('0x19')]==='undefined';var _0x390869=_0x3ad523[_0xcbb9('0x1a')];var _0x2e8d84=_0x1783b4?0x0:_0x43ce95[_0xcbb9('0x1b')];var _0x33b5e3=_0x1783b4?_0x3ad523[_0xcbb9('0x1a')]:_0x43ce95['offset']+_0x43ce95[_0xcbb9('0x19')];var _0x324648;if(_0x33b5e3>=_0x390869){_0x33b5e3=_0x390869;_0x324648=0xc8;}else{_0x324648=0xce;}_0x16b695[_0xcbb9('0x16')](_0x324648);return _0x16b695[_0xcbb9('0x1c')](_0xcbb9('0x1d'),_0x2e8d84+'-'+_0x33b5e3+'/'+_0x390869)[_0xcbb9('0x1e')](_0x3ad523);}return null;};}function patchUpdates(_0x103007){return function(_0x49f2c0){try{jsonpatch[_0xcbb9('0x1f')](_0x49f2c0,_0x103007,!![]);}catch(_0x421302){return BPromise[_0xcbb9('0x20')](_0x421302);}return _0x49f2c0['save']();};}function saveUpdates(_0x49361f,_0x3196c0){return function(_0x24415a){if(_0x24415a){return _0x24415a[_0xcbb9('0x21')](_0x49361f)[_0xcbb9('0x22')](function(_0x1b4ec2){return _0x1b4ec2;});}return null;};}function removeEntity(_0x40f53d,_0x3e1a90){return function(_0x2eaafb){if(_0x2eaafb){return _0x2eaafb[_0xcbb9('0x23')]()[_0xcbb9('0x22')](function(){var _0x4a70b4=_0x2eaafb['get']({'plain':!![]});var _0x395eac='Variables';return db[_0xcbb9('0x24')][_0xcbb9('0x23')]({'where':{'type':_0x395eac,'resourceId':_0x4a70b4['id']}})[_0xcbb9('0x22')](function(){return _0x2eaafb;});})[_0xcbb9('0x22')](function(){_0x40f53d[_0xcbb9('0x16')](0xcc)[_0xcbb9('0x17')]();});}};}function handleEntityNotFound(_0x3672d2,_0x477e7a){return function(_0x1aa6fc){if(!_0x1aa6fc){_0x3672d2[_0xcbb9('0x15')](0x194);}return _0x1aa6fc;};}function handleError(_0x28bc76,_0x3c5f30){_0x3c5f30=_0x3c5f30||0x1f4;return function(_0x139ca1){logger['error'](_0x139ca1[_0xcbb9('0x25')]);if(_0x139ca1['name']){delete _0x139ca1[_0xcbb9('0x26')];}_0x28bc76[_0xcbb9('0x16')](_0x3c5f30)[_0xcbb9('0x27')](_0x139ca1);};}exports['index']=function(_0x23a017,_0x127d41){var _0x1da148={},_0x1abb8d={},_0x3a7d6f={'count':0x0,'rows':[]};var _0x2b611b=_[_0xcbb9('0x28')](db[_0xcbb9('0x29')][_0xcbb9('0x2a')],function(_0x1f94ec){return{'name':_0x1f94ec[_0xcbb9('0x2b')],'type':_0x1f94ec['type']['key']};});_0x1abb8d[_0xcbb9('0x2c')]=_[_0xcbb9('0x28')](_0x2b611b,_0xcbb9('0x26'));_0x1abb8d[_0xcbb9('0x2d')]=_[_0xcbb9('0x2e')](_0x23a017[_0xcbb9('0x2d')]);_0x1abb8d[_0xcbb9('0x2f')]=_[_0xcbb9('0x30')](_0x1abb8d['model'],_0x1abb8d[_0xcbb9('0x2d')]);_0x1da148[_0xcbb9('0x31')]=_[_0xcbb9('0x30')](_0x1abb8d['model'],qs[_0xcbb9('0x32')](_0x23a017[_0xcbb9('0x2d')][_0xcbb9('0x32')]));_0x1da148[_0xcbb9('0x31')]=_0x1da148[_0xcbb9('0x31')][_0xcbb9('0x33')]?_0x1da148[_0xcbb9('0x31')]:_0x1abb8d[_0xcbb9('0x2c')];if(!_0x23a017[_0xcbb9('0x2d')][_0xcbb9('0x34')](_0xcbb9('0x35'))){_0x1da148[_0xcbb9('0x19')]=qs['limit'](_0x23a017[_0xcbb9('0x2d')][_0xcbb9('0x19')]);_0x1da148[_0xcbb9('0x1b')]=qs[_0xcbb9('0x1b')](_0x23a017['query'][_0xcbb9('0x1b')]);}_0x1da148[_0xcbb9('0x36')]=qs[_0xcbb9('0x37')](_0x23a017[_0xcbb9('0x2d')][_0xcbb9('0x37')]);_0x1da148[_0xcbb9('0x38')]=qs['filters'](_[_0xcbb9('0x39')](_0x23a017['query'],_0x1abb8d[_0xcbb9('0x2f')]),_0x2b611b);if(_0x23a017[_0xcbb9('0x2d')][_0xcbb9('0x3a')]){_0x1da148[_0xcbb9('0x38')]=_[_0xcbb9('0x3b')](_0x1da148[_0xcbb9('0x38')],{'$or':_[_0xcbb9('0x28')](_0x2b611b,function(_0x257178){if(_0x257178[_0xcbb9('0x3c')]!==_0xcbb9('0x3d')){var _0x18d606={};_0x18d606[_0x257178['name']]={'$like':'%'+_0x23a017[_0xcbb9('0x2d')]['filter']+'%'};return _0x18d606;}})});}_0x1da148=_[_0xcbb9('0x3b')]({},_0x1da148,_0x23a017[_0xcbb9('0x3e')]);var _0x1ec241={'where':_0x1da148[_0xcbb9('0x38')]};return db[_0xcbb9('0x29')][_0xcbb9('0x1a')](_0x1ec241)['then'](function(_0x6b53df){_0x3a7d6f[_0xcbb9('0x1a')]=_0x6b53df;if(_0x23a017[_0xcbb9('0x2d')]['includeAll']){_0x1da148[_0xcbb9('0x3f')]=[{'all':!![]}];}return db[_0xcbb9('0x29')][_0xcbb9('0x40')](_0x1da148);})['then'](function(_0x16c429){_0x3a7d6f[_0xcbb9('0x41')]=_0x16c429;return _0x3a7d6f;})[_0xcbb9('0x22')](respondWithFilteredResult(_0x127d41,_0x1da148))[_0xcbb9('0x42')](handleError(_0x127d41,null));};exports[_0xcbb9('0x43')]=function(_0x22414a,_0x44ac30){var _0x4be299={'raw':!![],'where':{'id':_0x22414a[_0xcbb9('0x44')]['id']}},_0x29ea2c={};_0x29ea2c[_0xcbb9('0x2c')]=_[_0xcbb9('0x2e')](db[_0xcbb9('0x29')][_0xcbb9('0x2a')]);_0x29ea2c[_0xcbb9('0x2d')]=_[_0xcbb9('0x2e')](_0x22414a[_0xcbb9('0x2d')]);_0x29ea2c[_0xcbb9('0x2f')]=_[_0xcbb9('0x30')](_0x29ea2c[_0xcbb9('0x2c')],_0x29ea2c[_0xcbb9('0x2d')]);_0x4be299['attributes']=_[_0xcbb9('0x30')](_0x29ea2c['model'],qs[_0xcbb9('0x32')](_0x22414a['query']['fields']));_0x4be299[_0xcbb9('0x31')]=_0x4be299[_0xcbb9('0x31')][_0xcbb9('0x33')]?_0x4be299[_0xcbb9('0x31')]:_0x29ea2c['model'];if(_0x22414a['query'][_0xcbb9('0x45')]){_0x4be299[_0xcbb9('0x3f')]=[{'all':!![]}];}_0x4be299=_[_0xcbb9('0x3b')]({},_0x4be299,_0x22414a[_0xcbb9('0x3e')]);return db['Variable'][_0xcbb9('0x46')](_0x4be299)[_0xcbb9('0x22')](handleEntityNotFound(_0x44ac30,null))[_0xcbb9('0x22')](respondWithResult(_0x44ac30,null))[_0xcbb9('0x42')](handleError(_0x44ac30,null));};exports[_0xcbb9('0x47')]=function(_0x3a078e,_0x230ff7){return db[_0xcbb9('0x29')]['create'](_0x3a078e[_0xcbb9('0x48')],{})[_0xcbb9('0x22')](function(_0x213dfa){var _0x242059=_0x3a078e[_0xcbb9('0x49')][_0xcbb9('0x4a')]({'plain':!![]});if(!_0x242059)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x242059[_0xcbb9('0x4b')]===_0xcbb9('0x49')){var _0x3db57d=_0x213dfa['get']({'plain':!![]});var _0x1a43e8=_0xcbb9('0x4c');return db['UserProfileSection']['find']({'where':{'name':_0x1a43e8,'userProfileId':_0x242059[_0xcbb9('0x4d')]},'raw':!![]})[_0xcbb9('0x22')](function(_0xaccf8f){if(_0xaccf8f&&_0xaccf8f[_0xcbb9('0x4e')]===0x0){return db[_0xcbb9('0x24')][_0xcbb9('0x47')]({'name':_0x3db57d[_0xcbb9('0x26')],'resourceId':_0x3db57d['id'],'type':_0xaccf8f[_0xcbb9('0x26')],'sectionId':_0xaccf8f['id']},{})[_0xcbb9('0x22')](function(){return _0x213dfa;});}else{return _0x213dfa;}})[_0xcbb9('0x42')](function(_0x2f2ef){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2f2ef);throw _0x2f2ef;});}return _0x213dfa;})[_0xcbb9('0x22')](respondWithResult(_0x230ff7,0xc9))['catch'](handleError(_0x230ff7,null));};exports[_0xcbb9('0x21')]=function(_0x383c58,_0xb0a56a){if(_0x383c58[_0xcbb9('0x48')]['id']){delete _0x383c58[_0xcbb9('0x48')]['id'];}return db[_0xcbb9('0x29')]['find']({'where':{'id':_0x383c58['params']['id']}})['then'](handleEntityNotFound(_0xb0a56a,null))[_0xcbb9('0x22')](saveUpdates(_0x383c58['body'],null))[_0xcbb9('0x22')](respondWithResult(_0xb0a56a,null))[_0xcbb9('0x42')](handleError(_0xb0a56a,null));};exports[_0xcbb9('0x23')]=function(_0x287666,_0x4132ca){return db[_0xcbb9('0x29')]['find']({'where':{'id':_0x287666[_0xcbb9('0x44')]['id']}})['then'](handleEntityNotFound(_0x4132ca,null))[_0xcbb9('0x22')](removeEntity(_0x4132ca,null))[_0xcbb9('0x42')](handleError(_0x4132ca,null));};
\ No newline at end of file
+var _0xf422=['destroy','get','UserProfileResource','error','stack','send','index','Variable','rawAttributes','fieldName','type','model','map','name','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','options','includeAll','include','findAll','rows','show','params','find','catch','create','body','user','Variables','UserProfileSection','userProfileId','autoAssociation','update','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','reject','then'];(function(_0x5c12f2,_0x5de043){var _0x5e8344=function(_0x445932){while(--_0x445932){_0x5c12f2['push'](_0x5c12f2['shift']());}};_0x5e8344(++_0x5de043);}(_0xf422,0x129));var _0x2f42=function(_0x2340dc,_0x8d1444){_0x2340dc=_0x2340dc-0x0;var _0x2f26ad=_0xf422[_0x2340dc];return _0x2f26ad;};'use strict';var emlformat=require(_0x2f42('0x0'));var rimraf=require(_0x2f42('0x1'));var zipdir=require(_0x2f42('0x2'));var jsonpatch=require(_0x2f42('0x3'));var rp=require(_0x2f42('0x4'));var moment=require(_0x2f42('0x5'));var BPromise=require(_0x2f42('0x6'));var Mustache=require(_0x2f42('0x7'));var util=require(_0x2f42('0x8'));var path=require(_0x2f42('0x9'));var sox=require(_0x2f42('0xa'));var csv=require(_0x2f42('0xb'));var ejs=require(_0x2f42('0xc'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x2f42('0xd'));var squel=require(_0x2f42('0xe'));var crypto=require('crypto');var jsforce=require(_0x2f42('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x2f42('0xb'));var querystring=require(_0x2f42('0x10'));var Papa=require(_0x2f42('0x11'));var Redis=require(_0x2f42('0x12'));var authService=require(_0x2f42('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x2f42('0x14'));var logger=require('../../config/logger')(_0x2f42('0x15'));var utils=require(_0x2f42('0x16'));var config=require(_0x2f42('0x17'));var licenseUtil=require(_0x2f42('0x18'));var db=require(_0x2f42('0x19'))['db'];function respondWithStatusCode(_0x5a1d66,_0x74f88d){_0x74f88d=_0x74f88d||0xcc;return function(_0x5938de){if(_0x5938de){return _0x5a1d66[_0x2f42('0x1a')](_0x74f88d);}return _0x5a1d66[_0x2f42('0x1b')](_0x74f88d)[_0x2f42('0x1c')]();};}function respondWithResult(_0x552780,_0x55022f){_0x55022f=_0x55022f||0xc8;return function(_0x365f31){if(_0x365f31){return _0x552780[_0x2f42('0x1b')](_0x55022f)[_0x2f42('0x1d')](_0x365f31);}};}function respondWithFilteredResult(_0x59a793,_0x1056bf){return function(_0x4a9979){if(_0x4a9979){var _0x54dde5=typeof _0x1056bf['offset']==='undefined'&&typeof _0x1056bf[_0x2f42('0x1e')]===_0x2f42('0x1f');var _0x5407e2=_0x4a9979[_0x2f42('0x20')];var _0x2b5bf1=_0x54dde5?0x0:_0x1056bf[_0x2f42('0x21')];var _0x813c44=_0x54dde5?_0x4a9979[_0x2f42('0x20')]:_0x1056bf[_0x2f42('0x21')]+_0x1056bf[_0x2f42('0x1e')];var _0x518c9a;if(_0x813c44>=_0x5407e2){_0x813c44=_0x5407e2;_0x518c9a=0xc8;}else{_0x518c9a=0xce;}_0x59a793[_0x2f42('0x1b')](_0x518c9a);return _0x59a793[_0x2f42('0x22')](_0x2f42('0x23'),_0x2b5bf1+'-'+_0x813c44+'/'+_0x5407e2)[_0x2f42('0x1d')](_0x4a9979);}return null;};}function patchUpdates(_0x442c2c){return function(_0x158f00){try{jsonpatch[_0x2f42('0x24')](_0x158f00,_0x442c2c,!![]);}catch(_0x5c8772){return BPromise[_0x2f42('0x25')](_0x5c8772);}return _0x158f00['save']();};}function saveUpdates(_0x2ecf95,_0x14d982){return function(_0x32e485){if(_0x32e485){return _0x32e485['update'](_0x2ecf95)[_0x2f42('0x26')](function(_0x19c93e){return _0x19c93e;});}return null;};}function removeEntity(_0x2510bb,_0x3346be){return function(_0x4630ea){if(_0x4630ea){return _0x4630ea[_0x2f42('0x27')]()[_0x2f42('0x26')](function(){var _0x1848d3=_0x4630ea[_0x2f42('0x28')]({'plain':!![]});var _0x16d8b7='Variables';return db[_0x2f42('0x29')][_0x2f42('0x27')]({'where':{'type':_0x16d8b7,'resourceId':_0x1848d3['id']}})[_0x2f42('0x26')](function(){return _0x4630ea;});})[_0x2f42('0x26')](function(){_0x2510bb['status'](0xcc)[_0x2f42('0x1c')]();});}};}function handleEntityNotFound(_0x5b30a2,_0x475581){return function(_0x282845){if(!_0x282845){_0x5b30a2[_0x2f42('0x1a')](0x194);}return _0x282845;};}function handleError(_0x1e44e3,_0x1ac964){_0x1ac964=_0x1ac964||0x1f4;return function(_0x293779){logger[_0x2f42('0x2a')](_0x293779[_0x2f42('0x2b')]);if(_0x293779['name']){delete _0x293779['name'];}_0x1e44e3[_0x2f42('0x1b')](_0x1ac964)[_0x2f42('0x2c')](_0x293779);};}exports[_0x2f42('0x2d')]=function(_0x3a1c48,_0x47d5a3){var _0x39586d={},_0x357cd5={},_0x321b1b={'count':0x0,'rows':[]};var _0x23d2b6=_['map'](db[_0x2f42('0x2e')][_0x2f42('0x2f')],function(_0x4fa952){return{'name':_0x4fa952[_0x2f42('0x30')],'type':_0x4fa952[_0x2f42('0x31')]['key']};});_0x357cd5[_0x2f42('0x32')]=_[_0x2f42('0x33')](_0x23d2b6,_0x2f42('0x34'));_0x357cd5[_0x2f42('0x35')]=_[_0x2f42('0x36')](_0x3a1c48['query']);_0x357cd5[_0x2f42('0x37')]=_['intersection'](_0x357cd5[_0x2f42('0x32')],_0x357cd5[_0x2f42('0x35')]);_0x39586d[_0x2f42('0x38')]=_[_0x2f42('0x39')](_0x357cd5[_0x2f42('0x32')],qs[_0x2f42('0x3a')](_0x3a1c48['query'][_0x2f42('0x3a')]));_0x39586d[_0x2f42('0x38')]=_0x39586d[_0x2f42('0x38')][_0x2f42('0x3b')]?_0x39586d[_0x2f42('0x38')]:_0x357cd5[_0x2f42('0x32')];if(!_0x3a1c48[_0x2f42('0x35')][_0x2f42('0x3c')](_0x2f42('0x3d'))){_0x39586d[_0x2f42('0x1e')]=qs[_0x2f42('0x1e')](_0x3a1c48[_0x2f42('0x35')][_0x2f42('0x1e')]);_0x39586d['offset']=qs[_0x2f42('0x21')](_0x3a1c48[_0x2f42('0x35')][_0x2f42('0x21')]);}_0x39586d[_0x2f42('0x3e')]=qs[_0x2f42('0x3f')](_0x3a1c48[_0x2f42('0x35')][_0x2f42('0x3f')]);_0x39586d[_0x2f42('0x40')]=qs['filters'](_['pick'](_0x3a1c48[_0x2f42('0x35')],_0x357cd5[_0x2f42('0x37')]),_0x23d2b6);if(_0x3a1c48['query']['filter']){_0x39586d['where']=_['merge'](_0x39586d['where'],{'$or':_[_0x2f42('0x33')](_0x23d2b6,function(_0x4d62e9){if(_0x4d62e9[_0x2f42('0x31')]!=='VIRTUAL'){var _0x3aa2eb={};_0x3aa2eb[_0x4d62e9[_0x2f42('0x34')]]={'$like':'%'+_0x3a1c48[_0x2f42('0x35')][_0x2f42('0x41')]+'%'};return _0x3aa2eb;}})});}_0x39586d=_[_0x2f42('0x42')]({},_0x39586d,_0x3a1c48[_0x2f42('0x43')]);var _0xf383e8={'where':_0x39586d[_0x2f42('0x40')]};return db[_0x2f42('0x2e')][_0x2f42('0x20')](_0xf383e8)['then'](function(_0x3d5994){_0x321b1b[_0x2f42('0x20')]=_0x3d5994;if(_0x3a1c48['query'][_0x2f42('0x44')]){_0x39586d[_0x2f42('0x45')]=[{'all':!![]}];}return db[_0x2f42('0x2e')][_0x2f42('0x46')](_0x39586d);})[_0x2f42('0x26')](function(_0x2a3003){_0x321b1b[_0x2f42('0x47')]=_0x2a3003;return _0x321b1b;})[_0x2f42('0x26')](respondWithFilteredResult(_0x47d5a3,_0x39586d))['catch'](handleError(_0x47d5a3,null));};exports[_0x2f42('0x48')]=function(_0xcd4852,_0x4dbc30){var _0x34a75e={'raw':!![],'where':{'id':_0xcd4852[_0x2f42('0x49')]['id']}},_0x32b011={};_0x32b011[_0x2f42('0x32')]=_[_0x2f42('0x36')](db[_0x2f42('0x2e')][_0x2f42('0x2f')]);_0x32b011['query']=_[_0x2f42('0x36')](_0xcd4852['query']);_0x32b011[_0x2f42('0x37')]=_[_0x2f42('0x39')](_0x32b011[_0x2f42('0x32')],_0x32b011[_0x2f42('0x35')]);_0x34a75e[_0x2f42('0x38')]=_['intersection'](_0x32b011[_0x2f42('0x32')],qs[_0x2f42('0x3a')](_0xcd4852[_0x2f42('0x35')][_0x2f42('0x3a')]));_0x34a75e[_0x2f42('0x38')]=_0x34a75e[_0x2f42('0x38')][_0x2f42('0x3b')]?_0x34a75e[_0x2f42('0x38')]:_0x32b011[_0x2f42('0x32')];if(_0xcd4852[_0x2f42('0x35')][_0x2f42('0x44')]){_0x34a75e[_0x2f42('0x45')]=[{'all':!![]}];}_0x34a75e=_[_0x2f42('0x42')]({},_0x34a75e,_0xcd4852[_0x2f42('0x43')]);return db['Variable'][_0x2f42('0x4a')](_0x34a75e)[_0x2f42('0x26')](handleEntityNotFound(_0x4dbc30,null))[_0x2f42('0x26')](respondWithResult(_0x4dbc30,null))[_0x2f42('0x4b')](handleError(_0x4dbc30,null));};exports['create']=function(_0x28f1c6,_0x148492){return db[_0x2f42('0x2e')][_0x2f42('0x4c')](_0x28f1c6[_0x2f42('0x4d')],{})[_0x2f42('0x26')](function(_0x476cfb){var _0x2a14ac=_0x28f1c6[_0x2f42('0x4e')]['get']({'plain':!![]});if(!_0x2a14ac)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2a14ac['role']===_0x2f42('0x4e')){var _0x54b737=_0x476cfb[_0x2f42('0x28')]({'plain':!![]});var _0xbf3456=_0x2f42('0x4f');return db[_0x2f42('0x50')]['find']({'where':{'name':_0xbf3456,'userProfileId':_0x2a14ac[_0x2f42('0x51')]},'raw':!![]})['then'](function(_0x199157){if(_0x199157&&_0x199157[_0x2f42('0x52')]===0x0){return db['UserProfileResource'][_0x2f42('0x4c')]({'name':_0x54b737['name'],'resourceId':_0x54b737['id'],'type':_0x199157[_0x2f42('0x34')],'sectionId':_0x199157['id']},{})[_0x2f42('0x26')](function(){return _0x476cfb;});}else{return _0x476cfb;}})[_0x2f42('0x4b')](function(_0xf5b22f){logger[_0x2f42('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xf5b22f);throw _0xf5b22f;});}return _0x476cfb;})[_0x2f42('0x26')](respondWithResult(_0x148492,0xc9))[_0x2f42('0x4b')](handleError(_0x148492,null));};exports[_0x2f42('0x53')]=function(_0x34b929,_0x49a793){if(_0x34b929[_0x2f42('0x4d')]['id']){delete _0x34b929[_0x2f42('0x4d')]['id'];}return db['Variable'][_0x2f42('0x4a')]({'where':{'id':_0x34b929[_0x2f42('0x49')]['id']}})[_0x2f42('0x26')](handleEntityNotFound(_0x49a793,null))[_0x2f42('0x26')](saveUpdates(_0x34b929[_0x2f42('0x4d')],null))[_0x2f42('0x26')](respondWithResult(_0x49a793,null))['catch'](handleError(_0x49a793,null));};exports[_0x2f42('0x27')]=function(_0x21c641,_0x33ccb8){return db[_0x2f42('0x2e')][_0x2f42('0x4a')]({'where':{'id':_0x21c641[_0x2f42('0x49')]['id']}})[_0x2f42('0x26')](handleEntityNotFound(_0x33ccb8,null))[_0x2f42('0x26')](removeEntity(_0x33ccb8,null))[_0x2f42('0x4b')](handleError(_0x33ccb8,null));};
\ No newline at end of file