Search in sources :

Example 16 with DataField

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

the class ADServiceImpl method getLookupSearchData.

public WindowTabDataDocument getLookupSearchData(GetLookupSearchDataReqDocument req) throws XFireFault {
    //int WindowNo, int TabNo, int RowNo, DataRow dr 
    authenticate(webServiceName, "getLookupSearchData");
    GetLookupSearchDataReq reqt = req.getGetLookupSearchDataReq();
    DataField[] df = reqt.getParams().getFieldArray();
    for (int i = 0; i < df.length; i++) {
        if (df[i].getVal() != null && df[i].getVal().length() > 0)
            log.info("LookUp COlumn: " + df[i].getColumn() + " " + df[i].getVal());
    }
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    int WindowNo = reqt.getWindowNo();
    int TabNo = reqt.getTabNo();
    int RowNo = reqt.getTabNo();
    WWindowStatus ws = null;
    if (WindowNo > 0)
        //<-- Note changes to the active record (bledne action), probably are not properly communicated parameters    	
        ws = WWindowStatus.get(WindowStatusMap, WindowNo, true, TabNo, true, RowNo);
    if (ws != null) {
        ADLookup lk = new ADLookup(df[0].getVal());
        lk.getLookupSearchValues(reqt.getParams(), ds, ws.ctx, WindowNo);
    } else {
        ADLookup lk = new ADLookup(df[0].getVal());
        lk.getLookupSearchValues(reqt.getParams(), ds, this.m_cs.getM_ctx(), 0);
    }
    return ret;
}
Also used : WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) DataField(pl.x3E.adInterface.DataField) DataSet(pl.x3E.adInterface.DataSet) WindowTabData(pl.x3E.adInterface.WindowTabData) GetLookupSearchDataReq(pl.x3E.adInterface.GetLookupSearchDataReq)

Example 17 with DataField

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

the class ADServiceImpl method updateFields.

/**
	 * 	Update Field Values from Parameter
	 *	@param request request
	 *	@param wsc session context
	 *	@param ws window status
	 *	@return true if error
	 */
