Search in sources :

Example 1 with DataRow

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

the class ADServiceImpl method getWindowTabData.

public WindowTabDataDocument getWindowTabData(WindowTabDataReqDocument reqd) throws XFireFault {
    authenticate(webServiceName, "getWindowTabData");
    WindowTabDataReq req = reqd.getWindowTabDataReq();
    WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
    WindowTabData wd = ret.addNewWindowTabData();
    DataSet ds = wd.addNewDataSet();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, req.getWindowNo(), false, 0, false, 0);
    if (ws == null) {
        GridWindowVO wo = getWindowVO(req.getWindowNo(), req.getADWindowID(), req.getADMenuID());
        ws = new WWindowStatus(wo);
        WindowStatusMap.put(new Integer(req.getWindowNo()), ws);
        //!!!!!!!!!!
        ws.curTab.query(ws.mWindow.isTransaction());
        ws.curTab.navigate(0);
        ws.curTab.setSingleRow(true);
    }
    if (ws.curTab.getTabNo() != req.getPrevTabNo()) {
        ws.curTab.removeDataStatusListener(ws.ads);
        ws.curTab = ws.mWindow.getTab(req.getPrevTabNo());
        // false
        ws.curTab.query(ws.mWindow.isTransaction());
        ws.curTab.navigate(0);
        ws.updateRecIDMap();
    }
    /*
    	if (ws.curTab.getCurrentRow() != req.getPrevRecNo())  
    	{
    		if (req.getPrevRecNo() >=0)
    			ws.curTab.navigate( req.getPrevRecNo() );     		
    	}
    	*/
    // we assume that it RecordID
    int prevRecNo = ws.getRowNoFromRecordID(req.getPrevRecNo());
    if (ws.curTab.getCurrentRow() != prevRecNo) {
        if (prevRecNo >= 0)
            ws.curTab.navigate(prevRecNo);
    }
    WWindowStatus.changeTabIfNeeded(ws, req.getTabNo());
    if (req.getGetData()) {
        if (req.getFromZoom()) {
            WWindowStatus ws2 = WWindowStatus.get(WindowStatusMap, req.getFromZoomWindowID(), true, req.getFromZoomTabID(), true, req.getFromZoomRowID());
            System.out.println(ws2.curTab.getTableName());
            GridField field = ws2.curTab.getField(req.getFromZoomColumnName());
            ws2 = null;
            if (field == null)
                return null;
            MLookup lookup = (MLookup) field.getLookup();
            if (lookup == null)
                return null;
            //
            MQuery zoomQuery = lookup.getZoomQuery();
            Object value = field.getValue();
            if (value == null) {
                value = req.getFromZoomColumnValue();
            }
            //	If not already exist or exact value
            if (zoomQuery == null || value != null) {
                //	ColumnName might be changed in GridTab.validateQuery
                zoomQuery = new MQuery();
                zoomQuery.addRestriction(req.getFromZoomColumnName(), MQuery.EQUAL, value);
            }
            ws.curTab.setQuery(zoomQuery);
            //ws.curTab.query(ws.mWindow.isTransaction());
            // ADEMPIERE/COMPIERE
            // adempiere
            ws.curTab.query(false, 0, 0);
        //ws.curTab.query(false, 0); // compiere
        } else {
            DataRow findDR = req.getFindCriteria();
            MQuery currentQuery = ws.curTab.getQuery();
            MQuery newQuery = createQuery(ws.curTab.getTableName(), findDR);
            if (findDR.getFieldArray().length > 0) {
                //(!currentQuery.getWhereClause().equals( newQuery.getWhereClause() )) { // change the query for zak�adki
                ws.curTab.setQuery(newQuery);
                //ws.curTab.query(ws.mWindow.isTransaction());
                //ADEMPIERE/COMPIERE
                // adempiere
                ws.curTab.query(false, 0, 0);
            //ws.curTab.query(false, 0); // compiere
            }
        }
        int rc = 0;
        if (req.getRowCount() > 0)
            rc = req.getRowCount();
        else
            rc = ws.curTab.getRowCount();
        int initRowNo = 0;
        if (req.getRowStart() > 0)
            initRowNo = req.getRowStart();
        //ok
        int lastRow = Math.min(rc, initRowNo + MAX_ROWS);
        //initRowNo + 5; // only for testing
        wd.setNumRows(lastRow);
        //lastRow += initRowNo;
        // ok
        wd.setTotalRows(ws.curTab.getRowCount());
        //wd.setTotalRows( 5 ); // only for testing
        wd.setStartRow(initRowNo);
        Map<Integer, Integer> RecordIDMap = ws.getRecordIDMap();
        try {
            RecordIDMap.clear();
            for (int lineNo = initRowNo; lineNo < lastRow; lineNo++) {
                ws.curTab.navigate(lineNo);
                int recID = ws.curTab.getRecord_ID();
                RecordIDMap.put(recID, lineNo);
                DataRow dr = ds.addNewDataRow();
                //System.out.println("row "+lineNo);
                fillDataRow(dr, ws, false, false);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        ;
        if (lastRow <= ws.curTab.getRowCount()) {
            //last row
            ws.updateRecIDMap();
        }
    }
    return ret;
}
Also used : DataSet(pl.x3E.adInterface.DataSet) MLookup(org.compiere.model.MLookup) WindowTabData(pl.x3E.adInterface.WindowTabData) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) DataRow(pl.x3E.adInterface.DataRow) TransformerException(javax.xml.transform.TransformerException) WindowTabDataDocument(pl.x3E.adInterface.WindowTabDataDocument) WindowTabDataReq(pl.x3E.adInterface.WindowTabDataReq) GridWindowVO(org.compiere.model.GridWindowVO)

