use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class ReportFragment method showReportData.
protected void showReportData() {
User user = ConfigProvider.getUser();
EpiWeek epiWeek = getEpiWeek();
EpiWeekFilterOption filterOption = getEpiWeekFilterOption();
if (epiWeek == null || !ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE)) {
setVisibilityForNoData();
} else {
WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(epiWeek, user);
if (EpiWeekFilterOption.THIS_WEEK.equals(filterOption)) {
// table is shown if the report for the last week has been confirmed; no buttons
reportDate = getResources().getString(R.string.hint_report_not_submitted);
setVisibilityForTable(false);
showPendingReport();
} else if (EpiWeekFilterOption.LAST_WEEK.equals(filterOption)) {
// table is shown, buttons are shown if the report has not been confirmed yet
if (weeklyReport == null) {
setVisibilityForTable(true);
reportDate = getResources().getString(R.string.hint_report_not_submitted);
showPendingReport();
} else {
setVisibilityForTable(false);
reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
showWeeklyReport(weeklyReport);
}
} else {
// any other week;
if (weeklyReport == null) {
if (DateHelper.isEpiWeekAfter(DateHelper.getEpiWeek(new Date()), epiWeek)) {
// 'no data' hint is shown for dates in the future
setVisibilityForNoData();
reportDate = "";
showNoReport();
} else {
// table is shown for dates in the past
setVisibilityForTable(true);
reportDate = getResources().getString(R.string.hint_report_not_submitted);
showPendingReport();
}
} else {
setVisibilityForTable(false);
reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
showWeeklyReport(weeklyReport);
}
}
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class ReportFragment method updateByEpiWeek.
private void updateByEpiWeek() {
EpiWeek epiWeek = getEpiWeek();
// TODO this is only necessary because the field value changes are triggered multiple times
if (DataHelper.equal(epiWeek, lastUpdateEpiWeek)) {
return;
}
lastUpdateEpiWeek = epiWeek;
EpiWeekFilterOption filterOption;
if (epiWeek == null) {
filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
} else if (epiWeek.equals(DateHelper.getPreviousEpiWeek(new Date()))) {
filterOption = EpiWeekFilterOption.LAST_WEEK;
} else if (epiWeek.equals(DateHelper.getEpiWeek(new Date()))) {
filterOption = EpiWeekFilterOption.THIS_WEEK;
} else {
filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
}
if (!DataHelper.equal(contentBinding.reportSelector.getValue(), filterOption)) {
contentBinding.reportSelector.setValue(filterOption);
}
showReportData();
getSubHeadingHandler().updateSubHeadingTitle(getSubHeadingTitle());
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportsFragment method updateByEpiWeek.
private void updateByEpiWeek() {
EpiWeek epiWeek = (EpiWeek) contentBinding.aggregateReportsWeek.getValue();
if (DataHelper.equal(epiWeek, lastUpdateEpiWeek)) {
return;
}
lastUpdateEpiWeek = epiWeek;
EpiWeekFilterOption filterOption;
if (epiWeek == null) {
filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
} else if (epiWeek.equals(DateHelper.getPreviousEpiWeek(new Date()))) {
filterOption = EpiWeekFilterOption.LAST_WEEK;
} else if (epiWeek.equals(DateHelper.getEpiWeek(new Date()))) {
filterOption = EpiWeekFilterOption.THIS_WEEK;
} else {
filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
}
if (!DataHelper.equal(contentBinding.reportSelector.getValue(), filterOption)) {
contentBinding.reportSelector.setValue(filterOption);
}
if (epiWeek != null) {
showReportData();
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportsFragment method showReportData.
private void showReportData() {
User user = ConfigProvider.getUser();
EpiWeek epiWeek = (EpiWeek) contentBinding.aggregateReportsWeek.getValue();
reports = DatabaseHelper.getAggregateReportDao().getReportsByEpiWeekAndUser(epiWeek, user);
contentBinding.reportContent.removeAllViews();
Date latestLocalChangeDate = null;
for (AggregateReport report : reports) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RowReportAggregateLayoutBinding binding = DataBindingUtil.inflate(inflater, R.layout.row_report_aggregate_layout, contentBinding.reportContent, true);
binding.setData(report);
if (latestLocalChangeDate == null || (report.getLocalChangeDate() != null && latestLocalChangeDate.before(report.getLocalChangeDate()))) {
latestLocalChangeDate = report.getLocalChangeDate();
}
}
Resources r = getResources();
if (latestLocalChangeDate == null) {
getSubHeadingHandler().updateSubHeadingTitle(r.getString(R.string.hint_case_numbers_not_submitted));
} else {
getSubHeadingHandler().updateSubHeadingTitle(String.format(r.getString(R.string.caption_latest_submission), DateFormatHelper.formatLocalDateTime(latestLocalChangeDate)));
}
}
use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.
the class EventSelectionField method forSuperordinateEvent.
public static EventSelectionField forSuperordinateEvent(EventDto eventDto, Set<String> excludedUuids) {
EventSelectionField eventSelectionField = new EventSelectionField(eventDto.getDisease(), I18nProperties.getString(Strings.infoPickOrCreateSuperordinateEventForEvent), eventCriteria -> {
eventCriteria.setExcludedUuids(excludedUuids);
eventCriteria.eventDateBetween(null, EventHelper.getStartOrEndDate(eventDto.getStartDate(), eventDto.getEndDate()), null, DateFilterOption.DATE);
});
eventSelectionField.weekAndDateFilter.getDateToFilter().addValueChangeListener(valueChangeEvent -> {
Date selectedToDate = eventSelectionField.weekAndDateFilter.getDateToFilter().getValue();
prepareSuperordinateFilters(eventDto, eventSelectionField, selectedToDate, eventSelectionField.weekAndDateFilter.getDateToFilter());
});
eventSelectionField.weekAndDateFilter.getWeekToFilter().addValueChangeListener(valueChangeEvent -> {
EpiWeek epiWeek = (EpiWeek) eventSelectionField.weekAndDateFilter.getWeekToFilter().getValue();
Date epiWeekEndDate = DateHelper.getEpiWeekEnd(epiWeek);
prepareSuperordinateFilters(eventDto, eventSelectionField, epiWeekEndDate, eventSelectionField.weekAndDateFilter.getWeekToFilter());
});
return eventSelectionField;
}
Aggregations