From a33c3b6801f017b691815285da28877d26611aa4 Mon Sep 17 00:00:00 2001 From: Pablo Takara Date: Mon, 2 Dec 2024 10:58:37 +0100 Subject: [PATCH] Set Certification Field Dynamically --- .../impl/SetEntityCertificationImpl.java | 10 +++++++--- .../service/jdbi3/EntityRepository.java | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java index 857605f3beee..1de5a955412c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/SetEntityCertificationImpl.java @@ -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 @@ -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); } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java index 9a7cda3fa51a..9f969a522049 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java @@ -916,6 +916,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 @@ -1693,6 +1694,22 @@ public final void applyTags(List 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 getTags(T entity) { return !supportsTags ? null : getTags(entity.getFullyQualifiedName()); }