Skip to content

Commit

Permalink
Add webui process WEBUI_M_ReceiptSchedule_RunMaterialReceiptJasper
Browse files Browse the repository at this point in the history
FRESH-1610 #210 Print Material Receipt
Document via Material Receipt Candidates Window
(cherry picked from commit 1f97c2a)
  • Loading branch information
metas-ts committed Apr 2, 2017
1 parent bc830d3 commit fa86305
Showing 1 changed file with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #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;
}
}

0 comments on commit fa86305

Please sign in to comment.