in fts/src/main/java/com/epam/eco/schemacatalog/fts/convert/SchemaDocumentConverter.java [49:110]
public static SchemaDocument convert(FullSchemaInfo schemaInfo) {
SchemaDocument document = new SchemaDocument();
document.setSubject(schemaInfo.getSubject());
document.setVersion(schemaInfo.getVersion());
document.setSchemaRegistryId(schemaInfo.getSchemaRegistryId());
document.setEcoId(schemaInfo.getEcoId());
document.setVersionLatest(schemaInfo.isVersionLatest());
document.setCompatibility(schemaInfo.getCompatibilityLevel().name());
document.setGlobalCompatibility(schemaInfo.isGlobalCompatibilityLevel());
document.setMode(schemaInfo.getMode().name());
document.setDeleted(schemaInfo.isDeleted());
if (schemaInfo.getSchemaAvro().getType() == Type.RECORD) {
document.setRootName(schemaInfo.getSchemaAvro().getName());
document.setRootNamespace(schemaInfo.getSchemaAvro().getNamespace());
document.setRootFullname(schemaInfo.getSchemaAvro().getFullName());
}
document.setMetadata(toMetadataDocument(schemaInfo));
new SchemaTraverser(new SchemaTraverseListener() {
@Override
public void onSchemaField(String path, Schema parentSchema, Field field) {
document.addPath(path);
document.addName(field.name());
document.addDoc(field.doc());
Map<String, Object> props = field.getObjectProps();
if (props != null && !props.isEmpty()) {
props.forEach(
(key, value) -> document.addProperty(key, Objects.toString(value, null)));
}
Set<String> aliases = field.aliases();
if (aliases != null && !aliases.isEmpty()) {
aliases.forEach(document::addAlias);
}
}
@Override
public void onSchema(String path, Schema parentSchema, Schema schema) {
document.addDoc(schema.getDoc());
if (
Type.RECORD == schema.getType() ||
Type.ENUM == schema.getType() ||
Type.FIXED == schema.getType()) {
document.addName(schema.getName());
document.addNamespace(schema.getNamespace());
document.addFullname(schema.getFullName());
}
if (schema.getLogicalType() != null) {
document.addLogicalType(schema.getLogicalType().getName());
}
Map<String, Object> props = schema.getObjectProps();
if (props != null && !props.isEmpty()) {
props.forEach(
(key, value) -> document.addProperty(key, Objects.toString(value, null)));
}
}
}).walk(schemaInfo.getSchemaAvro());
return document;
}