Skip to content

Commit 5e0577d

Browse files
Merge pull request #8719 from mandy-chessell/oak2025
Add mermaid graphs to glossary elements
2 parents 90dfd9e + a29c682 commit 5e0577d

File tree

33 files changed

+1349
-291
lines changed

33 files changed

+1349
-291
lines changed

CloudInformationModelGUIDMap.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

content-packs/CloudInformationModel.omarchive

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/ResultsRequestBody.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class ResultsRequestBody
3030
private Date asOfTime = null;
3131
private SequencingOrder sequencingOrder = null;
3232
private String sequencingProperty = null;
33+
private TemplateFilter templateFilter = null;
34+
3335

3436
/**
3537
* Default constructor
@@ -56,6 +58,7 @@ public ResultsRequestBody(ResultsRequestBody template)
5658
asOfTime = template.getAsOfTime();
5759
sequencingOrder = template.getSequencingOrder();
5860
sequencingProperty = template.getSequencingProperty();
61+
templateFilter = template.getTemplateFilter();
5962
}
6063
}
6164

@@ -220,6 +223,28 @@ public void setSequencingOrder(SequencingOrder sequencingOrder)
220223
}
221224

222225

226+
/**
227+
* Return the setting of the template filter.
228+
*
229+
* @return TemplateFilter enum
230+
*/
231+
public TemplateFilter getTemplateFilter()
232+
{
233+
return templateFilter;
234+
}
235+
236+
237+
/**
238+
* Set up the setting of the template filter.
239+
*
240+
* @param templateFilter enum
241+
*/
242+
public void setTemplateFilter(TemplateFilter templateFilter)
243+
{
244+
this.templateFilter = templateFilter;
245+
}
246+
247+
223248
/**
224249
* JSON-style toString
225250
*
@@ -236,6 +261,7 @@ public String toString()
236261
", asOfTime=" + asOfTime +
237262
", sequencingOrder=" + sequencingOrder +
238263
", sequencingProperty='" + sequencingProperty + '\'' +
264+
", templateFilter=" + templateFilter +
239265
'}';
240266
}
241267

@@ -258,6 +284,7 @@ public boolean equals(Object objectToCompare)
258284
Objects.equals(limitResultsByStatus, that.limitResultsByStatus) &&
259285
Objects.equals(asOfTime, that.asOfTime) &&
260286
sequencingOrder == that.sequencingOrder &&
287+
templateFilter == that.templateFilter &&
261288
Objects.equals(sequencingProperty, that.sequencingProperty);
262289
}
263290

@@ -271,7 +298,7 @@ public boolean equals(Object objectToCompare)
271298
@Override
272299
public int hashCode()
273300
{
274-
return Objects.hash(forLineage, forDuplicateProcessing, effectiveTime,
301+
return Objects.hash(forLineage, forDuplicateProcessing, effectiveTime, templateFilter,
275302
limitResultsByStatus, asOfTime, sequencingOrder, sequencingProperty);
276303
}
277304
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
/* Copyright Contributors to the ODPi Egeria project. */
3+
4+
package org.odpi.openmetadata.commonservices.ffdc.rest;
5+
6+
7+
/**
8+
* Defines the options to filter out templates
9+
*/
10+
public enum TemplateFilter
11+
{
12+
/**
13+
* Ignore any element that is either classified with the Template classification, or the TemplateSubstitute
14+
* classification.
15+
*/
16+
NO_TEMPLATES,
17+
18+
/**
19+
* Only return elements that are classified with the Template classification, or the TemplateSubstitute
20+
* classification.
21+
*/
22+
ONLY_TEMPLATES,
23+
24+
/**
25+
* Return all matching elements irrespective of whether they have the Template classification, or the
26+
* TemplateSubstitute classification.
27+
*/
28+
ALL
29+
}

