From 2b63460bf3809f457df512839332b9daa5beba29 Mon Sep 17 00:00:00 2001 From: himeshr Date: Fri, 6 Dec 2024 15:43:13 +0530 Subject: [PATCH] #1552 | getPreviousSettings after resetting Locale which is removed to avoid issues with re-login with different org user --- .../openchs-android/src/service/BackupRestoreRealm.js | 8 +++++++- .../openchs-android/src/service/RuleEvaluationService.js | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/openchs-android/src/service/BackupRestoreRealm.js b/packages/openchs-android/src/service/BackupRestoreRealm.js index c29285325..f92701d76 100644 --- a/packages/openchs-android/src/service/BackupRestoreRealm.js +++ b/packages/openchs-android/src/service/BackupRestoreRealm.js @@ -93,7 +93,7 @@ export default class BackupRestoreRealmService extends BaseService { let entitySyncStatusService = this.getService(EntitySyncStatusService); let downloadedFile = `${fs.DocumentDirectoryPath}/${General.randomUUID()}.zip`; let downloadedUncompressedDir = `${fs.DocumentDirectoryPath}/${General.randomUUID()}`; - const prevSettings = settingsService.getSettings().clone(); + const prevSettings = this.getPreviousSettings(settingsService); const prevUserInfo = UserInfo.fromResource({username: prevSettings.userId, organisationName: 'dummy', name: prevSettings.userId}); General.logInfo("BackupRestoreRealm", `To be downloaded file: ${downloadedFile}, Unzipped directory: ${downloadedUncompressedDir}, Realm file: ${REALM_FILE_FULL_PATH}`); @@ -195,6 +195,12 @@ export default class BackupRestoreRealmService extends BaseService { }); } + getPreviousSettings(settingsService) { + const prevSettings = settingsService.getSettings().clone(); + prevSettings.locale = null; + return prevSettings; + } + _deleteUserInfoAndIdAssignment() { this._deleteAndResetSync(UserInfo.schema.name); this._deleteAndResetSync(IdentifierAssignment.schema.name); diff --git a/packages/openchs-android/src/service/RuleEvaluationService.js b/packages/openchs-android/src/service/RuleEvaluationService.js index 83e86dc67..fc8dfd595 100644 --- a/packages/openchs-android/src/service/RuleEvaluationService.js +++ b/packages/openchs-android/src/service/RuleEvaluationService.js @@ -260,12 +260,14 @@ class RuleEvaluationService extends BaseService { ruleTypeValue = entity; return rule.fn.exec(entity, context, entityContext) } else { + General.logDebug("Rule-to-run", `Rule context and config: ${JSONStringify(context)}, ${JSONStringify(config)}, ${JSONStringify(entityContext)}`); + General.logDebug("Rule-to-run", `Rule function: ${rule.name}, uuid: ${rule.uuid}, ${JSONStringify(rule.fn)}`); return _.isNil(context) ? rule.fn.exec(entity, ruleTypeValue, config, entityContext) : rule.fn.exec(entity, ruleTypeValue, context, config, entityContext); } } catch (error) { - General.logDebug("Rule-Failure", `Rule failed: ${rule.name}, uuid: ${rule.uuid}`); + General.logDebug("Rule-Failure", `Rule failed: ${rule.name}, uuid: ${rule.uuid}`, error.message); this.saveFailedRules(error, rule.uuid, this.getIndividualUUID(entity, entityName), 'Decision', rule.uuid, entityName, entity.uuid); return ruleTypeValue;