Search in sources :

Example 1 with RecordsToOpen

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;
    }
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) IView(de.metas.ui.web.view.IView) ViewId(de.metas.ui.web.view.ViewId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) RecordsToOpen(de.metas.process.ProcessExecutionResult.RecordsToOpen) File(java.io.File) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 RecordsToOpen (de.metas.process.ProcessExecutionResult.RecordsToOpen)1 CreateViewRequest (de.metas.ui.web.view.CreateViewRequest)1 IView (de.metas.ui.web.view.IView)1 ViewId (de.metas.ui.web.view.ViewId)1 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)1 File (java.io.File)1 Set (java.util.Set)1