use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class ReportsView method updateEpiWeeks.
private void updateEpiWeeks(int year, int week) {
List<EpiWeek> epiWeekList = DateHelper.createEpiWeekList(year);
for (EpiWeek epiWeek : epiWeekList) {
epiWeekFilter.addItem(epiWeek.getWeek());
epiWeekFilter.setItemCaption(epiWeek.getWeek(), epiWeek.toString());
}
epiWeekFilter.select(week);
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportOfficersGrid method reload.
public void reload(RegionReferenceDto region, int year, int week) {
this.region = region;
this.week = week;
this.year = year;
getContainer().removeAllItems();
EpiWeek epiWeek = new EpiWeek(year, week);
List<WeeklyReportOfficerSummaryDto> summaryDtos = FacadeProvider.getWeeklyReportFacade().getSummariesPerOfficer(region, epiWeek);
summaryDtos.forEach(s -> getContainer().addItem(s));
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportOfficersGrid method itemClick.
@Override
public void itemClick(ItemClickEvent event) {
if (event.getPropertyId().equals(VIEW_DETAILS_BTN_ID)) {
WeeklyReportOfficerSummaryDto summaryDto = (WeeklyReportOfficerSummaryDto) event.getItemId();
if (summaryDto.getInformants() > 0) {
VerticalLayout layout = new VerticalLayout();
layout.setSizeUndefined();
layout.setMargin(true);
Window window = VaadinUiUtil.showPopupWindow(layout);
WeeklyReportInformantsGrid grid = new WeeklyReportInformantsGrid(summaryDto.getOfficer(), new EpiWeek(year, week));
grid.setWidth(960, Unit.PIXELS);
grid.setHeightMode(HeightMode.ROW);
grid.setHeightUndefined();
layout.addComponent(grid);
window.setCaption(String.format(I18nProperties.getCaption(Captions.weeklyReportsInDistrict), summaryDto.getDistrict().toString()) + " - " + I18nProperties.getString(Strings.epiWeek) + " " + week + "/" + year);
}
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class StatisticsHelper method getTimeGroupingKeys.
/**
* @param attribute
* @param subAttribute
* @param caseFacade Needed for StatisticsCaseAttribute.ONSET_TIME, REPORT_TIME, OUTCOME_TIME
* @return
*/
public static List<StatisticsGroupingKey> getTimeGroupingKeys(StatisticsCaseAttribute attribute, StatisticsCaseSubAttribute subAttribute, CaseFacade caseFacade) {
Date oldestCaseDate = null;
switch(attribute) {
case ONSET_TIME:
oldestCaseDate = caseFacade.getOldestCaseOnsetDate();
break;
case REPORT_TIME:
oldestCaseDate = caseFacade.getOldestCaseReportDate();
break;
case OUTCOME_TIME:
oldestCaseDate = caseFacade.getOldestCaseOutcomeDate();
break;
default:
return new ArrayList<>();
}
LocalDate earliest = oldestCaseDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate now = LocalDate.now();
switch(subAttribute) {
case YEAR:
List<StatisticsGroupingKey> years = new ArrayList<>();
for (int i = earliest.getYear(); i <= now.getYear(); i++) {
years.add(new Year(i));
}
return years;
case QUARTER:
List<StatisticsGroupingKey> quarters = new ArrayList<>();
for (int i = 1; i <= 4; i++) {
quarters.add(new Quarter(i));
}
return quarters;
case MONTH:
return toGroupingKeys(Month.values());
case EPI_WEEK:
List<StatisticsGroupingKey> epiWeeks = new ArrayList<>();
for (int i = 1; i <= DateHelper.getMaximumEpiWeekNumber(); i++) {
epiWeeks.add(new EpiWeek(null, i));
}
return epiWeeks;
case QUARTER_OF_YEAR:
List<StatisticsGroupingKey> quarterOfYearList = new ArrayList<>();
QuarterOfYear earliestQuarter = new QuarterOfYear(new Quarter(1), new Year(earliest.getYear()));
QuarterOfYear latestQuarter = new QuarterOfYear(new Quarter(4), new Year(now.getYear()));
while (earliestQuarter.getYear().getValue() <= latestQuarter.getYear().getValue()) {
quarterOfYearList.add(new QuarterOfYear(earliestQuarter.getQuarter(), earliestQuarter.getYear()));
earliestQuarter.increaseQuarter();
}
return quarterOfYearList;
case MONTH_OF_YEAR:
List<StatisticsGroupingKey> monthOfYearList = new ArrayList<>();
for (int year = earliest.getYear(); year <= now.getYear(); year++) {
for (Month month : Month.values()) {
monthOfYearList.add(new MonthOfYear(month, year));
}
}
return monthOfYearList;
case EPI_WEEK_OF_YEAR:
List<StatisticsGroupingKey> epiWeekOfYearList = new ArrayList<>();
for (int year = earliest.getYear(); year <= now.getYear(); year++) {
epiWeekOfYearList.addAll(DateHelper.createEpiWeekList(year));
}
return epiWeekOfYearList;
default:
return new ArrayList<>();
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class DashboardFilterLayout method createCustomDateFilterLayout.
private HorizontalLayout createCustomDateFilterLayout() {
// Custom filter
customDateFilterLayout = new HorizontalLayout();
customDateFilterLayout.setSpacing(true);
customDateFilterLayout.setVisible(false);
// 'Apply custom filter' button
Button applyButton = ButtonHelper.createButton(Captions.dashboardApplyCustomFilter, null, CssStyles.FORCE_CAPTION, CssStyles.BUTTON_FILTER_LIGHT);
// Date & Epi Week filter
EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(true, true, I18nProperties.getString(Strings.infoCaseDate), null);
customDateFilterLayout.addComponents(weekAndDateFilter, applyButton);
// Apply button listener
applyButton.addClickListener(e -> {
currentDateFilterType = DateFilterType.CUSTOM;
DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
Date fromDate = null;
Date toDate = null;
EpiWeek fromWeek = null;
EpiWeek toWeek = null;
if (dateFilterOption == DateFilterOption.DATE) {
fromDate = weekAndDateFilter.getDateFromFilter().getValue();
toDate = weekAndDateFilter.getDateToFilter().getValue();
setDateFilter(DateHelper.getStartOfDay(fromDate), DateHelper.getEndOfDay(toDate));
} else {
fromWeek = (EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue();
toWeek = (EpiWeek) weekAndDateFilter.getWeekToFilter().getValue();
setDateFilter(DateHelper.getEpiWeekStart(fromWeek), DateHelper.getEpiWeekEnd(toWeek));
}
if ((fromDate != null && toDate != null) || (fromWeek != null && toWeek != null)) {
if (dateFilterOption == DateFilterOption.DATE) {
btnCurrentPeriod.setCaption(DateFormatHelper.buildPeriodString(fromDate, toDate));
int activePeriodLength = DateHelper.getDaysBetween(fromDate, toDate);
btnPeriodBefore.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardPeriodBefore), DateFormatHelper.buildPeriodString(DateHelper.subtractDays(fromDate, activePeriodLength), DateHelper.subtractDays(toDate, activePeriodLength))));
btnPeriodLastYear.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardSamePeriodLastYear), DateFormatHelper.buildPeriodString(DateHelper.subtractYears(fromDate, 1), DateHelper.subtractYears(toDate, 1))));
} else {
btnCurrentPeriod.setCaption(fromWeek.toShortString() + " - " + toWeek.toShortString());
Date firstEpiWeekStart = DateHelper.getEpiWeekStart(fromWeek);
Date lastEpiWeekStart = DateHelper.getEpiWeekStart(toWeek);
int epiWeeksBetween = DateHelper.getWeeksBetween(firstEpiWeekStart, lastEpiWeekStart);
btnPeriodBefore.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardPeriodBefore), DateHelper.getEpiWeek(DateHelper.subtractWeeks(firstEpiWeekStart, epiWeeksBetween)).toShortString() + " - " + DateHelper.getEpiWeek(DateHelper.subtractWeeks(lastEpiWeekStart, epiWeeksBetween)).toShortString()));
btnPeriodLastYear.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardSamePeriodLastYear), DateHelper.getEpiWeekYearBefore(fromWeek).toShortString() + " - " + DateHelper.getEpiWeekYearBefore(toWeek).toShortString()));
}
updateComparisonButtons(DateFilterType.CUSTOM, null, null, true);
} else {
if (dateFilterOption == DateFilterOption.DATE) {
new Notification(I18nProperties.getString(Strings.headingMissingDateFilter), I18nProperties.getString(Strings.messageMissingDateFilter), Type.ERROR_MESSAGE, false).show(Page.getCurrent());
} else {
new Notification(I18nProperties.getString(Strings.headingMissingEpiWeekFilter), I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.ERROR_MESSAGE, false).show(Page.getCurrent());
}
}
});
return customDateFilterLayout;
}
Aggregations