Implement [ 1810133 ] Add logging policy on column level

This commit is contained in:
Carlos Ruiz 2008-07-29 05:27:49 +00:00
parent 6aa7c87454
commit d823361719
10 changed files with 5826 additions and 5694 deletions

View File

@ -509,4 +509,13 @@ public interface I_AD_Column
* Version of the table definition
*/
public BigDecimal getVersion();
/** Column name IsAllowLogging */
public static final String COLUMNNAME_isAllowLogging = "IsAllowLogging";
/** Get IsAllowLogging .
* Determines, if a column must be recorded into the change log
*/
public boolean IsAllowLogging() ;
}

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
@ -16,12 +16,15 @@
*****************************************************************************/
package org.compiere.model;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.*;
import org.compiere.util.*;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
/**
* Change Log Model
@ -31,6 +34,12 @@ import org.compiere.util.*;
*/
public class MChangeLog extends X_AD_ChangeLog
{
/**
*
*/
private static final long serialVersionUID = -7156972859181201446L;
/**
* Do we track changes for this table
* @param AD_Table_ID table

View File

@ -491,6 +491,14 @@ public class MColumn extends X_AD_Column
return sb.toString ();
} // toString
/** Get IsAllowLogging .
* Determines, if a column must be recorded into the change log
*/
public boolean IsAllowLogging() {
return super.IsAllowLogging();
}
//begin vpj-cd e-evolution
/**
* get Column ID

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
@ -16,13 +16,17 @@
*****************************************************************************/
package org.compiere.model;
import java.net.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.Adempiere;
import org.compiere.util.*;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.TimeUtil;
/**
* Session Model.
@ -37,6 +41,12 @@ import org.compiere.util.*;
*/
public class MSession extends X_AD_Session
{
/**
*
*/
private static final long serialVersionUID = 480745219310430126L;
/**
* Get existing or create local session
* @param ctx context
@ -269,11 +279,6 @@ public class MSession extends X_AD_Session
if (OldValue != null && NewValue != null && OldValue.equals(NewValue))
return null;
// No Log
if (AD_Column_ID == 6652
|| AD_Column_ID == 6653) // AD_Process.Statistics_
return null;
// Role Logging
MRole role = MRole.getDefault(getCtx(), false);
// Do we need to log
@ -288,8 +293,6 @@ public class MSession extends X_AD_Session
+ ", AD_Session_ID=" + getAD_Session_ID()
+ ", AD_Table_ID=" + AD_Table_ID + ", AD_Column_ID=" + AD_Column_ID
+ ": " + OldValue + " -> " + NewValue);
boolean success = false;
try
{
MChangeLog cl = new MChangeLog(getCtx(),

View File

@ -74,6 +74,11 @@ import org.w3c.dom.Element;
public abstract class PO
implements Serializable, Comparator, Evaluatee
{
/**
*
*/
private static final long serialVersionUID = -7147383015345754638L;
/**
* Set Document Value Workflow Manager
* @param docWFMgr mgr
@ -2241,6 +2246,7 @@ public abstract class PO
// Change Log - Only
if (session != null
&& m_IDs.length == 1
&& p_info.isAllowLogging(i) // logging allowed
&& !p_info.isEncrypted(i) // not encrypted
&& !p_info.isVirtualColumn(i) // no virtual column
&& !"Password".equals(columnName)
@ -2466,6 +2472,7 @@ public abstract class PO
String insertLog = MSysConfig.getValue("SYSTEM_INSERT_CHANGELOG", "Y", getAD_Client_ID());
if ( session != null
&& m_IDs.length == 1
&& p_info.isAllowLogging(i) // logging allowed
&& !p_info.isEncrypted(i) // not encrypted
&& !p_info.isVirtualColumn(i) // no virtual column
&& !"Password".equals(columnName)
@ -2740,6 +2747,7 @@ public abstract class PO
{
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))

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
@ -135,7 +135,8 @@ public class POInfo implements Serializable
+ "c.IsKey,c.IsParent, " // 10..11
+ "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
+ "t.AccessLevel, c.ColumnSQL, c.IsEncrypted, " // 18..20
+ "c.IsAllowLogging "); // 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)"
@ -182,6 +183,7 @@ public class POInfo implements Serializable
m_AccessLevel = rs.getString(18);
String ColumnSQL = rs.getString(19);
boolean IsEncrypted = "Y".equals(rs.getString(20));
boolean IsAllowLogging = "Y".equals(rs.getString(21));
POInfoColumn col = new POInfoColumn (
AD_Column_ID, ColumnName, ColumnSQL, AD_Reference_ID,
@ -190,7 +192,8 @@ public class POInfo implements Serializable
IsKey, IsParent,
AD_Reference_Value_ID, ValidationCode,
FieldLength, ValueMin, ValueMax,
IsTranslated, IsEncrypted);
IsTranslated, IsEncrypted,
IsAllowLogging);
list.add(col);
}
}
@ -397,7 +400,7 @@ public class POInfo implements Serializable
* @param index index
* @return Class
*/
public Class getColumnClass (int index)
public Class<?> getColumnClass (int index)
{
if (index < 0 || index >= m_columns.length)
return null;
@ -577,6 +580,19 @@ public class POInfo implements Serializable
return m_columns[index].IsEncrypted;
} // isEncrypted
/**
* Is allowed logging on this column
*
* @param index
* index
* @return true if column is allowed to be logged
*/
public boolean isAllowLogging(int index) {
if (index < 0 || index >= m_columns.length)
return false;
return m_columns[index].IsAllowLogging;
} // isAllowLogging
/**
* Get Column FieldLength
* @param index index

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
@ -16,10 +16,11 @@
*****************************************************************************/
package org.compiere.model;
import java.io.*;
import java.math.*;
import java.util.logging.*;
import org.compiere.util.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.logging.Level;
import org.compiere.util.CLogger;
/**
* PO Info Column Info Value Object
@ -35,7 +36,7 @@ public class POInfoColumn implements Serializable
/**
* Constructor
* @param ad_Column_ID Column ID
* @param columnName Dolumn name
* @param columnName Column name
* @param columnSQL virtual column
* @param displayType Display Type
* @param isMandatory Mandatory
@ -52,6 +53,7 @@ public class POInfoColumn implements Serializable
* @param valueMax maximal value
* @param isTranslated translated
* @param isEncrypted encrypted
* @param isAllowLogging allow logging
*/
public POInfoColumn (int ad_Column_ID, String columnName, String columnSQL, int displayType,
boolean isMandatory, boolean isUpdateable, String defaultLogic,
@ -59,7 +61,7 @@ public class POInfoColumn implements Serializable
boolean isKey, boolean isParent,
int ad_Reference_Value_ID, String validationCode,
int fieldLength, String valueMin, String valueMax,
boolean isTranslated, boolean isEncrypted)
boolean isTranslated, boolean isEncrypted, boolean isAllowLogging)
{
AD_Column_ID = ad_Column_ID;
ColumnName = columnName;
@ -117,6 +119,7 @@ public class POInfoColumn implements Serializable
}
IsTranslated = isTranslated;
IsEncrypted = isEncrypted;
IsAllowLogging = isAllowLogging;
} // Column
/** Column ID */
@ -128,7 +131,7 @@ public class POInfoColumn implements Serializable
/** Display Type */
public int DisplayType;
/** Data Type */
public Class ColumnClass;
public Class<?> ColumnClass;
/** Mandatory */
public boolean IsMandatory;
/** Default Value */
@ -145,8 +148,10 @@ public class POInfoColumn implements Serializable
public boolean IsParent;
/** Translated */
public boolean IsTranslated;
/** Encryoted */
/** Encrypted */
public boolean IsEncrypted;
/** Allow Logging */
public boolean IsAllowLogging;
/** Reference Value */
public int AD_Reference_Value_ID;

