IDEMPIERE-5647 Allow definition of context variables by Role - fix issue not being used in Logic (#2452)
This commit is contained in:
parent
90c4b7a64a
commit
3de220daec
|
|
@ -1845,7 +1845,7 @@ class QueryEvaluatee implements Evaluatee {
|
|||
}
|
||||
|
||||
String value = null;
|
||||
if (variableName.startsWith("#") || variableName.startsWith("$")) {
|
||||
if (Env.isGlobalVariable(variableName)) {
|
||||
value = Env.getContext(ctx, variableName);
|
||||
} else {
|
||||
value = parameterMap.get(variableName);
|
||||
|
|
@ -1857,7 +1857,7 @@ class QueryEvaluatee implements Evaluatee {
|
|||
id = Integer.parseInt(value);
|
||||
} catch (Exception e){}
|
||||
if (id > 0) {
|
||||
if (variableName.startsWith("#") || variableName.startsWith("$")) {
|
||||
if (Env.isGlobalVariable(variableName)) {
|
||||
variableName = variableName.substring(1);
|
||||
} else if (variableName.indexOf("|") > 0) {
|
||||
variableName = variableName.substring(variableName.lastIndexOf("|")+1);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class PrintDataEvaluatee implements Evaluatee {
|
|||
}
|
||||
|
||||
String value = null;
|
||||
if (variableName.startsWith("#") || variableName.startsWith("$")) {
|
||||
if (Env.isGlobalVariable(variableName)) {
|
||||
value = Env.getContext(Env.getCtx(), variableName);
|
||||
} else {
|
||||
Object obj = m_data.getNode(variableName);
|
||||
|
|
@ -89,7 +89,7 @@ public class PrintDataEvaluatee implements Evaluatee {
|
|||
"SELECT " + foreignColumn + " FROM " + foreignTable + " WHERE "
|
||||
+ foreignTable + "_ID = ?", id);
|
||||
} else {
|
||||
if (variableName.startsWith("#") || variableName.startsWith("$")) {
|
||||
if (Env.isGlobalVariable(variableName)) {
|
||||
variableName = variableName.substring(1);
|
||||
} else if (variableName.indexOf("|") > 0) {
|
||||
variableName = variableName.substring(variableName.lastIndexOf("|")+1);
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ public final class Env
|
|||
if (s == null)
|
||||
{
|
||||
// Explicit Base Values
|
||||
if (context.startsWith("#") || context.startsWith("$") || context.startsWith("P|"))
|
||||
if (Env.isGlobalVariable(context) || Env.isPreference(context))
|
||||
return getContext(ctx, context);
|
||||
if (onlyWindow) // no Default values
|
||||
return "";
|
||||
|
|
@ -1039,6 +1039,8 @@ public final class Env
|
|||
retValue = ctx.getProperty("#"+context); // Login setting
|
||||
if (retValue == null)
|
||||
retValue = ctx.getProperty("$"+context); // Accounting setting
|
||||
if (retValue == null)
|
||||
retValue = ctx.getProperty("+"+context); // Injected Role Variable
|
||||
}
|
||||
//
|
||||
return (retValue == null ? "" : retValue);
|
||||
|
|
@ -1527,7 +1529,7 @@ public final class Env
|
|||
}
|
||||
|
||||
String ctxInfo = getContext(ctx, WindowNo, token, onlyWindow); // get context
|
||||
if (ctxInfo.length() == 0 && (token.startsWith("#") || token.startsWith("$")) )
|
||||
if (ctxInfo.length() == 0 && Env.isGlobalVariable(token))
|
||||
ctxInfo = getContext(ctx, token); // get global context
|
||||
|
||||
if (ctxInfo.length() == 0 && defaultV != null)
|
||||
|
|
@ -1613,7 +1615,7 @@ public final class Env
|
|||
ctxInfo = getContext(ctx, WindowNo, tabNo, token, onlyTab); // get context
|
||||
}
|
||||
|
||||
if (ctxInfo.length() == 0 && (token.startsWith("#") || token.startsWith("$")) )
|
||||
if (ctxInfo.length() == 0 && Env.isGlobalVariable(token))
|
||||
ctxInfo = getContext(ctx, token); // get global context
|
||||
|
||||
if (ctxInfo.length() == 0 && defaultV != null)
|
||||
|
|
@ -1729,7 +1731,7 @@ public final class Env
|
|||
}
|
||||
|
||||
Properties ctx = po != null ? po.getCtx() : Env.getCtx();
|
||||
if (token.startsWith("#") || token.startsWith("$")) {
|
||||
if (Env.isGlobalVariable(token)) {
|
||||
//take from context
|
||||
String v = Env.getContext(ctx, token);
|
||||
if (v != null && v.length() > 0) {
|
||||
|
|
@ -1818,7 +1820,7 @@ public final class Env
|
|||
String token, String format, MColumn colToken, Object value, StringBuilder outStr) {
|
||||
if (format != null && format.length() > 0) {
|
||||
String foreignTable = colToken != null ? colToken.getReferenceTableName() : null;
|
||||
if (value instanceof String && token.endsWith("_ID") && (token.startsWith("#") || token.startsWith("$"))) {
|
||||
if (value instanceof String && token.endsWith("_ID") && Env.isGlobalVariable(token)) {
|
||||
try {
|
||||
int id = Integer.parseInt((String)value);
|
||||
value = id;
|
||||
|
|
@ -2343,4 +2345,28 @@ public final class Env
|
|||
return "Y".equals(Env.getContext(Env.getCtx(), "IsReadOnlySession"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if a context variable name is global, this is, starting with:
|
||||
* # Login
|
||||
* $ Accounting
|
||||
* + Role Injected
|
||||
* @param variable
|
||||
* @return
|
||||
*/
|
||||
public static boolean isGlobalVariable(String variable) {
|
||||
return variable.startsWith("#")
|
||||
|| variable.startsWith("$")
|
||||
|| variable.startsWith("+");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if a context variable name is a preference, this is, starting with:
|
||||
* P| Preference
|
||||
* @param variable
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPreference(String variable) {
|
||||
return variable.startsWith("P|");
|
||||
}
|
||||
|
||||
} // Env
|
||||
Loading…
Reference in New Issue