use of de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic in project metasfresh-webui-api by metasfresh.
the class DocumentFilterDescriptorsProviderFactory method createFiltersProvider_Defaults.
/**
* Creates standard filters, i.e. from document fields which are flagged with {@link Characteristic#AllowFiltering}.
*
* @param fields
*/
private ImmutableDocumentFilterDescriptorsProvider createFiltersProvider_Defaults(final Collection<DocumentFieldDescriptor> fields) {
final DocumentFilterDescriptor.Builder defaultFilter = DocumentFilterDescriptor.builder().setFilterId(FILTER_ID_Default).setDisplayName(msgBL.getTranslatableMsgText(MSG_DefaultFilterName)).setFrequentUsed(false);
final DocumentFilterDescriptor.Builder defaultDateFilter = DocumentFilterDescriptor.builder().setFilterId(FILTER_ID_DefaultDate).setFrequentUsed(true);
final List<DocumentFieldDescriptor> filteringFields = fields.stream().filter(DocumentFieldDescriptor::isDefaultFilterField).sorted(Ordering.natural().onResultOf(field -> field.getDefaultFilterInfo().getSeqNo())).collect(ImmutableList.toImmutableList());
for (final DocumentFieldDescriptor field : filteringFields) {
final DocumentFilterParamDescriptor.Builder filterParam = createFilterParam(field);
if (!defaultDateFilter.hasParameters() && filterParam.getWidgetType().isDateOrTime()) {
defaultDateFilter.setDisplayName(filterParam.getDisplayName());
defaultDateFilter.addParameter(filterParam);
} else {
defaultFilter.addParameter(filterParam);
}
}
return Stream.of(defaultDateFilter, defaultFilter).filter(filterBuilder -> filterBuilder.hasParameters()).map(filterBuilder -> filterBuilder.build()).collect(ImmutableDocumentFilterDescriptorsProvider.collector());
}
Aggregations