IDEMPIERE-6029 Extract @SQL= and @SQLFIND= to constant (#2230)
This commit is contained in:
parent
7224009efc
commit
6302f6f5fd
|
@ -304,7 +304,7 @@ public class GridField
|
||||||
Evaluator.parseDepends(list, m_vo.ReadOnlyLogic);
|
Evaluator.parseDepends(list, m_vo.ReadOnlyLogic);
|
||||||
Evaluator.parseDepends(list, m_vo.MandatoryLogic);
|
Evaluator.parseDepends(list, m_vo.MandatoryLogic);
|
||||||
// Virtual UI Column
|
// Virtual UI Column
|
||||||
if (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && m_vo.ColumnSQL.startsWith("@SQL="))
|
if (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
Evaluator.parseDepends(list, m_vo.ColumnSQL.substring(5));
|
Evaluator.parseDepends(list, m_vo.ColumnSQL.substring(5));
|
||||||
// Lookup
|
// Lookup
|
||||||
if (m_lookup != null)
|
if (m_lookup != null)
|
||||||
|
@ -349,7 +349,7 @@ public class GridField
|
||||||
if (checkContext && m_vo.MandatoryLogic.length() > 0)
|
if (checkContext && m_vo.MandatoryLogic.length() > 0)
|
||||||
{
|
{
|
||||||
boolean retValue = false;
|
boolean retValue = false;
|
||||||
if (m_vo.MandatoryLogic != null && m_vo.MandatoryLogic.startsWith("@SQL=")) {
|
if (m_vo.MandatoryLogic != null && m_vo.MandatoryLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
retValue = Evaluator.parseSQLLogic(m_vo.MandatoryLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
retValue = Evaluator.parseSQLLogic(m_vo.MandatoryLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
|
@ -390,7 +390,7 @@ public class GridField
|
||||||
public boolean isEditablePara(boolean checkContext) {
|
public boolean isEditablePara(boolean checkContext) {
|
||||||
if (checkContext && m_vo.ReadOnlyLogic.length() > 0)
|
if (checkContext && m_vo.ReadOnlyLogic.length() > 0)
|
||||||
{
|
{
|
||||||
if (m_vo.ReadOnlyLogic.startsWith("@SQL="))
|
if (m_vo.ReadOnlyLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
{
|
{
|
||||||
boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
||||||
if (!retValue)
|
if (!retValue)
|
||||||
|
@ -462,7 +462,7 @@ public class GridField
|
||||||
if (checkContext && m_vo.AlwaysUpdatableLogic.length() > 0)
|
if (checkContext && m_vo.AlwaysUpdatableLogic.length() > 0)
|
||||||
{
|
{
|
||||||
boolean isAlwaysUpdatable = false;
|
boolean isAlwaysUpdatable = false;
|
||||||
if (m_vo.AlwaysUpdatableLogic.startsWith("@SQL=")) {
|
if (m_vo.AlwaysUpdatableLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
isAlwaysUpdatable = Evaluator.parseSQLLogic(m_vo.AlwaysUpdatableLogic, ctx, m_vo.WindowNo,
|
isAlwaysUpdatable = Evaluator.parseSQLLogic(m_vo.AlwaysUpdatableLogic, ctx, m_vo.WindowNo,
|
||||||
m_vo.TabNo, m_vo.ColumnName);
|
m_vo.TabNo, m_vo.ColumnName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -543,7 +543,7 @@ public class GridField
|
||||||
// Do we have a readonly rule
|
// Do we have a readonly rule
|
||||||
if (checkContext && m_vo.ReadOnlyLogic.length() > 0)
|
if (checkContext && m_vo.ReadOnlyLogic.length() > 0)
|
||||||
{
|
{
|
||||||
if (m_vo.ReadOnlyLogic.startsWith("@SQL="))
|
if (m_vo.ReadOnlyLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
{
|
{
|
||||||
boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
||||||
if (!retValue)
|
if (!retValue)
|
||||||
|
@ -821,7 +821,7 @@ public class GridField
|
||||||
* (b) SQL Statement (for data integity & consistency)
|
* (b) SQL Statement (for data integity & consistency)
|
||||||
*/
|
*/
|
||||||
String defStr = "";
|
String defStr = "";
|
||||||
if (m_vo.DefaultValue != null && m_vo.DefaultValue.startsWith("@SQL="))
|
if (m_vo.DefaultValue != null && m_vo.DefaultValue.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
{
|
{
|
||||||
String sql = m_vo.DefaultValue.substring(5); // w/o tag
|
String sql = m_vo.DefaultValue.substring(5); // w/o tag
|
||||||
//hengsin, capture unparseable error to avoid subsequent sql exception
|
//hengsin, capture unparseable error to avoid subsequent sql exception
|
||||||
|
@ -878,7 +878,7 @@ public class GridField
|
||||||
/**
|
/**
|
||||||
* (c) Field DefaultValue === similar code in AStartRPDialog.getDefault ===
|
* (c) Field DefaultValue === similar code in AStartRPDialog.getDefault ===
|
||||||
*/
|
*/
|
||||||
if (m_vo.DefaultValue != null && !m_vo.DefaultValue.equals("") && !m_vo.DefaultValue.startsWith("@SQL="))
|
if (m_vo.DefaultValue != null && !m_vo.DefaultValue.equals("") && !m_vo.DefaultValue.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
{
|
{
|
||||||
String defStr = ""; // problem is with texts like 'sss;sss'
|
String defStr = ""; // problem is with texts like 'sss;sss'
|
||||||
// It is one or more variables/constants
|
// It is one or more variables/constants
|
||||||
|
@ -1297,7 +1297,7 @@ public class GridField
|
||||||
// ** dynamic content **
|
// ** dynamic content **
|
||||||
if (checkContext)
|
if (checkContext)
|
||||||
{
|
{
|
||||||
if (m_vo.DisplayLogic.startsWith("@SQL=")) {
|
if (m_vo.DisplayLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
return Evaluator.parseSQLLogic(m_vo.DisplayLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
return Evaluator.parseSQLLogic(m_vo.DisplayLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
||||||
}
|
}
|
||||||
Evaluatee evaluatee = new Evaluatee() {
|
Evaluatee evaluatee = new Evaluatee() {
|
||||||
|
@ -1342,7 +1342,7 @@ public class GridField
|
||||||
// ** dynamic content **
|
// ** dynamic content **
|
||||||
if (checkContext)
|
if (checkContext)
|
||||||
{
|
{
|
||||||
if (m_vo.DisplayLogic.startsWith("@SQL=")) {
|
if (m_vo.DisplayLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
return Evaluator.parseSQLLogic(m_vo.DisplayLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
return Evaluator.parseSQLLogic(m_vo.DisplayLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
|
||||||
}
|
}
|
||||||
Evaluatee evaluatee = new Evaluatee() {
|
Evaluatee evaluatee = new Evaluatee() {
|
||||||
|
@ -1434,7 +1434,7 @@ public class GridField
|
||||||
if (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0)
|
if (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0)
|
||||||
{
|
{
|
||||||
String query;
|
String query;
|
||||||
if (m_vo.ColumnSQL.startsWith("@SQL=") || m_vo.ColumnSQL.startsWith("@SQLFIND="))
|
if (m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX))
|
||||||
query = "NULL";
|
query = "NULL";
|
||||||
else
|
else
|
||||||
query = m_vo.ColumnSQL;
|
query = m_vo.ColumnSQL;
|
||||||
|
@ -1455,9 +1455,9 @@ public class GridField
|
||||||
if (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0)
|
if (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0)
|
||||||
{
|
{
|
||||||
String query;
|
String query;
|
||||||
if (m_vo.ColumnSQL.startsWith("@SQL="))
|
if (m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
query = "NULL";
|
query = "NULL";
|
||||||
else if (m_vo.ColumnSQL.startsWith("@SQLFIND="))
|
else if (m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX))
|
||||||
query = m_vo.ColumnSQL.substring(9);
|
query = m_vo.ColumnSQL.substring(9);
|
||||||
else
|
else
|
||||||
query = m_vo.ColumnSQL;
|
query = m_vo.ColumnSQL;
|
||||||
|
@ -1481,7 +1481,7 @@ public class GridField
|
||||||
*/
|
*/
|
||||||
public boolean isVirtualDBColumn()
|
public boolean isVirtualDBColumn()
|
||||||
{
|
{
|
||||||
return (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && !m_vo.ColumnSQL.startsWith("@SQL="));
|
return (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && !m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX));
|
||||||
} // isVirtualDBColumn
|
} // isVirtualDBColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1490,7 +1490,7 @@ public class GridField
|
||||||
*/
|
*/
|
||||||
public boolean isVirtualUIColumn()
|
public boolean isVirtualUIColumn()
|
||||||
{
|
{
|
||||||
return (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && m_vo.ColumnSQL.startsWith("@SQL="));
|
return (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX));
|
||||||
} // isVirtualUIColumn
|
} // isVirtualUIColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1499,7 +1499,7 @@ public class GridField
|
||||||
*/
|
*/
|
||||||
public boolean isVirtualSearchColumn()
|
public boolean isVirtualSearchColumn()
|
||||||
{
|
{
|
||||||
return (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && m_vo.ColumnSQL.startsWith("@SQLFIND="));
|
return (m_vo.ColumnSQL != null && m_vo.ColumnSQL.length() > 0 && m_vo.ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX));
|
||||||
} // isVirtualDBColumn
|
} // isVirtualDBColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class GridFieldVO implements Serializable, Cloneable
|
||||||
vo.IsQuickForm = "Y".equals(rs.getString ("IsQuickForm"));
|
vo.IsQuickForm = "Y".equals(rs.getString ("IsQuickForm"));
|
||||||
{
|
{
|
||||||
vo.ColumnSQL = rs.getString("ColumnSQL");
|
vo.ColumnSQL = rs.getString("ColumnSQL");
|
||||||
if (vo.ColumnSQL != null && !vo.ColumnSQL.startsWith("@SQL=") && !vo.ColumnSQL.startsWith("@SQLFIND=") && vo.ColumnSQL.contains("@")) {
|
if (vo.ColumnSQL != null && !vo.ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) && !vo.ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX) && vo.ColumnSQL.contains("@")) {
|
||||||
// NOTE: cannot use window context because this is set globally on the query, not per record
|
// NOTE: cannot use window context because this is set globally on the query, not per record
|
||||||
vo.ColumnSQL = Env.parseContext(ctx, -1, vo.ColumnSQL, false, true);
|
vo.ColumnSQL = Env.parseContext(ctx, -1, vo.ColumnSQL, false, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class InfoRelatedVO implements Serializable, Cloneable, IInfoColumn {
|
||||||
if (Util.isEmpty(getDisplayLogic()))
|
if (Util.isEmpty(getDisplayLogic()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (getDisplayLogic().startsWith("@SQL=")) {
|
if (getDisplayLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
return Evaluator.parseSQLLogic(DisplayLogic, ctx, WindowNo, 0, infoRelated.toString());
|
return Evaluator.parseSQLLogic(DisplayLogic, ctx, WindowNo, 0, infoRelated.toString());
|
||||||
}
|
}
|
||||||
Evaluatee evaluatee = new Evaluatee() {
|
Evaluatee evaluatee = new Evaluatee() {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class LookupDisplayColumn implements Serializable
|
||||||
IsTranslated = isTranslated;
|
IsTranslated = isTranslated;
|
||||||
DisplayType = ad_Reference_ID;
|
DisplayType = ad_Reference_ID;
|
||||||
AD_Reference_ID = ad_Reference_Value_ID;
|
AD_Reference_ID = ad_Reference_Value_ID;
|
||||||
if (columnSQL != null && columnSQL.length() > 0 && (columnSQL.startsWith("@SQL=") || columnSQL.startsWith("@SQLFIND=")))
|
if (columnSQL != null && columnSQL.length() > 0 && (columnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || columnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX)))
|
||||||
ColumnSQL = "NULL";
|
ColumnSQL = "NULL";
|
||||||
else
|
else
|
||||||
ColumnSQL = columnSQL;
|
ColumnSQL = columnSQL;
|
||||||
|
|
|
@ -51,6 +51,10 @@ import org.idempiere.expression.logic.LogicEvaluator;
|
||||||
*/
|
*/
|
||||||
public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
{
|
{
|
||||||
|
public static final String VIRTUAL_SEARCH_COLUMN_PREFIX = "@SQLFIND=";
|
||||||
|
|
||||||
|
public static final String VIRTUAL_UI_COLUMN_PREFIX = "@SQL=";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
|
@ -311,7 +315,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
public boolean isVirtualDBColumn()
|
public boolean isVirtualDBColumn()
|
||||||
{
|
{
|
||||||
String s = getColumnSQL();
|
String s = getColumnSQL();
|
||||||
return s != null && s.length() > 0 && !s.startsWith("@SQL=");
|
return s != null && s.length() > 0 && !s.startsWith(VIRTUAL_UI_COLUMN_PREFIX) && !s.startsWith(VIRTUAL_SEARCH_COLUMN_PREFIX);
|
||||||
} // isVirtualDBColumn
|
} // isVirtualDBColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,7 +325,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
public boolean isVirtualUIColumn()
|
public boolean isVirtualUIColumn()
|
||||||
{
|
{
|
||||||
String s = getColumnSQL();
|
String s = getColumnSQL();
|
||||||
return s != null && s.length() > 0 && s.startsWith("@SQL=");
|
return s != null && s.length() > 0 && s.startsWith(VIRTUAL_UI_COLUMN_PREFIX);
|
||||||
} // isVirtualUIColumn
|
} // isVirtualUIColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,7 +335,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
public boolean isVirtualSearchColumn()
|
public boolean isVirtualSearchColumn()
|
||||||
{
|
{
|
||||||
String s = getColumnSQL();
|
String s = getColumnSQL();
|
||||||
return s != null && s.length() > 0 && s.startsWith("@SQLFIND=");
|
return s != null && s.length() > 0 && s.startsWith(VIRTUAL_SEARCH_COLUMN_PREFIX);
|
||||||
} // isVirtualSearchColumn
|
} // isVirtualSearchColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -540,7 +544,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
|
|
||||||
//validate readonly logic expression
|
//validate readonly logic expression
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith(VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getReadOnlyLogic());
|
LogicEvaluator.validate(getReadOnlyLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1375,11 +1379,11 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
public String getColumnSQL(boolean nullForUI, boolean nullForSearch) {
|
public String getColumnSQL(boolean nullForUI, boolean nullForSearch) {
|
||||||
String query = getColumnSQL();
|
String query = getColumnSQL();
|
||||||
if (query != null && query.length() > 0) {
|
if (query != null && query.length() > 0) {
|
||||||
if (query.startsWith("@SQL=") && nullForUI)
|
if (query.startsWith(VIRTUAL_UI_COLUMN_PREFIX) && nullForUI)
|
||||||
query = "NULL";
|
query = "NULL";
|
||||||
else if (query.startsWith("@SQLFIND=") && nullForSearch)
|
else if (query.startsWith(VIRTUAL_SEARCH_COLUMN_PREFIX) && nullForSearch)
|
||||||
query = "NULL";
|
query = "NULL";
|
||||||
else if (query.startsWith("@SQLFIND=") && !nullForSearch)
|
else if (query.startsWith(VIRTUAL_SEARCH_COLUMN_PREFIX) && !nullForSearch)
|
||||||
query = query.substring(9);
|
query = query.substring(9);
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
|
|
|
@ -236,17 +236,17 @@ public class MField extends X_AD_Field implements ImmutablePOSupport
|
||||||
|
|
||||||
//validate logic expression
|
//validate logic expression
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getReadOnlyLogic());
|
LogicEvaluator.validate(getReadOnlyLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_DisplayLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_DisplayLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getDisplayLogic(), true) && !getDisplayLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getDisplayLogic(), true) && !getDisplayLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getDisplayLogic());
|
LogicEvaluator.validate(getDisplayLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_MandatoryLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_MandatoryLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getMandatoryLogic(), true) && !getMandatoryLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getMandatoryLogic(), true) && !getMandatoryLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getMandatoryLogic());
|
LogicEvaluator.validate(getMandatoryLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,7 +436,7 @@ public class MLookupFactory
|
||||||
ZoomWindow = rs.getInt(8);
|
ZoomWindow = rs.getInt(8);
|
||||||
ZoomWindowPO = rs.getInt(9);
|
ZoomWindowPO = rs.getInt(9);
|
||||||
displayColumnSQL = rs.getString(11);
|
displayColumnSQL = rs.getString(11);
|
||||||
if (displayColumnSQL != null && displayColumnSQL.length() > 0 && (displayColumnSQL.startsWith("@SQL=") || displayColumnSQL.startsWith("@SQLFIND=")))
|
if (displayColumnSQL != null && displayColumnSQL.length() > 0 && (displayColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || displayColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX)))
|
||||||
displayColumnSQL = "NULL";
|
displayColumnSQL = "NULL";
|
||||||
if (displayColumnSQL != null && displayColumnSQL.contains("@"))
|
if (displayColumnSQL != null && displayColumnSQL.contains("@"))
|
||||||
displayColumnSQL = Env.parseContext(Env.getCtx(), -1, displayColumnSQL, false, true);
|
displayColumnSQL = Env.parseContext(Env.getCtx(), -1, displayColumnSQL, false, true);
|
||||||
|
|
|
@ -358,12 +358,12 @@ public class MProcessPara extends X_AD_Process_Para implements ImmutablePOSuppor
|
||||||
|
|
||||||
//validate logic expression
|
//validate logic expression
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getReadOnlyLogic());
|
LogicEvaluator.validate(getReadOnlyLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_DisplayLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_DisplayLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getDisplayLogic(), true) && !getDisplayLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getDisplayLogic(), true) && !getDisplayLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getDisplayLogic());
|
LogicEvaluator.validate(getDisplayLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,17 +213,17 @@ public class MUserDefField extends X_AD_UserDef_Field implements ImmutablePOSupp
|
||||||
|
|
||||||
//validate logic expression
|
//validate logic expression
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_ReadOnlyLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getReadOnlyLogic(), true) && !getReadOnlyLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getReadOnlyLogic());
|
LogicEvaluator.validate(getReadOnlyLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_DisplayLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_DisplayLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getDisplayLogic(), true) && !getDisplayLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getDisplayLogic(), true) && !getDisplayLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getDisplayLogic());
|
LogicEvaluator.validate(getDisplayLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_MandatoryLogic)) {
|
if (newRecord || is_ValueChanged(COLUMNNAME_MandatoryLogic)) {
|
||||||
if (isActive() && !Util.isEmpty(getMandatoryLogic(), true) && !getMandatoryLogic().startsWith("@SQL=")) {
|
if (isActive() && !Util.isEmpty(getMandatoryLogic(), true) && !getMandatoryLogic().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
LogicEvaluator.validate(getMandatoryLogic());
|
LogicEvaluator.validate(getMandatoryLogic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,7 +340,7 @@ public class MUserQuery extends X_AD_UserQuery
|
||||||
get_Value(COLUMNNAME_AD_User_ID) == null) //Cannot save privately (user-specific) an already existing global query
|
get_Value(COLUMNNAME_AD_User_ID) == null) //Cannot save privately (user-specific) an already existing global query
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !getCode().startsWith("@SQL=");
|
return !getCode().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -353,7 +353,7 @@ public class MUserQuery extends X_AD_UserQuery
|
||||||
getAD_Client_ID() != Env.getAD_Client_ID(Env.getCtx())) //Cannot modify a query from another client (e.g. System)
|
getAD_Client_ID() != Env.getAD_Client_ID(Env.getCtx())) //Cannot modify a query from another client (e.g. System)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !getCode().startsWith("@SQL=");
|
return !getCode().startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // MUserQuery
|
} // MUserQuery
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class POInfo implements Serializable
|
||||||
//
|
//
|
||||||
m_AccessLevel = rs.getString(18);
|
m_AccessLevel = rs.getString(18);
|
||||||
String ColumnSQL = rs.getString(19);
|
String ColumnSQL = rs.getString(19);
|
||||||
if (ColumnSQL != null && ColumnSQL.length() > 0 && (ColumnSQL.startsWith("@SQL=") || ColumnSQL.startsWith("@SQLFIND=")))
|
if (ColumnSQL != null && ColumnSQL.length() > 0 && (ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX)))
|
||||||
ColumnSQL = "NULL";
|
ColumnSQL = "NULL";
|
||||||
if (ColumnSQL != null && ColumnSQL.contains("@"))
|
if (ColumnSQL != null && ColumnSQL.contains("@"))
|
||||||
ColumnSQL = Env.parseContext(Env.getCtx(), -1, ColumnSQL, false, true);
|
ColumnSQL = Env.parseContext(Env.getCtx(), -1, ColumnSQL, false, true);
|
||||||
|
@ -381,7 +381,7 @@ public class POInfo implements Serializable
|
||||||
if (index < 0 || index >= m_columns.length)
|
if (index < 0 || index >= m_columns.length)
|
||||||
return null;
|
return null;
|
||||||
if (m_columns[index].ColumnSQL != null && m_columns[index].ColumnSQL.length() > 0) {
|
if (m_columns[index].ColumnSQL != null && m_columns[index].ColumnSQL.length() > 0) {
|
||||||
if (m_columns[index].ColumnSQL.startsWith("@SQL=") || m_columns[index].ColumnSQL.startsWith("@SQLFIND="))
|
if (m_columns[index].ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || m_columns[index].ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX))
|
||||||
return "NULL AS " + m_columns[index].ColumnName;
|
return "NULL AS " + m_columns[index].ColumnName;
|
||||||
return m_columns[index].ColumnSQL + " AS " + m_columns[index].ColumnName;
|
return m_columns[index].ColumnSQL + " AS " + m_columns[index].ColumnName;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ public class POInfo implements Serializable
|
||||||
return true;
|
return true;
|
||||||
return m_columns[index].ColumnSQL != null
|
return m_columns[index].ColumnSQL != null
|
||||||
&& m_columns[index].ColumnSQL.length() > 0
|
&& m_columns[index].ColumnSQL.length() > 0
|
||||||
&& !m_columns[index].ColumnSQL.startsWith("@SQL=");
|
&& !m_columns[index].ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX);
|
||||||
} // isVirtualDBColumn
|
} // isVirtualDBColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,7 +426,7 @@ public class POInfo implements Serializable
|
||||||
return true;
|
return true;
|
||||||
return m_columns[index].ColumnSQL != null
|
return m_columns[index].ColumnSQL != null
|
||||||
&& m_columns[index].ColumnSQL.length() > 0
|
&& m_columns[index].ColumnSQL.length() > 0
|
||||||
&& m_columns[index].ColumnSQL.startsWith("@SQL=");
|
&& m_columns[index].ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX);
|
||||||
} // isVirtualUIColumn
|
} // isVirtualUIColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,7 +440,7 @@ public class POInfo implements Serializable
|
||||||
return true;
|
return true;
|
||||||
return m_columns[index].ColumnSQL != null
|
return m_columns[index].ColumnSQL != null
|
||||||
&& m_columns[index].ColumnSQL.length() > 0
|
&& m_columns[index].ColumnSQL.length() > 0
|
||||||
&& m_columns[index].ColumnSQL.startsWith("@SQLFIND=");
|
&& m_columns[index].ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX);
|
||||||
} // isVirtualSearchColumn
|
} // isVirtualSearchColumn
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.logging.Level;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
import org.compiere.model.MReportView;
|
import org.compiere.model.MReportView;
|
||||||
|
@ -340,9 +341,9 @@ public class DataEngine
|
||||||
int AD_PrintFormatItem_ID = rs.getInt("AD_PrintFormatItem_ID");
|
int AD_PrintFormatItem_ID = rs.getInt("AD_PrintFormatItem_ID");
|
||||||
String ColumnName = rs.getString(2);
|
String ColumnName = rs.getString(2);
|
||||||
String ColumnSQL = rs.getString(24);
|
String ColumnSQL = rs.getString(24);
|
||||||
if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith("@SQLFIND="))
|
if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX))
|
||||||
ColumnSQL = ColumnSQL.substring(9);
|
ColumnSQL = ColumnSQL.substring(9);
|
||||||
if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith("@SQL="))
|
if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
ColumnSQL = "NULL";
|
ColumnSQL = "NULL";
|
||||||
if (ColumnSQL != null && ColumnSQL.contains("@"))
|
if (ColumnSQL != null && ColumnSQL.contains("@"))
|
||||||
ColumnSQL = Env.parseContext(Env.getCtx(), m_windowNo, ColumnSQL, false, true);
|
ColumnSQL = Env.parseContext(Env.getCtx(), m_windowNo, ColumnSQL, false, true);
|
||||||
|
@ -424,9 +425,9 @@ public class DataEngine
|
||||||
// => (..) AS AName, Table.ID,
|
// => (..) AS AName, Table.ID,
|
||||||
if (script != null && !script.isEmpty())
|
if (script != null && !script.isEmpty())
|
||||||
{
|
{
|
||||||
if (script.startsWith("@SQL="))
|
if (script.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
{
|
{
|
||||||
script = "(" + script.replace("@SQL=", "").trim() + ")";
|
script = "(" + script.replace(MColumn.VIRTUAL_UI_COLUMN_PREFIX, "").trim() + ")";
|
||||||
script = Env.parseContext(Env.getCtx(), m_windowNo, script, false);
|
script = Env.parseContext(Env.getCtx(), m_windowNo, script, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.adempiere.base.upload.UploadResponse;
|
||||||
import org.compiere.model.MAttachment;
|
import org.compiere.model.MAttachment;
|
||||||
import org.compiere.model.MAuthorizationAccount;
|
import org.compiere.model.MAuthorizationAccount;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MMailText;
|
import org.compiere.model.MMailText;
|
||||||
import org.compiere.model.MNote;
|
import org.compiere.model.MNote;
|
||||||
import org.compiere.model.MOrgInfo;
|
import org.compiere.model.MOrgInfo;
|
||||||
|
@ -683,7 +684,7 @@ public class Scheduler extends AdempiereServer
|
||||||
if (variable == null
|
if (variable == null
|
||||||
|| (variable != null && variable.length() == 0))
|
|| (variable != null && variable.length() == 0))
|
||||||
value = null;
|
value = null;
|
||||||
else if (variable.startsWith("@SQL=")) {
|
else if (variable.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
String defStr = "";
|
String defStr = "";
|
||||||
String sql = variable.substring(5); // w/o tag
|
String sql = variable.substring(5); // w/o tag
|
||||||
//sql = Env.parseContext(m_vo.ctx, m_vo.WindowNo, sql, false, true); // replace variables
|
//sql = Env.parseContext(m_vo.ctx, m_vo.WindowNo, sql, false, true); // replace variables
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.adempiere.base.IServiceHolder;
|
||||||
import org.adempiere.webui.action.Actions;
|
import org.adempiere.webui.action.Actions;
|
||||||
import org.adempiere.webui.action.IAction;
|
import org.adempiere.webui.action.IAction;
|
||||||
import org.adempiere.webui.component.ToolBarButton;
|
import org.adempiere.webui.component.ToolBarButton;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MToolBarButton;
|
import org.compiere.model.MToolBarButton;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Evaluatee;
|
import org.compiere.util.Evaluatee;
|
||||||
|
@ -120,7 +121,7 @@ public class ToolbarCustomButton implements EventListener<Event>, Evaluatee {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean visible = true;
|
boolean visible = true;
|
||||||
if (displayLogic.startsWith("@SQL=")) {
|
if (displayLogic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
ADWindow adwindow = ADWindow.get(windowNo);
|
ADWindow adwindow = ADWindow.get(windowNo);
|
||||||
if (adwindow == null)
|
if (adwindow == null)
|
||||||
return;
|
return;
|
||||||
|
@ -200,7 +201,7 @@ public class ToolbarCustomButton implements EventListener<Event>, Evaluatee {
|
||||||
private boolean validateLogic(String logic, int tabNo) {
|
private boolean validateLogic(String logic, int tabNo) {
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
|
|
||||||
if (logic.startsWith("@SQL="))
|
if (logic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
{
|
{
|
||||||
isValid = Evaluator.parseSQLLogic(logic, Env.getCtx(), windowNo, tabNo, "");
|
isValid = Evaluator.parseSQLLogic(logic, Env.getCtx(), windowNo, tabNo, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.adempiere.webui.editor.IProcessButton;
|
||||||
import org.adempiere.webui.event.ActionEvent;
|
import org.adempiere.webui.event.ActionEvent;
|
||||||
import org.adempiere.webui.event.ActionListener;
|
import org.adempiere.webui.event.ActionListener;
|
||||||
import org.compiere.model.I_AD_Process;
|
import org.compiere.model.I_AD_Process;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
import org.compiere.model.MToolBarButton;
|
import org.compiere.model.MToolBarButton;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
@ -189,7 +190,7 @@ public class ToolbarProcessButton implements IProcessButton, Evaluatee {
|
||||||
*/
|
*/
|
||||||
private boolean validateLogic(String logic, int tabNo) {
|
private boolean validateLogic(String logic, int tabNo) {
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
if (logic.startsWith("@SQL=")) {
|
if (logic.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
isValid = Evaluator.parseSQLLogic(logic, Env.getCtx(), windowNo, tabNo, getColumnName());
|
isValid = Evaluator.parseSQLLogic(logic, Env.getCtx(), windowNo, tabNo, getColumnName());
|
||||||
} else {
|
} else {
|
||||||
isValid = Evaluator.evaluateLogic(this, logic);
|
isValid = Evaluator.evaluateLogic(this, logic);
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.adempiere.webui.window.ZkReportViewerProvider;
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
import org.compiere.model.I_AD_Menu;
|
import org.compiere.model.I_AD_Menu;
|
||||||
import org.compiere.model.MChart;
|
import org.compiere.model.MChart;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MDashboardContent;
|
import org.compiere.model.MDashboardContent;
|
||||||
import org.compiere.model.MDashboardContentAccess;
|
import org.compiere.model.MDashboardContentAccess;
|
||||||
import org.compiere.model.MDashboardPreference;
|
import org.compiere.model.MDashboardPreference;
|
||||||
|
@ -1732,7 +1733,7 @@ public class DashboardController implements EventListener<Event> {
|
||||||
if (paramValue == null
|
if (paramValue == null
|
||||||
|| (paramValue != null && paramValue.length() == 0))
|
|| (paramValue != null && paramValue.length() == 0))
|
||||||
value = null;
|
value = null;
|
||||||
else if (paramValue.startsWith("@SQL=")) {
|
else if (paramValue.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
String sql = paramValue.substring(5);
|
String sql = paramValue.substring(5);
|
||||||
sql = Env.parseContext(Env.getCtx(), 0, sql, false, false); // replace variables
|
sql = Env.parseContext(Env.getCtx(), 0, sql, false, false); // replace variables
|
||||||
if (!Util.isEmpty(sql)) {
|
if (!Util.isEmpty(sql)) {
|
||||||
|
|
|
@ -550,7 +550,7 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
boolean isDisplayed = rs.getString(4).equals("Y");
|
boolean isDisplayed = rs.getString(4).equals("Y");
|
||||||
int AD_Reference_Value_ID = rs.getInt(5);
|
int AD_Reference_Value_ID = rs.getInt(5);
|
||||||
String columnSql = rs.getString(6);
|
String columnSql = rs.getString(6);
|
||||||
if (columnSql != null && columnSql.length() > 0 && (columnSql.startsWith("@SQL=") || columnSql.startsWith("@SQLFIND=")))
|
if (columnSql != null && columnSql.length() > 0 && (columnSql.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || columnSql.startsWith(MColumn.VIRTUAL_SEARCH_COLUMN_PREFIX)))
|
||||||
columnSql = "NULL";
|
columnSql = "NULL";
|
||||||
if (columnSql != null && columnSql.contains("@"))
|
if (columnSql != null && columnSql.contains("@"))
|
||||||
columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true);
|
columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true);
|
||||||
|
|
|
@ -2052,7 +2052,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String code = userQuery.getCode();
|
String code = userQuery.getCode();
|
||||||
if (code.startsWith("@SQL=")) {
|
if (code.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
m_whereUserQuery = "(" + code.substring(code.indexOf("=")+1, code.length()) + ")";
|
m_whereUserQuery = "(" + code.substring(code.indexOf("=")+1, code.length()) + ")";
|
||||||
if (log.isLoggable(Level.INFO))
|
if (log.isLoggable(Level.INFO))
|
||||||
log.log(Level.INFO, m_whereUserQuery);
|
log.log(Level.INFO, m_whereUserQuery);
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
import org.compiere.model.MProcessDrillRule;
|
import org.compiere.model.MProcessDrillRule;
|
||||||
import org.compiere.model.MProcessDrillRulePara;
|
import org.compiere.model.MProcessDrillRulePara;
|
||||||
|
@ -660,7 +661,7 @@ public class DrillReportCtl {
|
||||||
if (variable == null
|
if (variable == null
|
||||||
|| (variable != null && variable.length() == 0))
|
|| (variable != null && variable.length() == 0))
|
||||||
value = null;
|
value = null;
|
||||||
else if (variable.startsWith("@SQL=")) {
|
else if (variable.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX)) {
|
||||||
String defStr = "";
|
String defStr = "";
|
||||||
String sql = variable.substring(5); // w/o tag
|
String sql = variable.substring(5); // w/o tag
|
||||||
//hengsin, capture unparseable error to avoid subsequent sql exception
|
//hengsin, capture unparseable error to avoid subsequent sql exception
|
||||||
|
|
|
@ -580,7 +580,7 @@ public class LogicExpressionTest extends AbstractTestCase {
|
||||||
ResultSet rs = stmt.executeQuery();
|
ResultSet rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String expr = rs.getString(mc.getColumnName());
|
String expr = rs.getString(mc.getColumnName());
|
||||||
if (expr.startsWith("@SQL=") || expr.startsWith("SQL="))
|
if (expr.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX) || expr.startsWith("SQL="))
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
LogicEvaluator.validate(expr);
|
LogicEvaluator.validate(expr);
|
||||||
|
|
|
@ -43,10 +43,12 @@ import org.compiere.model.I_AD_UserPreference;
|
||||||
import org.compiere.model.MAcctSchema;
|
import org.compiere.model.MAcctSchema;
|
||||||
import org.compiere.model.MBPartner;
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MMessage;
|
import org.compiere.model.MMessage;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.MProductCategory;
|
import org.compiere.model.MProductCategory;
|
||||||
import org.compiere.model.MProductCategoryAcct;
|
import org.compiere.model.MProductCategoryAcct;
|
||||||
|
import org.compiere.model.MProductionLine;
|
||||||
import org.compiere.model.MTest;
|
import org.compiere.model.MTest;
|
||||||
import org.compiere.model.POInfo;
|
import org.compiere.model.POInfo;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -553,4 +555,30 @@ public class POTest extends AbstractTestCase
|
||||||
assertTrue(file.exists(), "Not found: " + folderOr + fileName);
|
assertTrue(file.exists(), "Not found: " + folderOr + fileName);
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsVirtualColumnMethods() {
|
||||||
|
//column sql with no prefix
|
||||||
|
MColumn column = MColumn.get(Env.getCtx(), MTest.Table_Name, MTest.COLUMNNAME_TestVirtualQty);
|
||||||
|
assertTrue(column.isVirtualColumn(), "MColumn.isVirtualColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertTrue(column.isVirtualDBColumn(), "MColumn.isVirtualDBColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertFalse(column.isVirtualUIColumn(), "MColumn.isVirtualUIColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertFalse(column.isVirtualSearchColumn(), "MColumn.isVirtualSearchColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
|
||||||
|
//column sql with @SQLFIND= prefix
|
||||||
|
column = MColumn.get(Env.getCtx(), MProductionLine.Table_Name, "ProductType");
|
||||||
|
assertTrue(column.isVirtualColumn(), "MColumn.isVirtualColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertFalse(column.isVirtualDBColumn(), "MColumn.isVirtualDBColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertFalse(column.isVirtualUIColumn(), "MColumn.isVirtualUIColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertTrue(column.isVirtualSearchColumn(), "MColumn.isVirtualSearchColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
|
||||||
|
//column sql with @SQL= prefix
|
||||||
|
column = MColumn.get(Env.getCtx(), MTest.Table_Name, MTest.COLUMNNAME_TestVirtualQty);
|
||||||
|
column = new MColumn(column);
|
||||||
|
column.setColumnSQL(MColumn.VIRTUAL_UI_COLUMN_PREFIX+column.getColumnSQL());
|
||||||
|
assertTrue(column.isVirtualColumn(), "MColumn.isVirtualColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertFalse(column.isVirtualDBColumn(), "MColumn.isVirtualDBColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertTrue(column.isVirtualUIColumn(), "MColumn.isVirtualUIColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
assertFalse(column.isVirtualSearchColumn(), "MColumn.isVirtualSearchColumn() not working as expected for ColumnSQL="+column.getColumnSQL());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.adempiere.base.equinox.EquinoxExtensionLocator;
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.compiere.model.Lookup;
|
import org.compiere.model.Lookup;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MUser;
|
import org.compiere.model.MUser;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.POInfo;
|
import org.compiere.model.POInfo;
|
||||||
|
@ -390,7 +391,7 @@ public class AbstractService {
|
||||||
* @throws AdempiereException
|
* @throws AdempiereException
|
||||||
*/
|
*/
|
||||||
protected String parseSQL(String sql, ArrayList<Object> sqlParas, PO po,POInfo poInfo, Map<String, Object> requestCtx) throws AdempiereException {
|
protected String parseSQL(String sql, ArrayList<Object> sqlParas, PO po,POInfo poInfo, Map<String, Object> requestCtx) throws AdempiereException {
|
||||||
if (sql.startsWith("@SQL="))
|
if (sql.startsWith(MColumn.VIRTUAL_UI_COLUMN_PREFIX))
|
||||||
sql = sql.substring(5);
|
sql = sql.substring(5);
|
||||||
|
|
||||||
if (sql.toLowerCase().indexOf(" where ") == -1)
|
if (sql.toLowerCase().indexOf(" where ") == -1)
|
||||||
|
|
Loading…
Reference in New Issue