Search in sources :

Example 86 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class AtlasInstanceConverter method getTrait.

public ITypedStruct getTrait(AtlasClassification classification) throws AtlasBaseException {
    AtlasFormatConverter converter = instanceFormatters.getConverter(TypeCategory.CLASSIFICATION);
    AtlasType classificationType = typeRegistry.getType(classification.getTypeName());
    Struct trait = (Struct) converter.fromV2ToV1(classification, classificationType, new ConverterContext());
    try {
        return metadataService.createTraitInstance(trait);
    } catch (AtlasException e) {
        LOG.error("Exception while getting a typed reference for the entity ", e);
        throw toAtlasBaseException(e);
    }
}
Also used : ConverterContext(org.apache.atlas.repository.converters.AtlasFormatConverter.ConverterContext) AtlasType(org.apache.atlas.type.AtlasType) AtlasException(org.apache.atlas.AtlasException) ITypedStruct(org.apache.atlas.typesystem.ITypedStruct) IStruct(org.apache.atlas.typesystem.IStruct) Struct(org.apache.atlas.typesystem.Struct)

Example 87 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class NotificationHookConsumerTest method setup.

@BeforeMethod
public void setup() throws 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);
    EntityMutationResponse mutationResponse = mock(EntityMutationResponse.class);
    when(atlasEntityStore.createOrUpdate(any(EntityStream.class), anyBoolean())).thenReturn(mutationResponse);
}
Also used : EntityStream(org.apache.atlas.repository.store.graph.v1.EntityStream) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasType(org.apache.atlas.type.AtlasType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 88 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class ExportService method addType.

private void addType(String typeName, ExportContext context) {
    AtlasType type = null;
    try {
        type = typeRegistry.getType(typeName);
        addType(type, context);
    } catch (AtlasBaseException excp) {
        LOG.error("unknown type {}", typeName);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasType(org.apache.atlas.type.AtlasType)

Example 89 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class GraphBackedSearchIndexer method createIndexForAttribute.

private void createIndexForAttribute(AtlasGraphManagement management, String typeName, AtlasAttributeDef attributeDef) {
    final String propertyName = GraphHelper.encodePropertyKey(typeName + "." + attributeDef.getName());
    AtlasCardinality cardinality = toAtlasCardinality(attributeDef.getCardinality());
    boolean isUnique = attributeDef.getIsUnique();
    boolean isIndexable = attributeDef.getIsIndexable();
    String attribTypeName = attributeDef.getTypeName();
    boolean isBuiltInType = AtlasTypeUtil.isBuiltInType(attribTypeName);
    boolean isArrayType = AtlasTypeUtil.isArrayType(attribTypeName);
    boolean isMapType = AtlasTypeUtil.isMapType(attribTypeName);
    try {
        AtlasType atlasType = typeRegistry.getType(attribTypeName);
        if (isMapType || isArrayType || isClassificationType(atlasType) || isEntityType(atlasType)) {
            LOG.warn("Ignoring non-indexable attribute {}", attribTypeName);
        } else if (isBuiltInType) {
            createIndexes(management, propertyName, getPrimitiveClass(attribTypeName), isUnique, cardinality, false, isIndexable);
        } else if (isEnumType(atlasType)) {
            createIndexes(management, propertyName, String.class, isUnique, cardinality, false, isIndexable);
        } else if (isStructType(atlasType)) {
            AtlasStructDef structDef = typeRegistry.getStructDefByName(attribTypeName);
            updateIndexForTypeDef(management, structDef);
        }
    } catch (AtlasBaseException e) {
        LOG.error("No type exists for {}", attribTypeName, e);
    }
}
Also used : AtlasCardinality(org.apache.atlas.repository.graphdb.AtlasCardinality) AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasType(org.apache.atlas.type.AtlasType)

Example 90 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class GraphBackedSearchIndexer method cleanupIndexForAttribute.

private void cleanupIndexForAttribute(AtlasGraphManagement management, String typeName, AtlasAttributeDef attributeDef) {
    final String propertyName = GraphHelper.encodePropertyKey(typeName + "." + attributeDef.getName());
    String attribTypeName = attributeDef.getTypeName();
    boolean isBuiltInType = AtlasTypeUtil.isBuiltInType(attribTypeName);
    boolean isArrayType = AtlasTypeUtil.isArrayType(attribTypeName);
    boolean isMapType = AtlasTypeUtil.isMapType(attribTypeName);
    try {
        AtlasType atlasType = typeRegistry.getType(attribTypeName);
        if (isMapType || isArrayType || isClassificationType(atlasType) || isEntityType(atlasType)) {
            LOG.warn("Ignoring non-indexable attribute {}", attribTypeName);
        } else if (isBuiltInType || isEnumType(atlasType)) {
            cleanupIndex(management, propertyName);
        } else if (isStructType(atlasType)) {
            AtlasStructDef structDef = typeRegistry.getStructDefByName(attribTypeName);
            cleanupIndices(management, structDef);
        }
    } catch (AtlasBaseException e) {
        LOG.error("No type exists for {}", attribTypeName, e);
    }
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasType(org.apache.atlas.type.AtlasType)

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