Search in sources :

Example 21 with ProcessInfo

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

the class Viewer method launchProcessPara.

//	cmd_find
/**
	 * FR [ 295 ]
	 * Launch Parameters for re-query
	 * @return isOk
	 */
private boolean launchProcessPara() {
    if (m_reportEngine.getProcessInfo() == null)
        return false;
    //	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 para = new ProcessModalDialog(Env.getFrame((Container) this), m_WindowNo, pi);
    if (para.isValidDialog()) {
        para.validate();
        para.pack();
        AEnv.showCenterWindow(Env.getWindow(m_WindowNo), para);
        if (para.isOK()) {
            //	execute
            ProcessCtl worker = new ProcessCtl(null, m_WindowNo, pi, true, null);
            //synchrous
            worker.run();
            //	
            ReportEngine re = ReportEngine.get(Env.getCtx(), pi);
            //	
            m_reportEngine.setQuery(re.getQuery());
            //	
            return true;
        }
    }
    //	Default
    return false;
}
Also used : Container(java.awt.Container) ProcessCtl(org.compiere.apps.ProcessCtl) ProcessInfo(org.compiere.process.ProcessInfo) ProcessModalDialog(org.compiere.apps.ProcessModalDialog)

Example 22 with ProcessInfo

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

the class MDDOrder method createDropShip.

