mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-18 11:07:41 +00:00
This reverts commit 5b30aa94e2e018eb4c486d14424a5d34b2877979.
This commit is contained in:
parent
5b30aa94e2
commit
d065d85e0a
@ -324,20 +324,16 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
|||||||
boolean dryRun = Boolean.TRUE.equals(request.getDryRun());
|
boolean dryRun = Boolean.TRUE.equals(request.getDryRun());
|
||||||
|
|
||||||
GlossaryTerm term = this.get(null, glossaryTermId, getFields("id,tags"));
|
GlossaryTerm term = this.get(null, glossaryTermId, getFields("id,tags"));
|
||||||
EntityRepository<?> glossaryRepository =
|
|
||||||
Entity.getEntityRepository(term.getGlossary().getType());
|
|
||||||
EntityInterface glossary =
|
|
||||||
glossaryRepository.get(
|
|
||||||
null, term.getGlossary().getId(), glossaryRepository.getFields("tags"));
|
|
||||||
// Check if the tags are mutually exclusive for the glossary
|
// Check if the tags are mutually exclusive for the glossary
|
||||||
checkMutuallyExclusive(glossary.getTags());
|
checkMutuallyExclusive(request.getGlossaryTags());
|
||||||
|
|
||||||
BulkOperationResult result = new BulkOperationResult().withDryRun(dryRun);
|
BulkOperationResult result = new BulkOperationResult().withDryRun(dryRun);
|
||||||
List<BulkResponse> failures = new ArrayList<>();
|
List<BulkResponse> failures = new ArrayList<>();
|
||||||
List<BulkResponse> success = new ArrayList<>();
|
List<BulkResponse> success = new ArrayList<>();
|
||||||
|
|
||||||
if (dryRun
|
if (dryRun
|
||||||
&& (CommonUtil.nullOrEmpty(glossary.getTags())
|
&& (CommonUtil.nullOrEmpty(request.getGlossaryTags())
|
||||||
|| CommonUtil.nullOrEmpty(request.getAssets()))) {
|
|| CommonUtil.nullOrEmpty(request.getAssets()))) {
|
||||||
// Nothing to Validate
|
// Nothing to Validate
|
||||||
return result
|
return result
|
||||||
@ -369,7 +365,7 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
|||||||
asset.getFullyQualifiedName(),
|
asset.getFullyQualifiedName(),
|
||||||
FullyQualifiedName.buildHash(asset.getFullyQualifiedName()),
|
FullyQualifiedName.buildHash(asset.getFullyQualifiedName()),
|
||||||
allAssetTags,
|
allAssetTags,
|
||||||
glossary.getTags(),
|
request.getGlossaryTags(),
|
||||||
false);
|
false);
|
||||||
success.add(new BulkResponse().withRequest(ref));
|
success.add(new BulkResponse().withRequest(ref));
|
||||||
result.setNumberOfRowsPassed(result.getNumberOfRowsPassed() + 1);
|
result.setNumberOfRowsPassed(result.getNumberOfRowsPassed() + 1);
|
||||||
@ -392,11 +388,11 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
|||||||
// Apply the tags of glossary to the glossary term
|
// Apply the tags of glossary to the glossary term
|
||||||
if (!dryRun
|
if (!dryRun
|
||||||
&& CommonUtil.nullOrEmpty(result.getFailedRequest())
|
&& CommonUtil.nullOrEmpty(result.getFailedRequest())
|
||||||
&& (!(term.getTags().isEmpty() && glossary.getTags().isEmpty()))) {
|
&& (!(term.getTags().isEmpty() && request.getGlossaryTags().isEmpty()))) {
|
||||||
// Remove current entity tags in the database. It will be added back later from the merged tag
|
// Remove current entity tags in the database. It will be added back later from the merged tag
|
||||||
// list.
|
// list.
|
||||||
daoCollection.tagUsageDAO().deleteTagsByTarget(term.getFullyQualifiedName());
|
daoCollection.tagUsageDAO().deleteTagsByTarget(term.getFullyQualifiedName());
|
||||||
applyTags(getUniqueTags(glossary.getTags()), term.getFullyQualifiedName());
|
applyTags(getUniqueTags(request.getGlossaryTags()), term.getFullyQualifiedName());
|
||||||
|
|
||||||
searchRepository.updateEntity(term.getEntityReference());
|
searchRepository.updateEntity(term.getEntityReference());
|
||||||
}
|
}
|
||||||
@ -420,16 +416,10 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
|||||||
UUID glossaryTermId, AddGlossaryToAssetsRequest request) {
|
UUID glossaryTermId, AddGlossaryToAssetsRequest request) {
|
||||||
GlossaryTerm term = this.get(null, glossaryTermId, getFields("id,tags"));
|
GlossaryTerm term = this.get(null, glossaryTermId, getFields("id,tags"));
|
||||||
|
|
||||||
EntityRepository<?> glossaryRepository =
|
List<TagLabel> glossaryTagsToValidate = request.getGlossaryTags();
|
||||||
Entity.getEntityRepository(term.getGlossary().getType());
|
|
||||||
EntityInterface glossary =
|
|
||||||
glossaryRepository.get(
|
|
||||||
null, term.getGlossary().getId(), glossaryRepository.getFields("tags"));
|
|
||||||
|
|
||||||
List<TagLabel> glossaryTagsToValidate = glossary.getTags();
|
|
||||||
|
|
||||||
// Check if the tags are mutually exclusive for the glossary
|
// Check if the tags are mutually exclusive for the glossary
|
||||||
checkMutuallyExclusive(glossary.getTags());
|
checkMutuallyExclusive(request.getGlossaryTags());
|
||||||
|
|
||||||
BulkOperationResult result = new BulkOperationResult().withDryRun(true);
|
BulkOperationResult result = new BulkOperationResult().withDryRun(true);
|
||||||
List<BulkResponse> failures = new ArrayList<>();
|
List<BulkResponse> failures = new ArrayList<>();
|
||||||
|
|||||||
@ -89,7 +89,6 @@ import org.openmetadata.schema.type.Include;
|
|||||||
import org.openmetadata.schema.type.TagLabel;
|
import org.openmetadata.schema.type.TagLabel;
|
||||||
import org.openmetadata.schema.type.TaskDetails;
|
import org.openmetadata.schema.type.TaskDetails;
|
||||||
import org.openmetadata.schema.type.TaskStatus;
|
import org.openmetadata.schema.type.TaskStatus;
|
||||||
import org.openmetadata.schema.type.api.BulkOperationResult;
|
|
||||||
import org.openmetadata.service.Entity;
|
import org.openmetadata.service.Entity;
|
||||||
import org.openmetadata.service.governance.workflows.WorkflowHandler;
|
import org.openmetadata.service.governance.workflows.WorkflowHandler;
|
||||||
import org.openmetadata.service.resources.EntityResourceTest;
|
import org.openmetadata.service.resources.EntityResourceTest;
|
||||||
@ -1457,45 +1456,6 @@ public class GlossaryTermResourceTest extends EntityResourceTest<GlossaryTerm, C
|
|||||||
term1.getName(), glossary.getName())));
|
term1.getName(), glossary.getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void test_bulkAddAssetsToGlossaryTerm() throws IOException {
|
|
||||||
TagLabel glossaryTag =
|
|
||||||
new TagLabel()
|
|
||||||
.withTagFQN("PII.Sensitive")
|
|
||||||
.withSource(TagLabel.TagSource.CLASSIFICATION)
|
|
||||||
.withLabelType(TagLabel.LabelType.MANUAL);
|
|
||||||
CreateGlossary createGlossary =
|
|
||||||
glossaryTest.createRequest("GlossaryWithTags").withTags(List.of(glossaryTag));
|
|
||||||
Glossary glossary = glossaryTest.createEntity(createGlossary, ADMIN_AUTH_HEADERS);
|
|
||||||
|
|
||||||
CreateGlossaryTerm createTerm =
|
|
||||||
createRequest("TermForBulkAdd").withGlossary(glossary.getFullyQualifiedName());
|
|
||||||
GlossaryTerm term = createEntity(createTerm, ADMIN_AUTH_HEADERS);
|
|
||||||
|
|
||||||
TableResourceTest tableResourceTest = new TableResourceTest();
|
|
||||||
CreateTable createTable = tableResourceTest.createRequest("BulkAddTable");
|
|
||||||
Table table = tableResourceTest.createEntity(createTable, ADMIN_AUTH_HEADERS);
|
|
||||||
|
|
||||||
Map<String, Object> payload =
|
|
||||||
Map.of(
|
|
||||||
"assets",
|
|
||||||
List.of(new EntityReference().withId(table.getId()).withType("table")),
|
|
||||||
"dryRun",
|
|
||||||
false);
|
|
||||||
|
|
||||||
WebTarget target = getCollection().path(String.format("/%s/assets/add", term.getId()));
|
|
||||||
TestUtils.put(target, payload, BulkOperationResult.class, OK, ADMIN_AUTH_HEADERS);
|
|
||||||
|
|
||||||
Table updatedTable = tableResourceTest.getEntity(table.getId(), "tags", ADMIN_AUTH_HEADERS);
|
|
||||||
assertTrue(
|
|
||||||
updatedTable.getTags().stream()
|
|
||||||
.anyMatch(t -> t.getTagFQN().equals(glossaryTag.getTagFQN())),
|
|
||||||
"Table should have inherited the tag from the parent glossary");
|
|
||||||
|
|
||||||
tableResourceTest.deleteEntity(table.getId(), ADMIN_AUTH_HEADERS);
|
|
||||||
deleteEntity(term.getId(), ADMIN_AUTH_HEADERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Glossary createGlossary(
|
public Glossary createGlossary(
|
||||||
TestInfo test, List<EntityReference> reviewers, List<EntityReference> owners)
|
TestInfo test, List<EntityReference> reviewers, List<EntityReference> owners)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|||||||
@ -6,11 +6,27 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"javaType": "org.openmetadata.schema.api.AddGlossaryToAssetsRequest",
|
"javaType": "org.openmetadata.schema.api.AddGlossaryToAssetsRequest",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"operation": {
|
||||||
|
"description": "Operation to be performed",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"AddAssets",
|
||||||
|
"AddGlossaryTags"
|
||||||
|
]
|
||||||
|
},
|
||||||
"dryRun": {
|
"dryRun": {
|
||||||
"description": "If true, the request will be validated but no changes will be made",
|
"description": "If true, the request will be validated but no changes will be made",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
"glossaryTags": {
|
||||||
|
"description": "Glossary Tags to be added",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "../type/tagLabel.json"
|
||||||
|
},
|
||||||
|
"default": null
|
||||||
|
},
|
||||||
"assets": {
|
"assets": {
|
||||||
"description": "List of assets to be created against which the glossary needs to be added.",
|
"description": "List of assets to be created against which the glossary needs to be added.",
|
||||||
"$ref": "../type/entityReferenceList.json"
|
"$ref": "../type/entityReferenceList.json"
|
||||||
|
|||||||
@ -7,6 +7,14 @@
|
|||||||
"javaType": "org.openmetadata.schema.api.AddTagToAssetsRequest",
|
"javaType": "org.openmetadata.schema.api.AddTagToAssetsRequest",
|
||||||
"javaInterfaces": ["org.openmetadata.schema.BulkAssetsRequestInterface"],
|
"javaInterfaces": ["org.openmetadata.schema.BulkAssetsRequestInterface"],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"operation": {
|
||||||
|
"description": "Operation to be performed",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"AddAssets",
|
||||||
|
"AddClassificationTags"
|
||||||
|
]
|
||||||
|
},
|
||||||
"dryRun": {
|
"dryRun": {
|
||||||
"description": "If true, the request will be validated but no changes will be made",
|
"description": "If true, the request will be validated but no changes will be made",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -22,6 +22,14 @@ export interface AddGlossaryToAssetsRequest {
|
|||||||
* If true, the request will be validated but no changes will be made
|
* If true, the request will be validated but no changes will be made
|
||||||
*/
|
*/
|
||||||
dryRun?: boolean;
|
dryRun?: boolean;
|
||||||
|
/**
|
||||||
|
* Glossary Tags to be added
|
||||||
|
*/
|
||||||
|
glossaryTags?: TagLabel[];
|
||||||
|
/**
|
||||||
|
* Operation to be performed
|
||||||
|
*/
|
||||||
|
operation?: Operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,3 +87,99 @@ export interface EntityReference {
|
|||||||
*/
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This schema defines the type for labeling an entity with a Tag.
|
||||||
|
*/
|
||||||
|
export interface TagLabel {
|
||||||
|
/**
|
||||||
|
* Description for the tag label.
|
||||||
|
*/
|
||||||
|
description?: string;
|
||||||
|
/**
|
||||||
|
* Display Name that identifies this tag.
|
||||||
|
*/
|
||||||
|
displayName?: string;
|
||||||
|
/**
|
||||||
|
* Link to the tag resource.
|
||||||
|
*/
|
||||||
|
href?: string;
|
||||||
|
/**
|
||||||
|
* 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 Classification.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.
|
||||||
|
*/
|
||||||
|
labelType: LabelType;
|
||||||
|
/**
|
||||||
|
* Name of the tag or glossary term.
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
/**
|
||||||
|
* Label is from Tags or Glossary.
|
||||||
|
*/
|
||||||
|
source: TagSource;
|
||||||
|
/**
|
||||||
|
* 'Suggested' state is used when a tag label is suggested by users or tools. Owner of the
|
||||||
|
* entity must confirm the suggested labels before it is marked as 'Confirmed'.
|
||||||
|
*/
|
||||||
|
state: State;
|
||||||
|
style?: Style;
|
||||||
|
tagFQN: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 Classification.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.
|
||||||
|
*/
|
||||||
|
export enum LabelType {
|
||||||
|
Automated = "Automated",
|
||||||
|
Derived = "Derived",
|
||||||
|
Generated = "Generated",
|
||||||
|
Manual = "Manual",
|
||||||
|
Propagated = "Propagated",
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label is from Tags or Glossary.
|
||||||
|
*/
|
||||||
|
export enum TagSource {
|
||||||
|
Classification = "Classification",
|
||||||
|
Glossary = "Glossary",
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'Suggested' state is used when a tag label is suggested by users or tools. Owner of the
|
||||||
|
* entity must confirm the suggested labels before it is marked as 'Confirmed'.
|
||||||
|
*/
|
||||||
|
export enum State {
|
||||||
|
Confirmed = "Confirmed",
|
||||||
|
Suggested = "Suggested",
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI Style is used to associate a color code and/or icon to entity to customize the look of
|
||||||
|
* that entity in UI.
|
||||||
|
*/
|
||||||
|
export interface Style {
|
||||||
|
/**
|
||||||
|
* Hex Color Code to mark an entity such as GlossaryTerm, Tag, Domain or Data Product.
|
||||||
|
*/
|
||||||
|
color?: string;
|
||||||
|
/**
|
||||||
|
* An icon to associate with GlossaryTerm, Tag, Domain or Data Product.
|
||||||
|
*/
|
||||||
|
iconURL?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation to be performed
|
||||||
|
*/
|
||||||
|
export enum Operation {
|
||||||
|
AddAssets = "AddAssets",
|
||||||
|
AddGlossaryTags = "AddGlossaryTags",
|
||||||
|
}
|
||||||
|
|||||||
@ -22,6 +22,10 @@ export interface AddTagToAssetsRequest {
|
|||||||
* If true, the request will be validated but no changes will be made
|
* If true, the request will be validated but no changes will be made
|
||||||
*/
|
*/
|
||||||
dryRun?: boolean;
|
dryRun?: boolean;
|
||||||
|
/**
|
||||||
|
* Operation to be performed
|
||||||
|
*/
|
||||||
|
operation?: Operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,3 +83,11 @@ export interface EntityReference {
|
|||||||
*/
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation to be performed
|
||||||
|
*/
|
||||||
|
export enum Operation {
|
||||||
|
AddAssets = "AddAssets",
|
||||||
|
AddClassificationTags = "AddClassificationTags",
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user