use of de.metas.ui.web.process.ProcessInstanceResult.ResultAction in project metasfresh-webui-api by metasfresh.
the class ViewActionInstance method startProcess.
@Override
public ProcessInstanceResult startProcess(@NonNull final ProcessExecutionContext context) {
assertNotExecuted();
// Validate parameters, if any
if (parametersDocument != null) {
final DocumentValidStatus validStatus = parametersDocument.checkAndGetValidStatus();
if (!validStatus.isValid()) {
throw new AdempiereException(validStatus.getReason());
}
}
//
// Execute view action's method
final IView view = getView();
final Method viewActionMethod = viewActionDescriptor.getViewActionMethod();
final Object[] viewActionParams = viewActionDescriptor.extractMethodArguments(view, parametersDocument, selectedDocumentIds);
try {
final Object targetObject = Modifier.isStatic(viewActionMethod.getModifiers()) ? null : view;
final Object resultActionObj = viewActionMethod.invoke(targetObject, viewActionParams);
final ResultAction resultAction = viewActionDescriptor.convertReturnType(resultActionObj);
final ResultAction resultActionProcessed = processResultAction(resultAction, context.getViewsRepo());
final ProcessInstanceResult result = ProcessInstanceResult.builder(pinstanceId).action(resultActionProcessed).build();
this.result = result;
return result;
} catch (final Throwable ex) {
throw AdempiereException.wrapIfNeeded(ex);
}
}
Aggregations