Example 2 with DataRow

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

the class ADLookup method getResult.

private DataSet getResult(com._3e.ADInterface.ADInfo info, DataSet ds, int count, String mode) {
    if ("count".equals(mode) && count > 1) {
        DataRow dr = ds.addNewDataRow();
        DataField df = dr.addNewField();
        df.setVal("" + count);
        df.setColumn("__count");
        df.setType("string");
        return ds;
    }
    try {
        PreparedStatement pstmt = DB.prepareStatement(info.getSQL());
        info.setParameters(pstmt, false);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            DataRow dr = ds.addNewDataRow();
            DataField df = null;
            //DataField df = dr.addNewField();
            DataRow cols = info.getColumns();
            for (int i = 0; i < cols.sizeOfFieldArray(); i++) {
                df = dr.addNewField();
                DataField f = cols.getFieldArray(i);
                //if ("string".equalsIgnoreCase(f.getType())) {
                {
                    df.setVal(rs.getString(i + 1));
                    df.setColumn(f.getColumn());
                    df.setType(f.getType());
                    df.setLval(f.getLval());
                }
            }
        }
        rs.close();
        pstmt.close();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    return ds;
}
Also used : DataField(pl.x3E.adInterface.DataField) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) DataRow(pl.x3E.adInterface.DataRow) SQLException(java.sql.SQLException)

Example 3 with DataRow

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

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

the class ADServiceImpl method getDataRow.

public WindowTabDataDocument getDataRow(int WindowNo, int TabNo, int RowNo) throws XFireFault {
    authenticate(webServiceName, "getDataRow");
    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();
        fillDataRow(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)

Example 5 with DataRow

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

the class ModelADServiceImpl method updateData.

public StandardResponseDocument updateData(ModelCRUDRequestDocument req) throws XFireFault {
    StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
    StandardResponse resp = ret.addNewStandardResponse();
    ModelCRUD modelCRUD = req.getModelCRUDRequest().getModelCRUD();
    String serviceType = modelCRUD.getServiceType();
    ADLoginRequest reqlogin = req.getModelCRUDRequest().getADLoginRequest();
    String err = modelLogin(reqlogin, webServiceName, "updateData", serviceType);
    if (err != null && err.length() > 0) {
        resp.setError(err);
        resp.setIsError(true);
        return ret;
    }
    // Validate parameters vs service type
    validateCRUD(modelCRUD);
    String tableName = modelCRUD.getTableName();
    int recordID = modelCRUD.getRecordID();
    resp.setRecordID(recordID);
    Properties ctx = m_cs.getM_ctx();
    // start a trx
    String trxName = Trx.createTrxName("ws_modelUpdateData");
    Trx trx = Trx.get(trxName, false);
    // get the PO for the tablename and record ID
    MTable table = MTable.get(ctx, tableName);
    if (table == null)
        return rollbackAndSetError(trx, resp, ret, true, "No table " + tableName);
    PO po = table.getPO(recordID, trxName);
    if (po == null)
        return rollbackAndSetError(trx, resp, ret, true, "No Record " + recordID + " in " + tableName);
    POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
    DataRow dr = modelCRUD.getDataRow();
    for (DataField field : dr.getFieldList()) {
        // TODO: Implement lookup
        if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) {
            int idxcol = po.get_ColumnIndex(field.getColumn());
            if (idxcol < 0) {
                // The column doesn't exist - it must exist as it's defined in security
                return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " does not exist");
            } else {
                try {
                    setValueAccordingToClass(po, poinfo, field, idxcol);
                } catch (XFireFault e) {
                    log.log(Level.WARNING, "Error setting value", e);
                    return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " value could not be set: " + e.getLocalizedMessage());
                }
            }
        } else {
            return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " not allowed");
        }
    }
    if (!po.save())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot save record in " + tableName + ": " + CLogger.retrieveErrorString("no log message"));
    // close the trx
    if (!trx.commit())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot commit transaction after delete record " + recordID + " in " + tableName);
    trx.close();
    return ret;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) StandardResponse(pl.x3E.adInterface.StandardResponse) Properties(java.util.Properties) XFireFault(org.codehaus.xfire.fault.XFireFault) DataRow(pl.x3E.adInterface.DataRow) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument) POInfo(org.compiere.model.POInfo) MTable(org.compiere.model.MTable) DataField(pl.x3E.adInterface.DataField) ModelCRUD(pl.x3E.adInterface.ModelCRUD) Trx(org.compiere.util.Trx) PO(org.compiere.model.PO)

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