Search in sources :

Example 1 with WeeklyReportEntryDto

use of de.symeda.sormas.api.report.WeeklyReportEntryDto in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportFacadeEjb method toDto.

public static WeeklyReportDto toDto(WeeklyReport source) {
    if (source == null) {
        return null;
    }
    WeeklyReportDto target = new WeeklyReportDto();
    DtoHelper.fillDto(target, source);
    target.setReportingUser(UserFacadeEjb.toReferenceDto(source.getReportingUser()));
    target.setReportDateTime(source.getReportDateTime());
    target.setDistrict(DistrictFacadeEjb.toReferenceDto(source.getDistrict()));
    target.setCommunity(CommunityFacadeEjb.toReferenceDto(source.getCommunity()));
    target.setHealthFacility(FacilityFacadeEjb.toReferenceDto(source.getHealthFacility()));
    target.setAssignedOfficer(UserFacadeEjb.toReferenceDto(source.getAssignedOfficer()));
    target.setTotalNumberOfCases(source.getTotalNumberOfCases());
    target.setYear(source.getYear());
    target.setEpiWeek(source.getEpiWeek());
    List<WeeklyReportEntryDto> entryDtos = new ArrayList<>();
    for (WeeklyReportEntry entry : source.getReportEntries()) {
        WeeklyReportEntryDto entryDto = toDto(entry);
        entryDtos.add(entryDto);
    }
    target.setReportEntries(entryDtos);
    return target;
}
Also used : ArrayList(java.util.ArrayList) WeeklyReportEntryDto(de.symeda.sormas.api.report.WeeklyReportEntryDto) WeeklyReportDto(de.symeda.sormas.api.report.WeeklyReportDto)

Example 2 with WeeklyReportEntryDto

use of de.symeda.sormas.api.report.WeeklyReportEntryDto in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportDtoHelper method fillInnerFromAdo.

@Override
public void fillInnerFromAdo(WeeklyReportDto target, WeeklyReport source) {
    if (source.getReportingUser() != null) {
        User reportingUser = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
        target.setReportingUser(UserDtoHelper.toReferenceDto(reportingUser));
    } else {
        target.setReportingUser(null);
    }
    if (source.getDistrict() != null) {
        District district = DatabaseHelper.getDistrictDao().queryForId(source.getDistrict().getId());
        target.setDistrict(DistrictDtoHelper.toReferenceDto(district));
    } else {
        target.setDistrict(null);
    }
    if (source.getCommunity() != null) {
        Community community = DatabaseHelper.getCommunityDao().queryForId(source.getCommunity().getId());
        target.setCommunity(CommunityDtoHelper.toReferenceDto(community));
    } else {
        target.setCommunity(null);
    }
    if (source.getHealthFacility() != null) {
        Facility facility = DatabaseHelper.getFacilityDao().queryForId(source.getHealthFacility().getId());
        target.setHealthFacility(FacilityDtoHelper.toReferenceDto(facility));
    } else {
        target.setHealthFacility(null);
    }
    if (source.getAssignedOfficer() != null) {
        User assignedOfficer = DatabaseHelper.getUserDao().queryForId(source.getAssignedOfficer().getId());
        target.setAssignedOfficer(UserDtoHelper.toReferenceDto(assignedOfficer));
    } else {
        target.setAssignedOfficer(null);
    }
    List<WeeklyReportEntryDto> entryDtos = new ArrayList<>();
    if (!source.getReportEntries().isEmpty()) {
        for (WeeklyReportEntry entry : source.getReportEntries()) {
            WeeklyReportEntryDto entryDto = entryDtoHelper.adoToDto(entry);
            entryDtos.add(entryDto);
        }
    }
    target.setReportEntries(entryDtos);
    target.setReportDateTime(source.getReportDateTime());
    target.setTotalNumberOfCases(source.getTotalNumberOfCases());
    target.setYear(source.getYear());
    target.setEpiWeek(source.getEpiWeek());
}
Also used : User(de.symeda.sormas.app.backend.user.User) ArrayList(java.util.ArrayList) Facility(de.symeda.sormas.app.backend.facility.Facility) WeeklyReportEntryDto(de.symeda.sormas.api.report.WeeklyReportEntryDto) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community)

Example 3 with WeeklyReportEntryDto

use of de.symeda.sormas.api.report.WeeklyReportEntryDto in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportDtoHelper method fillInnerFromDto.

