You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by su...@apache.org on 2016/10/18 23:14:04 UTC
incubator-atlas git commit: ATLAS-1229 Add TypeCategory and methods
to access attribute definitiions in AtlasTypes (sumasai)
Repository: incubator-atlas
Updated Branches:
refs/heads/master d185522b5 -> 4d9cf4564
ATLAS-1229 Add TypeCategory and methods to access attribute definitiions in AtlasTypes (sumasai)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/4d9cf456
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/4d9cf456
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/4d9cf456
Branch: refs/heads/master
Commit: 4d9cf4564baa5aac6a1e123d8670fc1c13034668
Parents: d185522
Author: Suma Shivaprasad <su...@gmail.com>
Authored: Tue Oct 18 16:13:48 2016 -0700
Committer: Suma Shivaprasad <su...@gmail.com>
Committed: Tue Oct 18 16:13:48 2016 -0700
----------------------------------------------------------------------
.../org/apache/atlas/type/AtlasArrayType.java | 6 ++---
.../apache/atlas/type/AtlasBuiltInTypes.java | 24 ++++++++++----------
.../atlas/type/AtlasClassificationType.java | 2 +-
.../org/apache/atlas/type/AtlasEntityType.java | 2 +-
.../org/apache/atlas/type/AtlasEnumType.java | 2 +-
.../org/apache/atlas/type/AtlasMapType.java | 6 ++---
.../org/apache/atlas/type/AtlasStructType.java | 14 ++++++++++--
.../java/org/apache/atlas/type/AtlasType.java | 13 ++++++++++-
release-log.txt | 3 ++-
9 files changed, 47 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java b/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
index 2b79974..21a4037 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
@@ -48,7 +48,7 @@ public class AtlasArrayType extends AtlasType {
}
public AtlasArrayType(AtlasType elementType, int minCount, int maxCount) {
- super(AtlasBaseTypeDef.getArrayTypeName(elementType.getTypeName()));
+ super(AtlasBaseTypeDef.getArrayTypeName(elementType.getTypeName()), TypeCategory.ARRAY);
this.elementTypeName = elementType.getTypeName();
this.minCount = minCount;
@@ -61,7 +61,7 @@ public class AtlasArrayType extends AtlasType {
}
public AtlasArrayType(String elementTypeName, int minCount, int maxCount) {
- super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName));
+ super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName), TypeCategory.ARRAY);
this.elementTypeName = elementTypeName;
this.minCount = minCount;
@@ -75,7 +75,7 @@ public class AtlasArrayType extends AtlasType {
public AtlasArrayType(String elementTypeName, int minCount, int maxCount, AtlasTypeRegistry typeRegistry)
throws AtlasBaseException {
- super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName));
+ super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName), TypeCategory.ARRAY);
this.elementTypeName = elementTypeName;
this.minCount = minCount;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java b/intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java
index 16a3df6..c7dad29 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java
@@ -41,7 +41,7 @@ public class AtlasBuiltInTypes {
private static final Boolean DEFAULT_VALUE = Boolean.FALSE;
public AtlasBooleanType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN, TypeCategory.PRIMITIVE);
}
@Override
@@ -75,7 +75,7 @@ public class AtlasBuiltInTypes {
private static final Byte DEFAULT_VALUE = new Byte((byte)0);
public AtlasByteType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_BYTE);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_BYTE, TypeCategory.PRIMITIVE);
}
@Override
@@ -119,7 +119,7 @@ public class AtlasBuiltInTypes {
private static final Short DEFAULT_VALUE = new Short((short)0);
public AtlasShortType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_SHORT);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_SHORT, TypeCategory.PRIMITIVE);
}
@Override
@@ -163,7 +163,7 @@ public class AtlasBuiltInTypes {
private static final Integer DEFAULT_VALUE = new Integer(0);
public AtlasIntType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_INT);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_INT, TypeCategory.PRIMITIVE);
}
@Override
@@ -207,7 +207,7 @@ public class AtlasBuiltInTypes {
private static final Long DEFAULT_VALUE = new Long(0);
public AtlasLongType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_LONG);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_LONG, TypeCategory.PRIMITIVE);
}
@Override
@@ -251,7 +251,7 @@ public class AtlasBuiltInTypes {
private static final Float DEFAULT_VALUE = new Float(0);
public AtlasFloatType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_FLOAT);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_FLOAT, TypeCategory.PRIMITIVE);
}
@Override
@@ -295,7 +295,7 @@ public class AtlasBuiltInTypes {
private static final Double DEFAULT_VALUE = new Double(0);
public AtlasDoubleType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_DOUBLE);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_DOUBLE, TypeCategory.PRIMITIVE);
}
@Override
@@ -341,7 +341,7 @@ public class AtlasBuiltInTypes {
private static final BigInteger DEFAULT_VALUE = BigInteger.ZERO;
public AtlasBigIntegerType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER, TypeCategory.PRIMITIVE);
}
@Override
@@ -385,7 +385,7 @@ public class AtlasBuiltInTypes {
private static final BigDecimal DEFAULT_VALUE = BigDecimal.ZERO;
public AtlasBigDecimalType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL, TypeCategory.PRIMITIVE);
}
@Override
@@ -429,7 +429,7 @@ public class AtlasBuiltInTypes {
private static final Date DEFAULT_VALUE = new Date(0);
public AtlasDateType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_DATE);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_DATE, TypeCategory.PRIMITIVE);
}
@Override
@@ -478,7 +478,7 @@ public class AtlasBuiltInTypes {
private static final String DEFAULT_VALUE = "";
public AtlasStringType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_STRING);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_STRING, TypeCategory.PRIMITIVE);
}
@Override
@@ -506,7 +506,7 @@ public class AtlasBuiltInTypes {
*/
public static class AtlasObjectIdType extends AtlasType {
public AtlasObjectIdType() {
- super(AtlasBaseTypeDef.ATLAS_TYPE_OBJECT_ID);
+ super(AtlasBaseTypeDef.ATLAS_TYPE_OBJECT_ID, TypeCategory.OBJECT_ID_TYPE);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
index e0a0c6d..d962bbe 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
@@ -46,7 +46,7 @@ public class AtlasClassificationType extends AtlasStructType {
private Set<String> allSuperTypes = Collections.emptySet();
public AtlasClassificationType(AtlasClassificationDef classificationDef) {
- super(classificationDef);
+ super(classificationDef, TypeCategory.CLASSIFICATION);
this.classificationDef = classificationDef;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
index e91fb99..7017d65 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
@@ -45,7 +45,7 @@ public class AtlasEntityType extends AtlasStructType {
private Set<String> allSuperTypes = Collections.emptySet();
public AtlasEntityType(AtlasEntityDef entityDef) {
- super(entityDef);
+ super(entityDef, TypeCategory.ENTITY);
this.entityDef = entityDef;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasEnumType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasEnumType.java b/intg/src/main/java/org/apache/atlas/type/AtlasEnumType.java
index 5b41e71..e9a2021 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasEnumType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasEnumType.java
@@ -36,7 +36,7 @@ public class AtlasEnumType extends AtlasType {
private final String defaultValue;
public AtlasEnumType(AtlasEnumDef enumDef) {
- super(enumDef.getName());
+ super(enumDef.getName(), TypeCategory.PRIMITIVE);
Map<String, AtlasEnumElementDef> e = new HashMap<String, AtlasEnumElementDef>();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java b/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
index d770bc7..f2ab08b 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
@@ -39,14 +39,14 @@ public class AtlasMapType extends AtlasType {
private AtlasType valueType;
public AtlasMapType(String keyTypeName, String valueTypeName) {
- super(AtlasBaseTypeDef.getMapTypeName(keyTypeName, valueTypeName));
+ super(AtlasBaseTypeDef.getMapTypeName(keyTypeName, valueTypeName), TypeCategory.MAP);
this.keyTypeName = keyTypeName;
this.valueTypeName = valueTypeName;
}
public AtlasMapType(AtlasType keyType, AtlasType valueType) {
- super(AtlasBaseTypeDef.getMapTypeName(keyType.getTypeName(), valueType.getTypeName()));
+ super(AtlasBaseTypeDef.getMapTypeName(keyType.getTypeName(), valueType.getTypeName()), TypeCategory.MAP);
this.keyTypeName = keyType.getTypeName();
this.valueTypeName = valueType.getTypeName();
@@ -56,7 +56,7 @@ public class AtlasMapType extends AtlasType {
public AtlasMapType(String keyTypeName, String valueTypeName, AtlasTypeRegistry typeRegistry)
throws AtlasBaseException {
- super(AtlasBaseTypeDef.getMapTypeName(keyTypeName, valueTypeName));
+ super(AtlasBaseTypeDef.getMapTypeName(keyTypeName, valueTypeName), TypeCategory.MAP);
this.keyTypeName = keyTypeName;
this.valueTypeName = valueTypeName;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
index b1777c7..5c32db2 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
@@ -48,13 +48,19 @@ public class AtlasStructType extends AtlasType {
public AtlasStructType(AtlasStructDef structDef) {
- super(structDef.getName());
+ super(structDef.getName(), TypeCategory.STRUCT);
+
+ this.structDef = structDef;
+ }
+
+ public AtlasStructType(AtlasStructDef structDef, TypeCategory category) {
+ super(structDef.getName(), category);
this.structDef = structDef;
}
public AtlasStructType(AtlasStructDef structDef, AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
- super(structDef.getName());
+ super(structDef.getName(), TypeCategory.STRUCT);
this.structDef = structDef;
@@ -432,4 +438,8 @@ public class AtlasStructType extends AtlasType {
this.attributeName = attributeName;
}
}
+
+ public AtlasStructDef getStructDefinition() {
+ return structDef;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/intg/src/main/java/org/apache/atlas/type/AtlasType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasType.java b/intg/src/main/java/org/apache/atlas/type/AtlasType.java
index 204e305..a507bf4 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasType.java
@@ -31,13 +31,20 @@ import java.util.List;
*/
public abstract class AtlasType {
+ public enum TypeCategory {
+ PRIMITIVE, ARRAY, MAP, ENTITY, STRUCT, CLASSIFICATION, OBJECT_ID_TYPE
+ }
+
private static final Gson GSON =
new GsonBuilder().setDateFormat(AtlasBaseTypeDef.SERIALIZED_DATE_FORMAT_STR).create();
private final String typeName;
- public AtlasType(String typeName) {
+ private final TypeCategory typeCategory;
+
+ protected AtlasType(String typeName, TypeCategory category) {
this.typeName = typeName;
+ this.typeCategory = category;
}
public void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
@@ -51,6 +58,10 @@ public abstract class AtlasType {
public abstract Object getNormalizedValue(Object obj);
+ public TypeCategory getTypeCategory() {
+ return typeCategory;
+ }
+
public boolean validateValue(Object obj, String objName, List<String> messages) {
boolean ret = isValidValue(obj);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4d9cf456/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 4b42106..0792d46 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -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)
ALL CHANGES:
-ATLAS-1227 Added support for attribute constraints in the API
+ATLAS-1229 Add TypeCategory and methods to access attribute definitiions in AtlasTypes (sumasai)
+ATLAS-1227 Added support for attribute constraints in the API (mneethiraj)
ATLAS-1225 Optimize AtlasTypeDefGraphStore to use typeRegistry (mneethiraj via sumasai)
ATLAS-1221 build failure in windows SyntaxError: invalid syntax (zhangqiang2 via shwethags)
ATLAS-1226 Servlet init-params in web.xml are unused (mneethiraj via shwethags)