use of de.metas.process.ProcessExecutionResult.RecordsToOpen 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) {
return OpenReportAction.builder().filename(processExecutionResult.getReportFilename()).contentType(processExecutionResult.getReportContentType()).tempFile(reportTempFile).build();
} else // Open view
if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.GridView) {
final Set<DocumentPath> referencingDocumentPaths = extractReferencingDocumentPaths(processInfo);
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 included view
if (processExecutionResult.getWebuiIncludedViewIdToOpen() != null) {
return OpenIncludedViewAction.builder().viewId(ViewId.ofViewIdString(processExecutionResult.getWebuiIncludedViewIdToOpen())).profileId(ViewProfileId.fromJson(processExecutionResult.getWebuiViewProfileId())).build();
} 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 //
// No action
{
return null;
}
}
Aggregations