use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.
the class AtlasInstanceConverter method getReferenceable.
public Referenceable getReferenceable(AtlasEntity entity, final ConverterContext ctx) throws AtlasBaseException {
AtlasFormatConverter converter = instanceFormatters.getConverter(TypeCategory.ENTITY);
AtlasType entityType = typeRegistry.getType(entity.getTypeName());
Referenceable ref = (Referenceable) converter.fromV2ToV1(entity, entityType, ctx);
return ref;
}
use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.
the class AtlasMapFormatConverter method fromV2ToV1.
@Override
public Map fromV2ToV1(Object v2Obj, AtlasType type, ConverterContext ctx) throws AtlasBaseException {
Map ret = null;
if (v2Obj != null) {
if (v2Obj 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 v2Map = (Map) v2Obj;
ret = new HashMap<>();
for (Object key : v2Map.keySet()) {
Object value = v2Map.get(key);
Object v2Key = keyConverter.fromV2ToV1(key, keyType, ctx);
Object v2Value = valueConverter.fromV2ToV1(value, valueType, ctx);
ret.put(v2Key, v2Value);
}
} else {
throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map", v2Obj.getClass().getCanonicalName());
}
}
return ret;
}
use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.
the class AtlasMapFormatConverter method fromV1ToV2.
@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;
}
use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.
the class LineageUtils method isDataSet.
private static boolean isDataSet(String typeName, AtlasTypeRegistry registry) throws AtlasBaseException {
boolean ret = false;
AtlasType type = registry.getType(typeName);
if (type instanceof AtlasEntityType) {
AtlasEntityType entityType = (AtlasEntityType) type;
ret = entityType.getAllSuperTypes().contains(AtlasBaseTypeDef.ATLAS_TYPE_DATASET);
}
return ret;
}
use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.
the class NotificationHookConsumerKafkaTest method setup.
@BeforeTest
public void setup() throws AtlasException, InterruptedException, AtlasBaseException {
MockitoAnnotations.initMocks(this);
AtlasType mockType = mock(AtlasType.class);
when(typeRegistry.getType(anyString())).thenReturn(mockType);
AtlasEntity.AtlasEntitiesWithExtInfo mockEntity = mock(AtlasEntity.AtlasEntitiesWithExtInfo.class);
when(instanceConverter.toAtlasEntities(anyList())).thenReturn(mockEntity);
kafkaNotification = startKafkaServer();
}
Aggregations