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
0221e3dd
Commit
0221e3dd
authored
5 years ago
by
Pinal Shah
Committed by
Sarath Subramanian
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3866 : Relationship search API for hive storage desc throws error code 500
Signed-off-by:
Sarath Subramanian
<
sarath@apache.org
>
parent
9d597f24
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
8 deletions
+42
-8
EntityDiscoveryService.java
...va/org/apache/atlas/discovery/EntityDiscoveryService.java
+42
-8
No files found.
repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
View file @
0221e3dd
...
@@ -63,14 +63,13 @@ import javax.script.ScriptEngine;
...
@@ -63,14 +63,13 @@ import javax.script.ScriptEngine;
import
javax.script.ScriptException
;
import
javax.script.ScriptException
;
import
java.util.*
;
import
java.util.*
;
import
static
org
.
apache
.
atlas
.
AtlasErrorCode
.
CLASSIFICATION_NOT_FOUND
;
import
static
org
.
apache
.
atlas
.
AtlasErrorCode
.*;
import
static
org
.
apache
.
atlas
.
AtlasErrorCode
.
DISCOVERY_QUERY_FAILED
;
import
static
org
.
apache
.
atlas
.
AtlasErrorCode
.
UNKNOWN_TYPENAME
;
import
static
org
.
apache
.
atlas
.
SortOrder
.
ASCENDING
;
import
static
org
.
apache
.
atlas
.
SortOrder
.
ASCENDING
;
import
static
org
.
apache
.
atlas
.
SortOrder
.
DESCENDING
;
import
static
org
.
apache
.
atlas
.
SortOrder
.
DESCENDING
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
ACTIVE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
ACTIVE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
DELETED
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
DELETED
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.*;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
ASSET_ENTITY_TYPE
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
OWNER_ATTRIBUTE
;
import
static
org
.
apache
.
atlas
.
util
.
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.*;
import
static
org
.
apache
.
atlas
.
util
.
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.*;
@Component
@Component
...
@@ -564,7 +563,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -564,7 +563,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
AtlasSearchResult
searchRelatedEntities
(
String
guid
,
String
relation
,
String
sortBy
AttributeName
,
SortOrder
sortOrder
,
public
AtlasSearchResult
searchRelatedEntities
(
String
guid
,
String
relation
,
String
sortBy
,
SortOrder
sortOrder
,
boolean
excludeDeletedEntities
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
boolean
excludeDeletedEntities
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
AtlasQueryType
.
RELATIONSHIP
);
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
AtlasQueryType
.
RELATIONSHIP
);
...
@@ -594,15 +593,50 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -594,15 +593,50 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
}
}
}
}
if
(
StringUtils
.
isEmpty
(
sortByAttributeName
))
{
String
sortByAttributeName
=
DEFAULT_SORT_ATTRIBUTE_NAME
;
sortByAttributeName
=
DEFAULT_SORT_ATTRIBUTE_NAME
;
if
(
StringUtils
.
isNotEmpty
(
sortBy
))
{
sortByAttributeName
=
sortBy
;
}
//get entity type of relationship (End vertex entity type) from relationship label
Iterator
<
AtlasEdge
>
edges
=
GraphHelper
.
getAdjacentEdgesByLabel
(
entityVertex
,
AtlasEdgeDirection
.
BOTH
,
relation
);
AtlasEntityType
endEntityType
=
null
;
if
(
edges
!=
null
&&
edges
.
hasNext
())
{
AtlasEdge
relationEdge
=
edges
.
next
();
AtlasVertex
outVertex
=
relationEdge
.
getOutVertex
();
AtlasVertex
inVertex
=
relationEdge
.
getInVertex
();
String
outVertexId
=
outVertex
!=
null
?
outVertex
.
getIdForDisplay
()
:
null
;
AtlasVertex
endVertex
=
StringUtils
.
equals
(
outVertexId
,
entityVertex
.
getIdForDisplay
())
?
inVertex
:
outVertex
;
String
endTypeName
=
GraphHelper
.
getTypeName
(
endVertex
);
endEntityType
=
typeRegistry
.
getEntityTypeByName
(
endTypeName
);
}
if
(
endEntityType
==
null
)
{
ret
.
setEntities
(
new
ArrayList
<>());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Invalid relation : {} "
,
relation
);
}
}
AtlasAttribute
sortByAttribute
=
entityType
.
getAttribute
(
sortByAttributeName
);
return
ret
;
}
AtlasAttribute
sortByAttribute
=
endEntityType
.
getAttribute
(
sortByAttributeName
);
if
(
sortByAttribute
==
null
)
{
if
(
sortByAttribute
==
null
)
{
sortByAttributeName
=
null
;
sortByAttributeName
=
null
;
sortOrder
=
null
;
sortOrder
=
null
;
if
(
LOG
.
isDebugEnabled
())
{
if
(
StringUtils
.
isNotEmpty
(
sortBy
))
{
LOG
.
debug
(
"Invalid sortBy Attribute {} for entityType {}, Ignoring Sorting"
,
sortBy
,
endEntityType
.
getTypeName
());
}
else
{
LOG
.
debug
(
"Invalid Default sortBy Attribute {} for entityType {}, Ignoring Sorting"
,
DEFAULT_SORT_ATTRIBUTE_NAME
,
endEntityType
.
getTypeName
());
}
}
}
else
{
}
else
{
sortByAttributeName
=
sortByAttribute
.
getVertexPropertyName
();
sortByAttributeName
=
sortByAttribute
.
getVertexPropertyName
();
...
...
This diff is collapsed.
Click to expand it.
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