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
43639766
Commit
43639766
authored
9 years ago
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-289 updateEntity does not remove existing edge for multiplicity-one…
ATLAS-289 updateEntity does not remove existing edge for multiplicity-one reference (dkantor via shwethags)
parent
c0b4975b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
7 deletions
+75
-7
release-log.txt
release-log.txt
+1
-0
GraphBackedMetadataRepository.java
...atlas/repository/graph/GraphBackedMetadataRepository.java
+18
-1
TestUtils.java
repository/src/test/java/org/apache/atlas/TestUtils.java
+24
-4
GraphBackedMetadataRepositoryTest.java
...s/repository/graph/GraphBackedMetadataRepositoryTest.java
+32
-2
No files found.
release-log.txt
View file @
43639766
...
...
@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags)
ALL CHANGES:
ATLAS-289 updateEntity does not remove existing edge for multiplicity-one reference (dkantor via shwethags)
ATLAS-300 Need additional integration test coverage for entity notifications (tbeerbower via shwethags)
ATLAS-304 surefire fails to run tests if maven project directory path has embedded space(dkantor via sumasai)
ATLAS-301 Atlas Distribution module test is failing (yhemanth via shwethags)
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
View file @
43639766
...
...
@@ -357,6 +357,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
if
(
attrTypeCategory
==
DataTypes
.
TypeCategory
.
PRIMITIVE
)
{
instance
.
set
(
property
,
value
);
}
else
if
(
attrTypeCategory
==
DataTypes
.
TypeCategory
.
CLASS
)
{
// Disconnect any existing reference to the previous reference target.
disconnectClassReference
(
instanceVertex
,
attributeInfo
,
instance
);
Id
id
=
new
Id
(
value
,
0
,
attributeInfo
.
dataType
().
getName
());
instance
.
set
(
property
,
id
);
}
else
{
...
...
@@ -373,6 +377,19 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
}
}
private
void
disconnectClassReference
(
Vertex
instanceVertex
,
AttributeInfo
attributeInfo
,
ITypedReferenceableInstance
instance
)
throws
AtlasException
{
String
edgeLabel
=
getEdgeLabel
(
instance
,
attributeInfo
);
Iterable
<
Edge
>
edges
=
instanceVertex
.
getEdges
(
Direction
.
OUT
,
edgeLabel
);
if
(
edges
!=
null
)
{
Iterator
<
Edge
>
it
=
edges
.
iterator
();
if
(
it
.
hasNext
())
{
titanGraph
.
removeEdge
(
it
.
next
());
}
}
}
public
Id
getIdFromVertex
(
String
dataTypeName
,
Vertex
vertex
)
{
return
new
Id
(
vertex
.<
String
>
getProperty
(
Constants
.
GUID_PROPERTY_KEY
),
vertex
.<
Integer
>
getProperty
(
Constants
.
VERSION_PROPERTY_KEY
),
dataTypeName
);
...
...
@@ -849,7 +866,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
}
if
(
referenceVertex
!=
null
)
{
//
add an edge to the class vertex from the instance
//
Add an edge to the class vertex from the instance.
Edge
edge
=
GraphHelper
.
addEdge
(
titanGraph
,
instanceVertex
,
referenceVertex
,
propertyKey
);
return
String
.
valueOf
(
edge
.
getId
());
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/TestUtils.java
View file @
43639766
...
...
@@ -114,7 +114,8 @@ public final class TestUtils {
createOptionalAttrDef
(
"orgLevel"
,
"OrgLevel"
),
createOptionalAttrDef
(
"address"
,
"Address"
),
new
AttributeDefinition
(
"department"
,
"Department"
,
Multiplicity
.
REQUIRED
,
false
,
"employees"
),
new
AttributeDefinition
(
"manager"
,
"Manager"
,
Multiplicity
.
OPTIONAL
,
false
,
"subordinates"
));
new
AttributeDefinition
(
"manager"
,
"Manager"
,
Multiplicity
.
OPTIONAL
,
false
,
"subordinates"
),
new
AttributeDefinition
(
"mentor"
,
"Person"
,
Multiplicity
.
OPTIONAL
,
false
,
null
));
HierarchicalTypeDefinition
<
ClassType
>
managerTypeDef
=
createClassTypeDef
(
"Manager"
,
ImmutableList
.
of
(
"Person"
),
new
AttributeDefinition
(
"subordinates"
,
String
.
format
(
"array<%s>"
,
"Person"
),
Multiplicity
.
COLLECTION
,
...
...
@@ -135,7 +136,11 @@ public final class TestUtils {
Referenceable
jane
=
new
Referenceable
(
"Manager"
,
"SecurityClearance"
);
Referenceable
johnAddr
=
new
Referenceable
(
"Address"
);
Referenceable
janeAddr
=
new
Referenceable
(
"Address"
);
Referenceable
julius
=
new
Referenceable
(
"Manager"
);
Referenceable
juliusAddr
=
new
Referenceable
(
"Address"
);
Referenceable
max
=
new
Referenceable
(
"Person"
);
Referenceable
maxAddr
=
new
Referenceable
(
"Address"
);
hrDept
.
set
(
"name"
,
"hr"
);
john
.
set
(
"name"
,
"John"
);
john
.
set
(
"department"
,
hrDept
);
...
...
@@ -149,11 +154,26 @@ public final class TestUtils {
janeAddr
.
set
(
"city"
,
"Santa Clara"
);
jane
.
set
(
"address"
,
janeAddr
);
julius
.
set
(
"name"
,
"Julius"
);
julius
.
set
(
"department"
,
hrDept
);
juliusAddr
.
set
(
"street"
,
"Madison Ave"
);
juliusAddr
.
set
(
"city"
,
"Newtonville"
);
julius
.
set
(
"address"
,
juliusAddr
);
julius
.
set
(
"subordinates"
,
ImmutableList
.<
Referenceable
>
of
());
max
.
set
(
"name"
,
"Max"
);
max
.
set
(
"department"
,
hrDept
);
maxAddr
.
set
(
"street"
,
"Ripley St"
);
maxAddr
.
set
(
"city"
,
"Newton"
);
max
.
set
(
"address"
,
maxAddr
);
max
.
set
(
"manager"
,
jane
);
max
.
set
(
"mentor"
,
julius
);
john
.
set
(
"manager"
,
jane
);
hrDept
.
set
(
"employees"
,
ImmutableList
.
of
(
john
,
jane
));
hrDept
.
set
(
"employees"
,
ImmutableList
.
of
(
john
,
jane
,
julius
,
max
));
jane
.
set
(
"subordinates"
,
ImmutableList
.
of
(
john
));
jane
.
set
(
"subordinates"
,
ImmutableList
.
of
(
john
,
max
));
jane
.
getTrait
(
"SecurityClearance"
).
set
(
"level"
,
1
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
View file @
43639766
...
...
@@ -137,12 +137,12 @@ public class GraphBackedMetadataRepositoryTest {
Assert
.
fail
();
}
@Test
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testGetEntityList
()
throws
Exception
{
List
<
String
>
entityList
=
repositoryService
.
getEntityList
(
TestUtils
.
ENTITY_TYPE
);
System
.
out
.
println
(
"entityList = "
+
entityList
);
Assert
.
assertNotNull
(
entityList
);
Assert
.
assert
Equals
(
entityList
.
size
(),
1
);
// one department
Assert
.
assert
True
(
entityList
.
contains
(
guid
));
}
@Test
...
...
@@ -471,6 +471,36 @@ public class GraphBackedMetadataRepositoryTest {
row
=
(
JSONObject
)
results
.
get
(
0
);
Assert
.
assertEquals
(
row
.
get
(
"typeName"
),
"Person"
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testUpdateEntity_MultiplicityOneNonCompositeReference
()
throws
Exception
{
ITypedReferenceableInstance
john
=
repositoryService
.
getEntityDefinition
(
"Person"
,
"name"
,
"John"
);
String
johnGuid
=
john
.
getId
().
_getId
();
ITypedReferenceableInstance
max
=
repositoryService
.
getEntityDefinition
(
"Person"
,
"name"
,
"Max"
);
String
maxGuid
=
max
.
getId
().
_getId
();
ITypedReferenceableInstance
jane
=
repositoryService
.
getEntityDefinition
(
"Person"
,
"name"
,
"Jane"
);
String
janeGuid
=
jane
.
getId
().
_getId
();
// Update max's mentor reference to john.
repositoryService
.
updateEntity
(
maxGuid
,
"mentor"
,
johnGuid
);
// Verify the update was applied correctly - john should now be max's mentor.
max
=
repositoryService
.
getEntityDefinition
(
maxGuid
);
Object
object
=
max
.
get
(
"mentor"
);
Assert
.
assertTrue
(
object
instanceof
ITypedReferenceableInstance
);
ITypedReferenceableInstance
refTarget
=
(
ITypedReferenceableInstance
)
object
;
Assert
.
assertEquals
(
refTarget
.
getId
().
_getId
(),
johnGuid
);
// Update max's mentor reference to jane.
repositoryService
.
updateEntity
(
maxGuid
,
"mentor"
,
janeGuid
);
// Verify the update was applied correctly - jane should now be max's mentor.
max
=
repositoryService
.
getEntityDefinition
(
maxGuid
);
object
=
max
.
get
(
"mentor"
);
Assert
.
assertTrue
(
object
instanceof
ITypedReferenceableInstance
);
refTarget
=
(
ITypedReferenceableInstance
)
object
;
Assert
.
assertEquals
(
refTarget
.
getId
().
_getId
(),
janeGuid
);
}
private
ITypedReferenceableInstance
createHiveTableInstance
(
Referenceable
databaseInstance
)
throws
Exception
{
Referenceable
tableInstance
=
new
Referenceable
(
TestUtils
.
TABLE_TYPE
,
TestUtils
.
CLASSIFICATION
);
...
...
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