Search in sources :

Example 6 with MProcessPara

use of org.compiere.model.MProcessPara in project adempiere by adempiere.

the class WProcess method createParameterPage.

//  doPost
//Modified by Rob Klein 4/29/07
/**************************************************************************
	 * 	Create Parameter Page
	 * 	@param wsc web session context
	 *	@param AD_Menu_ID Menu
	 *	@return Page
	 */
private WebDoc createParameterPage(WebSessionCtx wsc, int processId, int windowID, int tableID, int recordID, int Type, String columnName, GridTab mTab) {
    MProcess process = null;
    if (Type == 0)
        process = MProcess.getFromMenu(wsc.ctx, processId);
    else
        process = MProcess.get(wsc.ctx, processId);
    //	need to check if Role can access
    if (process == null) {
        WebDoc doc = WebDoc.createWindow("Process Not Found");
        return doc;
    }
    //Modified by Rob Klein 4/29/07
    WebDoc doc = WebDoc.createWindow(process.getName());
    if (process.isWorkflow()) {
        //Modified by Rob Klein 7/01/07
        if (mTab == null) {
            doc = WebDoc.createWindow("No Tab found");
            return doc;
        }
        //	Pop up Document Action (Workflow)
        if (columnName.toString().equals("DocAction")) {
            readReference();
            option[] Options = dynInit(windowID, tableID, recordID, columnName, mTab);
            td center = doc.addWindowCenter(false);
            WebField wField = new WebField(wsc, columnName, columnName, columnName, //	no display length
            17, 22, 22, false, // 	not r/o, ., not error, not dependent
            false, false, false, false, false, processId, 0, 0, 0, 0, null, null, null, null, null);
            if (process.getDescription() != null)
                center.addElement(new p(new i(process.getDescription())));
            if (process.getHelp() != null)
                center.addElement(new p(process.getHelp(), AlignType.LEFT));
            form myForm = new form("WProcess").setName("process" + process.getAD_Process_ID());
            myForm.setTarget("WPopup");
            //myForm.setOnSubmit("this.Submit.disabled=true;return true;");
            myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
            myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
            myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
            myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
            table myTable = new table("0", "0", "5", "100%", null);
            myTable.setID("WProcessParameter");
            myTable.addElement(new tr().addElement(wField.getLabel()).addElement(createSelectField(columnName, Options)));
            // Reset
            String text = "Reset";
            if (wsc.ctx != null)
                text = Msg.getMsg(wsc.ctx, "Reset");
            input restbtn = new input(input.TYPE_RESET, text, "  " + text);
            restbtn.setID(text);
            restbtn.setClass("resetbtn");
            //	Submit
            text = "Submit";
            if (wsc.ctx != null)
                text = Msg.getMsg(wsc.ctx, "Submit");
            input submitbtn = new input(input.TYPE_SUBMIT, text, "  " + text);
            submitbtn.setID(text);
            submitbtn.setClass("submitbtn");
            myTable.addElement(new tr().addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, restbtn)).addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false, submitbtn)).addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, null)));
            myForm.addElement(myTable);
            center.addElement(myForm);
        }
    //	DocAction
    } else {
        td center = doc.addWindowCenter(false);
        if (process.getDescription() != null)
            center.addElement(new p(new i(process.getDescription())));
        if (process.getHelp() != null)
            center.addElement(new p(process.getHelp(), AlignType.LEFT));
        //
        form myForm = new form("WProcess").setName("process" + process.getAD_Process_ID());
        myForm.setTarget("WPopup");
        //myForm.setOnSubmit("this.Submit.disabled=true;return true;");
        myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
        myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
        myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
        myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
        table myTable = new table("0", "0", "5", "100%", null);
        myTable.setID("WProcessParameter");
        MProcessPara[] parameter = process.getParameters();
        for (int i = 0; i < parameter.length; i++) {
            MProcessPara para = parameter[i];
            WebField wField = new WebField(wsc, para.getColumnName(), para.getName(), para.getDescription(), //	no display length
            para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false, // 	not r/o, ., not error, not dependent
            false, para.isMandatory(), false, false, false, para.getAD_Process_ID(), 0, 0, 0, i, null, null, null, null, null);
            WebField wFieldforRange = null;
            if (para.isRange())
                wFieldforRange = new WebField(wsc, para.getColumnName(), para.getName(), para.getDescription(), //	no display length
                para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false, // 	not r/o, ., not error, not dependent
                false, para.isMandatory(), false, false, false, para.getAD_Process_ID(), 0, 0, 0, i + 1, null, null, null, null, null);
            td toField = para.isRange() ? wFieldforRange.getField(para.getLookup(), para.getDefaultValue2()) : new td(WebEnv.NBSP);
            //	Add to Table
            myTable.addElement(new tr().addElement(wField.getLabel()).addElement(wField.getField(para.getLookup(), para.getDefaultValue())).addElement(toField));
        }
        // Reset
        String text = "Reset";
        if (wsc.ctx != null)
            text = Msg.getMsg(wsc.ctx, "Reset");
        input restbtn = new input(input.TYPE_RESET, text, "  " + text);
        restbtn.setID(text);
        restbtn.setClass("resetbtn");
        //	Submit
        text = "Submit";
        if (wsc.ctx != null)
            text = Msg.getMsg(wsc.ctx, "Submit");
        input submitbtn = new input(input.TYPE_SUBMIT, text, "  " + text);
        submitbtn.setID(text);
        submitbtn.setClass("submitbtn");
        submitbtn.setOnClick("popUp('WProcess','WPopup')");
        myTable.addElement(new tr().addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, restbtn)).addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false, submitbtn)).addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, null)));
        myForm.addElement(myTable);
        center.addElement(myForm);
    }
    return doc;
}
Also used : MProcess(org.compiere.model.MProcess) org.apache.ecs.xhtml.i(org.apache.ecs.xhtml.i) MProcessPara(org.compiere.model.MProcessPara) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) Timestamp(java.sql.Timestamp) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr) org.apache.ecs.xhtml.option(org.apache.ecs.xhtml.option)

