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
14037eed
Commit
14037eed
authored
Mar 28, 2019
by
lma
Committed by
Sarath Subramanian
Mar 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3031: UI : Allow user to export the lineage in PNG or JPEG format
Signed-off-by:
Sarath Subramanian
<
ssubramanian@hortonworks.com
>
parent
8dc4041c
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
132 additions
and
33 deletions
+132
-33
AtlasJanusElement.java
...che/atlas/repository/graphdb/janus/AtlasJanusElement.java
+8
-4
AtlasArrayType.java
intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
+3
-5
TestUtilsV2.java
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
+37
-0
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+0
-4
AtlasGraphUtilsV2.java
...he/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java
+2
-3
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+22
-5
EntityGraphRetriever.java
...atlas/repository/store/graph/v2/EntityGraphRetriever.java
+11
-11
AtlasComplexAttributesTest.java
...repository/store/graph/v2/AtlasComplexAttributesTest.java
+49
-1
No files found.
graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusElement.java
View file @
14037eed
...
@@ -109,7 +109,14 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
...
@@ -109,7 +109,14 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
@Override
@Override
public
void
setProperty
(
String
propertyName
,
Object
value
)
{
public
void
setProperty
(
String
propertyName
,
Object
value
)
{
try
{
try
{
if
(
value
==
null
)
{
Object
existingVal
=
getProperty
(
propertyName
,
Object
.
class
);
if
(
existingVal
!=
null
)
{
removeProperty
(
propertyName
);
}
}
else
{
getWrappedElement
().
property
(
propertyName
,
value
);
getWrappedElement
().
property
(
propertyName
,
value
);
}
}
catch
(
SchemaViolationException
e
)
{
}
catch
(
SchemaViolationException
e
)
{
throw
new
AtlasSchemaViolationException
(
e
);
throw
new
AtlasSchemaViolationException
(
e
);
}
}
...
@@ -157,9 +164,6 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
...
@@ -157,9 +164,6 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
@Override
@Override
public
List
<
String
>
getListProperty
(
String
propertyName
)
{
public
List
<
String
>
getListProperty
(
String
propertyName
)
{
List
<
String
>
value
=
getProperty
(
propertyName
,
List
.
class
);
List
<
String
>
value
=
getProperty
(
propertyName
,
List
.
class
);
if
(
value
==
null
)
{
return
Collections
.
emptyList
();
}
return
value
;
return
value
;
}
}
...
@@ -200,7 +204,7 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
...
@@ -200,7 +204,7 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
List
<
String
>
value
=
getListProperty
(
propertyName
);
List
<
String
>
value
=
getListProperty
(
propertyName
);
if
(
value
.
isEmpty
())
{
if
(
value
==
null
||
value
.
isEmpty
())
{
return
(
List
<
V
>)
value
;
return
(
List
<
V
>)
value
;
}
}
...
...
intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
View file @
14037eed
...
@@ -154,9 +154,9 @@ public class AtlasArrayType extends AtlasType {
...
@@ -154,9 +154,9 @@ public class AtlasArrayType extends AtlasType {
boolean
ret
=
true
;
boolean
ret
=
true
;
if
(
val1
==
null
)
{
if
(
val1
==
null
)
{
ret
=
isEmptyArrayValue
(
val2
)
;
ret
=
val2
==
null
;
}
else
if
(
val2
==
null
)
{
}
else
if
(
val2
==
null
)
{
ret
=
isEmptyArrayValue
(
val1
)
;
ret
=
false
;
}
else
{
}
else
{
if
(
val1
.
getClass
().
isArray
()
&&
val2
.
getClass
().
isArray
())
{
if
(
val1
.
getClass
().
isArray
()
&&
val2
.
getClass
().
isArray
())
{
int
len
=
Array
.
getLength
(
val1
);
int
len
=
Array
.
getLength
(
val1
);
...
@@ -510,9 +510,7 @@ public class AtlasArrayType extends AtlasType {
...
@@ -510,9 +510,7 @@ public class AtlasArrayType extends AtlasType {
}
}
private
boolean
isEmptyArrayValue
(
Object
val
)
{
private
boolean
isEmptyArrayValue
(
Object
val
)
{
if
(
val
==
null
)
{
if
(
val
instanceof
Collection
)
{
return
true
;
}
else
if
(
val
instanceof
Collection
)
{
return
((
Collection
)
val
).
isEmpty
();
return
((
Collection
)
val
).
isEmpty
();
}
else
if
(
val
.
getClass
().
isArray
())
{
}
else
if
(
val
.
getClass
().
isArray
())
{
return
Array
.
getLength
(
val
)
==
0
;
return
Array
.
getLength
(
val
)
==
0
;
...
...
intg/src/test/java/org/apache/atlas/TestUtilsV2.java
View file @
14037eed
...
@@ -553,6 +553,7 @@ public final class TestUtilsV2 {
...
@@ -553,6 +553,7 @@ public final class TestUtilsV2 {
public
static
final
String
SERDE_TYPE
=
"serdeType"
;
public
static
final
String
SERDE_TYPE
=
"serdeType"
;
public
static
final
String
COLUMNS_MAP
=
"columnsMap"
;
public
static
final
String
COLUMNS_MAP
=
"columnsMap"
;
public
static
final
String
COLUMNS_ATTR_NAME
=
"columns"
;
public
static
final
String
COLUMNS_ATTR_NAME
=
"columns"
;
public
static
final
String
ENTITY_TYPE_WITH_SIMPLE_ATTR
=
"entity_with_simple_attr"
;
public
static
final
String
ENTITY_TYPE_WITH_NESTED_COLLECTION_ATTR
=
"entity_with_nested_collection_attr"
;
public
static
final
String
ENTITY_TYPE_WITH_NESTED_COLLECTION_ATTR
=
"entity_with_nested_collection_attr"
;
public
static
final
String
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR
=
"entity_with_complex_collection_attr"
;
public
static
final
String
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR
=
"entity_with_complex_collection_attr"
;
public
static
final
String
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR_DELETE
=
"entity_with_complex_collection_attr_delete"
;
public
static
final
String
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR_DELETE
=
"entity_with_complex_collection_attr_delete"
;
...
@@ -621,6 +622,42 @@ public final class TestUtilsV2 {
...
@@ -621,6 +622,42 @@ public final class TestUtilsV2 {
return
ret
;
return
ret
;
}
}
public
static
AtlasTypesDef
defineSimpleAttrType
()
{
AtlasEntityDef
simpleAttributesEntityType
=
createClassTypeDef
(
ENTITY_TYPE_WITH_SIMPLE_ATTR
,
ENTITY_TYPE_WITH_SIMPLE_ATTR
+
"_description"
,
null
,
createUniqueRequiredAttrDef
(
"name"
,
"string"
),
new
AtlasAttributeDef
(
"stringAtrr"
,
"string"
,
true
,
SINGLE
,
1
,
1
,
false
,
false
,
false
,
null
),
new
AtlasAttributeDef
(
"arrayOfStrings"
,
"array<string>"
,
true
,
SINGLE
,
1
,
1
,
false
,
false
,
false
,
null
),
new
AtlasAttributeDef
(
"mapOfStrings"
,
"map<string,string>"
,
true
,
SINGLE
,
1
,
1
,
false
,
false
,
false
,
null
)
);
AtlasTypesDef
ret
=
AtlasTypeUtil
.
getTypesDef
(
Collections
.<
AtlasEnumDef
>
emptyList
(),
Collections
.<
AtlasStructDef
>
emptyList
(),
Collections
.<
AtlasClassificationDef
>
emptyList
(),
Collections
.
singletonList
(
simpleAttributesEntityType
));
return
ret
;
}
public
static
AtlasEntityWithExtInfo
createSimpleAttrTypeEntity
()
{
AtlasEntity
entity
=
new
AtlasEntity
(
ENTITY_TYPE_WITH_SIMPLE_ATTR
);
entity
.
setAttribute
(
NAME
,
ENTITY_TYPE_WITH_SIMPLE_ATTR
);
entity
.
setAttribute
(
"stringAtrr"
,
"DummyThree"
);
entity
.
setAttribute
(
"arrayOfStrings"
,
Arrays
.
asList
(
"DummyOne"
,
"DummyTwo"
));
entity
.
setAttribute
(
"mapOfStrings"
,
Collections
.
singletonMap
(
"one"
,
"DummyString"
));
return
new
AtlasEntityWithExtInfo
(
entity
);
}
public
static
AtlasTypesDef
defineHiveTypes
()
{
public
static
AtlasTypesDef
defineHiveTypes
()
{
String
_description
=
"_description"
;
String
_description
=
"_description"
;
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
14037eed
...
@@ -1587,10 +1587,6 @@ public final class GraphHelper {
...
@@ -1587,10 +1587,6 @@ public final class GraphHelper {
public
static
Map
<
String
,
Object
>
getPrimitiveMap
(
AtlasVertex
instanceVertex
,
String
propertyName
)
{
public
static
Map
<
String
,
Object
>
getPrimitiveMap
(
AtlasVertex
instanceVertex
,
String
propertyName
)
{
Map
<
String
,
Object
>
ret
=
instanceVertex
.
getProperty
(
AtlasGraphUtilsV2
.
encodePropertyKey
(
propertyName
),
Map
.
class
);
Map
<
String
,
Object
>
ret
=
instanceVertex
.
getProperty
(
AtlasGraphUtilsV2
.
encodePropertyKey
(
propertyName
),
Map
.
class
);
if
(
ret
==
null
)
{
ret
=
new
HashMap
<>();
}
return
ret
;
return
ret
;
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java
View file @
14037eed
...
@@ -228,12 +228,11 @@ public class AtlasGraphUtilsV2 {
...
@@ -228,12 +228,11 @@ public class AtlasGraphUtilsV2 {
Object
existingValue
=
element
.
getProperty
(
propertyName
,
Object
.
class
);
Object
existingValue
=
element
.
getProperty
(
propertyName
,
Object
.
class
);
if
(
value
==
null
||
(
value
instanceof
Collection
&&
((
Collection
)
value
).
isEmpty
())
)
{
if
(
value
==
null
)
{
if
(
existingValue
!=
null
)
{
if
(
existingValue
!=
null
)
{
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing property {} from {}"
,
propertyName
,
toString
(
element
));
LOG
.
debug
(
"Removing property {} from {}"
,
propertyName
,
toString
(
element
));
}
}
element
.
removeProperty
(
propertyName
);
element
.
removeProperty
(
propertyName
);
}
}
}
else
{
}
else
{
...
@@ -242,7 +241,7 @@ public class AtlasGraphUtilsV2 {
...
@@ -242,7 +241,7 @@ public class AtlasGraphUtilsV2 {
LOG
.
debug
(
"Setting property {} in {}"
,
propertyName
,
toString
(
element
));
LOG
.
debug
(
"Setting property {} in {}"
,
propertyName
,
toString
(
element
));
}
}
if
(
value
instanceof
Date
)
{
if
(
value
instanceof
Date
)
{
Long
encodedValue
=
((
Date
)
value
).
getTime
();
Long
encodedValue
=
((
Date
)
value
).
getTime
();
element
.
setProperty
(
propertyName
,
encodedValue
);
element
.
setProperty
(
propertyName
,
encodedValue
);
}
else
{
}
else
{
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
14037eed
...
@@ -947,7 +947,12 @@ public class EntityGraphMapper {
...
@@ -947,7 +947,12 @@ public class EntityGraphMapper {
boolean
isReference
=
isReference
(
mapType
.
getValueType
());
boolean
isReference
=
isReference
(
mapType
.
getValueType
());
boolean
isSoftReference
=
ctx
.
getAttribute
().
getAttributeDef
().
isSoftReferenced
();
boolean
isSoftReference
=
ctx
.
getAttribute
().
getAttributeDef
().
isSoftReferenced
();
if
(
MapUtils
.
isNotEmpty
(
newVal
))
{
boolean
isNewValNull
=
newVal
==
null
;
if
(
isNewValNull
)
{
newVal
=
new
HashMap
<>();
}
String
propertyName
=
ctx
.
getVertexProperty
();
String
propertyName
=
ctx
.
getVertexProperty
();
if
(
isReference
)
{
if
(
isReference
)
{
...
@@ -987,12 +992,18 @@ public class EntityGraphMapper {
...
@@ -987,12 +992,18 @@ public class EntityGraphMapper {
newMap
.
putAll
(
finalMap
);
newMap
.
putAll
(
finalMap
);
}
else
{
}
else
{
// primitive type map
// primitive type map
if
(
isNewValNull
)
{
ctx
.
getReferringVertex
().
setProperty
(
propertyName
,
null
);
}
else
{
ctx
.
getReferringVertex
().
setProperty
(
propertyName
,
new
HashMap
<>(
newVal
));
ctx
.
getReferringVertex
().
setProperty
(
propertyName
,
new
HashMap
<>(
newVal
));
}
newVal
.
forEach
((
key
,
value
)
->
newMap
.
put
(
key
.
toString
(),
value
));
newVal
.
forEach
((
key
,
value
)
->
newMap
.
put
(
key
.
toString
(),
value
));
}
}
if
(
isSoftReference
)
{
if
(
isSoftReference
)
{
if
(
isNewValNull
)
{
ctx
.
getReferringVertex
().
setProperty
(
propertyName
,
null
);
}
else
{
ctx
.
getReferringVertex
().
setProperty
(
propertyName
,
new
HashMap
<>(
newMap
));
ctx
.
getReferringVertex
().
setProperty
(
propertyName
,
new
HashMap
<>(
newMap
));
}
}
}
}
...
@@ -1019,6 +1030,7 @@ public class EntityGraphMapper {
...
@@ -1019,6 +1030,7 @@ public class EntityGraphMapper {
Cardinality
cardinality
=
attribute
.
getAttributeDef
().
getCardinality
();
Cardinality
cardinality
=
attribute
.
getAttributeDef
().
getCardinality
();
List
<
Object
>
newElementsCreated
=
new
ArrayList
<>();
List
<
Object
>
newElementsCreated
=
new
ArrayList
<>();
List
<
Object
>
currentElements
;
List
<
Object
>
currentElements
;
boolean
isNewElementsNull
=
newElements
==
null
;
if
(
isReference
&&
!
isSoftReference
)
{
if
(
isReference
&&
!
isSoftReference
)
{
currentElements
=
(
List
)
getCollectionElementsUsingRelationship
(
ctx
.
getReferringVertex
(),
attribute
);
currentElements
=
(
List
)
getCollectionElementsUsingRelationship
(
ctx
.
getReferringVertex
(),
attribute
);
...
@@ -1026,7 +1038,10 @@ public class EntityGraphMapper {
...
@@ -1026,7 +1038,10 @@ public class EntityGraphMapper {
currentElements
=
(
List
)
getArrayElementsProperty
(
elementType
,
isSoftReference
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
());
currentElements
=
(
List
)
getArrayElementsProperty
(
elementType
,
isSoftReference
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
());
}
}
if
(
CollectionUtils
.
isNotEmpty
(
newElements
))
{
if
(
isNewElementsNull
)
{
newElements
=
new
ArrayList
();
}
if
(
cardinality
==
SET
)
{
if
(
cardinality
==
SET
)
{
newElements
=
(
List
)
newElements
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
newElements
=
(
List
)
newElements
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
}
}
...
@@ -1049,7 +1064,6 @@ public class EntityGraphMapper {
...
@@ -1049,7 +1064,6 @@ public class EntityGraphMapper {
newElementsCreated
.
add
(
newEntry
);
newElementsCreated
.
add
(
newEntry
);
}
}
}
}
}
if
(
isReference
&&
!
isSoftReference
)
{
if
(
isReference
&&
!
isSoftReference
)
{
List
<
AtlasEdge
>
additionalEdges
=
removeUnusedArrayEntries
(
attribute
,
(
List
)
currentElements
,
(
List
)
newElementsCreated
,
ctx
.
getReferringVertex
());
List
<
AtlasEdge
>
additionalEdges
=
removeUnusedArrayEntries
(
attribute
,
(
List
)
currentElements
,
(
List
)
newElementsCreated
,
ctx
.
getReferringVertex
());
...
@@ -1065,8 +1079,11 @@ public class EntityGraphMapper {
...
@@ -1065,8 +1079,11 @@ public class EntityGraphMapper {
}
}
}
}
// for dereference on way out
if
(
isNewElementsNull
)
{
setArrayElementsProperty
(
elementType
,
isSoftReference
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
null
);
}
else
{
setArrayElementsProperty
(
elementType
,
isSoftReference
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
newElementsCreated
);
setArrayElementsProperty
(
elementType
,
isSoftReference
,
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
newElementsCreated
);
}
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== mapArrayValue({})"
,
ctx
);
LOG
.
debug
(
"<== mapArrayValue({})"
,
ctx
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
View file @
14037eed
...
@@ -74,6 +74,7 @@ import java.util.HashMap;
...
@@ -74,6 +74,7 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.ListIterator
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -740,7 +741,9 @@ public class EntityGraphRetriever {
...
@@ -740,7 +741,9 @@ public class EntityGraphRetriever {
Map
<
String
,
AtlasObjectId
>
ret
=
null
;
Map
<
String
,
AtlasObjectId
>
ret
=
null
;
Map
softRefVal
=
entityVertex
.
getProperty
(
attribute
.
getVertexPropertyName
(),
Map
.
class
);
Map
softRefVal
=
entityVertex
.
getProperty
(
attribute
.
getVertexPropertyName
(),
Map
.
class
);
if
(
MapUtils
.
isNotEmpty
(
softRefVal
))
{
if
(
MapUtils
.
isEmpty
(
softRefVal
))
{
return
softRefVal
;
}
else
{
ret
=
new
HashMap
<>();
ret
=
new
HashMap
<>();
for
(
Object
mapKey
:
softRefVal
.
keySet
())
{
for
(
Object
mapKey
:
softRefVal
.
keySet
())
{
...
@@ -751,7 +754,6 @@ public class EntityGraphRetriever {
...
@@ -751,7 +754,6 @@ public class EntityGraphRetriever {
}
}
}
}
}
}
return
ret
;
return
ret
;
}
}
...
@@ -759,7 +761,9 @@ public class EntityGraphRetriever {
...
@@ -759,7 +761,9 @@ public class EntityGraphRetriever {
List
<
AtlasObjectId
>
ret
=
null
;
List
<
AtlasObjectId
>
ret
=
null
;
List
softRefVal
=
entityVertex
.
getListProperty
(
attribute
.
getVertexPropertyName
(),
List
.
class
);
List
softRefVal
=
entityVertex
.
getListProperty
(
attribute
.
getVertexPropertyName
(),
List
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
softRefVal
))
{
if
(
CollectionUtils
.
isEmpty
(
softRefVal
))
{
return
softRefVal
;
}
else
{
ret
=
new
ArrayList
<>();
ret
=
new
ArrayList
<>();
for
(
Object
o
:
softRefVal
)
{
for
(
Object
o
:
softRefVal
)
{
...
@@ -841,10 +845,6 @@ public class EntityGraphRetriever {
...
@@ -841,10 +845,6 @@ public class EntityGraphRetriever {
ret
=
getPrimitiveMap
(
entityVertex
,
attribute
.
getVertexPropertyName
());
ret
=
getPrimitiveMap
(
entityVertex
,
attribute
.
getVertexPropertyName
());
}
}
if
(
MapUtils
.
isEmpty
(
ret
))
{
ret
=
null
;
}
return
ret
;
return
ret
;
}
}
...
@@ -855,14 +855,14 @@ public class EntityGraphRetriever {
...
@@ -855,14 +855,14 @@ public class EntityGraphRetriever {
AtlasType
arrayElementType
=
arrayType
.
getElementType
();
AtlasType
arrayElementType
=
arrayType
.
getElementType
();
List
<
Object
>
arrayElements
=
getArrayElementsProperty
(
arrayElementType
,
entityVertex
,
attribute
);
List
<
Object
>
arrayElements
=
getArrayElementsProperty
(
arrayElementType
,
entityVertex
,
attribute
);
if
(
CollectionUtils
.
isEmpty
(
arrayElements
))
{
return
null
;
}
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Mapping array attribute {} for vertex {}"
,
arrayElementType
.
getTypeName
(),
entityVertex
);
LOG
.
debug
(
"Mapping array attribute {} for vertex {}"
,
arrayElementType
.
getTypeName
(),
entityVertex
);
}
}
if
(
CollectionUtils
.
isEmpty
(
arrayElements
))
{
return
arrayElements
;
}
List
arrValues
=
new
ArrayList
(
arrayElements
.
size
());
List
arrValues
=
new
ArrayList
(
arrayElements
.
size
());
String
edgeLabel
=
attribute
.
getRelationshipEdgeLabel
();
String
edgeLabel
=
attribute
.
getRelationshipEdgeLabel
();
AtlasRelationshipEdgeDirection
edgeDirection
=
attribute
.
getRelationshipEdgeDirection
();
AtlasRelationshipEdgeDirection
edgeDirection
=
attribute
.
getRelationshipEdgeDirection
();
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasComplexAttributesTest.java
View file @
14037eed
...
@@ -38,6 +38,7 @@ import org.testng.annotations.Test;
...
@@ -38,6 +38,7 @@ import org.testng.annotations.Test;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -48,6 +49,7 @@ import static org.apache.atlas.TestUtilsV2.ENTITY_TYPE;
...
@@ -48,6 +49,7 @@ import static org.apache.atlas.TestUtilsV2.ENTITY_TYPE;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_MAP
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_MAP
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR_DELETE
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR_DELETE
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
ENTITY_TYPE_WITH_SIMPLE_ATTR
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
NAME
;
import
static
org
.
apache
.
atlas
.
TestUtilsV2
.
NAME
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getStatus
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getStatus
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasTypeUtil
.
getAtlasObjectId
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasTypeUtil
.
getAtlasObjectId
;
...
@@ -66,7 +68,8 @@ public class AtlasComplexAttributesTest extends AtlasEntityTestBase {
...
@@ -66,7 +68,8 @@ public class AtlasComplexAttributesTest extends AtlasEntityTestBase {
// create typeDefs
// create typeDefs
AtlasTypesDef
[]
testTypesDefs
=
new
AtlasTypesDef
[]
{
TestUtilsV2
.
defineTypeWithComplexCollectionAttributes
(),
AtlasTypesDef
[]
testTypesDefs
=
new
AtlasTypesDef
[]
{
TestUtilsV2
.
defineTypeWithComplexCollectionAttributes
(),
TestUtilsV2
.
defineTypeWithMapAttributes
()
};
TestUtilsV2
.
defineTypeWithMapAttributes
(),
TestUtilsV2
.
defineSimpleAttrType
()};
createTypesDef
(
testTypesDefs
);
createTypesDef
(
testTypesDefs
);
// create entity
// create entity
...
@@ -195,6 +198,51 @@ public class AtlasComplexAttributesTest extends AtlasEntityTestBase {
...
@@ -195,6 +198,51 @@ public class AtlasComplexAttributesTest extends AtlasEntityTestBase {
attrEntity
.
setAttribute
(
"mapAttr5"
,
map5
);
attrEntity
.
setAttribute
(
"mapAttr5"
,
map5
);
}
}
@Test
public
void
testArrayAttribute
()
throws
Exception
{
init
();
AtlasEntityWithExtInfo
simpleEntity
=
TestUtilsV2
.
createSimpleAttrTypeEntity
();
EntityMutationResponse
response
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
simpleEntity
),
false
);
AtlasEntityHeader
simpleEntityHeader
=
response
.
getFirstCreatedEntityByTypeName
(
ENTITY_TYPE_WITH_SIMPLE_ATTR
);
AtlasEntity
createdSimpleEntity
=
getEntityFromStore
(
simpleEntityHeader
);
validateEntity
(
simpleEntity
,
createdSimpleEntity
);
createdSimpleEntity
.
setAttribute
(
"stringAtrr"
,
null
);
createdSimpleEntity
.
setAttribute
(
"mapOfStrings"
,
Collections
.
emptyMap
());
createdSimpleEntity
.
setAttribute
(
"arrayOfStrings"
,
Collections
.
emptyList
());
EntityMutationResponse
responseUpdated
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
createdSimpleEntity
),
false
);
AtlasEntityHeader
simpleEntityUpdatedHeader
=
responseUpdated
.
getFirstUpdatedEntityByTypeName
(
ENTITY_TYPE_WITH_SIMPLE_ATTR
);
AtlasEntity
updatedSimpleEntity
=
getEntityFromStore
(
simpleEntityUpdatedHeader
);
assertNull
(
updatedSimpleEntity
.
getAttribute
(
"stringAtrr"
));
assertEquals
(
updatedSimpleEntity
.
getAttribute
(
"mapOfStrings"
),
Collections
.
emptyMap
());
assertEquals
(
updatedSimpleEntity
.
getAttribute
(
"arrayOfStrings"
),
Collections
.
emptyList
());
updatedSimpleEntity
.
setAttribute
(
"stringAtrr"
,
""
);
updatedSimpleEntity
.
setAttribute
(
"mapOfStrings"
,
null
);
updatedSimpleEntity
.
setAttribute
(
"arrayOfStrings"
,
null
);
EntityMutationResponse
responseUpdatedAgain
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
updatedSimpleEntity
),
false
);
AtlasEntityHeader
simpleEntityUpdatedAgainHeader
=
responseUpdatedAgain
.
getFirstUpdatedEntityByTypeName
(
ENTITY_TYPE_WITH_SIMPLE_ATTR
);
AtlasEntity
updatedAgainSimpleEntity
=
getEntityFromStore
(
simpleEntityUpdatedAgainHeader
);
assertEquals
(
updatedAgainSimpleEntity
.
getAttribute
(
"stringAtrr"
),
""
);
assertNull
(
updatedAgainSimpleEntity
.
getAttribute
(
"arrayOfStrings"
));
assertNull
(
updatedAgainSimpleEntity
.
getAttribute
(
"mapOfStrings"
));
updatedAgainSimpleEntity
.
setAttribute
(
"stringAtrr"
,
"Dummy String Test 3"
);
updatedAgainSimpleEntity
.
setAttribute
(
"mapOfStrings"
,
Collections
.
singletonMap
(
"key1"
,
"val1"
));
updatedAgainSimpleEntity
.
setAttribute
(
"arrayOfStrings"
,
Arrays
.
asList
(
"DummyTest3"
,
"DummyTest4"
));
EntityMutationResponse
updateRes
=
entityStore
.
createOrUpdate
(
new
AtlasEntityStream
(
updatedAgainSimpleEntity
),
false
);
AtlasEntityHeader
updateHeader
=
updateRes
.
getFirstUpdatedEntityByTypeName
(
ENTITY_TYPE_WITH_SIMPLE_ATTR
);
AtlasEntity
updateEntity
=
getEntityFromStore
(
updateHeader
);
assertEquals
(
updateEntity
.
getAttribute
(
"stringAtrr"
),
"Dummy String Test 3"
);
assertEquals
(
updateEntity
.
getAttribute
(
"arrayOfStrings"
),
Arrays
.
asList
(
"DummyTest3"
,
"DummyTest4"
));
assertEquals
(
updateEntity
.
getAttribute
(
"mapOfStrings"
),
Collections
.
singletonMap
(
"key1"
,
"val1"
));
}
@Test
(
dependsOnMethods
=
"testCreateComplexAttributeEntity"
)
@Test
(
dependsOnMethods
=
"testCreateComplexAttributeEntity"
)
public
void
testStructArray
()
throws
Exception
{
public
void
testStructArray
()
throws
Exception
{
init
();
init
();
...
...
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