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
d5b438b5
Commit
d5b438b5
authored
7 years ago
by
Sarath Subramanian
Committed by
Madhan Neethiraj
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2325: fix to prevent duplicate elements in SET type attributes
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
8c9d3da2
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
EntityGraphMapper.java
...he/atlas/repository/store/graph/v1/EntityGraphMapper.java
+9
-3
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
View file @
d5b438b5
...
@@ -33,6 +33,7 @@ import org.apache.atlas.model.instance.AtlasStruct;
...
@@ -33,6 +33,7 @@ import org.apache.atlas.model.instance.AtlasStruct;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.instance.EntityMutations.EntityOperation
;
import
org.apache.atlas.model.instance.EntityMutations.EntityOperation
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.graph.GraphHelper
;
...
@@ -60,18 +61,19 @@ import org.springframework.stereotype.Component;
...
@@ -60,18 +61,19 @@ import org.springframework.stereotype.Component;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasRelatedObjectId
.
KEY_RELATIONSHIP_ATTRIBUTES
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasRelatedObjectId
.
KEY_RELATIONSHIP_ATTRIBUTES
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
CREATE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
CREATE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
PARTIAL_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
PARTIAL_UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
UPDATE
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasStructDef
.
AtlasAttributeDef
.
Cardinality
.
SET
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
STATE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
STATE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTypeName
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getTypeName
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
isRelationshipEdge
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
isRelationshipEdge
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v1
.
AtlasGraphUtilsV1
.
getIdFromVertex
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v1
.
AtlasGraphUtilsV1
.
getIdFromVertex
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
BOTH
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
IN
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
IN
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
OUT
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
OUT
;
...
@@ -808,6 +810,7 @@ public class EntityGraphMapper {
...
@@ -808,6 +810,7 @@ public class EntityGraphMapper {
AtlasType
elementType
=
arrType
.
getElementType
();
AtlasType
elementType
=
arrType
.
getElementType
();
boolean
isReference
=
AtlasGraphUtilsV1
.
isReference
(
elementType
);
boolean
isReference
=
AtlasGraphUtilsV1
.
isReference
(
elementType
);
AtlasAttribute
inverseRefAttribute
=
attribute
.
getInverseRefAttribute
();
AtlasAttribute
inverseRefAttribute
=
attribute
.
getInverseRefAttribute
();
Cardinality
cardinality
=
attribute
.
getAttributeDef
().
getCardinality
();
List
<
Object
>
newElementsCreated
=
new
ArrayList
<>();
List
<
Object
>
newElementsCreated
=
new
ArrayList
<>();
List
<
Object
>
currentElements
;
List
<
Object
>
currentElements
;
...
@@ -818,6 +821,10 @@ public class EntityGraphMapper {
...
@@ -818,6 +821,10 @@ public class EntityGraphMapper {
}
}
if
(
CollectionUtils
.
isNotEmpty
(
newElements
))
{
if
(
CollectionUtils
.
isNotEmpty
(
newElements
))
{
if
(
cardinality
==
SET
)
{
newElements
=
(
List
)
newElements
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
}
for
(
int
index
=
0
;
index
<
newElements
.
size
();
index
++)
{
for
(
int
index
=
0
;
index
<
newElements
.
size
();
index
++)
{
AtlasEdge
existingEdge
=
getEdgeAt
(
currentElements
,
index
,
elementType
);
AtlasEdge
existingEdge
=
getEdgeAt
(
currentElements
,
index
,
elementType
);
AttributeMutationContext
arrCtx
=
new
AttributeMutationContext
(
ctx
.
getOp
(),
ctx
.
getReferringVertex
(),
ctx
.
getAttribute
(),
newElements
.
get
(
index
),
AttributeMutationContext
arrCtx
=
new
AttributeMutationContext
(
ctx
.
getOp
(),
ctx
.
getReferringVertex
(),
ctx
.
getAttribute
(),
newElements
.
get
(
index
),
...
@@ -1507,4 +1514,4 @@ public class EntityGraphMapper {
...
@@ -1507,4 +1514,4 @@ public class EntityGraphMapper {
return
currentEntityId
;
return
currentEntityId
;
}
}
}
}
\ 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