From 4a05bcd598bfeb0f273501f990e23f5d640b9964 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Tue, 3 Dec 2024 21:03:35 +0000 Subject: [PATCH] Fix relationship queries Signed-off-by: Mandy Chessell --- .../repositoryconnector/database/DatabaseStore.java | 4 ++-- .../repositoryconnector/database/QueryBuilder.java | 9 +++++---- .../registration/ViewServiceDescription.java | 2 +- .../OpenMetadataAPIGenericHandler.java | 2 +- .../gaf/server/OpenMetadataStoreRESTServices.java | 2 +- .../Egeria-metadata-explorer-omvs.http | 13 +++++++++++++ .../server/spring/MetadataExplorerResource.java | 7 ++++++- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/DatabaseStore.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/DatabaseStore.java index 1804d7e955..5ed3a713c0 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/DatabaseStore.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/DatabaseStore.java @@ -449,7 +449,7 @@ public List retrieveRelationships(QueryBuilder queryBuilder, public List retrieveRelationshipsByProperties(QueryBuilder queryBuilder, Date asOfTime) throws RepositoryErrorException { - final String methodName = "retrieveRelationships"; + final String methodName = "retrieveRelationshipsByProperties"; String sqlQuery = queryBuilder.getPropertyJoinQuery(RepositoryTable.RELATIONSHIP.getTableName(), RepositoryTable.RELATIONSHIP_ATTRIBUTE_VALUE.getTableName(), @@ -1159,7 +1159,7 @@ private String getAsOfTimeClause(Date asOfTime) } else { - return " and (" + RepositoryColumn.VERSION_START_TIME.getColumnName() + " < '" + asOfTime + "' and (" + RepositoryColumn.VERSION_END_TIME.getColumnName() + " is null or " + RepositoryColumn.VERSION_END_TIME.getColumnName() + " > '" + asOfTime + "'))"; + return " and (" + RepositoryColumn.VERSION_START_TIME.getColumnName() + " <= '" + asOfTime + "' and (" + RepositoryColumn.VERSION_END_TIME.getColumnName() + " is null or " + RepositoryColumn.VERSION_END_TIME.getColumnName() + " > '" + asOfTime + "'))"; } } diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/QueryBuilder.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/QueryBuilder.java index b7b53d6712..effb078367 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/QueryBuilder.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/postgres-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/postgres/repositoryconnector/database/QueryBuilder.java @@ -591,9 +591,9 @@ private String getSearchPropertiesClause() throws RepositoryErrorException { if (searchProperties != null) { - return this.getPropertyComparisonFromPropertyConditions(searchProperties, - propertyTableName, - null); + return " and " + this.getPropertyComparisonFromPropertyConditions(searchProperties, + propertyTableName, + null); } return " "; @@ -621,7 +621,7 @@ private String getPropertyComparisonFromPropertyConditions(SearchProperties sear matchOperand = " or "; } - StringBuilder stringBuilder = new StringBuilder(" and ("); + StringBuilder stringBuilder = new StringBuilder("("); boolean firstProperty = true; for (PropertyCondition propertyCondition : searchProperties.getConditions()) @@ -759,6 +759,7 @@ else if (matchClassifications.getMatchCriteria() == MatchCriteria.NONE) if (classificationCondition.getMatchProperties() != null) { + stringBuilder.append(" and "); stringBuilder.append(this.getPropertyComparisonFromPropertyConditions(classificationCondition.getMatchProperties(), RepositoryTable.CLASSIFICATION_ATTRIBUTE_VALUE.getTableName(), null)); diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/ViewServiceDescription.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/ViewServiceDescription.java index 94a3bedd9c..fc37230f76 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/ViewServiceDescription.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/ViewServiceDescription.java @@ -152,7 +152,7 @@ public enum ViewServiceDescription "feedback-manager", "Work with note logs, comments, informal tags, ratings/reviews and likes.", "https://egeria-project.org/services/omvs/feedback-manager/overview/", - CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName()), + AccessServiceDescription.ASSET_CONSUMER_OMAS.getAccessServiceFullName()), /** * Maintain definitions of governance actions such as governance action processes and governance action types. diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java index 4ecb4597cb..6a5d42d9bc 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java @@ -5724,7 +5724,7 @@ public List findAttachmentLinks(String userId, sequencingOrder, forDuplicateProcessing, startingFrom, - pageSize, + queryPageSize, effectiveTime, methodName); diff --git a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenMetadataStoreRESTServices.java b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenMetadataStoreRESTServices.java index 45d0d6b84a..f2d6b52b7a 100644 --- a/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenMetadataStoreRESTServices.java +++ b/open-metadata-implementation/framework-services/gaf-metadata-management/gaf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/gaf/server/OpenMetadataStoreRESTServices.java @@ -2025,7 +2025,7 @@ public OpenMetadataRelationshipListResponse getRelationshipHistory(String boolean oldestFirst, HistoryRequestBody requestBody) { - final String methodName = "getMetadataElementHistory"; + final String methodName = "getRelationshipHistory"; final String guidParameterName = "relationshipGUID"; RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); diff --git a/open-metadata-implementation/view-server-generic-services/metadata-explorer/Egeria-metadata-explorer-omvs.http b/open-metadata-implementation/view-server-generic-services/metadata-explorer/Egeria-metadata-explorer-omvs.http index 1e62495392..c20086a524 100644 --- a/open-metadata-implementation/view-server-generic-services/metadata-explorer/Egeria-metadata-explorer-omvs.http +++ b/open-metadata-implementation/view-server-generic-services/metadata-explorer/Egeria-metadata-explorer-omvs.http @@ -97,6 +97,19 @@ Content-Type: application/json } +### +# @name getAnchoredElementsGraph +# Retrieve the metadata element using its unique identifier. +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/metadata-explorer/metadata-elements/{{elementGUID}}/with-anchored-elements +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "class" : "AnyTimeRequestBody", + "effectiveTime" : "{{$isoTimestamp}}" +} + + ### # @name getMetadataElementByUniqueName # Retrieve the metadata element using its unique name (typically the *qualifiedName* attribute but other attributes can be used if they are unique - such as *pathName* for a file). diff --git a/open-metadata-implementation/view-server-generic-services/metadata-explorer/metadata-explorer-spring/src/main/java/org/odpi/openmetadata/viewservices/metadataexplorer/server/spring/MetadataExplorerResource.java b/open-metadata-implementation/view-server-generic-services/metadata-explorer/metadata-explorer-spring/src/main/java/org/odpi/openmetadata/viewservices/metadataexplorer/server/spring/MetadataExplorerResource.java index 3ca42c6f98..73e8a3ca54 100644 --- a/open-metadata-implementation/view-server-generic-services/metadata-explorer/metadata-explorer-spring/src/main/java/org/odpi/openmetadata/viewservices/metadataexplorer/server/spring/MetadataExplorerResource.java +++ b/open-metadata-implementation/view-server-generic-services/metadata-explorer/metadata-explorer-spring/src/main/java/org/odpi/openmetadata/viewservices/metadataexplorer/server/spring/MetadataExplorerResource.java @@ -385,7 +385,7 @@ public OpenMetadataRelationshipListResponse getAllMetadataElementRelationships(@ /** - * Return all the elements that are anchored to an asset plus relationships between these elements and to other elements. + * Return all the elements that are anchored to an element plus relationships between these elements and to other elements. * * @param serverName name of the server instances for this request * @param urlMarker the identifier of the view service (for example runtime-manager for the Runtime Manager OMVS) @@ -403,6 +403,11 @@ public OpenMetadataRelationshipListResponse getAllMetadataElementRelationships(@ */ @PostMapping(path = "/metadata-elements/{elementGUID}/with-anchored-elements") + @Operation(summary="getAnchoredElementsGraph", + description="Return all the elements that are anchored to an element plus relationships between these elements and to other elements.", + externalDocs=@ExternalDocumentation(description="Further Information", + url="https://egeria-project.org/services/omvs/metadata-explorer/overview/")) + public OpenMetadataGraphResponse getAnchoredElementsGraph(@PathVariable String serverName, @PathVariable String urlMarker, @PathVariable String elementGUID,