Example 7 with MProcessPara

use of org.compiere.model.MProcessPara in project adempiere by adempiere.

the class WProcess method fillParameter.

/**
	 * 	Fill Parameter
	 *	@param request request
	 *	@param process process
	 *	@return process instance
	 */
private MPInstance fillParameter(HttpServletRequest request, MProcess process) {
    MPInstance pInstance = new MPInstance(process, 0);
    //
    MPInstancePara[] iParams = pInstance.getParameters();
    for (int pi = 0; pi < iParams.length; pi++) {
        MPInstancePara iPara = iParams[pi];
        String key = iPara.getParameterName();
        MProcessPara pPara = process.getParameter(key);
        if (pPara == null) {
            log.log(Level.SEVERE, "Parameter not found: " + key);
            continue;
        }
        String valueString = WebUtil.getParameter(request, key);
        log.fine("fillParameter - " + key + " = " + valueString);
        Object value = valueString;
        if (valueString != null && valueString.length() == 0)
            value = null;
        //	No Value
        if (value == null) {
        //	if (pPara.isMandatory())
        //		log.log(Level.WARNING,"fillParameter - " + key 
        //			+ " - empty - mandatory!");
        } else {
            //	Convert to Type
            try {
                if (DisplayType.isNumeric(pPara.getAD_Reference_ID()) || DisplayType.isID(pPara.getAD_Reference_ID())) {
                    BigDecimal bd = null;
                    if (value instanceof BigDecimal)
                        bd = (BigDecimal) value;
                    else if (value instanceof Integer)
                        bd = new BigDecimal(((Integer) value).intValue());
                    else
                        bd = new BigDecimal(value.toString());
                    iPara.setP_Number(bd);
                    log.fine("fillParameter - " + key + " = " + valueString + " (=" + bd + "=)");
                } else if (DisplayType.isDate(pPara.getAD_Reference_ID())) {
                    Timestamp ts = null;
                    if (value instanceof Timestamp)
                        ts = (Timestamp) value;
                    else
                        ts = Timestamp.valueOf(value.toString());
                    iPara.setP_Date(ts);
                    log.fine("fillParameter - " + key + " = " + valueString + " (=" + ts + "=)");
                } else {
                    iPara.setP_String(value.toString());
                }
                //
                iPara.saveEx();
            } catch (Exception e) {
                log.warning("fillParameter - " + key + " = " + valueString + " (" + value + ") " + value.getClass().getName() + " - " + e.getLocalizedMessage());
            }
        }
    //	not null
    }
    return pInstance;
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) MProcessPara(org.compiere.model.MProcessPara) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 8 with MProcessPara

