use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method onApplyClick.
private void onApplyClick(EpiWeekAndDateFilterComponent<ContactDateType> weekAndDateFilter) {
ContactCriteria criteria = getValue();
DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
Date fromDate, toDate;
if (dateFilterOption == DateFilterOption.DATE) {
Date dateFrom = weekAndDateFilter.getDateFromFilter().getValue();
fromDate = dateFrom != null ? DateHelper.getStartOfDay(dateFrom) : null;
Date dateTo = weekAndDateFilter.getDateToFilter().getValue();
toDate = dateFrom != null ? DateHelper.getEndOfDay(dateTo) : null;
} else {
fromDate = DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
}
if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
ContactDateType contactDateType = (ContactDateType) weekAndDateFilter.getDateTypeSelector().getValue();
if (contactDateType == ContactDateType.LAST_CONTACT_DATE) {
criteria.lastContactDateBetween(fromDate, toDate);
criteria.reportDateBetween(null, null);
} else {
criteria.reportDateBetween(fromDate, toDate);
criteria.lastContactDateBetween(null, null);
}
criteria.dateFilterOption(dateFilterOption);
} else {
weekAndDateFilter.setNotificationsForMissingFilters();
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportRegionsGrid method reload.
public void reload(int year, int week) {
this.week = week;
this.year = year;
getContainer().removeAllItems();
EpiWeek epiWeek = new EpiWeek(year, week);
List<WeeklyReportRegionSummaryDto> summaryDtos = FacadeProvider.getWeeklyReportFacade().getSummariesPerRegion(epiWeek);
summaryDtos.forEach(s -> getContainer().addItem(s));
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportsView method enter.
@Override
public void enter(ViewChangeEvent event) {
EpiWeek epiWeekFrom = criteria.getEpiWeekFrom();
EpiWeek epiWeekTo = criteria.getEpiWeekTo();
String params = event.getParameters().trim();
if (params.startsWith("?")) {
params = params.substring(1);
criteria.fromUrlParams(params);
}
if (criteria.getEpiWeekFrom() == null) {
criteria.setEpiWeekFrom(epiWeekFrom);
}
if (criteria.getEpiWeekTo() == null) {
criteria.setEpiWeekTo(epiWeekTo);
}
grid.reload();
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class CaseFilterForm method onApplyClick.
private void onApplyClick(EpiWeekAndDateFilterComponent<CriteriaDateType> weekAndDateFilter) {
DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
Date fromDate, toDate;
if (dateFilterOption == DateFilterOption.DATE) {
Date dateFrom = weekAndDateFilter.getDateFromFilter().getValue();
fromDate = dateFrom != null ? DateHelper.getStartOfDay(dateFrom) : null;
Date dateTo = weekAndDateFilter.getDateToFilter().getValue();
toDate = dateFrom != null ? DateHelper.getEndOfDay(dateTo) : null;
} else {
fromDate = DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
}
if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
CaseCriteria criteria = getValue();
CriteriaDateType newCaseDateType = (CriteriaDateType) weekAndDateFilter.getDateTypeSelector().getValue();
criteria.newCaseDateBetween(fromDate, toDate, newCaseDateType != null ? newCaseDateType : NewCaseDateType.MOST_RELEVANT);
criteria.dateFilterOption(dateFilterOption);
} else {
weekAndDateFilter.setNotificationsForMissingFilters();
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportFacadeEjb method saveWeeklyReport.
@Override
@RolesAllowed(UserRight._WEEKLYREPORT_CREATE)
public WeeklyReportDto saveWeeklyReport(@Valid WeeklyReportDto dto) {
// Don't create a new report if there already is one in the database for the user/epi week combination
WeeklyReportDto existingReport = getByEpiWeekAndUser(new EpiWeek(dto.getYear(), dto.getEpiWeek()), dto.getReportingUser());
if (existingReport != null && !dto.getUuid().equals(existingReport.getUuid())) {
logger.warn("Tried to create a new report for an already existing user/epi week combination (existing UUID: " + existingReport.getUuid() + "); report was not created");
return null;
}
WeeklyReport report = fromDto(dto, true);
weeklyReportService.ensurePersisted(report);
return toDto(report);
}
Aggregations