IDEMPIERE-5613 Make filling of _UU column optional (#1719)
* IDEMPIERE-5613 Make filling of _UU column optional * - clear _UU when column is made inactive * - Add parameter IsClearUUID - Fix issue with buffer log not being flushed
This commit is contained in:
parent
b188775e9a
commit
4c77efecb4
|
@ -0,0 +1,14 @@
|
|||
-- IDEMPIERE-5613 Make filling of _UU column optional
|
||||
SELECT register_migration_script('202303131848_IDEMPIERE-5613.sql') FROM dual;
|
||||
|
||||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Mar 13, 2023, 6:48:00 PM CET
|
||||
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203792,0,0,'Y',TO_TIMESTAMP('2023-03-13 18:46:14','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-13 18:46:14','YYYY-MM-DD HH24:MI:SS'),100,'IsClearUUID','Clear UUID','Clear UUID when column is inactive',NULL,'Clear UUID','D','69bb1e9c-14f1-4e4a-a43e-4417875c0de3')
|
||||
;
|
||||
|
||||
-- Mar 13, 2023, 6:48:13 PM CET
|
||||
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete,DateRangeOption,IsShowNegateButton) VALUES (200432,0,0,'Y',TO_TIMESTAMP('2023-03-13 18:48:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-13 18:48:12','YYYY-MM-DD HH24:MI:SS'),100,'Clear UUID','Clear UUID when column is inactive',53252,30,20,'N',1,'Y','N','IsClearUUID','Y','D',203792,'ef8c4d7e-8ee4-4911-a6e5-4d1d8989e4be','N','N','D','N')
|
||||
;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
-- IDEMPIERE-5613 Make filling of _UU column optional
|
||||
SELECT register_migration_script('202303131848_IDEMPIERE-5613.sql') FROM dual;
|
||||
|
||||
-- Mar 13, 2023, 6:48:00 PM CET
|
||||
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203792,0,0,'Y',TO_TIMESTAMP('2023-03-13 18:46:14','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-13 18:46:14','YYYY-MM-DD HH24:MI:SS'),100,'IsClearUUID','Clear UUID','Clear UUID when column is inactive',NULL,'Clear UUID','D','69bb1e9c-14f1-4e4a-a43e-4417875c0de3')
|
||||
;
|
||||
|
||||
-- Mar 13, 2023, 6:48:13 PM CET
|
||||
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,AD_Process_ID,SeqNo,AD_Reference_ID,IsRange,FieldLength,IsMandatory,DefaultValue,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete,DateRangeOption,IsShowNegateButton) VALUES (200432,0,0,'Y',TO_TIMESTAMP('2023-03-13 18:48:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-13 18:48:12','YYYY-MM-DD HH24:MI:SS'),100,'Clear UUID','Clear UUID when column is inactive',53252,30,20,'N',1,'Y','N','IsClearUUID','Y','D',203792,'ef8c4d7e-8ee4-4911-a6e5-4d1d8989e4be','N','N','D','N')
|
||||
;
|
||||
|
|
@ -55,6 +55,8 @@ public class UUIDGenerator extends SvrProcess {
|
|||
|
||||
private boolean isFillUUID = false;
|
||||
|
||||
private boolean isClearUUID = false;
|
||||
|
||||
/** Logger */
|
||||
private static final CLogger log = CLogger.getCLogger(UUIDGenerator.class);
|
||||
|
||||
|
@ -70,6 +72,8 @@ public class UUIDGenerator extends SvrProcess {
|
|||
tableName = param.getParameter().toString();
|
||||
else if (param.getParameterName().equals("IsFillUUID"))
|
||||
isFillUUID = param.getParameterAsBoolean();
|
||||
else if (param.getParameterName().equals("IsClearUUID"))
|
||||
isClearUUID = param.getParameterAsBoolean();
|
||||
else
|
||||
MProcessPara.validateUnknownParameter(getProcessInfo().getAD_Process_ID(), param);
|
||||
}
|
||||
|
@ -129,19 +133,35 @@ public class UUIDGenerator extends SvrProcess {
|
|||
|
||||
//update db
|
||||
if (isFillUUID) {
|
||||
// COMMENT NEXT LINE ON RELEASE WORK
|
||||
String msg = updateUUID(mColumn, null);
|
||||
if (! Util.isEmpty(msg)) {
|
||||
addBufferLog(0, null, null, msg, 0, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isFillUUID) {
|
||||
MColumn mColumn = MColumn.get(getCtx(), AD_Column_ID);
|
||||
// COMMENT NEXT LINE ON RELEASE WORK
|
||||
String msg = updateUUID(mColumn, null);
|
||||
if (! Util.isEmpty(msg)) {
|
||||
addBufferLog(0, null, null, msg, 0, 0);
|
||||
MColumn column = MColumn.get(AD_Column_ID);
|
||||
if (column.isActive()) {
|
||||
if (isFillUUID) {
|
||||
MColumn mColumn = MColumn.get(getCtx(), AD_Column_ID);
|
||||
String msg = updateUUID(mColumn, null);
|
||||
if (! Util.isEmpty(msg)) {
|
||||
addBufferLog(0, null, null, msg, 0, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isClearUUID) {
|
||||
StringBuilder sqlclear = new StringBuilder("UPDATE ")
|
||||
.append(cTableName)
|
||||
.append(" SET ")
|
||||
.append(columnName)
|
||||
.append("=NULL WHERE ")
|
||||
.append(columnName)
|
||||
.append(" IS NOT NULL");
|
||||
int cnt = DB.executeUpdateEx(sqlclear.toString(), get_TrxName());
|
||||
if (cnt > 0) {
|
||||
String msg = cnt + " UUID cleared from table " + cTableName;
|
||||
addBufferLog(0, null, null, msg, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,6 +282,9 @@ public abstract class SvrProcess implements ProcessCall
|
|||
success = false;
|
||||
|
||||
if (success) {
|
||||
// if the connection has not been used, then the buffer log is never flushed
|
||||
// f.e. when the process uses local transactions like UUIDGenerator
|
||||
m_trx.getConnection();
|
||||
m_trx.addTrxEventListener(new TrxEventListener() {
|
||||
@Override
|
||||
public void afterRollback(Trx trx, boolean success) {
|
||||
|
|
Loading…
Reference in New Issue