Search in sources :

Example 31 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class ProcessDialog method init.

//	dispose
/**
	 *	Dynamic Init
	 *  @return true, if there is something to process (start from menu)
	 */
public boolean init() {
    log.config("");
    //	Similar to APanel.actionButton
    ProcessInfo pi = new ProcessInfo(null, processId);
    pi.setAD_User_ID(Env.getAD_User_ID(Env.getCtx()));
    pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
    parameterPanel = new ProcessPanel(this, windowNo, pi, ProcessPanel.COLUMNS_1);
    //	Set Default
    parameterPanel.createFieldsAndEditors();
    getContentPane().add(parameterPanel.getPanel());
    setTitle(parameterPanel.getName());
    //	Revalidate
    validateScreen();
    return true;
}
Also used : ProcessInfo(org.compiere.process.ProcessInfo)

Example 32 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class MAssetAddition method updateSourceDocument.

//	afterSave
/**
	 * Update Source Document (Invoice, Project etc) Status
	 * @param isReversal is called from a reversal action (like Void, Reverse-Correct).
	 * 					We need this flag because that when we call the method from voidIt()
	 * 					the document is not marked as voided yet. Same thing applies for reverseCorrectIt too. 
	 */
private void updateSourceDocument(final boolean isReversalParam) {
    boolean isReversal = isReversalParam;
    // Check if this document is reversed/voided
    String docStatus = getDocStatus();
    if (!isReversal && (DOCSTATUS_Reversed.equals(docStatus) || DOCSTATUS_Voided.equals(docStatus))) {
        isReversal = true;
    }
    final String sourceType = getA_SourceType();
    // Invoice: mark C_InvoiceLine.A_Processed='Y' and set C_InvoiceLine.A_Asset_ID
    if (A_SOURCETYPE_Invoice.equals(sourceType) && isProcessed()) {
        int C_InvoiceLine_ID = getC_InvoiceLine_ID();
        MInvoiceLine invoiceLine = new MInvoiceLine(getCtx(), C_InvoiceLine_ID, get_TrxName());
        invoiceLine.setA_Processed(!isReversal);
        invoiceLine.setA_Asset_ID(isReversal ? 0 : getA_Asset_ID());
        invoiceLine.saveEx();
    } else // Project
    if (A_SOURCETYPE_Project.equals(sourceType) && isProcessed()) {
        if (isReversal) {
        // Project remains closed. We just void/reverse/reactivate the Addition
        } else {
            //TODO decide whether to close project first or later
            int project_id = getC_Project_ID();
            ProcessInfo pi = new ProcessInfo("", 0, MProject.Table_ID, project_id);
            pi.setAD_Client_ID(getAD_Client_ID());
            pi.setAD_User_ID(Env.getAD_User_ID(getCtx()));
            //
            ProjectClose proc = new ProjectClose();
            proc.startProcess(getCtx(), pi, Trx.get(get_TrxName(), false));
            if (pi.isError()) {
                throw new AssetException(pi.getSummary());
            }
        }
    } else // Import
    if (A_SOURCETYPE_Imported.equals(sourceType) && !isProcessed()) {
        if (is_new() && getI_FixedAsset_ID() > 0) {
            MIFixedAsset ifa = getI_FixedAsset(false);
            if (ifa != null) {
                ifa.setI_IsImported(true);
                ifa.setA_Asset_ID(getA_Asset_ID());
                ifa.saveEx(get_TrxName());
            }
        }
    } else // Manual
    if (A_SOURCETYPE_Manual.equals(sourceType) && isProcessed()) {
        // nothing to do
        log.fine("Nothing to do");
    }
}
Also used : ProjectClose(org.compiere.process.ProjectClose) AssetException(org.compiere.FA.exceptions.AssetException) ProcessInfo(org.compiere.process.ProcessInfo)

Example 33 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class OrderDistribution method generate.

//	saveSelection
public String generate(IStatusBar statusBar, String docActionSelected) {
    String info = "";
    log.info("M_Locator_ID=" + m_M_Locator_ID);
    String trxName = Trx.createTrxName("IMG");
    Trx trx = Trx.get(trxName, true);
    //  prevents from being called twice
    setSelectionActive(false);
    statusBar.setStatusLine(Msg.translate(Env.getCtx(), "M_Movement_ID"));
    statusBar.setStatusDB(String.valueOf(getSelection().size()));
    //	Prepare Process
    int AD_Process_ID = MProcess.getProcess_ID("M_Generate Movement", trxName);
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
    if (!instance.save()) {
        info = Msg.getMsg(Env.getCtx(), "ProcessNoInstance");
        return info;
    }
    DB.createT_Selection(instance.getAD_PInstance_ID(), getSelection(), null);
    //call process
    ProcessInfo pi = new ProcessInfo("VOrderDistribution", AD_Process_ID);
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    //	Add Parameter - Selection=Y
    MPInstancePara ip = new MPInstancePara(instance, 10);
    ip.setParameter("Selection", "Y");
    ip.saveEx();
    MLocator locator = MLocator.get(Env.getCtx(), Integer.parseInt(m_M_Locator_ID.toString()));
    //	Add Parameter - M_Warehouse_ID=x
    ip = new MPInstancePara(instance, 20);
    ip.setParameter("M_Warehouse_ID", locator.getM_Warehouse_ID());
    ip.saveEx();
    setTrx(trx);
    setProcessInfo(pi);
    return info;
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) MLocator(org.compiere.model.MLocator) Trx(org.compiere.util.Trx) ProcessInfo(org.compiere.process.ProcessInfo)

