diff --git a/modules/global/src/com/haulmont/cuba/security/global/UserSession.java b/modules/global/src/com/haulmont/cuba/security/global/UserSession.java
index 5bedf3fd7f..535f9e769c 100644
--- a/modules/global/src/com/haulmont/cuba/security/global/UserSession.java
+++ b/modules/global/src/com/haulmont/cuba/security/global/UserSession.java
@@ -210,11 +210,14 @@ public class UserSession implements Serializable
/**
* Get user session attribute. Attribute is a named serializable object bound to session.
- * @param name attribute name
+ * @param name attribute name, or userId
to obtain current or substituted user ID
* @return attribute value
*/
- public T getAttribute(String name) {
- return (T) attributes.get(name);
+ public T getAttribute(String name) {
+ if ("userId".equals(name))
+ return (T) (substitutedUser == null ? user.getId() : substitutedUser.getId());
+ else
+ return (T) attributes.get(name);
}
/**
diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/impl/AbstractCollectionDatasource.java b/modules/gui/src/com/haulmont/cuba/gui/data/impl/AbstractCollectionDatasource.java
index 06b6488277..d107a09f76 100644
--- a/modules/gui/src/com/haulmont/cuba/gui/data/impl/AbstractCollectionDatasource.java
+++ b/modules/gui/src/com/haulmont/cuba/gui/data/impl/AbstractCollectionDatasource.java
@@ -192,10 +192,7 @@ public abstract class AbstractCollectionDatasource, K>
case SESSION: {
Object value;
UserSession us = UserSessionClient.getUserSession();
- if ("userId".equals(path))
- value = us.getSubstitutedUser() != null ? us.getSubstitutedUser().getId() : us.getUser().getId();
- else
- value = us.getAttribute(path);
+ value = us.getAttribute(path);
if (value instanceof String && info.isCaseInsensitive()) {
value = makeCaseInsensitive((String) value);
diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/filter/CustomConditionEditDlg.java b/modules/web/src/com/haulmont/cuba/web/gui/components/filter/CustomConditionEditDlg.java
index dfdf2033de..01bd52b788 100644
--- a/modules/web/src/com/haulmont/cuba/web/gui/components/filter/CustomConditionEditDlg.java
+++ b/modules/web/src/com/haulmont/cuba/web/gui/components/filter/CustomConditionEditDlg.java
@@ -109,7 +109,7 @@ public class CustomConditionEditDlg extends Window {
whereText = new TextField();
whereText.setWidth(FIELD_WIDTH);
- whereText.setRows(2);
+ whereText.setRows(4);
whereText.setNullRepresentation("");
String where = replaceParamWithQuestionMark(condition.getWhere());
whereText.setValue(where);
@@ -238,7 +238,13 @@ public class CustomConditionEditDlg extends Window {
String res = where.trim();
if (!StringUtils.isBlank(res)) {
Matcher matcher = QueryParserRegex.PARAM_PATTERN.matcher(res);
- res = matcher.replaceAll("?");
+ StringBuffer sb = new StringBuffer();
+ while (matcher.find()) {
+ if (!matcher.group().startsWith(":session$"))
+ matcher.appendReplacement(sb, "?");
+ }
+ matcher.appendTail(sb);
+ return sb.toString();
}
return res;
}
@@ -329,6 +335,8 @@ public class CustomConditionEditDlg extends Window {
select.setValue(ParamType.BOOLEAN);
else if (Number.class.equals(param.getJavaClass()))
select.setValue(ParamType.NUMBER);
+ else if (UUID.class.equals(param.getJavaClass()))
+ select.setValue(ParamType.UUID);
else
throw new UnsupportedOperationException("Unsupported param class: " + param.getJavaClass());
break;