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
a9514d4b
Commit
a9514d4b
authored
7 years ago
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2050: Add helper method in relationship store to check if entity has relationships associated
parent
b23dc858
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
AtlasRelationshipStoreV1.java
...s/repository/store/graph/v1/AtlasRelationshipStoreV1.java
+39
-0
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasRelationshipStoreV1.java
View file @
a9514d4b
...
...
@@ -45,12 +45,16 @@ import org.springframework.stereotype.Component;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.UUID
;
import
static
org
.
apache
.
atlas
.
repository
.
graphdb
.
AtlasEdgeDirection
.
BOTH
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v1
.
AtlasGraphUtilsV1
.
getTypeName
;
@Component
public
class
AtlasRelationshipStoreV1
implements
AtlasRelationshipStore
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasRelationshipStoreV1
.
class
);
...
...
@@ -411,4 +415,38 @@ public class AtlasRelationshipStoreV1 implements AtlasRelationshipStore {
return
typeName
;
}
/**
* Check whether this vertex has a relationship associated with this relationship type.
* @param vertex
* @param relationshipTypeName
* @return true if found an edge with this relationship type in.
*/
private
boolean
vertexHasRelationshipWithType
(
AtlasVertex
vertex
,
String
relationshipTypeName
)
{
String
relationshipEdgeLabel
=
getRelationshipEdgeLabel
(
getTypeName
(
vertex
),
relationshipTypeName
);
Iterator
<
AtlasEdge
>
iter
=
graphHelper
.
getAdjacentEdgesByLabel
(
vertex
,
BOTH
,
relationshipEdgeLabel
);
return
(
iter
!=
null
)
?
iter
.
hasNext
()
:
false
;
}
private
String
getRelationshipEdgeLabel
(
String
typeName
,
String
relationshipTypeName
)
{
AtlasRelationshipType
relationshipType
=
typeRegistry
.
getRelationshipTypeByName
(
relationshipTypeName
);
AtlasRelationshipDef
relationshipDef
=
relationshipType
.
getRelationshipDef
();
AtlasEntityType
end1Type
=
relationshipType
.
getEnd1Type
();
AtlasEntityType
end2Type
=
relationshipType
.
getEnd2Type
();
Set
<
String
>
vertexTypes
=
getTypeAndAllSuperTypes
(
typeName
);
AtlasAttribute
attribute
=
null
;
if
(
vertexTypes
.
contains
(
end1Type
.
getTypeName
()))
{
String
attributeName
=
relationshipDef
.
getEndDef1
().
getName
();
attribute
=
(
attributeName
!=
null
)
?
end1Type
.
getAttribute
(
attributeName
)
:
null
;
}
else
if
(
vertexTypes
.
contains
(
end2Type
.
getTypeName
()))
{
String
attributeName
=
relationshipDef
.
getEndDef2
().
getName
();
attribute
=
(
attributeName
!=
null
)
?
end2Type
.
getAttribute
(
attributeName
)
:
null
;
}
return
(
attribute
!=
null
)
?
attribute
.
getRelationshipEdgeLabel
()
:
null
;
}
}
\ No newline at end of file
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