Skip to content

Commit

Permalink
[GITFLOW]merging 'hotfix-1.75.1' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKock committed Sep 20, 2022
2 parents 7a4043b + 23cee88 commit c503511
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 287 deletions.
2 changes: 1 addition & 1 deletion sormas-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<version>1.75.0</version>
<version>1.75.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sormas-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.75.0</version>
<version>1.75.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sormas-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.75.0</version>
<version>1.75.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4181,7 +4181,7 @@ public void updateSymptomsByVisit(Visit visit) {
SymptomsDto caseSymptoms = cazeDto.getSymptoms();
SymptomsHelper.updateSymptoms(SymptomsFacadeEjb.toDto(visit.getSymptoms()), caseSymptoms);

save(cazeDto, true);
caseSave(cazeDto, true, visit.getCaze(), cazeDto, true, true);
}

private Pseudonymizer getPseudonymizerForDtoWithClinician(@Nullable String pseudonymizedValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
import de.symeda.sormas.api.person.Sex;
import de.symeda.sormas.api.share.ExternalShareStatus;
import de.symeda.sormas.api.therapy.PrescriptionCriteria;
import de.symeda.sormas.api.therapy.TherapyReferenceDto;
import de.symeda.sormas.api.therapy.TreatmentCriteria;
Expand Down Expand Up @@ -1017,31 +1016,20 @@ public void dearchive(List<String> entityUuids, String dearchiveReason) {

public void setArchiveInExternalSurveillanceToolForEntities(List<String> entityUuids, boolean archived) {
if (externalSurveillanceToolGatewayFacade.isFeatureEnabled()) {
try {
externalSurveillanceToolGatewayFacade
.sendCases(externalShareInfoService.getSharedCaseUuidsWithoutDeletedStatus(entityUuids), archived);
} catch (ExternalSurveillanceToolException e) {
throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode());
}
}
}
List<String> sharedCaseUuids = externalShareInfoService.getSharedCaseUuidsWithoutDeletedStatus(entityUuids);

public void setArchiveInExternalSurveillanceToolForEntity(String entityUuid, boolean archived) {
Case caze = getByUuid(entityUuid);
if (externalSurveillanceToolGatewayFacade.isFeatureEnabled()
&& externalShareInfoService.isCaseShared(caze.getId())
&& !hasShareInfoWithDeletedStatus(entityUuid)) {
try {
externalSurveillanceToolGatewayFacade.sendCases(Collections.singletonList(entityUuid), archived);
} catch (ExternalSurveillanceToolException e) {
throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode());
if (!sharedCaseUuids.isEmpty()) {
try {
externalSurveillanceToolGatewayFacade.sendCases(sharedCaseUuids, archived);
} catch (ExternalSurveillanceToolException e) {
throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode());
}
}
}
}

public boolean hasShareInfoWithDeletedStatus(String entityUuid) {
List<ExternalShareInfo> result = externalShareInfoService.getShareInfoByCase(entityUuid);
return result.stream().anyMatch(info -> info.getStatus().equals(ExternalShareStatus.DELETED));
public void setArchiveInExternalSurveillanceToolForEntity(String entityUuid, boolean archived) {
setArchiveInExternalSurveillanceToolForEntities(Collections.singletonList(entityUuid), archived);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public <T extends CustomizableEnum> T getEnumValue(CustomizableEnumType type, St
.findFirst()
.orElseThrow(
() -> new CustomEnumNotFoundException(
"Invalid enum value " + value + " for customizable enum type " + type.toString() + "and disease " + disease.toString()));
"Invalid enum value " + value + " for customizable enum type " + type + " and disease " + disease));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import de.symeda.sormas.api.externaldata.ExternalDataUpdateException;
import de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException;
import de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolRuntimeException;
import de.symeda.sormas.api.share.ExternalShareStatus;
import de.symeda.sormas.api.task.TaskCriteria;
import de.symeda.sormas.api.user.JurisdictionLevel;
import de.symeda.sormas.api.utils.DataHelper;
Expand Down Expand Up @@ -307,31 +306,20 @@ public void dearchive(List<String> entityUuids, String dearchiveReason) {

public void setArchiveInExternalSurveillanceToolForEntities(List<String> entityUuids, boolean archived) {
if (externalSurveillanceToolGatewayFacade.isFeatureEnabled()) {
try {
externalSurveillanceToolGatewayFacade
.sendEvents(externalShareInfoService.getSharedEventUuidsWithoutDeletedStatus(entityUuids), archived);
} catch (ExternalSurveillanceToolException e) {
throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode());
}
}
}
List<String> sharedEventUuids = externalShareInfoService.getSharedEventUuidsWithoutDeletedStatus(entityUuids);

public void setArchiveInExternalSurveillanceToolForEntity(String eventUuid, boolean archived) {
Event event = getByUuid(eventUuid);
if (externalSurveillanceToolGatewayFacade.isFeatureEnabled()
&& externalShareInfoService.isEventShared(event.getId())
&& !hasShareInfoWithDeletedStatus(eventUuid)) {
try {
externalSurveillanceToolGatewayFacade.sendEvents(Collections.singletonList(eventUuid), archived);
} catch (ExternalSurveillanceToolException e) {
throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode());
if (!sharedEventUuids.isEmpty()) {
try {
externalSurveillanceToolGatewayFacade.sendEvents(sharedEventUuids, archived);
} catch (ExternalSurveillanceToolException e) {
throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode());
}
}
}
}