//	completeIt
private void createDropShip() {
    //Create movement delivery
    Date date = Date.from(LocalDate.now().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    Timestamp today = new Timestamp(date.getTime());
    List<Integer> recordIds = new ArrayList<>();
    recordIds.add(getDD_Order_ID());
    ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(GenerateMovement.getProcessId()).withTitle(GenerateMovement.getProcessName()).withRecordId(MDDOrder.Table_ID, 0).withSelectedRecordsIds(recordIds).withParameter(MMovement.COLUMNNAME_MovementDate, today).withParameter(MMovement.COLUMNNAME_DocAction, DocAction.ACTION_Complete).withoutTransactionClose().execute(get_TrxName());
    if (processInfo.isError())
        throw new AdempiereException(processInfo.getSummary());
    List<Integer> orderLinesIds = new ArrayList<>();
    LinkedHashMap<Integer, LinkedHashMap<String, Object>> selection = new LinkedHashMap<Integer, LinkedHashMap<String, Object>>();
    getLines().stream().filter(orderLine -> orderLine != null).forEach(orderLine -> {
        orderLinesIds.add(orderLine.get_ID());
        LinkedHashMap<String, Object> values = new LinkedHashMap<String, Object>();
        values.put("LINE_" + MDDOrderLine.COLUMNNAME_QtyInTransit, orderLine.getQtyInTransit());
        selection.put(orderLine.get_ID(), values);
    });
    processInfo = ProcessBuilder.create(getCtx()).process(GenerateMovementMaterial.getProcessId()).withTitle(GenerateMovementMaterial.getProcessName()).withRecordId(MDDOrderLine.Table_ID, 0).withSelectedRecordsIds(orderLinesIds, selection).withParameter(MMovement.COLUMNNAME_MovementDate, today).withoutTransactionClose().execute(get_TrxName());
    if (processInfo.isError())
        throw new AdempiereException(processInfo.getSummary());
}
Also used : DocumentEngine(org.compiere.process.DocumentEngine) Arrays(java.util.Arrays) MProject(org.compiere.model.MProject) Date(java.util.Date) Env(org.compiere.util.Env) ProcessBuilder(org.eevolution.service.dsl.ProcessBuilder) MStorage(org.compiere.model.MStorage) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) MBPartnerLocation(org.compiere.model.MBPartnerLocation) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) Query(org.compiere.model.Query) DB(org.compiere.util.DB) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MBPartner(org.compiere.model.MBPartner) Msg(org.compiere.util.Msg) ResultSet(java.sql.ResultSet) MPeriod(org.compiere.model.MPeriod) ProcessInfo(org.compiere.process.ProcessInfo) DocAction(org.compiere.process.DocAction) Util(org.compiere.util.Util) Properties(java.util.Properties) GenerateMovement(org.eevolution.process.GenerateMovement) Timestamp(java.sql.Timestamp) MDocType(org.compiere.model.MDocType) MRefList(org.compiere.model.MRefList) File(java.io.File) ZoneId(java.time.ZoneId) ReportEngine(org.compiere.print.ReportEngine) ModelValidator(org.compiere.model.ModelValidator) List(java.util.List) AdempiereException(org.adempiere.exceptions.AdempiereException) MMovement(org.compiere.model.MMovement) LocalDate(java.time.LocalDate) I_C_DocType(org.compiere.model.I_C_DocType) Optional(java.util.Optional) MLocator(org.compiere.model.MLocator) PO(org.compiere.model.PO) ModelValidationEngine(org.compiere.model.ModelValidationEngine) GenerateMovementMaterial(org.eevolution.process.GenerateMovementMaterial) ArrayList(java.util.ArrayList) ProcessInfo(org.compiere.process.ProcessInfo) Timestamp(java.sql.Timestamp) Date(java.util.Date) LocalDate(java.time.LocalDate) LinkedHashMap(java.util.LinkedHashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 23 with ProcessInfo

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

the class GenerateMovement method doIt.

//	prepare
/**
     * Generate Movements
     * @return info
     * @throws Exception
     */
protected String doIt() throws Exception {
    ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(MovementGenerate.getProcessId()).withTitle(GenerateMovement.getProcessName()).withRecordId(MDDOrder.Table_ID, 0).withSelectedRecordsIds(getSelectionKeys()).withParameter(MMovement.COLUMNNAME_MovementDate, getMovementDate()).withParameter(MMovement.COLUMNNAME_DocAction, DocAction.ACTION_Complete).execute();
    if (processInfo.isError())
        throw new AdempiereException(processInfo.getSummary());
    result = processInfo.getSummary();
    int[] movementProcessedIds = processInfo.getIDs();
    if (movementProcessedIds != null && movementProcessedIds.length > 0) {
        Arrays.stream(movementProcessedIds).filter(movementId -> movementId > 0).forEach(movementId -> {
            MMovement movement = new MMovement(getCtx(), movementId, null);
            StringBuffer resultText = new StringBuffer(Msg.translate(Env.getCtx(), "DocumentNo") + " : " + movement.getDocumentNo());
            result = result == null ? " " + resultText.toString() : result + " " + resultText.toString();
            printDocument(movement, "Inventory Move Hdr (Example)", processInfo.getWindowNo());
        });
    }
    return result;
}
Also used : Arrays(java.util.Arrays) MDDOrder(org.eevolution.model.MDDOrder) Env(org.compiere.util.Env) ProcessBuilder(org.eevolution.service.dsl.ProcessBuilder) Constructor(java.lang.reflect.Constructor) Ini(org.compiere.util.Ini) AdempiereException(org.adempiere.exceptions.AdempiereException) Msg(org.compiere.util.Msg) MMovement(org.compiere.model.MMovement) ProcessInfo(org.compiere.process.ProcessInfo) DocAction(org.compiere.process.DocAction) PO(org.compiere.model.PO) IPrintDocument(org.eevolution.form.IPrintDocument) AdempiereException(org.adempiere.exceptions.AdempiereException) ProcessInfo(org.compiere.process.ProcessInfo) MMovement(org.compiere.model.MMovement)

Example 24 with ProcessInfo

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

the class WReport method launchReport.

//	launchReport
/**
	 * 	Launch Report
	 * 	@param pf print format
	 */
private File launchReport(MPrintFormat pf, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
    int Record_ID = 0;
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    //Instance pInstance = new MPInstance (wsc.ctx, 0, 0);
    File fileName = null;
    if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer) {
        Record_ID = ((Integer) m_query.getCode(0)).intValue();
    }
    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());
        Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
        //	Execute Process
        WProcessCtl.process(this, m_curTab.getAD_Window_ID(), pi, trx, request);
    } else {
        // It's a default report using the standard printing engine
        ReportEngine re = new ReportEngine(wsc.ctx, pf, m_query, info);
        if (re == null) {
            log.info("Could not start ReportEngine");
        } else {
            try {
                File file = File.createTempFile("WProcess", ".pdf");
                boolean ok = re.createPDF(file);
                if (ok) {
                    fileName = file;
                } else {
                    log.info("Could not create Report");
                }
            } catch (Exception e) {
                log.info(e.toString());
            }
        }
    }
    return fileName;
}
Also used : ReportEngine(org.compiere.print.ReportEngine) PrintInfo(org.compiere.model.PrintInfo) ProcessInfo(org.compiere.process.ProcessInfo) Trx(org.compiere.util.Trx) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File) ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 25 with ProcessInfo

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

the class WReport method launchReport.

//	launchReport
/**
	 * 	Launch Report
	 * 	@param pf print format
	 */
private void launchReport(MPrintFormat pf) {
    int Record_ID = 0;
    //  The query is passed into A/WReport.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
        WProcessCtl.process(null, WindowNo, pi, null);
    } else {
        // It's a default report using the standard printing engine
        ReportEngine re = new ReportEngine(Env.getCtx(), pf, m_query, info);
        // TODO: Is this required?  The extended query, if any, is included in the query.
        re.setWhereExtended(m_whereExtended);
        ReportCtl.preview(re);
    }
}
Also used : ReportEngine(org.compiere.print.ReportEngine) PrintInfo(org.compiere.model.PrintInfo) ProcessInfo(org.compiere.process.ProcessInfo)

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