Search in sources :

Example 6 with AdWindowId

use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.

the class CableSalesOrderLineQuickInputDescriptorFactory method getMatchingKeys.

@Override
public Set<MatchingKey> getMatchingKeys() {
    final IADWindowDAO windowDAO = Services.get(IADWindowDAO.class);
    final AdWindowId salesOrderWindowId = windowDAO.getAdWindowId(I_C_OrderLine.Table_Name, SOTrx.SALES, WINDOW_ID_SalesOrder_DEFAULT);
    final AdWindowId purchaseOrderWindowId = windowDAO.getAdWindowId(I_C_OrderLine.Table_Name, SOTrx.PURCHASE, WINDOW_ID_PurchaseOrder_DEFAULT);
    return ImmutableSet.of(MatchingKey.includedDocument(DocumentType.Window, salesOrderWindowId.getRepoId(), I_C_OrderLine.Table_Name), MatchingKey.includedDocument(DocumentType.Window, purchaseOrderWindowId.getRepoId(), I_C_OrderLine.Table_Name));
}
Also used : IADWindowDAO(org.adempiere.ad.window.api.IADWindowDAO) AdWindowId(org.adempiere.ad.element.api.AdWindowId)

Example 7 with AdWindowId

use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.

the class DocumentCollection method getWindowId.

public WindowId getWindowId(@NonNull final DocumentZoomIntoInfo zoomIntoInfo) {
    if (zoomIntoInfo.getWindowId() != null) {
        return zoomIntoInfo.getWindowId();
    }
    final RecordZoomWindowFinder zoomWindowFinder;
    if (zoomIntoInfo.isRecordIdPresent()) {
        zoomWindowFinder = RecordZoomWindowFinder.newInstance(zoomIntoInfo.getTableName(), zoomIntoInfo.getRecordId());
    } else {
        zoomWindowFinder = RecordZoomWindowFinder.newInstance(zoomIntoInfo.getTableName());
    }
    final AdWindowId zoomInto_adWindowId = zoomWindowFinder.findAdWindowId().orElse(null);
    if (zoomInto_adWindowId == null) {
        throw new EntityNotFoundException("No windowId found").setParameter("zoomIntoInfo", zoomIntoInfo);
    }
    return WindowId.of(zoomInto_adWindowId);
}
Also used : RecordZoomWindowFinder(org.adempiere.model.RecordZoomWindowFinder) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) AdWindowId(org.adempiere.ad.element.api.AdWindowId)

Example 8 with AdWindowId

use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.

the class DataEntryTabLoaderTest method createDataEntryTabLoader.

private static DataEntryTabLoader createDataEntryTabLoader() {
    final WindowId windowId = WindowId.of(5);
    final DataEntryWebuiTools dataEntryWebuiTools = new DataEntryWebuiTools(new UserRepository());
    final JSONDataEntryRecordMapper jsonDataEntryRecordMapper = new JSONDataEntryRecordMapper();
    final DataEntryRecordRepository dataEntryRecordRepository = new DataEntryRecordRepository(jsonDataEntryRecordMapper);
    final DataEntrySubTabBindingDescriptorBuilder // 
    dataEntrySubTabBindingDescriptorBuilder = new DataEntrySubTabBindingDescriptorBuilder(dataEntryRecordRepository, dataEntryWebuiTools);
    return DataEntryTabLoader.builder().filterDescriptorsProvidersService(new DocumentFilterDescriptorsProvidersService(ImmutableList.of())).windowId(windowId).adWindowId(windowId.toAdWindowIdOrNull()).dataEntrySubTabBindingDescriptorBuilder(dataEntrySubTabBindingDescriptorBuilder).build();
}
Also used : DataEntryRecordRepository(de.metas.dataentry.data.DataEntryRecordRepository) DocumentFilterDescriptorsProvidersService(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvidersService) UserRepository(de.metas.user.UserRepository) JSONDataEntryRecordMapper(de.metas.dataentry.data.json.JSONDataEntryRecordMapper) AdWindowId(org.adempiere.ad.element.api.AdWindowId) WindowId(de.metas.ui.web.window.datatypes.WindowId)

Example 9 with AdWindowId

use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.

the class ADProcessDescriptorsFactory method streamDocumentRelatedProcesses.

