Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / squareOdbc / squareOdbc.controller.js
index 4cd2612..00393bb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf34f=['fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','then','destroy','get','ODBC','UserProfileResource','error','name','send','index','map','SquareOdbc','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','order','where','pick','filter','merge','VIRTUAL','options','count','includeAll','include','findAll','rows','catch','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','update','dsn','html-pdf','eml-format','rimraf','zip-dir'];(function(_0x812cf2,_0x1db171){var _0x19a552=function(_0x45c3d8){while(--_0x45c3d8){_0x812cf2['push'](_0x812cf2['shift']());}};_0x19a552(++_0x1db171);}(_0xf34f,0x1a5));var _0xff34=function(_0x100f1a,_0x4e35f9){_0x100f1a=_0x100f1a-0x0;var _0x2f5fa3=_0xf34f[_0x100f1a];return _0x2f5fa3;};'use strict';var pdf=require(_0xff34('0x0'));var emlformat=require(_0xff34('0x1'));var rimraf=require(_0xff34('0x2'));var zipdir=require(_0xff34('0x3'));var jsonpatch=require(_0xff34('0x4'));var rp=require(_0xff34('0x5'));var moment=require(_0xff34('0x6'));var BPromise=require('bluebird');var Mustache=require(_0xff34('0x7'));var util=require(_0xff34('0x8'));var path=require(_0xff34('0x9'));var sox=require(_0xff34('0xa'));var csv=require(_0xff34('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xff34('0xc'));var squel=require(_0xff34('0xd'));var crypto=require(_0xff34('0xe'));var jsforce=require(_0xff34('0xf'));var deskjs=require(_0xff34('0x10'));var toCsv=require(_0xff34('0xb'));var querystring=require(_0xff34('0x11'));var Papa=require(_0xff34('0x12'));var Redis=require(_0xff34('0x13'));var authService=require(_0xff34('0x14'));var qs=require(_0xff34('0x15'));var as=require(_0xff34('0x16'));var hardwareService=require(_0xff34('0x17'));var logger=require('../../config/logger')(_0xff34('0x18'));var utils=require('../../config/utils');var config=require(_0xff34('0x19'));var licenseUtil=require(_0xff34('0x1a'));var db=require(_0xff34('0x1b'))['db'];function respondWithStatusCode(_0x1fb3b2,_0x555d44){_0x555d44=_0x555d44||0xcc;return function(_0x33eb9f){if(_0x33eb9f){return _0x1fb3b2[_0xff34('0x1c')](_0x555d44);}return _0x1fb3b2[_0xff34('0x1d')](_0x555d44)[_0xff34('0x1e')]();};}function respondWithResult(_0x1f38ae,_0x357990){_0x357990=_0x357990||0xc8;return function(_0x1e255b){if(_0x1e255b){return _0x1f38ae[_0xff34('0x1d')](_0x357990)[_0xff34('0x1f')](_0x1e255b);}};}function respondWithFilteredResult(_0xc774a6,_0x2f3757){return function(_0x22203f){if(_0x22203f){var _0x4ca787=_0x22203f['count'],_0x3e10f8=_0x2f3757['offset'],_0x34164c=_0x2f3757[_0xff34('0x20')]+_0x2f3757[_0xff34('0x21')],_0x39ceca;if(_0x34164c>=_0x4ca787){_0x34164c=_0x4ca787;_0x39ceca=0xc8;}else{_0x39ceca=0xce;}_0xc774a6[_0xff34('0x1d')](_0x39ceca);return _0xc774a6[_0xff34('0x22')](_0xff34('0x23'),_0x3e10f8+'-'+_0x34164c+'/'+_0x4ca787)[_0xff34('0x1f')](_0x22203f);}return null;};}function patchUpdates(_0x2496c2){return function(_0x6d83a){try{jsonpatch[_0xff34('0x24')](_0x6d83a,_0x2496c2,!![]);}catch(_0x55800e){return BPromise['reject'](_0x55800e);}return _0x6d83a['save']();};}function saveUpdates(_0x3858bb,_0x1bf4aa){return function(_0x2e97eb){if(_0x2e97eb){return _0x2e97eb['update'](_0x3858bb)[_0xff34('0x25')](function(_0x24a598){return _0x24a598;});}return null;};}function removeEntity(_0x26724f,_0x29d688){return function(_0x517054){if(_0x517054){return _0x517054[_0xff34('0x26')]()['then'](function(){var _0x5bfc95=_0x517054[_0xff34('0x27')]({'plain':!![]});var _0x2c5415=_0xff34('0x28');return db[_0xff34('0x29')][_0xff34('0x26')]({'where':{'type':_0x2c5415,'resourceId':_0x5bfc95['id']}})[_0xff34('0x25')](function(){return _0x517054;});})['then'](function(){_0x26724f[_0xff34('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x547827,_0x3fe177){return function(_0x4be62e){if(!_0x4be62e){_0x547827[_0xff34('0x1c')](0x194);}return _0x4be62e;};}function handleError(_0x402c6d,_0x449fda){_0x449fda=_0x449fda||0x1f4;return function(_0x3ce456){logger[_0xff34('0x2a')](_0x3ce456['stack']);if(_0x3ce456[_0xff34('0x2b')]){delete _0x3ce456[_0xff34('0x2b')];}_0x402c6d[_0xff34('0x1d')](_0x449fda)[_0xff34('0x2c')](_0x3ce456);};}exports[_0xff34('0x2d')]=function(_0x44be8a,_0x378eed){var _0x32d9b6={},_0x4d9346={},_0x2df0d0={'count':0x0,'rows':[]};var _0x8802c7=_[_0xff34('0x2e')](db[_0xff34('0x2f')][_0xff34('0x30')],function(_0x4de3ab){return{'name':_0x4de3ab[_0xff34('0x31')],'type':_0x4de3ab[_0xff34('0x32')][_0xff34('0x33')]};});_0x4d9346[_0xff34('0x34')]=_[_0xff34('0x2e')](_0x8802c7,_0xff34('0x2b'));_0x4d9346[_0xff34('0x35')]=_[_0xff34('0x36')](_0x44be8a[_0xff34('0x35')]);_0x4d9346[_0xff34('0x37')]=_[_0xff34('0x38')](_0x4d9346[_0xff34('0x34')],_0x4d9346[_0xff34('0x35')]);_0x32d9b6[_0xff34('0x39')]=_[_0xff34('0x38')](_0x4d9346[_0xff34('0x34')],qs[_0xff34('0x3a')](_0x44be8a[_0xff34('0x35')][_0xff34('0x3a')]));_0x32d9b6[_0xff34('0x39')]=_0x32d9b6[_0xff34('0x39')][_0xff34('0x3b')]?_0x32d9b6[_0xff34('0x39')]:_0x4d9346[_0xff34('0x34')];if(!_0x44be8a['query']['hasOwnProperty']('nolimit')){_0x32d9b6[_0xff34('0x21')]=qs[_0xff34('0x21')](_0x44be8a['query']['limit']);_0x32d9b6[_0xff34('0x20')]=qs['offset'](_0x44be8a[_0xff34('0x35')][_0xff34('0x20')]);}_0x32d9b6[_0xff34('0x3c')]=qs['sort'](_0x44be8a[_0xff34('0x35')]['sort']);_0x32d9b6[_0xff34('0x3d')]=qs[_0xff34('0x37')](_[_0xff34('0x3e')](_0x44be8a[_0xff34('0x35')],_0x4d9346[_0xff34('0x37')]),_0x8802c7);if(_0x44be8a[_0xff34('0x35')][_0xff34('0x3f')]){_0x32d9b6[_0xff34('0x3d')]=_[_0xff34('0x40')](_0x32d9b6[_0xff34('0x3d')],{'$or':_[_0xff34('0x2e')](_0x8802c7,function(_0x4309eb){if(_0x4309eb[_0xff34('0x32')]!==_0xff34('0x41')){var _0x2527e9={};_0x2527e9[_0x4309eb[_0xff34('0x2b')]]={'$like':'%'+_0x44be8a[_0xff34('0x35')][_0xff34('0x3f')]+'%'};return _0x2527e9;}})});}_0x32d9b6=_[_0xff34('0x40')]({},_0x32d9b6,_0x44be8a[_0xff34('0x42')]);var _0x638135={'where':_0x32d9b6[_0xff34('0x3d')]};return db[_0xff34('0x2f')][_0xff34('0x43')](_0x638135)['then'](function(_0x1484f4){_0x2df0d0[_0xff34('0x43')]=_0x1484f4;if(_0x44be8a[_0xff34('0x35')][_0xff34('0x44')]){_0x32d9b6[_0xff34('0x45')]=[{'all':!![]}];}return db['SquareOdbc'][_0xff34('0x46')](_0x32d9b6);})[_0xff34('0x25')](function(_0x4d0716){_0x2df0d0[_0xff34('0x47')]=_0x4d0716;return _0x2df0d0;})[_0xff34('0x25')](respondWithFilteredResult(_0x378eed,_0x32d9b6))[_0xff34('0x48')](handleError(_0x378eed,null));};exports[_0xff34('0x49')]=function(_0x52f61f,_0x3e5956){var _0x3114f7={'raw':!![],'where':{'id':_0x52f61f[_0xff34('0x4a')]['id']}},_0x445cef={};_0x445cef[_0xff34('0x34')]=_[_0xff34('0x36')](db[_0xff34('0x2f')][_0xff34('0x30')]);_0x445cef[_0xff34('0x35')]=_[_0xff34('0x36')](_0x52f61f[_0xff34('0x35')]);_0x445cef[_0xff34('0x37')]=_['intersection'](_0x445cef[_0xff34('0x34')],_0x445cef[_0xff34('0x35')]);_0x3114f7[_0xff34('0x39')]=_['intersection'](_0x445cef[_0xff34('0x34')],qs[_0xff34('0x3a')](_0x52f61f[_0xff34('0x35')][_0xff34('0x3a')]));_0x3114f7[_0xff34('0x39')]=_0x3114f7['attributes'][_0xff34('0x3b')]?_0x3114f7[_0xff34('0x39')]:_0x445cef[_0xff34('0x34')];if(_0x52f61f[_0xff34('0x35')][_0xff34('0x44')]){_0x3114f7[_0xff34('0x45')]=[{'all':!![]}];}_0x3114f7=_['merge']({},_0x3114f7,_0x52f61f[_0xff34('0x42')]);return db[_0xff34('0x2f')][_0xff34('0x4b')](_0x3114f7)[_0xff34('0x25')](handleEntityNotFound(_0x3e5956,null))[_0xff34('0x25')](respondWithResult(_0x3e5956,null))['catch'](handleError(_0x3e5956,null));};exports[_0xff34('0x4c')]=function(_0x413bb,_0x330492){return db[_0xff34('0x2f')][_0xff34('0x4c')](_0x413bb[_0xff34('0x4d')],{})[_0xff34('0x25')](function(_0x4da902){var _0x4503b9=_0x413bb[_0xff34('0x4e')][_0xff34('0x27')]({'plain':!![]});if(!_0x4503b9)throw new Error(_0xff34('0x4f'));if(_0x4503b9['role']===_0xff34('0x4e')){var _0x4a754d=_0x4da902[_0xff34('0x27')]({'plain':!![]});var _0xf8957a=_0xff34('0x28');return db[_0xff34('0x50')][_0xff34('0x4b')]({'where':{'name':_0xf8957a,'userProfileId':_0x4503b9[_0xff34('0x51')]},'raw':!![]})['then'](function(_0x25e84b){if(_0x25e84b&&_0x25e84b[_0xff34('0x52')]===0x0){return db['UserProfileResource'][_0xff34('0x4c')]({'name':_0x4a754d['name'],'resourceId':_0x4a754d['id'],'type':_0x25e84b['name'],'sectionId':_0x25e84b['id']},{})[_0xff34('0x25')](function(){return _0x4da902;});}else{return _0x4da902;}})[_0xff34('0x48')](function(_0x3be212){logger[_0xff34('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x3be212);throw _0x3be212;});}return _0x4da902;})[_0xff34('0x25')](respondWithResult(_0x330492,0xc9))[_0xff34('0x48')](handleError(_0x330492,null));};exports[_0xff34('0x53')]=function(_0x1750af,_0x32d0f6){if(_0x1750af[_0xff34('0x4d')]['id']){delete _0x1750af['body']['id'];}return db[_0xff34('0x2f')]['find']({'where':{'id':_0x1750af[_0xff34('0x4a')]['id']}})[_0xff34('0x25')](handleEntityNotFound(_0x32d0f6,null))[_0xff34('0x25')](saveUpdates(_0x1750af[_0xff34('0x4d')],null))[_0xff34('0x25')](respondWithResult(_0x32d0f6,null))[_0xff34('0x48')](handleError(_0x32d0f6,null));};exports[_0xff34('0x26')]=function(_0x51415e,_0x45ca7c){return db[_0xff34('0x2f')][_0xff34('0x4b')]({'where':{'id':_0x51415e[_0xff34('0x4a')]['id']}})['then'](handleEntityNotFound(_0x45ca7c,null))[_0xff34('0x25')](removeEntity(_0x45ca7c,null))['catch'](handleError(_0x45ca7c,null));};exports['test']=function(_0x1d27e0,_0x61ed6,_0x414f73){var _0x2932d7;return db[_0xff34('0x2f')][_0xff34('0x4b')]({'where':{'id':_0x1d27e0[_0xff34('0x4a')]['id']},'attributes':['id',_0xff34('0x54')]})[_0xff34('0x25')](handleEntityNotFound(_0x61ed6,null))[_0xff34('0x25')](function(_0x5d3c8d){if(_0x5d3c8d){var _0x989395=require('odbc')();_0x989395['openSync'](_0x5d3c8d['dsn']);_0x989395['closeSync']();return _0x5d3c8d;}})[_0xff34('0x25')](respondWithResult(_0x61ed6,null))[_0xff34('0x48')](handleError(_0x61ed6,null));};
\ No newline at end of file
+var _0x5b80=['sort','where','filters','pick','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','userProfileId','autoAssociation','UserProfileResource','update','test','dsn','closeSync','request-promise','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','destroy','then','ODBC','sendStatus','error','stack','name','index','SquareOdbc','rawAttributes','key','map','query','intersection','model','attributes','fields','hasOwnProperty','nolimit','order'];(function(_0x1978f8,_0x5dc5b0){var _0x285d93=function(_0x20656e){while(--_0x20656e){_0x1978f8['push'](_0x1978f8['shift']());}};_0x285d93(++_0x5dc5b0);}(_0x5b80,0xc2));var _0x05b8=function(_0x433a86,_0x175b5c){_0x433a86=_0x433a86-0x0;var _0x23000c=_0x5b80[_0x433a86];return _0x23000c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x05b8('0x0'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x05b8('0x1'));var util=require('util');var path=require(_0x05b8('0x2'));var sox=require(_0x05b8('0x3'));var csv=require(_0x05b8('0x4'));var ejs=require(_0x05b8('0x5'));var fs=require('fs');var fs_extra=require(_0x05b8('0x6'));var _=require(_0x05b8('0x7'));var squel=require(_0x05b8('0x8'));var crypto=require(_0x05b8('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x05b8('0xa'));var toCsv=require(_0x05b8('0x4'));var querystring=require(_0x05b8('0xb'));var Papa=require('papaparse');var Redis=require(_0x05b8('0xc'));var authService=require(_0x05b8('0xd'));var qs=require(_0x05b8('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x05b8('0xf'));var logger=require(_0x05b8('0x10'))(_0x05b8('0x11'));var utils=require(_0x05b8('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0x05b8('0x13'));var db=require(_0x05b8('0x14'))['db'];function respondWithStatusCode(_0x5b3631,_0x2eeeba){_0x2eeeba=_0x2eeeba||0xcc;return function(_0x5b5464){if(_0x5b5464){return _0x5b3631['sendStatus'](_0x2eeeba);}return _0x5b3631['status'](_0x2eeeba)['end']();};}function respondWithResult(_0x3edb35,_0x1b7f9e){_0x1b7f9e=_0x1b7f9e||0xc8;return function(_0x149e8d){if(_0x149e8d){return _0x3edb35[_0x05b8('0x15')](_0x1b7f9e)[_0x05b8('0x16')](_0x149e8d);}};}function respondWithFilteredResult(_0x3ba702,_0xc5817c){return function(_0x8da748){if(_0x8da748){var _0x49d7b2=typeof _0xc5817c[_0x05b8('0x17')]===_0x05b8('0x18')&&typeof _0xc5817c['limit']===_0x05b8('0x18');var _0x2ceecb=_0x8da748[_0x05b8('0x19')];var _0x52f4ea=_0x49d7b2?0x0:_0xc5817c['offset'];var _0x595de3=_0x49d7b2?_0x8da748['count']:_0xc5817c[_0x05b8('0x17')]+_0xc5817c[_0x05b8('0x1a')];var _0x58ec83;if(_0x595de3>=_0x2ceecb){_0x595de3=_0x2ceecb;_0x58ec83=0xc8;}else{_0x58ec83=0xce;}_0x3ba702[_0x05b8('0x15')](_0x58ec83);return _0x3ba702[_0x05b8('0x1b')](_0x05b8('0x1c'),_0x52f4ea+'-'+_0x595de3+'/'+_0x2ceecb)[_0x05b8('0x16')](_0x8da748);}return null;};}function patchUpdates(_0x3fc4e6){return function(_0x186866){try{jsonpatch[_0x05b8('0x1d')](_0x186866,_0x3fc4e6,!![]);}catch(_0x169926){return BPromise[_0x05b8('0x1e')](_0x169926);}return _0x186866[_0x05b8('0x1f')]();};}function saveUpdates(_0xea09ad,_0x861125){return function(_0x1d6a45){if(_0x1d6a45){return _0x1d6a45['update'](_0xea09ad)['then'](function(_0x26d45b){return _0x26d45b;});}return null;};}function removeEntity(_0x38a94e,_0x3c39d5){return function(_0x26c47b){if(_0x26c47b){return _0x26c47b[_0x05b8('0x20')]()[_0x05b8('0x21')](function(){var _0x3fbc77=_0x26c47b['get']({'plain':!![]});var _0x113461=_0x05b8('0x22');return db['UserProfileResource'][_0x05b8('0x20')]({'where':{'type':_0x113461,'resourceId':_0x3fbc77['id']}})['then'](function(){return _0x26c47b;});})[_0x05b8('0x21')](function(){_0x38a94e[_0x05b8('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x21a9aa,_0x27153e){return function(_0x40a0b8){if(!_0x40a0b8){_0x21a9aa[_0x05b8('0x23')](0x194);}return _0x40a0b8;};}function handleError(_0x785029,_0x829d69){_0x829d69=_0x829d69||0x1f4;return function(_0x5e592f){logger[_0x05b8('0x24')](_0x5e592f[_0x05b8('0x25')]);if(_0x5e592f[_0x05b8('0x26')]){delete _0x5e592f[_0x05b8('0x26')];}_0x785029[_0x05b8('0x15')](_0x829d69)['send'](_0x5e592f);};}exports[_0x05b8('0x27')]=function(_0x1f58f3,_0x20e1d3){var _0x476595={},_0x127257={},_0x25b3d9={'count':0x0,'rows':[]};var _0x58b138=_['map'](db[_0x05b8('0x28')][_0x05b8('0x29')],function(_0x5dc57e){return{'name':_0x5dc57e['fieldName'],'type':_0x5dc57e['type'][_0x05b8('0x2a')]};});_0x127257['model']=_[_0x05b8('0x2b')](_0x58b138,_0x05b8('0x26'));_0x127257[_0x05b8('0x2c')]=_['keys'](_0x1f58f3[_0x05b8('0x2c')]);_0x127257['filters']=_[_0x05b8('0x2d')](_0x127257[_0x05b8('0x2e')],_0x127257['query']);_0x476595[_0x05b8('0x2f')]=_[_0x05b8('0x2d')](_0x127257[_0x05b8('0x2e')],qs['fields'](_0x1f58f3[_0x05b8('0x2c')][_0x05b8('0x30')]));_0x476595[_0x05b8('0x2f')]=_0x476595[_0x05b8('0x2f')]['length']?_0x476595['attributes']:_0x127257['model'];if(!_0x1f58f3[_0x05b8('0x2c')][_0x05b8('0x31')](_0x05b8('0x32'))){_0x476595[_0x05b8('0x1a')]=qs[_0x05b8('0x1a')](_0x1f58f3[_0x05b8('0x2c')]['limit']);_0x476595[_0x05b8('0x17')]=qs['offset'](_0x1f58f3[_0x05b8('0x2c')][_0x05b8('0x17')]);}_0x476595[_0x05b8('0x33')]=qs[_0x05b8('0x34')](_0x1f58f3[_0x05b8('0x2c')][_0x05b8('0x34')]);_0x476595[_0x05b8('0x35')]=qs[_0x05b8('0x36')](_[_0x05b8('0x37')](_0x1f58f3[_0x05b8('0x2c')],_0x127257['filters']),_0x58b138);if(_0x1f58f3[_0x05b8('0x2c')]['filter']){_0x476595[_0x05b8('0x35')]=_['merge'](_0x476595[_0x05b8('0x35')],{'$or':_[_0x05b8('0x2b')](_0x58b138,function(_0x1a8fa5){if(_0x1a8fa5['type']!==_0x05b8('0x38')){var _0x43f05f={};_0x43f05f[_0x1a8fa5[_0x05b8('0x26')]]={'$like':'%'+_0x1f58f3[_0x05b8('0x2c')]['filter']+'%'};return _0x43f05f;}})});}_0x476595=_[_0x05b8('0x39')]({},_0x476595,_0x1f58f3[_0x05b8('0x3a')]);var _0x37cb80={'where':_0x476595['where']};return db[_0x05b8('0x28')]['count'](_0x37cb80)[_0x05b8('0x21')](function(_0x915a3){_0x25b3d9['count']=_0x915a3;if(_0x1f58f3[_0x05b8('0x2c')][_0x05b8('0x3b')]){_0x476595[_0x05b8('0x3c')]=[{'all':!![]}];}return db[_0x05b8('0x28')][_0x05b8('0x3d')](_0x476595);})['then'](function(_0x2e0cfe){_0x25b3d9[_0x05b8('0x3e')]=_0x2e0cfe;return _0x25b3d9;})[_0x05b8('0x21')](respondWithFilteredResult(_0x20e1d3,_0x476595))[_0x05b8('0x3f')](handleError(_0x20e1d3,null));};exports[_0x05b8('0x40')]=function(_0x143acf,_0x5f1dce){var _0x4249fc={'raw':!![],'where':{'id':_0x143acf[_0x05b8('0x41')]['id']}},_0x4ff262={};_0x4ff262[_0x05b8('0x2e')]=_[_0x05b8('0x42')](db[_0x05b8('0x28')][_0x05b8('0x29')]);_0x4ff262['query']=_[_0x05b8('0x42')](_0x143acf[_0x05b8('0x2c')]);_0x4ff262[_0x05b8('0x36')]=_[_0x05b8('0x2d')](_0x4ff262[_0x05b8('0x2e')],_0x4ff262[_0x05b8('0x2c')]);_0x4249fc[_0x05b8('0x2f')]=_['intersection'](_0x4ff262[_0x05b8('0x2e')],qs['fields'](_0x143acf['query'][_0x05b8('0x30')]));_0x4249fc[_0x05b8('0x2f')]=_0x4249fc[_0x05b8('0x2f')][_0x05b8('0x43')]?_0x4249fc[_0x05b8('0x2f')]:_0x4ff262[_0x05b8('0x2e')];if(_0x143acf[_0x05b8('0x2c')][_0x05b8('0x3b')]){_0x4249fc[_0x05b8('0x3c')]=[{'all':!![]}];}_0x4249fc=_['merge']({},_0x4249fc,_0x143acf[_0x05b8('0x3a')]);return db[_0x05b8('0x28')][_0x05b8('0x44')](_0x4249fc)['then'](handleEntityNotFound(_0x5f1dce,null))['then'](respondWithResult(_0x5f1dce,null))['catch'](handleError(_0x5f1dce,null));};exports[_0x05b8('0x45')]=function(_0x53a527,_0x2672db){return db[_0x05b8('0x28')][_0x05b8('0x45')](_0x53a527[_0x05b8('0x46')],{})[_0x05b8('0x21')](function(_0x5a00f5){var _0x2eacf2=_0x53a527[_0x05b8('0x47')]['get']({'plain':!![]});if(!_0x2eacf2)throw new Error(_0x05b8('0x48'));if(_0x2eacf2[_0x05b8('0x49')]===_0x05b8('0x47')){var _0x4a283c=_0x5a00f5[_0x05b8('0x4a')]({'plain':!![]});var _0x29c409=_0x05b8('0x22');return db['UserProfileSection']['find']({'where':{'name':_0x29c409,'userProfileId':_0x2eacf2[_0x05b8('0x4b')]},'raw':!![]})[_0x05b8('0x21')](function(_0xd0ca8a){if(_0xd0ca8a&&_0xd0ca8a[_0x05b8('0x4c')]===0x0){return db[_0x05b8('0x4d')][_0x05b8('0x45')]({'name':_0x4a283c[_0x05b8('0x26')],'resourceId':_0x4a283c['id'],'type':_0xd0ca8a[_0x05b8('0x26')],'sectionId':_0xd0ca8a['id']},{})[_0x05b8('0x21')](function(){return _0x5a00f5;});}else{return _0x5a00f5;}})['catch'](function(_0x4dbb59){logger[_0x05b8('0x24')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4dbb59);throw _0x4dbb59;});}return _0x5a00f5;})[_0x05b8('0x21')](respondWithResult(_0x2672db,0xc9))[_0x05b8('0x3f')](handleError(_0x2672db,null));};exports[_0x05b8('0x4e')]=function(_0x30c190,_0x208125){if(_0x30c190['body']['id']){delete _0x30c190[_0x05b8('0x46')]['id'];}return db[_0x05b8('0x28')][_0x05b8('0x44')]({'where':{'id':_0x30c190['params']['id']}})[_0x05b8('0x21')](handleEntityNotFound(_0x208125,null))[_0x05b8('0x21')](saveUpdates(_0x30c190[_0x05b8('0x46')],null))[_0x05b8('0x21')](respondWithResult(_0x208125,null))[_0x05b8('0x3f')](handleError(_0x208125,null));};exports[_0x05b8('0x20')]=function(_0x621aa5,_0x1c5e08){return db[_0x05b8('0x28')][_0x05b8('0x44')]({'where':{'id':_0x621aa5[_0x05b8('0x41')]['id']}})[_0x05b8('0x21')](handleEntityNotFound(_0x1c5e08,null))[_0x05b8('0x21')](removeEntity(_0x1c5e08,null))['catch'](handleError(_0x1c5e08,null));};exports[_0x05b8('0x4f')]=function(_0x131c6f,_0x494c4e,_0x30e307){var _0x31be23;return db[_0x05b8('0x28')][_0x05b8('0x44')]({'where':{'id':_0x131c6f[_0x05b8('0x41')]['id']},'attributes':['id',_0x05b8('0x50')]})[_0x05b8('0x21')](handleEntityNotFound(_0x494c4e,null))[_0x05b8('0x21')](function(_0x1e6ee2){if(_0x1e6ee2){var _0x361979=require('odbc')();_0x361979['openSync'](_0x1e6ee2[_0x05b8('0x50')]);_0x361979[_0x05b8('0x51')]();return _0x1e6ee2;}})[_0x05b8('0x21')](respondWithResult(_0x494c4e,null))[_0x05b8('0x3f')](handleError(_0x494c4e,null));};
\ No newline at end of file