Search in sources :

Example 1 with ProcessCtl

use of org.compiere.apps.ProcessCtl in project adempiere by adempiere.

the class ZkReportViewer method launchProcessPara.

//	cmd_find
/**
	 * FR [ 295 ]
	 * Launch Parameters for re-query
	 * @return isOk
	 */
private boolean launchProcessPara() {
    //	Create new Instance
    ProcessInfo pi = new ProcessInfo(m_reportEngine.getProcessInfo().getTitle(), m_reportEngine.getProcessInfo().getAD_Process_ID(), m_reportEngine.getProcessInfo().getTable_ID(), m_reportEngine.getProcessInfo().getRecord_ID());
    //	Launch dialog
    ProcessModalDialog dialog = new ProcessModalDialog(null, m_WindowNo, pi);
    if (dialog.isValid()) {
        try {
            dialog.setPage(this.getPage());
            dialog.doModal();
            //	Valid
            if (dialog.isOK()) {
                //	execute
                ProcessCtl worker = new ProcessCtl(null, m_WindowNo, pi, true, null);
                //synchrous
                worker.run();
                //	
                ReportEngine re = ReportEngine.get(Env.getCtx(), pi);
                //	
                if (re != null) {
                    m_reportEngine.setQuery(re.getQuery());
                }
                //	
                return true;
            }
        } catch (InterruptedException e) {
            log.severe(e.getLocalizedMessage());
        }
    }
    //	Default
    return false;
}
Also used : ReportEngine(org.compiere.print.ReportEngine) ProcessCtl(org.compiere.apps.ProcessCtl) ProcessInfo(org.compiere.process.ProcessInfo) ProcessModalDialog(org.adempiere.webui.apps.ProcessModalDialog)

Example 2 with ProcessCtl

use of org.compiere.apps.ProcessCtl in project adempiere by adempiere.

the class VInOutInvoiceGen method generateInvoices.

//  generateShipments_complete
/**************************************************************************
	 *	Generate Invoices
	 */
