Search in sources :

Example 16 with DataRow

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

the class ADServiceImpl method addNewDataRow.

//  getFieldValue
public WindowTabDataDocument addNewDataRow(int WindowNo, int TabNo) throws XFireFault {
    authenticate(webServiceName, "addNewDataRow");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, true, TabNo, false, 0);
    if (ws != null) {
        if (ws.curTab.dataNew(false)) {
            //ws.curTab.setSingleRow(true);
            wd.setSuccess(true);
            DataRow dr = ds.addNewDataRow();
            fillDataRow(dr, ws, true, false);
            updateRecIDMap(ws);
            System.out.println("New Row no = " + ws.curTab.getCurrentRow());
        } else {
            ws.curTab.dataIgnore();
            wd.setSuccess(false);
        }
    }
    return ret;
}
Also used : WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) DataSet(pl.x3E.adInterface.DataSet) WindowTabData(pl.x3E.adInterface.WindowTabData) DataRow(pl.x3E.adInterface.DataRow)

Example 17 with DataRow

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

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