Search in sources :

Example 1 with AdProcessId

use of de.metas.process.AdProcessId in project metasfresh-webui-api by metasfresh.

the class WebuiHUTransformParametersFiller method getActions.

/**
 * @return the actions that are available according to which row is currently selected and to also according to whether there are already existing TUs or LUs in the context.
 */
public final LookupValuesList getActions(final AdProcessId processId) {
    final Set<String> allowedActions = new HashSet<>();
    final HUEditorRow huRow = getSelectedRow();
    if (huRow.isCU()) {
        allowedActions.addAll(getActionTypesForCUs());
    } else if (huRow.isTU()) {
        allowedActions.addAll(getActionTypesForTUs());
    } else if (huRow.isLU()) {
        allowedActions.add(ActionType.LU_Set_Ownership.toString());
    }
    final IADProcessDAO adProcessDAO = Services.get(IADProcessDAO.class);
    final I_AD_Process_Para processParameter = adProcessDAO.retrieveProcessParameter(processId, WEBUI_M_HU_Transform.PARAM_Action);
    final int actionsReferenceId = processParameter.getAD_Reference_Value_ID();
    final Collection<ADRefListItem> allActiveActionItems = adReferenceDAO.retrieveListItems(actionsReferenceId);
    final String adLanguage = Env.getAD_Language();
    return allActiveActionItems.stream().filter(item -> allowedActions.contains(item.getValueName())).map(item -> StringLookupValue.of(item.getValueName(), item.getName(), item.getDescription())).sorted(Comparator.comparing(lookupValue -> lookupValue.getDisplayName(adLanguage))).collect(LookupValuesList.collect());
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) LookupDataSourceFactory(de.metas.ui.web.window.model.lookup.LookupDataSourceFactory) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) Env(org.compiere.util.Env) HUEditorRowFilter(de.metas.ui.web.handlingunits.HUEditorRowFilter) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) I_AD_Process_Para(org.compiere.model.I_AD_Process_Para) ProductId(de.metas.product.ProductId) HashSet(java.util.HashSet) ADRefListItem(org.adempiere.ad.service.IADReferenceDAO.ADRefListItem) Select(de.metas.ui.web.handlingunits.HUEditorRowFilter.Select) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) DisplayType(org.compiere.util.DisplayType) AdProcessId(de.metas.process.AdProcessId) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) IADReferenceDAO(org.adempiere.ad.service.IADReferenceDAO) I_M_HU(de.metas.handlingunits.model.I_M_HU) Nullable(javax.annotation.Nullable) IADProcessDAO(de.metas.process.IADProcessDAO) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) HUTransformService(de.metas.handlingunits.allocation.transfer.HUTransformService) Services(de.metas.util.Services) List(java.util.List) WEBUI_ProcessHelper(de.metas.ui.web.handlingunits.util.WEBUI_ProcessHelper) StringLookupValue(de.metas.ui.web.window.datatypes.LookupValue.StringLookupValue) HuId(de.metas.handlingunits.HuId) X_M_HU(de.metas.handlingunits.model.X_M_HU) Builder(lombok.Builder) Check(de.metas.printing.esb.base.util.Check) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) BPartnerId(de.metas.bpartner.BPartnerId) Optional(java.util.Optional) ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) Comparator(java.util.Comparator) I_AD_Process_Para(org.compiere.model.I_AD_Process_Para) IADProcessDAO(de.metas.process.IADProcessDAO) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) HashSet(java.util.HashSet) ADRefListItem(org.adempiere.ad.service.IADReferenceDAO.ADRefListItem)

Example 2 with AdProcessId

use of de.metas.process.AdProcessId in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_PrintReceiptLabel method checkPreconditionsApplicable.

