mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-26 19:00:02 +00:00
Fix EntityHierarchy Schema (#19104)
* Fix Entity Schema * fix additionalProperties in entityHierarchy json --------- Co-authored-by: sonikashah <sonikashah94@gmail.com> Co-authored-by: sonika-shah <58761340+sonika-shah@users.noreply.github.com>
This commit is contained in:
parent
6522e3b9b3
commit
06d71f9450
@ -148,7 +148,7 @@ import org.openmetadata.schema.dataInsight.DataInsightChartResult;
|
|||||||
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart;
|
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart;
|
||||||
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChartResultList;
|
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChartResultList;
|
||||||
import org.openmetadata.schema.dataInsight.custom.FormulaHolder;
|
import org.openmetadata.schema.dataInsight.custom.FormulaHolder;
|
||||||
import org.openmetadata.schema.entity.data.EntityHierarchy__1;
|
import org.openmetadata.schema.entity.data.EntityHierarchy;
|
||||||
import org.openmetadata.schema.entity.data.Table;
|
import org.openmetadata.schema.entity.data.Table;
|
||||||
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
||||||
import org.openmetadata.schema.tests.DataQualityReport;
|
import org.openmetadata.schema.tests.DataQualityReport;
|
||||||
@ -592,21 +592,21 @@ public class ElasticSearchClient implements SearchClient {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityHierarchy__1> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
public List<EntityHierarchy> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
||||||
Map<String, EntityHierarchy__1> termMap =
|
Map<String, EntityHierarchy> termMap =
|
||||||
new LinkedHashMap<>(); // termMap represent glossary terms
|
new LinkedHashMap<>(); // termMap represent glossary terms
|
||||||
Map<String, EntityHierarchy__1> rootTerms =
|
Map<String, EntityHierarchy> rootTerms =
|
||||||
new LinkedHashMap<>(); // rootTerms represent glossaries
|
new LinkedHashMap<>(); // rootTerms represent glossaries
|
||||||
|
|
||||||
for (var hit : searchResponse.getHits().getHits()) {
|
for (var hit : searchResponse.getHits().getHits()) {
|
||||||
String jsonSource = hit.getSourceAsString();
|
String jsonSource = hit.getSourceAsString();
|
||||||
|
|
||||||
EntityHierarchy__1 term = JsonUtils.readValue(jsonSource, EntityHierarchy__1.class);
|
EntityHierarchy term = JsonUtils.readValue(jsonSource, EntityHierarchy.class);
|
||||||
EntityHierarchy__1 glossaryInfo =
|
EntityHierarchy glossaryInfo =
|
||||||
JsonUtils.readTree(jsonSource).path("glossary").isMissingNode()
|
JsonUtils.readTree(jsonSource).path("glossary").isMissingNode()
|
||||||
? null
|
? null
|
||||||
: JsonUtils.convertValue(
|
: JsonUtils.convertValue(
|
||||||
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy__1.class);
|
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy.class);
|
||||||
|
|
||||||
if (glossaryInfo != null) {
|
if (glossaryInfo != null) {
|
||||||
rootTerms.putIfAbsent(glossaryInfo.getFullyQualifiedName(), glossaryInfo);
|
rootTerms.putIfAbsent(glossaryInfo.getFullyQualifiedName(), glossaryInfo);
|
||||||
@ -626,15 +626,15 @@ public class ElasticSearchClient implements SearchClient {
|
|||||||
String termFQN = term.getFullyQualifiedName();
|
String termFQN = term.getFullyQualifiedName();
|
||||||
|
|
||||||
if (parentFQN != null && termMap.containsKey(parentFQN)) {
|
if (parentFQN != null && termMap.containsKey(parentFQN)) {
|
||||||
EntityHierarchy__1 parentTerm = termMap.get(parentFQN);
|
EntityHierarchy parentTerm = termMap.get(parentFQN);
|
||||||
List<EntityHierarchy__1> children = parentTerm.getChildren();
|
List<EntityHierarchy> children = parentTerm.getChildren();
|
||||||
children.removeIf(
|
children.removeIf(
|
||||||
child -> child.getFullyQualifiedName().equals(term.getFullyQualifiedName()));
|
child -> child.getFullyQualifiedName().equals(term.getFullyQualifiedName()));
|
||||||
children.add(term);
|
children.add(term);
|
||||||
parentTerm.setChildren(children);
|
parentTerm.setChildren(children);
|
||||||
} else {
|
} else {
|
||||||
if (rootTerms.containsKey(termFQN)) {
|
if (rootTerms.containsKey(termFQN)) {
|
||||||
EntityHierarchy__1 rootTerm = rootTerms.get(termFQN);
|
EntityHierarchy rootTerm = rootTerms.get(termFQN);
|
||||||
rootTerm.setChildren(term.getChildren());
|
rootTerm.setChildren(term.getChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ import org.openmetadata.schema.dataInsight.DataInsightChartResult;
|
|||||||
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart;
|
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChart;
|
||||||
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChartResultList;
|
import org.openmetadata.schema.dataInsight.custom.DataInsightCustomChartResultList;
|
||||||
import org.openmetadata.schema.dataInsight.custom.FormulaHolder;
|
import org.openmetadata.schema.dataInsight.custom.FormulaHolder;
|
||||||
import org.openmetadata.schema.entity.data.EntityHierarchy__1;
|
import org.openmetadata.schema.entity.data.EntityHierarchy;
|
||||||
import org.openmetadata.schema.entity.data.Table;
|
import org.openmetadata.schema.entity.data.Table;
|
||||||
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
||||||
import org.openmetadata.schema.tests.DataQualityReport;
|
import org.openmetadata.schema.tests.DataQualityReport;
|
||||||
@ -584,21 +584,21 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityHierarchy__1> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
public List<EntityHierarchy> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
||||||
Map<String, EntityHierarchy__1> termMap =
|
Map<String, EntityHierarchy> termMap =
|
||||||
new LinkedHashMap<>(); // termMap represent glossary terms
|
new LinkedHashMap<>(); // termMap represent glossary terms
|
||||||
Map<String, EntityHierarchy__1> rootTerms =
|
Map<String, EntityHierarchy> rootTerms =
|
||||||
new LinkedHashMap<>(); // rootTerms represent glossaries
|
new LinkedHashMap<>(); // rootTerms represent glossaries
|
||||||
|
|
||||||
for (var hit : searchResponse.getHits().getHits()) {
|
for (var hit : searchResponse.getHits().getHits()) {
|
||||||
String jsonSource = hit.getSourceAsString();
|
String jsonSource = hit.getSourceAsString();
|
||||||
|
|
||||||
EntityHierarchy__1 term = JsonUtils.readValue(jsonSource, EntityHierarchy__1.class);
|
EntityHierarchy term = JsonUtils.readValue(jsonSource, EntityHierarchy.class);
|
||||||
EntityHierarchy__1 glossaryInfo =
|
EntityHierarchy glossaryInfo =
|
||||||
JsonUtils.readTree(jsonSource).path("glossary").isMissingNode()
|
JsonUtils.readTree(jsonSource).path("glossary").isMissingNode()
|
||||||
? null
|
? null
|
||||||
: JsonUtils.convertValue(
|
: JsonUtils.convertValue(
|
||||||
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy__1.class);
|
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy.class);
|
||||||
|
|
||||||
if (glossaryInfo != null) {
|
if (glossaryInfo != null) {
|
||||||
rootTerms.putIfAbsent(glossaryInfo.getFullyQualifiedName(), glossaryInfo);
|
rootTerms.putIfAbsent(glossaryInfo.getFullyQualifiedName(), glossaryInfo);
|
||||||
@ -618,15 +618,15 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
String termFQN = term.getFullyQualifiedName();
|
String termFQN = term.getFullyQualifiedName();
|
||||||
|
|
||||||
if (parentFQN != null && termMap.containsKey(parentFQN)) {
|
if (parentFQN != null && termMap.containsKey(parentFQN)) {
|
||||||
EntityHierarchy__1 parentTerm = termMap.get(parentFQN);
|
EntityHierarchy parentTerm = termMap.get(parentFQN);
|
||||||
List<EntityHierarchy__1> children = parentTerm.getChildren();
|
List<EntityHierarchy> children = parentTerm.getChildren();
|
||||||
children.removeIf(
|
children.removeIf(
|
||||||
child -> child.getFullyQualifiedName().equals(term.getFullyQualifiedName()));
|
child -> child.getFullyQualifiedName().equals(term.getFullyQualifiedName()));
|
||||||
children.add(term);
|
children.add(term);
|
||||||
parentTerm.setChildren(children);
|
parentTerm.setChildren(children);
|
||||||
} else {
|
} else {
|
||||||
if (rootTerms.containsKey(termFQN)) {
|
if (rootTerms.containsKey(termFQN)) {
|
||||||
EntityHierarchy__1 rootTerm = rootTerms.get(termFQN);
|
EntityHierarchy rootTerm = rootTerms.get(termFQN);
|
||||||
rootTerm.setChildren(term.getChildren());
|
rootTerm.setChildren(term.getChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ import org.openmetadata.schema.api.data.CreateGlossaryTerm;
|
|||||||
import org.openmetadata.schema.api.data.CreateTable;
|
import org.openmetadata.schema.api.data.CreateTable;
|
||||||
import org.openmetadata.schema.api.data.TermReference;
|
import org.openmetadata.schema.api.data.TermReference;
|
||||||
import org.openmetadata.schema.api.feed.ResolveTask;
|
import org.openmetadata.schema.api.feed.ResolveTask;
|
||||||
import org.openmetadata.schema.entity.data.EntityHierarchy__1;
|
import org.openmetadata.schema.entity.data.EntityHierarchy;
|
||||||
import org.openmetadata.schema.entity.data.Glossary;
|
import org.openmetadata.schema.entity.data.Glossary;
|
||||||
import org.openmetadata.schema.entity.data.GlossaryTerm;
|
import org.openmetadata.schema.entity.data.GlossaryTerm;
|
||||||
import org.openmetadata.schema.entity.data.GlossaryTerm.Status;
|
import org.openmetadata.schema.entity.data.GlossaryTerm.Status;
|
||||||
@ -862,7 +862,7 @@ public class GlossaryTermResourceTest extends EntityResourceTest<GlossaryTerm, C
|
|||||||
GlossaryTerm childGlossaryTerm = createEntity(create, ADMIN_AUTH_HEADERS);
|
GlossaryTerm childGlossaryTerm = createEntity(create, ADMIN_AUTH_HEADERS);
|
||||||
String response =
|
String response =
|
||||||
getResponseFormSearchWithHierarchy("glossary_term_search_index", "*childGlossaryTerm*");
|
getResponseFormSearchWithHierarchy("glossary_term_search_index", "*childGlossaryTerm*");
|
||||||
List<EntityHierarchy__1> glossaries = JsonUtils.readObjects(response, EntityHierarchy__1.class);
|
List<EntityHierarchy> glossaries = JsonUtils.readObjects(response, EntityHierarchy.class);
|
||||||
boolean isChild =
|
boolean isChild =
|
||||||
glossaries.stream()
|
glossaries.stream()
|
||||||
.filter(glossary -> "g1".equals(glossary.getName())) // Find glossary with name "g1"
|
.filter(glossary -> "g1".equals(glossary.getName())) // Find glossary with name "g1"
|
||||||
|
@ -7,38 +7,12 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"javaType": "org.openmetadata.schema.entity.data.EntityHierarchy",
|
"javaType": "org.openmetadata.schema.entity.data.EntityHierarchy",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"EntityHierarchy": {
|
"entityHierarchyList": {
|
||||||
"type": "object",
|
"type": "array",
|
||||||
"properties": {
|
"items": {
|
||||||
"id": {
|
"$ref": "entityHierarchy.json"
|
||||||
"description": "Unique identifier of an entity hierarchy instance.",
|
|
||||||
"$ref": "../type/basic.json#/definitions/uuid"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"description": "Preferred name for the entity hierarchy.",
|
|
||||||
"$ref": "../type/basic.json#/definitions/entityName"
|
|
||||||
},
|
|
||||||
"displayName": {
|
|
||||||
"description": "Display name that identifies this hierarchy.",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"description": "Description of the entity hierarchy.",
|
|
||||||
"$ref": "../type/basic.json#/definitions/markdown"
|
|
||||||
},
|
|
||||||
"fullyQualifiedName": {
|
|
||||||
"description": "A unique name that identifies an entity within the hierarchy. It captures name hierarchy in the form of `rootEntity.childEntity`.",
|
|
||||||
"$ref": "../type/basic.json#/definitions/fullyQualifiedEntityName"
|
|
||||||
},
|
|
||||||
"children": {
|
|
||||||
"description": "Other entities that are children of this entity.",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/EntityHierarchy"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"required": ["id", "name", "description"]
|
"default": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -64,12 +38,8 @@
|
|||||||
},
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"description": "Other entities that are children of this entity.",
|
"description": "Other entities that are children of this entity.",
|
||||||
"type": "array",
|
"$ref" : "#/definitions/entityHierarchyList"
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/EntityHierarchy"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["id", "name", "description"],
|
"required": ["id", "name", "description"]
|
||||||
"additionalProperties": false
|
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* This schema defines the entity hierarchy structure.
|
* This schema defines the entity hierarchy structure.
|
||||||
*/
|
*/
|
||||||
export interface EntityHierarchy {
|
export interface EntityHierarchy {
|
||||||
@ -41,8 +39,14 @@ export interface EntityHierarchy {
|
|||||||
* Preferred name for the entity hierarchy.
|
* Preferred name for the entity hierarchy.
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
|
[property: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other entities that are children of this entity.
|
||||||
|
*
|
||||||
|
* This schema defines the entity hierarchy structure.
|
||||||
|
*/
|
||||||
export interface ChildElement {
|
export interface ChildElement {
|
||||||
/**
|
/**
|
||||||
* Other entities that are children of this entity.
|
* Other entities that are children of this entity.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user