View File

@ -958,4 +958,20 @@ public class X_AD_Column extends PO implements I_AD_Column, I_Persistent
return Env.ZERO;
return bd;
}
/** Get IsAllowLogging .
* Determines, if a column must be recorded into the change log
*/
public boolean IsAllowLogging() {
Object oo = get_Value(COLUMNNAME_isAllowLogging);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
}

View File

@ -0,0 +1,29 @@
-- Jul 23, 2008 4:50:40 PM COT
-- [ 1810133 ] Add logging policy on column level
INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,53669,0,'IsAllowLogging',TO_DATE('2008-07-23 16:50:36','YYYY-MM-DD HH24:MI:SS'),100,'Determine if a column must be recorded into the change log','U','Y','IsAllowLogging','IsAllowLogging',TO_DATE('2008-07-23 16:50:36','YYYY-MM-DD HH24:MI:SS'),100)
;
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53669 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID)
;
UPDATE AD_Element_Trl SET IsTranslated='Y',Name='RegistrarEnLog',PrintName='Registrar en Log de Cambios',Description='Determina si una columna debe ser registrada en el log de cambios',Updated=TO_DATE('2008-07-23 16:53:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53669 AND AD_Language='es_MX'
;
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,DefaultValue,Description,EntityType,FieldLength,IsActive,IsAlwaysUpdateable,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,56187,53669,0,20,101,'IsAllowLogging',TO_DATE('2008-07-23 16:55:42','YYYY-MM-DD HH24:MI:SS'),100,'Y','Determine if a column must be recorded into the change log','D',1,'Y','N','N','N','N','N','N','N','N','N','Y','IsAllowLogging',0,TO_DATE('2008-07-23 16:55:42','YYYY-MM-DD HH24:MI:SS'),100,0)
;
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=56187 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID)
;
ALTER TABLE AD_Column ADD IsAllowLogging CHAR(1) DEFAULT 'Y' CHECK (IsAllowLogging IN ('Y','N'))
;
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,56187,56317,0,101,TO_DATE('2008-07-23 16:57:53','YYYY-MM-DD HH24:MI:SS'),100,'Determine if a column must be recorded into the change log',0,'D','Y','Y','Y','N','N','N','N','N','IsAllowLogging',370,0,TO_DATE('2008-07-23 16:57:53','YYYY-MM-DD HH24:MI:SS'),100)
;
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56317 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
;
UPDATE AD_Column SET IsAllowLogging = 'N' WHERE AD_Column_ID IN (6652, 6653)
;

