mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-24 17:59:52 +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.DataInsightCustomChartResultList;
|
||||
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.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
||||
import org.openmetadata.schema.tests.DataQualityReport;
|
||||
@ -592,21 +592,21 @@ public class ElasticSearchClient implements SearchClient {
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<EntityHierarchy__1> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
||||
Map<String, EntityHierarchy__1> termMap =
|
||||
public List<EntityHierarchy> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
||||
Map<String, EntityHierarchy> termMap =
|
||||
new LinkedHashMap<>(); // termMap represent glossary terms
|
||||
Map<String, EntityHierarchy__1> rootTerms =
|
||||
Map<String, EntityHierarchy> rootTerms =
|
||||
new LinkedHashMap<>(); // rootTerms represent glossaries
|
||||
|
||||
for (var hit : searchResponse.getHits().getHits()) {
|
||||
String jsonSource = hit.getSourceAsString();
|
||||
|
||||
EntityHierarchy__1 term = JsonUtils.readValue(jsonSource, EntityHierarchy__1.class);
|
||||
EntityHierarchy__1 glossaryInfo =
|
||||
EntityHierarchy term = JsonUtils.readValue(jsonSource, EntityHierarchy.class);
|
||||
EntityHierarchy glossaryInfo =
|
||||
JsonUtils.readTree(jsonSource).path("glossary").isMissingNode()
|
||||
? null
|
||||
: JsonUtils.convertValue(
|
||||
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy__1.class);
|
||||
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy.class);
|
||||
|
||||
if (glossaryInfo != null) {
|
||||
rootTerms.putIfAbsent(glossaryInfo.getFullyQualifiedName(), glossaryInfo);
|
||||
@ -626,15 +626,15 @@ public class ElasticSearchClient implements SearchClient {
|
||||
String termFQN = term.getFullyQualifiedName();
|
||||
|
||||
if (parentFQN != null && termMap.containsKey(parentFQN)) {
|
||||
EntityHierarchy__1 parentTerm = termMap.get(parentFQN);
|
||||
List<EntityHierarchy__1> children = parentTerm.getChildren();
|
||||
EntityHierarchy parentTerm = termMap.get(parentFQN);
|
||||
List<EntityHierarchy> children = parentTerm.getChildren();
|
||||
children.removeIf(
|
||||
child -> child.getFullyQualifiedName().equals(term.getFullyQualifiedName()));
|
||||
children.add(term);
|
||||
parentTerm.setChildren(children);
|
||||
} else {
|
||||
if (rootTerms.containsKey(termFQN)) {
|
||||
EntityHierarchy__1 rootTerm = rootTerms.get(termFQN);
|
||||
EntityHierarchy rootTerm = rootTerms.get(termFQN);
|
||||
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.DataInsightCustomChartResultList;
|
||||
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.service.configuration.elasticsearch.ElasticSearchConfiguration;
|
||||
import org.openmetadata.schema.tests.DataQualityReport;
|
||||
@ -584,21 +584,21 @@ public class OpenSearchClient implements SearchClient {
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<EntityHierarchy__1> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
||||
Map<String, EntityHierarchy__1> termMap =
|
||||
public List<EntityHierarchy> buildGlossaryTermSearchHierarchy(SearchResponse searchResponse) {
|
||||
Map<String, EntityHierarchy> termMap =
|
||||
new LinkedHashMap<>(); // termMap represent glossary terms
|
||||
Map<String, EntityHierarchy__1> rootTerms =
|
||||
Map<String, EntityHierarchy> rootTerms =
|
||||
new LinkedHashMap<>(); // rootTerms represent glossaries
|
||||
|
||||
for (var hit : searchResponse.getHits().getHits()) {
|
||||
String jsonSource = hit.getSourceAsString();
|
||||
|
||||
EntityHierarchy__1 term = JsonUtils.readValue(jsonSource, EntityHierarchy__1.class);
|
||||
EntityHierarchy__1 glossaryInfo =
|
||||
EntityHierarchy term = JsonUtils.readValue(jsonSource, EntityHierarchy.class);
|
||||
EntityHierarchy glossaryInfo =
|
||||
JsonUtils.readTree(jsonSource).path("glossary").isMissingNode()
|
||||
? null
|
||||
: JsonUtils.convertValue(
|
||||
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy__1.class);
|
||||
JsonUtils.readTree(jsonSource).path("glossary"), EntityHierarchy.class);
|
||||
|
||||
if (glossaryInfo != null) {
|
||||
rootTerms.putIfAbsent(glossaryInfo.getFullyQualifiedName(), glossaryInfo);
|
||||
@ -618,15 +618,15 @@ public class OpenSearchClient implements SearchClient {
|
||||
String termFQN = term.getFullyQualifiedName();
|
||||
|
||||
if (parentFQN != null && termMap.containsKey(parentFQN)) {
|
||||
EntityHierarchy__1 parentTerm = termMap.get(parentFQN);
|
||||
List<EntityHierarchy__1> children = parentTerm.getChildren();
|
||||
EntityHierarchy parentTerm = termMap.get(parentFQN);
|
||||
List<EntityHierarchy> children = parentTerm.getChildren();
|
||||
children.removeIf(
|
||||
child -> child.getFullyQualifiedName().equals(term.getFullyQualifiedName()));
|
||||
children.add(term);
|
||||
parentTerm.setChildren(children);
|
||||
} else {
|
||||
if (rootTerms.containsKey(termFQN)) {
|
||||
EntityHierarchy__1 rootTerm = rootTerms.get(termFQN);
|
||||
EntityHierarchy rootTerm = rootTerms.get(termFQN);
|
||||
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.TermReference;
|
||||
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.GlossaryTerm;
|
||||
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);
|
||||
String response =
|
||||
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 =
|
||||
glossaries.stream()
|
||||
.filter(glossary -> "g1".equals(glossary.getName())) // Find glossary with name "g1"
|
||||
|
@ -7,38 +7,12 @@
|
||||
"type": "object",
|
||||
"javaType": "org.openmetadata.schema.entity.data.EntityHierarchy",
|
||||
"definitions": {
|
||||
"EntityHierarchy": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"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"
|
||||
}
|
||||
}
|
||||
"entityHierarchyList": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "entityHierarchy.json"
|
||||
},
|
||||
"required": ["id", "name", "description"]
|
||||
"default": []
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
@ -64,12 +38,8 @@
|
||||
},
|
||||
"children": {
|
||||
"description": "Other entities that are children of this entity.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/EntityHierarchy"
|
||||
}
|
||||
"$ref" : "#/definitions/entityHierarchyList"
|
||||
}
|
||||
},
|
||||
"required": ["id", "name", "description"],
|
||||
"additionalProperties": false
|
||||
"required": ["id", "name", "description"]
|
||||
}
|
||||
|
@ -10,9 +10,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* This schema defines the entity hierarchy structure.
|
||||
*/
|
||||
export interface EntityHierarchy {
|
||||
@ -41,8 +39,14 @@ export interface EntityHierarchy {
|
||||
* Preferred name for the entity hierarchy.
|
||||
*/
|
||||
name: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Other entities that are children of this entity.
|
||||
*
|
||||
* This schema defines the entity hierarchy structure.
|
||||
*/
|
||||
export interface ChildElement {
|
||||
/**
|
||||
* Other entities that are children of this entity.
|
||||
|
Loading…
x
Reference in New Issue
Block a user