@Override public SchemaMetadataInfo getSchemaMetadataInfo(String schemaName) { SchemaMetadataStorable givenSchemaMetadataStorable = new SchemaMetadataStorable(); givenSchemaMetadataStorable.setName(schemaName); SchemaMetadataStorable schemaMetadataStorable = storageManager.get(givenSchemaMetadataStorable.getStorableKey()); return schemaMetadataStorable != null ? schemaMetadataStorable.toSchemaMetadataInfo() : null; }
@Override public SchemaMetadataInfo updateSchemaMetadata(String schemaName, SchemaMetadata schemaMetadata) { if (!schemaName.equals(schemaMetadata.getName())) { throw new IllegalArgumentException("schemaName must match the name in schemaMetadata"); } SchemaMetadataStorable givenSchemaMetadataStorable = new SchemaMetadataStorable(); givenSchemaMetadataStorable.setName(schemaName); SchemaMetadataStorable schemaMetadataStorable = storageManager.get(givenSchemaMetadataStorable.getStorableKey()); if (schemaMetadataStorable != null) { schemaMetadataStorable = SchemaMetadataStorable.updateSchemaMetadata(schemaMetadataStorable, schemaMetadata); storageManager.update(schemaMetadataStorable); return schemaMetadataStorable.toSchemaMetadataInfo(); } else { return null; } }
public static SchemaMetadataStorable updateSchemaMetadata(SchemaMetadataStorable schemaMetadataStorable, SchemaMetadata schemaMetadata) { schemaMetadataStorable.setType(schemaMetadata.getType()); schemaMetadataStorable.setSchemaGroup(schemaMetadata.getSchemaGroup()); schemaMetadataStorable.setName(schemaMetadata.getName()); schemaMetadataStorable.setDescription(schemaMetadata.getDescription()); schemaMetadataStorable.setCompatibility(schemaMetadata.getCompatibility()); schemaMetadataStorable.setValidationLevel(schemaMetadata.getValidationLevel()); schemaMetadataStorable.setEvolve(schemaMetadata.isEvolve()); return schemaMetadataStorable; }