From c2b15a4377febdbd92d25d720d96037eef814829 Mon Sep 17 00:00:00 2001 From: Milan Bariya <52292922+MilanBariya@users.noreply.github.com> Date: Wed, 13 Jul 2022 15:23:27 +0530 Subject: [PATCH] FIX 5712: make generate gives different results depending on OS (#6035) FIX 5712: make generate gives different results depending on OS (#6035) --- .../openmetadata/catalog/jdbi3/CollectionDAO.java | 2 +- .../openmetadata/catalog/jdbi3/EntityRepository.java | 12 ++++++------ .../catalog/jdbi3/GlossaryRepository.java | 4 ++-- .../catalog/jdbi3/GlossaryTermRepository.java | 6 +++--- .../catalog/jdbi3/TagCategoryRepository.java | 8 ++++---- .../openmetadata/catalog/jdbi3/TagRepository.java | 10 +++++----- .../org/openmetadata/catalog/util/EntityUtil.java | 6 +++--- .../main/resources/json/schema/type/tagLabel.json | 9 ++++++--- .../catalog/EnumBackwardCompatibilityTest.java | 6 +++--- .../org/openmetadata/catalog/util/TestUtils.java | 4 ++-- .../ingestion/source/database/common_db_source.py | 7 ++++++- .../ingestion/source/database/database_service.py | 9 +++++++-- .../core/entity/repository/EntityRepository.java | 12 ++++++------ .../org/openmetadata/core/jdbi3/CollectionDAO.java | 2 +- .../main/resources/json/schema/type/tagLabel.json | 9 ++++++--- .../GlossaryDetails/GlossaryDetails.component.tsx | 4 ++-- .../GlossaryTerms/GlossaryTermsV1.component.tsx | 4 ++-- .../ui/src/components/SchemaTab/SchemaTab.test.tsx | 6 +++--- .../src/components/tags-container/tags-container.tsx | 4 ++-- .../ui/src/components/tags-viewer/tags-viewer.tsx | 4 ++-- .../ui/src/pages/TasksPage/shared/TagSuggestion.tsx | 6 +++--- 21 files changed, 75 insertions(+), 59 deletions(-) diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java index 1a2502a2b28..c0e41747934 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java @@ -1474,7 +1474,7 @@ public interface CollectionDAO { String description1 = r.getString("description1"); String description2 = r.getString("description2"); return new TagLabel() - .withSource(TagLabel.Source.values()[r.getInt("source")]) + .withSource(TagLabel.TagSource.values()[r.getInt("source")]) .withLabelType(TagLabel.LabelType.values()[r.getInt("labelType")]) .withState(TagLabel.State.values()[r.getInt("state")]) .withTagFQN(r.getString("tagFQN")) diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java index 5f46d5d6a5e..26a6b1266ab 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/EntityRepository.java @@ -81,7 +81,7 @@ import org.openmetadata.catalog.type.Include; import org.openmetadata.catalog.type.Relationship; import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.type.TagLabel.LabelType; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; import org.openmetadata.catalog.util.FullyQualifiedName; @@ -741,7 +741,7 @@ public abstract class EntityRepository { /** Get tags associated with a given set of tags */ private List getDerivedTags(TagLabel tagLabel) { - if (tagLabel.getSource() == Source.GLOSSARY) { // Related tags are only supported for Glossary + if (tagLabel.getSource() == TagSource.GLOSSARY) { // Related tags are only supported for Glossary List derivedTags = daoCollection.tagUsageDAO().getTags(tagLabel.getTagFQN()); derivedTags.forEach(tag -> tag.setLabelType(LabelType.DERIVED)); return derivedTags; @@ -759,14 +759,14 @@ public abstract class EntityRepository { /** Apply tags {@code tagLabels} to the entity or field identified by {@code targetFQN} */ public void applyTags(List tagLabels, String targetFQN) { for (TagLabel tagLabel : listOrEmpty(tagLabels)) { - if (tagLabel.getSource() == Source.TAG) { + if (tagLabel.getSource() == TagSource.TAG) { Tag tag = daoCollection.tagDAO().findEntityByName(tagLabel.getTagFQN()); tagLabel.withDescription(tag.getDescription()); - tagLabel.setSource(Source.TAG); - } else if (tagLabel.getSource() == Source.GLOSSARY) { + tagLabel.setSource(TagSource.TAG); + } else if (tagLabel.getSource() == TagSource.GLOSSARY) { GlossaryTerm term = daoCollection.glossaryTermDAO().findEntityByName(tagLabel.getTagFQN(), NON_DELETED); tagLabel.withDescription(term.getDescription()); - tagLabel.setSource(Source.GLOSSARY); + tagLabel.setSource(TagSource.GLOSSARY); } // Apply tagLabel to targetFQN that identifies an entity or field diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryRepository.java index cf56fe195c1..4363745b2e6 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryRepository.java @@ -30,7 +30,7 @@ import org.openmetadata.catalog.resources.glossary.GlossaryResource; import org.openmetadata.catalog.type.EntityReference; import org.openmetadata.catalog.type.Relationship; import org.openmetadata.catalog.type.TagLabel; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; @@ -91,7 +91,7 @@ public class GlossaryRepository extends EntityRepository { } private Integer getUsageCount(Glossary glossary) { - return daoCollection.tagUsageDAO().getTagCount(Source.GLOSSARY.ordinal(), glossary.getName()); + return daoCollection.tagUsageDAO().getTagCount(TagSource.GLOSSARY.ordinal(), glossary.getName()); } @Override diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryTermRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryTermRepository.java index da4dc49558b..74bc773023a 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryTermRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/GlossaryTermRepository.java @@ -37,7 +37,7 @@ import org.openmetadata.catalog.resources.glossary.GlossaryTermResource; import org.openmetadata.catalog.type.EntityReference; import org.openmetadata.catalog.type.Relationship; import org.openmetadata.catalog.type.TagLabel; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.catalog.util.EntityUtil; import org.openmetadata.catalog.util.EntityUtil.Fields; import org.openmetadata.catalog.util.FullyQualifiedName; @@ -71,7 +71,7 @@ public class GlossaryTermRepository extends EntityRepository { } private Integer getUsageCount(GlossaryTerm term) { - return daoCollection.tagUsageDAO().getTagCount(Source.GLOSSARY.ordinal(), term.getFullyQualifiedName()); + return daoCollection.tagUsageDAO().getTagCount(TagSource.GLOSSARY.ordinal(), term.getFullyQualifiedName()); } private EntityReference getParent(GlossaryTerm entity) throws IOException { @@ -197,7 +197,7 @@ public class GlossaryTermRepository extends EntityRepository { @Override protected void postDelete(GlossaryTerm entity) { // Cleanup all the tag labels using this glossary term - daoCollection.tagUsageDAO().deleteTagLabels(Source.GLOSSARY.ordinal(), entity.getFullyQualifiedName()); + daoCollection.tagUsageDAO().deleteTagLabels(TagSource.GLOSSARY.ordinal(), entity.getFullyQualifiedName()); } /** Handles entity updated from PUT and POST operation. */ diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagCategoryRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagCategoryRepository.java index 45061af02b8..4e3ec69f874 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagCategoryRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagCategoryRepository.java @@ -28,7 +28,7 @@ import org.openmetadata.catalog.resources.tags.TagResource; import org.openmetadata.catalog.type.Include; import org.openmetadata.catalog.type.TagCategory; import org.openmetadata.catalog.type.TagLabel; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.catalog.util.EntityUtil.Fields; import org.openmetadata.catalog.util.FullyQualifiedName; import org.openmetadata.catalog.util.JsonUtils; @@ -103,7 +103,7 @@ public class TagCategoryRepository extends EntityRepository { public void storeRelationships(TagCategory entity) {} private Integer getUsageCount(TagCategory category) { - return daoCollection.tagUsageDAO().getTagCount(Source.TAG.ordinal(), category.getName()); + return daoCollection.tagUsageDAO().getTagCount(TagSource.TAG.ordinal(), category.getName()); } @Transaction @@ -111,8 +111,8 @@ public class TagCategoryRepository extends EntityRepository { TagCategory category = get(uriInfo, id, Fields.EMPTY_FIELDS, Include.NON_DELETED); dao.delete(id); daoCollection.tagDAO().deleteTagsByPrefix(category.getName()); - daoCollection.tagUsageDAO().deleteTagLabels(Source.TAG.ordinal(), category.getName()); - daoCollection.tagUsageDAO().deleteTagLabelsByPrefix(Source.TAG.ordinal(), category.getName()); + daoCollection.tagUsageDAO().deleteTagLabels(TagSource.TAG.ordinal(), category.getName()); + daoCollection.tagUsageDAO().deleteTagLabelsByPrefix(TagSource.TAG.ordinal(), category.getName()); return category; } diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagRepository.java index 4c1f857d151..bb956d3f4ec 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/TagRepository.java @@ -25,7 +25,7 @@ import org.openmetadata.catalog.Entity; import org.openmetadata.catalog.entity.tags.Tag; import org.openmetadata.catalog.resources.tags.TagResource; import org.openmetadata.catalog.type.Include; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.catalog.util.EntityUtil.Fields; import org.openmetadata.catalog.util.FullyQualifiedName; import org.openmetadata.catalog.util.JsonUtils; @@ -113,7 +113,7 @@ public class TagRepository extends EntityRepository { @Override protected void postDelete(Tag entity) { // Cleanup all the tag labels using this tag - daoCollection.tagUsageDAO().deleteTagLabels(Source.TAG.ordinal(), entity.getFullyQualifiedName()); + daoCollection.tagUsageDAO().deleteTagLabels(TagSource.TAG.ordinal(), entity.getFullyQualifiedName()); } @Override @@ -123,7 +123,7 @@ public class TagRepository extends EntityRepository { } private Integer getUsageCount(Tag tag) { - return daoCollection.tagUsageDAO().getTagCount(Source.TAG.ordinal(), tag.getFullyQualifiedName()); + return daoCollection.tagUsageDAO().getTagCount(TagSource.TAG.ordinal(), tag.getFullyQualifiedName()); } @Transaction @@ -131,8 +131,8 @@ public class TagRepository extends EntityRepository { Tag tag = get(uriInfo, id, Fields.EMPTY_FIELDS, Include.NON_DELETED); dao.delete(id); daoCollection.tagDAO().deleteTagsByPrefix(tag.getFullyQualifiedName()); - daoCollection.tagUsageDAO().deleteTagLabels(Source.TAG.ordinal(), tag.getFullyQualifiedName()); - daoCollection.tagUsageDAO().deleteTagLabelsByPrefix(Source.TAG.ordinal(), tag.getFullyQualifiedName()); + daoCollection.tagUsageDAO().deleteTagLabels(TagSource.TAG.ordinal(), tag.getFullyQualifiedName()); + daoCollection.tagUsageDAO().deleteTagLabelsByPrefix(TagSource.TAG.ordinal(), tag.getFullyQualifiedName()); return tag; } diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java index e7b79d8e2b7..de0a6888bcc 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/util/EntityUtil.java @@ -62,7 +62,7 @@ import org.openmetadata.catalog.type.MlHyperParameter; import org.openmetadata.catalog.type.Schedule; import org.openmetadata.catalog.type.TableConstraint; import org.openmetadata.catalog.type.TagLabel; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.catalog.type.Task; import org.openmetadata.catalog.type.UsageDetails; import org.openmetadata.catalog.type.UsageStats; @@ -370,13 +370,13 @@ public final class EntityUtil { return new TagLabel() .withTagFQN(term.getFullyQualifiedName()) .withDescription(term.getDescription()) - .withSource(Source.GLOSSARY); + .withSource(TagSource.GLOSSARY); } public static TagLabel getTagLabel(Tag tag) throws HttpResponseException { return new TagLabel() .withTagFQN(tag.getFullyQualifiedName()) .withDescription(tag.getDescription()) - .withSource(Source.TAG); + .withSource(TagSource.TAG); } } diff --git a/catalog-rest-service/src/main/resources/json/schema/type/tagLabel.json b/catalog-rest-service/src/main/resources/json/schema/type/tagLabel.json index 6140f86f843..1d491b95a4b 100644 --- a/catalog-rest-service/src/main/resources/json/schema/type/tagLabel.json +++ b/catalog-rest-service/src/main/resources/json/schema/type/tagLabel.json @@ -9,6 +9,11 @@ "tagFQN": { "type": "string", "maxLength": 45 + }, + "TagSource": { + "type": "string", + "default": "Tag", + "enum": ["Tag", "Glossary"] } }, "properties": { @@ -21,9 +26,7 @@ }, "source": { "description": "Label is from Tags or Glossary.", - "type": "string", - "enum": ["Tag", "Glossary"], - "default": "Tag" + "$ref": "#/definitions/TagSource" }, "labelType": { "description": "Label type describes how a tag label was applied. 'Manual' indicates the tag label was applied by a person. 'Derived' indicates a tag label was derived using the associated tag relationship (see TagCategory.json for more details). 'Propagated` indicates a tag label was propagated from upstream based on lineage. 'Automated' is used when a tool was used to determine the tag label.", diff --git a/catalog-rest-service/src/test/java/org/openmetadata/catalog/EnumBackwardCompatibilityTest.java b/catalog-rest-service/src/test/java/org/openmetadata/catalog/EnumBackwardCompatibilityTest.java index b8a8587833c..3fd0d9e5b7a 100644 --- a/catalog-rest-service/src/test/java/org/openmetadata/catalog/EnumBackwardCompatibilityTest.java +++ b/catalog-rest-service/src/test/java/org/openmetadata/catalog/EnumBackwardCompatibilityTest.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.Test; import org.openmetadata.catalog.type.Relationship; import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.type.TagLabel.LabelType; -import org.openmetadata.catalog.type.TagLabel.Source; import org.openmetadata.catalog.type.TagLabel.State; +import org.openmetadata.catalog.type.TagLabel.TagSource; /** * Enum ordinal number is stored in the database. New enums must be added at the end to ensure backward compatibility @@ -64,7 +64,7 @@ class EnumBackwardCompatibilityTest { */ @Test void testTagSourceEnumBackwardCompatible() { - assertEquals(0, Source.TAG.ordinal()); - assertEquals(1, Source.GLOSSARY.ordinal()); + assertEquals(0, TagSource.TAG.ordinal()); + assertEquals(1, TagSource.GLOSSARY.ordinal()); } } diff --git a/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java b/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java index 1a78ab42c6d..6eb4485a9f9 100644 --- a/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java +++ b/catalog-rest-service/src/test/java/org/openmetadata/catalog/util/TestUtils.java @@ -66,7 +66,7 @@ import org.openmetadata.catalog.type.MessagingConnection; import org.openmetadata.catalog.type.MlModelConnection; import org.openmetadata.catalog.type.PipelineConnection; import org.openmetadata.catalog.type.TagLabel; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; @Slf4j public final class TestUtils { @@ -337,7 +337,7 @@ public final class TestUtils { EntityUtil.mergeTags(updatedExpectedList, expectedList); for (TagLabel expected : expectedList) { - if (expected.getSource() == Source.GLOSSARY) { + if (expected.getSource() == TagSource.GLOSSARY) { GlossaryTerm glossaryTerm = new GlossaryTermResourceTest().getEntityByName(expected.getTagFQN(), null, "tags", ADMIN_AUTH_HEADERS); List derived = new ArrayList<>(); diff --git a/ingestion/src/metadata/ingestion/source/database/common_db_source.py b/ingestion/src/metadata/ingestion/source/database/common_db_source.py index 28de5b90e6f..8fa259e371f 100644 --- a/ingestion/src/metadata/ingestion/source/database/common_db_source.py +++ b/ingestion/src/metadata/ingestion/source/database/common_db_source.py @@ -41,7 +41,12 @@ from metadata.generated.schema.metadataIngestion.workflow import ( Source as WorkflowSource, ) from metadata.generated.schema.type.entityReference import EntityReference -from metadata.generated.schema.type.tagLabel import LabelType, Source1, State, TagLabel +from metadata.generated.schema.type.tagLabel import ( + LabelType, + State, + TagLabel, + TagSource, +) from metadata.ingestion.models.ometa_tag_category import OMetaTagAndCategory from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.ingestion.source.database.database_service import ( diff --git a/ingestion/src/metadata/ingestion/source/database/database_service.py b/ingestion/src/metadata/ingestion/source/database/database_service.py index f6f3c86fbee..600a5c64a16 100644 --- a/ingestion/src/metadata/ingestion/source/database/database_service.py +++ b/ingestion/src/metadata/ingestion/source/database/database_service.py @@ -40,7 +40,12 @@ from metadata.generated.schema.metadataIngestion.workflow import ( ) from metadata.generated.schema.type import basic from metadata.generated.schema.type.basic import EntityName, FullyQualifiedEntityName -from metadata.generated.schema.type.tagLabel import LabelType, Source1, State, TagLabel +from metadata.generated.schema.type.tagLabel import ( + LabelType, + State, + TagLabel, + TagSource, +) from metadata.ingestion.api.source import Source, SourceStatus from metadata.ingestion.api.topology_runner import TopologyRunnerMixin from metadata.ingestion.models.ometa_tag_category import OMetaTagAndCategory @@ -314,7 +319,7 @@ class DatabaseServiceSource(DBTMixin, TopologyRunnerMixin, Source, ABC): ), labelType=LabelType.Automated, state=State.Suggested, - source=Source1.Tag, + source=TagSource.Tag, ) for tag_and_category in self.context.tags or [] if tag_and_category.fqn.__root__ == entity_fqn diff --git a/openmetadata-core/src/main/java/org/openmetadata/core/entity/repository/EntityRepository.java b/openmetadata-core/src/main/java/org/openmetadata/core/entity/repository/EntityRepository.java index f869438f2ce..68f6251bcd8 100644 --- a/openmetadata-core/src/main/java/org/openmetadata/core/entity/repository/EntityRepository.java +++ b/openmetadata-core/src/main/java/org/openmetadata/core/entity/repository/EntityRepository.java @@ -69,7 +69,7 @@ import org.openmetadata.catalog.type.Include; import org.openmetadata.catalog.type.Relationship; import org.openmetadata.catalog.type.TagLabel; import org.openmetadata.catalog.type.TagLabel.LabelType; -import org.openmetadata.catalog.type.TagLabel.Source; +import org.openmetadata.catalog.type.TagLabel.TagSource; import org.openmetadata.core.TypeRegistry; import org.openmetadata.core.entity.Entity; import org.openmetadata.core.entity.interfaces.EntityDAO; @@ -737,7 +737,7 @@ public abstract class EntityRepository { /** Get tags associated with a given set of tags */ private List getDerivedTags(TagLabel tagLabel) { - if (tagLabel.getSource() == Source.GLOSSARY) { // Related tags are only supported for Glossary + if (tagLabel.getSource() == TagSource.GLOSSARY) { // Related tags are only supported for Glossary List derivedTags = daoCollection.tagUsageDAO().getTags(tagLabel.getTagFQN()); derivedTags.forEach(tag -> tag.setLabelType(LabelType.DERIVED)); return derivedTags; @@ -755,14 +755,14 @@ public abstract class EntityRepository { /** Apply tags {@code tagLabels} to the entity or field identified by {@code targetFQN} */ public void applyTags(List tagLabels, String targetFQN) { for (TagLabel tagLabel : listOrEmpty(tagLabels)) { - if (tagLabel.getSource() == Source.TAG) { + if (tagLabel.getSource() == TagSource.TAG) { Tag tag = daoCollection.tagDAO().findEntityByName(tagLabel.getTagFQN()); tagLabel.withDescription(tag.getDescription()); - tagLabel.setSource(Source.TAG); - } else if (tagLabel.getSource() == Source.GLOSSARY) { + tagLabel.setSource(TagSource.TAG); + } else if (tagLabel.getSource() == TagSource.GLOSSARY) { GlossaryTerm term = daoCollection.glossaryTermDAO().findEntityByName(tagLabel.getTagFQN(), NON_DELETED); tagLabel.withDescription(term.getDescription()); - tagLabel.setSource(Source.GLOSSARY); + tagLabel.setSource(TagSource.GLOSSARY); } // Apply tagLabel to targetFQN that identifies an entity or field diff --git a/openmetadata-core/src/main/java/org/openmetadata/core/jdbi3/CollectionDAO.java b/openmetadata-core/src/main/java/org/openmetadata/core/jdbi3/CollectionDAO.java index 43a5a50da01..2790ff46f74 100644 --- a/openmetadata-core/src/main/java/org/openmetadata/core/jdbi3/CollectionDAO.java +++ b/openmetadata-core/src/main/java/org/openmetadata/core/jdbi3/CollectionDAO.java @@ -1445,7 +1445,7 @@ public interface CollectionDAO { String description1 = r.getString("description1"); String description2 = r.getString("description2"); return new TagLabel() - .withSource(TagLabel.Source.values()[r.getInt("source")]) + .withSource(TagLabel.TagSource.values()[r.getInt("source")]) .withLabelType(TagLabel.LabelType.values()[r.getInt("labelType")]) .withState(TagLabel.State.values()[r.getInt("state")]) .withTagFQN(r.getString("tagFQN")) diff --git a/openmetadata-core/src/main/resources/json/schema/type/tagLabel.json b/openmetadata-core/src/main/resources/json/schema/type/tagLabel.json index 6140f86f843..1d491b95a4b 100644 --- a/openmetadata-core/src/main/resources/json/schema/type/tagLabel.json +++ b/openmetadata-core/src/main/resources/json/schema/type/tagLabel.json @@ -9,6 +9,11 @@ "tagFQN": { "type": "string", "maxLength": 45 + }, + "TagSource": { + "type": "string", + "default": "Tag", + "enum": ["Tag", "Glossary"] } }, "properties": { @@ -21,9 +26,7 @@ }, "source": { "description": "Label is from Tags or Glossary.", - "type": "string", - "enum": ["Tag", "Glossary"], - "default": "Tag" + "$ref": "#/definitions/TagSource" }, "labelType": { "description": "Label type describes how a tag label was applied. 'Manual' indicates the tag label was applied by a person. 'Derived' indicates a tag label was derived using the associated tag relationship (see TagCategory.json for more details). 'Propagated` indicates a tag label was propagated from upstream based on lineage. 'Automated' is used when a tool was used to determine the tag label.", diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryDetails/GlossaryDetails.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryDetails/GlossaryDetails.component.tsx index 420347771e2..969659a3cdb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryDetails/GlossaryDetails.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryDetails/GlossaryDetails.component.tsx @@ -27,7 +27,7 @@ import { import { Glossary } from '../../generated/entity/data/glossary'; import { Operation } from '../../generated/entity/policies/policy'; import { EntityReference } from '../../generated/type/entityReference'; -import { LabelType, Source, State } from '../../generated/type/tagLabel'; +import { LabelType, State, TagSource } from '../../generated/type/tagLabel'; import { useAuth } from '../../hooks/authHooks'; import jsonData from '../../jsons/en'; import { getEntityName, hasEditAccess } from '../../utils/CommonUtils'; @@ -111,7 +111,7 @@ const GlossaryDetails = ({ isHasAccess, glossary, updateGlossary }: props) => { .map((tag) => ({ labelType: LabelType.Manual, state: State.Confirmed, - source: Source.Tag, + source: TagSource.Tag, tagFQN: tag, })); const updatedTags = [...prevTags, ...newTags]; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermsV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermsV1.component.tsx index 4863fac6bee..18b48c06d18 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermsV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermsV1.component.tsx @@ -31,7 +31,7 @@ import { TermReference, } from '../../generated/entity/data/glossaryTerm'; import { EntityReference } from '../../generated/entity/type'; -import { LabelType, Source, State } from '../../generated/type/tagLabel'; +import { LabelType, State, TagSource } from '../../generated/type/tagLabel'; import jsonData from '../../jsons/en'; import { getEntityName } from '../../utils/CommonUtils'; import SVGIcons, { Icons } from '../../utils/SvgUtils'; @@ -187,7 +187,7 @@ const GlossaryTermsV1 = ({ .map((tag) => ({ labelType: LabelType.Manual, state: State.Confirmed, - source: Source.Tag, + source: TagSource.Tag, tagFQN: tag, })); const updatedTags = [...prevTags, ...newTags]; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/SchemaTab/SchemaTab.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/SchemaTab/SchemaTab.test.tsx index 762a774d92e..2d2f78629df 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/SchemaTab/SchemaTab.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/SchemaTab/SchemaTab.test.tsx @@ -19,9 +19,9 @@ import { Column, DataType, LabelType, - Source, State, Table, + TagSource, } from '../../generated/entity/data/table'; import SchemaTab from './SchemaTab.component'; const mockColumns: Column[] = [ @@ -34,13 +34,13 @@ const mockColumns: Column[] = [ { tagFQN: 'string', labelType: LabelType.Manual, - source: Source.Tag, + source: TagSource.Tag, state: State.Confirmed, }, { tagFQN: 'string2', labelType: LabelType.Derived, - source: Source.Tag, + source: TagSource.Tag, state: State.Confirmed, }, ], diff --git a/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx b/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx index 31c485f9921..afc96afb7e2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx @@ -18,7 +18,7 @@ import { EntityTags, TagOption } from 'Models'; import React, { Fragment, FunctionComponent, useEffect, useState } from 'react'; import AsyncSelect from 'react-select/async'; import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants'; -import { Source } from '../../generated/type/tagLabel'; +import { TagSource } from '../../generated/type/tagLabel'; import { withLoader } from '../../hoc/withLoader'; import { Button } from '../buttons/Button/Button'; import Tags from '../tags/tags'; @@ -109,7 +109,7 @@ const TagsContainer: FunctionComponent = ({ removeTag={(_e, removedTag: string) => { handleTagRemoval(removedTag, index); }} - showOnlyName={tag.source === Source.Glossary} + showOnlyName={tag.source === TagSource.Glossary} tag={tag} type="border" /> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/tags-viewer/tags-viewer.tsx b/openmetadata-ui/src/main/resources/ui/src/components/tags-viewer/tags-viewer.tsx index dea6d654123..ddf50e4e9b4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/tags-viewer/tags-viewer.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/tags-viewer/tags-viewer.tsx @@ -16,7 +16,7 @@ import { isNil } from 'lodash'; import { EntityTags } from 'Models'; import React, { Fragment, FunctionComponent } from 'react'; import { LIST_SIZE } from '../../constants/constants'; -import { Source } from '../../generated/type/tagLabel'; +import { TagSource } from '../../generated/type/tagLabel'; import PopOver from '../common/popover/PopOver'; import Tags from '../tags/tags'; import { TagsViewerProps } from './tags-viewer.interface'; @@ -39,7 +39,7 @@ const TagsViewer: FunctionComponent = ({ { 'diff-added tw-mx-1': tag?.added }, { 'diff-removed': tag?.removed } )} - showOnlyName={tag.source === Source.Glossary} + showOnlyName={tag.source === TagSource.Glossary} startWith={showStartWith ? '#' : undefined} tag={tag} type={type} diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/TasksPage/shared/TagSuggestion.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/TasksPage/shared/TagSuggestion.tsx index 184fc9be6d4..fef0e4cf6d3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/TasksPage/shared/TagSuggestion.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/TasksPage/shared/TagSuggestion.tsx @@ -18,9 +18,9 @@ import React, { useEffect, useState } from 'react'; import { getTagSuggestions } from '../../../axiosAPIs/miscAPI'; import { LabelType, - Source, State, TagLabel, + TagSource, } from '../../../generated/type/tagLabel'; import { showErrorToast } from '../../../utils/ToastUtils'; @@ -84,8 +84,8 @@ const TagSuggestion: React.FC = ({ onChange, selectedTags }) => { labelType: LabelType.Manual, state: State.Suggested, source: isEqual(value['data-sourceType'], 'tag') - ? Source.Tag - : Source.Glossary, + ? TagSource.Tag + : TagSource.Glossary, tagFQN: value.value, })); onChange(newTags);