public Stream<WebuiRelatedProcessDescriptor> streamDocumentRelatedProcesses(@NonNull final WebuiPreconditionsContext preconditionsContext, @NonNull final IUserRolePermissions userRolePermissions) {
    final String tableName = preconditionsContext.getTableName();
    final int adTableId = !Check.isEmpty(tableName) ? adTableDAO.retrieveTableId(tableName) : -1;
    final AdWindowId adWindowId = preconditionsContext.getAdWindowId();
    final AdTabId adTabId = preconditionsContext.getAdTabId();
    final Stream<RelatedProcessDescriptor> relatedProcessDescriptors;
    {
        final Stream<RelatedProcessDescriptor> tableRelatedProcessDescriptors = adProcessDAO.retrieveRelatedProcessDescriptors(adTableId, adWindowId, adTabId).stream();
        final Stream<RelatedProcessDescriptor> additionalRelatedProcessDescriptors = preconditionsContext.getAdditionalRelatedProcessDescriptors().stream();
        relatedProcessDescriptors = Stream.concat(additionalRelatedProcessDescriptors, tableRelatedProcessDescriptors).collect(GuavaCollectors.distinctBy(RelatedProcessDescriptor::getProcessId));
    }
    return relatedProcessDescriptors.filter(relatedProcess -> isEligible(relatedProcess, preconditionsContext, userRolePermissions)).map(relatedProcess -> toWebuiRelatedProcessDescriptor(relatedProcess, preconditionsContext));
}
Also used : DisplayPlace(de.metas.process.RelatedProcessDescriptor.DisplayPlace) IExpression(org.adempiere.ad.expression.api.IExpression) DefaultValueExpressionsFactory(de.metas.ui.web.window.descriptor.factory.standard.DefaultValueExpressionsFactory) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) IRangeAwareParams(org.adempiere.util.api.IRangeAwareParams) GuavaCollectors(de.metas.util.GuavaCollectors) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) IExpressionFactory(org.adempiere.ad.expression.api.IExpressionFactory) DateRangeValue(de.metas.ui.web.window.datatypes.DateRangeValue) NonNull(lombok.NonNull) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) ConstantLogicExpression(org.adempiere.ad.expression.api.ConstantLogicExpression) JavaProcess(de.metas.process.JavaProcess) X_AD_Process(org.compiere.model.X_AD_Process) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) I_AD_Process(org.compiere.model.I_AD_Process) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) Stream(java.util.stream.Stream) ProcessId(de.metas.ui.web.process.ProcessId) DocumentEntityDataBindingDescriptorBuilder(de.metas.ui.web.window.descriptor.DocumentEntityDataBindingDescriptor.DocumentEntityDataBindingDescriptorBuilder) Builder(lombok.Builder) IProcessPreconditionsContext(de.metas.process.IProcessPreconditionsContext) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) Optional(java.util.Optional) ProcessParams(de.metas.process.ProcessParams) IADElementDAO(org.adempiere.ad.element.api.IADElementDAO) DocumentType(de.metas.ui.web.window.datatypes.DocumentType) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) LogManager(de.metas.logging.LogManager) TimeUtil(org.compiere.util.TimeUtil) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) I_AD_Process_Para(org.compiere.model.I_AD_Process_Para) Supplier(java.util.function.Supplier) ProcessDescriptorType(de.metas.ui.web.process.descriptor.ProcessDescriptor.ProcessDescriptorType) DescriptorsFactoryHelper(de.metas.ui.web.window.descriptor.factory.standard.DescriptorsFactoryHelper) IUserRolePermissions(de.metas.security.IUserRolePermissions) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) Characteristic(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Characteristic) ICalloutField(org.adempiere.ad.callout.api.ICalloutField) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) InternalName(de.metas.ui.web.process.descriptor.InternalName) I_AD_Element(org.compiere.model.I_AD_Element) CoalesceUtil(de.metas.util.lang.CoalesceUtil) BarcodeScannerType(de.metas.process.BarcodeScannerType) Nullable(javax.annotation.Nullable) IADProcessDAO(de.metas.process.IADProcessDAO) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) AdWindowId(org.adempiere.ad.element.api.AdWindowId) Check(de.metas.util.Check) Logger(org.slf4j.Logger) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) ProcessLayout(de.metas.ui.web.process.descriptor.ProcessLayout) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) CCache(de.metas.cache.CCache) Services(de.metas.util.Services) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) DocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDataBindingDescriptor) AdTabId(org.adempiere.ad.element.api.AdTabId) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) Stream(java.util.stream.Stream) AdTabId(org.adempiere.ad.element.api.AdTabId) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) AdWindowId(org.adempiere.ad.element.api.AdWindowId)

Example 10 with AdWindowId

use of org.adempiere.ad.element.api.AdWindowId in project metasfresh-webui-api by metasfresh.

the class ADProcessInstancesRepository method createProcessInfo.

