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
b445a1d2
Commit
b445a1d2
authored
7 years ago
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1984: Use AtlasRelatedObjectId to refer to relationship attributes during…
ATLAS-1984: Use AtlasRelatedObjectId to refer to relationship attributes during entity create/update
parent
2f6d7b24
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
16 deletions
+64
-16
AtlasRelationship.java
...va/org/apache/atlas/model/instance/AtlasRelationship.java
+6
-0
AtlasStruct.java
...ain/java/org/apache/atlas/model/instance/AtlasStruct.java
+8
-0
AtlasStructType.java
.../src/main/java/org/apache/atlas/type/AtlasStructType.java
+20
-5
AtlasTypeUtil.java
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+4
-2
AtlasEntityGraphDiscoveryV1.java
...epository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java
+26
-9
EntityGraphMapper.java
...he/atlas/repository/store/graph/v1/EntityGraphMapper.java
+0
-0
No files found.
intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationship.java
View file @
b445a1d2
...
@@ -85,6 +85,12 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
...
@@ -85,6 +85,12 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
init
(
nextInternalId
(),
end1
,
end2
,
null
,
null
,
null
,
null
,
null
,
null
,
0L
);
init
(
nextInternalId
(),
end1
,
end2
,
null
,
null
,
null
,
null
,
null
,
null
,
0L
);
}
}
public
AtlasRelationship
(
String
typeName
,
AtlasObjectId
end1
,
AtlasObjectId
end2
,
Map
<
String
,
Object
>
attributes
)
{
super
(
typeName
,
attributes
);
init
(
nextInternalId
(),
end1
,
end2
,
null
,
null
,
null
,
null
,
null
,
null
,
0L
);
}
public
AtlasRelationship
(
String
typeName
,
String
attrName
,
Object
attrValue
)
{
public
AtlasRelationship
(
String
typeName
,
String
attrName
,
Object
attrValue
)
{
super
(
typeName
,
attrName
,
attrValue
);
super
(
typeName
,
attrName
,
attrValue
);
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java
View file @
b445a1d2
...
@@ -126,6 +126,14 @@ public class AtlasStruct implements Serializable {
...
@@ -126,6 +126,14 @@ public class AtlasStruct implements Serializable {
}
}
}
}
public
void
removeAttribute
(
String
name
)
{
Map
<
String
,
Object
>
a
=
this
.
attributes
;
if
(
a
!=
null
&&
a
.
containsKey
(
name
))
{
a
.
remove
(
name
);
}
}
public
StringBuilder
toString
(
StringBuilder
sb
)
{
public
StringBuilder
toString
(
StringBuilder
sb
)
{
if
(
sb
==
null
)
{
if
(
sb
==
null
)
{
sb
=
new
StringBuilder
();
sb
=
new
StringBuilder
();
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
View file @
b445a1d2
...
@@ -19,6 +19,7 @@ package org.apache.atlas.type;
...
@@ -19,6 +19,7 @@ package org.apache.atlas.type;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasStruct
;
import
org.apache.atlas.model.instance.AtlasStruct
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
...
@@ -330,13 +331,24 @@ public class AtlasStructType extends AtlasType {
...
@@ -330,13 +331,24 @@ public class AtlasStructType extends AtlasType {
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
ret
=
dataType
.
validateValue
(
value
,
fieldName
,
messages
)
&&
ret
;
ret
=
dataType
.
validateValue
(
value
,
fieldName
,
messages
)
&&
ret
;
}
else
if
(!
attributeDef
.
getIsOptional
())
{
}
else
if
(!
attributeDef
.
getIsOptional
())
{
ret
=
false
;
// if required attribute is null, check if attribute value specified in relationship
messages
.
add
(
fieldName
+
": mandatory attribute value missing in type "
+
getTypeName
());
if
(
structObj
instanceof
AtlasEntity
)
{
AtlasEntity
entityObj
=
(
AtlasEntity
)
structObj
;
if
(
entityObj
.
getRelationshipAttribute
(
attrName
)
==
null
)
{
ret
=
false
;
messages
.
add
(
fieldName
+
": mandatory attribute value missing in type "
+
getTypeName
());
}
}
else
{
ret
=
false
;
messages
.
add
(
fieldName
+
": mandatory attribute value missing in type "
+
getTypeName
());
}
}
}
}
}
}
}
}
else
if
(
obj
instanceof
Map
)
{
}
else
if
(
obj
instanceof
Map
)
{
Map
attributes
=
AtlasTypeUtil
.
toStructAttributes
((
Map
)
obj
);
Map
attributes
=
AtlasTypeUtil
.
toStructAttributes
((
Map
)
obj
);
Map
relationshipAttributes
=
AtlasTypeUtil
.
toRelationshipAttributes
((
Map
)
obj
);
for
(
AtlasAttributeDef
attributeDef
:
structDef
.
getAttributeDefs
())
{
for
(
AtlasAttributeDef
attributeDef
:
structDef
.
getAttributeDefs
())
{
String
attrName
=
attributeDef
.
getName
();
String
attrName
=
attributeDef
.
getName
();
...
@@ -350,8 +362,11 @@ public class AtlasStructType extends AtlasType {
...
@@ -350,8 +362,11 @@ public class AtlasStructType extends AtlasType {
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
ret
=
dataType
.
validateValue
(
value
,
fieldName
,
messages
)
&&
ret
;
ret
=
dataType
.
validateValue
(
value
,
fieldName
,
messages
)
&&
ret
;
}
else
if
(!
attributeDef
.
getIsOptional
())
{
}
else
if
(!
attributeDef
.
getIsOptional
())
{
ret
=
false
;
// if required attribute is null, check if attribute value specified in relationship
messages
.
add
(
fieldName
+
": mandatory attribute value missing in type "
+
getTypeName
());
if
(
MapUtils
.
isEmpty
(
relationshipAttributes
)
||
!
relationshipAttributes
.
containsKey
(
attrName
))
{
ret
=
false
;
messages
.
add
(
fieldName
+
": mandatory attribute value missing in type "
+
getTypeName
());
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
View file @
b445a1d2
...
@@ -316,11 +316,13 @@ public class AtlasTypeUtil {
...
@@ -316,11 +316,13 @@ public class AtlasTypeUtil {
}
}
public
static
Map
toRelationshipAttributes
(
Map
map
)
{
public
static
Map
toRelationshipAttributes
(
Map
map
)
{
Map
ret
=
null
;
if
(
map
!=
null
&&
map
.
containsKey
(
"typeName"
)
&&
map
.
containsKey
(
"relationshipAttributes"
)
&&
map
.
get
(
"relationshipAttributes"
)
instanceof
Map
)
{
if
(
map
!=
null
&&
map
.
containsKey
(
"typeName"
)
&&
map
.
containsKey
(
"relationshipAttributes"
)
&&
map
.
get
(
"relationshipAttributes"
)
instanceof
Map
)
{
ret
urn
(
Map
)
map
.
get
(
"relationshipAttributes"
);
ret
=
(
Map
)
map
.
get
(
"relationshipAttributes"
);
}
}
return
map
;
return
ret
;
}
}
public
static
AtlasObjectId
getAtlasObjectId
(
AtlasEntity
entity
)
{
public
static
AtlasObjectId
getAtlasObjectId
(
AtlasEntity
entity
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java
View file @
b445a1d2
...
@@ -301,21 +301,38 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery {
...
@@ -301,21 +301,38 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery {
visitStruct
(
structType
,
struct
);
visitStruct
(
structType
,
struct
);
}
}
void
visitStruct
(
AtlasStructType
structType
,
AtlasStruct
struct
)
throws
AtlasBaseException
{
void
visitEntity
(
AtlasEntityType
entityType
,
AtlasEntity
entity
)
throws
AtlasBaseException
{
for
(
AtlasAttribute
attribute
:
structType
.
getAllAttributes
().
values
())
{
List
<
String
>
visitedAttributes
=
new
ArrayList
<>();
// visit relationship attributes
for
(
AtlasAttribute
attribute
:
entityType
.
getRelationshipAttributes
().
values
())
{
AtlasType
attrType
=
attribute
.
getAttributeType
();
AtlasType
attrType
=
attribute
.
getAttributeType
();
Object
attrVal
=
struct
.
getAttribute
(
attribute
.
getName
());
String
attrName
=
attribute
.
getName
();
Object
attrVal
=
entity
.
getRelationshipAttribute
(
attrName
);
visitAttribute
(
attrType
,
attrVal
);
if
(
entity
.
hasRelationshipAttribute
(
attrName
))
{
visitAttribute
(
attrType
,
attrVal
);
visitedAttributes
.
add
(
attrName
);
}
}
}
}
void
visitEntity
(
AtlasEntityType
entityType
,
AtlasEntity
entity
)
throws
AtlasBaseException
{
// visit struct attributes
visitStruct
(
entityType
,
entity
);
for
(
AtlasAttribute
attribute
:
entityType
.
getAllAttributes
().
values
())
{
AtlasType
attrType
=
attribute
.
getAttributeType
();
String
attrName
=
attribute
.
getName
();
Object
attrVal
=
entity
.
getAttribute
(
attrName
);
for
(
AtlasAttribute
attribute
:
entityType
.
getRelationshipAttributes
().
values
())
{
if
(
entity
.
hasAttribute
(
attrName
)
&&
!
visitedAttributes
.
contains
(
attrName
))
{
visitAttribute
(
attrType
,
attrVal
);
}
}
}
void
visitStruct
(
AtlasStructType
structType
,
AtlasStruct
struct
)
throws
AtlasBaseException
{
for
(
AtlasAttribute
attribute
:
structType
.
getAllAttributes
().
values
())
{
AtlasType
attrType
=
attribute
.
getAttributeType
();
AtlasType
attrType
=
attribute
.
getAttributeType
();
Object
attrVal
=
entity
.
getRelationship
Attribute
(
attribute
.
getName
());
Object
attrVal
=
struct
.
get
Attribute
(
attribute
.
getName
());
visitAttribute
(
attrType
,
attrVal
);
visitAttribute
(
attrType
,
attrVal
);
}
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
View file @
b445a1d2
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