Search in sources :

Example 1 with WindowTabDataReq

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

Aggregations

TransformerException (javax.xml.transform.TransformerException)1 GridField (org.compiere.model.GridField)1 GridWindowVO (org.compiere.model.GridWindowVO)1 MLookup (org.compiere.model.MLookup)1 MQuery (org.compiere.model.MQuery)1 DataRow (pl.x3E.adInterface.DataRow)1 DataSet (pl.x3E.adInterface.DataSet)1 WindowTabData (pl.x3E.adInterface.WindowTabData)1 WindowTabDataDocument (pl.x3E.adInterface.WindowTabDataDocument)1 WindowTabDataReq (pl.x3E.adInterface.WindowTabDataReq)1