Search in sources :

Example 6 with WindowTabDataDocument

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

the class ModelADServiceImpl method queryData.

public WindowTabDataDocument queryData(ModelCRUDRequestDocument req) throws XFireFault {
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData resp = ret.addNewWindowTabData();
    ModelCRUD modelCRUD = req.getModelCRUDRequest().getModelCRUD();
    String serviceType = modelCRUD.getServiceType();
    /** 2014-12-04 Carlos Parada Add Support for Paginate Records */
    /** Current Page*/
    int currentPage = req.getModelCRUDRequest().getModelCRUD().getPageNo();
    /** Records per Page*/
    int m_RecByPage = MSysConfig.getIntValue("WS_RECORDS_BY_PAGE", 1);
    /** Quantity Pages*/
    int qtyPages = 0;
    log.info("Current Page " + currentPage);
    /** 2014-12-04 Carlos Parada */
    ADLoginRequest reqlogin = req.getModelCRUDRequest().getADLoginRequest();
    String err = modelLogin(reqlogin, webServiceName, "queryData", serviceType);
    if (err != null && err.length() > 0) {
        resp.setError(err);
        return ret;
    }
    // Validate parameters vs service type
    validateCRUD(modelCRUD);
    Properties ctx = m_cs.getM_ctx();
    String tableName = modelCRUD.getTableName();
    // get the PO for the tablename and record ID
    MTable table = MTable.get(ctx, tableName);
    if (table == null)
        throw new XFireFault("Web service type " + m_webservicetype.getValue() + ": table " + tableName + " not found", new QName("queryData"));
    int roleid = reqlogin.getRoleID();
    MRole role = new MRole(ctx, roleid, null);
    // 2014-12-04 Carlos Parada Replace ResultSet For Query  
    List<PO> records = null;
    String key = m_cs.getM_AD_User_ID() + "_" + serviceType;
    if (currentPage != 0)
        records = (List<PO>) s_cache.get(key);
    //"SELECT * FROM " + tableName;
    String sqlWhere = "";
    //sqlquery = role.addAccessSQL(sqlquery, tableName, true, true);
    for (DataField field : modelCRUD.getDataRow().getFieldList()) {
        if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) {
            sqlWhere += (sqlWhere.equals("") ? "" : " AND ") + field.getColumn() + "=?";
        } else {
            throw new XFireFault("Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " not allowed", new QName("queryData"));
        }
    }
    if (modelCRUD.getFilter() != null && modelCRUD.getFilter().length() > 0)
        sqlWhere += " AND " + modelCRUD.getFilter();
    POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
    int cnt = 0;
    try {
        if (records == null) {
            Query query = new Query(ctx, poinfo.getTableName(), sqlWhere, null);
            Object[] parameters = new Object[modelCRUD.getDataRow().getFieldList().size()];
            int p = 1;
            int i = 0;
            for (DataField field : modelCRUD.getDataRow().getFieldList()) {
                parameters[i] = field.getVal();
                i++;
            }
            if (parameters.length > 0)
                query.setParameters(parameters);
            records = query.setApplyAccessFilter(true).list();
        }
        // Angelo Dabala' (genied) must create just one DataSet, moved outside of the while loop
        DataSet ds = resp.addNewDataSet();
        // Set Quantity of Pages
        if (records.size() != 0)
            qtyPages = new BigDecimal(records.size()).divide(new BigDecimal(m_RecByPage)).setScale(0, BigDecimal.ROUND_UP).intValue();
        int begin = 0, end = 0;
        begin = currentPage * m_RecByPage;
        end = (((currentPage + 1) * m_RecByPage) > records.size() ? records.size() : ((currentPage + 1) * m_RecByPage));
        for (int j = begin; j < end; j++) {
            PO record = records.get(j);
            cnt++;
            DataRow dr = ds.addNewDataRow();
            for (int i = 0; i < poinfo.getColumnCount(); i++) {
                String columnName = poinfo.getColumnName(i);
                if (m_webservicetype.isOutputColumnNameAllowed(columnName)) {
                    DataField dfid = dr.addNewField();
                    dfid.setColumn(columnName);
                    dfid.setLval(record.get_ValueAsString(columnName));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    // ignore this exception
    }
    resp.setSuccess(true);
    resp.setRowCount(cnt);
    resp.setNumRows(cnt);
    resp.setTotalRows(cnt);
    resp.setStartRow(1);
    resp.setQtyPages(qtyPages);
    return ret;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) Query(org.compiere.model.Query) DataSet(pl.x3E.adInterface.DataSet) QName(javax.xml.namespace.QName) MRole(org.compiere.model.MRole) WindowTabData(pl.x3E.adInterface.WindowTabData) Properties(java.util.Properties) XFireFault(org.codehaus.xfire.fault.XFireFault) DataRow(pl.x3E.adInterface.DataRow) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException) POInfo(org.compiere.model.POInfo) WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) MTable(org.compiere.model.MTable) DataField(pl.x3E.adInterface.DataField) ModelCRUD(pl.x3E.adInterface.ModelCRUD) List(java.util.List) ModelGetList(pl.x3E.adInterface.ModelGetList) ArrayList(java.util.ArrayList) PO(org.compiere.model.PO)

Example 7 with WindowTabDataDocument

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

the class ADServiceImpl method updateDataRow.

public WindowTabDataDocument updateDataRow(int WindowNo, int TabNo, int RowNo, WindowTabDataDocument data) throws XFireFault {
    authenticate(webServiceName, "updateDataRow");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    DataRow ret_dr = ds.addNewDataRow();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, true, TabNo, true, RowNo);
    if (ws != null) {
        DataRow[] dr = data.getWindowTabData().getDataSet().getDataRowArray();
        if (dr.length == 1) {
            DataRow dr0 = dr[0];
            boolean err = updateFields(ws, dr0);
            if (ws.ads.m_is_error) {
                wd.setError(ws.ads.m_error_message);
                wd.setErrorInfo(ws.ads.m_error_info);
            }
            wd.setStatus(ws.ads.m_status_data);
            wd.setStatusError(ws.ads.m_is_status_error);
            //ws.curTab.dataRefresh();
            fillDataRow(ret_dr, ws, true, 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 8 with WindowTabDataDocument

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

the class ADServiceImpl method deleteDataRow.

public WindowTabDataDocument deleteDataRow(int WindowNo, int TabNo, int RowNo) throws XFireFault {
    authenticate(webServiceName, "deleteDataRow");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, false, 0, true, RowNo);
    if (ws != null) {
        wd.setSuccess(ws.curTab.dataDelete());
        DataRow ret_dr = ds.addNewDataRow();
        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);
        }
        wd.setStatus(ws.ads.m_status_data);
        wd.setStatusError(ws.ads.m_is_status_error);
        updateRecIDMap(ws);
    }
    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 9 with WindowTabDataDocument

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

the class ADServiceImpl method ignoreDataRow.

public WindowTabDataDocument ignoreDataRow(int WindowNo, int TabNo, int RowNo) throws XFireFault {
    authenticate(webServiceName, "ignoreDataRow");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, false, 0, true, RowNo);
    if (ws != null) {
        ws.curTab.dataIgnore();
        wd.setSuccess(true);
        DataRow ret_dr = ds.addNewDataRow();
        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);
        }
        wd.setStatus(ws.ads.m_status_data);
        wd.setStatusError(ws.ads.m_is_status_error);
        updateRecIDMap(ws);
    }
    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 10 with WindowTabDataDocument

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