use of org.compiere.model.MProcessPara in project adempiere by adempiere.

the class ProcessAbstractClassGenerator method createParameters.

/**
	 * Create Parameters for header
	 * @return
	 */
private void createParameters() {
    //	Create Name and Values
    for (MProcessPara parameter : getParameters()) {
        //	The information only don't are parameters
        if (parameter.isInfoOnly())
            continue;
        createParameterName(parameter);
        createParameterValue(parameter, false);
        createParameterFill(parameter, false);
        //	For Range
        if (parameter.isRange()) {
            createParameterValue(parameter, true);
            createParameterFill(parameter, true);
        }
    }
}
Also used : MProcessPara(org.compiere.model.MProcessPara)

Example 9 with MProcessPara

use of org.compiere.model.MProcessPara in project adempiere by adempiere.

the class ASPGenerateLevel method generateProcess.

private void generateProcess(int p_AD_Process_ID) {
    // Add Process and Parameters
    MProcess process = new MProcess(getCtx(), p_AD_Process_ID, get_TrxName());
    int asp_process_id = DB.getSQLValueEx(get_TrxName(), "SELECT ASP_Process_ID FROM ASP_Process WHERE ASP_Level_ID = ? AND AD_Process_ID = ?", p_ASP_Level_ID, process.getAD_Process_ID());
    X_ASP_Process aspProcess = null;
    if (asp_process_id < 1) {
        aspProcess = new X_ASP_Process(getCtx(), 0, get_TrxName());
        aspProcess.setASP_Level_ID(p_ASP_Level_ID);
        aspProcess.setAD_Process_ID(process.getAD_Process_ID());
        aspProcess.setASP_Status(p_ASP_Status);
        if (aspProcess.save()) {
            noProcesses++;
            asp_process_id = aspProcess.getASP_Process_ID();
        }
    } else {
        aspProcess = new X_ASP_Process(getCtx(), asp_process_id, get_TrxName());
    }
    // parameters
    for (MProcessPara processpara : process.getParameters()) {
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Process_Para WHERE ASP_Process_ID = ? AND AD_Process_Para_ID = ?", asp_process_id, processpara.getAD_Process_Para_ID()) < 1) {
            X_ASP_Process_Para aspProcess_Para = new X_ASP_Process_Para(getCtx(), 0, get_TrxName());
            aspProcess_Para.setASP_Process_ID(asp_process_id);
            aspProcess_Para.setAD_Process_Para_ID(processpara.getAD_Process_Para_ID());
            aspProcess_Para.setASP_Status(p_ASP_Status);
            if (aspProcess_Para.save())
                noParameters++;
        }
    }
    if (process.getAD_Workflow_ID() > 0) {
        generateWorkflow(process.getAD_Workflow_ID());
    }
}
Also used : MProcess(org.compiere.model.MProcess) X_ASP_Process(org.compiere.model.X_ASP_Process) MProcessPara(org.compiere.model.MProcessPara) X_ASP_Process_Para(org.compiere.model.X_ASP_Process_Para)

Example 10 with MProcessPara

use of org.compiere.model.MProcessPara in project adempiere by adempiere.

the class CopyReportProcess method copyFrom.

