Search in sources :

Example 1 with LookupValues

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

the class ADServiceImpl method getDocAction.

public DocActionDocument getDocAction(int WindowNo, int TabNo, int RowNo, String ColName) throws XFireFault {
    authenticate(webServiceName, "getDocAction");
    DocActionDocument ret = DocActionDocument.Factory.newInstance();
    DocAction da = ret.addNewDocAction();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, true, TabNo, true, RowNo);
    if (ws != null) {
        LookupValues lvs = da.addNewAction();
        Process.renderDocActionOptions(lvs, ws.curTab);
    }
    return ret;
}
Also used : DocAction(pl.x3E.adInterface.DocAction) LookupValues(pl.x3E.adInterface.LookupValues) DocActionDocument(pl.x3E.adInterface.DocActionDocument)

Example 2 with LookupValues

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

the class ADServiceImpl method getLookupData.

public WindowTabDataDocument getLookupData(int WindowNo, int TabNo, int RowNo, String columnName) throws XFireFault {
    authenticate(webServiceName, "getLookupData");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, true, TabNo, true, RowNo);
    if (ws != null) {
        DataRow dr = ds.addNewDataRow();
        DataField df = dr.addNewField();
        GridField field = ws.curTab.getField(columnName);
        Lookup lookup = field.getLookup();
        df.setColumn(field.getColumnName());
        String lookupValue = null;
        if (field.getValue() != null)
            lookupValue = lookup.getDisplay(field.getValue());
        df.setLval(lookupValue);
        if (field.getValue() != null)
            df.setVal(field.getValue().toString());
        LookupValues lvs = df.addNewLookup();
        ADLookup.fillLookupValues(lvs, lookup, field);
    }
    return ret;
}
Also used : WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) DataField(pl.x3E.adInterface.DataField) DataSet(pl.x3E.adInterface.DataSet) WindowTabData(pl.x3E.adInterface.WindowTabData) Lookup(org.compiere.model.Lookup) MLookup(org.compiere.model.MLookup) GridField(org.compiere.model.GridField) LookupValues(pl.x3E.adInterface.LookupValues) DataRow(pl.x3E.adInterface.DataRow)

Example 3 with LookupValues

use of pl.x3E.adInterface.LookupValues 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)

Example 4 with LookupValues

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

the class ADServiceImpl method fillDataRow.

