Search in sources :

Example 1 with DocumentFilterDescriptorsProvider

use of de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.

the class SqlViewFactory method createViewBinding.

private SqlViewBinding createViewBinding(@NonNull final SqlViewBindingKey key) {
    final WindowId windowId = key.getWindowId();
    final DocumentEntityDescriptor entityDescriptor = documentDescriptorFactory.getDocumentEntityDescriptor(windowId);
    final Set<String> displayFieldNames = entityDescriptor.getFieldNamesWithCharacteristic(key.getRequiredFieldCharacteristic());
    final SqlDocumentEntityDataBindingDescriptor entityBinding = SqlDocumentEntityDataBindingDescriptor.cast(entityDescriptor.getDataBinding());
    final DocumentFilterDescriptorsProvider filterDescriptors = entityDescriptor.getFilterDescriptors();
    final SqlViewBinding.Builder builder = createBuilderForEntityBindingAndFieldNames(entityBinding, displayFieldNames).filterDescriptors(filterDescriptors).viewInvalidationAdvisor(getViewInvalidationAdvisor(windowId));
    if (windowId2SqlDocumentFilterConverterDecorator.containsKey(windowId)) {
        builder.filterConverterDecorator(windowId2SqlDocumentFilterConverterDecorator.get(windowId));
    }
    final SqlViewCustomizer sqlViewCustomizer = getSqlViewCustomizer(windowId, key.getProfileId());
    if (sqlViewCustomizer != null) {
        final ViewRowCustomizer rowCustomizer = sqlViewCustomizer;
        builder.rowCustomizer(rowCustomizer);
        sqlViewCustomizer.customizeSqlViewBinding(builder);
    }
    return builder.build();
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)

Example 2 with DocumentFilterDescriptorsProvider

use of de.metas.ui.web.document.filter.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);
        customizeHUEditorViewRepository(huEditorViewRepositoryBuilder);
        huEditorViewRepository = huEditorViewRepositoryBuilder.build();
    }
    // 
    // HUEditorView
    {
        // Filters
        // as long as the deprecated getFilterOnlyIds() is around we can't ignore it
        @SuppressWarnings("deprecation") final List<DocumentFilter> stickyFilters = extractStickyFilters(request.getStickyFilters(), request.getFilterOnlyIds());
        final DocumentFilterDescriptorsProvider filterDescriptors = getViewFilterDescriptors();
        final List<DocumentFilter> filters = request.getOrUnwrapFilters(filterDescriptors);
        // Start building the HUEditorView
        final HUEditorViewBuilder huViewBuilder = HUEditorView.builder().setParentViewId(request.getParentViewId()).setParentRowId(request.getParentRowId()).setViewId(viewId).setViewType(request.getViewType()).setStickyFilters(stickyFilters).setFilters(filters).setFilterDescriptors(filterDescriptors).setReferencingDocumentPaths(referencingTableName, referencingDocumentPaths).orderBys(sqlViewBinding.getDefaultOrderBys()).setActions(request.getActions()).addAdditionalRelatedProcessDescriptors(request.getAdditionalRelatedProcessDescriptors()).setHUEditorViewRepository(huEditorViewRepository).setParameters(request.getParameters());
        // 
        // Call view customizers
        getViewCustomizers(referencingTableName).forEach(viewCustomizer -> viewCustomizer.beforeCreate(huViewBuilder));
        customizeHUEditorView(huViewBuilder);
        return huViewBuilder.build();
    }
}
Also used : ArrayKey(org.compiere.util.Util.ArrayKey) CCache(org.compiere.util.CCache) SqlViewRowFieldBinding(de.metas.ui.web.view.descriptor.SqlViewRowFieldBinding) Autowired(org.springframework.beans.factory.annotation.Autowired) Map(java.util.Map) Constants(de.metas.handlingunits.attribute.Constants) 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) 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) Services(org.adempiere.util.Services) 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) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) GuavaCollectors(org.adempiere.util.GuavaCollectors) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) PlainContextAware(org.adempiere.model.PlainContextAware) ArrayList(java.util.ArrayList) DocumentFilterDescriptor(de.metas.ui.web.document.filter.DocumentFilterDescriptor) 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) ImmutableDocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.ImmutableDocumentFilterDescriptorsProvider) 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) Nullable(javax.annotation.Nullable) 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) WindowId(de.metas.ui.web.window.datatypes.WindowId) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) SqlDocumentFilterConverter(de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter) Check(org.adempiere.util.Check) 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) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) ITranslatableString(de.metas.i18n.ITranslatableString) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider) ImmutableDocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.ImmutableDocumentFilterDescriptorsProvider)