/**
	 * Copy parameters to process
	 * @param process
	 * @param record
	 * @throws SQLException 
	 */
private void copyFrom(MProcess process, int key) throws SQLException {
    //	Get Values
    int m_AD_Column_ID = getSelectionAsInt(key, "PARAMETER_AD_Column_ID");
    int m_AD_ReportView_ID = getSelectionAsInt(key, "PARAMETER_AD_ReportView_ID");
    int m_AD_Process_Para_ID = getSelectionAsInt(key, "PARAMETER_AD_Process_Para_ID");
    boolean m_IsMandatory = getSelectionAsBoolean(key, "PARAMETER_IsMandatory");
    boolean m_IsRange = getSelectionAsBoolean(key, "PARAMETER_IsRange");
    String m_DefaultValue = getSelectionAsString(key, "PARAMETER_DefaultValue");
    String m_DefaultValue2 = getSelectionAsString(key, "PARAMETER_DefaultValue2");
    //	Do it
    MProcessPara newParameter = new MProcessPara(process);
    if (m_AD_ReportView_ID != 0) {
        //	For Create from View
        MColumn column = MColumn.get(getCtx(), m_AD_Column_ID);
        //	
        if (column.getAD_Reference_ID() == DisplayType.ID) {
            return;
        }
        //	For Process
        if (process.getAD_ReportView_ID() != m_AD_ReportView_ID) {
            process.setAD_ReportView_ID(m_AD_ReportView_ID);
            process.saveEx();
        }
        //	Set Values
        newParameter.setEntityType(process.getEntityType());
        newParameter.setAD_Element_ID(column.getAD_Element_ID());
        newParameter.setAD_Reference_ID(column.getAD_Reference_ID());
        newParameter.setAD_Reference_Value_ID(column.getAD_Reference_Value_ID());
        newParameter.setAD_Val_Rule_ID(column.getAD_Val_Rule_ID());
        newParameter.setName(column.getName());
        newParameter.setColumnName(column.getColumnName());
        newParameter.setDescription(column.getDescription());
        newParameter.setFieldLength(column.getFieldLength());
        newParameter.setHelp(column.getHelp());
        newParameter.setIsCentrallyMaintained(true);
    } else if (m_AD_Process_Para_ID != 0) {
        //	For Copy from Process
        MProcessPara fromParameter = new MProcessPara(getCtx(), m_AD_Process_Para_ID, get_TrxName());
        PO.copyValues(fromParameter, newParameter);
    } else {
        return;
    }
    //	Fill values
    newParameter.setIsMandatory(m_IsMandatory);
    newParameter.setIsRange(m_IsRange);
    newParameter.setDefaultValue(m_DefaultValue);
    newParameter.setDefaultValue2(m_DefaultValue2);
    newParameter.setSeqNo(m_SeqNo);
    //	Save
    newParameter.saveEx();
    //	Add new Sequence
    m_SeqNo += 10;
    addLog("@AD_Process_Para_ID@ @" + newParameter.getColumnName() + "@ @Added@");
}
Also used : MColumn(org.compiere.model.MColumn) MProcessPara(org.compiere.model.MProcessPara)

Aggregations

MProcessPara (org.compiere.model.MProcessPara)14 MProcess (org.compiere.model.MProcess)8 Timestamp (java.sql.Timestamp)5 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)4 MPInstancePara (org.compiere.model.MPInstancePara)4 BigDecimal (java.math.BigDecimal)3 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)3 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)3 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)3 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)3 MPInstance (org.compiere.model.MPInstance)3 ServletException (javax.servlet.ServletException)2 JasperPrint (net.sf.jasperreports.engine.JasperPrint)2 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)2 org.apache.ecs.xhtml.fieldset (org.apache.ecs.xhtml.fieldset)2 org.apache.ecs.xhtml.i (org.apache.ecs.xhtml.i)2 org.apache.ecs.xhtml.option (org.apache.ecs.xhtml.option)2 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)2