use of de.metas.ui.web.process.ProcessId in project metasfresh-webui-api by metasfresh.
the class ADProcessDescriptorsFactory method toWebuiRelatedProcessDescriptor.
private WebuiRelatedProcessDescriptor toWebuiRelatedProcessDescriptor(@NonNull final RelatedProcessDescriptor relatedProcessDescriptor, @NonNull final IProcessPreconditionsContext preconditionsContext) {
final ProcessId processId = ProcessId.ofAD_Process_ID(relatedProcessDescriptor.getProcessId());
final ProcessDescriptor processDescriptor = getProcessDescriptor(processId);
final ProcessPreconditionsResolutionSupplier preconditionsResolutionSupplier = ProcessPreconditionsResolutionSupplier.builder().preconditionsContext(preconditionsContext).processPreconditionsCheckers(relatedProcessDescriptor.getProcessPreconditionsCheckers()).processDescriptor(processDescriptor).build();
return WebuiRelatedProcessDescriptor.builder().processId(processDescriptor.getProcessId()).processCaption(processDescriptor.getCaption()).processDescription(processDescriptor.getDescription()).debugProcessClassname(processDescriptor.getProcessClassname()).quickAction(relatedProcessDescriptor.isWebuiQuickAction()).defaultQuickAction(relatedProcessDescriptor.isWebuiDefaultQuickAction()).preconditionsResolutionSupplier(preconditionsResolutionSupplier).build();
}
use of de.metas.ui.web.process.ProcessId in project metasfresh-webui-api by metasfresh.
the class HUReportProcessInstancesRepository method toWebuiHUProcessDescriptor.
private WebuiHUProcessDescriptor toWebuiHUProcessDescriptor(final HUProcessDescriptor huProcessDescriptor) {
final int reportADProcessId = huProcessDescriptor.getProcessId();
final ProcessId processId = ProcessId.of(PROCESS_HANDLER_TYPE, reportADProcessId);
final I_AD_Process adProcess = Services.get(IADProcessDAO.class).retrieveProcessById(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).setType(ProcessDescriptorType.Report).setParametersDescriptor(parametersDescriptor).setLayout(ProcessLayout.builder().setProcessId(processId).setCaption(caption).setDescription(description).addElements(parametersDescriptor).build()).build()).build();
}
use of de.metas.ui.web.process.ProcessId in project metasfresh-webui-api by metasfresh.
the class ADProcessDescriptorsFactory method retrieveProcessDescriptor.
private ProcessDescriptor retrieveProcessDescriptor(final ProcessId processId) {
final I_AD_Process adProcess = InterfaceWrapperHelper.create(Env.getCtx(), processId.getProcessIdAsInt(), I_AD_Process.class, ITrx.TRXNAME_None);
if (adProcess == null) {
throw new EntityNotFoundException("@NotFound@ @AD_Process_ID@ (" + processId + ")");
}
final WebuiProcessClassInfo webuiProcesClassInfo = WebuiProcessClassInfo.of(adProcess.getClassname());
final IModelTranslationMap adProcessTrlsMap = InterfaceWrapperHelper.getModelTranslationMap(adProcess);
//
// Parameters document descriptor
final DocumentEntityDescriptor parametersDescriptor;
{
final DocumentEntityDescriptor.Builder parametersDescriptorBuilder = DocumentEntityDescriptor.builder().setDocumentType(DocumentType.Process, processId.toDocumentId()).setCaption(adProcessTrlsMap.getColumnTrl(I_AD_Process.COLUMNNAME_Name, adProcess.getName())).setDescription(adProcessTrlsMap.getColumnTrl(I_AD_Process.COLUMNNAME_Description, adProcess.getDescription())).setDataBinding(ProcessParametersDataBindingDescriptorBuilder.instance).disableDefaultTableCallouts();
// Get AD_Process_Para(s) and populate the entity descriptor
adProcessDAO.retrieveProcessParameters(adProcess).stream().map(adProcessParam -> createProcessParaDescriptor(webuiProcesClassInfo, adProcessParam)).forEach(processParaDescriptor -> parametersDescriptorBuilder.addField(processParaDescriptor));
parametersDescriptor = parametersDescriptorBuilder.build();
}
//
// Parameters layout
final ProcessLayout.Builder layout = ProcessLayout.builder().setProcessId(processId).setLayoutType(webuiProcesClassInfo.getLayoutType()).setCaption(parametersDescriptor.getCaption()).setDescription(parametersDescriptor.getDescription()).addElements(parametersDescriptor);
// Process descriptor
return ProcessDescriptor.builder().setProcessId(processId).setType(extractType(adProcess)).setProcessClassname(extractClassnameOrNull(adProcess)).setParametersDescriptor(parametersDescriptor).setLayout(layout.build()).build();
}
use of de.metas.ui.web.process.ProcessId in project metasfresh-webui-api by metasfresh.
the class ADProcessInstancesRepository method retrieveProcessInstance.
private ADProcessInstanceController retrieveProcessInstance(final DocumentId adPInstanceId) {
Check.assumeNotNull(adPInstanceId, "Parameter adPInstanceId is not null");
Check.assume(adPInstanceId.toInt() > 0, "adPInstanceId > 0");
//
// Load process info
final ProcessInfo processInfo = ProcessInfo.builder().setCtx(Env.getCtx()).setCreateTemporaryCtx().setAD_PInstance_ID(adPInstanceId.toInt()).build();
final Object processClassInstance = processInfo.newProcessClassInstanceOrNull();
try (final IAutoCloseable c = JavaProcess.temporaryChangeCurrentInstance(processClassInstance)) {
//
// Build the parameters document
final ProcessId processId = ProcessId.ofAD_Process_ID(processInfo.getAD_Process_ID());
final ProcessDescriptor processDescriptor = getProcessDescriptor(processId);
//
// Build the parameters (as document)
final DocumentEntityDescriptor parametersDescriptor = processDescriptor.getParametersDescriptor();
final Document parametersDoc = parametersDescriptor.getDataBinding().getDocumentsRepository().retrieveDocumentById(parametersDescriptor, adPInstanceId, NullDocumentChangesCollector.instance);
// TODO: handle the case when the process was already executed
// In that case we need to load the result and provide it to ProcessInstance constructor
//
// View informations
final IRangeAwareParams processInfoParams = processInfo.getParameterAsIParams();
final String viewIdStr = processInfoParams.getParameterAsString(ViewBasedProcessTemplate.PARAM_ViewId);
final ViewId viewId = Strings.isNullOrEmpty(viewIdStr) ? null : ViewId.ofViewIdString(viewIdStr);
//
return ADProcessInstanceController.builder().caption(processDescriptor.getCaption()).instanceId(adPInstanceId).parameters(parametersDoc).processClassInstance(processClassInstance).viewId(viewId).build();
}
}
Aggregations