[atlas] 02/02: ATLAS-3700: added option to append value to array, map type attributes
This is an automated email from the ASF dual-hosted git repository. madhan pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git commit 9e17881ae092141a6656c78c14cab6ea19728b03 Author: Madhan Neethiraj AuthorDate: Tue Mar 31 10:53:43 2020 -0700 ATLAS-3700: added option to append value to array, map type attributes (cherry picked from commit f5cd728d561a3e58a6b69c8b635e04769103a67f) --- .../model/instance/EntityMutationResponse.java | 5 + .../apache/atlas/model/typedef/AtlasStructDef.java | 16 +++- .../test/java/org/apache/atlas/TestUtilsV2.java| 15 ++- .../store/graph/v2/EntityGraphMapper.java | 52 --- .../store/graph/v2/AtlasComplexAttributesTest.java | 101 - 5 files changed, 168 insertions(+), 21 deletions(-) diff --git a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java index 1434a24..d83f0e0 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java @@ -209,6 +209,11 @@ public class EntityMutationResponse { } @JsonIgnore +public AtlasEntityHeader getFirstPartialUpdatedEntityByTypeName(String typeName) { +return getFirstEntityByType(getEntitiesByOperation(EntityOperation.PARTIAL_UPDATE), typeName); +} + +@JsonIgnore public void addEntity(EntityOperation op, AtlasEntityHeader header) { // if an entity is already included in CREATE, ignore subsequent UPDATE, PARTIAL_UPDATE if (op == EntityOperation.UPDATE || op == EntityOperation.PARTIAL_UPDATE) { diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java index 1d4e37b..a621fb0 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java @@ -263,10 +263,11 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { public static final int DEFAULT_SEARCHWEIGHT = -1; -public static final StringSEARCH_WEIGHT_ATTR_NAME = "searchWeight"; -public static final StringINDEX_TYPE_ATTR_NAME = "indexType"; -public static final StringATTRDEF_OPTION_SOFT_REFERENCE = "isSoftReference"; -private final String STRING_TRUE = "true"; +public static final StringSEARCH_WEIGHT_ATTR_NAME = "searchWeight"; +public static final StringINDEX_TYPE_ATTR_NAME = "indexType"; +public static final StringATTRDEF_OPTION_SOFT_REFERENCE = "isSoftReference"; +public static final StringATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE = "isAppendOnPartialUpdate"; +private final String STRING_TRUE = "true"; /** * single-valued attribute or multi-valued attribute. @@ -520,6 +521,13 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { } @JsonIgnore +public boolean isAppendOnPartialUpdate() { +String val = getOption(AtlasAttributeDef.ATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE); + +return val != null && Boolean.valueOf(val); +} + +@JsonIgnore public void setOption(String name, String value) { if (this.options == null) { this.options = new HashMap<>(); diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 7ec2b87..55497fc 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -627,6 +627,13 @@ public final class TestUtilsV2 { } public static AtlasTypesDef defineSimpleAttrType() { +AtlasAttributeDef attrPuArray = new AtlasAttributeDef("puArray", "array", true, SINGLE, 1, 1, false, false, false, null); +AtlasAttributeDef attrPuMap = new AtlasAttributeDef("puMap", "map", true, SINGLE, 1,1, false, false, false, null); + + attrPuArray.setOption(AtlasAttributeDef.ATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE, "true"); + attrPuMap.setOption(AtlasAttributeDef.ATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE, "true"); + + AtlasEntityDef simpleAttributesEntityType = createClassTypeDef(ENTITY_TYPE_WITH_SIMPLE_ATTR, ENTITY_TYPE_WITH_SIMPLE_ATTR + "_description", null, createUniqueRequiredAttrDef("name", "string"), @@ -641,7 +648,11 @@ public final class TestUtilsV2 { false, false, false, null), new AtlasAttributeDef("mapOfStrings", "map",
[atlas] 02/02: ATLAS-3700: added option to append value to array, map type attributes
This is an automated email from the ASF dual-hosted git repository. madhan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git commit f5cd728d561a3e58a6b69c8b635e04769103a67f Author: Madhan Neethiraj AuthorDate: Tue Mar 31 10:53:43 2020 -0700 ATLAS-3700: added option to append value to array, map type attributes --- .../model/instance/EntityMutationResponse.java | 5 + .../apache/atlas/model/typedef/AtlasStructDef.java | 16 +++- .../test/java/org/apache/atlas/TestUtilsV2.java| 15 ++- .../store/graph/v2/EntityGraphMapper.java | 52 --- .../store/graph/v2/AtlasComplexAttributesTest.java | 101 - 5 files changed, 168 insertions(+), 21 deletions(-) diff --git a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java index 1434a24..d83f0e0 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java @@ -209,6 +209,11 @@ public class EntityMutationResponse { } @JsonIgnore +public AtlasEntityHeader getFirstPartialUpdatedEntityByTypeName(String typeName) { +return getFirstEntityByType(getEntitiesByOperation(EntityOperation.PARTIAL_UPDATE), typeName); +} + +@JsonIgnore public void addEntity(EntityOperation op, AtlasEntityHeader header) { // if an entity is already included in CREATE, ignore subsequent UPDATE, PARTIAL_UPDATE if (op == EntityOperation.UPDATE || op == EntityOperation.PARTIAL_UPDATE) { diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java index 1d4e37b..a621fb0 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java @@ -263,10 +263,11 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { public static final int DEFAULT_SEARCHWEIGHT = -1; -public static final StringSEARCH_WEIGHT_ATTR_NAME = "searchWeight"; -public static final StringINDEX_TYPE_ATTR_NAME = "indexType"; -public static final StringATTRDEF_OPTION_SOFT_REFERENCE = "isSoftReference"; -private final String STRING_TRUE = "true"; +public static final StringSEARCH_WEIGHT_ATTR_NAME = "searchWeight"; +public static final StringINDEX_TYPE_ATTR_NAME = "indexType"; +public static final StringATTRDEF_OPTION_SOFT_REFERENCE = "isSoftReference"; +public static final StringATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE = "isAppendOnPartialUpdate"; +private final String STRING_TRUE = "true"; /** * single-valued attribute or multi-valued attribute. @@ -520,6 +521,13 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { } @JsonIgnore +public boolean isAppendOnPartialUpdate() { +String val = getOption(AtlasAttributeDef.ATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE); + +return val != null && Boolean.valueOf(val); +} + +@JsonIgnore public void setOption(String name, String value) { if (this.options == null) { this.options = new HashMap<>(); diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 7ec2b87..55497fc 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -627,6 +627,13 @@ public final class TestUtilsV2 { } public static AtlasTypesDef defineSimpleAttrType() { +AtlasAttributeDef attrPuArray = new AtlasAttributeDef("puArray", "array", true, SINGLE, 1, 1, false, false, false, null); +AtlasAttributeDef attrPuMap = new AtlasAttributeDef("puMap", "map", true, SINGLE, 1,1, false, false, false, null); + + attrPuArray.setOption(AtlasAttributeDef.ATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE, "true"); + attrPuMap.setOption(AtlasAttributeDef.ATTRDEF_OPTION_APPEND_ON_PARTIAL_UPDATE, "true"); + + AtlasEntityDef simpleAttributesEntityType = createClassTypeDef(ENTITY_TYPE_WITH_SIMPLE_ATTR, ENTITY_TYPE_WITH_SIMPLE_ATTR + "_description", null, createUniqueRequiredAttrDef("name", "string"), @@ -641,7 +648,11 @@ public final class TestUtilsV2 { false, false, false, null), new AtlasAttributeDef("mapOfStrings", "map", -true, SINGLE, 1,1, false, false, false, null) +