use of de.metas.process.ProcessExecutionResult.WebuiViewToOpen in project metasfresh-webui-api by metasfresh.
the class ADProcessPostProcessService method createResultAction.
private ResultAction createResultAction(final ProcessInfo processInfo, final ProcessExecutionResult processExecutionResult) {
final File reportTempFile = saveReportToDiskIfAny(processExecutionResult);
final RecordsToOpen recordsToOpen = processExecutionResult.getRecordsToOpen();
// Open report
if (reportTempFile != null) {
logger.debug("The processExecutionResult specifies reportTempFile={}", reportTempFile);
return OpenReportAction.builder().filename(processExecutionResult.getReportFilename()).contentType(processExecutionResult.getReportContentType()).tempFile(reportTempFile).build();
} else // Create & open view from Records
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.GridView) {
logger.debug("The processExecutionResult specifies recordsToOpen={}", recordsToOpen);
final Set<DocumentPath> referencingDocumentPaths = recordsToOpen.isAutomaticallySetReferencingDocumentPaths() ? extractReferencingDocumentPaths(processInfo) : null;
final String parentViewIdStr = processExecutionResult.getWebuiViewId();
final ViewId parentViewId = parentViewIdStr != null ? ViewId.ofViewIdString(parentViewIdStr) : null;
final CreateViewRequest viewRequest = createViewRequest(recordsToOpen, referencingDocumentPaths, parentViewId);
final IView view = viewsRepo.createView(viewRequest);
return OpenViewAction.builder().viewId(view.getViewId()).build();
} else // Open existing view
if (processExecutionResult.getWebuiViewToOpen() != null) {
final WebuiViewToOpen viewToOpen = processExecutionResult.getWebuiViewToOpen();
logger.debug("The processExecutionResult specifies viewToOpen={}", viewToOpen);
final ViewOpenTarget target = viewToOpen.getTarget();
if (ViewOpenTarget.IncludedView.equals(target)) {
return OpenIncludedViewAction.builder().viewId(ViewId.ofViewIdString(viewToOpen.getViewId())).profileId(ViewProfileId.fromJson(viewToOpen.getProfileId())).build();
} else if (ViewOpenTarget.ModalOverlay.equals(target)) {
return OpenViewAction.builder().viewId(ViewId.ofViewIdString(viewToOpen.getViewId())).profileId(ViewProfileId.fromJson(viewToOpen.getProfileId())).modalOverlay(true).build();
} else if (ViewOpenTarget.NewBrowserTab.equals(target)) {
return OpenViewAction.builder().viewId(ViewId.ofViewIdString(viewToOpen.getViewId())).profileId(ViewProfileId.fromJson(viewToOpen.getProfileId())).modalOverlay(false).build();
} else {
throw new AdempiereException("Unknown target: " + target);
}
} else // Open single document
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.SingleDocument) {
final DocumentPath documentPath = extractSingleDocumentPath(recordsToOpen);
return OpenSingleDocument.builder().documentPath(documentPath).modal(false).build();
} else // Open single document
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.SingleDocumentModal) {
final DocumentPath documentPath = extractSingleDocumentPath(recordsToOpen);
return OpenSingleDocument.builder().documentPath(documentPath).modal(true).build();
} else // Display QRCode to user
if (processExecutionResult.getDisplayQRCode() != null) {
return DisplayQRCodeAction.builder().code(processExecutionResult.getDisplayQRCode().getCode()).build();
} else //
// No action
{
return null;
}
}
Aggregations