use of de.metas.ui.web.document.filter.DocumentFilterList 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.DocumentFilterList in project metasfresh-webui-api by metasfresh.
the class CreateViewRequest method deleteStickyFilterBuilder.
public static Builder deleteStickyFilterBuilder(@NonNull final IView view, @NonNull final String stickyFilterIdToDelete) {
final DocumentFilterList stickyFilters = view.getStickyFilters().stream().filter(stickyFilter -> !Objects.equals(stickyFilter.getFilterId(), stickyFilterIdToDelete)).collect(DocumentFilterList.toDocumentFilterList());
// FIXME: instead of removing all referencing document paths (to prevent creating sticky filters from them),
// we shall remove only those is are related to "stickyFilterIdToDelete".
// view.getReferencingDocumentPaths();
final Set<DocumentPath> referencingDocumentPaths = ImmutableSet.of();
return builder(view.getViewId().getWindowId(), view.getViewType()).setProfileId(view.getProfileId()).setParentViewId(view.getParentViewId()).setParentRowId(view.getParentRowId()).setReferencingDocumentPaths(referencingDocumentPaths).setStickyFilters(stickyFilters).setFilters(view.getFilters()).setUseAutoFilters(false).addActions(view.getActions()).addAdditionalRelatedProcessDescriptors(view.getAdditionalRelatedProcessDescriptors());
}
use of de.metas.ui.web.document.filter.DocumentFilterList 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.DocumentFilterList in project metasfresh-webui-api by metasfresh.
the class PickingSlotViewFactory method createView.
/**
* This method is called once for each shipment schedule (left-hand side) and creates the respective picking view (right-hand side)
*
* @param request
* @param allShipmentScheduleIds the shipment schedule IDs to display picking slots for; <br>
* may be {@code null} or empty, in this case we assume that only the given {@code request}'s {@code shipmentScheduleId} is available.
* @return
*/
public PickingSlotView createView(@NonNull final CreateViewRequest request, @Nullable final Set<ShipmentScheduleId> allShipmentScheduleIds) {
final DocumentFilterList filters = request.getFiltersUnwrapped(getFilterDescriptorsProvider());
final ViewId pickingViewId = request.getParentViewId();
final DocumentId pickingRowId = request.getParentRowId();
final ViewId pickingSlotViewId = PickingSlotViewsIndexStorage.createViewId(pickingViewId, pickingRowId);
final ShipmentScheduleId currentShipmentScheduleId = extractCurrentShipmentScheduleId(request);
final PickingSlotRepoQuery query = createPickingSlotRowsQuery(filters, currentShipmentScheduleId, allShipmentScheduleIds);
final Supplier<List<PickingSlotRow>> rowsSupplier = () -> pickingSlotRepo.retrieveRows(query);
return PickingSlotView.builder().viewId(pickingSlotViewId).parentViewId(pickingViewId).parentRowId(pickingRowId).currentShipmentScheduleId(currentShipmentScheduleId).rowsSupplier(rowsSupplier).additionalRelatedProcessDescriptors(createAdditionalRelatedProcessDescriptors()).filters(filters).build();
}
use of de.metas.ui.web.document.filter.DocumentFilterList in project metasfresh-webui-api by metasfresh.
the class HUEditorViewBuilder method createRowsBuffer.
HUEditorViewBuffer createRowsBuffer(@NonNull final SqlDocumentFilterConverterContext context) {
final ViewId viewId = getViewId();
final DocumentFilterList stickyFilters = getStickyFilters();
final DocumentFilterList filters = getFilters();
if (HUEditorViewBuffer_HighVolume.isHighVolume(stickyFilters)) {
return new HUEditorViewBuffer_HighVolume(viewId, huEditorViewRepository, stickyFilters, filters, getOrderBys(), context);
} else {
return new HUEditorViewBuffer_FullyCached(viewId, huEditorViewRepository, stickyFilters, filters, getOrderBys(), context);
}
}
Aggregations