You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2019/06/01 17:15:10 UTC
[atlas] branch master updated: ATLAS-3180: enhanced typedef
retrieval to support filter by serviceType
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new a92ddec ATLAS-3180: enhanced typedef retrieval to support filter by serviceType
a92ddec is described below
commit a92ddec05d0ae0d2fe87d931e3dcfa287c60e7f6
Author: Diego Marino Monetti <dm...@gmail.com>
AuthorDate: Mon Apr 29 17:48:22 2019 +0200
ATLAS-3180: enhanced typedef retrieval to support filter by serviceType
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
---
.../java/org/apache/atlas/model/SearchFilter.java | 12 ++++---
.../apache/atlas/repository/util/FilterUtil.java | 40 +++++++++++++++++++---
2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/intg/src/main/java/org/apache/atlas/model/SearchFilter.java b/intg/src/main/java/org/apache/atlas/model/SearchFilter.java
index 62929a7..7410800 100644
--- a/intg/src/main/java/org/apache/atlas/model/SearchFilter.java
+++ b/intg/src/main/java/org/apache/atlas/model/SearchFilter.java
@@ -40,11 +40,13 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class SearchFilter {
- public static final String PARAM_TYPE = "type";
- public static final String PARAM_NAME = "name";
- public static final String PARAM_SUPERTYPE = "supertype";
- public static final String PARAM_NOT_SUPERTYPE = "notsupertype";
- public static final String PARAM_NOT_NAME = "notname";
+ public static final String PARAM_TYPE = "type";
+ public static final String PARAM_NAME = "name";
+ public static final String PARAM_SUPERTYPE = "supertype";
+ public static final String PARAM_SERVICETYPE = "servicetype";
+ public static final String PARAM_NOT_SUPERTYPE = "notsupertype";
+ public static final String PARAM_NOT_SERVICETYPE = "notservicetype";
+ public static final String PARAM_NOT_NAME = "notname";
/**
* to specify whether the result should be sorted? If yes, whether asc or desc.
diff --git a/repository/src/main/java/org/apache/atlas/repository/util/FilterUtil.java b/repository/src/main/java/org/apache/atlas/repository/util/FilterUtil.java
index 7057ace..5b16dda 100644
--- a/repository/src/main/java/org/apache/atlas/repository/util/FilterUtil.java
+++ b/repository/src/main/java/org/apache/atlas/repository/util/FilterUtil.java
@@ -37,11 +37,13 @@ public class FilterUtil {
public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) {
List<Predicate> predicates = new ArrayList<>();
- final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE);
- final String name = searchFilter.getParam(SearchFilter.PARAM_NAME);
- final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE);
- final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE);
- final List<String> notNames = searchFilter.getParams(SearchFilter.PARAM_NOT_NAME);
+ final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE);
+ final String name = searchFilter.getParam(SearchFilter.PARAM_NAME);
+ final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE);
+ final String serviceType = searchFilter.getParam(SearchFilter.PARAM_SERVICETYPE);
+ final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE);
+ final String notServiceType = searchFilter.getParam(SearchFilter.PARAM_NOT_SERVICETYPE);
+ final List<String> notNames = searchFilter.getParams(SearchFilter.PARAM_NOT_NAME);
// Add filter for the type/category
if (StringUtils.isNotBlank(type)) {
@@ -53,6 +55,11 @@ public class FilterUtil {
predicates.add(getNamePredicate(name));
}
+ // Add filter for the serviceType
+ if(StringUtils.isNotBlank(serviceType)) {
+ predicates.add(getServiceTypePredicate(serviceType));
+ }
+
// Add filter for the supertype
if (StringUtils.isNotBlank(supertype)) {
predicates.add(getSuperTypePredicate(supertype));
@@ -63,6 +70,16 @@ public class FilterUtil {
predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype)));
}
+ // Add filter for the serviceType negation
+ // NOTE: Creating code for the exclusion of multiple service types is currently useless.
+ // In fact the getSearchFilter in TypeREST.java uses the HttpServletRequest.getParameter(key)
+ // that if the key takes more values it takes only the first the value. Could be useful
+ // to change the getSearchFilter to use getParameterValues instead of getParameter.
+ if (StringUtils.isNotBlank(notServiceType)) {
+ predicates.add(new NotPredicate(getServiceTypePredicate(notServiceType)));
+ }
+
+
// Add filter for the type negation
if (CollectionUtils.isNotEmpty(notNames)) {
for (String notName : notNames) {
@@ -86,6 +103,19 @@ public class FilterUtil {
};
}
+ private static Predicate getServiceTypePredicate(final String serviceType) {
+ return new Predicate() {
+ private boolean isAtlasType(Object o) {
+ return o instanceof AtlasType;
+ }
+
+ @Override
+ public boolean evaluate(Object o) {
+ return isAtlasType(o) && Objects.equals(((AtlasType) o).getServiceType(), serviceType);
+ }
+ };
+ }
+
private static Predicate getSuperTypePredicate(final String supertype) {
return new Predicate() {
private boolean isClassificationType(Object o) {