the class ADServiceImpl method refreshDataRow.

public WindowTabDataDocument refreshDataRow(int WindowNo, int TabNo, int RowNo) throws XFireFault {
    authenticate(webServiceName, "refreshDataRow");
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, false, 0, true, RowNo);
    if (ws != null) {
        ws.curTab.dataRefresh();
        wd.setSuccess(true);
        DataRow ret_dr = ds.addNewDataRow();
        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);
        }
        wd.setStatus(ws.ads.m_status_data);
        wd.setStatusError(ws.ads.m_is_status_error);
    }
    return ret;
}
Also used : WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) DataSet(pl.x3E.adInterface.DataSet) WindowTabData(pl.x3E.adInterface.WindowTabData) DataRow(pl.x3E.adInterface.DataRow)

Aggregations

DataSet (pl.x3E.adInterface.DataSet)13 WindowTabData (pl.x3E.adInterface.WindowTabData)13 WindowTabDataDocument (pl.x3E.adInterface.WindowTabDataDocument)13 DataRow (pl.x3E.adInterface.DataRow)12 DataField (pl.x3E.adInterface.DataField)6 Properties (java.util.Properties)3 QName (javax.xml.namespace.QName)3 XFireFault (org.codehaus.xfire.fault.XFireFault)3 GridField (org.compiere.model.GridField)3 MTable (org.compiere.model.MTable)3 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)3 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 MLookup (org.compiere.model.MLookup)2 MRole (org.compiere.model.MRole)2 PO (org.compiere.model.PO)2 POInfo (org.compiere.model.POInfo)2 ModelCRUD (pl.x3E.adInterface.ModelCRUD)2 ModelGetList (pl.x3E.adInterface.ModelGetList)2 BigDecimal (java.math.BigDecimal)1