IDEMPIERE-1006 Improve transaction and busy dialog for merge window
This commit is contained in:
parent
829583bd28
commit
fb4dfe08bd
|
|
@ -77,7 +77,6 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
|
||||||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||||
private String m_msg;
|
private String m_msg;
|
||||||
private boolean m_success;
|
private boolean m_success;
|
||||||
private BusyDialog progressWindow;
|
|
||||||
|
|
||||||
private MergeRunnable runnable;
|
private MergeRunnable runnable;
|
||||||
|
|
||||||
|
|
@ -255,10 +254,7 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
|
||||||
{
|
{
|
||||||
updateDeleteTable(columnNameRef);
|
updateDeleteTable(columnNameRef);
|
||||||
|
|
||||||
progressWindow = new BusyDialog();
|
Clients.showBusy("");
|
||||||
progressWindow.setPage(form.getPage());
|
|
||||||
progressWindow.doHighlighted();
|
|
||||||
|
|
||||||
runnable = new MergeRunnable(columnNameRef, fromIdRef, toIdRef);
|
runnable = new MergeRunnable(columnNameRef, fromIdRef, toIdRef);
|
||||||
Clients.response(new AuEcho(form, "runProcess", null));
|
Clients.response(new AuEcho(form, "runProcess", null));
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +275,8 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
m_success = merge (columnName, from_ID, to_ID);
|
m_success = merge (columnName, from_ID, to_ID);
|
||||||
postMerge(columnName, to_ID);
|
if (m_success)
|
||||||
|
postMerge(columnName, to_ID);
|
||||||
} finally{
|
} finally{
|
||||||
Clients.clearBusy();
|
Clients.clearBusy();
|
||||||
Clients.response(new AuEcho(form, "onAfterProcess", null));
|
Clients.response(new AuEcho(form, "onAfterProcess", null));
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ import org.compiere.util.Trx;
|
||||||
|
|
||||||
public class Merge
|
public class Merge
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static final long serialVersionUID = 149783846292562740L;
|
|
||||||
/** Window No */
|
/** Window No */
|
||||||
public int m_WindowNo = 0;
|
public int m_WindowNo = 0;
|
||||||
/** Total Count */
|
/** Total Count */
|
||||||
|
|
@ -115,7 +113,6 @@ public class Merge
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
m_trx = Trx.get(Trx.createTrxName("merge"), true);
|
m_trx = Trx.get(Trx.createTrxName("merge"), true);
|
||||||
//
|
//
|
||||||
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
|
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
|
||||||
|
|
@ -142,9 +139,6 @@ public class Merge
|
||||||
{
|
{
|
||||||
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
sql = "DELETE " + TableName + " WHERE " + ColumnName + "=" + from_ID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( DB.executeUpdate(sql, m_trx.getTrxName()) < 0 )
|
if ( DB.executeUpdate(sql, m_trx.getTrxName()) < 0 )
|
||||||
{
|
{
|
||||||
m_errorLog.append(Env.NL).append("DELETE ").append(TableName)
|
m_errorLog.append(Env.NL).append("DELETE ").append(TableName)
|
||||||
|
|
@ -156,14 +150,6 @@ public class Merge
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
if ( success )
|
|
||||||
success = m_trx.commit();
|
|
||||||
else
|
|
||||||
m_trx.rollback();
|
|
||||||
|
|
||||||
m_trx.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -172,6 +158,14 @@ public class Merge
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
if (m_trx != null) {
|
||||||
|
if (success)
|
||||||
|
success = m_trx.commit();
|
||||||
|
else
|
||||||
|
m_trx.rollback();
|
||||||
|
m_trx.close();
|
||||||
|
}
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null;
|
rs = null;
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
|
|
@ -214,11 +208,8 @@ public class Merge
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = DB.executeUpdate(sql, m_trx.getTrxName());
|
int count = DB.executeUpdate(sql, m_trx.getTrxName());
|
||||||
|
if (count < 0)
|
||||||
|
|
||||||
if ( count < 0 )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
count = -1;
|
count = -1;
|
||||||
m_errorLog.append(Env.NL)
|
m_errorLog.append(Env.NL)
|
||||||
.append(delete ? "DELETE " : "UPDATE ")
|
.append(delete ? "DELETE " : "UPDATE ")
|
||||||
|
|
@ -226,12 +217,10 @@ public class Merge
|
||||||
.append(" - ").append(sql);
|
.append(" - ").append(sql);
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config(m_errorLog.toString());
|
if (log.isLoggable(Level.CONFIG)) log.config(m_errorLog.toString());
|
||||||
m_trx.rollback();
|
m_trx.rollback();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(count
|
if (log.isLoggable(Level.FINE)) log.fine(count
|
||||||
+ (delete ? " -Delete- " : " -Update- ") + TableName);
|
+ (delete ? " -Delete- " : " -Update- ") + TableName);
|
||||||
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
} // mergeTable
|
} // mergeTable
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue