Commit 4d9cf456 by Suma Shivaprasad

ATLAS-1229 Add TypeCategory and methods to access attribute definitiions in AtlasTypes (sumasai)

parent d185522b
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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>();
......
......@@ -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;
......
......@@ -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;
}
}
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment