public static AtlasTypesDef toAtlasTypesDef(String typeDefinition, AtlasTypeRegistry registry) throws AtlasBaseException { AtlasTypesDef ret = new AtlasTypesDef(); try { if (StringUtils.isEmpty(typeDefinition)) { throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition); } TypesDef typesDef = TypesSerialization.fromJson(typeDefinition); if (CollectionUtils.isNotEmpty(typesDef.enumTypesAsJavaList())) { List<AtlasEnumDef> enumDefs = toAtlasEnumDefs(typesDef.enumTypesAsJavaList()); ret.setEnumDefs(enumDefs); } if (CollectionUtils.isNotEmpty(typesDef.structTypesAsJavaList())) { List<AtlasStructDef> structDefs = toAtlasStructDefs(typesDef.structTypesAsJavaList()); ret.setStructDefs(structDefs); } if (CollectionUtils.isNotEmpty(typesDef.classTypesAsJavaList())) { List<AtlasEntityDef> entityDefs = toAtlasEntityDefs(typesDef.classTypesAsJavaList(), registry); ret.setEntityDefs(entityDefs); } if (CollectionUtils.isNotEmpty(typesDef.traitTypesAsJavaList())) { List<AtlasClassificationDef> classificationDefs = toAtlasClassificationDefs(typesDef.traitTypesAsJavaList()); ret.setClassificationDefs(classificationDefs); } } catch (Exception e) { LOG.error("Invalid type definition = {}", typeDefinition, e); throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition); } return ret; }
public static AtlasTypesDef toAtlasTypesDef(String typeDefinition, AtlasTypeRegistry registry) throws AtlasBaseException { AtlasTypesDef ret = new AtlasTypesDef(); try { if (StringUtils.isEmpty(typeDefinition)) { throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition); } TypesDef typesDef = AtlasType.fromV1Json(typeDefinition, TypesDef.class); if (CollectionUtils.isNotEmpty(typesDef.getEnumTypes())) { List<AtlasEnumDef> enumDefs = toAtlasEnumDefs(typesDef.getEnumTypes()); ret.setEnumDefs(enumDefs); } if (CollectionUtils.isNotEmpty(typesDef.getStructTypes())) { List<AtlasStructDef> structDefs = toAtlasStructDefs(typesDef.getStructTypes()); ret.setStructDefs(structDefs); } if (CollectionUtils.isNotEmpty(typesDef.getClassTypes())) { List<AtlasEntityDef> entityDefs = toAtlasEntityDefs(typesDef.getClassTypes(), registry); ret.setEntityDefs(entityDefs); } if (CollectionUtils.isNotEmpty(typesDef.getTraitTypes())) { List<AtlasClassificationDef> classificationDefs = toAtlasClassificationDefs(typesDef.getTraitTypes()); ret.setClassificationDefs(classificationDefs); } } catch (Exception e) { LOG.error("Invalid type definition = {}", typeDefinition, e); throw new AtlasBaseException(INVALID_TYPE_DEFINITION, typeDefinition); } return ret; }