[ 2195894 ] Improve performance in PO engine Is ChangeLog

http://sourceforge.net/tracker/index.php?func=detail&aid=2195894&group_id=176962&atid=879335
This commit is contained in:
vpj-cd 2008-10-26 01:24:38 +00:00
parent 1180f4b9f4
commit 104e31deb8
2 changed files with 54 additions and 33 deletions

View File

@ -71,6 +71,9 @@ import org.w3c.dom.Element;
* <li>FR [ 1720995 ] Add PO.saveEx() and PO.deleteEx() methods
* <li>BF [ 1990856 ] PO.set_Value* : truncate string more than needed
* <li>FR [ 2042844 ] PO.get_Translation improvements
* @author Victor Perez, e-Evolution SC
* <li>[ 2195894 ] Improve performance in PO engine
* <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195894&group_id=176962&atid=879335
*/
public abstract class PO
implements Serializable, Comparator, Evaluatee
@ -2750,42 +2753,45 @@ public abstract class PO
{
if (success)
{
// Change Log
MSession session = MSession.get (p_ctx, false);
if (session == null)
log.fine("No Session found");
else if (m_IDs.length == 1)
if( p_info.isChangeLog())
{
int AD_ChangeLog_ID = 0;
int size = get_ColumnCount();
for (int i = 0; i < size; i++)
// Change Log
MSession session = MSession.get (p_ctx, false);
if (session == null)
log.fine("No Session found");
else if (m_IDs.length == 1)
{
Object value = m_oldValues[i];
if (value != null
&& p_info.isAllowLogging(i) // logging allowed
&& !p_info.isEncrypted(i) // not encrypted
&& !p_info.isVirtualColumn(i) // no virtual column
&& !"Password".equals(p_info.getColumnName(i))
)
int AD_ChangeLog_ID = 0;
int size = get_ColumnCount();
for (int i = 0; i < size; i++)
{
// change log on delete
MChangeLog cLog = session.changeLog (
m_trxName != null ? m_trxName : localTrxName, AD_ChangeLog_ID,
AD_Table_ID, p_info.getColumn(i).AD_Column_ID,
Record_ID, getAD_Client_ID(), getAD_Org_ID(), value, null, MChangeLog.EVENTCHANGELOG_Delete);
if (cLog != null)
AD_ChangeLog_ID = cLog.getAD_ChangeLog_ID();
}
} // for all fields
Object value = m_oldValues[i];
if (value != null
&& p_info.isAllowLogging(i) // logging allowed
&& !p_info.isEncrypted(i) // not encrypted
&& !p_info.isVirtualColumn(i) // no virtual column
&& !"Password".equals(p_info.getColumnName(i))
)
{
// change log on delete
MChangeLog cLog = session.changeLog (
m_trxName != null ? m_trxName : localTrxName, AD_ChangeLog_ID,
AD_Table_ID, p_info.getColumn(i).AD_Column_ID,
Record_ID, getAD_Client_ID(), getAD_Org_ID(), value, null, MChangeLog.EVENTCHANGELOG_Delete);
if (cLog != null)
AD_ChangeLog_ID = cLog.getAD_ChangeLog_ID();
}
} // for all fields
}
// Housekeeping
m_IDs[0] = I_ZERO;
if (m_trxName == null)
log.fine("complete");
else
log.fine("[" + m_trxName + "] - complete");
m_attachment = null;
}
// Housekeeping
m_IDs[0] = I_ZERO;
if (m_trxName == null)
log.fine("complete");
else
log.fine("[" + m_trxName + "] - complete");
m_attachment = null;
}
else
{

View File

@ -37,6 +37,9 @@ import org.compiere.util.Env;
*
* @author Jorg Janke
* @version $Id: POInfo.java,v 1.2 2006/07/30 00:58:37 jjanke Exp $
* @author Victor Perez, e-Evolution SC
* <li>[ 2195894 ] Improve performance in PO engine
* <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195894&group_id=176962&atid=879335
*/
public class POInfo implements Serializable
{
@ -118,6 +121,8 @@ public class POInfo implements Serializable
private POInfoColumn[] m_columns = null;
/** Table has Key Column */
private boolean m_hasKeyColumn = false;
/** Table needs keep log*/
private boolean m_IsChangeLog = false;
/**
@ -136,7 +141,7 @@ public class POInfo implements Serializable
+ "c.AD_Reference_Value_ID, vr.Code, " // 12..13
+ "c.FieldLength, c.ValueMin, c.ValueMax, c.IsTranslated, " // 14..17
+ "t.AccessLevel, c.ColumnSQL, c.IsEncrypted, " // 18..20
+ "c.IsAllowLogging "); // 21
+ "c.IsAllowLogging,t.IsChangeLog "); // 21
sql.append("FROM AD_Table t"
+ " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID)"
+ " LEFT OUTER JOIN AD_Val_Rule vr ON (c.AD_Val_Rule_ID=vr.AD_Val_Rule_ID)"
@ -184,6 +189,7 @@ public class POInfo implements Serializable
String ColumnSQL = rs.getString(19);
boolean IsEncrypted = "Y".equals(rs.getString(20));
boolean IsAllowLogging = "Y".equals(rs.getString(21));
m_IsChangeLog="Y".equals(rs.getString(22));
POInfoColumn col = new POInfoColumn (
AD_Column_ID, ColumnName, ColumnSQL, AD_Reference_ID,
@ -724,4 +730,13 @@ public class POInfo implements Serializable
return sql;
}
/**
*
* @return if table save log
*/
public boolean isChangeLog()
{
return m_IsChangeLog;
}
} // POInfo