Search in sources :

Example 1 with DisplayQRCodeAction

use of de.metas.ui.web.process.ProcessInstanceResult.DisplayQRCodeAction in project metasfresh-webui-api by metasfresh.

the class JSONProcessInstanceResult method toJSONResultAction.

/**
 * Converts {@link ResultAction} to JSON
 */
private static final JSONResultAction toJSONResultAction(final ResultAction resultAction) {
    if (resultAction == null) {
        return null;
    } else if (resultAction instanceof OpenReportAction) {
        final OpenReportAction openReportAction = (OpenReportAction) resultAction;
        return new JSONOpenReportAction(openReportAction.getFilename(), openReportAction.getContentType());
    } else if (resultAction instanceof OpenViewAction) {
        final OpenViewAction openViewAction = (OpenViewAction) resultAction;
        return new JSONOpenViewAction(openViewAction.getViewId(), openViewAction.getProfileId(), openViewAction.isModalOverlay());
    } else if (resultAction instanceof OpenIncludedViewAction) {
        final OpenIncludedViewAction openIncludedViewAction = (OpenIncludedViewAction) resultAction;
        return new JSONOpenIncludedViewAction(openIncludedViewAction.getViewId(), openIncludedViewAction.getProfileId());
    } else if (resultAction instanceof OpenSingleDocument) {
        final OpenSingleDocument openDocumentAction = (OpenSingleDocument) resultAction;
        final DocumentPath documentPath = openDocumentAction.getDocumentPath();
        return new JSONOpenSingleDocumentAction(documentPath.getWindowId(), documentPath.getDocumentId().toJson(), openDocumentAction.isModal());
    } else if (resultAction instanceof SelectViewRowsAction) {
        final SelectViewRowsAction selectViewRowsAction = (SelectViewRowsAction) resultAction;
        return new JSONSelectViewRowsAction(selectViewRowsAction.getViewId(), selectViewRowsAction.getRowIds());
    } else if (resultAction instanceof DisplayQRCodeAction) {
        final DisplayQRCodeAction displayQRCodeAction = (DisplayQRCodeAction) resultAction;
        return new JSONDisplayQRCodeAction(displayQRCodeAction.getCode());
    } else {
        logger.warn("Unknown result action: {}. Ignoring it.", resultAction);
        return null;
    }
}
Also used : OpenViewAction(de.metas.ui.web.process.ProcessInstanceResult.OpenViewAction) SelectViewRowsAction(de.metas.ui.web.process.ProcessInstanceResult.SelectViewRowsAction) OpenSingleDocument(de.metas.ui.web.process.ProcessInstanceResult.OpenSingleDocument) OpenIncludedViewAction(de.metas.ui.web.process.ProcessInstanceResult.OpenIncludedViewAction) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DisplayQRCodeAction(de.metas.ui.web.process.ProcessInstanceResult.DisplayQRCodeAction) OpenReportAction(de.metas.ui.web.process.ProcessInstanceResult.OpenReportAction)

Aggregations

DisplayQRCodeAction (de.metas.ui.web.process.ProcessInstanceResult.DisplayQRCodeAction)1 OpenIncludedViewAction (de.metas.ui.web.process.ProcessInstanceResult.OpenIncludedViewAction)1 OpenReportAction (de.metas.ui.web.process.ProcessInstanceResult.OpenReportAction)1 OpenSingleDocument (de.metas.ui.web.process.ProcessInstanceResult.OpenSingleDocument)1 OpenViewAction (de.metas.ui.web.process.ProcessInstanceResult.OpenViewAction)1 SelectViewRowsAction (de.metas.ui.web.process.ProcessInstanceResult.SelectViewRowsAction)1 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)1