Search in sources :

Example 1 with EnumTypeDefinition

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

the class TypeConverterUtil method toAtlasEnumDefs.

private static List<AtlasEnumDef> toAtlasEnumDefs(List<EnumTypeDefinition> enumTypeDefinitions) {
    List<AtlasEnumDef> ret = new ArrayList<AtlasEnumDef>();
    for (EnumTypeDefinition enumType : enumTypeDefinitions) {
        AtlasEnumDef enumDef = new AtlasEnumDef();
        enumDef.setName(enumType.name);
        enumDef.setDescription(enumType.description);
        enumDef.setTypeVersion(enumType.version);
        enumDef.setElementDefs(getAtlasEnumElementDefs(enumType.enumValues));
        ret.add(enumDef);
    }
    return ret;
}
Also used : EnumTypeDefinition(org.apache.atlas.typesystem.types.EnumTypeDefinition) ArrayList(java.util.ArrayList) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 2 with EnumTypeDefinition

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

the class TypeConverterUtil method enumToTypesDef.

private static TypesDef enumToTypesDef(AtlasEnumType enumType) {
    TypesDef ret = null;
    AtlasEnumDef enumDef = enumType.getEnumDef();
    String enumName = enumDef.getName();
    String enumDesc = enumDef.getDescription();
    String enumVersion = enumDef.getTypeVersion();
    EnumValue[] enumValues = getEnumValues(enumDef.getElementDefs());
    if (enumName != null && enumValues != null && enumValues.length > 0) {
        EnumTypeDefinition enumTypeDef = new EnumTypeDefinition(enumName, enumDesc, enumVersion, enumValues);
        ret = TypesUtil.getTypesDef(ImmutableList.of(enumTypeDef), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
    }
    return ret;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) TypesDef(org.apache.atlas.typesystem.TypesDef) EnumValue(org.apache.atlas.typesystem.types.EnumValue) EnumTypeDefinition(org.apache.atlas.typesystem.types.EnumTypeDefinition) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef) StructTypeDefinition(org.apache.atlas.typesystem.types.StructTypeDefinition)

Aggregations

AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)2 EnumTypeDefinition (org.apache.atlas.typesystem.types.EnumTypeDefinition)2 ArrayList (java.util.ArrayList)1 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)1 TypesDef (org.apache.atlas.typesystem.TypesDef)1 EnumValue (org.apache.atlas.typesystem.types.EnumValue)1 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)1 StructTypeDefinition (org.apache.atlas.typesystem.types.StructTypeDefinition)1