Search in sources :

Example 1 with DocumentFilterList

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();
    }
}
Also used : SqlViewRowFieldBinding(de.metas.ui.web.view.descriptor.SqlViewRowFieldBinding) Autowired(org.springframework.beans.factory.annotation.Autowired) ImmutableDocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.ImmutableDocumentFilterDescriptorsProvider) ISysConfigBL(org.adempiere.service.ISysConfigBL) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) GuavaCollectors(de.metas.util.GuavaCollectors) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) PanelLayoutType(de.metas.ui.web.window.datatypes.PanelLayoutType) ConstantQueryFilter(org.adempiere.ad.dao.ConstantQueryFilter) IViewFactory(de.metas.ui.web.view.IViewFactory) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) Collection(java.util.Collection) DocumentFilterParamDescriptor(de.metas.ui.web.document.filter.DocumentFilterParamDescriptor) Set(java.util.Set) IQueryBuilder(org.adempiere.ad.dao.IQueryBuilder) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) ISqlQueryFilter(org.adempiere.ad.dao.ISqlQueryFilter) Objects(java.util.Objects) HUAttributeConstants(de.metas.handlingunits.attribute.HUAttributeConstants) List(java.util.List) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) SqlHUEditorViewRepositoryBuilder(de.metas.ui.web.handlingunits.SqlHUEditorViewRepository.SqlHUEditorViewRepositoryBuilder) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) LogManager(de.metas.logging.LogManager) IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) PlainContextAware(org.adempiere.model.PlainContextAware) DocumentFilterDescriptor(de.metas.ui.web.document.filter.DocumentFilterDescriptor) SqlViewBindingFactory(de.metas.ui.web.view.descriptor.SqlViewBindingFactory) Value(lombok.Value) IADWindowDAO(org.adempiere.ad.window.api.IADWindowDAO) ImmutableList(com.google.common.collect.ImmutableList) I_AD_Tab(org.compiere.model.I_AD_Tab) SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) SqlSelectValue(de.metas.ui.web.window.descriptor.sql.SqlSelectValue) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) I_M_HU(de.metas.handlingunits.model.I_M_HU) BarcodeScannerType(de.metas.process.BarcodeScannerType) Nullable(javax.annotation.Nullable) Check(de.metas.util.Check) SqlDocumentFilterConverterContext(de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverterContext) Logger(org.slf4j.Logger) DocumentDescriptorFactory(de.metas.ui.web.window.descriptor.factory.DocumentDescriptorFactory) InArrayQueryFilter(org.adempiere.ad.dao.impl.InArrayQueryFilter) ViewProfileId(de.metas.ui.web.view.ViewProfileId) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider) WindowId(de.metas.ui.web.window.datatypes.WindowId) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) CCache(de.metas.cache.CCache) Services(de.metas.util.Services) SqlDocumentFilterConverter(de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter) HuId(de.metas.handlingunits.HuId) HUReservationService(de.metas.handlingunits.reservation.HUReservationService) SqlViewFactory(de.metas.ui.web.view.SqlViewFactory) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) LayoutFactory(de.metas.ui.web.window.descriptor.factory.standard.LayoutFactory) SqlParamsCollector(de.metas.ui.web.document.filter.sql.SqlParamsCollector) ViewId(de.metas.ui.web.view.ViewId) WindowId(de.metas.ui.web.window.datatypes.WindowId) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) ViewId(de.metas.ui.web.view.ViewId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) SqlHUEditorViewRepositoryBuilder(de.metas.ui.web.handlingunits.SqlHUEditorViewRepository.SqlHUEditorViewRepositoryBuilder) ITranslatableString(de.metas.i18n.ITranslatableString) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) ImmutableDocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.ImmutableDocumentFilterDescriptorsProvider) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider)

Example 2 with DocumentFilterList

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());
}
Also used : DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Getter(lombok.Getter) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) ArrayList(java.util.ArrayList) Value(lombok.Value) LinkedHashMap(java.util.LinkedHashMap) ViewActionDescriptorsFactory(de.metas.ui.web.process.view.ViewActionDescriptorsFactory) AccessLevel(lombok.AccessLevel) ImmutableList(com.google.common.collect.ImmutableList) Characteristic(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) Map(java.util.Map) ToString(lombok.ToString) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) JSONFilterViewRequest(de.metas.ui.web.view.json.JSONFilterViewRequest) JSONDocumentFilter(de.metas.ui.web.document.filter.json.JSONDocumentFilter) LinkedHashSet(java.util.LinkedHashSet) Check(de.metas.util.Check) ViewActionDescriptorsList(de.metas.ui.web.process.view.ViewActionDescriptorsList) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) NonNull(lombok.NonNull) Collection(java.util.Collection) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) Set(java.util.Set) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider) WindowId(de.metas.ui.web.window.datatypes.WindowId) Objects(java.util.Objects) List(java.util.List) AdempiereException(org.adempiere.exceptions.AdempiereException) CollectionUtils(de.metas.util.collections.CollectionUtils) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList)

Example 3 with DocumentFilterList

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());
    }
}
Also used : DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider)

Example 4 with DocumentFilterList

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();
}
Also used : ViewId(de.metas.ui.web.view.ViewId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ShipmentScheduleId(de.metas.inoutcandidate.api.ShipmentScheduleId) ImmutableList(com.google.common.collect.ImmutableList) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) List(java.util.List) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList)

Example 5 with DocumentFilterList

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);
    }
}
Also used : ViewId(de.metas.ui.web.view.ViewId) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList)

Aggregations

DocumentFilterList (de.metas.ui.web.document.filter.DocumentFilterList)10 DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider)5 ViewId (de.metas.ui.web.view.ViewId)5 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)4 List (java.util.List)4 ImmutableList (com.google.common.collect.ImmutableList)3 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)3 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)3 WindowId (de.metas.ui.web.window.datatypes.WindowId)3 Check (de.metas.util.Check)3 Collection (java.util.Collection)3 Set (java.util.Set)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 LogManager (de.metas.logging.LogManager)2 SqlDocumentFilterConverter (de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter)2 SqlDocumentFilterConverterContext (de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverterContext)2 SqlParamsCollector (de.metas.ui.web.document.filter.sql.SqlParamsCollector)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 Objects (java.util.Objects)2