Search in sources :

Example 1 with ProcessParamList

use of pl.x3E.adInterface.ProcessParamList in project adempiere by adempiere.

the class Process method getProcessParams.

public static ProcessParamsDocument getProcessParams(CompiereService cs, GetProcessParamsDocument req) throws XFireFault {
    ProcessParamsDocument res = ProcessParamsDocument.Factory.newInstance();
    ProcessParams params = res.addNewProcessParams();
    ProcessParamList PL = params.addNewParams();
    int AD_Menu_ID = req.getGetProcessParams().getADMenuID();
    int AD_Process_ID = req.getGetProcessParams().getADProcessID();
    MProcess process = null;
    if (AD_Menu_ID > 0 && AD_Process_ID == 0)
        process = MProcess.getFromMenu(cs.getM_ctx(), AD_Menu_ID);
    else if (AD_Menu_ID == 0 && AD_Process_ID > 0)
        process = new MProcess(cs.getM_ctx(), AD_Process_ID, null);
    if (process != null) {
        params.setDescription(process.getDescription());
        params.setHelp(process.getHelp());
        params.setName(process.getName());
        params.setADProcessID(process.getAD_Process_ID());
        MProcessPara[] parameter = process.getParameters();
        for (int i = 0; i < parameter.length; i++) {
            MProcessPara para = parameter[i];
            ProcessParam p = PL.addNewParam();
            p.setName(para.getName());
            p.setDescription(para.getDescription());
            p.setDisplayType(para.getAD_Reference_ID());
            p.setIsMandatory(para.isMandatory());
            p.setFieldLength(para.getFieldLength());
            p.setIsRange(para.isRange());
            p.setColumnName(para.getColumnName());
            p.setDefaultValue(para.getDefaultValue());
            p.setDefaultValue2(para.getDefaultValue2());
            if (para.getDefaultValue() != null) {
                if (DisplayType.isDate(para.getAD_Reference_ID())) {
                    if (para.getDefaultValue().indexOf("@#Date@") >= 0) {
                        //Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" );
                        //String t = Env.getContext( cs.getM_ctx(), "#Date" );
                        String t = cs.dateFormat.format(Env.getContextAsDate(cs.getM_ctx(), "#Date"));
                        //cs.dateFormat.format( t ));
                        p.setDefaultValue(t);
                    }
                } else if (DisplayType.YesNo == para.getAD_Reference_ID()) {
                    if ("Y".equalsIgnoreCase(para.getDefaultValue()))
                        p.setDefaultValue("true");
                    else
                        p.setDefaultValue("false");
                }
            } else {
                if (DisplayType.YesNo == para.getAD_Reference_ID())
                    p.setDefaultValue("false");
            }
            if (para.getDefaultValue2() != null) {
                if (DisplayType.isDate(para.getAD_Reference_ID())) {
                    if (para.getDefaultValue2().indexOf("@#Date@") >= 0) {
                        //Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" );
                        //String t = Env.getContext( cs.getM_ctx(), "#Date" );
                        String t = cs.dateFormat.format(Env.getContextAsDate(cs.getM_ctx(), "#Date"));
                        //cs.dateFormat.format( t ) );
                        p.setDefaultValue2(t);
                    }
                }
            }
            if (para.isLookup()) {
                LookupValues lvs = p.addNewLookup();
                Lookup lookup = para.getLookup();
                try {
                    ADLookup.fillLookupValues(lvs, lookup, para.isMandatory(), false);
                } catch (Exception ex) {
                    System.out.println("getProcessParams exception: " + ex.getMessage());
                    ex.printStackTrace();
                }
            }
        }
    }
    return res;
}
Also used : MProcess(org.compiere.model.MProcess) ProcessParams(pl.x3E.adInterface.ProcessParams) GetProcessParamsDocument(pl.x3E.adInterface.GetProcessParamsDocument) ProcessParamsDocument(pl.x3E.adInterface.ProcessParamsDocument) ProcessParamList(pl.x3E.adInterface.ProcessParamList) MProcessPara(org.compiere.model.MProcessPara) Lookup(org.compiere.model.Lookup) LookupValues(pl.x3E.adInterface.LookupValues) JasperPrint(net.sf.jasperreports.engine.JasperPrint) ProcessParam(pl.x3E.adInterface.ProcessParam) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 JasperPrint (net.sf.jasperreports.engine.JasperPrint)1 Lookup (org.compiere.model.Lookup)1 MProcess (org.compiere.model.MProcess)1 MProcessPara (org.compiere.model.MProcessPara)1 GetProcessParamsDocument (pl.x3E.adInterface.GetProcessParamsDocument)1 LookupValues (pl.x3E.adInterface.LookupValues)1 ProcessParam (pl.x3E.adInterface.ProcessParam)1 ProcessParamList (pl.x3E.adInterface.ProcessParamList)1 ProcessParams (pl.x3E.adInterface.ProcessParams)1 ProcessParamsDocument (pl.x3E.adInterface.ProcessParamsDocument)1