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

Commit f584ab8

Browse files
lgallgal
authored andcommitted
SORMAS-Foundation#3360 add UUID generation in epi date and visit facades
1 parent 95d3bd1 commit f584ab8

2 files changed

Lines changed: 3 additions & 23 deletions

File tree

sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiDataFacadeEjb.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*******************************************************************************/
1818
package de.symeda.sormas.backend.epidata;
1919

20-
import java.sql.Timestamp;
2120
import java.util.ArrayList;
2221
import java.util.Date;
2322
import java.util.List;
@@ -89,17 +88,7 @@ public Exposure fromExposureDto(ExposureDto source, boolean checkChangeDate) {
8988
return null;
9089
}
9190

92-
Exposure exposure = exposureService.getByUuid(source.getUuid());
93-
if (exposure == null) {
94-
exposure = new Exposure();
95-
exposure.setUuid(source.getUuid());
96-
if (source.getCreationDate() != null) {
97-
exposure.setCreationDate(new Timestamp(source.getCreationDate().getTime()));
98-
}
99-
}
100-
101-
Exposure target = exposure;
102-
DtoHelper.validateDto(source, target, checkChangeDate);
91+
Exposure target = DtoHelper.fillOrBuildEntity(source, exposureService.getByUuid(source.getUuid()), Exposure::new, checkChangeDate);
10392

10493
target.setAnimalCondition(source.getAnimalCondition());
10594
target.setTypeOfAnimal(source.getTypeOfAnimal());
@@ -152,7 +141,7 @@ public Exposure fromExposureDto(ExposureDto source, boolean checkChangeDate) {
152141
target.setRiskArea(source.getRiskArea());
153142
target.setPatientExpositionRole(source.getPatientExpositionRole());
154143

155-
return exposure;
144+
return target;
156145
}
157146

158147
public static EpiDataDto toDto(EpiData epiData) {

sormas-backend/src/main/java/de/symeda/sormas/backend/visit/VisitFacadeEjb.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*******************************************************************************/
1818
package de.symeda.sormas.backend.visit;
1919

20-
import java.sql.Timestamp;
2120
import java.util.ArrayList;
2221
import java.util.Collections;
2322
import java.util.Comparator;
@@ -492,15 +491,7 @@ public List<VisitExportDto> getVisitsExportList(
492491
public Visit fromDto(@NotNull VisitDto source, boolean checkChangeDate) {
493492

494493
final String visitUuid = source.getUuid();
495-
Visit target = visitUuid != null ? visitService.getByUuid(visitUuid) : null;
496-
if (target == null) {
497-
target = new Visit();
498-
target.setUuid(visitUuid);
499-
if (source.getCreationDate() != null) {
500-
target.setCreationDate(new Timestamp(source.getCreationDate().getTime()));
501-
}
502-
}
503-
DtoHelper.validateDto(source, target, checkChangeDate);
494+
Visit target = DtoHelper.fillOrBuildEntity(source, visitService.getByUuid(visitUuid), Visit::new, checkChangeDate);
504495

505496
target.setDisease(source.getDisease());
506497
target.setPerson(personService.getByReferenceDto(source.getPerson()));

0 commit comments

Comments
 (0)