ATLAS-2833: Associating tag to entity API throws exception since mapGraphToTypedInstance uses outdated transient typesystem information
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AbstractDataType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AbstractDataType.java index dc9cdf2..cbe04e3 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AbstractDataType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AbstractDataType.java
@@ -38,6 +38,10 @@ this.description = description; } + public void setTypeSystem(TypeSystem typeSystem) { + // do nothing + } + protected T convertNull(Multiplicity m) throws AtlasException { if (!m.nullAllowed()) { throw new ValueConversionException.NullConversionException(m);
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java index bdd0a13..5535271 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java
@@ -28,7 +28,7 @@ public class EnumType extends AbstractDataType<EnumValue> { - public final TypeSystem typeSystem; + public TypeSystem typeSystem; public final ImmutableMap<String, EnumValue> valueMap; public final ImmutableMap<Integer, EnumValue> ordinalMap; @@ -49,6 +49,10 @@ ordinalMap = b2.build(); } + public void setTypeSystem(TypeSystem typeSystem) { + this.typeSystem = typeSystem; + } + @Override public EnumValue convert(Object val, Multiplicity m) throws AtlasException { if (val != null) {
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java index befc705..2988f3c 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java
@@ -50,7 +50,7 @@ */ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends AbstractDataType<T> { - public final TypeSystem typeSystem; + public TypeSystem typeSystem; public final Class<ST> superTypeClass; public final FieldMapping fieldMapping; public final int numFields; @@ -97,6 +97,10 @@ this.immediateAttrs = ImmutableList.copyOf(fields); } + public void setTypeSystem(TypeSystem typeSystem) { + this.typeSystem = typeSystem; + } + public FieldMapping fieldMapping() { return fieldMapping; }
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/IDataType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/IDataType.java index 85ddee7..3272038 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/IDataType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/IDataType.java
@@ -55,5 +55,7 @@ void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException; String getDescription(); + + void setTypeSystem(TypeSystem typeSystem); }
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 6f40c1d..42d9c9f 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
@@ -35,7 +35,7 @@ public class StructType extends AbstractDataType<IStruct> implements IConstructableType<IStruct, ITypedStruct> { - public final TypeSystem typeSystem; + public TypeSystem typeSystem; public final FieldMapping fieldMapping; public final Map<AttributeInfo, List<String>> infoToNameMap; public final int numFields; @@ -60,6 +60,10 @@ this.handler = new TypedStructHandler(this); } + public void setTypeSystem(TypeSystem typeSystem) { + this.typeSystem = typeSystem; + } + public FieldMapping fieldMapping() { return fieldMapping; }
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 c355ba9..ed395b4 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
@@ -345,6 +345,9 @@ String typeName = typeEntry.getKey(); IDataType type = typeEntry.getValue(); //Add/replace the new type in the typesystem + + type.setTypeSystem(this); + typeCache.put(type); } }