use of de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.
the class HUEditorViewFactoryTemplate method createView.
@Override
public final HUEditorView createView(final CreateViewRequest request) {
final ViewId viewId = request.getViewId();
//
// Referencing documentPaths and tableName (i.e. from where are we coming, e.g. receipt schedule)
final Set<DocumentPath> referencingDocumentPaths = request.getReferencingDocumentPaths();
final String referencingTableName = extractReferencingTablename(referencingDocumentPaths);
final SqlViewBinding sqlViewBinding = getSqlViewBinding();
//
// HUEditorView rows repository
final HUEditorViewRepository huEditorViewRepository;
{
final WindowId windowId = viewId.getWindowId();
final boolean attributesAlwaysReadonly = rowAttributesAlwaysReadonlyByReferencingTableName.getOrDefault(referencingTableName, Boolean.TRUE);
final SqlHUEditorViewRepositoryBuilder huEditorViewRepositoryBuilder = SqlHUEditorViewRepository.builder().windowId(windowId).rowProcessedPredicate(getRowProcessedPredicate(referencingTableName)).attributesProvider(HUEditorRowAttributesProvider.builder().readonly(attributesAlwaysReadonly).build()).sqlViewBinding(sqlViewBinding).huReservationService(huReservationService);
customizeHUEditorViewRepository(huEditorViewRepositoryBuilder);
huEditorViewRepository = huEditorViewRepositoryBuilder.build();
}
//
// HUEditorView
{
// Filters
// as long as the deprecated getFilterOnlyIds() is around we can't ignore it
@SuppressWarnings("deprecation") final DocumentFilterList stickyFilters = extractStickyFilters(request.getStickyFilters(), request.getFilterOnlyIds());
final DocumentFilterDescriptorsProvider filterDescriptors = getViewFilterDescriptors();
final DocumentFilterList userFilters = request.getFiltersUnwrapped(filterDescriptors);
// Start building the HUEditorView
final HUEditorViewBuilder huViewBuilder = HUEditorView.builder().setParentViewId(request.getParentViewId()).setParentRowId(request.getParentRowId()).setViewId(viewId).setViewType(request.getViewType()).setStickyFilters(stickyFilters).setFilters(userFilters).setFilterDescriptors(filterDescriptors).setReferencingDocumentPaths(referencingTableName, referencingDocumentPaths).orderBys(sqlViewBinding.getDefaultOrderBys()).setActions(request.getActions()).addAdditionalRelatedProcessDescriptors(request.getAdditionalRelatedProcessDescriptors()).setHUEditorViewRepository(huEditorViewRepository).setUseAutoFilters(request.isUseAutoFilters()).setParameters(request.getParameters());
//
// Call view customizers
getViewCustomizers(referencingTableName).forEach(viewCustomizer -> viewCustomizer.beforeCreate(huViewBuilder));
customizeHUEditorView(huViewBuilder);
return huViewBuilder.build();
}
}
use of de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.
the class SqlViewFactory method filterView.
private DefaultView filterView(@NonNull final DefaultView view, @NonNull final JSONFilterViewRequest filterViewRequest) {
final DocumentFilterDescriptorsProvider filterDescriptors = view.getViewDataRepository().getViewFilterDescriptors();
final DocumentFilterList newFilters = filterViewRequest.getFiltersUnwrapped(filterDescriptors);
// final DocumentFilterList newFiltersExcludingFacets = newFilters.retainOnlyNonFacetFilters();
//
// final DocumentFilterList currentFiltersExcludingFacets = view.getFilters().retainOnlyNonFacetFilters();
//
// if (DocumentFilterList.equals(currentFiltersExcludingFacets, newFiltersExcludingFacets))
// {
// // TODO
// throw new AdempiereException("TODO");
// }
// else
{
return createView(CreateViewRequest.filterViewBuilder(view).setFilters(newFilters).build());
}
}
use of de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.
the class PickingSlotsClearingViewFactory method createView.
@Override
public PickingSlotsClearingView createView(final CreateViewRequest request) {
request.assertNoParentViewOrRow();
final DocumentFilterDescriptorsProvider filterDescriptors = getFilterDescriptorsProvider();
final DocumentFilterList filters = request.getFiltersUnwrapped(filterDescriptors);
final ViewId viewId = ViewId.random(PickingSlotsClearingViewFactory.WINDOW_ID);
final PickingSlotQuery query = createPickingSlotQuery(filters);
return PickingSlotsClearingView.builder().viewId(viewId).rows(() -> pickingSlotRepo.retrievePickingSlotsRows(query)).additionalRelatedProcessDescriptors(createAdditionalRelatedProcessDescriptors()).filterDescriptors(filterDescriptors).filters(filters).build();
}
use of de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.
the class UserQueryDocumentFilterDescriptorsProviderFactory method createFiltersProvider.
@Override
public DocumentFilterDescriptorsProvider createFiltersProvider(@Nullable final AdTabId adTabId, @Nullable final String tableName, final Collection<DocumentFieldDescriptor> fields) {
if (tableName == null || adTabId == null) {
return NullDocumentFilterDescriptorsProvider.instance;
}
Check.assumeNotEmpty(tableName, "tableName is not empty");
final int adTableId = adTablesRepo.retrieveTableId(tableName);
final List<IUserQueryField> searchFields = fields.stream().map(field -> createUserQueryField(field)).collect(ImmutableList.toImmutableList());
final UserQueryRepository repository = UserQueryRepository.builder().setAD_Tab_ID(adTabId.getRepoId()).setAD_Table_ID(adTableId).setAD_User_ID(// FIXME: hardcoded, see https://github.com/metasfresh/metasfresh-webui/issues/162
UserId.METASFRESH.getRepoId()).setSearchFields(searchFields).setColumnDisplayTypeProvider(POInfo.getPOInfo(AdTableId.ofRepoId(adTableId))).build();
return new UserQueryDocumentFilterDescriptorsProvider(repository);
}
use of de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.
the class PackageableViewFactoryV2 method createView.
@Override
public PackageableView createView(final CreateViewRequest request) {
final ViewId viewId = request.getViewId();
viewId.assertWindowId(PickingConstantsV2.WINDOWID_PackageableView);
final DocumentFilterDescriptorsProvider filterDescriptors = getFilterDescriptorsProvider();
final PackageableRowsData rowsData = rowsRepo.newPackageableRowsData().filters(request.getFiltersUnwrapped(filterDescriptors)).stickyFilters(request.getStickyFilters()).build();
return PackageableView.builder().viewId(viewId).rowsData(rowsData).relatedProcessDescriptors(getRelatedProcessDescriptors()).viewFilterDescriptors(filterDescriptors).build();
}
Aggregations