public boolean hasShareInfoWithDeletedStatus(String entityUuid) {
List<ExternalShareInfo> result = externalShareInfoService.getShareInfoByEvent(entityUuid);
return result.stream().anyMatch(info -> info.getStatus().equals(ExternalShareStatus.DELETED));
public void setArchiveInExternalSurveillanceToolForEntity(String eventUuid, boolean archived) {
setArchiveInExternalSurveillanceToolForEntities(Collections.singletonList(eventUuid), archived);
}

public List<String> getArchivedUuidsSince(Date since) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void setEvent(Event event) {
}

@ManyToOne
@JoinColumn(nullable = false)
@JoinColumn
public User getSender() {
return sender;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import de.symeda.sormas.api.share.ExternalShareInfoDto;
import de.symeda.sormas.api.share.ExternalShareInfoFacade;
import de.symeda.sormas.backend.common.CriteriaBuilderHelper;
import de.symeda.sormas.backend.user.UserFacadeEjb;
import de.symeda.sormas.backend.user.UserService;
import de.symeda.sormas.backend.util.DtoHelper;
import de.symeda.sormas.backend.util.ModelConstants;
Expand Down Expand Up @@ -93,7 +94,7 @@ private ExternalShareInfoDto toDto(ExternalShareInfo source) {

DtoHelper.fillDto(target, source);

target.setSender(source.getSender().toReference());
target.setSender(UserFacadeEjb.toReferenceDto(source.getSender()));
target.setStatus(source.getStatus());

return target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public List<Vaccination> getRelevantVaccinationsForCase(Case caze) {
Join<Immunization, Vaccination> vaccination = immunization.join(Immunization.VACCINATIONS, JoinType.LEFT);

Predicate predicate = cb.in(root).value(caze);
cq.where(predicate);
cq.where(cb.and(predicate, cb.isNotNull(vaccination)));
cq.select(vaccination);

List<Vaccination> vaccinations = em.createQuery(cq).getResultList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,7 @@ public VisitDto saveVisit(@Valid VisitDto dto) {

FacadeHelper.checkCreateAndEditRights(existingVisit, userService, UserRight.VISIT_CREATE, UserRight.VISIT_EDIT);

final VisitDto existingDto = toDto(existingVisit);

restorePseudonymizedDto(dto, existingVisit, existingDto);

this.validate(dto);

if (dto.getVisitStatus().equals(VisitStatus.COOPERATIVE)) {
SymptomsHelper.updateIsSymptomatic(dto.getSymptoms());
} else {
dto.getSymptoms().setSymptomatic(null);
}
Visit entity = fromDto(dto, true);

visitService.ensurePersisted(entity);

onVisitChanged(existingDto, entity);

return convertToDto(entity, Pseudonymizer.getDefault(userService::hasRight));
return doSaveVisit(dto, existingVisit);
}

@Override
Expand All @@ -264,7 +247,7 @@ public ExternalVisitDto saveExternalVisit(@Valid final ExternalVisitDto dto) {
dto.getReportLatLonAccuracy(),
VisitOrigin.EXTERNAL_JOURNAL);

saveVisit(visitDto);
doSaveVisit(visitDto, null);

return ExternalVisitDto.build(
personUuid,
Expand All @@ -278,6 +261,27 @@ public ExternalVisitDto saveExternalVisit(@Valid final ExternalVisitDto dto) {
visitDto.getReportLatLonAccuracy());
}

private VisitDto doSaveVisit(@Valid VisitDto dto, Visit existingVisit) {
final VisitDto existingDto = toDto(existingVisit);

restorePseudonymizedDto(dto, existingVisit, existingDto);

this.validate(dto);

if (dto.getVisitStatus().equals(VisitStatus.COOPERATIVE)) {
SymptomsHelper.updateIsSymptomatic(dto.getSymptoms());
} else {
dto.getSymptoms().setSymptomatic(null);
}
Visit entity = fromDto(dto, true);

visitService.ensurePersisted(entity);

onVisitChanged(existingDto, entity);

return convertToDto(entity, Pseudonymizer.getDefault(userService::hasRight));
}

@Override
public void validate(VisitDto visit) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.junit.Before;
import org.junit.Test;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.customizableenum.CustomEnumNotFoundException;
import de.symeda.sormas.api.customizableenum.CustomizableEnum;
import de.symeda.sormas.api.customizableenum.CustomizableEnumType;
import de.symeda.sormas.backend.AbstractBeanTest;
Expand Down Expand Up @@ -50,4 +48,9 @@ public void getEnumValues() {
assertEquals(1, enumValues.size());

}

@Test(expected = CustomEnumNotFoundException.class)
public void tetGetUnknownDiseaseVariantWithNullDisease() throws CustomEnumNotFoundException {
getCustomizableEnumFacade().getEnumValue(CustomizableEnumType.DISEASE_VARIANT, "any", null);
}
}
Loading

0 comments on commit c503511

Please sign in to comment.