View File

@ -0,0 +1,29 @@
-- Jul 23, 2008 4:50:40 PM COT
-- [ 1810133 ] Add logging policy on column level
INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,53669,0,'IsAllowLogging',TO_TIMESTAMP('2008-07-23 16:50:36','YYYY-MM-DD HH24:MI:SS'),100,'Determine if a column must be recorded into the change log','U','Y','IsAllowLogging','IsAllowLogging',TO_TIMESTAMP('2008-07-23 16:50:36','YYYY-MM-DD HH24:MI:SS'),100)
;
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53669 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID)
;
UPDATE AD_Element_Trl SET IsTranslated='Y',Name='RegistrarEnLog',PrintName='Registrar en Log de Cambios',Description='Determina si una columna debe ser registrada en el log de cambios',Updated=TO_TIMESTAMP('2008-07-23 16:53:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53669 AND AD_Language='es_MX'
;
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,DefaultValue,Description,EntityType,FieldLength,IsActive,IsAlwaysUpdateable,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,56187,53669,0,20,101,'IsAllowLogging',TO_TIMESTAMP('2008-07-23 16:55:42','YYYY-MM-DD HH24:MI:SS'),100,'Y','Determine if a column must be recorded into the change log','D',1,'Y','N','N','N','N','N','N','N','N','N','Y','IsAllowLogging',0,TO_TIMESTAMP('2008-07-23 16:55:42','YYYY-MM-DD HH24:MI:SS'),100,0)
;
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=56187 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID)
;
ALTER TABLE AD_Column ADD COLUMN IsAllowLogging CHAR(1) DEFAULT 'Y' CHECK (IsAllowLogging IN ('Y','N'))
;
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,56187,56317,0,101,TO_TIMESTAMP('2008-07-23 16:57:53','YYYY-MM-DD HH24:MI:SS'),100,'Determine if a column must be recorded into the change log',0,'D','Y','Y','Y','N','N','N','N','N','IsAllowLogging',370,0,TO_TIMESTAMP('2008-07-23 16:57:53','YYYY-MM-DD HH24:MI:SS'),100)
;
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56317 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
;
UPDATE AD_Column SET IsAllowLogging = 'N' WHERE AD_Column_ID IN (6652, 6653)
;