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
07192bc8
Commit
07192bc8
authored
Mar 28, 2019
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3107: updated AtlasEntityDef with addition of read-only field relationshipAttributeDefs
parent
14037eed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
2 deletions
+126
-2
AtlasEntityDef.java
...n/java/org/apache/atlas/model/typedef/AtlasEntityDef.java
+103
-2
AtlasEntityType.java
.../src/main/java/org/apache/atlas/type/AtlasEntityType.java
+16
-0
AtlasRelationshipType.java
...ain/java/org/apache/atlas/type/AtlasRelationshipType.java
+2
-0
AtlasStructType.java
.../src/main/java/org/apache/atlas/type/AtlasStructType.java
+5
-0
No files found.
intg/src/main/java/org/apache/atlas/model/typedef/AtlasEntityDef.java
View file @
07192bc8
...
@@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlAccessType;
...
@@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlSeeAlso
;
import
javax.xml.bind.annotation.XmlSeeAlso
;
import
java.io.Serializable
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -55,10 +56,13 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
...
@@ -55,10 +56,13 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
private
Set
<
String
>
superTypes
;
private
Set
<
String
>
superTypes
;
//
subTypes field below is derived from 'superTypes' specified in all AtlasEntityDef
//
this is a read-only field, any value provided during create & update operation is ignored
// th
is value is ignored during create & update operations
// th
e value of this field is derived from 'superTypes' specified in all AtlasEntityDef
private
Set
<
String
>
subTypes
;
private
Set
<
String
>
subTypes
;
// this is a read-only field, any value provided during create & update operation is ignored
// the value of this field is derived from all the relationshipDefs this entityType is referenced in
private
List
<
AtlasRelationshipAttributeDef
>
relationshipAttributeDefs
;
public
AtlasEntityDef
()
{
public
AtlasEntityDef
()
{
this
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
this
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
...
@@ -148,6 +152,14 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
...
@@ -148,6 +152,14 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
this
.
subTypes
=
subTypes
;
this
.
subTypes
=
subTypes
;
}
}
public
List
<
AtlasRelationshipAttributeDef
>
getRelationshipAttributeDefs
()
{
return
relationshipAttributeDefs
;
}
public
void
setRelationshipAttributeDefs
(
List
<
AtlasRelationshipAttributeDef
>
relationshipAttributeDefs
)
{
this
.
relationshipAttributeDefs
=
relationshipAttributeDefs
;
}
public
boolean
hasSuperType
(
String
typeName
)
{
public
boolean
hasSuperType
(
String
typeName
)
{
return
hasSuperType
(
superTypes
,
typeName
);
return
hasSuperType
(
superTypes
,
typeName
);
}
}
...
@@ -191,6 +203,18 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
...
@@ -191,6 +203,18 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
sb
.
append
(
", superTypes=["
);
sb
.
append
(
", superTypes=["
);
dumpObjects
(
superTypes
,
sb
);
dumpObjects
(
superTypes
,
sb
);
sb
.
append
(
"]"
);
sb
.
append
(
"]"
);
sb
.
append
(
", relationshipAttributeDefs=["
);
if
(
CollectionUtils
.
isNotEmpty
(
relationshipAttributeDefs
))
{
int
i
=
0
;
for
(
AtlasRelationshipAttributeDef
attributeDef
:
relationshipAttributeDefs
)
{
attributeDef
.
toString
(
sb
);
if
(
i
>
0
)
{
sb
.
append
(
", "
);
}
i
++;
}
}
sb
.
append
(
']'
);
sb
.
append
(
'}'
);
sb
.
append
(
'}'
);
return
sb
;
return
sb
;
...
@@ -216,6 +240,83 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
...
@@ -216,6 +240,83 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
return
toString
(
new
StringBuilder
()).
toString
();
return
toString
(
new
StringBuilder
()).
toString
();
}
}
/**
* class that captures details of a struct-attribute.
*/
@JsonAutoDetect
(
getterVisibility
=
PUBLIC_ONLY
,
setterVisibility
=
PUBLIC_ONLY
,
fieldVisibility
=
NONE
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
PROPERTY
)
public
static
class
AtlasRelationshipAttributeDef
extends
AtlasAttributeDef
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
relationshipTypeName
;
private
boolean
isLegacyAttribute
;
public
AtlasRelationshipAttributeDef
()
{
}
public
AtlasRelationshipAttributeDef
(
String
relationshipTypeName
,
boolean
isLegacyAttribute
,
AtlasAttributeDef
attributeDef
)
{
super
(
attributeDef
);
this
.
relationshipTypeName
=
relationshipTypeName
;
this
.
isLegacyAttribute
=
isLegacyAttribute
;
}
public
String
getRelationshipTypeName
()
{
return
relationshipTypeName
;
}
public
void
setRelationshipTypeName
(
String
relationshipTypeName
)
{
this
.
relationshipTypeName
=
relationshipTypeName
;
}
public
boolean
getIsLegacyAttribute
()
{
return
isLegacyAttribute
;
}
public
void
setIsLegacyAttribute
(
boolean
isLegacyAttribute
)
{
this
.
isLegacyAttribute
=
isLegacyAttribute
;
}
public
StringBuilder
toString
(
StringBuilder
sb
)
{
if
(
sb
==
null
)
{
sb
=
new
StringBuilder
();
}
sb
.
append
(
"AtlasRelationshipAttributeDef{"
);
super
.
toString
(
sb
);
sb
.
append
(
", relationshipTypeName='"
).
append
(
relationshipTypeName
).
append
(
'\''
);
sb
.
append
(
", isLegacyAttribute='"
).
append
(
isLegacyAttribute
).
append
(
'\''
);
sb
.
append
(
'}'
);
return
sb
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
AtlasRelationshipAttributeDef
that
=
(
AtlasRelationshipAttributeDef
)
o
;
return
super
.
equals
(
that
)
&&
isLegacyAttribute
==
that
.
isLegacyAttribute
&&
Objects
.
equals
(
relationshipTypeName
,
that
.
relationshipTypeName
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
super
.
hashCode
(),
relationshipTypeName
,
isLegacyAttribute
);
}
@Override
public
String
toString
()
{
return
toString
(
new
StringBuilder
()).
toString
();
}
}
/**
/**
* REST serialization friendly list.
* REST serialization friendly list.
...
...
intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
View file @
07192bc8
...
@@ -24,6 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
...
@@ -24,6 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.model.instance.AtlasStruct
;
import
org.apache.atlas.model.instance.AtlasStruct
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef.AtlasRelationshipAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType
;
import
org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType
;
import
org.apache.atlas.utils.AtlasEntityUtil
;
import
org.apache.atlas.utils.AtlasEntityUtil
;
...
@@ -241,6 +242,21 @@ public class AtlasEntityType extends AtlasStructType {
...
@@ -241,6 +242,21 @@ public class AtlasEntityType extends AtlasStructType {
ownedRefAttributes
=
Collections
.
unmodifiableList
(
ownedRefAttributes
);
ownedRefAttributes
=
Collections
.
unmodifiableList
(
ownedRefAttributes
);
entityDef
.
setSubTypes
(
subTypes
);
entityDef
.
setSubTypes
(
subTypes
);
List
<
AtlasRelationshipAttributeDef
>
relationshipAttrDefs
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Map
<
String
,
AtlasAttribute
>>
attrEntry
:
relationshipAttributes
.
entrySet
())
{
Map
<
String
,
AtlasAttribute
>
relations
=
attrEntry
.
getValue
();
for
(
Map
.
Entry
<
String
,
AtlasAttribute
>
relationsEntry
:
relations
.
entrySet
())
{
String
relationshipType
=
relationsEntry
.
getKey
();
AtlasAttribute
relationshipAttr
=
relationsEntry
.
getValue
();
relationshipAttrDefs
.
add
(
new
AtlasRelationshipAttributeDef
(
relationshipType
,
relationshipAttr
.
isLegacyAttribute
(),
relationshipAttr
.
getAttributeDef
()));
}
}
entityDef
.
setRelationshipAttributeDefs
(
Collections
.
unmodifiableList
(
relationshipAttrDefs
));
}
}
public
Set
<
String
>
getSuperTypes
()
{
public
Set
<
String
>
getSuperTypes
()
{
...
...
intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
View file @
07192bc8
...
@@ -349,11 +349,13 @@ public class AtlasRelationshipType extends AtlasStructType {
...
@@ -349,11 +349,13 @@ public class AtlasRelationshipType extends AtlasStructType {
attribute
=
new
AtlasAttribute
(
entityType
,
attributeDef
,
attribute
=
new
AtlasAttribute
(
entityType
,
attributeDef
,
typeRegistry
.
getType
(
attrTypeName
),
getTypeName
(),
relationshipLabel
);
typeRegistry
.
getType
(
attrTypeName
),
getTypeName
(),
relationshipLabel
);
attribute
.
setLegacyAttribute
(
endDef
.
getIsLegacyAttribute
());
}
else
{
}
else
{
// attribute already exists (legacy attribute which is also a relationship attribute)
// attribute already exists (legacy attribute which is also a relationship attribute)
// add relationshipLabel information to existing attribute
// add relationshipLabel information to existing attribute
attribute
.
setRelationshipName
(
getTypeName
());
attribute
.
setRelationshipName
(
getTypeName
());
attribute
.
setRelationshipEdgeLabel
(
relationshipLabel
);
attribute
.
setRelationshipEdgeLabel
(
relationshipLabel
);
attribute
.
setLegacyAttribute
(
true
);
}
}
entityType
.
addRelationshipAttribute
(
attrName
,
attribute
,
this
);
entityType
.
addRelationshipAttribute
(
attrName
,
attribute
,
this
);
...
...
intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
View file @
07192bc8
...
@@ -708,6 +708,7 @@ public class AtlasStructType extends AtlasType {
...
@@ -708,6 +708,7 @@ public class AtlasStructType extends AtlasType {
private
String
relationshipName
;
private
String
relationshipName
;
private
String
relationshipEdgeLabel
;
private
String
relationshipEdgeLabel
;
private
AtlasRelationshipEdgeDirection
relationshipEdgeDirection
;
private
AtlasRelationshipEdgeDirection
relationshipEdgeDirection
;
private
boolean
isLegacyAttribute
;
public
AtlasAttribute
(
AtlasStructType
definedInType
,
AtlasAttributeDef
attrDef
,
AtlasType
attributeType
,
String
relationshipName
,
String
relationshipLabel
)
{
public
AtlasAttribute
(
AtlasStructType
definedInType
,
AtlasAttributeDef
attrDef
,
AtlasType
attributeType
,
String
relationshipName
,
String
relationshipLabel
)
{
this
.
definedInType
=
definedInType
;
this
.
definedInType
=
definedInType
;
...
@@ -815,6 +816,10 @@ public class AtlasStructType extends AtlasType {
...
@@ -815,6 +816,10 @@ public class AtlasStructType extends AtlasType {
this
.
relationshipEdgeDirection
=
relationshipEdgeDirection
;
this
.
relationshipEdgeDirection
=
relationshipEdgeDirection
;
}
}
public
boolean
isLegacyAttribute
()
{
return
isLegacyAttribute
;
}
public
void
setLegacyAttribute
(
boolean
legacyAttribute
)
{
isLegacyAttribute
=
legacyAttribute
;
}
public
static
String
getEdgeLabel
(
String
property
)
{
public
static
String
getEdgeLabel
(
String
property
)
{
return
"__"
+
property
;
return
"__"
+
property
;
}
}
...
...
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