Skip to content

Commit

Permalink
fix(views): Add relationship annotation to GlobalViewsSettings urn (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro93 authored and sleeperdeep committed Jun 25, 2024
1 parent a62dcd4 commit 4d686ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ record GlobalViewsSettings {
/**
* The default View for the instance, or organization.
*/
@Relationship = {
"name": "viewedWith",
"entityTypes": [ "dataHubView" ]
}
defaultView: optional Urn
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import com.linkedin.metadata.entity.AspectUtils;
import com.linkedin.metadata.key.DataHubViewKey;
import com.linkedin.metadata.utils.EntityKeyUtils;
import com.linkedin.r2.RemoteInvocationException;
import com.linkedin.view.DataHubViewDefinition;
import com.linkedin.view.DataHubViewInfo;
import com.linkedin.view.DataHubViewType;
import io.datahubproject.metadata.context.OperationContext;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -177,6 +179,20 @@ public void deleteView(@Nonnull OperationContext opContext, @Nonnull Urn viewUrn
try {
this.entityClient.deleteEntity(
opContext, Objects.requireNonNull(viewUrn, "viewUrn must not be null"));

// Asynchronously delete all references to the entity (to return quickly)
CompletableFuture.runAsync(
() -> {
try {
this.entityClient.deleteEntityReferences(opContext, viewUrn);
} catch (RemoteInvocationException e) {
log.error(
String.format(
"Caught exception while attempting to clear all entity references for view with urn %s",
viewUrn),
e);
}
});
} catch (Exception e) {
throw new RuntimeException(String.format("Failed to delete View with urn %s", viewUrn), e);
}
Expand Down

0 comments on commit 4d686ea

Please sign in to comment.