Search in sources :

Example 1 with DocumentFilterDescriptorsProvider

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();
    }
}
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 DocumentFilterDescriptorsProvider

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

Example 3 with DocumentFilterDescriptorsProvider

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

Example 4 with DocumentFilterDescriptorsProvider

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);
}
Also used : UserId(de.metas.user.UserId) Check(de.metas.util.Check) Collection(java.util.Collection) NullDocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.NullDocumentFilterDescriptorsProvider) AdTableId(org.adempiere.ad.table.api.AdTableId) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider) DocumentFilterDescriptorsProviderFactory(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProviderFactory) Services(de.metas.util.Services) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) Component(org.springframework.stereotype.Component) List(java.util.List) AdTabId(org.adempiere.ad.element.api.AdTabId) ImmutableList(com.google.common.collect.ImmutableList) UserQueryRepository(org.compiere.apps.search.UserQueryRepository) IUserQueryField(org.compiere.apps.search.IUserQueryField) POInfo(org.compiere.model.POInfo) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) Nullable(javax.annotation.Nullable) IUserQueryField(org.compiere.apps.search.IUserQueryField) UserQueryRepository(org.compiere.apps.search.UserQueryRepository)

Example 5 with DocumentFilterDescriptorsProvider

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

Aggregations

DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider)7 DocumentFilterList (de.metas.ui.web.document.filter.DocumentFilterList)4 ViewId (de.metas.ui.web.view.ViewId)3 ImmutableList (com.google.common.collect.ImmutableList)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 CCache (de.metas.cache.CCache)1 HuId (de.metas.handlingunits.HuId)1 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 HUAttributeConstants (de.metas.handlingunits.attribute.HUAttributeConstants)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 HUReservationService (de.metas.handlingunits.reservation.HUReservationService)1 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 LogManager (de.metas.logging.LogManager)1 PickingSlotQuery (de.metas.picking.api.PickingSlotQuery)1