Example 34 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class ZkReportViewerProvider method openViewer.

public void openViewer(ReportEngine report) {
    if (report.getPrintInfo().getAD_Process_ID() == 202 && MSysConfig.getBooleanValue("SMART_REPORT", Boolean.FALSE)) {
        ProcessInfo processInfo = report.getProcessInfo();
        MReport m_report = new MReport(report.getCtx(), processInfo.getRecord_ID(), processInfo.getTransactionName());
        ProcessInfoParameter[] pi = processInfo.getParameter();
        // Goodwill BF: report title is taken wrongly from other report if report line set is shared 
        // - passing PA_Report_ID instead of PA_ReportLineSet_ID
        Window smjviewer = new SMJReportViewer(processInfo.getAD_PInstance_ID(), processInfo.getTransactionName(), m_report.getPA_Report_ID(), pi[0].getParameterAsInt(), report.getPrintFormat().getAD_PrintFont_ID(), m_report.getColumnSet().getColumns());
        smjviewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        smjviewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
        SessionManager.getAppDesktop().showWindow(smjviewer);
    } else {
        Window viewer = new ZkReportViewer(report, report.getName());
        viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
        SessionManager.getAppDesktop().showWindow(viewer);
    }
}
Also used : MReport(org.compiere.report.MReport) Window(org.adempiere.webui.component.Window) ProcessInfoParameter(org.compiere.process.ProcessInfoParameter) ProcessInfo(org.compiere.process.ProcessInfo) SMJReportViewer(org.adempiere.webui.component.SMJReportViewer)

Example 35 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class WBrowser method cmd_Ok.

/**
	 * Ok Action
	 */
private void cmd_Ok() {
    log.config("OK=" + true);
    m_ok = true;
    saveResultSelection(detail);
    saveSelection(detail);
    //	Is Process ok
    boolean isOk = false;
    //	Valid Process, Selected Keys and process parameters
    if (getAD_Process_ID() > 0 && getSelectedKeys() != null) {
        parameterPanel.getProcessInfo().setAD_PInstance_ID(-1);
        // FR [ 265 ]
        if (parameterPanel.validateParameters() == null) {
            //	Save Parameters
            if (parameterPanel.saveParameters() == null) {
                //	Get Process Info
                ProcessInfo pi = parameterPanel.getProcessInfo();
                if (getFieldKey() != null && getFieldKey().get_ID() > 0) {
                    MViewDefinition viewDefinition = (MViewDefinition) getFieldKey().getAD_View_Column().getAD_View_Definition();
                    pi.setAliasForTableSelection(viewDefinition.getTableAlias());
                    pi.setTableSelectionId(viewDefinition.getAD_Table_ID());
                }
                //	Set Selected Values
                pi.setSelectionValues(getSelectedValues());
                //	
                setBrowseProcessInfo(pi);
                // Execute Process
                ProcessCtl worker = new ProcessCtl(this, pi.getWindowNo(), pi, null);
                showBusyDialog();
                worker.run();
                hideBusyDialog();
                setStatusLine(pi.getSummary(), pi.isError());
                //	For Valid Ok
                isOk = !pi.isError();
            }
        }
    }
    //	For when is ok the process
    if (isOk) {
        //	Close
        if (getParentWindowNo() > 0) {
            //	BR [ 394 ]
            Env.clearWinContext(getWindowNo());
            SessionManager.getAppDesktop().closeActiveWindow();
            return;
        }
        //	Else Reset
        p_loadedOK = initBrowser();
        collapsibleSeach.setOpen(true);
    }
}
Also used : ProcessCtl(org.compiere.apps.ProcessCtl) ProcessInfo(org.compiere.process.ProcessInfo) MViewDefinition(org.adempiere.model.MViewDefinition)

Aggregations

ProcessInfo (org.compiere.process.ProcessInfo)65 MPInstance (org.compiere.model.MPInstance)21 Trx (org.compiere.util.Trx)17 AdempiereException (org.adempiere.exceptions.AdempiereException)14 MPInstancePara (org.compiere.model.MPInstancePara)12 ReportEngine (org.compiere.print.ReportEngine)11 File (java.io.File)10 MProcess (org.compiere.model.MProcess)9 ProcessCtl (org.compiere.apps.ProcessCtl)8 SQLException (java.sql.SQLException)6 Timestamp (java.sql.Timestamp)6 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 ServletException (javax.servlet.ServletException)4 MBrowse (org.adempiere.model.MBrowse)4 PrintInfo (org.compiere.model.PrintInfo)4 ProcessInfoParameter (org.compiere.process.ProcessInfoParameter)4 Properties (java.util.Properties)3 MMovement (org.compiere.model.MMovement)3 PO (org.compiere.model.PO)3