Search in sources :

Example 46 with AtlasType

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;
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) AtlasType(org.apache.atlas.type.AtlasType)

Example 47 with AtlasType

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;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasType(org.apache.atlas.type.AtlasType) Map(java.util.Map) HashMap(java.util.HashMap) AtlasMapType(org.apache.atlas.type.AtlasMapType)

Example 48 with AtlasType

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;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasType(org.apache.atlas.type.AtlasType) Map(java.util.Map) HashMap(java.util.HashMap) AtlasMapType(org.apache.atlas.type.AtlasMapType)

Example 49 with AtlasType

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;
}
Also used : AtlasType(org.apache.atlas.type.AtlasType) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Example 50 with AtlasType

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();
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasType(org.apache.atlas.type.AtlasType) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

AtlasType (org.apache.atlas.type.AtlasType)95 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)51 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)33 AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)23 AtlasArrayType (org.apache.atlas.type.AtlasArrayType)17 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)17 AtlasStructType (org.apache.atlas.type.AtlasStructType)16 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)15 AtlasMapType (org.apache.atlas.type.AtlasMapType)13 ArrayList (java.util.ArrayList)11 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)9 HashMap (java.util.HashMap)8 AtlasTypeAccessRequest (org.apache.atlas.authorize.AtlasTypeAccessRequest)8 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)8 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)8 Map (java.util.Map)7 List (java.util.List)6 Collection (java.util.Collection)5 LinkedHashSet (java.util.LinkedHashSet)5 Set (java.util.Set)4