IDEMPIERE-4262 on some condition, record insert by direct sql missing UUID (#1068)
* IDEMPIERE-4262 on some condition, record insert by direct sql missing UUID / fix role access uuids * more on AD_Document_Action_Access * Improve performance for trl recreate or insert - using update instead of record by record * - add AD_PInstance_Log.AD_PInstance_Log_UU
This commit is contained in:
parent
c4c3e348b6
commit
85cb32f2d8
|
@ -94,6 +94,13 @@ BEGIN
|
|||
-- DBMS_OUTPUT.PUT_LINE (sqlins);
|
||||
EXECUTE IMMEDIATE sqlins;
|
||||
|
||||
UPDATE AD_Window_Access SET AD_Window_Access_UU=generate_uuid() WHERE AD_Window_Access_UU IS NULL;
|
||||
UPDATE AD_Process_Access SET AD_Process_Access_UU=generate_uuid() WHERE AD_Process_Access_UU IS NULL;
|
||||
UPDATE AD_Form_Access SET AD_Form_Access_UU=generate_uuid() WHERE AD_Form_Access_UU IS NULL;
|
||||
UPDATE AD_Workflow_Access SET AD_Workflow_Access_UU=generate_uuid() WHERE AD_Workflow_Access_UU IS NULL;
|
||||
UPDATE AD_Document_Action_Access SET AD_Document_Action_Access_UU=generate_uuid() WHERE AD_Document_Action_Access_UU IS NULL;
|
||||
UPDATE AD_InfoWindow_Access SET AD_InfoWindow_Access_UU=generate_uuid() WHERE AD_InfoWindow_Access_UU IS NULL;
|
||||
|
||||
END LOOP;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -91,6 +91,13 @@ BEGIN
|
|||
|
||||
EXECUTE sqlins;
|
||||
|
||||
UPDATE AD_Window_Access SET AD_Window_Access_UU=generate_uuid() WHERE AD_Window_Access_UU IS NULL;
|
||||
UPDATE AD_Process_Access SET AD_Process_Access_UU=generate_uuid() WHERE AD_Process_Access_UU IS NULL;
|
||||
UPDATE AD_Form_Access SET AD_Form_Access_UU=generate_uuid() WHERE AD_Form_Access_UU IS NULL;
|
||||
UPDATE AD_Workflow_Access SET AD_Workflow_Access_UU=generate_uuid() WHERE AD_Workflow_Access_UU IS NULL;
|
||||
UPDATE AD_Document_Action_Access SET AD_Document_Action_Access_UU=generate_uuid() WHERE AD_Document_Action_Access_UU IS NULL;
|
||||
UPDATE AD_InfoWindow_Access SET AD_InfoWindow_Access_UU=generate_uuid() WHERE AD_InfoWindow_Access_UU IS NULL;
|
||||
|
||||
END LOOP;
|
||||
|
||||
END;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.process.UUIDGenerator;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.idempiere.cache.ImmutableIntPOCache;
|
||||
|
@ -324,6 +325,12 @@ public class MDocType extends X_C_DocType implements ImmutablePOSupport
|
|||
|
||||
int docact = DB.executeUpdate(sqlDocAction.toString(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("AD_Document_Action_Access=" + docact);
|
||||
|
||||
if (DB.isGenerateUUIDSupported())
|
||||
DB.executeUpdateEx("UPDATE AD_Document_Action_Access SET AD_Document_Action_Access_UU=generate_uuid() WHERE AD_Document_Action_Access_UU IS NULL", get_TrxName());
|
||||
else
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MDocumentActionAccess.Table_Name, PO.getUUIDColumnName(MDocumentActionAccess.Table_Name)), get_TrxName());
|
||||
|
||||
}
|
||||
return success;
|
||||
} // afterSave
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - Carlos Ruiz *
|
||||
**********************************************************************/
|
||||
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MDocumentActionAccess extends X_AD_Document_Action_Access {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2036011342206732816L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
*
|
||||
* @param ctx context
|
||||
* @param ignored -
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MDocumentActionAccess(Properties ctx, int ignored, String trxName) {
|
||||
super(ctx, 0, trxName);
|
||||
if (ignored != 0)
|
||||
throw new IllegalArgumentException("Multi-Key");
|
||||
} // MDocumentActionAccess
|
||||
|
||||
/**
|
||||
* MDocumentActionAccess
|
||||
*
|
||||
* @param ctx
|
||||
* @param rs
|
||||
* @param trxName transaction
|
||||
*/
|
||||
public MDocumentActionAccess(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
} // MDocumentActionAccess
|
||||
|
||||
} // MDocumentActionAccess
|
|
@ -498,10 +498,23 @@ public class MLanguage extends X_AD_Language implements ImmutablePOSupport
|
|||
.append(" WHERE AD_Language='").append(getAD_Language()).append("')");
|
||||
int no = DB.executeUpdateEx(insert.toString(), null, get_TrxName());
|
||||
// IDEMPIERE-99 Language Maintenance does not create UUIDs
|
||||
String uucolname = PO.getUUIDColumnName(tableName);
|
||||
MTable table = MTable.get(getCtx(), tableName);
|
||||
MColumn column = table.getColumn(PO.getUUIDColumnName(tableName));
|
||||
if (column != null)
|
||||
UUIDGenerator.updateUUID(column, get_TrxName());
|
||||
MColumn column = table.getColumn(uucolname);
|
||||
if (column != null) {
|
||||
if (DB.isGenerateUUIDSupported()) {
|
||||
StringBuilder upduuid = new StringBuilder("UPDATE ")
|
||||
.append(tableName)
|
||||
.append(" SET ")
|
||||
.append(uucolname)
|
||||
.append("=generate_uuid() WHERE ")
|
||||
.append(uucolname)
|
||||
.append(" IS NULL");
|
||||
DB.executeUpdateEx(upduuid.toString(), get_TrxName());
|
||||
} else {
|
||||
UUIDGenerator.updateUUID(column, get_TrxName());
|
||||
}
|
||||
}
|
||||
//
|
||||
StringBuilder msglog = new StringBuilder().append(tableName).append(" #").append(no);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.math.BigDecimal;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -120,8 +121,8 @@ public class MPInstanceLog
|
|||
|
||||
|
||||
private final static String insertSql = "INSERT INTO AD_PInstance_Log "
|
||||
+ "(AD_PInstance_ID, Log_ID, P_Date, P_ID, P_Number, P_Msg, AD_Table_ID, Record_ID)"
|
||||
+ " VALUES (?,?,?,?,?,?,?,?)";
|
||||
+ "(AD_PInstance_ID, Log_ID, P_Date, P_ID, P_Number, P_Msg, AD_Table_ID, Record_ID, AD_PInstance_Log_UU)"
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
/**
|
||||
* Save to Database
|
||||
|
@ -144,7 +145,7 @@ public class MPInstanceLog
|
|||
private Object[] getInsertParams() {
|
||||
MColumn colMsg = MColumn.get(Env.getCtx(), I_AD_PInstance_Log.Table_Name, I_AD_PInstance_Log.COLUMNNAME_P_Msg);
|
||||
int maxMsgLength = colMsg.getFieldLength();
|
||||
Object[] params = new Object[8];
|
||||
Object[] params = new Object[9];
|
||||
params[0] = m_AD_PInstance_ID;
|
||||
params[1] = m_Log_ID;
|
||||
if (m_P_Date != null)
|
||||
|
@ -163,6 +164,7 @@ public class MPInstanceLog
|
|||
params[6] = m_AD_Table_ID;
|
||||
if (m_Record_ID != 0)
|
||||
params[7] = m_Record_ID;
|
||||
params[8] = UUID.randomUUID().toString();
|
||||
return params;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.util.Set;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.process.UUIDGenerator;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
|
@ -47,6 +48,7 @@ import org.compiere.util.Msg;
|
|||
import org.compiere.util.Trace;
|
||||
import org.compiere.util.Util;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
import org.compiere.wf.MWorkflowAccess;
|
||||
import org.idempiere.cache.ImmutablePOSupport;
|
||||
import org.idempiere.cache.POCopyCache;
|
||||
|
||||
|
@ -590,6 +592,22 @@ public final class MRole extends X_AD_Role implements ImmutablePOSupport
|
|||
int docact = DB.executeUpdateEx(sqlDocAction, get_TrxName());
|
||||
int info = DB.executeUpdateEx(sqlInfo + roleAccessLevel, get_TrxName());
|
||||
|
||||
if (DB.isGenerateUUIDSupported()) {
|
||||
DB.executeUpdateEx("UPDATE AD_Window_Access SET AD_Window_Access_UU=generate_uuid() WHERE AD_Window_Access_UU IS NULL", get_TrxName());
|
||||
DB.executeUpdateEx("UPDATE AD_Process_Access SET AD_Process_Access_UU=generate_uuid() WHERE AD_Process_Access_UU IS NULL", get_TrxName());
|
||||
DB.executeUpdateEx("UPDATE AD_Form_Access SET AD_Form_Access_UU=generate_uuid() WHERE AD_Form_Access_UU IS NULL", get_TrxName());
|
||||
DB.executeUpdateEx("UPDATE AD_Workflow_Access SET AD_Workflow_Access_UU=generate_uuid() WHERE AD_Workflow_Access_UU IS NULL", get_TrxName());
|
||||
DB.executeUpdateEx("UPDATE AD_Document_Action_Access SET AD_Document_Action_Access_UU=generate_uuid() WHERE AD_Document_Action_Access_UU IS NULL", get_TrxName());
|
||||
DB.executeUpdateEx("UPDATE AD_InfoWindow_Access SET AD_InfoWindow_Access_UU=generate_uuid() WHERE AD_InfoWindow_Access_UU IS NULL", get_TrxName());
|
||||
} else {
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MWindowAccess.Table_Name, PO.getUUIDColumnName(MWindowAccess.Table_Name)), get_TrxName());
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MProcessAccess.Table_Name, PO.getUUIDColumnName(MProcessAccess.Table_Name)), get_TrxName());
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MFormAccess.Table_Name, PO.getUUIDColumnName(MFormAccess.Table_Name)), get_TrxName());
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MWorkflowAccess.Table_Name, PO.getUUIDColumnName(MWorkflowAccess.Table_Name)), get_TrxName());
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MDocumentActionAccess.Table_Name, PO.getUUIDColumnName(MDocumentActionAccess.Table_Name)), get_TrxName());
|
||||
UUIDGenerator.updateUUID(MColumn.get(getCtx(), MInfoWindowAccess.Table_Name, PO.getUUIDColumnName(MInfoWindowAccess.Table_Name)), get_TrxName());
|
||||
}
|
||||
|
||||
loadAccess(true);
|
||||
return "@AD_Window_ID@ #" + win
|
||||
+ " - @AD_Process_ID@ #" + proc
|
||||
|
|
Loading…
Reference in New Issue