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
8bb31fdf
Commit
8bb31fdf
authored
Feb 28, 2017
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1584 Fix issues with owned map reference and add tests (sumasai)
parent
101abe6e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
37 deletions
+78
-37
AtlasStructType.java
.../src/main/java/org/apache/atlas/type/AtlasStructType.java
+4
-0
TestUtilsV2.java
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
+4
-1
release-log.txt
release-log.txt
+2
-1
AtlasGraphUtilsV1.java
...he/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
+1
-2
EntityGraphMapper.java
...he/atlas/repository/store/graph/v1/EntityGraphMapper.java
+32
-13
AtlasDeleteHandlerV1Test.java
...s/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
+0
-0
AtlasEntityStoreV1Test.java
...las/repository/store/graph/v1/AtlasEntityStoreV1Test.java
+4
-20
HardDeleteHandlerV1Test.java
...as/repository/store/graph/v1/HardDeleteHandlerV1Test.java
+18
-0
SoftDeleteHandlerV1Test.java
...as/repository/store/graph/v1/SoftDeleteHandlerV1Test.java
+13
-0
No files found.
intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
View file @
8bb31fdf
...
@@ -559,6 +559,10 @@ public class AtlasStructType extends AtlasType {
...
@@ -559,6 +559,10 @@ public class AtlasStructType extends AtlasType {
type
=
((
AtlasArrayType
)
type
).
getElementType
();
type
=
((
AtlasArrayType
)
type
).
getElementType
();
}
}
if
(
type
instanceof
AtlasMapType
)
{
type
=
((
AtlasMapType
)
type
).
getValueType
();
}
return
type
instanceof
AtlasEntityType
?
(
AtlasEntityType
)
type
:
null
;
return
type
instanceof
AtlasEntityType
?
(
AtlasEntityType
)
type
:
null
;
}
}
...
...
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
View file @
8bb31fdf
...
@@ -713,7 +713,10 @@ public final class TestUtilsV2 {
...
@@ -713,7 +713,10 @@ public final class TestUtilsV2 {
true
,
true
,
AtlasAttributeDef
.
Cardinality
.
SINGLE
,
0
,
1
,
AtlasAttributeDef
.
Cardinality
.
SINGLE
,
0
,
1
,
false
,
false
,
false
,
false
,
Collections
.<
AtlasStructDef
.
AtlasConstraintDef
>
emptyList
()
new
ArrayList
<
AtlasStructDef
.
AtlasConstraintDef
>()
{{
add
(
new
AtlasStructDef
.
AtlasConstraintDef
(
AtlasConstraintDef
.
CONSTRAINT_TYPE_OWNED_REF
));
}}
),
),
//map of structs
//map of structs
new
AtlasAttributeDef
(
"partitionsMap"
,
new
AtlasAttributeDef
(
"partitionsMap"
,
...
...
release-log.txt
View file @
8bb31fdf
...
@@ -9,7 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
...
@@ -9,7 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ALL CHANGES:
ATLAS_1589 DSL queries return wrong object when filter traverses an edge (jnhagelberg)
ATLAS-1584 Fix issues with owned map reference and add tests (sumasai)
ATLAS-1589 DSL queries return wrong object when filter traverses an edge (jnhagelberg)
ATLAS-1590 UI : Edit Button is enabled for Deleted entities. (kevalbhatt)
ATLAS-1590 UI : Edit Button is enabled for Deleted entities. (kevalbhatt)
ATLAS-1487 Create Entity in UI : types list doesn't list fs_permissions (struct type) hence no entity could be created for it. (kevalbhatt)
ATLAS-1487 Create Entity in UI : types list doesn't list fs_permissions (struct type) hence no entity could be created for it. (kevalbhatt)
ATLAS-1573 Full text mapping for Entity store V2
ATLAS-1573 Full text mapping for Entity store V2
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasGraphUtilsV1.java
View file @
8bb31fdf
...
@@ -225,8 +225,7 @@ public class AtlasGraphUtilsV1 {
...
@@ -225,8 +225,7 @@ public class AtlasGraphUtilsV1 {
public
static
AtlasVertex
findByGuid
(
String
guid
)
{
public
static
AtlasVertex
findByGuid
(
String
guid
)
{
AtlasGraphQuery
query
=
AtlasGraphProvider
.
getGraphInstance
().
query
()
AtlasGraphQuery
query
=
AtlasGraphProvider
.
getGraphInstance
().
query
()
.
has
(
Constants
.
GUID_PROPERTY_KEY
,
guid
)
.
has
(
Constants
.
GUID_PROPERTY_KEY
,
guid
);
.
has
(
Constants
.
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
Iterator
<
AtlasVertex
>
results
=
query
.
vertices
().
iterator
();
Iterator
<
AtlasVertex
>
results
=
query
.
vertices
().
iterator
();
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
View file @
8bb31fdf
...
@@ -59,6 +59,7 @@ import java.util.Collection;
...
@@ -59,6 +59,7 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -68,6 +69,7 @@ import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.CR
...
@@ -68,6 +69,7 @@ import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.CR
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
.
instance
.
EntityMutations
.
EntityOperation
.
DELETE
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
EntityMutations
.
EntityOperation
.
DELETE
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
STATE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
string
;
...
@@ -437,7 +439,11 @@ public class EntityGraphMapper {
...
@@ -437,7 +439,11 @@ public class EntityGraphMapper {
Map
<
String
,
Object
>
finalMap
=
removeUnusedMapEntries
(
attribute
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
currentMap
,
newMap
);
Map
<
String
,
Object
>
finalMap
=
removeUnusedMapEntries
(
attribute
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
currentMap
,
newMap
);
Set
<
String
>
newKeys
=
new
HashSet
<>(
newMap
.
keySet
());
for
(
Object
newEntry
:
newMap
.
values
())
{
updateInConsistentOwnedMapVertices
(
ctx
,
mapType
,
newEntry
);
}
Set
<
String
>
newKeys
=
new
LinkedHashSet
<>(
newMap
.
keySet
());
newKeys
.
addAll
(
finalMap
.
keySet
());
newKeys
.
addAll
(
finalMap
.
keySet
());
// for dereference on way out
// for dereference on way out
...
@@ -534,21 +540,21 @@ public class EntityGraphMapper {
...
@@ -534,21 +540,21 @@ public class EntityGraphMapper {
private
Object
mapCollectionElementsToVertex
(
AttributeMutationContext
ctx
,
EntityMutationContext
context
)
throws
AtlasBaseException
{
private
Object
mapCollectionElementsToVertex
(
AttributeMutationContext
ctx
,
EntityMutationContext
context
)
throws
AtlasBaseException
{
switch
(
ctx
.
getAttrType
().
getTypeCategory
())
{
switch
(
ctx
.
getAttrType
().
getTypeCategory
())
{
case
PRIMITIVE:
case
PRIMITIVE:
case
ENUM:
case
ENUM:
return
ctx
.
getValue
();
return
ctx
.
getValue
();
case
STRUCT:
case
STRUCT:
return
mapStructValue
(
ctx
,
context
);
return
mapStructValue
(
ctx
,
context
);
case
OBJECT_ID_TYPE:
case
OBJECT_ID_TYPE:
AtlasEntityType
instanceType
=
getInstanceType
(
ctx
.
getValue
());
AtlasEntityType
instanceType
=
getInstanceType
(
ctx
.
getValue
());
ctx
.
setElementType
(
instanceType
);
ctx
.
setElementType
(
instanceType
);
return
mapObjectIdValue
(
ctx
,
context
);
return
mapObjectIdValue
(
ctx
,
context
);
case
MAP:
case
MAP:
case
ARRAY:
case
ARRAY:
default
:
default
:
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_CATEGORY_INVALID
,
ctx
.
getAttrType
().
getTypeCategory
().
name
());
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_CATEGORY_INVALID
,
ctx
.
getAttrType
().
getTypeCategory
().
name
());
}
}
}
}
...
@@ -776,6 +782,19 @@ public class EntityGraphMapper {
...
@@ -776,6 +782,19 @@ public class EntityGraphMapper {
return
new
AtlasEntityHeader
(
id
.
getTypeName
(),
id
.
getGuid
(),
id
.
getUniqueAttributes
());
return
new
AtlasEntityHeader
(
id
.
getTypeName
(),
id
.
getGuid
(),
id
.
getUniqueAttributes
());
}
}
private
void
updateInConsistentOwnedMapVertices
(
AttributeMutationContext
ctx
,
AtlasMapType
mapType
,
Object
val
)
{
if
(
mapType
.
getValueType
().
getTypeCategory
()
==
TypeCategory
.
OBJECT_ID_TYPE
)
{
AtlasEdge
edge
=
(
AtlasEdge
)
val
;
if
(
ctx
.
getAttribute
().
isOwnedRef
()
&&
GraphHelper
.
getStatus
(
edge
)
==
AtlasEntity
.
Status
.
DELETED
&&
GraphHelper
.
getStatus
(
edge
.
getInVertex
())
==
AtlasEntity
.
Status
.
DELETED
)
{
//Resurrect the vertex and edge to ACTIVE state
GraphHelper
.
setProperty
(
edge
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
GraphHelper
.
setProperty
(
edge
.
getInVertex
(),
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
}
}
}
public
void
addClassifications
(
final
EntityMutationContext
context
,
String
guid
,
List
<
AtlasClassification
>
classifications
)
public
void
addClassifications
(
final
EntityMutationContext
context
,
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasBaseException
{
throws
AtlasBaseException
{
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java
View file @
8bb31fdf
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
View file @
8bb31fdf
...
@@ -261,7 +261,6 @@ public class AtlasEntityStoreV1Test {
...
@@ -261,7 +261,6 @@ public class AtlasEntityStoreV1Test {
partsMap
.
put
(
"part0"
,
new
AtlasStruct
(
TestUtils
.
PARTITION_STRUCT_TYPE
,
TestUtilsV2
.
NAME
,
"test"
));
partsMap
.
put
(
"part0"
,
new
AtlasStruct
(
TestUtils
.
PARTITION_STRUCT_TYPE
,
TestUtilsV2
.
NAME
,
"test"
));
tableEntity
.
setAttribute
(
"partitionsMap"
,
partsMap
);
tableEntity
.
setAttribute
(
"partitionsMap"
,
partsMap
);
entitiesInfo
.
addReferredEntity
(
tableEntity
);
init
();
init
();
EntityMutationResponse
response
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entitiesInfo
),
false
);
EntityMutationResponse
response
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entitiesInfo
),
false
);
...
@@ -365,10 +364,14 @@ public class AtlasEntityStoreV1Test {
...
@@ -365,10 +364,14 @@ public class AtlasEntityStoreV1Test {
AtlasEntityHeader
tableDefinition6
=
response
.
getFirstUpdatedEntityByTypeName
(
TABLE_TYPE
);
AtlasEntityHeader
tableDefinition6
=
response
.
getFirstUpdatedEntityByTypeName
(
TABLE_TYPE
);
validateEntity
(
entitiesInfo
,
getEntityFromStore
(
tableDefinition6
));
validateEntity
(
entitiesInfo
,
getEntityFromStore
(
tableDefinition6
));
Assert
.
assertEquals
(
entityStore
.
getById
(
col0
.
getGuid
()).
getEntity
().
getStatus
(),
AtlasEntity
.
Status
.
ACTIVE
);
Assert
.
assertEquals
(
entityStore
.
getById
(
col1
.
getGuid
()).
getEntity
().
getStatus
(),
AtlasEntity
.
Status
.
ACTIVE
);
//Drop the first key and change the class type as well to col0
//Drop the first key and change the class type as well to col0
columnsMap
.
clear
();
columnsMap
.
clear
();
columnsMap
.
put
(
"col0"
,
AtlasTypeUtil
.
getAtlasObjectId
(
col0
));
columnsMap
.
put
(
"col0"
,
AtlasTypeUtil
.
getAtlasObjectId
(
col0
));
init
();
init
();
response
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entitiesInfo
),
false
);
response
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
entitiesInfo
),
false
);
AtlasEntityHeader
tableDefinition7
=
response
.
getFirstUpdatedEntityByTypeName
(
TABLE_TYPE
);
AtlasEntityHeader
tableDefinition7
=
response
.
getFirstUpdatedEntityByTypeName
(
TABLE_TYPE
);
validateEntity
(
entitiesInfo
,
getEntityFromStore
(
tableDefinition7
));
validateEntity
(
entitiesInfo
,
getEntityFromStore
(
tableDefinition7
));
...
@@ -494,25 +497,6 @@ public class AtlasEntityStoreV1Test {
...
@@ -494,25 +497,6 @@ public class AtlasEntityStoreV1Test {
validateEntity
(
entitiesInfo
,
getEntityFromStore
(
updatedTable
));
validateEntity
(
entitiesInfo
,
getEntityFromStore
(
updatedTable
));
}
}
// private AtlasEntity clearSubOrdinates(List<AtlasObjectId> employees, int index) {
//
// AtlasEntity ret = null;
// AtlasObjectId employee = employees.get(index);
// AtlasEntity subOrdClone = new ArrayList<>(subOrdinates);
// ret = subOrdClone.remove(index);
//
// employees.get(index).setAttribute("subordinates", subOrdClone);
// return ret;
// }
//
// private int addSubordinate(AtlasEntity manager, AtlasEntity employee) {
// List<AtlasEntity> subOrdinates = (List<AtlasEntity>) manager.getAttribute("subordinates");
// subOrdinates.add(employee);
//
// manager.setAttribute("subordinates", subOrdinates);
// return subOrdinates.size() - 1;
// }
@Test
(
dependsOnMethods
=
"testCreate"
)
@Test
(
dependsOnMethods
=
"testCreate"
)
public
void
testClassUpdate
()
throws
Exception
{
public
void
testClassUpdate
()
throws
Exception
{
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java
View file @
8bb31fdf
...
@@ -26,6 +26,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
...
@@ -26,6 +26,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.IStruct
;
...
@@ -146,6 +147,23 @@ public class HardDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test {
...
@@ -146,6 +147,23 @@ public class HardDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test {
}
}
}
}
protected
void
assertTestDisconnectMapReferenceFromClassType
(
final
String
mapOwnerGuid
)
throws
Exception
{
// Verify map references from mapOwner were disconnected.
AtlasEntity
.
AtlasEntityWithExtInfo
mapOwnerInstance
=
entityStore
.
getById
(
mapOwnerGuid
);
Map
<
String
,
AtlasObjectId
>
map
=
(
Map
<
String
,
AtlasObjectId
>)
mapOwnerInstance
.
getEntity
().
getAttribute
(
"map"
);
Assert
.
assertNull
(
map
);
Map
<
String
,
AtlasObjectId
>
biMap
=
(
Map
<
String
,
AtlasObjectId
>)
mapOwnerInstance
.
getEntity
().
getAttribute
(
"biMap"
);
Assert
.
assertNull
(
biMap
);
AtlasVertex
mapOwnerVertex
=
GraphHelper
.
getInstance
().
getVertexForGUID
(
mapOwnerGuid
);
Object
object
=
mapOwnerVertex
.
getProperty
(
"MapOwner.map.value1"
,
String
.
class
);
assertNull
(
object
);
object
=
mapOwnerVertex
.
getProperty
(
"MapOwner.biMap.value1"
,
String
.
class
);
assertNull
(
object
);
}
@Override
@Override
protected
void
assertTestDisconnectUnidirectionalArrayReferenceFromStructAndTraitTypes
(
String
structContainerGuid
)
protected
void
assertTestDisconnectUnidirectionalArrayReferenceFromStructAndTraitTypes
(
String
structContainerGuid
)
throws
Exception
{
throws
Exception
{
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java
View file @
8bb31fdf
...
@@ -183,6 +183,19 @@ public class SoftDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test {
...
@@ -183,6 +183,19 @@ public class SoftDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test {
}
}
@Override
@Override
protected
void
assertTestDisconnectMapReferenceFromClassType
(
final
String
mapOwnerGuid
)
throws
Exception
{
AtlasEntity
.
AtlasEntityWithExtInfo
mapOwnerInstance
=
entityStore
.
getById
(
mapOwnerGuid
);
Map
<
String
,
AtlasObjectId
>
map
=
(
Map
<
String
,
AtlasObjectId
>)
mapOwnerInstance
.
getEntity
().
getAttribute
(
"map"
);
assertNotNull
(
map
);
assertEquals
(
map
.
size
(),
1
);
Map
<
String
,
AtlasObjectId
>
biMap
=
(
Map
<
String
,
AtlasObjectId
>)
mapOwnerInstance
.
getEntity
().
getAttribute
(
"biMap"
);
assertNotNull
(
biMap
);
assertEquals
(
biMap
.
size
(),
1
);
}
@Override
protected
void
assertTestDisconnectUnidirectionalArrayReferenceFromStructAndTraitTypes
(
final
String
structContainerGuid
)
throws
Exception
{
protected
void
assertTestDisconnectUnidirectionalArrayReferenceFromStructAndTraitTypes
(
final
String
structContainerGuid
)
throws
Exception
{
// Verify that the unidirectional references from the struct and trait instances
// Verify that the unidirectional references from the struct and trait instances
// to the deleted entities were not disconnected.
// to the deleted entities were not disconnected.
...
...
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