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());
}
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();
}
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;
}
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();
}
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();
}
Aggregations