diff --git a/modules/global/src/com/haulmont/chile/jpa/loader/JPAAnnotationsLoader.java b/modules/global/src/com/haulmont/chile/jpa/loader/JPAAnnotationsLoader.java
index 1d8d64e35a..de48fb8c3c 100644
--- a/modules/global/src/com/haulmont/chile/jpa/loader/JPAAnnotationsLoader.java
+++ b/modules/global/src/com/haulmont/chile/jpa/loader/JPAAnnotationsLoader.java
@@ -2,10 +2,6 @@
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
-
- * Author: FIRSTNAME LASTNAME
- * Created: 06.11.2008 9:49:55
- * $Id: JPAAnnotationsLoader.java 5981 2011-09-20 07:35:58Z krivopustov $
*/
package com.haulmont.chile.jpa.loader;
@@ -17,6 +13,7 @@ import com.haulmont.chile.core.model.Range;
import com.haulmont.chile.core.model.Session;
import com.haulmont.chile.core.model.MetaProperty;
import com.haulmont.chile.core.model.impl.MetaClassImpl;
+import com.haulmont.cuba.core.entity.annotation.SystemLevel;
import org.apache.commons.lang.StringUtils;
import static org.apache.commons.lang.StringUtils.isBlank;
@@ -35,6 +32,10 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
+/**
+ * @author krivopustov
+ * @version $Id$
+ */
public class JPAAnnotationsLoader extends ChileAnnotationsLoader implements ClassMetadataLoader {
private Log log = LogFactory.getLog(JPAMetadataLoader.class);
@@ -236,6 +237,11 @@ public class JPAAnnotationsLoader extends ChileAnnotationsLoader implements Clas
if (temporal != null) {
metaProperty.getAnnotations().put("temporal", temporal.value());
}
+
+ SystemLevel systemLevel = field.getAnnotation(SystemLevel.class);
+ if (systemLevel != null) {
+ metaProperty.getAnnotations().put("system", true);
+ }
}
protected boolean isPersistent(Field field) {
@@ -246,4 +252,4 @@ public class JPAAnnotationsLoader extends ChileAnnotationsLoader implements Clas
|| field.isAnnotationPresent(ManyToMany.class)
|| field.isAnnotationPresent(Embedded.class);
}
-}
+}
\ No newline at end of file
diff --git a/modules/global/src/com/haulmont/cuba/core/entity/annotation/SystemLevel.java b/modules/global/src/com/haulmont/cuba/core/entity/annotation/SystemLevel.java
index 56290d5756..2b09d319a8 100644
--- a/modules/global/src/com/haulmont/cuba/core/entity/annotation/SystemLevel.java
+++ b/modules/global/src/com/haulmont/cuba/core/entity/annotation/SystemLevel.java
@@ -12,14 +12,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Indicates that annotated entity is low-level and should not be available for end-user in various entity lists.
+ * Indicates that annotated entity/field is low-level and should not be available for end-user in various entity/field lists.
+ * For field indicates that attribute should not be available for dynamic filters in UI.
*
* @author krivopustov
* @version $Id$
*/
-@Target({ElementType.TYPE})
+@Target({ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SystemLevel {
boolean value() default true;
-}
+}
\ No newline at end of file
diff --git a/modules/global/src/com/haulmont/cuba/security/entity/User.java b/modules/global/src/com/haulmont/cuba/security/entity/User.java
index 2b0ffdcf85..a9f42d7a29 100644
--- a/modules/global/src/com/haulmont/cuba/security/entity/User.java
+++ b/modules/global/src/com/haulmont/cuba/security/entity/User.java
@@ -15,6 +15,7 @@ import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.cuba.core.entity.StandardEntity;
import com.haulmont.cuba.core.entity.annotation.Listeners;
import com.haulmont.cuba.core.entity.annotation.OnDeleteInverse;
+import com.haulmont.cuba.core.entity.annotation.SystemLevel;
import com.haulmont.cuba.core.entity.annotation.TrackEditScreenHistory;
import com.haulmont.cuba.core.global.DeletePolicy;
import com.haulmont.cuba.core.sys.AppContext;
@@ -42,9 +43,11 @@ public class User extends StandardEntity {
@Column(name = "LOGIN", length = LOGIN_FIELD_LEN, nullable = false)
protected String login;
+ @SystemLevel
@Column(name = "LOGIN_LC", length = LOGIN_FIELD_LEN, nullable = false)
protected String loginLowerCase;
+ @SystemLevel
@Column(name = "PASSWORD", length = 255)
protected String password;
@@ -254,4 +257,4 @@ public class User extends StandardEntity {
public String getSalt() {
return id != null ? id.toString() : "";
}
-}
+}
\ No newline at end of file
diff --git a/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse-filter.xml b/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse-filter.xml
deleted file mode 100644
index 8d722dfcd1..0000000000
--- a/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse-filter.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
- select g from sec$Group g
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse.xml b/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse.xml
index 1e054db1ec..9fda7137e9 100644
--- a/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse.xml
+++ b/modules/gui/src/com/haulmont/cuba/gui/app/security/user/browse/user-browse.xml
@@ -26,7 +26,7 @@
-
+
(h.parent.id = ? or h.group.id = ?) or (u.group.id = ? and h.parent is null)
@@ -73,4 +73,4 @@
-
+
\ No newline at end of file
diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/ModelPropertiesFilter.java b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/ModelPropertiesFilter.java
new file mode 100644
index 0000000000..12caa7ef9d
--- /dev/null
+++ b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/ModelPropertiesFilter.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
+ * Haulmont Technology proprietary and confidential.
+ * Use is subject to license terms.
+ */
+
+package com.haulmont.cuba.gui.components.filter.addcondition;
+
+import com.haulmont.chile.core.model.MetaProperty;
+import com.haulmont.cuba.core.global.AppBeans;
+import com.haulmont.cuba.core.global.MessageTools;
+import com.haulmont.cuba.core.global.UserSessionSource;
+import com.haulmont.cuba.security.entity.EntityAttrAccess;
+import com.haulmont.cuba.security.global.UserSession;
+import org.apache.commons.lang.BooleanUtils;
+
+/**
+ * @author artamonov
+ * @version $Id$
+ */
+public class ModelPropertiesFilter {
+
+ private UserSession userSession;
+ private final MessageTools messageTools;
+
+ public ModelPropertiesFilter() {
+ userSession = AppBeans.get(UserSessionSource.class).getUserSession();
+ messageTools = AppBeans.get(MessageTools.class);
+ }
+
+ public boolean isPropertyFilterAllowed(MetaProperty property) {
+ if (userSession.isEntityAttrPermitted(property.getDomain(), property.getName(), EntityAttrAccess.VIEW)) {
+ // exclude system level attributes
+ Boolean systemLevel = (Boolean) property.getAnnotations().get("system");
+ if (!BooleanUtils.isTrue(systemLevel)) {
+ // exclude not localized properties (they are usually not for end user) and ToMany
+ if (messageTools.hasPropertyCaption(property) && !property.getRange().getCardinality().isMany()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/PropertyModelItem.java b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/PropertyModelItem.java
index aef3ea2e5b..f3d5690b05 100644
--- a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/PropertyModelItem.java
+++ b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/PropertyModelItem.java
@@ -9,10 +9,7 @@ package com.haulmont.cuba.gui.components.filter.addcondition;
import com.haulmont.chile.core.model.MetaProperty;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.MessageTools;
-import com.haulmont.cuba.core.global.UserSessionProvider;
import com.haulmont.cuba.gui.components.filter.AbstractConditionDescriptor;
-import com.haulmont.cuba.security.entity.EntityAttrAccess;
-import com.haulmont.cuba.security.global.UserSession;
import javax.annotation.Nonnull;
import java.util.ArrayList;
@@ -20,11 +17,10 @@ import java.util.Collections;
import java.util.List;
/**
- * Property node.
- *
- * $Id$
+ * Property node
*
* @author krivopustov
+ * @version $Id$
*/
public class PropertyModelItem implements ModelItem {
@@ -64,16 +60,11 @@ public class PropertyModelItem implements ModelItem {
if (metaProperty.getRange().isClass()) {
List list = new ArrayList<>();
- UserSession userSession = UserSessionProvider.getUserSession();
+ ModelPropertiesFilter propertiesFilter = new ModelPropertiesFilter();
for (MetaProperty property : metaProperty.getRange().asClass().getProperties()) {
- // check permissions
- if (userSession.isEntityAttrPermitted(property.getDomain(), property.getName(), EntityAttrAccess.VIEW)) {
- // exclude not localized properties (they are usually not for end user) and ToMany
- if (AppBeans.get(MessageTools.class).hasPropertyCaption(property) && !property.getRange().getCardinality().isMany()) {
- list.add(new PropertyModelItem(this, property, null, descriptorBuilder));
- }
- }
+ if (propertiesFilter.isPropertyFilterAllowed(property))
+ list.add(new PropertyModelItem(this, property, null, descriptorBuilder));
}
Collections.sort(list, new ModelItemComparator());
return list;
diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/RootPropertyModelItem.java b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/RootPropertyModelItem.java
index 65b853088b..05898f4bac 100644
--- a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/RootPropertyModelItem.java
+++ b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/RootPropertyModelItem.java
@@ -9,13 +9,11 @@ package com.haulmont.cuba.gui.components.filter.addcondition;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.MetaProperty;
import com.haulmont.chile.core.model.MetaPropertyPath;
-import com.haulmont.cuba.core.global.MessageProvider;
-import com.haulmont.cuba.core.global.UserSessionProvider;
+import com.haulmont.cuba.core.global.AppBeans;
+import com.haulmont.cuba.core.global.Messages;
import com.haulmont.cuba.gui.components.filter.AbstractConditionDescriptor;
import com.haulmont.cuba.gui.components.filter.AbstractFilterEditor;
import com.haulmont.cuba.gui.components.filter.AbstractPropertyConditionDescriptor;
-import com.haulmont.cuba.security.entity.EntityAttrAccess;
-import com.haulmont.cuba.security.global.UserSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -55,7 +53,7 @@ public class RootPropertyModelItem implements ModelItem {
public List getChildren() {
List list = new ArrayList<>();
- UserSession userSession = UserSessionProvider.getUserSession();
+ ModelPropertiesFilter modelPropertiesFilter = new ModelPropertiesFilter();
for (AbstractConditionDescriptor descriptor : propertyDescriptors) {
if (descriptor instanceof AbstractPropertyConditionDescriptor) {
@@ -65,7 +63,8 @@ public class RootPropertyModelItem implements ModelItem {
continue;
}
MetaProperty metaProperty = mpp.getMetaProperty();
- if (userSession.isEntityAttrPermitted(metaClass, metaProperty.getName(), EntityAttrAccess.VIEW))
+
+ if (modelPropertiesFilter.isPropertyFilterAllowed(metaProperty))
list.add(new PropertyModelItem(null, metaProperty, descriptor, descriptorBuilder));
}
}
@@ -76,11 +75,11 @@ public class RootPropertyModelItem implements ModelItem {
@Override
public String getCaption() {
- return MessageProvider.getMessage(AbstractFilterEditor.MESSAGES_PACK, "NewConditionDlg.attributes");
+ return AppBeans.get(Messages.class).getMessage(AbstractFilterEditor.MESSAGES_PACK, "NewConditionDlg.attributes");
}
@Override
public AbstractConditionDescriptor getDescriptor() {
return null;
}
-}
+}
\ No newline at end of file