From 127fa07f3c3c7fdfe38ea50c15a488f039863c73 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Mon, 15 Oct 2018 16:19:57 +0300 Subject: [PATCH] Fix updated settings bug --- assets/server_defaults/anc/site_characteristics.json | 4 ++-- .../main/java/org/opensrp/repository/SettingRepository.java | 2 +- .../org/opensrp/repository/couch/SettingRepositoryImpl.java | 2 +- .../opensrp/repository/postgres/SettingRepositoryImpl.java | 4 ++-- .../src/main/java/org/opensrp/service/SettingService.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/server_defaults/anc/site_characteristics.json b/assets/server_defaults/anc/site_characteristics.json index 7b7188a1de..fb405a9d6a 100644 --- a/assets/server_defaults/anc/site_characteristics.json +++ b/assets/server_defaults/anc/site_characteristics.json @@ -6,14 +6,14 @@ "locationId": "", "providerId": "", "teamId": "", - "dateCreated": "", + "dateCreated": "1970-10-04T10:17:09.993+03:00", "serverVersion": 1, "settings": [ { "key": "site_ipv_assess", "label": "Minimum requirements for IPV assessment", "value": null, - "description": "\"Are all of the following in place at your facility: \r\n1. A protocol or standard operating procedure for Intimate Partner Violence (IPV); \r\n2. A health worker trained on how to ask about IPV and how to provide the minimum response or beyond;\r\n3. A private setting; \r\n4. A way to ensure confidentiality; \r\n5. Time to allow for appropriate disclosure; and\r\n6. A system for referral in place. \"" + "description": "Are all of the following in place at your facility: \r\n\ta. A protocol or standard operating procedure for Intimate Partner Violence (IPV); \r\n\tb. A health worker trained on how to ask about IPV and how to provide the minimum response or beyond;\r\n\tc. A private setting; \r\n\td. A way to ensure confidentiality; \r\n\te. Time to allow for appropriate disclosure; and\r\n\tf. A system for referral in place. " }, { "key": "site_anc_hiv", diff --git a/opensrp-core/src/main/java/org/opensrp/repository/SettingRepository.java b/opensrp-core/src/main/java/org/opensrp/repository/SettingRepository.java index 5587169331..28e3988f11 100644 --- a/opensrp-core/src/main/java/org/opensrp/repository/SettingRepository.java +++ b/opensrp-core/src/main/java/org/opensrp/repository/SettingRepository.java @@ -18,7 +18,7 @@ public interface SettingRepository extends BaseRepository SettingsMetadata saveSetting(SettingConfiguration settingConfiguration, SettingsMetadata settingMetadata); - SettingsMetadata getSettingMetadataByIdentifier(String identifier); + SettingsMetadata getSettingMetadataByIdentifierAndTeamId(String identifier, String teamId); Settings getSettingById(Long id); diff --git a/opensrp-core/src/main/java/org/opensrp/repository/couch/SettingRepositoryImpl.java b/opensrp-core/src/main/java/org/opensrp/repository/couch/SettingRepositoryImpl.java index f29aa5477d..48f55ac79d 100644 --- a/opensrp-core/src/main/java/org/opensrp/repository/couch/SettingRepositoryImpl.java +++ b/opensrp-core/src/main/java/org/opensrp/repository/couch/SettingRepositoryImpl.java @@ -68,7 +68,7 @@ public List findAllLatestSettingsByVersion(Long lastSynced } @Override - public SettingsMetadata getSettingMetadataByIdentifier(String identifier) { + public SettingsMetadata getSettingMetadataByIdentifierAndTeamId(String identifier, String teamId) { // TODO Auto-generated method stub return null; } diff --git a/opensrp-core/src/main/java/org/opensrp/repository/postgres/SettingRepositoryImpl.java b/opensrp-core/src/main/java/org/opensrp/repository/postgres/SettingRepositoryImpl.java index 54027b677d..ec6df2915e 100644 --- a/opensrp-core/src/main/java/org/opensrp/repository/postgres/SettingRepositoryImpl.java +++ b/opensrp-core/src/main/java/org/opensrp/repository/postgres/SettingRepositoryImpl.java @@ -298,9 +298,9 @@ public void add(SettingConfiguration entity) { } @Override - public SettingsMetadata getSettingMetadataByIdentifier(String identifier) { + public SettingsMetadata getSettingMetadataByIdentifierAndTeamId(String identifier, String teamId) { SettingsMetadataExample example = new SettingsMetadataExample(); - example.createCriteria().andIdentifierEqualTo(identifier); + example.createCriteria().andIdentifierEqualTo(identifier).andTeamIdEqualTo(teamId); List settingsMetadata = settingMetadataMapper.selectByExample(example); diff --git a/opensrp-core/src/main/java/org/opensrp/service/SettingService.java b/opensrp-core/src/main/java/org/opensrp/service/SettingService.java index 61b6002eba..648a2e2f42 100644 --- a/opensrp-core/src/main/java/org/opensrp/service/SettingService.java +++ b/opensrp-core/src/main/java/org/opensrp/service/SettingService.java @@ -67,7 +67,7 @@ public synchronized SettingsMetadata saveSetting(String jsonSettingConfiguration SettingConfiguration settingConfigurations = gson.fromJson(jsonSettingConfiguration, new TypeToken() {}.getType()); - SettingsMetadata metadata = settingRepository.getSettingMetadataByIdentifier(settingConfigurations.getIdentifier()); + SettingsMetadata metadata = settingRepository.getSettingMetadataByIdentifierAndTeamId(settingConfigurations.getIdentifier(), settingConfigurations.getTeamId()); Settings settings; if (metadata != null) {