Example 3 with DocumentFilterDescriptorsProvider

use of de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.

the class MaterialCockpitViewFactory method createView.

@Override
public IView createView(@NonNull final CreateViewRequest request) {
    assertWindowIdOfRequestIsCorrect(request);
    final DocumentFilterDescriptorsProvider filterDescriptors = materialCockpitFilters.getFilterDescriptors();
    final ImmutableList<DocumentFilter> requestFilters = materialCockpitFilters.extractDocumentFilters(request);
    final ImmutableList<DocumentFilter> filtersToUse = request.isUseAutoFilters() ? materialCockpitFilters.createAutoFilters() : requestFilters;
    final MaterialCockpitView view = MaterialCockpitView.builder().viewId(request.getViewId()).description(ITranslatableString.empty()).filters(filtersToUse).filterDescriptors(filterDescriptors).rowsData(materialCockpitRowRepository.createRowsData(filtersToUse)).relatedProcessDescriptor(createProcessDescriptor()).build();
    return view;
}
Also used : DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)

Example 4 with DocumentFilterDescriptorsProvider

use of de.metas.ui.web.document.filter.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 CreateViewRequest requestEffective = request.unwrapFiltersAndCopy(filterDescriptors);
    final ViewId viewId = ViewId.random(PickingSlotsClearingViewFactory.WINDOW_ID);
    final PickingSlotQuery query = createPickingSlotQuery(requestEffective);
    return PickingSlotsClearingView.builder().viewId(viewId).rows(() -> pickingSlotRepo.retrievePickingSlotsRows(query)).additionalRelatedProcessDescriptors(createAdditionalRelatedProcessDescriptors()).filterDescriptors(filterDescriptors).filters(requestEffective.getFilters().getFilters()).build();
}
Also used : PickingSlotQuery(de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery) ViewId(de.metas.ui.web.view.ViewId) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)

Example 5 with DocumentFilterDescriptorsProvider

use of de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider in project metasfresh-webui-api by metasfresh.

the class MaterialCockpitFilters method extractDocumentFilters.

public ImmutableList<DocumentFilter> extractDocumentFilters(@NonNull final CreateViewRequest request) {
    final DocumentFilterDescriptorsProvider provider = getFilterDescriptors();
    final List<DocumentFilter> filters = request.getOrUnwrapFilters(provider);
    return ImmutableList.copyOf(filters);
}
Also used : DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider) ImmutableDocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.ImmutableDocumentFilterDescriptorsProvider)

Aggregations

DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)5 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)3 ImmutableDocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.ImmutableDocumentFilterDescriptorsProvider)2 CreateViewRequest (de.metas.ui.web.view.CreateViewRequest)2 ViewId (de.metas.ui.web.view.ViewId)2 SqlViewBinding (de.metas.ui.web.view.descriptor.SqlViewBinding)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 SqlDocumentEntityDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 Constants (de.metas.handlingunits.attribute.Constants)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 LogManager (de.metas.logging.LogManager)1 PickingSlotQuery (de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery)1 DocumentFilterDescriptor (de.metas.ui.web.document.filter.DocumentFilterDescriptor)1