Search in sources :

Example 1 with I_AD_Tab

use of org.compiere.model.I_AD_Tab in project metasfresh-webui-api by metasfresh.

the class InMemoryUIElementsProvider method getUISections.

@Override
public List<I_AD_UI_Section> getUISections(final int AD_Tab_ID) {
    // Generate the UI elements if needed
    if (!adTabId2sections.containsKey(AD_Tab_ID)) {
        final WindowUIElementsGenerator generator = WindowUIElementsGenerator.forConsumer(this);
        final I_AD_Tab adTab = InterfaceWrapperHelper.create(Env.getCtx(), AD_Tab_ID, I_AD_Tab.class, ITrx.TRXNAME_ThreadInherited);
        final boolean primaryTab = adTab.getTabLevel() == 0;
        if (primaryTab) {
            generator.migratePrimaryTab(adTab);
        } else {
            generator.migrateDetailTab(adTab);
        }
    }
    return adTabId2sections.get(AD_Tab_ID);
}
Also used : I_AD_Tab(org.compiere.model.I_AD_Tab) WindowUIElementsGenerator(org.adempiere.ad.window.process.AD_Window_CreateUIElements.WindowUIElementsGenerator)

Example 2 with I_AD_Tab

use of org.compiere.model.I_AD_Tab in project metasfresh-webui-api by metasfresh.

the class HUEditorViewFactoryTemplate method createSqlViewBinding.

private SqlViewBinding createSqlViewBinding() {
    // Get HU's standard entity descriptor. We will needed all over.
    final DocumentEntityDescriptor huEntityDescriptor = getHUEntityDescriptor();
    // 
    // Static where clause
    final StringBuilder sqlWhereClause = new StringBuilder();
    {
        // top level
        sqlWhereClause.append(I_M_HU.COLUMNNAME_M_HU_Item_Parent_ID + " is null");
        // Consider window tab's where clause if any
        final I_AD_Tab huTab = Services.get(IADWindowDAO.class).retrieveFirstTab(WEBUI_HU_Constants.WEBUI_HU_Window_ID.toInt());
        if (!Check.isEmpty(huTab.getWhereClause(), true)) {
            sqlWhereClause.append("\n AND (").append(huTab.getWhereClause()).append(")");
        }
    }
    // 
    // Start preparing the sqlViewBinding builder
    final List<String> displayFieldNames = ImmutableList.of(I_M_HU.COLUMNNAME_M_HU_ID);
    final SqlViewBinding.Builder sqlViewBinding = SqlViewBinding.builder().tableName(I_M_HU.Table_Name).displayFieldNames(displayFieldNames).sqlWhereClause(sqlWhereClause.toString()).rowIdsConverter(HUSqlViewRowIdsConverter.instance);
    // 
    // View fields: from M_HU's entity descriptor
    {
        // NOTE: we need to add all HU's standard fields because those might be needed for some of the standard filters defined
        final SqlDocumentEntityDataBindingDescriptor huEntityBindings = SqlDocumentEntityDataBindingDescriptor.cast(huEntityDescriptor.getDataBinding());
        huEntityBindings.getFields().stream().map(huField -> SqlViewFactory.createViewFieldBindingBuilder(huField, displayFieldNames).build()).forEach(sqlViewBinding::field);
    }
    // 
    // View field: BestBeforeDate
    {
        sqlViewBinding.field(SqlViewRowFieldBinding.builder().fieldName(HUEditorRow.FIELDNAME_BestBeforeDate).widgetType(DocumentFieldWidgetType.Date).columnSql(Constants.sqlBestBeforeDate(sqlViewBinding.getTableAlias() + "." + I_M_HU.COLUMNNAME_M_HU_ID)).fieldLoader((rs, adLanguage) -> rs.getTimestamp(HUEditorRow.FIELDNAME_BestBeforeDate)).build());
    }
    // 
    // View filters and converters
    {
        sqlViewBinding.filterDescriptors(createFilterDescriptorsProvider()).filterConverter(HUBarcodeSqlDocumentFilterConverter.FILTER_ID, HUBarcodeSqlDocumentFilterConverter.instance).filterConverter(HUIdsFilterHelper.FILTER_ID, HUIdsFilterHelper.SQL_DOCUMENT_FILTER_CONVERTER);
        createFilterConvertersIndexedByFilterId().forEach(sqlViewBinding::filterConverter);
    }
    // 
    return sqlViewBinding.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) I_AD_Tab(org.compiere.model.I_AD_Tab) 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) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 3 with I_AD_Tab

use of org.compiere.model.I_AD_Tab in project metasfresh-webui-api by metasfresh.

the class GridTabVOBasedDocumentEntityDescriptorFactory method createLabelsLookup.

private static final LabelsLookup createLabelsLookup(final I_AD_UI_Element labelsUIElement, final String tableName) {
    final I_AD_Tab labelsTab = labelsUIElement.getLabels_Tab();
    final String labelsTableName = labelsTab.getAD_Table().getTableName();
    final String linkColumnName;
    if (labelsTab.getParent_Column_ID() > 0) {
        linkColumnName = labelsTab.getParent_Column().getColumnName();
    } else {
        linkColumnName = InterfaceWrapperHelper.getKeyColumnName(tableName);
    }
    final String labelsLinkColumnName;
    if (labelsTab.getAD_Column_ID() > 0) {
        labelsLinkColumnName = labelsTab.getAD_Column().getColumnName();
    } else {
        labelsLinkColumnName = linkColumnName;
    }
    final I_AD_Column labelsValueColumn = labelsUIElement.getLabels_Selector_Field().getAD_Column();
    final String labelsValueColumnName = labelsValueColumn.getColumnName();
    final LookupDescriptor labelsValuesLookupDescriptor = SqlLookupDescriptor.builder().setCtxTableName(labelsTableName).setCtxColumnName(labelsValueColumnName).setDisplayType(labelsValueColumn.getAD_Reference_ID()).setWidgetType(DescriptorsFactoryHelper.extractWidgetType(labelsValueColumnName, labelsValueColumn.getAD_Reference_ID())).setAD_Reference_Value_ID(labelsValueColumn.getAD_Reference_Value_ID()).setAD_Val_Rule_ID(labelsValueColumn.getAD_Val_Rule_ID()).buildForDefaultScope();
    return LabelsLookup.builder().labelsTableName(labelsTableName).labelsValueColumnName(labelsValueColumnName).labelsValuesLookupDescriptor(labelsValuesLookupDescriptor).labelsLinkColumnName(labelsLinkColumnName).tableName(tableName).linkColumnName(linkColumnName).build();
}
Also used : I_AD_Tab(org.compiere.model.I_AD_Tab) I_AD_Column(org.compiere.model.I_AD_Column) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Aggregations

I_AD_Tab (org.compiere.model.I_AD_Tab)3 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