private boolean updateFields(WWindowStatus ws, DataRow dr) {
    boolean error = false;
    //request.getParameterNames();
    Enumeration en = null;
    DataField[] df = dr.getFieldArray();
    DataField f;
    for (int i = 0; i < df.length; i++) {
        //String key = (String)en.nextElement();
        f = df[i];
        String cn = f.getColumn();
        GridField GridField = ws.curTab.getField(cn);
        if (!GridField.isDisplayed(false))
            continue;
        if (// kolec - byl dopisany warunek na 'DocAction' ale to nie jest ok:  && !cn.equals("DocAction")
        GridField.getDisplayType() == DisplayType.Button)
            continue;
        if (GridField != null && GridField.isEditable(true)) {
            //!!!!
            String value = f.getVal();
            // kolec (plaba -cos wstawia &nbsp; do input type="text")
            if (value.length() == 0)
                value = null;
            //kolec
            if (value != null && (value.equals("-1")) && GridField.isLookup())
                value = null;
            if (GridField.getDisplayType() == DisplayType.YesNo) {
                if (value != null && (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")))
                    value = value.toLowerCase();
            //if (value != null && value.equalsIgnoreCase("null"))
            //	value = "false";
            //if (value == null)
            //	value = "false";
            }
            Object dbValue = GridField.getValue();
            boolean fieldError = false;
            String columnName = GridField.getColumnName();
            if (dbValue == null && value == null)
                continue;
            else //   new value null
            if (dbValue != null && value == null)
                ws.curTab.setValue(GridField, null);
            else //  from null to new value
            if (dbValue == null && value != null) {
                fieldError = !setFieldValue(ws, GridField, value);
            } else if (dbValue.equals(value))
                continue;
            else
                fieldError = !setFieldValue(ws, GridField, value);
            //
            if (!error && fieldError) {
                //log.info("Error: " + GridField.getColumnName());
                error = true;
            }
        }
    }
    return error;
}
Also used : Enumeration(java.util.Enumeration) DataField(pl.x3E.adInterface.DataField) GridField(org.compiere.model.GridField)

Example 18 with DataField

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

the class ADServiceImpl method saveDataRow.

public WindowTabDataDocument saveDataRow(int WindowNo, int TabNo, int RowNo, WindowTabDataDocument data) throws XFireFault {
    authenticate(webServiceName, "saveDataRow");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    DataRow ret_dr = ds.addNewDataRow();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, false, 0, true, RowNo);
    if (ws != null) {
        DataRow[] dr = data.getWindowTabData().getDataSet().getDataRowArray();
        if (dr.length == 1) {
            DataRow dr0 = dr[0];
            boolean error = updateFields(ws, dr0);
            DataField[] f = dr0.getFieldArray();
            HashMap fmap = new HashMap();
            for (int i = 0; i < f.length; i++) fmap.put(f[i].getColumn(), f[i].getVal());
            //  Check Mandatory
            int size = ws.curTab.getFieldCount();
            for (int i = 0; i < size; i++) {
                GridField field = ws.curTab.getField(i);
                if (//  context check
                field.isMandatory(true)) {
                    Object value = new Object();
                    //jesli tak nie zrobimy, mozemy stracic wartosc
                    if (field.getValue() == null && fmap.get(field.getColumnName()) != null)
                        //field.getValue();
                        value = fmap.get(field.getColumnName());
                    else
                        value = field.getValue();
                    if ((value == null || value.toString().length() == 0)) {
                        //  set editable otherwise deadlock
                        field.setInserting(true);
                        field.setError(true);
                        field.setErrorValue(value == null ? null : value.toString());
                        if (!error)
                            error = true;
                        System.out.println("Mandatory Error: " + field.getColumnName());
                    //log.info("Mandatory Error: " + field.getColumnName());
                    } else
                        field.setError(false);
                }
            }
            //  save it - of errors ignore changes
            wd.setSuccess(ws.curTab.dataSave(true));
            //ws.curTab.dataIgnore();
            ;
            //else
            //	fillDataRow( ret_dr, ws, true);          	
            fillDataRow(ret_dr, ws, true, false);
            if (ws.ads.m_is_error) {
                wd.setError(ws.ads.m_error_message);
                wd.setErrorInfo(ws.ads.m_error_info);
            } else {
                updateRecIDMap(ws);
            }
            wd.setStatus(ws.ads.m_status_data);
            wd.setStatusError(ws.ads.m_is_status_error);
            ws.m_needSave = false;
        //log.fine("done");
        }
    }
    return ret;
}
Also used : DataSet(pl.x3E.adInterface.DataSet) HashMap(java.util.HashMap) WindowTabData(pl.x3E.adInterface.WindowTabData) GridField(org.compiere.model.GridField) DataRow(pl.x3E.adInterface.DataRow) WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) DataField(pl.x3E.adInterface.DataField)

Aggregations

DataField (pl.x3E.adInterface.DataField)18 DataRow (pl.x3E.adInterface.DataRow)10 DataSet (pl.x3E.adInterface.DataSet)6 WindowTabData (pl.x3E.adInterface.WindowTabData)6 WindowTabDataDocument (pl.x3E.adInterface.WindowTabDataDocument)6 SQLException (java.sql.SQLException)5 Properties (java.util.Properties)5 XFireFault (org.codehaus.xfire.fault.XFireFault)5 MTable (org.compiere.model.MTable)5 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)5 GridField (org.compiere.model.GridField)4 PO (org.compiere.model.PO)4 POInfo (org.compiere.model.POInfo)4 ModelCRUD (pl.x3E.adInterface.ModelCRUD)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 QName (javax.xml.namespace.QName)3 Lookup (org.compiere.model.Lookup)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2