private static TypesDef entityToTypesDef(AtlasEntityType entityType, AtlasTypeRegistry registry) { String typeName = entityType.getEntityDef().getName(); String typeDesc = entityType.getEntityDef().getDescription(); String typeVersion = entityType.getEntityDef().getTypeVersion(); Set<String> superTypes = entityType.getEntityDef().getSuperTypes(); List<AttributeDefinition> attributes = getAttributes(entityType, registry); ClassTypeDefinition classTypeDef = new ClassTypeDefinition(typeName, typeDesc, typeVersion, attributes, superTypes); TypesDef ret = new TypesDef(null, null, null, Arrays.asList(classTypeDef)); return ret; }
public static ClassTypeDefinition toClassTypeDefinition(final AtlasEntityType entityType) { ClassTypeDefinition ret = null; if (entityType != null) { AtlasEntityDef entityDef = entityType.getEntityDef(); ret = new ClassTypeDefinition(); ret.setTypeName(entityDef.getName()); ret.setTypeDescription(entityDef.getDescription()); ret.setTypeVersion(entityDef.getTypeVersion()); ret.setSuperTypes(entityDef.getSuperTypes()); if (MapUtils.isNotEmpty(entityType.getAllAttributes())) { List<AttributeDefinition> attributeDefinitions = entityType.getAllAttributes() .entrySet() .stream() .map(e -> toV1AttributeDefinition(e.getValue())) .collect(Collectors.toList()); ret.setAttributeDefinitions(attributeDefinitions); } } return ret; }
private AtlasBaseTypeDef getTypeDefFromType(AtlasType type) throws AtlasBaseException { AtlasBaseTypeDef ret; switch (type.getTypeCategory()) { case ENUM: ret = ((AtlasEnumType) type).getEnumDef(); break; case STRUCT: ret = ((AtlasStructType) type).getStructDef(); break; case CLASSIFICATION: ret = ((AtlasClassificationType) type).getClassificationDef(); break; case ENTITY: ret = ((AtlasEntityType) type).getEntityDef(); break; case PRIMITIVE: case OBJECT_ID_TYPE: case ARRAY: case MAP: default: throw new AtlasBaseException(AtlasErrorCode.SYSTEM_TYPE, type.getTypeCategory().name()); } return ret; }
typesDef.getEntityDefs().add(entityType.getEntityDef());
private AtlasBaseTypeDef getTypeDefFromType(AtlasType type) throws AtlasBaseException { AtlasBaseTypeDef ret; switch (type.getTypeCategory()) { case ENUM: ret = ((AtlasEnumType) type).getEnumDef(); break; case STRUCT: ret = ((AtlasStructType) type).getStructDef(); break; case CLASSIFICATION: ret = ((AtlasClassificationType) type).getClassificationDef(); break; case ENTITY: ret = ((AtlasEntityType) type).getEntityDef(); break; case RELATIONSHIP: ret = ((AtlasRelationshipType) type).getRelationshipDef(); break; case PRIMITIVE: case OBJECT_ID_TYPE: case ARRAY: case MAP: default: throw new AtlasBaseException(AtlasErrorCode.SYSTEM_TYPE, type.getTypeCategory().name()); } return ret; }