@Override public Map fromV1ToV2(Object v1Obj, AtlasType type, ConverterContext ctx) throws AtlasBaseException { Map ret = null; if (v1Obj != null) { if (v1Obj instanceof Map) { AtlasMapType mapType = (AtlasMapType)type; AtlasType keyType = mapType.getKeyType(); AtlasType valueType = mapType.getValueType(); AtlasFormatConverter keyConverter = converterRegistry.getConverter(keyType.getTypeCategory()); AtlasFormatConverter valueConverter = converterRegistry.getConverter(valueType.getTypeCategory()); Map v1Map = (Map)v1Obj; ret = new HashMap<>(); for (Object key : v1Map.keySet()) { Object value = v1Map.get(key); Object v2Key = keyConverter.fromV1ToV2(key, keyType, ctx); Object v2Value = valueConverter.fromV1ToV2(value, valueType, ctx); ret.put(v2Key, v2Value); } } else { throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map", v1Obj.getClass().getCanonicalName()); } } return ret; }
@Override public Map fromV1ToV2(Object v1Obj, AtlasType type, ConverterContext ctx) throws AtlasBaseException { Map ret = null; if (v1Obj != null) { if (v1Obj instanceof Map) { AtlasMapType mapType = (AtlasMapType)type; AtlasType keyType = mapType.getKeyType(); AtlasType valueType = mapType.getValueType(); AtlasFormatConverter keyConverter = converterRegistry.getConverter(keyType.getTypeCategory()); AtlasFormatConverter valueConverter = converterRegistry.getConverter(valueType.getTypeCategory()); Map v1Map = (Map)v1Obj; ret = new HashMap<>(); for (Object key : v1Map.keySet()) { Object value = v1Map.get(key); Object v2Key = keyConverter.fromV1ToV2(key, keyType, ctx); Object v2Value = valueConverter.fromV1ToV2(value, valueType, ctx); ret.put(v2Key, v2Value); } } else { throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map", v1Obj.getClass().getCanonicalName()); } } return ret; }
if (v2Obj instanceof Map) { AtlasMapType mapType = (AtlasMapType)type; AtlasType keyType = mapType.getKeyType(); AtlasType valueType = mapType.getValueType(); AtlasFormatConverter keyConverter = converterRegistry.getConverter(keyType.getTypeCategory());
} if (type instanceof AtlasMapType && v1Obj instanceof Map) { AtlasMapType mapType = (AtlasMapType) type; AtlasType keyType = mapType.getKeyType(); AtlasType valueType = mapType.getValueType(); AtlasFormatConverter keyConverter = null;
private void addType(AtlasType type, ExportContext context) { if (type.getTypeCategory() == TypeCategory.PRIMITIVE) { return; } if (type instanceof AtlasArrayType) { AtlasArrayType arrayType = (AtlasArrayType)type; addType(arrayType.getElementType(), context); } else if (type instanceof AtlasMapType) { AtlasMapType mapType = (AtlasMapType)type; addType(mapType.getKeyType(), context); addType(mapType.getValueType(), context); } else if (type instanceof AtlasEntityType) { addEntityType((AtlasEntityType)type, context); } else if (type instanceof AtlasClassificationType) { addClassificationType((AtlasClassificationType)type, context); } else if (type instanceof AtlasStructType) { addStructType((AtlasStructType)type, context); } else if (type instanceof AtlasEnumType) { addEnumType((AtlasEnumType)type, context); } }
private void addType(AtlasType type, ExportService.ExportContext context) { if (type.getTypeCategory() == TypeCategory.PRIMITIVE) { return; } if (type instanceof AtlasArrayType) { AtlasArrayType arrayType = (AtlasArrayType)type; addType(arrayType.getElementType(), context); } else if (type instanceof AtlasMapType) { AtlasMapType mapType = (AtlasMapType)type; addType(mapType.getKeyType(), context); addType(mapType.getValueType(), context); } else if (type instanceof AtlasEntityType) { addEntityType((AtlasEntityType)type, context); } else if (type instanceof AtlasClassificationType) { addClassificationType((AtlasClassificationType)type, context); } else if (type instanceof AtlasStructType) { addStructType((AtlasStructType)type, context); } else if (type instanceof AtlasEnumType) { addEnumType((AtlasEnumType)type, context); } else if (type instanceof AtlasRelationshipType) { addRelationshipType((AtlasRelationshipType)type, context); } }
void visitAttribute(AtlasType attrType, Object val) throws AtlasBaseException { if (attrType == null || val == null) { return; } switch (attrType.getTypeCategory()) { case PRIMITIVE: case ENUM: return; case ARRAY: { AtlasArrayType arrayType = (AtlasArrayType) attrType; AtlasType elemType = arrayType.getElementType(); visitCollectionReferences(elemType, val); } break; case MAP: { AtlasType keyType = ((AtlasMapType) attrType).getKeyType(); AtlasType valueType = ((AtlasMapType) attrType).getValueType(); visitMapReferences(keyType, valueType, val); } break; case STRUCT: visitStruct((AtlasStructType)attrType, val); break; case OBJECT_ID_TYPE: visitReference((AtlasObjectIdType) attrType, val); break; default: throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID, attrType.getTypeCategory().name()); } }
void visitAttribute(AtlasType attrType, Object val) throws AtlasBaseException { if (attrType == null || val == null) { return; } switch (attrType.getTypeCategory()) { case PRIMITIVE: case ENUM: return; case ARRAY: { AtlasArrayType arrayType = (AtlasArrayType) attrType; AtlasType elemType = arrayType.getElementType(); visitCollectionReferences(elemType, val); } break; case MAP: { AtlasType keyType = ((AtlasMapType) attrType).getKeyType(); AtlasType valueType = ((AtlasMapType) attrType).getValueType(); visitMapReferences(keyType, valueType, val); } break; case STRUCT: visitStruct((AtlasStructType)attrType, val); break; case OBJECT_ID_TYPE: visitReference((AtlasObjectIdType) attrType, val); break; default: throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID, attrType.getTypeCategory().name()); } }
AtlasMapType mapType = (AtlasMapType)type; addType(mapType.getKeyType(), context); addType(mapType.getValueType(), context); } else if (type instanceof AtlasEntityType) {