IDEMPIERE-5668 - Improvements to the copy role process (#1780)

* IDEMPIERE-5668 - Improvements to the copy role process

* IDEMPIERE-5668 - Adjustments to the parameters of the copyRole process
This commit is contained in:
Jose Leite 2023-04-26 22:58:00 -03:00 committed by GitHub
parent 6a94b815cd
commit ade419e699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 230 additions and 38 deletions

View File

@ -0,0 +1,38 @@
-- IDEMPIERE-5668
SELECT register_migration_script('202304131354_IDEMPIERE-5668.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 13, 2023, 1:57:56 PM BRT
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200175,'AD_Role of User','S','AD_Role.AD_Role_ID IN (SELECT AD_User_Roles.AD_Role_ID FROM AD_User_Roles WHERE AD_User_Roles.AD_User_ID = @#AD_User_ID@)',0,0,'Y',TO_TIMESTAMP('2023-04-13 13:57:56','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 13:57:56','YYYY-MM-DD HH24:MI:SS'),100,'D','d1e9c6fc-5a01-41d5-bdaf-4f9f76b8eccd')
;
-- Apr 13, 2023, 1:58:21 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200175,Updated=TO_TIMESTAMP('2023-04-13 13:58:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50002
;
-- Apr 13, 2023, 1:58:30 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200175,Updated=TO_TIMESTAMP('2023-04-13 13:58:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50001
;
-- Apr 13, 2023, 1:59:13 PM BRT
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200176,'AD_Client Acess','S','(CASE WHEN @#AD_Client_ID@ <> 0 THEN AD_Client.AD_Client_ID <> 0 ELSE TRUE END)',0,0,'Y',TO_TIMESTAMP('2023-04-13 13:59:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 13:59:12','YYYY-MM-DD HH24:MI:SS'),100,'D','130eb80f-a0d6-4df2-8595-1c92c538700e')
;
-- Apr 13, 2023, 1:59:22 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200176,Updated=TO_TIMESTAMP('2023-04-13 13:59:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50003
;
-- Apr 13, 2023, 2:00:53 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=148,Updated=TO_TIMESTAMP('2023-04-13 14:00:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50004
;
-- Apr 13, 2023, 2:02:40 PM BRT
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Roles must be different',0,0,'Y',TO_TIMESTAMP('2023-04-13 14:02:40','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 14:02:40','YYYY-MM-DD HH24:MI:SS'),100,200831,'RolesMustBeDifferent','D','61a4a8d4-a253-4160-867f-1814463b1688')
;
-- Apr 13, 2023, 2:03:37 PM BRT
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Role Copied',0,0,'Y',TO_TIMESTAMP('2023-04-13 14:03:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 14:03:36','YYYY-MM-DD HH24:MI:SS'),100,200832,'RoleCopied','D','3f6a6ae6-7083-4d97-afb3-476577b135a5')
;

View File

@ -0,0 +1,69 @@
-- IDEMPIERE-5668
SELECT register_migration_script('202304250949_IDEMPIERE-5668.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 25, 2023, 9:49:32 AM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=NULL,Updated=TO_TIMESTAMP('2023-04-25 09:49:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50002
;
-- Apr 25, 2023, 9:49:49 AM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=NULL,Updated=TO_TIMESTAMP('2023-04-25 09:49:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50001
;
-- Apr 25, 2023, 9:49:53 AM BRT
DELETE FROM AD_Val_Rule WHERE AD_Val_Rule_UU='d1e9c6fc-5a01-41d5-bdaf-4f9f76b8eccd'
;
-- Apr 25, 2023, 9:50:39 AM BRT
DELETE FROM AD_Process_Para WHERE AD_Process_Para_UU='61319c51-d825-44bc-9244-ffe44c82ca82'
;
-- Apr 25, 2023, 9:51:13 AM BRT
UPDATE AD_Process_Para SET SeqNo=5,Updated=TO_TIMESTAMP('2023-04-25 09:51:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50004
;
-- Apr 25, 2023, 9:51:27 AM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=NULL,Updated=TO_TIMESTAMP('2023-04-25 09:51:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50004
;
-- Apr 25, 2023, 9:55:19 AM BRT
UPDATE AD_Process SET Description='WARNING! when executing the process, all Role to access records will be lost, being replaced by Role from records',Updated=TO_TIMESTAMP('2023-04-25 09:55:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=50010
;
-- Apr 25, 2023, 9:55:19 AM BRT
UPDATE AD_Menu SET Name='Copy Role', Description='WARNING! when executing the process, all Role to access records will be lost, being replaced by Role from records', IsActive='Y',Updated=TO_TIMESTAMP('2023-04-25 09:55:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=50007
;
-- Apr 25, 2023, 10:19:33 AM BRT
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 (203807,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:19:32','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:19:32','YYYY-MM-DD HH24:MI:SS'),100,'AD_Role_ID_From','Role From','Role that will be copied all accesses','Inform the role that you want to copy the access information','Role From','D','b8c55d50-a3e9-4448-ab48-420b3792fe00')
;
-- Apr 25, 2023, 10:29:08 AM BRT
DELETE FROM AD_Process_Para WHERE AD_Process_Para_UU='c91ae734-af0a-410b-8493-6c9333786c1f'
;
-- Apr 25, 2023, 10:29:35 AM BRT
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete,DateRangeOption,IsShowNegateButton) VALUES (200436,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:29:34','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:29:34','YYYY-MM-DD HH24:MI:SS'),100,'Role From','Role that will be copied all accesses','Inform the role that you want to copy the access information',50010,10,18,53317,'N',0,'N','AD_Role_ID_From','Y','D',203807,'5f991e98-4cf2-4390-9233-f9baa9457e1c','N','N','D','N')
;
-- Apr 25, 2023, 10:33:01 AM BRT
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 (203808,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:33:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:33:01','YYYY-MM-DD HH24:MI:SS'),100,'AD_Role_ID_To','Role To','Role that will receive the copy of access permissions','Inform the role that will receive access information','Role To','D','19b55f83-b362-416b-b301-8e43b4700db2')
;
-- Apr 25, 2023, 10:33:33 AM BRT
DELETE FROM AD_Process_Para WHERE AD_Process_Para_UU='d701cb36-ab0f-4dac-aeb4-6aa5b935950c'
;
-- Apr 25, 2023, 10:33:56 AM BRT
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete,DateRangeOption,IsShowNegateButton) VALUES (200437,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:33:56','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:33:56','YYYY-MM-DD HH24:MI:SS'),100,'Role To','Role that will receive the copy of access permissions','Inform the role that will receive access information',50010,15,18,53317,'N',0,'N','AD_Role_ID_To','Y','D',203808,'4b94a03d-515b-4f1a-86a4-fc6991d922b3','N','N','D','N')
;
-- Apr 25, 2023, 10:35:03 AM BRT
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2023-04-25 10:35:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200436
;
-- Apr 25, 2023, 10:35:11 AM BRT
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2023-04-25 10:35:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200437
;

View File

@ -0,0 +1,35 @@
-- IDEMPIERE-5668
SELECT register_migration_script('202304131354_IDEMPIERE-5668.sql') FROM dual;
-- Apr 13, 2023, 1:57:56 PM BRT
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200175,'AD_Role of User','S','AD_Role.AD_Role_ID IN (SELECT AD_User_Roles.AD_Role_ID FROM AD_User_Roles WHERE AD_User_Roles.AD_User_ID = @#AD_User_ID@)',0,0,'Y',TO_TIMESTAMP('2023-04-13 13:57:56','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 13:57:56','YYYY-MM-DD HH24:MI:SS'),100,'D','d1e9c6fc-5a01-41d5-bdaf-4f9f76b8eccd')
;
-- Apr 13, 2023, 1:58:21 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200175,Updated=TO_TIMESTAMP('2023-04-13 13:58:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50002
;
-- Apr 13, 2023, 1:58:30 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200175,Updated=TO_TIMESTAMP('2023-04-13 13:58:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50001
;
-- Apr 13, 2023, 1:59:13 PM BRT
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200176,'AD_Client Acess','S','(CASE WHEN @#AD_Client_ID@ <> 0 THEN AD_Client.AD_Client_ID <> 0 ELSE TRUE END)',0,0,'Y',TO_TIMESTAMP('2023-04-13 13:59:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 13:59:12','YYYY-MM-DD HH24:MI:SS'),100,'D','130eb80f-a0d6-4df2-8595-1c92c538700e')
;
-- Apr 13, 2023, 1:59:22 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200176,Updated=TO_TIMESTAMP('2023-04-13 13:59:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50003
;
-- Apr 13, 2023, 2:00:53 PM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=148,Updated=TO_TIMESTAMP('2023-04-13 14:00:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50004
;
-- Apr 13, 2023, 2:02:40 PM BRT
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Roles must be different',0,0,'Y',TO_TIMESTAMP('2023-04-13 14:02:40','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 14:02:40','YYYY-MM-DD HH24:MI:SS'),100,200831,'RolesMustBeDifferent','D','61a4a8d4-a253-4160-867f-1814463b1688')
;
-- Apr 13, 2023, 2:03:37 PM BRT
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Role Copied',0,0,'Y',TO_TIMESTAMP('2023-04-13 14:03:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-13 14:03:36','YYYY-MM-DD HH24:MI:SS'),100,200832,'RoleCopied','D','3f6a6ae6-7083-4d97-afb3-476577b135a5')
;

View File

@ -0,0 +1,65 @@
-- IDEMPIERE-5668
SELECT register_migration_script('202304250949_IDEMPIERE-5668.sql') FROM dual;
-- Apr 25, 2023, 9:49:32 AM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=NULL,Updated=TO_TIMESTAMP('2023-04-25 09:49:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50002
;
-- Apr 25, 2023, 9:49:49 AM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=NULL,Updated=TO_TIMESTAMP('2023-04-25 09:49:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50001
;
-- Apr 25, 2023, 9:49:53 AM BRT
DELETE FROM AD_Val_Rule WHERE AD_Val_Rule_UU='d1e9c6fc-5a01-41d5-bdaf-4f9f76b8eccd'
;
-- Apr 25, 2023, 9:50:39 AM BRT
DELETE FROM AD_Process_Para WHERE AD_Process_Para_UU='61319c51-d825-44bc-9244-ffe44c82ca82'
;
-- Apr 25, 2023, 9:51:13 AM BRT
UPDATE AD_Process_Para SET SeqNo=5,Updated=TO_TIMESTAMP('2023-04-25 09:51:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50004
;
-- Apr 25, 2023, 9:51:27 AM BRT
UPDATE AD_Process_Para SET AD_Val_Rule_ID=NULL,Updated=TO_TIMESTAMP('2023-04-25 09:51:27','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=50004
;
-- Apr 25, 2023, 9:55:19 AM BRT
UPDATE AD_Process SET Description='WARNING! when executing the process, all Role to access records will be lost, being replaced by Role from records',Updated=TO_TIMESTAMP('2023-04-25 09:55:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=50010
;
-- Apr 25, 2023, 9:55:19 AM BRT
UPDATE AD_Menu SET Name='Copy Role', Description='WARNING! when executing the process, all Role to access records will be lost, being replaced by Role from records', IsActive='Y',Updated=TO_TIMESTAMP('2023-04-25 09:55:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=50007
;
-- Apr 25, 2023, 10:19:33 AM BRT
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 (203807,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:19:32','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:19:32','YYYY-MM-DD HH24:MI:SS'),100,'AD_Role_ID_From','Role From','Role that will be copied all accesses','Inform the role that you want to copy the access information','Role From','D','b8c55d50-a3e9-4448-ab48-420b3792fe00')
;
-- Apr 25, 2023, 10:29:08 AM BRT
DELETE FROM AD_Process_Para WHERE AD_Process_Para_UU='c91ae734-af0a-410b-8493-6c9333786c1f'
;
-- Apr 25, 2023, 10:29:35 AM BRT
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete,DateRangeOption,IsShowNegateButton) VALUES (200436,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:29:34','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:29:34','YYYY-MM-DD HH24:MI:SS'),100,'Role From','Role that will be copied all accesses','Inform the role that you want to copy the access information',50010,10,18,53317,'N',0,'N','AD_Role_ID_From','Y','D',203807,'5f991e98-4cf2-4390-9233-f9baa9457e1c','N','N','D','N')
;
-- Apr 25, 2023, 10:33:01 AM BRT
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 (203808,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:33:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:33:01','YYYY-MM-DD HH24:MI:SS'),100,'AD_Role_ID_To','Role To','Role that will receive the copy of access permissions','Inform the role that will receive access information','Role To','D','19b55f83-b362-416b-b301-8e43b4700db2')
;
-- Apr 25, 2023, 10:33:33 AM BRT
DELETE FROM AD_Process_Para WHERE AD_Process_Para_UU='d701cb36-ab0f-4dac-aeb4-6aa5b935950c'
;
-- Apr 25, 2023, 10:33:56 AM BRT
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete,DateRangeOption,IsShowNegateButton) VALUES (200437,0,0,'Y',TO_TIMESTAMP('2023-04-25 10:33:56','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-04-25 10:33:56','YYYY-MM-DD HH24:MI:SS'),100,'Role To','Role that will receive the copy of access permissions','Inform the role that will receive access information',50010,15,18,53317,'N',0,'N','AD_Role_ID_To','Y','D',203808,'4b94a03d-515b-4f1a-86a4-fc6991d922b3','N','N','D','N')
;
-- Apr 25, 2023, 10:35:03 AM BRT
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2023-04-25 10:35:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200436
;
-- Apr 25, 2023, 10:35:11 AM BRT
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2023-04-25 10:35:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200437
;

View File

@ -21,19 +21,21 @@ package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.adempiere.base.annotation.Parameter;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.I_AD_Role_Included; import org.compiere.model.I_AD_Role_Included;
import org.compiere.model.MProcessPara;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg;
/** /**
* Copy role access records * Copy role access records
* *
* @author Robert Klein * @author Robert Klein
* @ author Paul Bowden * @author Paul Bowden
* @contributor Jose.Leite
* @version $Id: CopyRole.java,v 1.0$ * @version $Id: CopyRole.java,v 1.0$
* *
*/ */
@ -41,35 +43,17 @@ import org.compiere.util.Env;
@org.adempiere.base.annotation.Process @org.adempiere.base.annotation.Process
public class CopyRole extends SvrProcess public class CopyRole extends SvrProcess
{ {
private int m_AD_Role_ID_From = 0; @Parameter
private int m_AD_Role_ID_To = 0; private int p_AD_Role_ID_From = 0;
private int m_AD_Client_ID = 0; @Parameter
private int m_AD_Org_ID = 0; private int p_AD_Role_ID_To = 0;
@Parameter
private int p_AD_Org_ID = 0;
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare()
{
ProcessInfoParameter[] para = getParameter(); protected void prepare(){
for (int i = 0; i < para.length; i++)
{ }
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("AD_Role_ID") && i == 0)
m_AD_Role_ID_From = para[i].getParameterAsInt();
else if (name.equals("AD_Role_ID")&& i == 1)
m_AD_Role_ID_To = para[i].getParameterAsInt();
else if (name.equals("AD_Client_ID"))
m_AD_Client_ID = para[i].getParameterAsInt();
else if (name.equals("AD_Org_ID"))
m_AD_Org_ID = para[i].getParameterAsInt();
else
MProcessPara.validateUnknownParameter(getProcessInfo().getAD_Process_ID(), para[i]);
}
} // prepare
/** /**
* Copy the role access records * Copy the role access records
@ -78,12 +62,13 @@ public class CopyRole extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
if (! MRole.getDefault().isAccessAdvanced()) { if (! MRole.getDefault().isAccessAdvanced()) {
return "@Error@ @Advanced@ @Process@"; return "@Error@ @Advanced@ @Process@";
} }
if (m_AD_Role_ID_From == m_AD_Role_ID_To) if (p_AD_Role_ID_From == p_AD_Role_ID_To)
throw new AdempiereException("Roles must be different"); throw new AdempiereException(Msg.getMsg(getCtx(), "RolesMustBeDifferent"));
String[] tables = new String[] {"AD_Window_Access", "AD_Process_Access", "AD_Form_Access", String[] tables = new String[] {"AD_Window_Access", "AD_Process_Access", "AD_Form_Access",
"AD_Workflow_Access", "AD_Task_Access", "AD_Document_Action_Access", "AD_InfoWindow_Access", "AD_Workflow_Access", "AD_Task_Access", "AD_Document_Action_Access", "AD_InfoWindow_Access",
@ -101,7 +86,7 @@ public class CopyRole extends SvrProcess
String table = tables[i]; String table = tables[i];
String keycolumn = keycolumns[i]; String keycolumn = keycolumns[i];
StringBuilder sql = new StringBuilder("DELETE FROM ").append(table).append(" WHERE AD_Role_ID = ").append(m_AD_Role_ID_To); StringBuilder sql = new StringBuilder("DELETE FROM ").append(table).append(" WHERE AD_Role_ID = ").append(p_AD_Role_ID_To);
int no = DB.executeUpdateEx(sql.toString(), get_TrxName()); int no = DB.executeUpdateEx(sql.toString(), get_TrxName());
addLog(action++, null, BigDecimal.valueOf(no), "Old records deleted from " + table ); addLog(action++, null, BigDecimal.valueOf(no), "Old records deleted from " + table );
@ -120,25 +105,25 @@ public class CopyRole extends SvrProcess
sql.append(", isReadWrite) "); sql.append(", isReadWrite) ");
else else
sql.append(") "); sql.append(") ");
sql.append("SELECT ").append(m_AD_Client_ID) sql.append("SELECT ").append(Env.getAD_Client_ID(getCtx()))
.append(", ").append(m_AD_Org_ID) .append(", ").append(p_AD_Org_ID)
.append(", getDate(), ").append(Env.getAD_User_ID(Env.getCtx())) .append(", getDate(), ").append(Env.getAD_User_ID(Env.getCtx()))
.append(", getDate(), ").append(Env.getAD_User_ID(Env.getCtx())) .append(", getDate(), ").append(Env.getAD_User_ID(Env.getCtx()))
.append(", ").append(m_AD_Role_ID_To) .append(", ").append(p_AD_Role_ID_To)
.append(", ").append(keycolumn) .append(", ").append(keycolumn)
.append(", IsActive "); .append(", IsActive ");
if (column_SeqNo) if (column_SeqNo)
sql.append(", SeqNo "); sql.append(", SeqNo ");
if (column_IsReadWrite) if (column_IsReadWrite)
sql.append(", isReadWrite "); sql.append(", isReadWrite ");
sql.append("FROM ").append(table).append(" WHERE AD_Role_ID = ").append(m_AD_Role_ID_From); sql.append("FROM ").append(table).append(" WHERE AD_Role_ID = ").append(p_AD_Role_ID_From);
no = DB.executeUpdateEx (sql.toString(), get_TrxName()); no = DB.executeUpdateEx (sql.toString(), get_TrxName());
addLog(action++, null, new BigDecimal(no), "New records inserted into " + table ); addLog(action++, null, new BigDecimal(no), "New records inserted into " + table );
} }
return "Role copied"; return Msg.getMsg(getCtx(),"RoleCopied");
} // doIt } // doIt
} // CopyRole } // CopyRole