IDEMPIERE-5647 - allow define context variables by role (#1753)

* IDEMPIERE-5647 - allow define context variables by role

* IDEMPIERE-5647 - fix PR comment
This commit is contained in:
muriloht 2023-03-29 07:44:15 -03:00 committed by GitHub
parent 10ade8a25b
commit 1441b9095a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 4 deletions

View File

@ -0,0 +1,26 @@
-- IDEMPIERE-5647
SELECT register_migration_script('202303262358_IDEMPIERE-5647.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 26, 2023, 11:58:42 PM BRT
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (215806,0,'Predefined Context Variables','Predefined context variables to inject when opening a menu entry or a window',156,'PredefinedContextVariables',4000,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2023-03-26 23:58:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-26 23:58:42','YYYY-MM-DD HH24:MI:SS'),100,203475,'Y','N','D','N','N','N','Y','f5b18037-47e7-4e98-a002-ba54bfd62674','Y',0,'N','N','N','N')
;
-- Mar 26, 2023, 11:58:50 PM BRT
ALTER TABLE AD_Role ADD PredefinedContextVariables VARCHAR2(4000 CHAR) DEFAULT NULL
;
-- Mar 26, 2023, 11:59:42 PM BRT
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (207596,'Predefined Context Variables','Predefined context variables to inject when opening a menu entry or a window',119,215806,'Y',4000,450,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-03-26 23:59:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-26 23:59:42','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','78a3f4d6-26a3-4af2-9342-3b4cc675f867','Y',460,5)
;
-- Mar 27, 2023, 12:00:13 AM BRT
UPDATE AD_Field SET SeqNo=420, AD_FieldGroup_ID=200015, NumLines=5,Updated=TO_TIMESTAMP('2023-03-27 00:00:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207596
;
-- Mar 27, 2023, 12:02:53 AM BRT
UPDATE AD_Field SET DisplayLogic='@IsMasterRole@=N', IsAdvancedField='Y',Updated=TO_TIMESTAMP('2023-03-27 00:02:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207596
;

View File

@ -0,0 +1,23 @@
-- IDEMPIERE-5647
SELECT register_migration_script('202303262358_IDEMPIERE-5647.sql') FROM dual;
-- Mar 26, 2023, 11:58:42 PM BRT
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (215806,0,'Predefined Context Variables','Predefined context variables to inject when opening a menu entry or a window',156,'PredefinedContextVariables',4000,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2023-03-26 23:58:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-26 23:58:42','YYYY-MM-DD HH24:MI:SS'),100,203475,'Y','N','D','N','N','N','Y','f5b18037-47e7-4e98-a002-ba54bfd62674','Y',0,'N','N','N','N')
;
-- Mar 26, 2023, 11:58:50 PM BRT
ALTER TABLE AD_Role ADD COLUMN PredefinedContextVariables VARCHAR(4000) DEFAULT NULL
;
-- Mar 26, 2023, 11:59:42 PM BRT
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (207596,'Predefined Context Variables','Predefined context variables to inject when opening a menu entry or a window',119,215806,'Y',4000,450,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-03-26 23:59:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-26 23:59:42','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','78a3f4d6-26a3-4af2-9342-3b4cc675f867','Y',460,5)
;
-- Mar 27, 2023, 12:00:13 AM BRT
UPDATE AD_Field SET SeqNo=420, AD_FieldGroup_ID=200015, NumLines=5,Updated=TO_TIMESTAMP('2023-03-27 00:00:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207596
;
-- Mar 27, 2023, 12:02:53 AM BRT
UPDATE AD_Field SET DisplayLogic='@IsMasterRole@=N', IsAdvancedField='Y',Updated=TO_TIMESTAMP('2023-03-27 00:02:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207596
;

View File

@ -622,4 +622,17 @@ public interface I_AD_Role
* System Tenant Organization
*/
public String getUserLevel();
/** Column name PredefinedContextVariables */
public static final String COLUMNNAME_PredefinedContextVariables = "PredefinedContextVariables";
/** Set Predefined Context Variables.
* Predefined context variables to inject when opening a menu entry or a window
*/
public void setPredefinedContextVariables (String PredefinedContextVariables);
/** Get Predefined Context Variables.
* Predefined context variables to inject when opening a menu entry or a window
*/
public String getPredefinedContextVariables();
}

View File

@ -1198,4 +1198,20 @@ public class X_AD_Role extends PO implements I_AD_Role, I_Persistent
{
return (String)get_Value(COLUMNNAME_UserLevel);
}
/** Set Predefined Context Variables.
@param PredefinedContextVariables Predefined context variables to inject when opening a menu entry or a window
*/
public void setPredefinedContextVariables (String PredefinedContextVariables)
{
set_Value (COLUMNNAME_PredefinedContextVariables, PredefinedContextVariables);
}
/** Get Predefined Context Variables.
@return Predefined context variables to inject when opening a menu entry or a window
*/
public String getPredefinedContextVariables()
{
return (String)get_Value(COLUMNNAME_PredefinedContextVariables);
}
}

View File

@ -2177,7 +2177,7 @@ public final class Env
/** New Line */
public static final String NL = System.getProperty("line.separator");
/* Prefix for predefined context variables coming from menu or window definition */
/* Prefix for predefined context variables coming from menu, window or role definition */
public static final String PREFIX_PREDEFINED_VARIABLE = "+";
@ -2192,14 +2192,14 @@ public final class Env
/**
* Add in context predefined variables with prefix +, coming from menu or window definition
* Add in context predefined variables with prefix +, coming from menu, window or role definition
* Predefined variables must come separated by new lines in one of the formats:
* VAR=VALUE
* VAR="VALUE"
* VAR='VALUE'
* The + prefix is not required, is added here to the defined variables
* @param ctx
* @param windowNo
* @param windowNo window number or -1 to global level
* @param predefinedVariables
*/
public static void setPredefinedVariables(Properties ctx, int windowNo, String predefinedVariables) {
@ -2216,7 +2216,10 @@ public final class Env
) {
value = value.substring(1, value.length()-1);
}
Env.setContext(ctx, windowNo, PREFIX_PREDEFINED_VARIABLE + var, value);
if (windowNo >= 0)
Env.setContext(ctx, windowNo, PREFIX_PREDEFINED_VARIABLE + var, value);
else
Env.setContext(ctx, PREFIX_PREDEFINED_VARIABLE + var, value);
}
}
}

View File

@ -789,6 +789,8 @@ public class Login
if (AD_Client_ID != 0 && MSysConfig.getBooleanValue(MSysConfig.SYSTEM_IN_MAINTENANCE_MODE, false, AD_Client_ID))
return Msg.getMsg(m_ctx, "SystemInMaintenance");
}
Env.setPredefinedVariables(Env.getCtx(), -1, MRole.getDefault().getPredefinedContextVariables());
return null;
} // validateLogin