Search in sources :

Example 11 with MProcessPara

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

the class SvrProcess method validateParameter.

//  process
/**
	 * Validate Parameters
	 */
private void validateParameter() {
    MProcess process = MProcess.get(getCtx(), processInfo.getAD_Process_ID());
    //	No have parameter
    if (process == null)
        return;
    //	
    MProcessPara[] parameters = process.getParameters();
    StringBuffer errorMsg = new StringBuffer();
    //	Loop over parameter, find a mandatory parameter
    for (MProcessPara parameter : parameters) {
        if (parameter.isMandatory() && parameter.isActive()) {
            ProcessInfoParameter infoParameter = getInfoParameter(parameter.getColumnName());
            if (infoParameter == null || infoParameter.getParameter() == null || (DisplayType.isID(parameter.getAD_Reference_ID()) && ((infoParameter.getParameter() instanceof String && infoParameter.getParameterAsString() == null) || (infoParameter.getParameter() instanceof Number && infoParameter.getParameterAsInt() < 0))) || (DisplayType.isText(parameter.getAD_Reference_ID()) && (infoParameter.getParameterAsString() == null || infoParameter.getParameterAsString().length() == 0))) {
                if (errorMsg.length() > 0) {
                    errorMsg.append(", ");
                }
                //	
                errorMsg.append("@").append(parameter.getColumnName()).append("@");
            }
        }
    }
    //	throw exception
    if (errorMsg.length() > 0) {
        throw new AdempiereException(MESSAGE_FillMandatory + errorMsg.toString());
    }
}
Also used : MProcess(org.compiere.model.MProcess) AdempiereException(org.adempiere.exceptions.AdempiereException) MProcessPara(org.compiere.model.MProcessPara)

Example 12 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 MobileDoc createParameterPage(MobileSessionCtx 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) {
        MobileDoc doc = MobileDoc.createWindow("Process Not Found");
        return doc;
    }
    //Modified by Rob Klein 4/29/07
    MobileDoc doc = MobileDoc.createWindow(process.getName());
    if (process.isWorkflow()) {
        //Modified by Rob Klein 7/01/07
        if (mTab == null) {
            doc = MobileDoc.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);
            fieldset center = new fieldset();
            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("WProcess");
            myForm.setMethod("GET");
            //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(true)).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 {
        form myForm = new form().setName(process.getName());
        myForm.addAttribute("selected", "true");
        myForm.setClass("panel");
        if (process.getDescription() != null)
            myForm.addElement(new p(new i(process.getDescription())));
        if (process.getHelp() != null)
            myForm.addElement(new p(process.getHelp(), AlignType.LEFT));
        //
        myForm.setMethod("get");
        myForm.setAction(MobileEnv.getBaseDirectory("WProcess?AD_Process_ID=" + process.getAD_Process_ID()));
        myForm.setTarget("_self");
        //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));
        fieldset fs = new fieldset();
        fs.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);
            Element toField = para.isRange() ? wFieldforRange.getField(para.getLookup(), para.getDefaultValue2()) : new td(MobileEnv.NBSP);
            div d = new div();
            d.setClass("row");
            //	Add to list
            fs.addElement(d.addElement(wField.getLabel(true)).addElement(wField.getField(para.getLookup(), para.getDefaultValue())).addElement(toField));
        }
        //	Submit
        String text = "Submit";
        if (wsc.ctx != null)
            text = Msg.getMsg(wsc.ctx, "Submit");
        a submitbtn = new a("#", text);
        submitbtn.setClass("whiteButton");
        submitbtn.addAttribute("type", "submit");
        submitbtn.setID(text);
        // submitbtn.setOnClick("popUp('WProcess','WPopup')");
        myForm.addElement(fs);
        myForm.addElement(submitbtn);
        doc.getBody().addElement(myForm);
    }
    return doc;
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) org.apache.ecs.xhtml.a(org.apache.ecs.xhtml.a) MProcessPara(org.compiere.model.MProcessPara) MProcess(org.compiere.model.MProcess) Element(org.apache.ecs.Element) org.apache.ecs.xhtml.fieldset(org.apache.ecs.xhtml.fieldset) org.apache.ecs.xhtml.i(org.apache.ecs.xhtml.i) org.apache.ecs.xhtml.li(org.apache.ecs.xhtml.li) MProcessPara(org.compiere.model.MProcessPara) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) Timestamp(java.sql.Timestamp) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.div(org.apache.ecs.xhtml.div) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) 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 13 with MProcessPara

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

the class WLookup method doGet.

