void updateDs(DSDataSourceProxy out) throws DataStoreException, java.sql.SQLException, Exception { int rowNo = -1; DataStoreRow row = new DataStoreRow(this, null, _desc); // do deletes for (rowNo = 0; rowNo < _deletedRows.size(); rowNo++) { row.setDSDataRow((DSDataRow) _deletedRows.elementAt(rowNo)); ((DSDataRow) _deletedRows.elementAt(rowNo)).setProxyRow(rowNo); if (!out.deleteRow(this, row)) throw new Exception("$Delete$"); } // do the updates for (rowNo = 0; rowNo < _rows.size(); rowNo++) { row.setDSDataRow((DSDataRow) _rows.elementAt(rowNo)); ((DSDataRow) _rows.elementAt(rowNo)).setProxyRow(rowNo); if (row.getDSDataRow().getRowStatus() == STATUS_MODIFIED) { if (!out.updateRow(this, row)) throw new Exception("$Update$"); } } // do the inserts for (rowNo = 0; rowNo < _rows.size(); rowNo++) { row.setDSDataRow((DSDataRow) _rows.elementAt(rowNo)); ((DSDataRow) _rows.elementAt(rowNo)).setProxyRow(rowNo); if (row.getDSDataRow().getRowStatus() == STATUS_NEW_MODIFIED) { if (!out.insertRow(this, row)) throw new Exception("$Insert$"); } } }
/** * The run method for the thread that retrieves the data from the database. This method should not * be called directly. Instead use the retrieve method. */ public void run() { try { DataStoreRow row = new DataStoreRow(this, new DSDataRow(_desc), _desc); while (_dataSource.retrieveRow(this, row)) { _rows.addElement(row.getDSDataRow()); if (_threaded) notifyListeners(ModelChangedEvent.TYPE_ROW_INSERTED_OR_DELETED); if (!_retrieveInProgress || (_maxRows > -1 && _rows.size() >= _maxRows)) { _cancelInProgress = true; _retrieveInProgress = false; interruptWaitingRetrieveThreads(); break; } if (_threaded) Thread.yield(); row.setDSDataRow(new DSDataRow(_desc)); } _dataSource.postRetrieve(this); _cancelInProgress = false; interruptWaitingCancelThreads(); notifyListeners(ModelChangedEvent.TYPE_DATA_LOADED); } catch (Exception e) { System.out.println("DataStore.run:" + e); _cancelInProgress = false; interruptWaitingCancelThreads(); } _retrieveInProgress = false; interruptWaitingRetrieveThreads(); _cancelInProgress = false; interruptWaitingCancelThreads(); }