@Override
public void fillInnerFromDto(WeeklyReport target, WeeklyReportDto source) {
    target.setReportingUser(DatabaseHelper.getUserDao().getByReferenceDto(source.getReportingUser()));
    target.setReportDateTime(source.getReportDateTime());
    target.setDistrict(DatabaseHelper.getDistrictDao().getByReferenceDto(source.getDistrict()));
    target.setCommunity(DatabaseHelper.getCommunityDao().getByReferenceDto(source.getCommunity()));
    target.setHealthFacility(DatabaseHelper.getFacilityDao().getByReferenceDto(source.getHealthFacility()));
    target.setAssignedOfficer(DatabaseHelper.getUserDao().getByReferenceDto(source.getAssignedOfficer()));
    target.setTotalNumberOfCases(source.getTotalNumberOfCases());
    target.setYear(source.getYear());
    target.setEpiWeek(source.getEpiWeek());
    // just recreate all of this and throw the old stuff away
    List<WeeklyReportEntry> entries = new ArrayList<>();
    if (!source.getReportEntries().isEmpty()) {
        for (WeeklyReportEntryDto entryDto : source.getReportEntries()) {
            WeeklyReportEntry entry = entryDtoHelper.fillOrCreateFromDto(null, entryDto);
            entry.setWeeklyReport(target);
            entries.add(entry);
        }
    }
    target.setReportEntries(entries);
}
Also used : ArrayList(java.util.ArrayList) WeeklyReportEntryDto(de.symeda.sormas.api.report.WeeklyReportEntryDto)

Example 4 with WeeklyReportEntryDto

use of de.symeda.sormas.api.report.WeeklyReportEntryDto in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportFacadeEjb method toDto.

public static WeeklyReportEntryDto toDto(WeeklyReportEntry source) {
    if (source == null) {
        return null;
    }
    WeeklyReportEntryDto target = new WeeklyReportEntryDto();
    DtoHelper.fillDto(target, source);
    target.setDisease(source.getDisease());
    target.setNumberOfCases(source.getNumberOfCases());
    return target;
}
Also used : WeeklyReportEntryDto(de.symeda.sormas.api.report.WeeklyReportEntryDto)

Example 5 with WeeklyReportEntryDto

use of de.symeda.sormas.api.report.WeeklyReportEntryDto in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportFacadeEjb method fromDto.

public WeeklyReport fromDto(@NotNull WeeklyReportDto source, boolean checkChangeDate) {
    WeeklyReport target = DtoHelper.fillOrBuildEntity(source, weeklyReportService.getByUuid(source.getUuid()), WeeklyReport::new, checkChangeDate);
    target.setReportingUser(userService.getByReferenceDto(source.getReportingUser()));
    target.setReportDateTime(source.getReportDateTime());
    target.setDistrict(districtService.getByReferenceDto(source.getDistrict()));
    target.setCommunity(communityService.getByReferenceDto(source.getCommunity()));
    target.setHealthFacility(facilityService.getByReferenceDto(source.getHealthFacility()));
    target.setAssignedOfficer(userService.getByReferenceDto(source.getAssignedOfficer()));
    target.setTotalNumberOfCases(source.getTotalNumberOfCases());
    target.setYear(source.getYear());
    target.setEpiWeek(source.getEpiWeek());
    List<WeeklyReportEntry> entries = new ArrayList<>();
    for (WeeklyReportEntryDto entryDto : source.getReportEntries()) {
        WeeklyReportEntry entry = fromDto(entryDto, checkChangeDate);
        entry.setWeeklyReport(target);
        entries.add(entry);
    }
    if (!DataHelper.equal(target.getReportEntries(), entries)) {
        target.setChangeDateOfEmbeddedLists(new Date());
    }
    target.getReportEntries().clear();
    target.getReportEntries().addAll(entries);
    return target;
}
Also used : ArrayList(java.util.ArrayList) WeeklyReportEntryDto(de.symeda.sormas.api.report.WeeklyReportEntryDto) Date(java.util.Date) LocalDate(java.time.LocalDate)

Aggregations

WeeklyReportEntryDto (de.symeda.sormas.api.report.WeeklyReportEntryDto)5 ArrayList (java.util.ArrayList)4 WeeklyReportDto (de.symeda.sormas.api.report.WeeklyReportDto)1 Facility (de.symeda.sormas.app.backend.facility.Facility)1 Community (de.symeda.sormas.app.backend.region.Community)1 District (de.symeda.sormas.app.backend.region.District)1 User (de.symeda.sormas.app.backend.user.User)1 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1