Search in sources :

Example 1 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class TypeConverterUtil method toAtlasEntityDefs.

private static List<AtlasEntityDef> toAtlasEntityDefs(List<HierarchicalTypeDefinition<ClassType>> classTypeDefinitions, AtlasTypeRegistry registry) throws AtlasBaseException {
    List<AtlasEntityDef> atlasEntityDefs = new ArrayList<AtlasEntityDef>();
    for (HierarchicalTypeDefinition<ClassType> classType : classTypeDefinitions) {
        List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
        AtlasEntityDef atlasEntityDef = new AtlasEntityDef();
        String classTypeDefName = classType.typeName;
        atlasEntityDef.setName(classTypeDefName);
        atlasEntityDef.setDescription(classType.typeDescription);
        atlasEntityDef.setTypeVersion(classType.typeVersion);
        atlasEntityDef.setSuperTypes(classType.superTypes);
        AttributeDefinition[] attrDefinitions = classType.attributeDefinitions;
        for (AttributeDefinition oldAttr : attrDefinitions) {
            AtlasAttributeDef newAttr = toAtlasAttributeDef(oldAttr);
            attrDefs.add(newAttr);
        }
        atlasEntityDef.setAttributeDefs(attrDefs);
        atlasEntityDefs.add(atlasEntityDef);
    }
    return atlasEntityDefs;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) ArrayList(java.util.ArrayList) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType)

Example 2 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class TypeConverterUtil method classificationToTypesDef.

private static TypesDef classificationToTypesDef(AtlasClassificationType classificationType, AtlasTypeRegistry registry) throws AtlasBaseException {
    String typeName = classificationType.getClassificationDef().getName();
    String typeDesc = classificationType.getClassificationDef().getDescription();
    String typeVersion = classificationType.getClassificationDef().getTypeVersion();
    ImmutableSet superTypes = ImmutableSet.copyOf(classificationType.getClassificationDef().getSuperTypes());
    AttributeDefinition[] attributes = getAttributes(classificationType, registry);
    HierarchicalTypeDefinition traitType = TypesUtil.createTraitTypeDef(typeName, typeDesc, typeVersion, superTypes, attributes);
    TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(traitType), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
    return ret;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) ImmutableSet(com.google.common.collect.ImmutableSet) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType)

Example 3 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class TypeConverterUtil method toAtlasStructDefs.

private static List<AtlasStructDef> toAtlasStructDefs(List<StructTypeDefinition> structTypeDefinitions) throws AtlasBaseException {
    List<AtlasStructDef> ret = new ArrayList<AtlasStructDef>();
    for (StructTypeDefinition structType : structTypeDefinitions) {
        AtlasStructDef structDef = new AtlasStructDef();
        List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
        structDef.setName(structType.typeName);
        structDef.setDescription(structType.typeDescription);
        structDef.setTypeVersion(structType.typeVersion);
        AttributeDefinition[] attrDefinitions = structType.attributeDefinitions;
        for (AttributeDefinition attrDefinition : attrDefinitions) {
            attrDefs.add(toAtlasAttributeDef(attrDefinition));
        }
        structDef.setAttributeDefs(attrDefs);
        ret.add(structDef);
    }
    return ret;
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) ArrayList(java.util.ArrayList) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) StructTypeDefinition(org.apache.atlas.typesystem.types.StructTypeDefinition)

Example 4 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class TypeConverterUtil method getAttributes.

private static AttributeDefinition[] getAttributes(AtlasStructType structType, AtlasTypeRegistry registry) throws AtlasBaseException {
    List<AttributeDefinition> ret = new ArrayList<>();
    List<AtlasAttributeDef> attrDefs = structType.getStructDef().getAttributeDefs();
    if (CollectionUtils.isNotEmpty(attrDefs)) {
        for (AtlasAttributeDef attrDef : attrDefs) {
            AtlasAttribute attribute = structType.getAttribute(attrDef.getName());
            ret.add(AtlasStructDefStoreV1.toAttributeDefintion(attribute));
        }
    }
    return ret.toArray(new AttributeDefinition[ret.size()]);
}
Also used : AtlasAttribute(org.apache.atlas.type.AtlasStructType.AtlasAttribute) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) ArrayList(java.util.ArrayList) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition)

Example 5 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class TypeConverterUtil method structToTypesDef.

private static TypesDef structToTypesDef(AtlasStructType structType, AtlasTypeRegistry registry) throws AtlasBaseException {
    String typeName = structType.getStructDef().getName();
    String typeDesc = structType.getStructDef().getDescription();
    String typeVersion = structType.getStructDef().getTypeVersion();
    AttributeDefinition[] attributes = getAttributes(structType, registry);
    StructTypeDefinition structTypeDef = TypesUtil.createStructTypeDef(typeName, typeDesc, typeVersion, attributes);
    TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.of(structTypeDef), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
    return ret;
}
Also used : AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType) StructTypeDefinition(org.apache.atlas.typesystem.types.StructTypeDefinition)

Aggregations

AttributeDefinition (org.apache.atlas.typesystem.types.AttributeDefinition)27 ClassType (org.apache.atlas.typesystem.types.ClassType)17 Test (org.testng.annotations.Test)13 TraitType (org.apache.atlas.typesystem.types.TraitType)10 ArrayList (java.util.ArrayList)7 TypesDef (org.apache.atlas.typesystem.TypesDef)7 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)5 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)4 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)4 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)3 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)3 Referenceable (org.apache.atlas.typesystem.Referenceable)3 StructTypeDefinition (org.apache.atlas.typesystem.types.StructTypeDefinition)3 TypeSystem (org.apache.atlas.typesystem.types.TypeSystem)3 BeforeTest (org.testng.annotations.BeforeTest)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2 QueryParams (org.apache.atlas.query.QueryParams)2 JSONObject (org.codehaus.jettison.json.JSONObject)2 Callable (java.util.concurrent.Callable)1