private void fillDataRow(DataRow dr, WWindowStatus ws, boolean handleLookups, boolean onlyUpdated) throws XFireFault {
    authenticate(webServiceName, "fillDataRow");
    int noFields = ws.curTab.getFieldCount();
    //m_cs.dateFormat = new SimpleDateFormat( m_cs.datePattern );
    //m_cs.dateTimeFormat = new SimpleDateFormat( m_cs.datePattern );
    String column = "";
    boolean isEditable = false;
    if (onlyUpdated) {
        java.util.Date clientUpdated = new java.util.Date();
        java.util.Date updated = (java.util.Date) ws.curTab.getValue("Updated");
        if (!updated.after(clientUpdated)) {
            DataField df = dr.addNewField();
            df.setColumn(recordIDfield);
            df.setDisp(false);
            df.setVal(Integer.toString(ws.curTab.getRecord_ID()));
            return;
        }
    }
    for (int colNo = 0; colNo < noFields; colNo++) {
        GridField field = ws.curTab.getField(colNo);
        column = field.getColumnName();
        if (!field.isDisplayed(true)) {
            DataField df = dr.addNewField();
            df.setColumn(column);
            df.setDisp(false);
            df.setVal("");
            //System.out.println("   *** not displayed: "+field.getColumnName()+"  | "+field.getDisplayLogic());
            continue;
        }
        if (field.getDisplayType() == DisplayType.Button)
            continue;
        DataField df = dr.addNewField();
        isEditable = field.isEditable(true);
        df.setEdit(isEditable);
        //  Get Data - turn to string
        Object data = ws.curTab.getValue(column);
        String info = null;
        //
        if (data == null && !DisplayType.isLookup(field.getDisplayType()))
            info = "";
        else {
            int dt = field.getDisplayType();
            switch(dt) {
                case DisplayType.Date:
                    info = m_cs.dateFormat.format(data);
                    //System.out.println( "Date: "+info );
                    break;
                case DisplayType.DateTime:
                    // TODO
                    //m_cs.dateTimeFormat.format(data);
                    info = m_cs.dateFormat.format(data);
                    //System.out.println( "DateTime: "+info ); 
                    break;
                case DisplayType.Amount:
                    info = m_cs.amountFormat.format(data);
                    break;
                case DisplayType.Number:
                case DisplayType.CostPrice:
                    info = m_cs.numberFormat.format(data);
                    break;
                case DisplayType.Quantity:
                    info = m_cs.quantityFormat.format(data);
                    break;
                case DisplayType.Integer:
                    info = m_cs.integerFormat.format(data);
                    break;
                case DisplayType.YesNo:
                    info = data.toString();
                    if ("Y".equals(info))
                        info = "true";
                    if ("N".equals(info))
                        info = "false";
                    //info = Msg.getMsg(ws.ctx, data.toString());
                    break;
                case DisplayType.Location:
                    info = data.toString();
                    if (handleLookups) {
                        String x = DB.getSQLValueString(null, "select l.address1||', '||l.postal||', '||l.city from c_location l where c_location_id=?", Integer.parseInt(info));
                        df.setLval(x);
                        System.out.println("  location = " + x);
                    }
                    break;
                default:
                    if (DisplayType.isLookup(dt)) {
                        Lookup lookup = field.getLookup();
                        //ArrayList<String> deps = field.getDependentOn();						
                        String lookupValue = null;
                        if (field.getValue() != null) {
                            lookupValue = lookup.getDisplay(field.getValue());
                        }
                        //lookup.refresh();
                        if (data != null) {
                            info = lookup.getDisplay(data);
                            if (info == null) {
                                lookup.refresh();
                                info = lookup.getDisplay(data);
                            }
                        }
                        df.setLval(lookupValue);
                        if (handleLookups && /*&& isEditable*/
                        lookup != null && //deps.size()>0) 
                        (field.getVO().ValidationCode != null && field.getVO().ValidationCode.length() > 0)) {
                            if (data != null)
                                info = lookup.getDisplay(data);
                            LookupValues lvs = df.addNewLookup();
                            ADLookup.fillLookupValues(lvs, lookup, field);
                        }
                        if (data != null)
                            info = data.toString();
                    } else {
                        info = data.toString();
                    //System.out.println(">>>>>>>> UNKNOWN > "+field.getColumnName() +"  = "+info);
                    }
            }
        }
        //System.out.println("		"+column+" = "+info);
        if ("M_Product_ID".equals(field.getColumnName()))
            System.out.println("---  " + info);
        df.setDisp(true);
        df.setVal(info);
        df.setColumn(field.getColumnName());
        if (field.isError()) {
            df.setError(true);
            df.setErrorVal(field.getErrorValue());
        }
    }
    DataField df = dr.addNewField();
    df.setColumn(recordIDfield);
    df.setVal(Integer.toString(ws.curTab.getRecord_ID()));
}
Also used : DataField(pl.x3E.adInterface.DataField) Lookup(org.compiere.model.Lookup) MLookup(org.compiere.model.MLookup) GridField(org.compiere.model.GridField) LookupValues(pl.x3E.adInterface.LookupValues)

Example 5 with LookupValues

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

the class ADServiceImpl method getCountry.

private LookupValues getCountry(MLocation location) {
    MCountry[] countries = MCountry.getCountries(location.getCtx());
    int comp = location.getC_Country_ID();
    if (comp == 0)
        comp = Env.getContextAsInt(m_cs.getM_ctx(), "C_Country_ID");
    LookupValues lvs = LookupValues.Factory.newInstance();
    for (int i = 0; i < countries.length; i++) {
        LookupValue lv = lvs.addNewLv();
        lv.setKey(String.valueOf(countries[i].getC_Country_ID()));
        lv.setVal(countries[i].getName());
    }
    return lvs;
}
Also used : MCountry(org.compiere.model.MCountry) LookupValues(pl.x3E.adInterface.LookupValues) LookupValue(pl.x3E.adInterface.LookupValue)

Aggregations

LookupValues (pl.x3E.adInterface.LookupValues)8 Lookup (org.compiere.model.Lookup)4 LookupValue (pl.x3E.adInterface.LookupValue)4 GridField (org.compiere.model.GridField)3 MLookup (org.compiere.model.MLookup)3 KeyNamePair (org.compiere.util.KeyNamePair)2 DataField (pl.x3E.adInterface.DataField)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 JasperPrint (net.sf.jasperreports.engine.JasperPrint)1 MCountry (org.compiere.model.MCountry)1 MProcess (org.compiere.model.MProcess)1 MProcessPara (org.compiere.model.MProcessPara)1 MRegion (org.compiere.model.MRegion)1 Language (org.compiere.util.Language)1 Login (org.compiere.util.Login)1 ValueNamePair (org.compiere.util.ValueNamePair)1 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)1 ADLoginResponse (pl.x3E.adInterface.ADLoginResponse)1