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;
}
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;
}
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;
}
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()]);
}
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;
}
Aggregations