-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(removed): Make sure removed entities do not appear on recommendat…
…ions (#4353)
- Loading branch information
Dexter Lee
authored
Mar 11, 2022
1 parent
3ea7286
commit fab9c23
Showing
8 changed files
with
96 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
metadata-io/src/main/java/com/linkedin/metadata/entity/EntityUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.linkedin.metadata.entity; | ||
|
||
import com.linkedin.common.Status; | ||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.entity.EnvelopedAspect; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
||
@Slf4j | ||
public class EntityUtils { | ||
private EntityUtils() { | ||
} | ||
|
||
/** | ||
* Check if entity is removed (removed=true in Status aspect) | ||
*/ | ||
public static boolean checkIfRemoved(EntityService entityService, Urn entityUrn) { | ||
try { | ||
EnvelopedAspect statusAspect = | ||
entityService.getLatestEnvelopedAspect(entityUrn.getEntityType(), entityUrn, "status"); | ||
if (statusAspect == null) { | ||
return false; | ||
} | ||
Status status = new Status(statusAspect.getValue().data()); | ||
return status.isRemoved(); | ||
} catch (Exception e) { | ||
log.error("Error while checking if {} is removed", entityUrn, e); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.