//  init
/**
	 * Process the HTTP Get request - initial Start
	 * Needs to have parameters FormName and ColumnName
	 *
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    MobileEnv.dump(request);
    MobileEnv.dump(request.getSession());
    //Modified by Rob Klein 4/29/07
    //
    MobileSessionCtx wsc = MobileSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    if (wsc == null) {
        MobileUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //  Get Mandatory Parameters
    String columnName = MobileUtil.getParameter(request, "ColumnName");
    //Lookup called from a process
    //Modified by Rob Klein 4/29/07
    int AD_Process_ID = MobileUtil.getParameterAsInt(request, "AD_Process_ID");
    //Lookup modified to include paging
    //Modified by Rob Klein 07/07/07
    int page = MobileUtil.getParameterAsInt(request, "page");
    int refValueId = 0;
    boolean startUpdate = false;
    String targetBase = "'" + columnName;
    String header = null;
    if (AD_Process_ID > 0) {
        if (AD_Process_ID < 1 || columnName == null || columnName.equals("")) {
            MobileUtil.createErrorPage(request, response, this, Msg.getMsg(wsc.ctx, "ParameterMissing"));
            return;
        }
        MProcess process = MProcess.get(wsc.ctx, AD_Process_ID);
        MProcessPara para = null;
        MProcessPara[] parameters = process.getParameters();
        for (int i = 0; i < parameters.length; i++) {
            if (para.getColumnName().equals(columnName))
                para = parameters[i];
        }
        if (para != null)
            refValueId = para.getAD_Reference_Value_ID();
        header = para.getColumnName();
    } else //Lookup called from a window
    {
        //	Modified by Rob Klein 7/01/07
        if (ws == null) {
            MobileUtil.createTimeoutPage(request, response, this, null);
            return;
        }
        GridField mField = ws.curTab.getField(columnName);
        log.config("ColumnName=" + columnName + ", MField=" + mField);
        if (mField == null || columnName == null || columnName.equals("")) {
            MobileUtil.createErrorPage(request, response, this, Msg.getMsg(ws.ctx, "ParameterMissing"));
            return;
        }
        header = mField.getHeader();
        boolean hasDependents = ws.curTab.hasDependants(columnName);
        boolean hasCallout = mField.getCallout().length() > 0;
        startUpdate = hasDependents || hasCallout;
        refValueId = mField.getAD_Reference_Value_ID();
    }
    if (m_searchFields == null || m_searchFields.length == 0) {
        getSearchFields(columnName, refValueId);
    }
    String search = MobileUtil.getParameter(request, "search");
    if (Util.isEmpty(MobileUtil.getParameter(request, "search"))) {
        //  Create Document
        MobileDoc doc = MobileDoc.createPopup(header);
        form panel = new form();
        panel.setMethod("post");
        panel.setClass("dialog");
        panel.setID("WLookup1");
        panel.setAction("WLookup?ColumnName=" + columnName + "&AD_Process_ID=" + AD_Process_ID);
        panel.addAttribute("selected", "true");
        fieldset set = new fieldset();
        h1 h = new h1(header);
        set.addElement(h);
        a a = new a("#", "Cancel");
        a.addAttribute("type", "cancel");
        a.setClass("button leftButton");
        set.addElement(a);
        a = new a("WLookup?ColumnName=" + columnName + "&AD_Process_ID=" + AD_Process_ID, "Search");
        a.addAttribute("type", "submit");
        a.setClass("button");
        set.addElement(a);
        panel.addElement(set);
        for (int i = 0; i < m_searchFields.length; i++) {
            /*
				label l = new label();
				l.addElement(m_searchLabels[i]);
				set.addElement(l)*/
            input f = new input(input.TYPE_TEXT, m_searchFields[i], "");
            f.setID(m_searchFields[i]);
            f.addAttribute("placeholder", m_searchLabels[i]);
            set.addElement(f).addElement(new br());
        }
        input hidden = new input(input.TYPE_HIDDEN, "search", "true");
        set.addElement(hidden);
        doc.getBody().addElement(panel);
        MobileUtil.createResponseFragment(request, response, this, null, doc);
    } else {
        //  Create Document
        MobileDoc doc = MobileDoc.createPopup(header);
        StringBuffer where = new StringBuffer();
        for (String column : m_searchFields) {
            String value = request.getParameter(column);
            if (!Util.isEmpty(value)) {
                value = "%" + value + "%";
                where.append(" AND UPPER(").append(column).append(") LIKE UPPER(").append(DB.TO_STRING(value)).append(") ");
            }
        }
        div panel = new div();
        panel.setClass("dialog");
        panel.addAttribute("selected", "true");
        panel.setID("WLookup2");
        fieldset set = new fieldset();
        panel.addElement(set);
        set.addElement(fillTable(wsc, columnName, refValueId, request.getRequestURI(), targetBase, startUpdate, page, where.toString()));
        //  Reset
        String text = "Reset";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Reset");		
        input resetbtn = new input(input.TYPE_RESET, text, "  " + text);
        resetbtn.setID(text);
        resetbtn.setClass("resetbtn");
        String script = targetBase + "F.value='';" + targetBase + "D.value='';self.close();";
        if (startUpdate)
            script += "startUpdate(" + targetBase + "F);";
        resetbtn.setOnClick(script);
        doc.getBody().addElement(panel);
        doc.getBody().addElement(resetbtn);
        MobileUtil.createResponseFragment(request, response, this, null, doc);
    }
}
Also used : MobileSessionCtx(org.compiere.mobile.MobileSessionCtx) MProcessPara(org.compiere.model.MProcessPara) org.apache.ecs.xhtml.a(org.apache.ecs.xhtml.a) MProcess(org.compiere.model.MProcess) org.apache.ecs.xhtml.fieldset(org.apache.ecs.xhtml.fieldset) org.apache.ecs.xhtml.h1(org.apache.ecs.xhtml.h1) MProcessPara(org.compiere.model.MProcessPara) GridField(org.compiere.model.GridField) org.apache.ecs.xhtml.br(org.apache.ecs.xhtml.br) org.apache.ecs.xhtml.div(org.apache.ecs.xhtml.div) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form)

Example 14 with MProcessPara

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

the class ProcessController method loadData.

/**
	 *	Read Fields to display
	 *  @return true if loaded OK
	 */
public boolean loadData() {
    log.config("");
    //	Create Fields
    boolean hasFields = false;
    process = MProcess.get(Env.getCtx(), processInfo.getAD_Process_ID());
    //	Load Parameter
    for (MProcessPara para : process.getASPParameters()) {
        hasFields = true;
        createField(para, windowNo);
    }
    //	
    return hasFields;
}
Also used : 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