Search in sources :

Example 1 with SqlHUEditorViewRepositoryBuilder

use of de.metas.ui.web.handlingunits.SqlHUEditorViewRepository.SqlHUEditorViewRepositoryBuilder 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)

Aggregations

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 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)1 DocumentFilterDescriptor (de.metas.ui.web.document.filter.DocumentFilterDescriptor)1 DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)1 DocumentFilterParamDescriptor (de.metas.ui.web.document.filter.DocumentFilterParamDescriptor)1 ImmutableDocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.ImmutableDocumentFilterDescriptorsProvider)1 SqlDocumentFilterConverter (de.metas.ui.web.document.filter.sql.SqlDocumentFilterConverter)1 SqlParamsCollector (de.metas.ui.web.document.filter.sql.SqlParamsCollector)1 SqlHUEditorViewRepositoryBuilder (de.metas.ui.web.handlingunits.SqlHUEditorViewRepository.SqlHUEditorViewRepositoryBuilder)1 CreateViewRequest (de.metas.ui.web.view.CreateViewRequest)1 IViewFactory (de.metas.ui.web.view.IViewFactory)1 SqlViewFactory (de.metas.ui.web.view.SqlViewFactory)1