http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java index 20569f1..3188840 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java @@ -36,17 +36,14 @@ public class HierarchicalTypeDefinition<T extends HierarchicalType> extends Stru * @throws ClassNotFoundException */ @InterfaceAudience.Private - public HierarchicalTypeDefinition(String hierarchicalMetaTypeName, - String typeName, String[] superTypes, - AttributeDefinition[] attributeDefinitions) - throws ClassNotFoundException { - this((Class<T>) Class.forName(hierarchicalMetaTypeName), - typeName, ImmutableList.copyOf(superTypes), attributeDefinitions); + public HierarchicalTypeDefinition(String hierarchicalMetaTypeName, String typeName, String[] superTypes, + AttributeDefinition[] attributeDefinitions) throws ClassNotFoundException { + this((Class<T>) Class.forName(hierarchicalMetaTypeName), typeName, ImmutableList.copyOf(superTypes), + attributeDefinitions); } - public HierarchicalTypeDefinition(Class<T> hierarchicalMetaType, - String typeName, ImmutableList<String> superTypes, - AttributeDefinition[] attributeDefinitions) { + public HierarchicalTypeDefinition(Class<T> hierarchicalMetaType, String typeName, ImmutableList<String> superTypes, + AttributeDefinition[] attributeDefinitions) { super(typeName, false, attributeDefinitions); hierarchicalMetaTypeName = hierarchicalMetaType.getName(); this.superTypes = superTypes == null ? ImmutableList.<String>of() : superTypes; @@ -54,14 +51,24 @@ public class HierarchicalTypeDefinition<T extends HierarchicalType> extends Stru @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } HierarchicalTypeDefinition that = (HierarchicalTypeDefinition) o; - if (!hierarchicalMetaTypeName.equals(that.hierarchicalMetaTypeName)) return false; - if (!superTypes.equals(that.superTypes)) return false; + if (!hierarchicalMetaTypeName.equals(that.hierarchicalMetaTypeName)) { + return false; + } + if (!superTypes.equals(that.superTypes)) { + return false; + } return true; }
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java index 210c945..a54dabc 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java @@ -31,6 +31,7 @@ public final class Multiplicity { public final int lower; public final int upper; public final boolean isUnique; + public Multiplicity(int lower, int upper, boolean isUnique) { assert lower >= 0; assert upper >= 1; @@ -46,14 +47,24 @@ public final class Multiplicity { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Multiplicity that = (Multiplicity) o; - if (isUnique != that.isUnique) return false; - if (lower != that.lower) return false; - if (upper != that.upper) return false; + if (isUnique != that.isUnique) { + return false; + } + if (lower != that.lower) { + return false; + } + if (upper != that.upper) { + return false; + } return true; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java index 8725d22..8824e7b 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphTraversal.java @@ -39,8 +39,7 @@ public class ObjectGraphTraversal implements Iterator<ObjectGraphTraversal.Insta final TypeSystem typeSystem; Set<Id> processedIds; - public ObjectGraphTraversal(TypeSystem typeSystem, IReferenceableInstance start) - throws AtlasException { + public ObjectGraphTraversal(TypeSystem typeSystem, IReferenceableInstance start) throws AtlasException { this.typeSystem = typeSystem; queue = new LinkedList<InstanceTuple>(); processedIds = new HashSet<Id>(); @@ -56,8 +55,8 @@ public class ObjectGraphTraversal implements Iterator<ObjectGraphTraversal.Insta IDataType keyType = ((DataTypes.MapType) dT).getKeyType(); IDataType valueType = ((DataTypes.MapType) dT).getKeyType(); processMap(keyType, valueType, val); - } else if (dT.getTypeCategory() == DataTypes.TypeCategory.STRUCT || - dT.getTypeCategory() == DataTypes.TypeCategory.TRAIT) { + } else if (dT.getTypeCategory() == DataTypes.TypeCategory.STRUCT + || dT.getTypeCategory() == DataTypes.TypeCategory.TRAIT) { processStruct(val); } else if (dT.getTypeCategory() == DataTypes.TypeCategory.CLASS) { processReferenceableInstance(val); @@ -66,8 +65,8 @@ public class ObjectGraphTraversal implements Iterator<ObjectGraphTraversal.Insta } void processMap(IDataType keyType, IDataType valueType, Object val) throws AtlasException { - if (keyType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE && - valueType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE) { + if (keyType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE + && valueType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE) { return; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java index 5112752..399902c 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java @@ -47,13 +47,11 @@ public class ObjectGraphWalker { final NodeProcessor nodeProcessor; Set<Id> processedIds; - public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor) - throws AtlasException { + public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor) throws AtlasException { this(typeSystem, nodeProcessor, (IReferenceableInstance) null); } - public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor, - IReferenceableInstance start) + public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor, IReferenceableInstance start) throws AtlasException { this.typeSystem = typeSystem; this.nodeProcessor = nodeProcessor; @@ -65,8 +63,7 @@ public class ObjectGraphWalker { } public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor, - List<? extends IReferenceableInstance> roots) - throws AtlasException { + List<? extends IReferenceableInstance> roots) throws AtlasException { this.typeSystem = typeSystem; this.nodeProcessor = nodeProcessor; queue = new LinkedList<IReferenceableInstance>(); @@ -96,8 +93,8 @@ public class ObjectGraphWalker { IDataType keyType = ((DataTypes.MapType) dT).getKeyType(); IDataType valueType = ((DataTypes.MapType) dT).getKeyType(); visitMap(keyType, valueType, val); - } else if (dT.getTypeCategory() == DataTypes.TypeCategory.STRUCT || - dT.getTypeCategory() == DataTypes.TypeCategory.TRAIT) { + } else if (dT.getTypeCategory() == DataTypes.TypeCategory.STRUCT + || dT.getTypeCategory() == DataTypes.TypeCategory.TRAIT) { visitStruct(val); } else if (dT.getTypeCategory() == DataTypes.TypeCategory.CLASS) { visitReferenceableInstance(val); @@ -106,8 +103,8 @@ public class ObjectGraphWalker { } void visitMap(IDataType keyType, IDataType valueType, Object val) throws AtlasException { - if (keyType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE && - valueType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE) { + if (keyType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE + && valueType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE) { return; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java index 0717bc2..448827e 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructType.java @@ -28,8 +28,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public class StructType extends AbstractDataType<IStruct> - implements IConstructableType<IStruct, ITypedStruct> { +public class StructType extends AbstractDataType<IStruct> implements IConstructableType<IStruct, ITypedStruct> { public final TypeSystem typeSystem; public final String name; @@ -50,13 +49,11 @@ public class StructType extends AbstractDataType<IStruct> this.handler = null; } - protected StructType(TypeSystem typeSystem, String name, - ImmutableList<String> superTypes, AttributeInfo... fields) + protected StructType(TypeSystem typeSystem, String name, ImmutableList<String> superTypes, AttributeInfo... fields) throws AtlasException { this.typeSystem = typeSystem; this.name = name; - this.fieldMapping = constructFieldMapping(superTypes, - fields); + this.fieldMapping = constructFieldMapping(superTypes, fields); infoToNameMap = TypeUtils.buildAttrInfoToNameMap(this.fieldMapping); this.numFields = this.fieldMapping.fields.size(); this.handler = new TypedStructHandler(this); @@ -71,8 +68,7 @@ public class StructType extends AbstractDataType<IStruct> return name; } - protected FieldMapping constructFieldMapping(ImmutableList<String> superTypes, - AttributeInfo... fields) + protected FieldMapping constructFieldMapping(ImmutableList<String> superTypes, AttributeInfo... fields) throws AtlasException { Map<String, AttributeInfo> fieldsMap = new LinkedHashMap<String, AttributeInfo>(); @@ -97,9 +93,7 @@ public class StructType extends AbstractDataType<IStruct> for (AttributeInfo i : fields) { if (fieldsMap.containsKey(i.name)) { throw new AtlasException( - String.format( - "Struct defintion cannot contain multiple fields with the same " + - "name %s", + String.format("Struct defintion cannot contain multiple fields with the same " + "name %s", i.name)); } fieldsMap.put(i.name, i); @@ -146,8 +140,8 @@ public class StructType extends AbstractDataType<IStruct> } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) { fieldPos.put(i.name, numMaps); numMaps++; - } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT || - i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { + } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT + || i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { fieldPos.put(i.name, numStructs); numStructs++; } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) { @@ -158,23 +152,8 @@ public class StructType extends AbstractDataType<IStruct> } } - return new FieldMapping(fieldsMap, - fieldPos, - fieldNullPos, - numBools, - numBytes, - numShorts, - numInts, - numLongs, - numFloats, - numDoubles, - numBigInts, - numBigDecimals, - numDates, - numStrings, - numArrays, - numMaps, - numStructs, + return new FieldMapping(fieldsMap, fieldPos, fieldNullPos, numBools, numBytes, numShorts, numInts, numLongs, + numFloats, numDoubles, numBigInts, numBigDecimals, numDates, numStrings, numArrays, numMaps, numStructs, numReferenceables); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java index be6228e..e4bd28d 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java @@ -42,13 +42,21 @@ public class StructTypeDefinition { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } StructTypeDefinition that = (StructTypeDefinition) o; - if (!Arrays.equals(attributeDefinitions, that.attributeDefinitions)) return false; - if (!typeName.equals(that.typeName)) return false; + if (!Arrays.equals(attributeDefinitions, that.attributeDefinitions)) { + return false; + } + if (!typeName.equals(that.typeName)) { + return false; + } return true; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/TraitType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TraitType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TraitType.java index 605e5bf..d23d247 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TraitType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TraitType.java @@ -35,15 +35,13 @@ public class TraitType extends HierarchicalType<TraitType, IStruct> /** * Used when creating a TraitType, to support recursive Structs. */ - TraitType(TypeSystem typeSystem, String name, ImmutableList<String> superTraits, - int numFields) { + TraitType(TypeSystem typeSystem, String name, ImmutableList<String> superTraits, int numFields) { super(typeSystem, TraitType.class, name, superTraits, numFields); handler = null; infoToNameMap = null; } - TraitType(TypeSystem typeSystem, String name, ImmutableList<String> superTraits, - AttributeInfo... fields) + TraitType(TypeSystem typeSystem, String name, ImmutableList<String> superTraits, AttributeInfo... fields) throws AtlasException { super(typeSystem, TraitType.class, name, superTraits, fields); handler = new TypedStructHandler(this); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java index 78e8414..0d0c783 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java @@ -29,7 +29,16 @@ import org.apache.atlas.typesystem.TypesDef; import javax.inject.Singleton; import java.lang.reflect.Constructor; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; @Singleton @@ -130,7 +139,7 @@ public class TypeSystem { if (types.containsKey(name)) { try { return cls.cast(types.get(name)); - } catch(ClassCastException cce) { + } catch (ClassCastException cce) { throw new AtlasException(cce); } } @@ -149,20 +158,18 @@ public class TypeSystem { */ String[] mapType = TypeUtils.parseAsMapType(name); if (mapType != null) { - IDataType dT = defineMapType(getDataType(IDataType.class, mapType[0]), - getDataType(IDataType.class, mapType[1])); + IDataType dT = + defineMapType(getDataType(IDataType.class, mapType[0]), getDataType(IDataType.class, mapType[1])); return cls.cast(dT); } throw new TypeNotFoundException(String.format("Unknown datatype: %s", name)); } - public StructType defineStructType(String name, - boolean errorIfExists, - AttributeDefinition... attrDefs) throws AtlasException { + public StructType defineStructType(String name, boolean errorIfExists, AttributeDefinition... attrDefs) + throws AtlasException { StructTypeDefinition structDef = new StructTypeDefinition(name, attrDefs); - defineTypes(ImmutableList.of(structDef), - ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), + defineTypes(ImmutableList.of(structDef), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); return getDataType(StructType.class, structDef.typeName); @@ -177,10 +184,8 @@ public class TypeSystem { * @return temporary struct type * @throws AtlasException */ - public StructType defineQueryResultType(String name, - Map<String, IDataType> tempTypes, - AttributeDefinition... attrDefs) - throws AtlasException { + public StructType defineQueryResultType(String name, Map<String, IDataType> tempTypes, + AttributeDefinition... attrDefs) throws AtlasException { AttributeInfo[] infos = new AttributeInfo[attrDefs.length]; for (int i = 0; i < attrDefs.length; i++) { @@ -190,53 +195,44 @@ public class TypeSystem { return new StructType(this, name, null, infos); } - public TraitType defineTraitType(HierarchicalTypeDefinition<TraitType> traitDef) - throws AtlasException { + public TraitType defineTraitType(HierarchicalTypeDefinition<TraitType> traitDef) throws AtlasException { - defineTypes(ImmutableList.<StructTypeDefinition>of(), - ImmutableList.of(traitDef), + defineTypes(ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(traitDef), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); return getDataType(TraitType.class, traitDef.typeName); } - public ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef) - throws AtlasException { + public ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef) throws AtlasException { - defineTypes(ImmutableList.<StructTypeDefinition>of(), - ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), + defineTypes(ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(classDef)); return getDataType(ClassType.class, classDef.typeName); } - public Map<String, IDataType> defineTraitTypes( - HierarchicalTypeDefinition<TraitType>... traitDefs) throws AtlasException { - TransientTypeSystem transientTypes = new TransientTypeSystem( - ImmutableList.<StructTypeDefinition>of(), - ImmutableList.copyOf(traitDefs), - ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); + public Map<String, IDataType> defineTraitTypes(HierarchicalTypeDefinition<TraitType>... traitDefs) + throws AtlasException { + TransientTypeSystem transientTypes = + new TransientTypeSystem(ImmutableList.<StructTypeDefinition>of(), ImmutableList.copyOf(traitDefs), + ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); return transientTypes.defineTypes(); } - public Map<String, IDataType> defineClassTypes( - HierarchicalTypeDefinition<ClassType>... classDefs) throws AtlasException { - TransientTypeSystem transientTypes = new TransientTypeSystem( - ImmutableList.<StructTypeDefinition>of(), - ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), - ImmutableList.copyOf(classDefs)); + public Map<String, IDataType> defineClassTypes(HierarchicalTypeDefinition<ClassType>... classDefs) + throws AtlasException { + TransientTypeSystem transientTypes = new TransientTypeSystem(ImmutableList.<StructTypeDefinition>of(), + ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.copyOf(classDefs)); return transientTypes.defineTypes(); } - public Map<String, IDataType> defineTypes(TypesDef typesDef) - throws AtlasException { + public Map<String, IDataType> defineTypes(TypesDef typesDef) throws AtlasException { Map<String, IDataType> typesAdded = new HashMap<>(); for (EnumTypeDefinition enumDef : typesDef.enumTypesAsJavaList()) { typesAdded.put(enumDef.name, defineEnumType(enumDef)); } - ImmutableList<StructTypeDefinition> structDefs = ImmutableList - .copyOf(typesDef.structTypesAsJavaList()); + ImmutableList<StructTypeDefinition> structDefs = ImmutableList.copyOf(typesDef.structTypesAsJavaList()); ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs = ImmutableList.copyOf(typesDef.traitTypesAsJavaList()); ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs = @@ -247,32 +243,29 @@ public class TypeSystem { } public Map<String, IDataType> defineTypes(ImmutableList<StructTypeDefinition> structDefs, - ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs, - ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) - throws AtlasException { - TransientTypeSystem transientTypes = new TransientTypeSystem(structDefs, - traitDefs, - classDefs); + ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs, + ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) throws AtlasException { + TransientTypeSystem transientTypes = new TransientTypeSystem(structDefs, traitDefs, classDefs); Map<String, IDataType> definedTypes = transientTypes.defineTypes(); -// LOG.debug("Defined new types " + Arrays.toString(definedTypes.keySet().toArray(new String[definedTypes.size()]))); + // LOG.debug("Defined new types " + Arrays.toString(definedTypes.keySet().toArray(new + // String[definedTypes.size()]))); return definedTypes; } public DataTypes.ArrayType defineArrayType(IDataType elemType) throws AtlasException { assert elemType != null; DataTypes.ArrayType dT = new DataTypes.ArrayType(elemType); -// types.put(dT.getName(), dT); -// typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.ARRAY, dT.getName()); + // types.put(dT.getName(), dT); + // typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.ARRAY, dT.getName()); return dT; } - public DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType) - throws AtlasException { + public DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType) throws AtlasException { assert keyType != null; assert valueType != null; DataTypes.MapType dT = new DataTypes.MapType(keyType, valueType); -// types.put(dT.getName(), dT); -// typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.MAP, dT.getName()); + // types.put(dT.getName(), dT); + // typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.MAP, dT.getName()); return dT; } @@ -283,8 +276,7 @@ public class TypeSystem { public EnumType defineEnumType(EnumTypeDefinition eDef) throws AtlasException { assert eDef.name != null; if (types.containsKey(eDef.name)) { - throw new AtlasException( - String.format("Redefinition of type %s not supported", eDef.name)); + throw new AtlasException(String.format("Redefinition of type %s not supported", eDef.name)); } EnumType eT = new EnumType(this, eDef.name, eDef.enumValues); @@ -302,7 +294,7 @@ public class TypeSystem { } public void removeTypes(Collection<String> typeNames) { - for(String typeName : typeNames) { + for (String typeName : typeNames) { IDataType dataType = types.get(typeName); final DataTypes.TypeCategory typeCategory = dataType.getTypeCategory(); typeCategoriesToTypeNamesMap.get(typeCategory).remove(typeName); @@ -316,10 +308,8 @@ public class TypeSystem { final ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs; final ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs; Map<String, StructTypeDefinition> structNameToDefMap = new HashMap<>(); - Map<String, HierarchicalTypeDefinition<TraitType>> traitNameToDefMap = - new HashMap<>(); - Map<String, HierarchicalTypeDefinition<ClassType>> classNameToDefMap = - new HashMap<>(); + Map<String, HierarchicalTypeDefinition<TraitType>> traitNameToDefMap = new HashMap<>(); + Map<String, HierarchicalTypeDefinition<ClassType>> classNameToDefMap = new HashMap<>(); Set<String> transientTypes; @@ -329,8 +319,8 @@ public class TypeSystem { TransientTypeSystem(ImmutableList<StructTypeDefinition> structDefs, - ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs, - ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) { + ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs, + ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) { this.structDefs = structDefs; this.traitDefs = traitDefs; @@ -358,11 +348,10 @@ public class TypeSystem { for (StructTypeDefinition sDef : structDefs) { assert sDef.typeName != null; if (dataType(sDef.typeName) != null) { - throw new AtlasException( - String.format("Cannot redefine type %s", sDef.typeName)); + throw new AtlasException(String.format("Cannot redefine type %s", sDef.typeName)); } - TypeSystem.this.types.put(sDef.typeName, - new StructType(this, sDef.typeName, sDef.attributeDefinitions.length)); + TypeSystem.this.types + .put(sDef.typeName, new StructType(this, sDef.typeName, sDef.attributeDefinitions.length)); structNameToDefMap.put(sDef.typeName, sDef); transientTypes.add(sDef.typeName); } @@ -370,12 +359,10 @@ public class TypeSystem { for (HierarchicalTypeDefinition<TraitType> traitDef : traitDefs) { assert traitDef.typeName != null; if (types.containsKey(traitDef.typeName)) { - throw new AtlasException( - String.format("Cannot redefine type %s", traitDef.typeName)); + throw new AtlasException(String.format("Cannot redefine type %s", traitDef.typeName)); } - TypeSystem.this.types.put(traitDef.typeName, - new TraitType(this, traitDef.typeName, traitDef.superTypes, + TypeSystem.this.types.put(traitDef.typeName, new TraitType(this, traitDef.typeName, traitDef.superTypes, traitDef.attributeDefinitions.length)); traitNameToDefMap.put(traitDef.typeName, traitDef); transientTypes.add(traitDef.typeName); @@ -384,20 +371,17 @@ public class TypeSystem { for (HierarchicalTypeDefinition<ClassType> classDef : classDefs) { assert classDef.typeName != null; if (types.containsKey(classDef.typeName)) { - throw new AtlasException( - String.format("Cannot redefine type %s", classDef.typeName)); + throw new AtlasException(String.format("Cannot redefine type %s", classDef.typeName)); } - TypeSystem.this.types.put(classDef.typeName, - new ClassType(this, classDef.typeName, classDef.superTypes, + TypeSystem.this.types.put(classDef.typeName, new ClassType(this, classDef.typeName, classDef.superTypes, classDef.attributeDefinitions.length)); classNameToDefMap.put(classDef.typeName, classDef); transientTypes.add(classDef.typeName); } } - private <U extends HierarchicalType> void validateSuperTypes(Class<U> cls, - HierarchicalTypeDefinition<U> def) + private <U extends HierarchicalType> void validateSuperTypes(Class<U> cls, HierarchicalTypeDefinition<U> def) throws AtlasException { Set<String> s = new HashSet<>(); ImmutableList<String> superTypes = def.superTypes; @@ -405,22 +389,21 @@ public class TypeSystem { if (s.contains(superTypeName)) { throw new AtlasException( - String.format("Type %s extends superType %s multiple times", - def.typeName, superTypeName)); + String.format("Type %s extends superType %s multiple times", def.typeName, superTypeName)); } IDataType dT = dataType(superTypeName); if (dT == null) { throw new AtlasException( - String.format("Unknown superType %s in definition of type %s", - superTypeName, def.typeName)); + String.format("Unknown superType %s in definition of type %s", superTypeName, + def.typeName)); } if (!cls.isAssignableFrom(dT.getClass())) { throw new AtlasException( - String.format("SuperType %s must be a %s, in definition of type %s", - superTypeName, cls.getName(), def.typeName)); + String.format("SuperType %s must be a %s, in definition of type %s", superTypeName, + cls.getName(), def.typeName)); } s.add(superTypeName); } @@ -445,8 +428,7 @@ public class TypeSystem { } } - private AttributeInfo constructAttributeInfo(AttributeDefinition attrDef) - throws AtlasException { + private AttributeInfo constructAttributeInfo(AttributeDefinition attrDef) throws AtlasException { AttributeInfo info = new AttributeInfo(this, attrDef, null); if (transientTypes.contains(attrDef.dataTypeName)) { recursiveRefs.add(info); @@ -466,9 +448,8 @@ public class TypeSystem { } } - if (info.multiplicity.upper > 1 && !( - info.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP || - info.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY)) { + if (info.multiplicity.upper > 1 && !(info.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP + || info.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY)) { throw new AtlasException( String.format("A multiplicty of more than one requires a collection type for attribute '%s'", info.name)); @@ -477,8 +458,7 @@ public class TypeSystem { return info; } - private StructType constructStructureType(StructTypeDefinition def) - throws AtlasException { + private StructType constructStructureType(StructTypeDefinition def) throws AtlasException { AttributeInfo[] infos = new AttributeInfo[def.attributeDefinitions.length]; for (int i = 0; i < def.attributeDefinitions.length; i++) { infos[i] = constructAttributeInfo(def.attributeDefinitions[i]); @@ -490,25 +470,20 @@ public class TypeSystem { } private <U extends HierarchicalType> U constructHierarchicalType(Class<U> cls, - HierarchicalTypeDefinition<U> def) - throws AtlasException { + HierarchicalTypeDefinition<U> def) throws AtlasException { AttributeInfo[] infos = new AttributeInfo[def.attributeDefinitions.length]; for (int i = 0; i < def.attributeDefinitions.length; i++) { infos[i] = constructAttributeInfo(def.attributeDefinitions[i]); } try { - Constructor<U> cons = cls.getDeclaredConstructor( - TypeSystem.class, - String.class, - ImmutableList.class, + Constructor<U> cons = cls.getDeclaredConstructor(TypeSystem.class, String.class, ImmutableList.class, AttributeInfo[].class); U type = cons.newInstance(TypeSystem.this, def.typeName, def.superTypes, infos); TypeSystem.this.types.put(def.typeName, type); return type; } catch (Exception e) { - throw new AtlasException( - String.format("Cannot construct Type of MetaType %s", cls.getName()), e); + throw new AtlasException(String.format("Cannot construct Type of MetaType %s", cls.getName()), e); } } @@ -537,14 +512,12 @@ public class TypeSystem { } for (TraitType traitType : traitTypes) { - constructHierarchicalType(TraitType.class, - traitNameToDefMap.get(traitType.getName())); + constructHierarchicalType(TraitType.class, traitNameToDefMap.get(traitType.getName())); typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.TRAIT, traitType.getName()); } for (ClassType classType : classTypes) { - constructHierarchicalType(ClassType.class, - classNameToDefMap.get(classType.getName())); + constructHierarchicalType(ClassType.class, classNameToDefMap.get(classType.getName())); typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.CLASS, classType.getName()); } } @@ -599,29 +572,25 @@ public class TypeSystem { } @Override - public StructType defineStructType(String name, boolean errorIfExists, - AttributeDefinition... attrDefs) + public StructType defineStructType(String name, boolean errorIfExists, AttributeDefinition... attrDefs) throws AtlasException { throw new AtlasException("Internal Error: define type called on TrasientTypeSystem"); } @Override - public TraitType defineTraitType(HierarchicalTypeDefinition traitDef) - throws AtlasException { + public TraitType defineTraitType(HierarchicalTypeDefinition traitDef) throws AtlasException { throw new AtlasException("Internal Error: define type called on TrasientTypeSystem"); } @Override - public ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef - ) throws AtlasException { + public ClassType defineClassType(HierarchicalTypeDefinition<ClassType> classDef) throws AtlasException { throw new AtlasException("Internal Error: define type called on TrasientTypeSystem"); } @Override public Map<String, IDataType> defineTypes(ImmutableList<StructTypeDefinition> structDefs, - ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs, - ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) - throws AtlasException { + ImmutableList<HierarchicalTypeDefinition<TraitType>> traitDefs, + ImmutableList<HierarchicalTypeDefinition<ClassType>> classDefs) throws AtlasException { throw new AtlasException("Internal Error: define type called on TrasientTypeSystem"); } @@ -631,23 +600,23 @@ public class TypeSystem { } @Override - public DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType) - throws AtlasException { + public DataTypes.MapType defineMapType(IDataType keyType, IDataType valueType) throws AtlasException { throw new AtlasException("Internal Error: define type called on TrasientTypeSystem"); } } public class IdType { private static final String ID_ATTRNAME = "guid"; - private static final String TYPENAME_ATTRNAME = "typeName"; - private static final String TYP_NAME = "__IdType"; + private static final String TYPENAME_ATTRNAME = "typeName"; + private static final String TYP_NAME = "__IdType"; private IdType() { - AttributeDefinition idAttr = new AttributeDefinition(ID_ATTRNAME, - DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); + AttributeDefinition idAttr = + new AttributeDefinition(ID_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, + null); AttributeDefinition typNmAttr = - new AttributeDefinition(TYPENAME_ATTRNAME, - DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); + new AttributeDefinition(TYPENAME_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, + false, null); try { AttributeInfo[] infos = new AttributeInfo[2]; infos[0] = new AttributeInfo(TypeSystem.this, idAttr, null); @@ -665,9 +634,17 @@ public class TypeSystem { return getDataType(StructType.class, TYP_NAME); } - public String getName() { return TYP_NAME; } - public String idAttrName() { return ID_ATTRNAME;} - public String typeNameAttrName() { return TYPENAME_ATTRNAME;} + public String getName() { + return TYP_NAME; + } + + public String idAttrName() { + return ID_ATTRNAME; + } + + public String typeNameAttrName() { + return TYPENAME_ATTRNAME; + } } public static final String ID_STRUCT_ID_ATTRNAME = IdType.ID_ATTRNAME; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java index d651aa8..7017a7e 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeUtils.java @@ -36,13 +36,11 @@ public class TypeUtils { public static final String NAME_REGEX = "[a-zA-z][a-zA-Z0-9_]*"; public static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX); - public static final Pattern ARRAY_TYPE_NAME_PATTERN = Pattern - .compile(String.format("array<(%s)>", NAME_REGEX)); + public static final Pattern ARRAY_TYPE_NAME_PATTERN = Pattern.compile(String.format("array<(%s)>", NAME_REGEX)); public static final Pattern MAP_TYPE_NAME_PATTERN = Pattern.compile(String.format("map<(%s),(%s)>", NAME_REGEX, NAME_REGEX)); - public static void outputVal(String val, Appendable buf, String prefix) - throws AtlasException { + public static void outputVal(String val, Appendable buf, String prefix) throws AtlasException { try { buf.append(prefix).append(val); } catch (IOException ie) { @@ -73,14 +71,14 @@ public class TypeUtils { return ImmutableMap.copyOf(b); } - public static TypesDef getTypesDef(ImmutableList<EnumTypeDefinition> enums, ImmutableList<StructTypeDefinition> structs, - ImmutableList<HierarchicalTypeDefinition<TraitType>> traits, - ImmutableList<HierarchicalTypeDefinition<ClassType>> classes) { + public static TypesDef getTypesDef(ImmutableList<EnumTypeDefinition> enums, + ImmutableList<StructTypeDefinition> structs, ImmutableList<HierarchicalTypeDefinition<TraitType>> traits, + ImmutableList<HierarchicalTypeDefinition<ClassType>> classes) { return new TypesDef(JavaConversions.asScalaBuffer(enums), JavaConversions.asScalaBuffer(structs), JavaConversions.asScalaBuffer(traits), JavaConversions.asScalaBuffer(classes)); } - protected static class Pair<L,R> { + protected static class Pair<L, R> { protected L left; protected R right; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java index 74f7cef..da246d6 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypedStructHandler.java @@ -68,8 +68,7 @@ public class TypedStructHandler { } } return ts; - } else if (val instanceof StructInstance && - ((StructInstance) val).getTypeName() == structType.getName()) { + } else if (val instanceof StructInstance && ((StructInstance) val).getTypeName() == structType.getName()) { return (StructInstance) val; } else { throw new ValueConversionException(structType, val); @@ -86,9 +85,7 @@ public class TypedStructHandler { } public ITypedStruct createInstance() { - return new StructInstance(structType.getName(), - fieldMapping, - new boolean[fieldMapping.fields.size()], + return new StructInstance(structType.getName(), fieldMapping, new boolean[fieldMapping.fields.size()], fieldMapping.numBools == 0 ? null : new boolean[fieldMapping.numBools], fieldMapping.numBytes == 0 ? null : new byte[fieldMapping.numBytes], fieldMapping.numShorts == 0 ? null : new short[fieldMapping.numShorts], @@ -96,18 +93,15 @@ public class TypedStructHandler { fieldMapping.numLongs == 0 ? null : new long[fieldMapping.numLongs], fieldMapping.numFloats == 0 ? null : new float[fieldMapping.numFloats], fieldMapping.numDoubles == 0 ? null : new double[fieldMapping.numDoubles], - fieldMapping.numBigDecimals == 0 ? null - : new BigDecimal[fieldMapping.numBigDecimals], + fieldMapping.numBigDecimals == 0 ? null : new BigDecimal[fieldMapping.numBigDecimals], fieldMapping.numBigInts == 0 ? null : new BigInteger[fieldMapping.numBigInts], fieldMapping.numDates == 0 ? null : new Date[fieldMapping.numDates], fieldMapping.numStrings == 0 ? null : new String[fieldMapping.numStrings], fieldMapping.numArrays == 0 ? null : new ImmutableList[fieldMapping.numArrays], fieldMapping.numMaps == 0 ? null : new ImmutableMap[fieldMapping.numMaps], fieldMapping.numStructs == 0 ? null : new StructInstance[fieldMapping.numStructs], - fieldMapping.numReferenceables == 0 ? null - : new ReferenceableInstance[fieldMapping.numReferenceables], - fieldMapping.numReferenceables == 0 ? null - : new Id[fieldMapping.numReferenceables]); + fieldMapping.numReferenceables == 0 ? null : new ReferenceableInstance[fieldMapping.numReferenceables], + fieldMapping.numReferenceables == 0 ? null : new Id[fieldMapping.numReferenceables]); } public void output(IStruct s, Appendable buf, String prefix) throws AtlasException { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java index 0b6423a..5cdee8d 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ValueConversionException.java @@ -27,19 +27,16 @@ public class ValueConversionException extends AtlasException { } public ValueConversionException(IDataType typ, Object val, Throwable t) { - super(String - .format("Cannot convert value '%s' to datatype %s", val.toString(), typ.getName()), - t); + super(String.format("Cannot convert value '%s' to datatype %s", val.toString(), typ.getName()), t); } public ValueConversionException(IDataType typ, Object val, String msg) { - super(String.format("Cannot convert value '%s' to datatype %s because: %s", - val.toString(), typ.getName(), msg)); + super(String + .format("Cannot convert value '%s' to datatype %s because: %s", val.toString(), typ.getName(), msg)); } public ValueConversionException(String typeName, Object val, String msg) { - super(String.format("Cannot convert value '%s' to datatype %s because: %s", - val.toString(), typeName, msg)); + super(String.format("Cannot convert value '%s' to datatype %s because: %s", val.toString(), typeName, msg)); } protected ValueConversionException(String msg) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java index 95f8cab..69956a3 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java @@ -37,40 +37,32 @@ public class TypesUtil { private TypesUtil() { } - public static AttributeDefinition createOptionalAttrDef(String name, - IDataType dataType) { - return new AttributeDefinition(name, dataType.getName(), - Multiplicity.OPTIONAL, false, null); + public static AttributeDefinition createOptionalAttrDef(String name, IDataType dataType) { + return new AttributeDefinition(name, dataType.getName(), Multiplicity.OPTIONAL, false, null); } - public static AttributeDefinition createOptionalAttrDef(String name, - String dataType) { + public static AttributeDefinition createOptionalAttrDef(String name, String dataType) { return new AttributeDefinition(name, dataType, Multiplicity.OPTIONAL, false, null); } - public static AttributeDefinition createRequiredAttrDef(String name, - String dataType) { + public static AttributeDefinition createRequiredAttrDef(String name, String dataType) { return new AttributeDefinition(name, dataType, Multiplicity.REQUIRED, false, null); } - public static AttributeDefinition createUniqueRequiredAttrDef(String name, - IDataType dataType) { - return new AttributeDefinition(name, dataType.getName(), - Multiplicity.REQUIRED, false, true, true, null); + public static AttributeDefinition createUniqueRequiredAttrDef(String name, IDataType dataType) { + return new AttributeDefinition(name, dataType.getName(), Multiplicity.REQUIRED, false, true, true, null); } - public static AttributeDefinition createRequiredAttrDef(String name, - IDataType dataType) { - return new AttributeDefinition(name, dataType.getName(), - Multiplicity.REQUIRED, false, null); + public static AttributeDefinition createRequiredAttrDef(String name, IDataType dataType) { + return new AttributeDefinition(name, dataType.getName(), Multiplicity.REQUIRED, false, null); } public static EnumTypeDefinition createEnumTypeDef(String name, EnumValue... enumValues) { return new EnumTypeDefinition(name, enumValues); } - public static HierarchicalTypeDefinition<TraitType> createTraitTypeDef( - String name, ImmutableList<String> superTypes, AttributeDefinition... attrDefs) { + public static HierarchicalTypeDefinition<TraitType> createTraitTypeDef(String name, + ImmutableList<String> superTypes, AttributeDefinition... attrDefs) { return new HierarchicalTypeDefinition<>(TraitType.class, name, superTypes, attrDefs); } @@ -78,8 +70,8 @@ public class TypesUtil { return new StructTypeDefinition(name, attrDefs); } - public static HierarchicalTypeDefinition<ClassType> createClassTypeDef( - String name, ImmutableList<String> superTypes, AttributeDefinition... attrDefs) { + public static HierarchicalTypeDefinition<ClassType> createClassTypeDef(String name, + ImmutableList<String> superTypes, AttributeDefinition... attrDefs) { return new HierarchicalTypeDefinition<>(ClassType.class, name, superTypes, attrDefs); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java index 5f269d5..a8c58bd 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/json/SerializationJavaTest.java @@ -62,38 +62,26 @@ public class SerializationJavaTest extends BaseTest { TypeSystem ts = getTypeSystem(); - HierarchicalTypeDefinition<ClassType> deptTypeDef = createClassTypeDef("Department", - ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> deptTypeDef = createClassTypeDef("Department", ImmutableList.<String>of(), createRequiredAttrDef("name", DataTypes.STRING_TYPE), - new AttributeDefinition("employees", - String.format("array<%s>", "Person"), Multiplicity.COLLECTION, true, - "department") - ); - HierarchicalTypeDefinition<ClassType> personTypeDef = createClassTypeDef("Person", - ImmutableList.<String>of(), + new AttributeDefinition("employees", String.format("array<%s>", "Person"), Multiplicity.COLLECTION, + true, "department")); + HierarchicalTypeDefinition<ClassType> personTypeDef = createClassTypeDef("Person", ImmutableList.<String>of(), createRequiredAttrDef("name", DataTypes.STRING_TYPE), - new AttributeDefinition("department", - "Department", Multiplicity.REQUIRED, false, "employees"), - new AttributeDefinition("manager", - "Manager", Multiplicity.OPTIONAL, false, "subordinates") - ); - HierarchicalTypeDefinition<ClassType> managerTypeDef = createClassTypeDef("Manager", - ImmutableList.<String>of("Person"), - new AttributeDefinition("subordinates", - String.format("array<%s>", "Person"), Multiplicity.COLLECTION, false, - "manager") - ); - - HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = createTraitTypeDef( - "SecurityClearance", - ImmutableList.<String>of(), - createRequiredAttrDef("level", DataTypes.INT_TYPE) - ); + new AttributeDefinition("department", "Department", Multiplicity.REQUIRED, false, "employees"), + new AttributeDefinition("manager", "Manager", Multiplicity.OPTIONAL, false, "subordinates")); + HierarchicalTypeDefinition<ClassType> managerTypeDef = + createClassTypeDef("Manager", ImmutableList.<String>of("Person"), + new AttributeDefinition("subordinates", String.format("array<%s>", "Person"), + Multiplicity.COLLECTION, false, "manager")); + + HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = + createTraitTypeDef("SecurityClearance", ImmutableList.<String>of(), + createRequiredAttrDef("level", DataTypes.INT_TYPE)); ts.defineTypes(ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(securityClearanceTypeDef), - ImmutableList.<HierarchicalTypeDefinition<ClassType>>of(deptTypeDef, personTypeDef, - managerTypeDef)); + ImmutableList.<HierarchicalTypeDefinition<ClassType>>of(deptTypeDef, personTypeDef, managerTypeDef)); Referenceable hrDept = new Referenceable("Department"); Referenceable john = new Referenceable("Person"); @@ -155,11 +143,9 @@ public class SerializationJavaTest extends BaseTest { public void testTrait() throws AtlasException { TypeSystem ts = getTypeSystem(); - HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = createTraitTypeDef( - "SecurityClearance2", - ImmutableList.<String>of(), - createRequiredAttrDef("level", DataTypes.INT_TYPE) - ); + HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = + createTraitTypeDef("SecurityClearance2", ImmutableList.<String>of(), + createRequiredAttrDef("level", DataTypes.INT_TYPE)); ts.defineTypes(ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(securityClearanceTypeDef), http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/test/java/org/apache/atlas/typesystem/types/BaseTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/BaseTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/BaseTest.java index 17d114d..1d80681 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/BaseTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/BaseTest.java @@ -37,11 +37,10 @@ public abstract class BaseTest { public static final String STRUCT_TYPE_1 = "t1"; public static final String STRUCT_TYPE_2 = "t2"; public static final String TEST_DATE = "2014-12-11T02:35:58.440Z"; - public static final long TEST_DATE_IN_LONG=1418265358440L; + public static final long TEST_DATE_IN_LONG = 1418265358440L; public static Struct createStruct() throws AtlasException { - StructType structType = TypeSystem.getInstance().getDataType( - StructType.class, STRUCT_TYPE_1); + StructType structType = TypeSystem.getInstance().getDataType(StructType.class, STRUCT_TYPE_1); Struct s = new Struct(structType.getName()); s.set("a", 1); s.set("b", true); @@ -56,8 +55,7 @@ public abstract class BaseTest { s.set("k", new BigDecimal(1)); s.set("l", new Date(1418265358440L)); s.set("m", Lists.asList(1, new Integer[]{1})); - s.set("n", Lists.asList(BigDecimal.valueOf(1.1), - new BigDecimal[]{BigDecimal.valueOf(1.1)})); + s.set("n", Lists.asList(BigDecimal.valueOf(1.1), new BigDecimal[]{BigDecimal.valueOf(1.1)})); Map<String, Double> hm = Maps.newHashMap(); hm.put("a", 1.0); hm.put("b", 2.0); @@ -74,41 +72,38 @@ public abstract class BaseTest { TypeSystem ts = TypeSystem.getInstance(); ts.reset(); - StructType structType = ts.defineStructType(STRUCT_TYPE_1, - true, - TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE), - TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE), - TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE), - TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE), - TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE), - TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE), - TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE), - TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE), - TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE), - TypesUtil.createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE), - TypesUtil.createOptionalAttrDef("l", DataTypes.DATE_TYPE), - TypesUtil.createOptionalAttrDef("m", ts.defineArrayType(DataTypes.INT_TYPE)), - TypesUtil.createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)), - TypesUtil.createOptionalAttrDef("o", - ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE))); + StructType structType = + ts.defineStructType(STRUCT_TYPE_1, true, TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE), + TypesUtil.createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), + TypesUtil.createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + TypesUtil.createOptionalAttrDef("d", DataTypes.SHORT_TYPE), + TypesUtil.createOptionalAttrDef("e", DataTypes.INT_TYPE), + TypesUtil.createOptionalAttrDef("f", DataTypes.INT_TYPE), + TypesUtil.createOptionalAttrDef("g", DataTypes.LONG_TYPE), + TypesUtil.createOptionalAttrDef("h", DataTypes.FLOAT_TYPE), + TypesUtil.createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE), + TypesUtil.createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE), + TypesUtil.createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE), + TypesUtil.createOptionalAttrDef("l", DataTypes.DATE_TYPE), + TypesUtil.createOptionalAttrDef("m", ts.defineArrayType(DataTypes.INT_TYPE)), + TypesUtil.createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)), TypesUtil + .createOptionalAttrDef("o", + ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE))); System.out.println("defined structType = " + structType); - StructType recursiveStructType = ts.defineStructType(STRUCT_TYPE_2, - true, - TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE), - TypesUtil.createOptionalAttrDef("s", STRUCT_TYPE_2)); + StructType recursiveStructType = + ts.defineStructType(STRUCT_TYPE_2, true, TypesUtil.createRequiredAttrDef("a", DataTypes.INT_TYPE), + TypesUtil.createOptionalAttrDef("s", STRUCT_TYPE_2)); System.out.println("defined recursiveStructType = " + recursiveStructType); } - protected Map<String, IDataType> defineTraits(HierarchicalTypeDefinition... tDefs) - throws AtlasException { + protected Map<String, IDataType> defineTraits(HierarchicalTypeDefinition... tDefs) throws AtlasException { return getTypeSystem().defineTraitTypes(tDefs); } - protected Map<String, IDataType> defineClasses( - HierarchicalTypeDefinition<ClassType>... classDefs) throws AtlasException { + protected Map<String, IDataType> defineClasses(HierarchicalTypeDefinition<ClassType>... classDefs) + throws AtlasException { return getTypeSystem().defineClassTypes(classDefs); } @@ -123,47 +118,30 @@ public abstract class BaseTest { protected void defineDeptEmployeeTypes(TypeSystem ts) throws AtlasException { HierarchicalTypeDefinition<ClassType> deptTypeDef = TypesUtil - .createClassTypeDef("Department", - ImmutableList.<String>of(), + .createClassTypeDef("Department", ImmutableList.<String>of(), TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), - new AttributeDefinition("employees", - String.format("array<%s>", "Person"), Multiplicity.COLLECTION, true, - "department") - ); - HierarchicalTypeDefinition<ClassType> personTypeDef = TypesUtil.createClassTypeDef("Person", - ImmutableList.<String>of(), - TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), - new AttributeDefinition("department", - "Department", Multiplicity.REQUIRED, false, "employees"), - new AttributeDefinition("manager", - "Manager", Multiplicity.OPTIONAL, false, "subordinates") - ); - HierarchicalTypeDefinition<ClassType> managerTypeDef = - TypesUtil.createClassTypeDef("Manager", - ImmutableList.of("Person"), - new AttributeDefinition("subordinates", - String.format("array<%s>", "Person"), - Multiplicity.COLLECTION, false, "manager") - ); - - HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = - TypesUtil.createTraitTypeDef( - "SecurityClearance", - ImmutableList.<String>of(), - TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE) - ); - - ts.defineTypes(ImmutableList.<StructTypeDefinition>of(), - ImmutableList.of(securityClearanceTypeDef), - ImmutableList.of(deptTypeDef, personTypeDef, - managerTypeDef)); - - ImmutableList.of( - ts.getDataType(HierarchicalType.class, "SecurityClearance"), - ts.getDataType(ClassType.class, "Department"), - ts.getDataType(ClassType.class, "Person"), - ts.getDataType(ClassType.class, "Manager") - ); + new AttributeDefinition("employees", String.format("array<%s>", "Person"), + Multiplicity.COLLECTION, true, "department")); + HierarchicalTypeDefinition<ClassType> personTypeDef = TypesUtil + .createClassTypeDef("Person", ImmutableList.<String>of(), + TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), + new AttributeDefinition("department", "Department", Multiplicity.REQUIRED, false, "employees"), + new AttributeDefinition("manager", "Manager", Multiplicity.OPTIONAL, false, "subordinates")); + HierarchicalTypeDefinition<ClassType> managerTypeDef = TypesUtil + .createClassTypeDef("Manager", ImmutableList.of("Person"), + new AttributeDefinition("subordinates", String.format("array<%s>", "Person"), + Multiplicity.COLLECTION, false, "manager")); + + HierarchicalTypeDefinition<TraitType> securityClearanceTypeDef = TypesUtil + .createTraitTypeDef("SecurityClearance", ImmutableList.<String>of(), + TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE)); + + ts.defineTypes(ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(securityClearanceTypeDef), + ImmutableList.of(deptTypeDef, personTypeDef, managerTypeDef)); + + ImmutableList.of(ts.getDataType(HierarchicalType.class, "SecurityClearance"), + ts.getDataType(ClassType.class, "Department"), ts.getDataType(ClassType.class, "Person"), + ts.getDataType(ClassType.class, "Manager")); } protected Referenceable createDeptEg1(TypeSystem ts) throws AtlasException { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/test/java/org/apache/atlas/typesystem/types/EnumTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/EnumTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/EnumTest.java index c82a1df..9074519 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/EnumTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/EnumTest.java @@ -48,26 +48,16 @@ public class EnumTest extends BaseTest { } void defineEnums(TypeSystem ts) throws AtlasException { - ts.defineEnumType("HiveObjectType", - new EnumValue("GLOBAL", 1), - new EnumValue("DATABASE", 2), - new EnumValue("TABLE", 3), - new EnumValue("PARTITION", 4), - new EnumValue("COLUMN", 5)); - - ts.defineEnumType("PrincipalType", - new EnumValue("USER", 1), - new EnumValue("ROLE", 2), + ts.defineEnumType("HiveObjectType", new EnumValue("GLOBAL", 1), new EnumValue("DATABASE", 2), + new EnumValue("TABLE", 3), new EnumValue("PARTITION", 4), new EnumValue("COLUMN", 5)); + + ts.defineEnumType("PrincipalType", new EnumValue("USER", 1), new EnumValue("ROLE", 2), new EnumValue("GROUP", 3)); - ts.defineEnumType("TxnState", - new EnumValue("COMMITTED", 1), - new EnumValue("ABORTED", 2), + ts.defineEnumType("TxnState", new EnumValue("COMMITTED", 1), new EnumValue("ABORTED", 2), new EnumValue("OPEN", 3)); - ts.defineEnumType("LockLevel", - new EnumValue("DB", 1), - new EnumValue("TABLE", 2), + ts.defineEnumType("LockLevel", new EnumValue("DB", 1), new EnumValue("TABLE", 2), new EnumValue("PARTITION", 3)); } @@ -86,8 +76,7 @@ public class EnumTest extends BaseTest { s.set("k", new BigDecimal(1)); s.set("l", new Date(1418265358440L)); s.set("m", Lists.asList(1, new Integer[]{1})); - s.set("n", - Lists.asList(BigDecimal.valueOf(1.1), new BigDecimal[]{BigDecimal.valueOf(1.1)})); + s.set("n", Lists.asList(BigDecimal.valueOf(1.1), new BigDecimal[]{BigDecimal.valueOf(1.1)})); Map<String, Double> hm = Maps.newHashMap(); hm.put("a", 1.0); hm.put("b", 2.0); @@ -111,55 +100,46 @@ public class EnumTest extends BaseTest { } protected ClassType defineClassTypeWithEnum(TypeSystem ts) throws AtlasException { - return ts.defineClassType(createClassTypeDef("t4", - ImmutableList.<String>of(), - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), - createOptionalAttrDef("d", DataTypes.SHORT_TYPE), - createOptionalAttrDef("enum1", ts.getDataType(EnumType.class, "HiveObjectType")), - createOptionalAttrDef("e", DataTypes.INT_TYPE), - createOptionalAttrDef("f", DataTypes.INT_TYPE), - createOptionalAttrDef("g", DataTypes.LONG_TYPE), - createOptionalAttrDef("enum2", ts.getDataType(EnumType.class, "PrincipalType")), - createOptionalAttrDef("h", DataTypes.FLOAT_TYPE), - createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE), - createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE), - createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE), - createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")), - createOptionalAttrDef("l", DataTypes.DATE_TYPE), - createOptionalAttrDef("m", ts.defineArrayType(DataTypes.INT_TYPE)), - createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)), - createOptionalAttrDef("o", - ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)), - createOptionalAttrDef("enum4", ts.getDataType(EnumType.class, "LockLevel")))); + return ts.defineClassType( + createClassTypeDef("t4", ImmutableList.<String>of(), createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), + createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + createOptionalAttrDef("d", DataTypes.SHORT_TYPE), + createOptionalAttrDef("enum1", ts.getDataType(EnumType.class, "HiveObjectType")), + createOptionalAttrDef("e", DataTypes.INT_TYPE), createOptionalAttrDef("f", DataTypes.INT_TYPE), + createOptionalAttrDef("g", DataTypes.LONG_TYPE), + createOptionalAttrDef("enum2", ts.getDataType(EnumType.class, "PrincipalType")), + createOptionalAttrDef("h", DataTypes.FLOAT_TYPE), + createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE), + createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE), + createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE), + createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")), + createOptionalAttrDef("l", DataTypes.DATE_TYPE), + createOptionalAttrDef("m", ts.defineArrayType(DataTypes.INT_TYPE)), + createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)), + createOptionalAttrDef("o", ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)), + createOptionalAttrDef("enum4", ts.getDataType(EnumType.class, "LockLevel")))); } @Test public void testStruct() throws AtlasException { TypeSystem ts = getTypeSystem(); defineEnums(ts); - StructType structType = ts.defineStructType("t3", - true, - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + StructType structType = ts.defineStructType("t3", true, createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE), createOptionalAttrDef("enum1", ts.getDataType(EnumType.class, "HiveObjectType")), - createOptionalAttrDef("e", DataTypes.INT_TYPE), - createOptionalAttrDef("f", DataTypes.INT_TYPE), + createOptionalAttrDef("e", DataTypes.INT_TYPE), createOptionalAttrDef("f", DataTypes.INT_TYPE), createOptionalAttrDef("g", DataTypes.LONG_TYPE), createOptionalAttrDef("enum2", ts.getDataType(EnumType.class, "PrincipalType")), - createOptionalAttrDef("h", DataTypes.FLOAT_TYPE), - createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE), + createOptionalAttrDef("h", DataTypes.FLOAT_TYPE), createOptionalAttrDef("i", DataTypes.DOUBLE_TYPE), createOptionalAttrDef("j", DataTypes.BIGINTEGER_TYPE), createOptionalAttrDef("k", DataTypes.BIGDECIMAL_TYPE), createOptionalAttrDef("enum3", ts.getDataType(EnumType.class, "TxnState")), createOptionalAttrDef("l", DataTypes.DATE_TYPE), createOptionalAttrDef("m", ts.defineArrayType(DataTypes.INT_TYPE)), createOptionalAttrDef("n", ts.defineArrayType(DataTypes.BIGDECIMAL_TYPE)), - createOptionalAttrDef("o", - ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)), + createOptionalAttrDef("o", ts.defineMapType(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)), createOptionalAttrDef("enum4", ts.getDataType(EnumType.class, "LockLevel"))); Struct s = createStructWithEnum("t3"); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java index 103639e..2ce4bbc 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/StructTest.java @@ -34,8 +34,7 @@ public class StructTest extends BaseTest { public void setup() throws Exception { super.setup(); structType = getTypeSystem().getDataType(StructType.class, STRUCT_TYPE_1); - recursiveStructType = getTypeSystem() - .getDataType(StructType.class, STRUCT_TYPE_2); + recursiveStructType = getTypeSystem().getDataType(StructType.class, STRUCT_TYPE_2); } @Test http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java index 4cccfff..571d136 100755 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java @@ -63,15 +63,13 @@ public class TraitTest extends BaseTest { */ @Test public void test1() throws AtlasException { - HierarchicalTypeDefinition A = createTraitTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableList.<String>of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableList.<String>of("A"), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition C = + createTraitTypeDef("C", ImmutableList.<String>of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableList.<String>of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); @@ -79,11 +77,12 @@ public class TraitTest extends BaseTest { TraitType DType = (TraitType) getTypeSystem().getDataType(TraitType.class, "D"); -// for(String aName : DType.fieldMapping().fields.keySet()) { -// System.out.println(String.format("nameToQualifiedName.put(\"%s\", \"%s\");", aName, DType.getQualifiedName(aName))); -// } + // for(String aName : DType.fieldMapping().fields.keySet()) { + // System.out.println(String.format("nameToQualifiedName.put(\"%s\", \"%s\");", aName, DType + // .getQualifiedName(aName))); + // } - Map<String,String> nameToQualifiedName = new HashMap(); + Map<String, String> nameToQualifiedName = new HashMap(); { nameToQualifiedName.put("d", "D.d"); nameToQualifiedName.put("b", "B.b"); @@ -172,15 +171,13 @@ public class TraitTest extends BaseTest { @Test public void testRandomOrder() throws AtlasException { - HierarchicalTypeDefinition A = createTraitTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableList.<String>of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableList.<String>of("A"), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition C = + createTraitTypeDef("C", ImmutableList.<String>of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableList.<String>of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java ---------------------------------------------------------------------- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java index f6e601e..a2dd759 100644 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java +++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java @@ -51,11 +51,10 @@ public class TypeInheritanceTest extends BaseTest { */ @Test public void testSimpleInheritance() throws AtlasException { - HierarchicalTypeDefinition A = createClassTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE)); + HierarchicalTypeDefinition A = createClassTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE)); - HierarchicalTypeDefinition B = createClassTypeDef("B", ImmutableList.of("A"), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); + HierarchicalTypeDefinition B = + createClassTypeDef("B", ImmutableList.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); defineClasses(A, B); @@ -80,12 +79,11 @@ public class TypeInheritanceTest extends BaseTest { */ @Test public void testSimpleInheritanceWithOverrides() throws AtlasException { - HierarchicalTypeDefinition A = createClassTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE), + HierarchicalTypeDefinition A = createClassTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), createRequiredAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition B = createClassTypeDef("B", ImmutableList.of("A"), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); + HierarchicalTypeDefinition B = + createClassTypeDef("B", ImmutableList.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); defineClasses(A, B); @@ -114,17 +112,16 @@ public class TypeInheritanceTest extends BaseTest { */ @Test public void testMultiLevelInheritance() throws AtlasException { - HierarchicalTypeDefinition A = createClassTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE)); + HierarchicalTypeDefinition A = createClassTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE)); - HierarchicalTypeDefinition B = createClassTypeDef("B", ImmutableList.of("A"), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); + HierarchicalTypeDefinition B = + createClassTypeDef("B", ImmutableList.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createClassTypeDef("C", ImmutableList.of("B"), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition C = + createClassTypeDef("C", ImmutableList.of("B"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); - HierarchicalTypeDefinition D = createClassTypeDef("D", ImmutableList.of("C"), - createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); + HierarchicalTypeDefinition D = + createClassTypeDef("D", ImmutableList.of("C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); defineClasses(A, B, C, D); @@ -167,17 +164,15 @@ public class TypeInheritanceTest extends BaseTest { */ @Test public void testDiamondInheritance() throws AtlasException { - HierarchicalTypeDefinition A = createTraitTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), - createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); - HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableList.of("A"), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableList.of("A"), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); - HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableList.of("B", "C"), + HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); + HierarchicalTypeDefinition B = + createTraitTypeDef("B", ImmutableList.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); + HierarchicalTypeDefinition C = + createTraitTypeDef("C", ImmutableList.of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition D = + createTraitTypeDef("D", ImmutableList.of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); defineTraits(A, B, C, D);
