From fa86305c30b912d64b03a50769cc34b442050a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Sch=C3=B6neberg?= Date: Mon, 6 Mar 2017 20:52:39 +0100 Subject: [PATCH] Add webui process WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper FRESH-1610 metasfresh/metasfresh-webui#210 Print Material Receipt Document via Material Receipt Candidates Window (cherry picked from commit 1f97c2a212eb9c572171c7afa31682d083bf54a6) --- ...eiptSchedule_RunMaterialReceiptJasper.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper.java diff --git a/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper.java b/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper.java new file mode 100644 index 000000000..1cba04609 --- /dev/null +++ b/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper.java @@ -0,0 +1,72 @@ +package de.metas.ui.web.handlingunits.process; + +import org.springframework.context.annotation.Profile; + +import de.metas.handlingunits.model.I_M_ReceiptSchedule; +import de.metas.handlingunits.report.HUReceiptScheduleReportExecutor; +import de.metas.process.IProcessPrecondition; +import de.metas.process.IProcessPreconditionsContext; +import de.metas.process.JavaProcess; +import de.metas.process.ProcessPreconditionsResolution; +import de.metas.ui.web.WebRestApiApplication; + +/* + * #%L + * metasfresh-webui-api + * %% + * Copyright (C) 2017 metas GmbH + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + +@Profile(value = WebRestApiApplication.PROFILE_Webui) +public class WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper extends JavaProcess implements IProcessPrecondition +{ + @Override + public ProcessPreconditionsResolution checkPreconditionsApplicable(final IProcessPreconditionsContext context) + { + if (context.isNoSelection()) + { + return ProcessPreconditionsResolution.rejectBecauseNoSelection(); + } + if (!context.isSingleSelection()) + { + return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection(); + } + + final I_M_ReceiptSchedule receiptSchedule = context.getSelectedModel(I_M_ReceiptSchedule.class); + + // guard against null (might happen if the selected ID is not valid) + if (receiptSchedule == null) + { + return ProcessPreconditionsResolution.rejectBecauseNoSelection(); + } + + return ProcessPreconditionsResolution.accept(); + } + + @Override + protected String doIt() throws Exception + { + final I_M_ReceiptSchedule receiptSchedule = getRecord(I_M_ReceiptSchedule.class); + + HUReceiptScheduleReportExecutor + .get(receiptSchedule) + .executeHUReport(); + + return MSG_OK; + } +}