From 5a08660fbfb64df0a0ec62c365afedc5e82e79c8 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Thu, 5 Sep 2024 13:10:28 +0100 Subject: [PATCH] Add more simple queries to Classification Manager Signed-off-by: Mandy Chessell --- .../StewardshipExchangeInterface.java | 73 +++++++ .../StewardshipManagementInterface.java | 73 +++++++ .../exchange/StewardshipExchangeClient.java | 116 ++++++++++ .../StewardshipManagementClient.java | 89 ++++++++ .../rest/MetadataElementSummaryResponse.java | 124 +++++++++++ .../Egeria-classification-manager-omvs.http | 44 +++- .../ClassificationManagerRESTServices.java | 202 ++++++++++++++++++ .../spring/ClassificationManagerResource.java | 96 +++++++++ 8 files changed, 815 insertions(+), 2 deletions(-) create mode 100644 open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/MetadataElementSummaryResponse.java diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/StewardshipExchangeInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/StewardshipExchangeInterface.java index ca4fcce50d1..6b40aaba960 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/StewardshipExchangeInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/StewardshipExchangeInterface.java @@ -1160,6 +1160,79 @@ List getElementsSourceFrom(String userId, PropertyServerException; + /** + * Retrieve the metadata element using its unique identifier. + * + * @param userId calling user + * @param elementGUID unique identifier for the metadata element + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + MetadataElementSummary getMetadataElementByGUID(String userId, + String elementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + MetadataElementSummary getMetadataElementByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element unique identifier (guid) + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + String getMetadataElementGUIDByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + /** * Retrieve elements of the requested type name and/or name. * diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/management/StewardshipManagementInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/management/StewardshipManagementInterface.java index 95496ef122b..0081c62a148 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/management/StewardshipManagementInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/management/StewardshipManagementInterface.java @@ -979,6 +979,79 @@ List getElementsSourceFrom(String userId, PropertyServerException; + /** + * Retrieve the metadata element using its unique identifier. + * + * @param userId calling user + * @param elementGUID unique identifier for the metadata element + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + MetadataElementSummary getMetadataElementByGUID(String userId, + String elementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + MetadataElementSummary getMetadataElementByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element unique identifier (guid) + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + String getMetadataElementGUIDByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + /** * Retrieve elements of the requested type name and/or name. * diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/StewardshipExchangeClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/StewardshipExchangeClient.java index 73170cbdde6..e0d8fea2fdb 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/StewardshipExchangeClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/StewardshipExchangeClient.java @@ -8,6 +8,8 @@ import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.AssetElement; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GovernanceDefinitionElement; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.MetadataElementSummaryResponse; import org.odpi.openmetadata.frameworks.governanceaction.properties.OpenMetadataElement; import org.odpi.openmetadata.frameworks.governanceaction.properties.OpenMetadataRelationship; import org.odpi.openmetadata.frameworks.governanceaction.properties.RelatedMetadataElement; @@ -2066,6 +2068,120 @@ public List getElementsSourceFrom(String userId, } + + /** + * Retrieve the metadata element using its unique identifier. + * + * @param userId calling user + * @param elementGUID unique identifier for the metadata element + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + @Override + public MetadataElementSummary getMetadataElementByGUID(String userId, + String elementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getMetadataElementByGUID"; + final String elementGUIDParameterName = "elementGUID"; + + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameterName, methodName); + + OpenMetadataElement openMetadataElement = openMetadataStoreClient.getMetadataElementByGUID(userId, + elementGUID, + forLineage, + forDuplicateProcessing, + effectiveTime); + + return metadataElementSummaryConverter.getNewBean(MetadataElementSummary.class, + openMetadataElement, + methodName); + } + + + /** + * Retrieve the metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + @Override + public MetadataElementSummary getMetadataElementByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getMetadataElementByUniqueName"; + final String elementGUIDParameterName = "uniqueName"; + + invalidParameterHandler.validateName(uniqueName, elementGUIDParameterName, methodName); + + OpenMetadataElement openMetadataElement = openMetadataStoreClient.getMetadataElementByUniqueName(userId, + uniqueName, + uniquePropertyName, + forLineage, + forDuplicateProcessing, + effectiveTime); + + return metadataElementSummaryConverter.getNewBean(MetadataElementSummary.class, + openMetadataElement, + methodName); + } + + + + /** + * Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element unique identifier (guid) + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + @Override + public String getMetadataElementGUIDByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStoreClient.getMetadataElementGUIDByUniqueName(userId, uniqueName, uniquePropertyName, forLineage, forDuplicateProcessing, effectiveTime); + } + + /** * Retrieve elements of the requested type name. * diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/management/StewardshipManagementClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/management/StewardshipManagementClient.java index 4c248b6fcf2..7d31f0470b2 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/management/StewardshipManagementClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/management/StewardshipManagementClient.java @@ -9,6 +9,10 @@ import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.AssetElement; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GovernanceDefinitionElement; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallToken; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.MetadataElementSummaryResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; @@ -1385,6 +1389,91 @@ public List getElementsSourceFrom(String userId, } + /** + * Retrieve the metadata element using its unique identifier. + * + * @param userId calling user + * @param elementGUID unique identifier for the metadata element + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + @Override + public MetadataElementSummary getMetadataElementByGUID(String userId, + String elementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return client.getMetadataElementByGUID(userId, elementGUID, forLineage, forDuplicateProcessing, effectiveTime); + } + + + /** + * Retrieve the metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + @Override + public MetadataElementSummary getMetadataElementByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return client.getMetadataElementByUniqueName(userId, uniqueName, uniquePropertyName, forLineage, forDuplicateProcessing, effectiveTime); + } + + + /** + * Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). + * + * @param userId calling user + * @param uniqueName unique name for the metadata element + * @param uniquePropertyName name of property name to test in the open metadata element - if null "qualifiedName" is used + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element unique identifier (guid) + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + @Override + public String getMetadataElementGUIDByUniqueName(String userId, + String uniqueName, + String uniquePropertyName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return client.getMetadataElementGUIDByUniqueName(userId, uniqueName, uniquePropertyName, forLineage, forDuplicateProcessing, effectiveTime); + } + + /** * Retrieve elements of the requested type name. * diff --git a/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/MetadataElementSummaryResponse.java b/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/MetadataElementSummaryResponse.java new file mode 100644 index 00000000000..417f56d5fa9 --- /dev/null +++ b/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/MetadataElementSummaryResponse.java @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.commonservices.ffdc.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.MetadataElementSummary; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * MetadataElementSummaryResponse is a response object for passing back a single + * element or an exception if the request failed. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class MetadataElementSummaryResponse extends FFDCResponseBase +{ + private MetadataElementSummary element = null; + + + /** + * Default constructor + */ + public MetadataElementSummaryResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public MetadataElementSummaryResponse(MetadataElementSummaryResponse template) + { + super(template); + + if (template != null) + { + element = template.getElement(); + } + } + + + /** + * Return the metadata element. + * + * @return result object + */ + public MetadataElementSummary getElement() + { + return element; + } + + + /** + * Set up the metadata element to return. + * + * @param element result object + */ + public void setElement(MetadataElementSummary element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "MetadataElementSummaryResponse{" + + "element=" + element + + "} " + super.toString(); + } + + + /** + * Return comparison result based on the content of the properties. + * + * @param objectToCompare test object + * @return result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (objectToCompare == null || getClass() != objectToCompare.getClass()) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + MetadataElementSummaryResponse that = (MetadataElementSummaryResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), element); + } +} diff --git a/open-metadata-implementation/view-services/classification-manager/Egeria-classification-manager-omvs.http b/open-metadata-implementation/view-services/classification-manager/Egeria-classification-manager-omvs.http index bb653d06a7e..ce325122487 100644 --- a/open-metadata-implementation/view-services/classification-manager/Egeria-classification-manager-omvs.http +++ b/open-metadata-implementation/view-services/classification-manager/Egeria-classification-manager-omvs.http @@ -20,7 +20,7 @@ Content-Type: application/json ### -@elementGUID=b359e297-a565-414a-8213-fa423312ab36 +@elementGUID=add guid here ### # ===================================================================================================================== @@ -415,6 +415,47 @@ Content-Type: application/json # They are optional and have a default value of "{{$isoTimestamp}}", false and false respectively. # The paging request parameters "startFrom" and "pageSize" are also optional and have default values of 0, # which attempts to retrieve as much as is available upto the maximum allowed by the server. +### +# @name getMetadataElementByGUID +# Retrieve the metadata element using its unique identifier. +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/classification-manager/elements/{{elementGUID}} +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "EffectiveTimeQueryRequestBody", + "effectiveTime" : "{{$isoTimestamp}}" +} + +### +# @name getMetadataElementByUniqueName +# Retrieve the metadata element using its unique name (typically the qualified name). +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/classification-manager/elements/by-unique-name +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "NameRequestBody", + "name" : "Add name here", + "namePropertyName" : "qualifiedName", + "effectiveTime" : "{{$isoTimestamp}}" +} + + +### +# @name getMetadataElementGUIDByUniqueName +# Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/classification-manager/elements/guid-by-unique-name +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "NameRequestBody", + "name" : "Add name here", + "namePropertyName" : "qualifiedName", + "effectiveTime" : "{{$isoTimestamp}}" +} + ### # @name getElements @@ -433,7 +474,6 @@ Content-Type: application/json } - ### # @name getElementsByPropertyValue # Retrieve elements by a value found in one of the properties specified. The value must match exactly. diff --git a/open-metadata-implementation/view-services/classification-manager/classification-manager-server/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/ClassificationManagerRESTServices.java b/open-metadata-implementation/view-services/classification-manager/classification-manager-server/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/ClassificationManagerRESTServices.java index 28205199419..39fa2f451dd 100644 --- a/open-metadata-implementation/view-services/classification-manager/classification-manager-server/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/ClassificationManagerRESTServices.java +++ b/open-metadata-implementation/view-services/classification-manager/classification-manager-server/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/ClassificationManagerRESTServices.java @@ -13,12 +13,16 @@ import org.odpi.openmetadata.frameworks.openmetadata.properties.FindPropertyNamesProperties; import org.odpi.openmetadata.frameworks.openmetadata.properties.governance.*; import org.odpi.openmetadata.frameworks.openmetadata.properties.security.SecurityTagsProperties; +import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataProperty; +import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataType; import org.odpi.openmetadata.tokencontroller.TokenController; import org.odpi.openmetadata.viewservices.classificationmanager.rest.ClassificationRequestBody; import org.odpi.openmetadata.viewservices.classificationmanager.rest.EffectiveTimeQueryRequestBody; import org.odpi.openmetadata.viewservices.classificationmanager.rest.RelationshipRequestBody; import org.slf4j.LoggerFactory; +import java.util.Date; + /** * The ClassificationManagerRESTServices provides the implementation of the Classification ManagerOpen Metadata View Service (OMVS). @@ -1243,6 +1247,204 @@ public VoidResponse removeGovernanceDefinitionFromElement(String } + /** + * Retrieve the metadata element using its unique identifier. + * + * @param serverName name of server instance to route request to + * @param elementGUID unique identifier for the metadata element + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param requestBody only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties or + * InvalidParameterException the unique identifier is null or not known. + * UserNotAuthorizedException the governance action service is not able to access the element + * PropertyServerException there is a problem accessing the metadata store + */ + public MetadataElementSummaryResponse getMetadataElementByGUID(String serverName, + String elementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getMetadataElementByGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + MetadataElementSummaryResponse response = new MetadataElementSummaryResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + StewardshipManagementClient handler = instanceHandler.getStewardshipManagementClient(userId, serverName, methodName); + + if (requestBody == null) + { + response.setElement(handler.getMetadataElementByGUID(userId, + elementGUID, + forLineage, + forDuplicateProcessing, + new Date())); + } + else + { + response.setElement(handler.getMetadataElementByGUID(userId, + elementGUID, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime())); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the metadata element using its unique name (typically the qualified name). + * + * @param serverName name of server instance to route request to + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param requestBody unique name for the metadata element + * + * @return metadata element properties or + * InvalidParameterException the unique identifier is null or not known. + * UserNotAuthorizedException the governance action service is not able to access the element + * PropertyServerException there is a problem accessing the metadata store + */ + public MetadataElementSummaryResponse getMetadataElementByUniqueName(String serverName, + boolean forLineage, + boolean forDuplicateProcessing, + NameRequestBody requestBody) + { + final String methodName = "getMetadataElementByUniqueName"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + MetadataElementSummaryResponse response = new MetadataElementSummaryResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + StewardshipManagementClient handler = instanceHandler.getStewardshipManagementClient(userId, serverName, methodName); + + if (requestBody == null) + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + else if (requestBody.getNamePropertyName() == null) + { + response.setElement(handler.getMetadataElementByUniqueName(userId, + requestBody.getName(), + OpenMetadataProperty.QUALIFIED_NAME.name, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime())); + } + else + { + response.setElement(handler.getMetadataElementByUniqueName(userId, + requestBody.getName(), + requestBody.getNamePropertyName(), + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime())); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). + * + * @param serverName name of server instance to route request to + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param requestBody unique name for the metadata element + * + * @return metadata element unique identifier (guid) or + * InvalidParameterException the unique identifier is null or not known or + * UserNotAuthorizedException the governance action service is not able to access the element or + * PropertyServerException there is a problem accessing the metadata store + */ + public GUIDResponse getMetadataElementGUIDByUniqueName(String serverName, + boolean forLineage, + boolean forDuplicateProcessing, + NameRequestBody requestBody) + { + final String methodName = "getMetadataElementGUIDByUniqueName"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + StewardshipManagementClient handler = instanceHandler.getStewardshipManagementClient(userId, serverName, methodName); + + if (requestBody == null) + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + else if (requestBody.getNamePropertyName() == null) + { + response.setGUID(handler.getMetadataElementGUIDByUniqueName(userId, + requestBody.getName(), + OpenMetadataProperty.QUALIFIED_NAME.name, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime())); + } + else + { + response.setGUID(handler.getMetadataElementGUIDByUniqueName(userId, + requestBody.getName(), + requestBody.getNamePropertyName(), + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime())); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** * Retrieve elements of the requested type name. * diff --git a/open-metadata-implementation/view-services/classification-manager/classification-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/spring/ClassificationManagerResource.java b/open-metadata-implementation/view-services/classification-manager/classification-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/spring/ClassificationManagerResource.java index b0ef025a9f4..29da1ec223a 100644 --- a/open-metadata-implementation/view-services/classification-manager/classification-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/spring/ClassificationManagerResource.java +++ b/open-metadata-implementation/view-services/classification-manager/classification-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/classificationmanager/server/spring/ClassificationManagerResource.java @@ -681,6 +681,102 @@ public VoidResponse removeGovernanceDefinitionFromElement(@PathVariable String } + /** + * Retrieve the metadata element using its unique identifier. + * + * @param serverName name of server instance to route request to + * @param elementGUID unique identifier for the metadata element + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param requestBody only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now. + * + * @return metadata element properties or + * InvalidParameterException the unique identifier is null or not known. + * UserNotAuthorizedException the governance action service is not able to access the element + * PropertyServerException there is a problem accessing the metadata store + */ + @PostMapping(path = "/elements/{elementGUID}") + + @Operation(summary="getMetadataElementByGUID", + description="Retrieve the metadata element using its unique identifier.", + externalDocs=@ExternalDocumentation(description="Further Information", + url="https://egeria-project.org/services/gaf-metadata-management/")) + + public MetadataElementSummaryResponse getMetadataElementByGUID(@PathVariable String serverName, + @PathVariable String elementGUID, + @RequestParam (required = false, defaultValue = "false") + boolean forLineage, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getMetadataElementByGUID(serverName, elementGUID, forLineage, forDuplicateProcessing, requestBody); + } + + + /** + * Retrieve the metadata element using its unique name (typically the qualified name). + * + * @param serverName name of server instance to route request to + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param requestBody unique name for the metadata element + * + * @return metadata element properties or + * InvalidParameterException the unique identifier is null or not known. + * UserNotAuthorizedException the governance action service is not able to access the element + * PropertyServerException there is a problem accessing the metadata store + */ + @PostMapping(path = "/elements/by-unique-name") + + @Operation(summary="getMetadataElementByUniqueName", + description="Retrieve the metadata element using its unique name (typically the qualified name, but it is possible to specify a different property name in the request body as long as it is unique). If multiple matching instances are found, and exception is thrown.", + externalDocs=@ExternalDocumentation(description="Further Information", + url="https://egeria-project.org/services/gaf-metadata-management/")) + + public MetadataElementSummaryResponse getMetadataElementByUniqueName(@PathVariable String serverName, + @RequestParam (required = false, defaultValue = "false") + boolean forLineage, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, + @RequestBody (required = false) NameRequestBody requestBody) + { + return restAPI.getMetadataElementByUniqueName(serverName, forLineage, forDuplicateProcessing, requestBody); + } + + + /** + * Retrieve the unique identifier of a metadata element using its unique name (typically the qualified name). + * + * @param serverName name of server instance to route request to + * @param forLineage the retrieved element is for lineage processing so include archived elements + * @param forDuplicateProcessing the retrieved element is for duplicate processing so do not combine results from known duplicates. + * @param requestBody unique name for the metadata element + * + * @return metadata element unique identifier (guid) or + * InvalidParameterException the unique identifier is null or not known or + * UserNotAuthorizedException the governance action service is not able to access the element or + * PropertyServerException there is a problem accessing the metadata store + */ + @PostMapping(path = "/elements/guid-by-unique-name") + + @Operation(summary="getMetadataElementGUIDByUniqueName", + description="Retrieve the metadata element GUID using its unique name (typically the qualified name, but it is possible to specify a different property name in the request body as long as it is unique). If multiple matching instances are found, and exception is thrown.", + externalDocs=@ExternalDocumentation(description="Further Information", + url="https://egeria-project.org/services/gaf-metadata-management/")) + + public GUIDResponse getMetadataElementGUIDByUniqueName(@PathVariable String serverName, + @RequestParam (required = false, defaultValue = "false") + boolean forLineage, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, + @RequestBody (required = false) NameRequestBody requestBody) + { + return restAPI.getMetadataElementGUIDByUniqueName(serverName, forLineage, forDuplicateProcessing, requestBody); + } + + /** * Retrieve elements of the requested type name. *