Search in sources :

Example 1 with ActivityAsCase

use of de.symeda.sormas.backend.activityascase.ActivityAsCase in project SORMAS-Project by hzi-braunschweig.

the class EpiDataFacadeEjb method fromActivityAsCaseDto.

public ActivityAsCase fromActivityAsCaseDto(ActivityAsCaseDto source, boolean checkChangeDate) {
    if (source == null) {
        return null;
    }
    ActivityAsCase target = DtoHelper.fillOrBuildEntity(source, activityAsCaseService.getByUuid(source.getUuid()), ActivityAsCase::new, checkChangeDate);
    target.setReportingUser(userService.getByReferenceDto(source.getReportingUser()));
    target.setStartDate(source.getStartDate());
    target.setEndDate(source.getEndDate());
    target.setDescription(source.getDescription());
    target.setActivityAsCaseType(source.getActivityAsCaseType());
    target.setActivityAsCaseTypeDetails(source.getActivityAsCaseTypeDetails());
    target.setLocation(locationFacade.fromDto(source.getLocation(), checkChangeDate));
    target.setRole(source.getRole());
    target.setTypeOfPlace(source.getTypeOfPlace());
    target.setTypeOfPlaceDetails(source.getTypeOfPlaceDetails());
    target.setMeansOfTransport(source.getMeansOfTransport());
    target.setMeansOfTransportDetails(source.getMeansOfTransportDetails());
    target.setConnectionNumber(source.getConnectionNumber());
    target.setSeatNumber(source.getSeatNumber());
    target.setWorkEnvironment(source.getWorkEnvironment());
    target.setGatheringType(source.getGatheringType());
    target.setGatheringDetails(source.getGatheringDetails());
    target.setHabitationType(source.getHabitationType());
    target.setHabitationDetails(source.getHabitationDetails());
    return target;
}
Also used : ActivityAsCase(de.symeda.sormas.backend.activityascase.ActivityAsCase)

Example 2 with ActivityAsCase

use of de.symeda.sormas.backend.activityascase.ActivityAsCase in project SORMAS-Project by hzi-braunschweig.

the class EpiDataFacadeEjb method fromDto.

public EpiData fromDto(EpiDataDto source, boolean checkChangeDate) {
    if (source == null) {
        return null;
    }
    EpiData target = DtoHelper.fillOrBuildEntity(source, service.getByUuid(source.getUuid()), EpiData::new, checkChangeDate);
    target.setExposureDetailsKnown(source.getExposureDetailsKnown());
    target.setActivityAsCaseDetailsKnown(source.getActivityAsCaseDetailsKnown());
    target.setContactWithSourceCaseKnown(source.getContactWithSourceCaseKnown());
    target.setHighTransmissionRiskArea(source.getHighTransmissionRiskArea());
    target.setLargeOutbreaksArea(source.getLargeOutbreaksArea());
    target.setAreaInfectedAnimals(source.getAreaInfectedAnimals());
    List<Exposure> exposures = new ArrayList<>();
    for (ExposureDto exposureDto : source.getExposures()) {
        Exposure exposure = fromExposureDto(exposureDto, checkChangeDate);
        exposure.setEpiData(target);
        exposures.add(exposure);
    }
    if (!DataHelper.equal(target.getExposures(), exposures)) {
        target.setChangeDateOfEmbeddedLists(new Date());
    }
    target.getExposures().clear();
    target.getExposures().addAll(exposures);
    List<ActivityAsCase> activitiesAsCase = new ArrayList<>();
    for (ActivityAsCaseDto activityAsCaseDto : source.getActivitiesAsCase()) {
        ActivityAsCase activityAsCase = fromActivityAsCaseDto(activityAsCaseDto, checkChangeDate);
        activityAsCase.setEpiData(target);
        activitiesAsCase.add(activityAsCase);
    }
    if (!DataHelper.equal(target.getActivitiesAsCase(), activitiesAsCase)) {
        target.setChangeDateOfEmbeddedLists(new Date());
    }
    target.getActivitiesAsCase().clear();
    target.getActivitiesAsCase().addAll(activitiesAsCase);
    return target;
}
Also used : ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) ActivityAsCaseDto(de.symeda.sormas.api.activityascase.ActivityAsCaseDto) ArrayList(java.util.ArrayList) Exposure(de.symeda.sormas.backend.exposure.Exposure) ActivityAsCase(de.symeda.sormas.backend.activityascase.ActivityAsCase) Date(java.util.Date)

Example 3 with ActivityAsCase

use of de.symeda.sormas.backend.activityascase.ActivityAsCase in project SORMAS-Project by hzi-braunschweig.

the class EpiDataFacadeEjb method toDto.

public static EpiDataDto toDto(EpiData epiData) {
    if (epiData == null) {
        return null;
    }
    EpiDataDto target = new EpiDataDto();
    EpiData source = epiData;
    DtoHelper.fillDto(target, source);
    target.setExposureDetailsKnown(source.getExposureDetailsKnown());
    target.setActivityAsCaseDetailsKnown(source.getActivityAsCaseDetailsKnown());
    target.setContactWithSourceCaseKnown(source.getContactWithSourceCaseKnown());
    target.setHighTransmissionRiskArea(source.getHighTransmissionRiskArea());
    target.setLargeOutbreaksArea(source.getLargeOutbreaksArea());
    target.setAreaInfectedAnimals(source.getAreaInfectedAnimals());
    List<ExposureDto> exposureDtos = new ArrayList<>();
    for (Exposure exposure : source.getExposures()) {
        ExposureDto exposureDto = toExposureDto(exposure);
        exposureDtos.add(exposureDto);
    }
    target.setExposures(exposureDtos);
    List<ActivityAsCaseDto> activityAsCaseDtos = new ArrayList<>();
    for (ActivityAsCase activityAsCase : source.getActivitiesAsCase()) {
        ActivityAsCaseDto activityAsCaseDto = toActivityAsCaseDto(activityAsCase);
        activityAsCaseDtos.add(activityAsCaseDto);
    }
    target.setActivitiesAsCase(activityAsCaseDtos);
    return target;
}
Also used : EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) ActivityAsCaseDto(de.symeda.sormas.api.activityascase.ActivityAsCaseDto) ArrayList(java.util.ArrayList) Exposure(de.symeda.sormas.backend.exposure.Exposure) ActivityAsCase(de.symeda.sormas.backend.activityascase.ActivityAsCase)

Aggregations

ActivityAsCase (de.symeda.sormas.backend.activityascase.ActivityAsCase)3 ActivityAsCaseDto (de.symeda.sormas.api.activityascase.ActivityAsCaseDto)2 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)2 Exposure (de.symeda.sormas.backend.exposure.Exposure)2 ArrayList (java.util.ArrayList)2 EpiDataDto (de.symeda.sormas.api.epidata.EpiDataDto)1 Date (java.util.Date)1