Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 0138590

Browse files
SORMAS-Foundation#3817 fix saving all changes of returned cases/contacts (SORMAS-Foundation#3913)
SORMAS-Foundation#3817 fix saving all changes of returned cases/contacts
1 parent f0faa3f commit 0138590

13 files changed

Lines changed: 139 additions & 75 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public interface Strings {
191191
String errorSetFeverRequired = "errorSetFeverRequired";
192192
String errorSormasToSormasCertNotGenerated = "errorSormasToSormasCertNotGenerated";
193193
String errorSormasToSormasConnection = "errorSormasToSormasConnection";
194+
String errorSormasToSormasCountry = "errorSormasToSormasCountry";
194195
String errorSormasToSormasDecrypt = "errorSormasToSormasDecrypt";
195196
String errorSormasToSormasEncrypt = "errorSormasToSormasEncrypt";
196197
String errorSormasToSormasInfrastructure = "errorSormasToSormasInfrastructure";

sormas-api/src/main/java/de/symeda/sormas/api/region/CountryDto.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package de.symeda.sormas.api.region;
22

3+
import java.util.Date;
4+
35
import javax.validation.constraints.Size;
46

57
import de.symeda.sormas.api.EntityDto;
68
import de.symeda.sormas.api.utils.DataHelper;
79

8-
import java.util.Date;
9-
1010
public class CountryDto extends EntityDto {
1111

1212
private static final long serialVersionUID = 8309822957203823162L;
@@ -25,14 +25,15 @@ public class CountryDto extends EntityDto {
2525
private String unoCode;
2626
private boolean archived;
2727

28-
public CountryDto(Date creationDate,
29-
Date changeDate,
30-
String uuid,
31-
boolean archived,
32-
String defaultName,
33-
String externalId,
34-
String isoCode,
35-
String unoCode) {
28+
public CountryDto(
29+
Date creationDate,
30+
Date changeDate,
31+
String uuid,
32+
boolean archived,
33+
String defaultName,
34+
String externalId,
35+
String isoCode,
36+
String unoCode) {
3637

3738
super(creationDate, changeDate, uuid);
3839
this.archived = archived;

sormas-api/src/main/java/de/symeda/sormas/api/region/CountryFacade.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public interface CountryFacade {
1414

1515
List<CountryReferenceDto> getByDefaultName(String name, boolean includeArchivedEntities);
1616

17+
CountryDto getByIsoCode(String isoCode, boolean includeArchivedEntities);
18+
1719
List<CountryIndexDto> getIndexList(CountryCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties);
1820

1921
long count(CountryCriteria criteria);

sormas-api/src/main/java/de/symeda/sormas/api/region/CountryReferenceDto.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,29 @@ public class CountryReferenceDto extends ReferenceDto implements StatisticsGroup
77

88
private static final long serialVersionUID = -7477992903590074568L;
99

10+
private String isoCode;
11+
1012
public CountryReferenceDto() {
1113
}
1214

13-
public CountryReferenceDto(String uuid) {
14-
setUuid(uuid);
15-
}
15+
public CountryReferenceDto(String uuid, String isoCode) {
16+
super(uuid);
17+
this.isoCode = isoCode;
18+
}
19+
20+
public CountryReferenceDto(String uuid, String caption, String isoCode) {
21+
setUuid(uuid);
22+
setCaption(caption);
23+
this.isoCode = isoCode;
24+
}
1625

17-
public CountryReferenceDto(String uuid, String caption) {
18-
setUuid(uuid);
19-
setCaption(caption);
20-
}
26+
public String getIsoCode() {
27+
return isoCode;
28+
}
29+
30+
public void setIsoCode(String isoCode) {
31+
this.isoCode = isoCode;
32+
}
2133

2234
@Override
2335
public int keyCompareTo(StatisticsGroupingKey o) {

sormas-api/src/main/java/de/symeda/sormas/api/user/UserRight.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import static de.symeda.sormas.api.user.UserRole.POE_INFORMANT;
3838
import static de.symeda.sormas.api.user.UserRole.POE_NATIONAL_USER;
3939
import static de.symeda.sormas.api.user.UserRole.POE_SUPERVISOR;
40+
import static de.symeda.sormas.api.user.UserRole.SORMAS_TO_SORMAS_CLIENT;
4041
import static de.symeda.sormas.api.user.UserRole.STATE_OBSERVER;
4142
import static de.symeda.sormas.api.user.UserRole.SURVEILLANCE_OFFICER;
4243
import static de.symeda.sormas.api.user.UserRole.SURVEILLANCE_SUPERVISOR;
@@ -1110,8 +1111,9 @@ public enum UserRight {
11101111
CONTACT_OFFICER,
11111112
HOSPITAL_INFORMANT,
11121113
COMMUNITY_INFORMANT,
1113-
POE_INFORMANT),
1114-
SEE_PERSONAL_DATA_OUTSIDE_JURISDICTION(),
1114+
POE_INFORMANT,
1115+
SORMAS_TO_SORMAS_CLIENT),
1116+
SEE_PERSONAL_DATA_OUTSIDE_JURISDICTION(SORMAS_TO_SORMAS_CLIENT),
11151117
SEE_SENSITIVE_DATA_IN_JURISDICTION(
11161118
SURVEILLANCE_SUPERVISOR,
11171119
ADMIN_SUPERVISOR,
@@ -1127,8 +1129,9 @@ public enum UserRight {
11271129
HOSPITAL_INFORMANT,
11281130
COMMUNITY_INFORMANT,
11291131
POE_INFORMANT,
1130-
LAB_USER),
1131-
SEE_SENSITIVE_DATA_OUTSIDE_JURISDICTION(),
1132+
LAB_USER,
1133+
SORMAS_TO_SORMAS_CLIENT),
1134+
SEE_SENSITIVE_DATA_OUTSIDE_JURISDICTION(SORMAS_TO_SORMAS_CLIENT),
11321135
CAMPAIGN_VIEW(
11331136
ADMIN,
11341137
NATIONAL_USER,

sormas-api/src/main/resources/strings.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ errorSormasToSormasSend = Unexpected error occurred while sharing. Please contac
237237
errorSormasToSormasConnection = Connection refused by the target health department.
238238
errorSormasToSormasResult = Unexpected error occurred while getting share result. Please contact the recipient health department and tell them about this issue. Please also contact your admin and tell them about this issue.
239239
errorSormasToSormasInfrastructure = Infrastructure data does not match. Unmatched values: %s
240+
errorSormasToSormasCountry = Unmatched country: %s
240241
errorSormasToSormasCertNotGenerated = Sormas to sormas certificate is not yet generated. Please contact an admin and tell them about this issue.
241242
errorSormasToSormasEncrypt = Could not encrypt the data. Please contact an admin and tell them about this issue.
242243
errorSormasToSormasDecrypt = Could not decrypt the shared data. Please contact an admin and tell them about this issue.

sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDtoHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public static CountryReferenceDto toReferenceDto(Country ado) {
5353
if (ado == null) {
5454
return null;
5555
}
56-
CountryReferenceDto dto = new CountryReferenceDto(ado.getUuid());
5756

58-
return dto;
57+
return new CountryReferenceDto(ado.getUuid(), ado.getIsoCode());
5958
}
6059
}

sormas-backend/src/main/java/de/symeda/sormas/backend/region/CountryFacadeEjb.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public List<CountryReferenceDto> getByDefaultName(String name, boolean includeAr
6161
.collect(Collectors.toList());
6262
}
6363

64+
@Override
65+
public CountryDto getByIsoCode(String isoCode, boolean includeArchivedEntities) {
66+
return countryService.getByIsoCode(isoCode, includeArchivedEntities).map(this::toDto).orElse(null);
67+
}
68+
6469
@Override
6570
public List<CountryIndexDto> getIndexList(CountryCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties) {
6671
CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -167,7 +172,20 @@ public static CountryReferenceDto toReferenceDto(Country entity) {
167172
if (entity == null) {
168173
return null;
169174
}
170-
return new CountryReferenceDto(entity.getUuid(), I18nProperties.getCountryName(entity.getIsoCode(), entity.getDefaultName()));
175+
return new CountryReferenceDto(
176+
entity.getUuid(),
177+
I18nProperties.getCountryName(entity.getIsoCode(), entity.getDefaultName()),
178+
entity.getIsoCode());
179+
}
180+
181+
public static CountryReferenceDto toReferenceDto(CountryDto entity) {
182+
if (entity == null) {
183+
return null;
184+
}
185+
return new CountryReferenceDto(
186+
entity.getUuid(),
187+
I18nProperties.getCountryName(entity.getIsoCode(), entity.getDefaultName()),
188+
entity.getIsoCode());
171189
}
172190

173191
public CountryDto toDto(Country entity) {

sormas-backend/src/main/java/de/symeda/sormas/backend/sormastosormas/SormasToSormasFacadeEjb.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import javax.persistence.criteria.CriteriaQuery;
4747
import javax.persistence.criteria.Predicate;
4848
import javax.persistence.criteria.Root;
49+
import javax.transaction.Transactional;
4950
import javax.ws.rs.ProcessingException;
5051
import javax.ws.rs.client.ResponseProcessingException;
5152
import javax.ws.rs.core.Response;
@@ -295,6 +296,7 @@ public void shareContacts(List<String> contactUuids, SormasToSormasOptionsDto op
295296
}
296297

297298
@Override
299+
@Transactional
298300
public void returnCase(String caseUuid, SormasToSormasOptionsDto options) throws SormasToSormasException {
299301
options.setHandOverOwnership(true);
300302
User currentUser = userService.getCurrentUser();

sormas-backend/src/main/java/de/symeda/sormas/backend/sormastosormas/datapersister/ProcessedCaseDataPersister.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ public class ProcessedCaseDataPersister implements ProcessedDataPersister<Proces
5656
@EJB
5757
private SormasToSormasOriginInfoFacadeEjbLocal originInfoFacade;
5858

59+
@Transactional(rollbackOn = {
60+
Exception.class })
5961
public void persistSharedData(ProcessedCaseData caseData) throws SormasToSormasValidationException {
60-
persistSharedDataInTransaction(caseData);
61-
}
62-
63-
@Transactional
64-
private void persistSharedDataInTransaction(ProcessedCaseData caseData) throws SormasToSormasValidationException {
6562
CaseDataDto caze = caseData.getCaze();
6663

6764
handleValidationError(() -> personFacade.savePerson(caseData.getPerson()), Captions.Person, buildCaseValidationGroupName(caze));
@@ -88,22 +85,18 @@ private void persistSharedDataInTransaction(ProcessedCaseData caseData) throws S
8885
}
8986
}
9087

88+
@Transactional(rollbackOn = {
89+
Exception.class })
9190
public void persistReturnedData(ProcessedCaseData caseData, SormasToSormasOriginInfoDto originInfo) throws SormasToSormasValidationException {
92-
persistReturnedDataInTransaction(caseData, originInfo);
93-
}
94-
95-
@Transactional
96-
private void persistReturnedDataInTransaction(ProcessedCaseData caseData, SormasToSormasOriginInfoDto originInfo)
97-
throws SormasToSormasValidationException {
9891
CaseDataDto caze = caseData.getCaze();
9992

100-
handleValidationError(() -> personFacade.savePerson(caseData.getPerson()), Captions.Person, buildCaseValidationGroupName(caze));
10193
CaseDataDto savedCase = handleValidationError(() -> caseFacade.saveCase(caze), Captions.CaseData, buildCaseValidationGroupName(caze));
102-
10394
SormasToSormasShareInfo shareInfo = shareInfoService.getByCaseAndOrganization(savedCase.getUuid(), originInfo.getOrganizationId());
10495
shareInfo.setOwnershipHandedOver(false);
10596
shareInfoService.persist(shareInfo);
10697

98+
handleValidationError(() -> personFacade.savePerson(caseData.getPerson()), Captions.Person, buildCaseValidationGroupName(caze));
99+
107100
SormasToSormasOriginInfoDto savedOriginInfo = null;
108101

109102
if (caseData.getAssociatedContacts() != null) {

0 commit comments

Comments
 (0)