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;
}
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());
}
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);
}
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;
}
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;
}
Aggregations