private TaskGroupPredicate createPredicate() { List<FilterPair> listFilters = (List<FilterPair>) bdFilters .getSelectedElements(); Date startDate = filterStartDate.getValue(); Date finishDate = filterFinishDate.getValue(); Boolean includeOrderElements = checkIncludeOrderElements.isChecked(); if (startDate == null && finishDate == null) { TaskGroupPredicate predicate = model .getDefaultPredicate(includeOrderElements); //show filter dates calculated by default on screen if (model.getFilterStartDate() != null && !FilterUtils.hasProjectsStartDateChanged()) { filterStartDate.setValue(model.getFilterStartDate()); } if (model.getFilterFinishDate() != null && !FilterUtils.hasProjectsEndDateChanged()) { filterFinishDate.setValue(model.getFilterFinishDate()); } predicate.setFilters(listFilters); return predicate; } return new TaskGroupPredicate(listFilters, startDate, finishDate, includeOrderElements); }
private void loadPredefinedBandboxFilter() { User user = model.getUser(); List<FilterPair> sessionFilterPairs = FilterUtils .readProjectsParameters(); if (sessionFilterPairs != null) { bdFilters.addSelectedElements(sessionFilterPairs); } else if ((user != null) && (user.getProjectsFilterLabel() != null)) { bdFilters.clear(); bdFilters.addSelectedElement(new FilterPair( TaskGroupFilterEnum.Label, user.getProjectsFilterLabel() .getFinderPattern(), user .getProjectsFilterLabel())); } // Calculate filter based on user preferences if (user != null) { if ((filterStartDate.getValue() == null) && !FilterUtils.hasProjectsStartDateChanged() && (user.getProjectsFilterPeriodSince() != null)) { filterStartDate.setValue(new LocalDate() .minusMonths(user.getProjectsFilterPeriodSince()) .toDateTimeAtStartOfDay().toDate()); } if (filterFinishDate.getValue() == null && !FilterUtils.hasProjectsEndDateChanged() && (user.getProjectsFilterPeriodTo() != null)) { filterFinishDate.setValue(new LocalDate() .plusMonths(user.getProjectsFilterPeriodTo()) .toDateMidnight().toDate()); } } }