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

MINOR: Set Certification Field Dynamically #18874

Merged
merged 5 commits into from
Dec 4, 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 @@ -16,11 +16,10 @@
import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.type.AssetCertification;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.TagLabel;
import org.openmetadata.service.Entity;
import org.openmetadata.service.jdbi3.EntityRepository;
import org.openmetadata.service.resources.feeds.MessageParser;
import org.openmetadata.service.resources.tags.TagLabelUtil;
import org.openmetadata.service.util.EntityUtil;
import org.openmetadata.service.util.JsonUtils;

@Slf4j
Expand Down Expand Up @@ -76,7 +75,12 @@ private void setStatus(

AssetCertification assetCertification =
new AssetCertification()
.withTagLabel(EntityUtil.toTagLabel(TagLabelUtil.getTag(certification)));
.withTagLabel(
new TagLabel()
.withTagFQN(certification)
.withSource(TagLabel.TagSource.CLASSIFICATION)
.withLabelType(TagLabel.LabelType.AUTOMATED)
.withState(TagLabel.State.CONFIRMED));
entity.setCertification(assetCertification);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ public final void storeRelationshipsInternal(T entity) {
public final T setFieldsInternal(T entity, Fields fields) {
entity.setOwners(fields.contains(FIELD_OWNERS) ? getOwners(entity) : entity.getOwners());
entity.setTags(fields.contains(FIELD_TAGS) ? getTags(entity) : entity.getTags());
entity.setCertification(fields.contains(FIELD_TAGS) ? getCertification(entity) : null);
entity.setExtension(
fields.contains(FIELD_EXTENSION) ? getExtension(entity) : entity.getExtension());
// Always return domains of entity
Expand Down Expand Up @@ -1715,6 +1716,22 @@ public final void applyTags(List<TagLabel> tagLabels, String targetFQN) {
}
}

protected AssetCertification getCertification(T entity) {
return !supportsCertification ? null : getCertification(entity.getCertification());
}

protected AssetCertification getCertification(AssetCertification certification) {
if (certification == null) {
return null;
}

String certificationTagFqn = certification.getTagLabel().getTagFQN();
TagLabel certificationTagLabel =
EntityUtil.toTagLabel(TagLabelUtil.getTag(certificationTagFqn));
certification.setTagLabel(certificationTagLabel);
return certification;
}

protected List<TagLabel> getTags(T entity) {
return !supportsTags ? null : getTags(entity.getFullyQualifiedName());
}
Expand Down
Loading