open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryCategoryHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ private List<B> getValidCategories(String userId,
562562

563563

564564
/**
565-
* Convert the returned glossary category entities into a list of glossary term elements.
565+
* Convert the returned glossary category entities into a list of glossary category elements.
566566
*
567567
* @param userId calling user
568568
* @param relatedCategories list of entities returned
@@ -603,7 +603,7 @@ private List<B> getRelatedGlossaryCategoryBeans(String userId,
603603

604604

605605
/**
606-
* Convert the returned glossary term entity into an element.
606+
* Convert the returned glossary category entities into an element.
607607
*
608608
* @param userId calling user
609609
* @param categoryEntities entities returned
@@ -643,7 +643,7 @@ private List<B> getGlossaryCategoryBeans(String userId,
643643

644644

645645
/**
646-
* Convert the returned glossary term entity into an element.
646+
* Convert the returned glossary category entity into an element.
647647
*
648648
* @param userId calling user
649649
* @param categoryEntity entity returned

open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryConverter.java

Lines changed: 143 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@
22
/* Copyright Contributors to the ODPi Egeria project. */
33
package org.odpi.openmetadata.commonservices.generichandlers;
44

5-
import org.odpi.openmetadata.commonservices.generichandlers.OMFConverter;
5+
import org.odpi.openmetadata.commonservices.mermaid.GlossaryMermaidGraphBuilder;
6+
import org.odpi.openmetadata.frameworks.openmetadata.ffdc.PropertyServerException;
7+
import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.ChildCategoryElement;
68
import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.GlossaryElement;
9+
import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.RelatedMetadataElementSummary;
710
import org.odpi.openmetadata.frameworks.openmetadata.properties.glossaries.GlossaryProperties;
8-
import org.odpi.openmetadata.frameworks.openmetadata.ffdc.PropertyServerException;
9-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*;
11+
import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataType;
12+
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail;
13+
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
14+
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;
1015
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory;
1116
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper;
1217

1318
import java.lang.reflect.InvocationTargetException;
19+
import java.util.ArrayList;
20+
import java.util.HashMap;
21+
import java.util.List;
22+
import java.util.Map;
1423

1524
/**
1625
* GlossaryConverter transfers the relevant properties from an Open Metadata Repository Services (OMRS)
@@ -34,19 +43,23 @@ public GlossaryConverter(OMRSRepositoryHelper repositoryHelper,
3443

3544

3645
/**
37-
* Using the supplied instances, return a new instance of the bean. This is used for beans that
38-
* contain a combination of the properties from an entity and that of a connected relationship.
46+
* Using the supplied instances, return a new instance of the bean.
3947
*
4048
* @param beanClass name of the class to create
41-
* @param entity entity containing the properties
49+
* @param primaryEntity entity that is the root of the collection of entities that make up the
50+
* content of the bean
51+
* @param relationship relationship used to access the entity
52+
* @param relatedEntities relationships linking the entities
4253
* @param methodName calling method
4354
* @return bean populated with properties from the instances supplied
4455
* @throws PropertyServerException there is a problem instantiating the bean
4556
*/
46-
@Override
47-
public B getNewBean(Class<B> beanClass,
48-
EntityDetail entity,
49-
String methodName) throws PropertyServerException
57+
public B getNewComplexBean(Class<B> beanClass,
58+
EntityDetail primaryEntity,
59+
Relationship relationship,
60+
List<RelatedEntity> relatedEntities,
61+
String methodName) throws PropertyServerException
62+
5063
{
5164
try
5265
{
@@ -57,16 +70,16 @@ public B getNewBean(Class<B> beanClass,
5770

5871
if (returnBean instanceof GlossaryElement bean)
5972
{
60-
GlossaryProperties glossaryProperties = new GlossaryProperties();
6173

62-
if (entity != null)
74+
if (primaryEntity != null)
6375
{
64-
bean.setElementHeader(this.getMetadataElementHeader(beanClass, entity, methodName));
76+
bean.setElementHeader(this.getMetadataElementHeader(beanClass, primaryEntity, methodName));
77+
GlossaryProperties glossaryProperties = new GlossaryProperties();
6578

6679
/*
6780
* The initial set of values come from the entity.
6881
*/
69-
InstanceProperties instanceProperties = new InstanceProperties(entity.getProperties());
82+
InstanceProperties instanceProperties = new InstanceProperties(primaryEntity.getProperties());
7083

7184
glossaryProperties.setQualifiedName(this.removeQualifiedName(instanceProperties));
7285
glossaryProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties));
@@ -76,6 +89,102 @@ public B getNewBean(Class<B> beanClass,
7689
glossaryProperties.setUsage(this.removeUsage(instanceProperties));
7790

7891
bean.setGlossaryProperties(glossaryProperties);
92+
93+
if (relatedEntities != null)
94+
{
95+
List<RelatedMetadataElementSummary> externalReferences = new ArrayList<>();
96+
Map<String, ChildCategoryElement> categories = new HashMap<>();
97+
List<RelatedEntity> categoryHierarchyLinks = new ArrayList<>();
98+
List<String> childCategories = new ArrayList<>();
99+
List<RelatedMetadataElementSummary> otherRelatedElements = new ArrayList<>();
100+
101+
for (RelatedEntity relatedEntity : relatedEntities)
102+
{
103+
if ((relatedEntity != null) && (relatedEntity.relationship() != null) && (relatedEntity.entityDetail() != null))
104+
{
105+
if (repositoryHelper.isTypeOf(serviceName,
106+
relatedEntity.relationship().getType().getTypeDefName(),
107+
OpenMetadataType.CATEGORY_ANCHOR_RELATIONSHIP.typeName))
108+
{
109+
ChildCategoryElement childCategoryElement = new ChildCategoryElement(super.getRelatedMetadataElementSummary(beanClass, relatedEntity, methodName));
110+
111+
categories.put(childCategoryElement.getRelatedElement().getElementHeader().getGUID(), childCategoryElement);
112+
}
113+
else if (repositoryHelper.isTypeOf(serviceName,
114+
relatedEntity.relationship().getType().getTypeDefName(),
115+
OpenMetadataType.CATEGORY_HIERARCHY_LINK_RELATIONSHIP.typeName))
116+
{
117+
categoryHierarchyLinks.add(relatedEntity);
118+
}
119+
else if (repositoryHelper.isTypeOf(serviceName,
120+
relatedEntity.relationship().getType().getTypeDefName(),
121+
OpenMetadataType.EXTERNAL_REFERENCE_LINK_RELATIONSHIP.typeName))
122+
{
123+
externalReferences.add(super.getRelatedMetadataElementSummary(beanClass, relatedEntity, methodName));
124+
}
125+
else if (! repositoryHelper.isTypeOf(serviceName,
126+
relatedEntity.relationship().getType().getTypeDefName(),
127+
OpenMetadataType.TERM_ANCHOR_RELATIONSHIP.typeName))
128+
{
129+
otherRelatedElements.add(super.getRelatedMetadataElementSummary(beanClass, relatedEntity, methodName));
130+
}
131+
}
132+
}
133+
134+
if (! categoryHierarchyLinks.isEmpty())
135+
{
136+
for (RelatedEntity relatedEntity : categoryHierarchyLinks)
137+
{
138+
ChildCategoryElement parentCategory = categories.get(relatedEntity.relationship().getEntityOneProxy().getGUID());
139+
ChildCategoryElement childCategory = categories.get(relatedEntity.relationship().getEntityTwoProxy().getGUID());
140+
141+
if ((parentCategory != null) && (childCategory != null))
142+
{
143+
List<ChildCategoryElement> currentChildCategories = parentCategory.getChildCategories();
144+
145+
if (currentChildCategories == null)
146+
{
147+
currentChildCategories = new ArrayList<>();
148+
}
149+
150+
currentChildCategories.add(childCategory);
151+
parentCategory.setChildCategories(currentChildCategories);
152+
childCategories.add(childCategory.getRelatedElement().getElementHeader().getGUID());
153+
}
154+
}
155+
}
156+
157+
if (! externalReferences.isEmpty())
158+
{
159+
bean.setExternalReferences(externalReferences);
160+
}
161+
if (! categories.isEmpty())
162+
{
163+
/*
164+
* Only need to return the top-level categories - all other
165+
* categories are nested.
166+
*/
167+
List<ChildCategoryElement> parentCategories = new ArrayList<>();
168+
169+
for (ChildCategoryElement categoryElement : categories.values())
170+
{
171+
if (! childCategories.contains(categoryElement.getRelatedElement().getElementHeader().getGUID()))
172+
{
173+
parentCategories.add(categoryElement);
174+
}
175+
}
176+
177+
bean.setCategories(parentCategories);
178+
}
179+
if (! otherRelatedElements.isEmpty())
180+
{
181+
bean.setOtherRelatedElements(otherRelatedElements);
182+
}
183+
}
184+
185+
GlossaryMermaidGraphBuilder graphBuilder = new GlossaryMermaidGraphBuilder(bean);
186+
187+
bean.setMermaidGraph(graphBuilder.getMermaidGraph());
79188
}
80189
else
81190
{
@@ -94,6 +203,25 @@ public B getNewBean(Class<B> beanClass,
94203
}
95204

96205

206+
/**
207+
* Using the supplied instances, return a new instance of the bean. This is used for beans that
208+
* contain a combination of the properties from an entity and that of a connected relationship.
209+
*
210+
* @param beanClass name of the class to create
211+
* @param entity entity containing the properties
212+
* @param methodName calling method
213+
* @return bean populated with properties from the instances supplied
214+
* @throws PropertyServerException there is a problem instantiating the bean
215+
*/
216+
@Override
217+
public B getNewBean(Class<B> beanClass,
218+
EntityDetail entity,
219+
String methodName) throws PropertyServerException
220+
{
221+
return getNewComplexBean(beanClass, entity, (Relationship) null, null, methodName);
222+
}
223+
224+
97225
/**
98226
* Using the supplied instances, return a new instance of the bean. This is used for beans that
99227
* contain a combination of the properties from an entity and that of a connected relationship.
@@ -111,6 +239,6 @@ public B getNewBean(Class<B> beanClass,
111239
Relationship relationship,
112240
String methodName) throws PropertyServerException
113241
{
114-
return getNewBean(beanClass, entity, methodName);
242+
return getNewComplexBean(beanClass, entity, relationship, null, methodName);
115243
}
116244
}

0 commit comments

Comments
 (0)