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
5a4dd2e7
Commit
5a4dd2e7
authored
Oct 20, 2016
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1235: TypesREST.update() does not update fields like description
parent
a96424a1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
212 additions
and
45 deletions
+212
-45
AtlasClassificationType.java
...n/java/org/apache/atlas/type/AtlasClassificationType.java
+40
-12
AtlasEntityType.java
.../src/main/java/org/apache/atlas/type/AtlasEntityType.java
+39
-11
TestAtlasTypeRegistry.java
...est/java/org/apache/atlas/type/TestAtlasTypeRegistry.java
+0
-0
AtlasClassificationDefStoreV1.java
...ository/store/graph/v1/AtlasClassificationDefStoreV1.java
+5
-5
AtlasEntityDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+6
-5
AtlasStructDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+50
-8
AtlasTypeDefGraphStoreV1.java
...s/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+72
-4
No files found.
intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
View file @
5a4dd2e7
...
...
@@ -65,22 +65,13 @@ public class AtlasClassificationType extends AtlasStructType {
super
.
resolveReferences
(
typeRegistry
);
List
<
AtlasClassificationType
>
s
=
new
ArrayList
<
AtlasClassificationType
>();
Set
<
String
>
allS
=
new
HashSet
<
String
>(
);
Set
<
String
>
allS
=
getAllSuperTypes
(
typeRegistry
);
for
(
String
superTypeName
:
classificationDef
.
getSuperTypes
())
{
AtlasType
superType
=
typeRegistry
.
getType
(
superTypeName
);
if
(
superType
instanceof
AtlasClassificationType
)
{
AtlasClassificationType
superClassificationType
=
(
AtlasClassificationType
)
superType
;
superClassificationType
.
resolveReferences
(
typeRegistry
);
s
.
add
(
superClassificationType
);
allS
.
add
(
superTypeName
);
if
(
CollectionUtils
.
isNotEmpty
(
superClassificationType
.
getAllSuperTypes
()))
{
allS
.
addAll
(
superClassificationType
.
getAllSuperTypes
());
}
s
.
add
((
AtlasClassificationType
)
superType
);
}
else
{
throw
new
AtlasBaseException
(
superTypeName
+
": incompatible supertype in classification "
+
classificationDef
.
getName
());
...
...
@@ -88,7 +79,7 @@ public class AtlasClassificationType extends AtlasStructType {
}
this
.
superTypes
=
Collections
.
unmodifiableList
(
s
);
this
.
allSuperTypes
=
allS
;
this
.
allSuperTypes
=
Collections
.
unmodifiableSet
(
allS
)
;
}
public
Set
<
String
>
getSuperTypes
()
{
...
...
@@ -193,4 +184,41 @@ public class AtlasClassificationType extends AtlasStructType {
super
.
populateDefaultValues
(
classification
);
}
}
private
Set
<
String
>
getAllSuperTypes
(
AtlasTypeRegistry
typeRegistry
)
throws
AtlasBaseException
{
Set
<
String
>
superTypes
=
new
HashSet
<>();
List
<
String
>
subTypes
=
new
ArrayList
<>();
collectAllSuperTypes
(
subTypes
,
superTypes
,
typeRegistry
);
return
superTypes
;
}
/*
* This method should not assume that resolveReferences() has been called on all superTypes.
* this.classificationDef is the only safe member to reference here
*/
private
void
collectAllSuperTypes
(
List
<
String
>
subTypes
,
Set
<
String
>
superTypes
,
AtlasTypeRegistry
typeRegistry
)
throws
AtlasBaseException
{
if
(
subTypes
.
contains
(
classificationDef
.
getName
()))
{
throw
new
AtlasBaseException
(
classificationDef
.
getName
()
+
": invalid supertypes - circular reference back to self "
+
subTypes
);
}
if
(
CollectionUtils
.
isNotEmpty
(
classificationDef
.
getSuperTypes
()))
{
superTypes
.
addAll
(
classificationDef
.
getSuperTypes
());
subTypes
.
add
(
classificationDef
.
getName
());
for
(
String
superTypeName
:
classificationDef
.
getSuperTypes
())
{
AtlasType
type
=
typeRegistry
.
getType
(
superTypeName
);
if
(
type
instanceof
AtlasClassificationType
)
{
AtlasClassificationType
superType
=
(
AtlasClassificationType
)
type
;
superType
.
collectAllSuperTypes
(
subTypes
,
superTypes
,
typeRegistry
);
}
}
subTypes
.
remove
(
classificationDef
.
getName
());
}
}
}
intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
View file @
5a4dd2e7
...
...
@@ -63,22 +63,13 @@ public class AtlasEntityType extends AtlasStructType {
super
.
resolveReferences
(
typeRegistry
);
List
<
AtlasEntityType
>
s
=
new
ArrayList
<
AtlasEntityType
>();
Set
<
String
>
allS
=
new
HashSet
<
String
>(
);
Set
<
String
>
allS
=
getAllSuperTypes
(
typeRegistry
);
for
(
String
superTypeName
:
entityDef
.
getSuperTypes
())
{
AtlasType
superType
=
typeRegistry
.
getType
(
superTypeName
);
if
(
superType
instanceof
AtlasEntityType
)
{
AtlasEntityType
superEntityType
=
(
AtlasEntityType
)
superType
;
superEntityType
.
resolveReferences
(
typeRegistry
);
s
.
add
(
superEntityType
);
allS
.
add
(
superTypeName
);
if
(
CollectionUtils
.
isNotEmpty
(
superEntityType
.
getAllSuperTypes
()))
{
allS
.
addAll
(
superEntityType
.
getAllSuperTypes
());
}
s
.
add
((
AtlasEntityType
)
superType
);
}
else
{
throw
new
AtlasBaseException
(
superTypeName
+
": incompatible supertype in entity "
+
entityDef
.
getName
());
...
...
@@ -193,4 +184,41 @@ public class AtlasEntityType extends AtlasStructType {
super
.
populateDefaultValues
(
ent
);
}
}
private
Set
<
String
>
getAllSuperTypes
(
AtlasTypeRegistry
typeRegistry
)
throws
AtlasBaseException
{
Set
<
String
>
superTypes
=
new
HashSet
<>();
List
<
String
>
subTypes
=
new
ArrayList
<>();
collectAllSuperTypes
(
subTypes
,
superTypes
,
typeRegistry
);
return
superTypes
;
}
/*
* This method should not assume that resolveReferences() has been called on all superTypes.
* this.entityDef is the only safe member to reference here
*/
private
void
collectAllSuperTypes
(
List
<
String
>
subTypes
,
Set
<
String
>
superTypes
,
AtlasTypeRegistry
typeRegistry
)
throws
AtlasBaseException
{
if
(
subTypes
.
contains
(
entityDef
.
getName
()))
{
throw
new
AtlasBaseException
(
entityDef
.
getName
()
+
": invalid supertypes - circular reference back to self "
+
subTypes
);
}
if
(
CollectionUtils
.
isNotEmpty
(
entityDef
.
getSuperTypes
()))
{
superTypes
.
addAll
(
entityDef
.
getSuperTypes
());
subTypes
.
add
(
entityDef
.
getName
());
for
(
String
superTypeName
:
entityDef
.
getSuperTypes
())
{
AtlasType
type
=
typeRegistry
.
getType
(
superTypeName
);
if
(
type
instanceof
AtlasEntityType
)
{
AtlasEntityType
superType
=
(
AtlasEntityType
)
type
;
superType
.
collectAllSuperTypes
(
subTypes
,
superTypes
,
typeRegistry
);
}
}
subTypes
.
remove
(
entityDef
.
getName
());
}
}
}
intg/src/test/java/org/apache/atlas/type/TestAtlasTypeRegistry.java
0 → 100644
View file @
5a4dd2e7
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
View file @
5a4dd2e7
...
...
@@ -173,8 +173,8 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
LOG
.
debug
(
"==> AtlasClassificationDefStoreV1.update({})"
,
classifiDef
);
}
AtlasClassificationDef
ret
=
StringUtils
.
isNotBlank
(
classifiDef
.
get
Name
())
?
updateBy
Name
(
classifiDef
.
getName
(),
classifiDef
)
:
updateByGuid
(
classifiDef
.
getGuid
(),
classifiDef
);
AtlasClassificationDef
ret
=
StringUtils
.
isNotBlank
(
classifiDef
.
get
Guid
())
?
updateBy
Guid
(
classifiDef
.
getGuid
(),
classifiDef
)
:
updateByName
(
classifiDef
.
getName
(),
classifiDef
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasClassificationDefStoreV1.update({}): {}"
,
classifiDef
,
ret
);
...
...
@@ -360,13 +360,13 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
private
void
updateVertexPreCreate
(
AtlasClassificationDef
classificationDef
,
AtlasClassificationType
classificationType
,
AtlasVertex
vertex
)
{
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
classificationDef
,
classificationType
,
vertex
);
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
classificationDef
,
classificationType
,
vertex
,
typeDefStore
);
}
private
void
updateVertexPreUpdate
(
AtlasClassificationDef
classificationDef
,
AtlasClassificationType
classificationType
,
AtlasVertex
vertex
)
{
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
classificationDef
,
classificationType
,
vertex
);
AtlasVertex
vertex
)
throws
AtlasBaseException
{
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
classificationDef
,
classificationType
,
vertex
,
typeDefStore
);
}
private
void
updateVertexAddReferences
(
AtlasClassificationDef
classificationDef
,
AtlasVertex
vertex
)
throws
AtlasBaseException
{
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
View file @
5a4dd2e7
...
...
@@ -172,8 +172,8 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
LOG
.
debug
(
"==> AtlasEntityDefStoreV1.update({})"
,
entityDef
);
}
AtlasEntityDef
ret
=
StringUtils
.
isNotBlank
(
entityDef
.
get
Name
())
?
updateByName
(
entityDef
.
getName
(),
entityDef
)
:
updateBy
Guid
(
entityDef
.
getGuid
(),
entityDef
);
AtlasEntityDef
ret
=
StringUtils
.
isNotBlank
(
entityDef
.
get
Guid
())
?
updateByGuid
(
entityDef
.
getGuid
(),
entityDef
)
:
updateBy
Name
(
entityDef
.
getName
(),
entityDef
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasEntityDefStoreV1.update({}): {}"
,
entityDef
,
ret
);
...
...
@@ -356,11 +356,12 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
}
private
void
updateVertexPreCreate
(
AtlasEntityDef
entityDef
,
AtlasEntityType
entityType
,
AtlasVertex
vertex
)
{
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
entityDef
,
entityType
,
vertex
);
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
entityDef
,
entityType
,
vertex
,
typeDefStore
);
}
private
void
updateVertexPreUpdate
(
AtlasEntityDef
entityDef
,
AtlasEntityType
entityType
,
AtlasVertex
vertex
)
{
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
entityDef
,
entityType
,
vertex
);
private
void
updateVertexPreUpdate
(
AtlasEntityDef
entityDef
,
AtlasEntityType
entityType
,
AtlasVertex
vertex
)
throws
AtlasBaseException
{
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
entityDef
,
entityType
,
vertex
,
typeDefStore
);
}
private
void
updateVertexAddReferences
(
AtlasEntityDef
entityDef
,
AtlasVertex
vertex
)
throws
AtlasBaseException
{
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
View file @
5a4dd2e7
...
...
@@ -81,7 +81,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
ret
=
typeDefStore
.
createTypeVertex
(
structDef
);
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
structDef
,
(
AtlasStructType
)
type
,
ret
);
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
structDef
,
(
AtlasStructType
)
type
,
ret
,
typeDefStore
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasStructDefStoreV1.preCreate({}): {}"
,
structDef
,
ret
);
...
...
@@ -184,8 +184,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
LOG
.
debug
(
"==> AtlasStructDefStoreV1.update({})"
,
structDef
);
}
AtlasStructDef
ret
=
StringUtils
.
isNotBlank
(
structDef
.
get
Name
())
?
updateByName
(
structDef
.
getName
(),
structDef
)
:
updateBy
Guid
(
structDef
.
getGuid
(),
structDef
);
AtlasStructDef
ret
=
StringUtils
.
isNotBlank
(
structDef
.
get
Guid
())
?
updateByGuid
(
structDef
.
getGuid
(),
structDef
)
:
updateBy
Name
(
structDef
.
getName
(),
structDef
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasStructDefStoreV1.update({}): {}"
,
structDef
,
ret
);
...
...
@@ -212,7 +212,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
throw
new
AtlasBaseException
(
"no structDef exists with name "
+
name
);
}
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
structDef
,
(
AtlasStructType
)
type
,
vertex
);
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
structDef
,
(
AtlasStructType
)
type
,
vertex
,
typeDefStore
);
AtlasStructDefStoreV1
.
updateVertexAddReferences
(
structDef
,
vertex
,
typeDefStore
);
AtlasStructDef
ret
=
toStructDef
(
vertex
);
...
...
@@ -242,7 +242,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
throw
new
AtlasBaseException
(
"no structDef exists with guid "
+
guid
);
}
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
structDef
,
(
AtlasStructType
)
type
,
vertex
);
AtlasStructDefStoreV1
.
updateVertexPreUpdate
(
structDef
,
(
AtlasStructType
)
type
,
vertex
,
typeDefStore
);
AtlasStructDefStoreV1
.
updateVertexAddReferences
(
structDef
,
vertex
,
typeDefStore
);
AtlasStructDef
ret
=
toStructDef
(
vertex
);
...
...
@@ -377,7 +377,8 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
return
ret
;
}
public
static
void
updateVertexPreCreate
(
AtlasStructDef
structDef
,
AtlasStructType
structType
,
AtlasVertex
vertex
)
{
public
static
void
updateVertexPreCreate
(
AtlasStructDef
structDef
,
AtlasStructType
structType
,
AtlasVertex
vertex
,
AtlasTypeDefGraphStoreV1
typeDefStore
)
{
List
<
String
>
attrNames
=
new
ArrayList
<>(
structDef
.
getAttributeDefs
().
size
());
for
(
AtlasAttributeDef
attributeDef
:
structDef
.
getAttributeDefs
())
{
...
...
@@ -390,8 +391,49 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
AtlasGraphUtilsV1
.
setProperty
(
vertex
,
AtlasGraphUtilsV1
.
getPropertyKey
(
structDef
),
attrNames
);
}
public
static
void
updateVertexPreUpdate
(
AtlasStructDef
structDef
,
AtlasStructType
structType
,
AtlasVertex
vertex
)
{
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
structDef
,
structType
,
vertex
);
public
static
void
updateVertexPreUpdate
(
AtlasStructDef
structDef
,
AtlasStructType
structType
,
AtlasVertex
vertex
,
AtlasTypeDefGraphStoreV1
typeDefStore
)
throws
AtlasBaseException
{
List
<
String
>
attrNames
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
structDef
.
getAttributeDefs
()))
{
for
(
AtlasAttributeDef
attributeDef
:
structDef
.
getAttributeDefs
())
{
attrNames
.
add
(
attributeDef
.
getName
());
}
}
List
<
String
>
currAttrNames
=
vertex
.
getProperty
(
AtlasGraphUtilsV1
.
getPropertyKey
(
structDef
),
List
.
class
);
// delete attributes that are not present in updated structDef
if
(
CollectionUtils
.
isNotEmpty
(
currAttrNames
))
{
for
(
String
currAttrName
:
currAttrNames
)
{
if
(!
attrNames
.
contains
(
currAttrName
))
{
throw
new
AtlasBaseException
(
structDef
.
getName
()
+
"."
+
currAttrName
+
": attribute delete not supported"
);
}
}
}
typeDefStore
.
updateTypeVertex
(
structDef
,
vertex
);
// add/update attributes that are present in updated structDef
if
(
CollectionUtils
.
isNotEmpty
(
structDef
.
getAttributeDefs
()))
{
for
(
AtlasAttributeDef
attributeDef
:
structDef
.
getAttributeDefs
())
{
if
(
CollectionUtils
.
isEmpty
(
currAttrNames
)
||
!
currAttrNames
.
contains
(
attributeDef
.
getName
()))
{
// new attribute - only allow if optional
if
(!
attributeDef
.
isOptional
())
{
throw
new
AtlasBaseException
(
structDef
.
getName
()
+
"."
+
attributeDef
.
getName
()
+
": can not add mandatory attribute"
);
}
}
String
propertyKey
=
AtlasGraphUtilsV1
.
getPropertyKey
(
structDef
,
attributeDef
.
getName
());
AtlasGraphUtilsV1
.
setProperty
(
vertex
,
propertyKey
,
toJsonFromAttributeDef
(
attributeDef
,
structType
));
}
}
AtlasGraphUtilsV1
.
setProperty
(
vertex
,
AtlasGraphUtilsV1
.
getPropertyKey
(
structDef
),
attrNames
);
}
public
static
void
updateVertexAddReferences
(
AtlasStructDef
structDef
,
AtlasVertex
vertex
,
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
View file @
5a4dd2e7
...
...
@@ -162,8 +162,6 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
public
AtlasVertex
createTypeVertex
(
AtlasBaseTypeDef
typeDef
)
{
// Validate all the required checks
Preconditions
.
checkArgument
(
StringUtils
.
isNotBlank
(
typeDef
.
getName
()),
"Type name can't be null/empty"
);
Preconditions
.
checkArgument
(
StringUtils
.
isNotBlank
(
typeDef
.
getTypeVersion
()),
"Type version can't be null/empty"
);
Preconditions
.
checkArgument
(
typeDef
.
getVersion
()
!=
null
,
"Version can't be null"
);
AtlasVertex
ret
=
atlasGraph
.
addVertex
();
...
...
@@ -171,6 +169,10 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
typeDef
.
setTypeVersion
(
"1.0"
);
}
if
(
typeDef
.
getVersion
()
==
null
)
{
typeDef
.
setVersion
(
Long
.
valueOf
(
1
l
));
}
if
(
StringUtils
.
isBlank
(
typeDef
.
getGuid
()))
{
typeDef
.
setGuid
(
UUID
.
randomUUID
().
toString
());
}
...
...
@@ -198,6 +200,26 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
return
ret
;
}
public
void
updateTypeVertex
(
AtlasBaseTypeDef
typeDef
,
AtlasVertex
vertex
)
{
if
(!
isTypeVertex
(
vertex
))
{
LOG
.
warn
(
"updateTypeVertex(): not a type-vertex - {}"
,
vertex
);
return
;
}
updateVertexProperty
(
vertex
,
Constants
.
GUID_PROPERTY_KEY
,
typeDef
.
getGuid
());
/*
* rename of a type is supported yet - as the typename is used to in the name of the edges from this vertex
* To support rename of types, he edge names should be derived from an internal-name - not directly the typename
*
updateVertexProperty(vertex, Constants.TYPENAME_PROPERTY_KEY, typeDef.getName());
*/
updateVertexProperty
(
vertex
,
Constants
.
TYPEDESCRIPTION_PROPERTY_KEY
,
typeDef
.
getDescription
());
updateVertexProperty
(
vertex
,
Constants
.
TYPEVERSION_PROPERTY_KEY
,
typeDef
.
getTypeVersion
());
markVertexUpdated
(
vertex
);
}
public
void
deleteTypeVertexOutEdges
(
AtlasVertex
vertex
)
throws
AtlasBaseException
{
Iterable
<
AtlasEdge
>
edges
=
vertex
.
getEdges
(
AtlasEdgeDirection
.
OUT
);
...
...
@@ -311,15 +333,23 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
return
ret
;
}
public
void
createSuperTypeEdges
(
AtlasVertex
vertex
,
Set
<
String
>
superTypes
,
TypeCategory
typeCategory
)
{
public
void
createSuperTypeEdges
(
AtlasVertex
vertex
,
Set
<
String
>
superTypes
,
TypeCategory
typeCategory
)
throws
AtlasBaseException
{
Set
<
String
>
currentSuperTypes
=
getSuperTypeNames
(
vertex
);
if
(
CollectionUtils
.
isNotEmpty
(
superTypes
))
{
if
(!
superTypes
.
containsAll
(
currentSuperTypes
))
{
throw
new
AtlasBaseException
(
"superType remove not supported"
);
}
for
(
String
superType
:
superTypes
)
{
AtlasVertex
superTypeVertex
=
findTypeVertexByNameAndCategory
(
superType
,
typeCategory
);
getOrCreateEdge
(
vertex
,
superTypeVertex
,
AtlasGraphUtilsV1
.
SUPERTYPE_EDGE_LABEL
);
}
}
else
if
(
CollectionUtils
.
isNotEmpty
(
currentSuperTypes
))
{
throw
new
AtlasBaseException
(
"superType remove not supported"
);
}
// TODO: remove any other superType edges, if any exists
}
public
Set
<
String
>
getSuperTypeNames
(
AtlasVertex
vertex
)
{
...
...
@@ -348,4 +378,42 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
return
ret
;
}
/*
* update the given vertex property, if the new value is not-blank
*/
private
void
updateVertexProperty
(
AtlasVertex
vertex
,
String
propertyName
,
String
newValue
)
{
if
(
StringUtils
.
isNotBlank
(
newValue
))
{
String
currValue
=
vertex
.
getProperty
(
propertyName
,
String
.
class
);
if
(!
StringUtils
.
equals
(
currValue
,
newValue
))
{
vertex
.
setProperty
(
propertyName
,
newValue
);
}
}
}
/*
* update the given vertex property, if the new value is not-null
*/
private
void
updateVertexProperty
(
AtlasVertex
vertex
,
String
propertyName
,
Date
newValue
)
{
if
(
newValue
!=
null
)
{
Number
currValue
=
vertex
.
getProperty
(
propertyName
,
Number
.
class
);
if
(
currValue
==
null
||
!
currValue
.
equals
(
newValue
.
getTime
()))
{
vertex
.
setProperty
(
propertyName
,
newValue
.
getTime
());
}
}
}
/*
* increment the version value for this vertex
*/
private
void
markVertexUpdated
(
AtlasVertex
vertex
)
{
Date
now
=
new
Date
();
Number
currVersion
=
vertex
.
getProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
Number
.
class
);
long
newVersion
=
currVersion
==
null
?
1
:
(
currVersion
.
longValue
()
+
1
);
vertex
.
setProperty
(
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
now
.
getTime
());
vertex
.
setProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
newVersion
);
}
}
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