@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
    if (!isHUEditorView()) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
    }
    final HUReportService huReportService = HUReportService.get();
    final AdProcessId adProcessId = huReportService.retrievePrintReceiptLabelProcessIdOrNull();
    if (adProcessId == null) {
        return ProcessPreconditionsResolution.reject("Receipt label process not configured via sysconfig " + HUReportService.SYSCONFIG_RECEIPT_LABEL_PROCESS_ID);
    }
    if (!getSelectedRowIds().isSingleDocumentId()) {
        return ProcessPreconditionsResolution.reject("No (single) row selected");
    }
    final HUToReport hu = getSingleSelectedRow().getAsHUToReportOrNull();
    if (hu == null) {
        return ProcessPreconditionsResolution.reject("No (single) HU selected");
    }
    final List<HUToReport> husToProcess = huReportService.getHUsToProcess(hu, adProcessId);
    if (husToProcess.isEmpty()) {
        return ProcessPreconditionsResolution.reject("current HU's type does not match the receipt label process");
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : HUToReport(de.metas.handlingunits.report.HUToReport) AdProcessId(de.metas.process.AdProcessId) HUReportService(de.metas.handlingunits.report.HUReportService)

Example 3 with AdProcessId

use of de.metas.process.AdProcessId in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_PrintReceiptLabel method doIt.

@Override
@RunOutOfTrx
protected String doIt() throws Exception {
    final HUReportService huReportService = HUReportService.get();
    final AdProcessId adProcessId = huReportService.retrievePrintReceiptLabelProcessIdOrNull();
    final HUToReport hu = getSingleSelectedRow().getAsHUToReport();
    final List<HUToReport> husToProcess = huReportService.getHUsToProcess(hu, adProcessId).stream().filter(// issue https://github.com/metasfresh/metasfresh/issues/3851
    HUToReport::isTopLevel).collect(ImmutableList.toImmutableList());
    HUReportExecutor.newInstance(getCtx()).windowNo(getProcessInfo().getWindowNo()).numberOfCopies(p_copies).executeHUReportAfterCommit(adProcessId, husToProcess);
    return MSG_OK;
}
Also used : HUToReport(de.metas.handlingunits.report.HUToReport) AdProcessId(de.metas.process.AdProcessId) HUReportService(de.metas.handlingunits.report.HUReportService) RunOutOfTrx(de.metas.process.RunOutOfTrx)

Example 4 with AdProcessId

use of de.metas.process.AdProcessId in project metasfresh-webui-api by metasfresh.

the class HUReportProcessInstancesRepository method toWebuiHUProcessDescriptor.

private WebuiHUProcessDescriptor toWebuiHUProcessDescriptor(@NonNull final HUProcessDescriptor huProcessDescriptor) {
    final AdProcessId reportADProcessId = huProcessDescriptor.getProcessId();
    final ProcessId processId = ProcessId.of(PROCESS_HANDLER_TYPE, reportADProcessId.getRepoId());
    final I_AD_Process adProcess = Services.get(IADProcessDAO.class).getById(reportADProcessId);
    final IModelTranslationMap adProcessTrl = InterfaceWrapperHelper.getModelTranslationMap(adProcess);
    final ITranslatableString caption = adProcessTrl.getColumnTrl(I_AD_Process.COLUMNNAME_Name, adProcess.getName());
    final ITranslatableString description = adProcessTrl.getColumnTrl(I_AD_Process.COLUMNNAME_Description, adProcess.getDescription());
    final DocumentEntityDescriptor parametersDescriptor = DocumentEntityDescriptor.builder().setDocumentType(DocumentType.Process, processId.toDocumentId()).setCaption(caption).setDescription(description).disableDefaultTableCallouts().addField(DocumentFieldDescriptor.builder(HUReportProcessInstance.PARAM_Copies).setCaption(Services.get(IMsgBL.class).translatable(HUReportProcessInstance.PARAM_Copies)).setWidgetType(DocumentFieldWidgetType.Integer)).build();
    return WebuiHUProcessDescriptor.builder().huProcessDescriptor(huProcessDescriptor).processDescriptor(ProcessDescriptor.builder().setProcessId(processId).setInternalName(InternalName.ofString(huProcessDescriptor.getInternalName())).setType(ProcessDescriptorType.Report).setParametersDescriptor(parametersDescriptor).setLayout(ProcessLayout.builder().setProcessId(processId).setCaption(caption).setDescription(description).addElements(parametersDescriptor).build()).build()).build();
}
Also used : IModelTranslationMap(de.metas.i18n.IModelTranslationMap) AdProcessId(de.metas.process.AdProcessId) I_AD_Process(org.compiere.model.I_AD_Process) IMsgBL(de.metas.i18n.IMsgBL) ITranslatableString(de.metas.i18n.ITranslatableString) AdProcessId(de.metas.process.AdProcessId) ProcessId(de.metas.ui.web.process.ProcessId) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) IADProcessDAO(de.metas.process.IADProcessDAO)

Example 5 with AdProcessId

use of de.metas.process.AdProcessId in project metasfresh-webui-api by metasfresh.

the class MaterialCockpitViewFactory method createProcessDescriptor.

private final RelatedProcessDescriptor createProcessDescriptor(@NonNull final Class<?> processClass) {
    final IADProcessDAO adProcessDAO = Services.get(IADProcessDAO.class);
    final AdProcessId processId = adProcessDAO.retrieveProcessIdByClass(processClass);
    if (processId == null) {
        throw new AdempiereException("No processId found for " + processClass);
    }
    return RelatedProcessDescriptor.builder().processId(processId).anyTable().anyWindow().displayPlace(DisplayPlace.ViewQuickActions).build();
}
Also used : AdProcessId(de.metas.process.AdProcessId) AdempiereException(org.adempiere.exceptions.AdempiereException) IADProcessDAO(de.metas.process.IADProcessDAO)

Aggregations

AdProcessId (de.metas.process.AdProcessId)15 IADProcessDAO (de.metas.process.IADProcessDAO)11 AdempiereException (org.adempiere.exceptions.AdempiereException)4 Services (de.metas.util.Services)3 AcctDocRegistry (de.metas.acct.doc.AcctDocRegistry)2 HUReportService (de.metas.handlingunits.report.HUReportService)2 HUToReport (de.metas.handlingunits.report.HUToReport)2 LogManager (de.metas.logging.LogManager)2 RelatedProcessDescriptor (de.metas.process.RelatedProcessDescriptor)2 DisplayPlace (de.metas.process.RelatedProcessDescriptor.DisplayPlace)2 WEBUI_Fact_Acct_Repost_SingleDocument (de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_SingleDocument)2 WEBUI_Fact_Acct_Repost_ViewRows (de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_ViewRows)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PostConstruct (javax.annotation.PostConstruct)2 IADTableDAO (org.adempiere.ad.table.api.IADTableDAO)2 Logger (org.slf4j.Logger)2 Component (org.springframework.stereotype.Component)2 BPartnerId (de.metas.bpartner.BPartnerId)1