private void generateInvoices() {
    String trxName = Trx.createTrxName("IVG");
    //trx needs to be committed too
    Trx trx = Trx.get(trxName, true);
    //String trxName = null;
    //Trx trx = null;
    //  prevents from being called twice
    m_selectionActive = false;
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateGen"));
    statusBar.setStatusDB(String.valueOf(selection.size()));
    //	Prepare Process
    int AD_Process_ID = 0;
    KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
    if (docTypeKNPair.getKey() == MRMA.Table_ID) {
        // C_Invoice_GenerateRMA - org.adempiere.process.InvoiceGenerateRMA
        AD_Process_ID = 52002;
    } else {
        // HARDCODED    C_InvoiceCreate
        AD_Process_ID = 134;
    }
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
    if (!instance.save()) {
        info.setText(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
        return;
    }
    //insert selection
    /*Selection exist from shipment*/
    StringBuffer insert = new StringBuffer();
    insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
    int counter = 0;
    for (Integer selectedId : selection) {
        counter++;
        if (counter > 1)
            insert.append(" UNION ");
        insert.append("SELECT ");
        insert.append(instance.getAD_PInstance_ID());
        insert.append(", ");
        insert.append(selectedId);
        insert.append(" FROM DUAL ");
        if (counter == 1000) {
            if (DB.executeUpdate(insert.toString(), trxName) < 0) {
                //  not translated!
                String msg = "No Shipments";
                log.config(msg);
                info.setText(msg);
                trx.rollback();
                return;
            }
            insert = new StringBuffer();
            insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
            counter = 0;
        }
    }
    if (counter > 0) {
        if (DB.executeUpdate(insert.toString(), trxName) < 0) {
            //  not translated!
            String msg = "No Shipments";
            log.config(msg);
            info.setText(msg);
            trx.rollback();
            return;
        }
    }
    ProcessInfo pi = new ProcessInfo("", AD_Process_ID);
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    //	Add Parameters
    MPInstancePara para = new MPInstancePara(instance, 10);
    para.setParameter("Selection", "Y");
    if (!para.save()) {
        //  not translated
        String msg = "No Selection Parameter added";
        info.setText(msg);
        log.log(Level.SEVERE, msg);
        return;
    }
    para = new MPInstancePara(instance, 20);
    para.setParameter("DocAction", "CO");
    if (!para.save()) {
        //  not translated
        String msg = "No DocAction Parameter added";
        info.setText(msg);
        log.log(Level.SEVERE, msg);
        return;
    }
    //	Execute Process
    ProcessCtl worker = new ProcessCtl(this, Env.getWindowNo(this), pi, trx);
    //  complete tasks in unlockUI / generateInvoice_complete
    worker.start();
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) ProcessCtl(org.compiere.apps.ProcessCtl) Trx(org.compiere.util.Trx) KeyNamePair(org.compiere.util.KeyNamePair) ProcessInfo(org.compiere.process.ProcessInfo)

Example 3 with ProcessCtl

use of org.compiere.apps.ProcessCtl in project adempiere by adempiere.

the class VInOutInvoiceGen method generateShipments.

//	saveSelection
/**************************************************************************
	 *	Generate Shipments
	 */
private void generateShipments() {
    log.info("M_Warehouse_ID=" + m_M_Warehouse_ID);
    String trxName = Trx.createTrxName("IOG");
    //trx needs to be committed too
    Trx trx = Trx.get(trxName, true);
    //String trxName = null;
    //Trx trx = null;
    //  prevents from being called twice
    m_selectionActive = false;
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateGen"));
    statusBar.setStatusDB(String.valueOf(selection.size()));
    //	Prepare Process
    int AD_Process_ID = 0;
    KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
    if (docTypeKNPair.getKey() == MRMA.Table_ID) {
        // M_InOut_GenerateRMA - org.adempiere.process.InOutGenerateRMA
        AD_Process_ID = 52001;
    } else {
        // M_InOut_Generate - org.compiere.process.InOutGenerate
        AD_Process_ID = 199;
    }
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
    if (!instance.save()) {
        info.setText(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
        return;
    }
    //insert selection
    StringBuffer insert = new StringBuffer();
    insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
    int counter = 0;
    for (Integer selectedId : selection) {
        counter++;
        if (counter > 1)
            insert.append(" UNION ");
        insert.append("SELECT ");
        insert.append(instance.getAD_PInstance_ID());
        insert.append(", ");
        insert.append(selectedId);
        insert.append(" FROM DUAL ");
        if (counter == 1000) {
            if (DB.executeUpdate(insert.toString(), trxName) < 0) {
                //  not translated!
                String msg = "No Shipments";
                log.config(msg);
                info.setText(msg);
                trx.rollback();
                return;
            }
            insert = new StringBuffer();
            insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
            counter = 0;
        }
    }
    if (counter > 0) {
        if (DB.executeUpdate(insert.toString(), trxName) < 0) {
            //  not translated!
            String msg = "No Shipments";
            log.config(msg);
            info.setText(msg);
            trx.rollback();
            return;
        }
    }
    //call process
    ProcessInfo pi = new ProcessInfo("VInOutGen", 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");
    if (!ip.save()) {
        //  not translated
        String msg = "No Parameter added";
        info.setText(msg);
        log.log(Level.SEVERE, msg);
        return;
    }
    //	Add Parameter - M_Warehouse_ID=x
    ip = new MPInstancePara(instance, 20);
    ip.setParameter("M_Warehouse_ID", Integer.parseInt(m_M_Warehouse_ID.toString()));
    if (!ip.save()) {
        //  not translated
        String msg = "No Parameter added";
        info.setText(msg);
        log.log(Level.SEVERE, msg);
        return;
    }
    //	Execute Process
    ProcessCtl worker = new ProcessCtl(this, Env.getWindowNo(this), pi, trx);
    //  complete tasks in unlockUI / generateShipments_complete
    worker.start();
//
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) ProcessCtl(org.compiere.apps.ProcessCtl) Trx(org.compiere.util.Trx) KeyNamePair(org.compiere.util.KeyNamePair) ProcessInfo(org.compiere.process.ProcessInfo)

Example 4 with ProcessCtl

use of org.compiere.apps.ProcessCtl in project adempiere by adempiere.

the class ProcessPanel method runProcess.

/**
	 * Run it
	 */
protected void runProcess() {
    getProcessInfo().setPrintPreview(true);
    ProcessCtl worker = new ProcessCtl(this, getWindowNo(), getProcessInfo(), null);
    worker.run();
//	Run
}
Also used : ProcessCtl(org.compiere.apps.ProcessCtl)

Example 5 with ProcessCtl

use of org.compiere.apps.ProcessCtl in project adempiere by adempiere.

the class AReport method launchReport.

//	launchReport
/**
	 * 	Launch Report
	 * 	@param pf print format
	 */
private void launchReport(MPrintFormat pf) {
    int Record_ID = 0;
    //  The query is passed into AReport.java with only the key or link column included.
    if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer)
        Record_ID = ((Integer) m_query.getCode(0)).intValue();
    //  Add the extended query after the record ID has been identified.
    if (m_whereExtended != null && m_whereExtended.length() > 0 && m_query != null)
        m_query.addRestriction(Env.parseContext(Env.getCtx(), WindowNo, m_whereExtended, false));
    PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
    info.setDescription(m_query.getInfo());
    if (pf != null && pf.getJasperProcess_ID() > 0) {
        // It's a report using the JasperReports engine
        ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID);
        //	Execute Process
        ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null);
    } else {
        // It's a default report using the standard printing engine
        ReportEngine re = new ReportEngine(Env.getCtx(), pf, m_query, info);
        re.setWhereExtended(m_whereExtended);
        re.setWindowNo(WindowNo);
        ReportCtl.preview(re);
    }
}
Also used : ProcessCtl(org.compiere.apps.ProcessCtl) PrintInfo(org.compiere.model.PrintInfo) ProcessInfo(org.compiere.process.ProcessInfo)

Aggregations

ProcessCtl (org.compiere.apps.ProcessCtl)9 ProcessInfo (org.compiere.process.ProcessInfo)7 MViewDefinition (org.adempiere.model.MViewDefinition)2 MPInstance (org.compiere.model.MPInstance)2 MPInstancePara (org.compiere.model.MPInstancePara)2 KeyNamePair (org.compiere.util.KeyNamePair)2 Trx (org.compiere.util.Trx)2 Container (java.awt.Container)1 ProcessModalDialog (org.adempiere.webui.apps.ProcessModalDialog)1 ProcessModalDialog (org.compiere.apps.ProcessModalDialog)1 Waiting (org.compiere.apps.Waiting)1 PrintInfo (org.compiere.model.PrintInfo)1 ReportEngine (org.compiere.print.ReportEngine)1