use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.
the class CaseFilterForm method streamFieldsForEmptyCheck.
@SuppressWarnings("rawtypes")
@Override
protected Stream<Field> streamFieldsForEmptyCheck(CustomLayout layout) {
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
return super.streamFieldsForEmptyCheck(layout).filter(f -> f != weekAndDateFilter.getDateFilterOptionFilter());
}
use of de.symeda.sormas.api.caze.NewCaseDateType 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;
}
use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
final RegionReferenceDto region = newValue.getRegion();
final DistrictReferenceDto district = newValue.getDistrict();
applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
final UserDto user = currentUserDto();
ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
if (user.getRegion() != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.CONTACT_OFFICER));
} else if (region != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region, UserRole.CONTACT_OFFICER));
} else {
officerField.removeAllItems();
}
ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
birthDateDD.setEnabled(true);
} else {
birthDateDD.clear();
birthDateDD.setEnabled(false);
}
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
weekAndDateFilter.getDateToFilter().setValue(dateTo);
}
if (StringUtils.isBlank(newValue.getEventLike())) {
clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
} else {
enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
}
ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
ComboBox diseaseVariantField = getField(ContactCriteria.DISEASE_VARIANT);
Disease disease = (Disease) diseaseField.getValue();
if (disease == null) {
FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
FieldHelper.setEnabled(false, diseaseVariantField);
} else {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
}
}
use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method streamFieldsForEmptyCheck.
@Override
@SuppressWarnings("rawtypes")
protected Stream<Field> streamFieldsForEmptyCheck(CustomLayout layout) {
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
return super.streamFieldsForEmptyCheck(layout).filter(f -> f != weekAndDateFilter.getDateFilterOptionFilter());
}
use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.
the class TaskGridFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(TaskCriteria newValue) {
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
TaskDateType taskDateType = newValue.getStartDateFrom() != null ? TaskDateType.SUGGESTED_START_DATE : newValue.getDueDateFrom() != null ? TaskDateType.DUE_DATE : null;
weekAndDateFilter.getDateTypeSelector().setValue(taskDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
Date dateFrom = taskDateType == TaskDateType.SUGGESTED_START_DATE ? newValue.getStartDateFrom() : taskDateType == TaskDateType.DUE_DATE ? newValue.getDueDateFrom() : null;
Date dateTo = taskDateType == TaskDateType.SUGGESTED_START_DATE ? newValue.getStartDateTo() : taskDateType == TaskDateType.DUE_DATE ? newValue.getDueDateTo() : null;
if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
weekAndDateFilter.getDateToFilter().setValue(dateTo);
}
}
Aggregations