Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
a92ddec0
Commit
a92ddec0
authored
Apr 29, 2019
by
Diego Marino Monetti
Committed by
Madhan Neethiraj
Jun 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3180: enhanced typedef retrieval to support filter by serviceType
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
be9df1c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
SearchFilter.java
intg/src/main/java/org/apache/atlas/model/SearchFilter.java
+7
-5
FilterUtil.java
...ain/java/org/apache/atlas/repository/util/FilterUtil.java
+35
-5
No files found.
intg/src/main/java/org/apache/atlas/model/SearchFilter.java
View file @
a92ddec0
...
...
@@ -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.
...
...
repository/src/main/java/org/apache/atlas/repository/util/FilterUtil.java
View file @
a92ddec0
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment