BF [1985481] - Processed documents can be edited

- Optimize - just one select to check updated and processed
- Fix wrong management of message
This commit is contained in:
Carlos Ruiz 2009-05-08 19:32:49 +00:00
parent 301549146c
commit d39d2a0869
3 changed files with 62 additions and 14 deletions

View File

@ -3153,23 +3153,71 @@ public class GridTable extends AbstractTableModel
// compare Updated, IsProcessed
if (getKeyID(row) > 0) {
int colUpdated = findColumn("Updated");
if (colUpdated > 0) {
Timestamp memUpdated = (Timestamp) getValueAt(row, colUpdated);
Timestamp dbUpdated = DB.getSQLValueTSEx(null, "SELECT Updated FROM " + m_tableName + " WHERE " + m_tableName + "_ID=?" , getKeyID(row));
int colProcessed = findColumn("Processed");
boolean hasUpdated = (colUpdated > 0);
boolean hasProcessed = (colProcessed > 0);
String columns = null;
if (hasUpdated && hasProcessed) {
columns = new String("Updated, Processed");
} else if (hasUpdated) {
columns = new String("Updated");
} else if (hasProcessed) {
columns = new String("Processed");
} else {
// no columns updated or processed to commpare
return false;
}
Timestamp dbUpdated = null;
String dbProcessedS = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT " + columns + " FROM " + m_tableName + " WHERE " + m_tableName + "_ID=?";
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getKeyID(row));
rs = pstmt.executeQuery();
if (rs.next()) {
int idx = 1;
if (hasUpdated)
dbUpdated = rs.getTimestamp(idx++);
if (hasProcessed)
dbProcessedS = rs.getString(idx++);
}
else
log.info("No Value " + sql);
}
catch (SQLException e)
{
throw new DBException(e, sql);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
if (hasUpdated) {
Timestamp memUpdated = null;
memUpdated = (Timestamp) getValueAt(row, colUpdated);
if (! memUpdated.equals(dbUpdated))
return true;
}
int colProcessed = findColumn("Processed");
if (colProcessed > 0) {
Boolean memProcessed = (Boolean) getValueAt(row, colProcessed);
String dbProcessedS = DB.getSQLValueStringEx(null, "SELECT Processed FROM " + m_tableName + " WHERE " + m_tableName + "_ID=?" , getKeyID(row));
}
if (hasProcessed) {
Boolean memProcessed = null;
memProcessed = (Boolean) getValueAt(row, colProcessed);
Boolean dbProcessed = Boolean.TRUE;
if (! dbProcessedS.equals("Y"))
dbProcessed = Boolean.FALSE;
if (! memProcessed.equals(dbProcessed))
return true;
}
}
}
// @TODO: configurable aggressive - compare each column with the DB

View File

@ -1871,7 +1871,7 @@ public final class APanel extends CPanel
private void showLastError() {
String msg = CLogger.retrieveErrorString(null);
if (msg != null)
ADialog.error(m_curWindowNo, this, msg);
ADialog.error(m_curWindowNo, this, null, msg);
else
ADialog.error(m_curWindowNo, this, "SaveIgnored");
setStatusLine(Msg.getMsg(m_ctx, "SaveIgnored"), true);
@ -2266,7 +2266,7 @@ public final class APanel extends CPanel
if (m_curTab.hasChangedCurrentTabAndParents()) {
String msg = CLogger.retrieveErrorString("Please ReQuery Window");
ADialog.error(m_curWindowNo, this, msg);
ADialog.error(m_curWindowNo, this, null, msg);
return;
}

View File

@ -1222,7 +1222,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
private void showLastError() {
String msg = CLogger.retrieveErrorString(null);
if (msg != null)
FDialog.error(curWindowNo, parent, msg);
FDialog.error(curWindowNo, parent, null, msg);
else
FDialog.error(curWindowNo, parent, "SaveIgnored");
//actual error will prompt in the dataStatusChanged event
@ -1606,7 +1606,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
if (curTab.hasChangedCurrentTabAndParents()) {
String msg = CLogger.retrieveErrorString("Please ReQuery Window");
FDialog.error(curWindowNo, parent, msg);
FDialog.error(curWindowNo, parent, null, msg);
return;
}