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
67d48953
Commit
67d48953
authored
Mar 26, 2018
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2514: Deleting a table with lineage should not remove propagated classification edges
parent
14d5a8e6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
23 deletions
+61
-23
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+37
-0
DeleteHandlerV1.java
...ache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+19
-18
SoftDeleteHandlerV1.java
.../atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java
+5
-5
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
67d48953
...
@@ -917,6 +917,43 @@ public final class GraphHelper {
...
@@ -917,6 +917,43 @@ public final class GraphHelper {
return
ret
;
return
ret
;
}
}
public
static
List
<
AtlasEdge
>
getClassificationEdges
(
AtlasVertex
entityVertex
)
{
return
getClassificationEdges
(
entityVertex
,
false
);
}
public
static
List
<
AtlasEdge
>
getPropagatedClassificationEdges
(
AtlasVertex
entityVertex
)
{
return
getClassificationEdges
(
entityVertex
,
true
);
}
public
static
List
<
AtlasEdge
>
getAllClassificationEdges
(
AtlasVertex
entityVertex
)
{
return
getClassificationEdges
(
entityVertex
,
null
);
}
public
static
List
<
AtlasEdge
>
getClassificationEdges
(
AtlasVertex
entityVertex
,
Boolean
propagated
)
{
List
<
AtlasEdge
>
ret
=
new
ArrayList
<>();
AtlasVertexQuery
query
=
entityVertex
.
query
().
direction
(
AtlasEdgeDirection
.
OUT
).
label
(
CLASSIFICATION_LABEL
);
if
(
propagated
!=
null
)
{
query
=
query
.
has
(
CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY
,
propagated
);
}
Iterable
edges
=
query
.
edges
();
if
(
edges
!=
null
)
{
Iterator
<
AtlasEdge
>
iterator
=
edges
.
iterator
();
while
(
iterator
.
hasNext
())
{
AtlasEdge
edge
=
iterator
.
next
();
if
(
edge
!=
null
)
{
ret
.
add
(
edge
);
}
}
}
return
ret
;
}
public
static
List
<
String
>
getSuperTypeNames
(
AtlasVertex
<?,?>
entityVertex
)
{
public
static
List
<
String
>
getSuperTypeNames
(
AtlasVertex
<?,?>
entityVertex
)
{
ArrayList
<
String
>
superTypes
=
new
ArrayList
<>();
ArrayList
<
String
>
superTypes
=
new
ArrayList
<>();
Collection
<
String
>
propertyValues
=
entityVertex
.
getPropertyValues
(
Constants
.
SUPER_TYPES_PROPERTY_KEY
,
String
.
class
);
Collection
<
String
>
propertyValues
=
entityVertex
.
getPropertyValues
(
Constants
.
SUPER_TYPES_PROPERTY_KEY
,
String
.
class
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
View file @
67d48953
...
@@ -52,6 +52,8 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL;
...
@@ -52,6 +52,8 @@ import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
EDGE_LABEL_PREFIX
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
EDGE_LABEL_PREFIX
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
addListProperty
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
addListProperty
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getClassificationEdge
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getClassificationEdges
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getPropagatedEdges
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getPropagatedEdges
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTraitNames
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTraitNames
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTypeName
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTypeName
;
...
@@ -112,7 +114,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -112,7 +114,7 @@ public abstract class DeleteHandlerV1 {
// Delete traits and vertices.
// Delete traits and vertices.
for
(
AtlasVertex
deletionCandidateVertex
:
deletionCandidateVertices
)
{
for
(
AtlasVertex
deletionCandidateVertex
:
deletionCandidateVertices
)
{
deleteAll
Trait
s
(
deletionCandidateVertex
);
deleteAll
Classification
s
(
deletionCandidateVertex
);
deleteTypeVertex
(
deletionCandidateVertex
,
false
);
deleteTypeVertex
(
deletionCandidateVertex
,
false
);
}
}
}
}
...
@@ -336,9 +338,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -336,9 +338,7 @@ public abstract class DeleteHandlerV1 {
break
;
break
;
case
CLASSIFICATION:
case
CLASSIFICATION:
removeTagPropagation
(
instanceVertex
);
deleteClassificationVertex
(
instanceVertex
,
force
);
deleteTypeVertex
(
instanceVertex
,
force
);
break
;
break
;
case
ENTITY:
case
ENTITY:
...
@@ -367,7 +367,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -367,7 +367,7 @@ public abstract class DeleteHandlerV1 {
getTypeName
(
propagatedEntityVertex
),
GraphHelper
.
getGuid
(
propagatedEntityVertex
),
CLASSIFICATION_LABEL
);
getTypeName
(
propagatedEntityVertex
),
GraphHelper
.
getGuid
(
propagatedEntityVertex
),
CLASSIFICATION_LABEL
);
}
}
remove
PropagatedTraitName
(
propagatedEntityVertex
,
classificationName
);
remove
FromPropagatedTraitNames
(
propagatedEntityVertex
,
classificationName
);
deleteEdge
(
propagatedEdge
,
true
);
deleteEdge
(
propagatedEdge
,
true
);
...
@@ -381,7 +381,7 @@ public abstract class DeleteHandlerV1 {
...
@@ -381,7 +381,7 @@ public abstract class DeleteHandlerV1 {
return
ret
;
return
ret
;
}
}
private
void
remove
PropagatedTraitName
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
private
void
remove
FromPropagatedTraitNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
if
(
entityVertex
!=
null
&&
StringUtils
.
isNotEmpty
(
classificationName
))
{
if
(
entityVertex
!=
null
&&
StringUtils
.
isNotEmpty
(
classificationName
))
{
List
<
String
>
propagatedTraitNames
=
getTraitNames
(
entityVertex
,
true
);
List
<
String
>
propagatedTraitNames
=
getTraitNames
(
entityVertex
,
true
);
...
@@ -485,22 +485,15 @@ public abstract class DeleteHandlerV1 {
...
@@ -485,22 +485,15 @@ public abstract class DeleteHandlerV1 {
}
}
/**
/**
* Delete all
traits from the specified
vertex.
* Delete all
associated classifications from the specified entity
vertex.
* @param instanceVertex
* @param instanceVertex
* @throws AtlasException
* @throws AtlasException
*/
*/
private
void
deleteAllTraits
(
AtlasVertex
instanceVertex
)
throws
AtlasBaseException
{
private
void
deleteAllClassifications
(
AtlasVertex
instanceVertex
)
throws
AtlasBaseException
{
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
List
<
AtlasEdge
>
classificationEdges
=
getClassificationEdges
(
instanceVertex
);
List
<
String
>
traitNames
=
GraphHelper
.
getTraitNames
(
instanceVertex
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting traits {} for {}"
,
traitNames
,
string
(
instanceVertex
));
}
for
(
String
traitNameToBeDeleted
:
traitNames
)
{
for
(
AtlasEdge
edge
:
classificationEdges
)
{
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
typeName
,
traitNameToBeDeleted
);
deleteEdgeReference
(
edge
,
TypeCategory
.
CLASSIFICATION
,
false
,
false
,
instanceVertex
);
deleteEdgeReference
(
instanceVertex
,
relationshipLabel
,
TypeCategory
.
CLASSIFICATION
,
false
);
}
}
}
}
...
@@ -689,4 +682,12 @@ public abstract class DeleteHandlerV1 {
...
@@ -689,4 +682,12 @@ public abstract class DeleteHandlerV1 {
_deleteVertex
(
instanceVertex
,
force
);
_deleteVertex
(
instanceVertex
,
force
);
}
}
protected
void
deleteClassificationVertex
(
AtlasVertex
classificationVertex
,
boolean
force
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting classification vertex"
,
string
(
classificationVertex
));
}
_deleteVertex
(
classificationVertex
,
force
);
}
}
}
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java
View file @
67d48953
...
@@ -49,10 +49,10 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
...
@@ -49,10 +49,10 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
graphHelper
.
removeVertex
(
instanceVertex
);
graphHelper
.
removeVertex
(
instanceVertex
);
}
else
{
}
else
{
AtlasEntity
.
Status
state
=
AtlasGraphUtilsV1
.
getState
(
instanceVertex
);
AtlasEntity
.
Status
state
=
AtlasGraphUtilsV1
.
getState
(
instanceVertex
);
if
(
state
!=
AtlasEntity
.
Status
.
DELETED
)
{
if
(
state
!=
AtlasEntity
.
Status
.
DELETED
)
{
GraphHelper
.
setProperty
(
instanceVertex
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
DELETED
.
name
());
GraphHelper
.
setProperty
(
instanceVertex
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
DELETED
.
name
());
GraphHelper
.
setProperty
(
instanceVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
GraphHelper
.
setProperty
(
instanceVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContextV1
.
get
().
getRequestTime
());
RequestContextV1
.
get
().
getRequestTime
());
GraphHelper
.
setProperty
(
instanceVertex
,
MODIFIED_BY_KEY
,
RequestContextV1
.
get
().
getUser
());
GraphHelper
.
setProperty
(
instanceVertex
,
MODIFIED_BY_KEY
,
RequestContextV1
.
get
().
getUser
());
}
}
}
}
...
@@ -64,13 +64,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
...
@@ -64,13 +64,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
graphHelper
.
removeEdge
(
edge
);
graphHelper
.
removeEdge
(
edge
);
}
else
{
}
else
{
AtlasEntity
.
Status
state
=
AtlasGraphUtilsV1
.
getState
(
edge
);
AtlasEntity
.
Status
state
=
AtlasGraphUtilsV1
.
getState
(
edge
);
if
(
state
!=
AtlasEntity
.
Status
.
DELETED
)
{
if
(
state
!=
AtlasEntity
.
Status
.
DELETED
)
{
GraphHelper
.
setProperty
(
edge
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
DELETED
.
name
());
GraphHelper
.
setProperty
(
edge
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
DELETED
.
name
());
GraphHelper
GraphHelper
.
setProperty
(
edge
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContextV1
.
get
().
getRequestTime
());
.
setProperty
(
edge
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContextV1
.
get
().
getRequestTime
());
GraphHelper
.
setProperty
(
edge
,
MODIFIED_BY_KEY
,
RequestContextV1
.
get
().
getUser
());
GraphHelper
.
setProperty
(
edge
,
MODIFIED_BY_KEY
,
RequestContextV1
.
get
().
getUser
());
}
}
}
}
}
}
}
}
\ No newline at end of file
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