private ProcessInfo createProcessInfo(@NonNull final CreateProcessInstanceRequest request) {
    final DocumentPath singleDocumentPath = request.getSingleDocumentPath();
    final String tableName;
    final int recordId;
    final String sqlWhereClause;
    final AdWindowId adWindowId;
    // View
    if (request.getViewRowIdsSelection() != null) {
        final ViewRowIdsSelection viewRowIdsSelection = request.getViewRowIdsSelection();
        final ViewId viewId = viewRowIdsSelection.getViewId();
        final IView view = viewsRepo.getView(viewId);
        final DocumentIdsSelection viewDocumentIds = viewRowIdsSelection.getRowIds();
        adWindowId = viewId.getWindowId().toAdWindowIdOrNull();
        if (viewDocumentIds.isSingleDocumentId()) {
            final DocumentId viewSingleDocumentId = viewDocumentIds.getSingleDocumentId();
            final TableRecordReference recordRef = view.getTableRecordReferenceOrNull(viewSingleDocumentId);
            if (recordRef != null) {
                tableName = recordRef.getTableName();
                recordId = recordRef.getRecord_ID();
            } else {
                tableName = view.getTableNameOrNull(viewSingleDocumentId);
                recordId = -1;
            }
        } else {
            tableName = view.getTableNameOrNull(null);
            recordId = -1;
        }
        final boolean emptyTableName = Check.isEmpty(tableName);
        if (viewDocumentIds.isEmpty() || emptyTableName) {
            // Note: in the case of material cockpit, there is no single tableName to be returned by view.getTableNameOrNull,
            // so we do have selected rows, but no table name, which is OK
            sqlWhereClause = null;
        } else {
            sqlWhereClause = view.getSqlWhereClause(viewDocumentIds, SqlOptions.usingTableName(tableName));
        }
    } else // Single document call
    if (singleDocumentPath != null) {
        final DocumentEntityDescriptor entityDescriptor = documentDescriptorFactory.getDocumentEntityDescriptor(singleDocumentPath);
        adWindowId = singleDocumentPath.getWindowId().toAdWindowIdOrNull();
        tableName = entityDescriptor.getTableNameOrNull();
        final DocumentId documentId;
        if (singleDocumentPath.isRootDocument()) {
            documentId = singleDocumentPath.getDocumentId();
        } else {
            documentId = singleDocumentPath.getSingleRowId();
        }
        if (documentId.isInt()) {
            recordId = documentId.toInt();
        } else {
            recordId = -1;
        }
        sqlWhereClause = entityDescriptor.getDataBinding(SqlDocumentEntityDataBindingDescriptor.class).getSqlWhereClauseById(documentId);
    } else // 
    // From menu
    {
        tableName = null;
        recordId = -1;
        sqlWhereClause = null;
        adWindowId = null;
    }
    // 
    final Set<TableRecordReference> selectedIncludedRecords = request.getSelectedIncludedDocumentPaths().stream().map(documentDescriptorFactory::getTableRecordReference).collect(ImmutableSet.toImmutableSet());
    final ProcessInfoBuilder processInfoBuilder = ProcessInfo.builder().setCtx(Env.getCtx()).setCreateTemporaryCtx().setAD_Process_ID(request.getProcessIdAsInt()).setAdWindowId(adWindowId).setRecord(tableName, recordId).setSelectedIncludedRecords(selectedIncludedRecords).setWhereClause(sqlWhereClause);
    // 
    // View related internal parameters
    addViewInternalParameters(request, processInfoBuilder);
    return processInfoBuilder.build();
}
Also used : IView(de.metas.ui.web.view.IView) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) AdWindowId(org.adempiere.ad.element.api.AdWindowId) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) ViewId(de.metas.ui.web.view.ViewId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) ProcessInfoBuilder(de.metas.process.ProcessInfo.ProcessInfoBuilder) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)

Aggregations

AdWindowId (org.adempiere.ad.element.api.AdWindowId)12 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)4 AdempiereException (org.adempiere.exceptions.AdempiereException)4 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)3 CCache (de.metas.cache.CCache)2 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)2 LogManager (de.metas.logging.LogManager)2 OrgId (de.metas.organization.OrgId)2 ElementPermission (de.metas.security.permissions.ElementPermission)2 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 RecordZoomWindowFinder (org.adempiere.model.RecordZoomWindowFinder)2 Joiner (com.google.common.base.Joiner)1 Preconditions (com.google.common.base.Preconditions)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Amount (de.metas.currency.Amount)1 CurrencyCode (de.metas.currency.CurrencyCode)1