catch up with development
Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.filter.feature/.project b/org.eclipse.osbp.filter.feature/.project
index c7ab46f..d347c5d 100644
--- a/org.eclipse.osbp.filter.feature/.project
+++ b/org.eclipse.osbp.filter.feature/.project
@@ -16,12 +16,12 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
+ <name>org.sonarlint.eclipse.core.sonarlintBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.sonarlint.eclipse.core.sonarlintBuilder</name>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
diff --git a/org.eclipse.osbp.filter.feature/.settings/org.eclipse.xtend.core.Xtend.prefs b/org.eclipse.osbp.filter.feature/.settings/org.eclipse.xtend.core.Xtend.prefs
index 6155a21..f6a7c78 100644
--- a/org.eclipse.osbp.filter.feature/.settings/org.eclipse.xtend.core.Xtend.prefs
+++ b/org.eclipse.osbp.filter.feature/.settings/org.eclipse.xtend.core.Xtend.prefs
@@ -1,4 +1,5 @@
//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=src/test/generated-sources/xtend
+BuilderConfiguration.is_project_specific=true
eclipse.preferences.version=1
is_project_specific=true
outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
diff --git a/org.eclipse.osbp.filter/META-INF/MANIFEST.MF b/org.eclipse.osbp.filter/META-INF/MANIFEST.MF
index 34622c1..c718970 100644
--- a/org.eclipse.osbp.filter/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.filter/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@
org.eclipse.osbp.authentication.providerimpl;version="0.9.0",
org.eclipse.osbp.dsl.common.datatypes;version="0.9.0",
org.eclipse.osbp.ui.api.useraccess;version="0.9.0",
- org.eclipse.osbp.ui.api.userfilter;version="0.9.0",
+ org.eclipse.osbp.ui.api.user.filter;version="0.9.0",
org.osgi.service.component.annotations;version="1.2.0"
Service-Component: OSGI-INF/*.xml
Export-Package: org.eclipse.osbp.filter
diff --git a/org.eclipse.osbp.filter/src/org/eclipse/osbp/filter/DefaultFilterEnhancer.java b/org.eclipse.osbp.filter/src/org/eclipse/osbp/filter/DefaultFilterEnhancer.java
index 1b00de3..882908d 100644
--- a/org.eclipse.osbp.filter/src/org/eclipse/osbp/filter/DefaultFilterEnhancer.java
+++ b/org.eclipse.osbp.filter/src/org/eclipse/osbp/filter/DefaultFilterEnhancer.java
@@ -17,13 +17,13 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.osbp.authentication.account.dtos.UserAccountDto;
import org.eclipse.osbp.jpa.services.Query;
import org.eclipse.osbp.jpa.services.filters.LAnd;
import org.eclipse.osbp.jpa.services.filters.LIn;
import org.eclipse.osbp.jpa.services.filters.LNot;
import org.eclipse.osbp.runtime.common.filter.IFilterEnhancer;
import org.eclipse.osbp.runtime.common.filter.IQuery;
+import org.eclipse.osbp.ui.api.user.filter.FilterMap;
import org.eclipse.osbp.ui.api.useraccess.IUserAccessService;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@@ -49,45 +49,46 @@
* @see org.eclipse.osbp.dsl.dto.lib.services.filters.IFilterEnhancer#
* enhanceQuery(org.eclipse.osbp.dsl.dto.lib.services.IQuery)
*/
+ @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void enhanceQuery(IQuery query) {
if (userAccessService != null && userAccessService.isAuthenticated()) {
- UserAccountDto user = (UserAccountDto) userAccessService.getUser();
- if (user != null) {
- List<Class> queryMap = (List<Class>) query.getMap().get(Query.ENTITY_CLASSES_KEY);
- if (queryMap != null) {
- LIn inFilter = null;
- LNot notFilter = null;
- for (Class entityClass : queryMap) {
- String propertyId = "id";
- // LIn filter creation
- List<String> filterInValues = userAccessService.getUserFilterMap().getInFilterMap()
- .get(entityClass.getName());
- if (filterInValues != null) {
- List<Comparable<?>> values = new ArrayList<>();
- for (Comparable<?> value : filterInValues) {
- values.add(value);
- }
- inFilter = new LIn(propertyId, values);
+ FilterMap fm = userAccessService.getFilterMap();
+ if ( fm == null ) return;
+
+ List<Class> queryMap = (List<Class>) query.getMap().get(Query.ENTITY_CLASSES_KEY);
+ if (queryMap != null) {
+ LIn inFilter = null;
+ LNot notFilter = null;
+ for (Class entityClass : queryMap) {
+ String propertyId = "id";
+ // LIn filter creation
+ List<String> filterInValues = fm.getInFilterMap()
+ .get(entityClass.getName());
+ if (filterInValues != null) {
+ List<Comparable<?>> values = new ArrayList<>();
+ for (Comparable<?> value : filterInValues) {
+ values.add(value);
}
- // LNot filter creation
- List<String> filterNotValues = userAccessService.getUserFilterMap().getNotFilterMap()
- .get(entityClass.getName());
- if (filterNotValues != null) {
- List<Comparable<?>> values = new ArrayList<>();
- for (Comparable<?> value : filterNotValues) {
- values.add(value);
- }
- notFilter = new LNot(new LIn(propertyId, values));
+ inFilter = new LIn(propertyId, values);
+ }
+ // LNot filter creation
+ List<String> filterNotValues = fm.getNotFilterMap()
+ .get(entityClass.getName());
+ if (filterNotValues != null) {
+ List<Comparable<?>> values = new ArrayList<>();
+ for (Comparable<?> value : filterNotValues) {
+ values.add(value);
}
- // ReplaceFilter
- if ((inFilter != null) && (notFilter != null)) {
- query.replaceFilter(new LAnd(inFilter, notFilter));
- } else if (inFilter != null) {
- query.replaceFilter(inFilter);
- } else if (notFilter != null) {
- query.replaceFilter(notFilter);
- }
+ notFilter = new LNot(new LIn(propertyId, values));
+ }
+ // ReplaceFilter
+ if ((inFilter != null) && (notFilter != null)) {
+ query.replaceFilter(new LAnd(inFilter, notFilter));
+ } else if (inFilter != null) {
+ query.replaceFilter(inFilter);
+ } else if (notFilter != null) {
+ query.replaceFilter(notFilter);
}
}
}
@@ -123,24 +124,25 @@
@Override
public boolean checkGet(Class<?> entityClass, Object id) {
if (userAccessService != null && userAccessService.isAuthenticated()) {
- UserAccountDto user = (UserAccountDto) userAccessService.getUser();
- if (user != null) {
- List<String> filterInValues = userAccessService.getUserFilterMap().getInFilterMap().get(entityClass.getName());
- if (filterInValues != null) {
- if(id instanceof String) {
- return (filterInValues.contains((String) id));
- } else {
- return (filterInValues.contains(new Integer((int) id).toString()));
- }
+
+ FilterMap fm = userAccessService.getFilterMap();
+ if (fm == null) return true;
+
+ List<String> filterInValues = fm.getInFilterMap().get(entityClass.getName());
+ if (filterInValues != null) {
+ if(id instanceof String) {
+ return (filterInValues.contains(id));
+ } else {
+ return (filterInValues.contains(new Integer((int) id).toString()));
}
- List<String> filterNotValues = userAccessService.getUserFilterMap().getNotFilterMap()
- .get(entityClass.getName());
- if (filterNotValues != null) {
- if(id instanceof String) {
- return !(filterNotValues.contains((String) id));
- } else {
- return !(filterNotValues.contains(new Integer((int) id).toString()));
- }
+ }
+ List<String> filterNotValues = fm.getNotFilterMap()
+ .get(entityClass.getName());
+ if (filterNotValues != null) {
+ if(id instanceof String) {
+ return !(filterNotValues.contains(id));
+ } else {
+ return !(filterNotValues.contains(new Integer((int) id).toString()));
}
}
}