Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDelete MetadataInterceptor #582

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public interface MetadataInterceptor {

/**
* apply business rules before retrieving back. These rules may change or overriding existing
* Apply business rules before retrieving back. These rules may change or override existing
* business metadata.
*
* @param userMetadataService user metadata service
Expand All @@ -47,14 +47,25 @@ default void onRead(final UserMetadataService userMetadataService,
}

/**
* Valide ObjectNode before storing it.
* Validate ObjectNode before storing it.
* @param userMetadataService user metadata service
* @param name qualified name
* @param objectNode input metadata object node
* @param name qualified name
* @param objectNode input metadata object node
* @throws InvalidMetadataException business validation exception
*/
default void onWrite(final UserMetadataService userMetadataService,
final QualifiedName name, final ObjectNode objectNode)
throws InvalidMetadataException {
}

/**
* Validate ObjectNode before deleting it.
* @param userMetadataService user metadata service
* @param name qualified name
* @throws InvalidMetadataException business validation exception
*/
default void onDelete(final UserMetadataService userMetadataService,
final QualifiedName name)
throws InvalidMetadataException {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ private void _deleteDefinitionMetadata(
@Nullable final List<QualifiedName> names
) {
if (names != null && !names.isEmpty()) {
for (QualifiedName name : names) {
this.metadataInterceptor.onDelete(this, name);
}
final SqlParameterValue[] aNames = names.stream().filter(name -> !name.isPartitionDefinition())
.map(n -> new SqlParameterValue(Types.VARCHAR, n))
.toArray(SqlParameterValue[]::new);
Expand Down Expand Up @@ -599,7 +602,7 @@ public void saveDefinitionMetadata(
name.toString());

} else {
//apply interceptor to change the object node
// apply interceptor to change the object node
if (metadata.isPresent()) {
this.metadataInterceptor.onWrite(this, name, metadata.get());
}
Expand Down
Loading