From 3dc4b69f18fdee5d086f6d5e95855c43f3064d43 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Thu, 25 Jul 2024 22:22:38 +0100 Subject: [PATCH] Add missing operations for retrieving feedback Signed-off-by: Mandy Chessell --- .../UnityCatalog-demo-cataloguing-uc.http | 22 +- .../Egeria-feedback-manager-omvs.http | 29 ++- .../handler/CollaborationManagerHandler.java | 214 +++++++++++++++++- .../rest/LikeElementsResponse.java | 148 ++++++++++++ .../rest/RatingElementsResponse.java | 148 ++++++++++++ .../server/FeedbackManagerRESTServices.java | 178 +++++++++++++++ .../spring/FeedbackManagerResource.java | 115 +++++++++- 7 files changed, 835 insertions(+), 19 deletions(-) create mode 100644 open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/LikeElementsResponse.java create mode 100644 open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/RatingElementsResponse.java diff --git a/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-cataloguing-uc.http b/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-cataloguing-uc.http index 485025c30ad..34c5f85a7b8 100644 --- a/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-cataloguing-uc.http +++ b/open-metadata-implementation/adapters/open-connectors/data-manager-connectors/unity-catalog-connectors/UnityCatalog-demo-cataloguing-uc.http @@ -68,7 +68,7 @@ Content-Type: application/json ### -@server1GUID=ea997682-a8fe-4ae9-967b-6fb0252d734f +@server1GUID=add guid here ### @@ -210,7 +210,7 @@ Content-Type: application/json ### -@ucCatalogGUID=9b8c275d-d1d7-4e42-9962-21656334b77b +@ucCatalogGUID=add guid here ### # @name getTechnologyTypeElements (schemas) @@ -225,7 +225,7 @@ Content-Type: application/json ### -@ucSchemaGUID=3d649060-ffab-4bfa-8a7b-6392cd3d99d2 +@ucSchemaGUID=add guid here ### # @name=getAssetGraph (schemas) @@ -250,7 +250,7 @@ Content-Type: application/json ### -@ucVolumeGUID=b6a46809-35ad-4324-8699-1621ea20e11c +@ucVolumeGUID=add guid here ### # @name=getAssetGraph (volumes) @@ -292,12 +292,12 @@ Authorization: Bearer {{token}} Content-Type: application/json { - "filter" : "Unity Catalog Table" + "filter" : "Unity Catalog Schema" } ### -@ucTableGUID=b20f88cb-8e5c-4ff2-bead-e193b910bc13 +@ucTableGUID=add guid here ### # @name=getAssetGraph (Tables) @@ -332,7 +332,7 @@ Content-Type: application/json ### -@server2GUID=8e9e3c2d-baf1-4250-9168-7e3941f894ff +@server2GUID=add guid here ### # @name=getAssetGraph (UC Server 2) @@ -371,7 +371,7 @@ Content-Type: application/json ### -@catalogTargetRelationshipGUID=d38ec279-d3d7-4820-8795-262f26fb22cd +@catalogTargetRelationshipGUID=add guid here ### @@ -459,7 +459,7 @@ Content-Type: application/json ### -@catalogGUID=eeb1bb8e-11fc-4946-a027-9034bb67f12d +@catalogGUID=add guid here ### # @name deleteMetadataElement @@ -482,7 +482,7 @@ Content-Type: application/json "templateGUID" : "{{ucServerTemplateGUID}}", "isOwnAnchor" : true, "placeholderPropertyValues" : { - "hostURL" : "http://egeria.pdr-associates.com", + "hostURL" : "http://localhost", "portNumber" : "7070", "serverName" : "Unity Catalog 3", "versionIdentifier" : "V1.0", @@ -517,7 +517,7 @@ Authorization: Bearer {{token}} Content-Type: application/json { - "catalogTargetName" : "uc3.1", + "catalogTargetName" : "uc3", "templateProperties" : { "Unity Catalog Catalog" : "{{ucCatalogTemplateGUID}}", "Unity Catalog Schema" : "{{ucSchemaTemplateGUID}}", diff --git a/open-metadata-implementation/view-services/feedback-manager/Egeria-feedback-manager-omvs.http b/open-metadata-implementation/view-services/feedback-manager/Egeria-feedback-manager-omvs.http index 34fca24e28a..d52db37d16c 100644 --- a/open-metadata-implementation/view-services/feedback-manager/Egeria-feedback-manager-omvs.http +++ b/open-metadata-implementation/view-services/feedback-manager/Egeria-feedback-manager-omvs.http @@ -67,8 +67,8 @@ Content-Type: application/json "elementProperties" : { "class" : "CommentProperties", "qualifiedName" : "Add unique name here", - "text" : "Add comment text here", - "commentType" : "GENERAL_COMMENT", + "commentText" : "Add comment text here", + "commentType" : "STANDARD_COMMENT", "additionalProperties" : { "propertyName 1" : "property value 1", "propertyName 2" : "property value 2" @@ -90,8 +90,8 @@ Content-Type: application/json "elementProperties" : { "class" : "CommentProperties", "qualifiedName" : "Add unique name here", - "text" : "Add comment text here", - "commentType" : "GENERAL_COMMENT", + "commentText" : "Add comment text here", + "commentType" : "STANDARD_COMMENT", "additionalProperties" : { "propertyName 1" : "property value 1", "propertyName 2" : "property value 2" @@ -209,6 +209,12 @@ POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/feedback-manager/eleme Authorization: Bearer {{token}} Content-Type: application/json +### +# @name getAttachedLikes +# Return the likes attached to an element. +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/feedback-manager/elements/{{elementGUID}}/likes/retrieve?startFrom=0&pageSize=10 +Authorization: Bearer {{token}} +Content-Type: application/json ### # ===================================================================================================================== @@ -243,6 +249,13 @@ Authorization: Bearer {{token}} Content-Type: application/json +### +# @name getAttachedRatings +# Return the ratings attached to an element. +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/feedback-manager/elements/{{elementGUID}}/ratings/retrieve?startFrom=0&pageSize=10 +Authorization: Bearer {{token}} +Content-Type: application/json + ### # ===================================================================================================================== # Informal tags are labels (with an optional description) that can be used to group elements together or mark @@ -361,6 +374,14 @@ Authorization: Bearer {{token}} Content-Type: application/json +### +# @name getAttachedTags +# Return the informal tags attached to an element. +POST {{baseURL}}/servers/{{viewServer}}/api/open-metadata/feedback-manager/elements/{{elementGUID}}/tags/retrieve?startFrom=0&pageSize=10 +Authorization: Bearer {{token}} +Content-Type: application/json + + ### # @name removeTagFromElement # Removes a link between a tag and an element that was added by this user. diff --git a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/handler/CollaborationManagerHandler.java b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/handler/CollaborationManagerHandler.java index a3c07728ff4..e8873988af9 100644 --- a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/handler/CollaborationManagerHandler.java +++ b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/handler/CollaborationManagerHandler.java @@ -17,6 +17,7 @@ import org.odpi.openmetadata.frameworks.governanceaction.search.ElementProperties; import org.odpi.openmetadata.frameworks.governanceaction.search.PropertyHelper; import org.odpi.openmetadata.frameworks.governanceaction.search.SequencingOrder; +import org.odpi.openmetadata.frameworks.openmetadata.enums.CommentType; import org.odpi.openmetadata.frameworks.openmetadata.enums.StarRating; import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataProperty; import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataType; @@ -39,6 +40,8 @@ public class CollaborationManagerHandler private final PropertyHelper propertyHelper = new PropertyHelper(); private final CommentConverter commentConverter; + private final LikeConverter likeConverter; + private final RatingConverter ratingConverter; private final InformalTagConverter tagConverter; private final NoteLogConverter noteLogConverter; private final NoteConverter noteConverter; @@ -68,6 +71,8 @@ public CollaborationManagerHandler(String localServerName, String serviceName = ViewServiceDescription.FEEDBACK_MANAGER.getViewServiceFullName(); this.commentConverter = new CommentConverter<>(propertyHelper, serviceName, localServerName); + this.likeConverter = new LikeConverter<>(propertyHelper, serviceName, localServerName); + this.ratingConverter = new RatingConverter<>(propertyHelper, serviceName, localServerName); this.tagConverter = new InformalTagConverter<>(propertyHelper, serviceName, localServerName); this.noteLogConverter = new NoteLogConverter<>(propertyHelper, serviceName, localServerName); this.noteConverter = new NoteConverter<>(propertyHelper, serviceName, localServerName); @@ -290,6 +295,75 @@ public void removeRatingFromElement(String userId, } + + /** + * Return the ratings attached to an element. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime effective time + * @return list of ratings + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem updating the element properties in the property server. + * @throws UserNotAuthorizedException the user does not have permission to perform this request. + */ + public List getAttachedRatings(String userId, + String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getAttachedRatings"; + + List relatedMetadataElements = client.getRelatedMetadataElements(userId, + elementGUID, + 1, + OpenMetadataType.ATTACHED_RATING_RELATIONSHIP.typeName, + false, + false, + effectiveTime, + startFrom, + pageSize); + return this.getRatingsFromRelatedMetadataElement(relatedMetadataElements, methodName); + } + + + /** + * Convert the GAF beans into feedback beans. + * + * @param relatedMetadataElements elements retrieved from the repository + * @param methodName calling method + * @return feedback beans + * @throws PropertyServerException error formatting bean + */ + private List getRatingsFromRelatedMetadataElement(List relatedMetadataElements, + String methodName) throws PropertyServerException + { + if (relatedMetadataElements != null) + { + List results = new ArrayList<>(); + + for (RelatedMetadataElement relatedMetadataElement : relatedMetadataElements) + { + if (relatedMetadataElement != null) + { + results.add(ratingConverter.getNewBean(RatingElement.class, + relatedMetadataElement.getElement(), + methodName)); + } + } + + return results; + } + + return null; + } + + /** * Adds a "Like" to the element. * @@ -351,6 +425,75 @@ public void removeLikeFromElement(String userId, } + /** + * Return the likes attached to an element. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime effective time + * @return list of likes + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem updating the element properties in the property server. + * @throws UserNotAuthorizedException the user does not have permission to perform this request. + */ + public List getAttachedLikes(String userId, + String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getAttachedLikes"; + + List relatedMetadataElements = client.getRelatedMetadataElements(userId, + elementGUID, + 1, + OpenMetadataType.ATTACHED_LIKE_RELATIONSHIP.typeName, + false, + false, + effectiveTime, + startFrom, + pageSize); + return this.getLikesFromRelatedMetadataElement(relatedMetadataElements, methodName); + } + + + /** + * Convert the GAF beans into feedback beans. + * + * @param relatedMetadataElements elements retrieved from the repository + * @param methodName calling method + * @return feedback beans + * @throws PropertyServerException error formatting bean + */ + private List getLikesFromRelatedMetadataElement(List relatedMetadataElements, + String methodName) throws PropertyServerException + { + if (relatedMetadataElements != null) + { + List results = new ArrayList<>(); + + for (RelatedMetadataElement relatedMetadataElement : relatedMetadataElements) + { + if (relatedMetadataElement != null) + { + results.add(likeConverter.getNewBean(LikeElement.class, + relatedMetadataElement.getElement(), + methodName)); + } + } + + return results; + } + + return null; + } + + + /** * Adds a comment to the element. * @@ -431,7 +574,7 @@ private ElementProperties getElementPropertiesForComment(CommentProperties prope { elementProperties = propertyHelper.addEnumProperty(elementProperties, OpenMetadataProperty.COMMENT_TYPE.name, - StarRating.getOpenTypeName(), + CommentType.getOpenTypeName(), properties.getCommentType().getName()); } @@ -1302,6 +1445,75 @@ public List getElementsByTag(String userId, } + + /** + * Return the informal tags attached to an element. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime effective time + * @return list of tags + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem updating the element properties in the property server. + * @throws UserNotAuthorizedException the user does not have permission to perform this request. + */ + public List getAttachedTags(String userId, + String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getAttachedTags"; + + List relatedMetadataElements = client.getRelatedMetadataElements(userId, + elementGUID, + 1, + OpenMetadataType.ATTACHED_TAG_RELATIONSHIP.typeName, + false, + false, + effectiveTime, + startFrom, + pageSize); + return this.getTagsFromRelatedMetadataElement(relatedMetadataElements, methodName); + } + + + /** + * Convert the GAF beans into feedback beans. + * + * @param relatedMetadataElements elements retrieved from the repository + * @param methodName calling method + * @return feedback beans + * @throws PropertyServerException error formatting bean + */ + private List getTagsFromRelatedMetadataElement(List relatedMetadataElements, + String methodName) throws PropertyServerException + { + if (relatedMetadataElements != null) + { + List results = new ArrayList<>(); + + for (RelatedMetadataElement relatedMetadataElement : relatedMetadataElements) + { + if (relatedMetadataElement != null) + { + results.add(tagConverter.getNewBean(InformalTagElement.class, + relatedMetadataElement.getElement(), + methodName)); + } + } + + return results; + } + + return null; + } + + /* ===================================================================================================================== * A note log maintains an ordered list of notes. It can be used to support release note, blogs and similar * broadcast information. Note logs are typically maintained by the owners/stewards of an element. diff --git a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/LikeElementsResponse.java b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/LikeElementsResponse.java new file mode 100644 index 00000000000..b10ca2ab302 --- /dev/null +++ b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/LikeElementsResponse.java @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.viewservices.feedbackmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.frameworkservices.gaf.rest.OMAGGAFAPIResponse; +import org.odpi.openmetadata.viewservices.feedbackmanager.metadataelements.LikeElement; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * LikeElementsResponse is a response object for passing back a list of elements 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 LikeElementsResponse extends OMAGGAFAPIResponse +{ + + private List elementList = null; + + + /** + * Default constructor + */ + public LikeElementsResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LikeElementsResponse(LikeElementsResponse template) + { + super(template); + + if (template != null) + { + elementList = template.getElementList(); + } + } + + + /** + * Return the list of metadata elements. + * + * @return result object + */ + public List getElementList() + { + if (elementList == null) + { + return null; + } + else if (elementList.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elementList); + } + } + + + /** + * Set up the metadata element to return. + * + * @param elementList result object + */ + public void setElementList(List elementList) + { + this.elementList = elementList; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LikeElementsResponse{" + + "elementList=" + elementList + + ", exceptionClassName='" + getExceptionClassName() + '\'' + + ", exceptionCausedBy='" + getExceptionCausedBy() + '\'' + + ", actionDescription='" + getActionDescription() + '\'' + + ", relatedHTTPCode=" + getRelatedHTTPCode() + + ", exceptionErrorMessage='" + getExceptionErrorMessage() + '\'' + + ", exceptionErrorMessageId='" + getExceptionErrorMessageId() + '\'' + + ", exceptionErrorMessageParameters=" + Arrays.toString(getExceptionErrorMessageParameters()) + + ", exceptionSystemAction='" + getExceptionSystemAction() + '\'' + + ", exceptionUserAction='" + getExceptionUserAction() + '\'' + + ", exceptionProperties=" + getExceptionProperties() + + '}'; + } + + /** + * 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; + } + LikeElementsResponse that = (LikeElementsResponse) objectToCompare; + return Objects.equals(elementList, that.elementList); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), elementList); + } +} diff --git a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/RatingElementsResponse.java b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/RatingElementsResponse.java new file mode 100644 index 00000000000..7396f008d59 --- /dev/null +++ b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/rest/RatingElementsResponse.java @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.viewservices.feedbackmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.frameworkservices.gaf.rest.OMAGGAFAPIResponse; +import org.odpi.openmetadata.viewservices.feedbackmanager.metadataelements.RatingElement; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * RatingElementsResponse is a response object for passing back a list of elements 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 RatingElementsResponse extends OMAGGAFAPIResponse +{ + + private List elementList = null; + + + /** + * Default constructor + */ + public RatingElementsResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public RatingElementsResponse(RatingElementsResponse template) + { + super(template); + + if (template != null) + { + elementList = template.getElementList(); + } + } + + + /** + * Return the list of metadata elements. + * + * @return result object + */ + public List getElementList() + { + if (elementList == null) + { + return null; + } + else if (elementList.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elementList); + } + } + + + /** + * Set up the metadata element to return. + * + * @param elementList result object + */ + public void setElementList(List elementList) + { + this.elementList = elementList; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "RatingElementsResponse{" + + "elementList=" + elementList + + ", exceptionClassName='" + getExceptionClassName() + '\'' + + ", exceptionCausedBy='" + getExceptionCausedBy() + '\'' + + ", actionDescription='" + getActionDescription() + '\'' + + ", relatedHTTPCode=" + getRelatedHTTPCode() + + ", exceptionErrorMessage='" + getExceptionErrorMessage() + '\'' + + ", exceptionErrorMessageId='" + getExceptionErrorMessageId() + '\'' + + ", exceptionErrorMessageParameters=" + Arrays.toString(getExceptionErrorMessageParameters()) + + ", exceptionSystemAction='" + getExceptionSystemAction() + '\'' + + ", exceptionUserAction='" + getExceptionUserAction() + '\'' + + ", exceptionProperties=" + getExceptionProperties() + + '}'; + } + + /** + * 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; + } + RatingElementsResponse that = (RatingElementsResponse) objectToCompare; + return Objects.equals(elementList, that.elementList); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), elementList); + } +} diff --git a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/FeedbackManagerRESTServices.java b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/FeedbackManagerRESTServices.java index ef6e72fcb59..00f72639b30 100644 --- a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/FeedbackManagerRESTServices.java +++ b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-server/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/FeedbackManagerRESTServices.java @@ -158,6 +158,65 @@ public VoidResponse removeRatingFromElement(String server } + /** + * Return the comments attached to an element. + * + * @param serverName name of the server instances for this request + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) + * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call + * @param requestBody optional effective time + * @return list of ratings or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem updating the element properties in the property server. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + public RatingElementsResponse getAttachedRatings(String serverName, + String elementGUID, + int startFrom, + int pageSize, + String viewServiceURLMarker, + String accessServiceURLMarker, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getAttachedRatings"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + RatingElementsResponse response = new RatingElementsResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + CollaborationManagerHandler handler = instanceHandler.getCollaborationManagerHandler(userId, serverName, viewServiceURLMarker, accessServiceURLMarker, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setElementList(handler.getAttachedRatings(userId, elementGUID, startFrom, pageSize, requestBody.getEffectiveTime())); + } + else + { + response.setElementList(handler.getAttachedRatings(userId, elementGUID, startFrom, pageSize, new Date())); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + /** * Adds a "LikeProperties" to the element. * @@ -276,6 +335,66 @@ public VoidResponse removeLikeFromElement(String serverNa } + + /** + * Return the likes attached to an element. + * + * @param serverName name of the server instances for this request + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) + * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call + * @param requestBody optional effective time + * @return list of likes or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem updating the element properties in the property server. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + public LikeElementsResponse getAttachedLikes(String serverName, + String elementGUID, + int startFrom, + int pageSize, + String viewServiceURLMarker, + String accessServiceURLMarker, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getAttachedLikes"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + LikeElementsResponse response = new LikeElementsResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + CollaborationManagerHandler handler = instanceHandler.getCollaborationManagerHandler(userId, serverName, viewServiceURLMarker, accessServiceURLMarker, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setElementList(handler.getAttachedLikes(userId, elementGUID, startFrom, pageSize, requestBody.getEffectiveTime())); + } + else + { + response.setElementList(handler.getAttachedLikes(userId, elementGUID, startFrom, pageSize, new Date())); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + /** * Adds a comment to the element. * @@ -1525,6 +1644,65 @@ public RelatedElementsResponse getElementsByTag(String se } + + /** + * Return the informal tags attached to an element. + * + * @param serverName name of the server instances for this request + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) + * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call + * @param requestBody optional effective time + * @return list of tags or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem updating the element properties in the property server. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + public InformalTagsResponse getAttachedTags(String serverName, + String elementGUID, + int startFrom, + int pageSize, + String viewServiceURLMarker, + String accessServiceURLMarker, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getAttachedTags"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, methodName); + + InformalTagsResponse response = new InformalTagsResponse(); + AuditLog auditLog = null; + + try + { + String userId = super.getUser(instanceHandler.getServiceName(), methodName); + + restCallLogger.setUserId(token, userId); + + CollaborationManagerHandler handler = instanceHandler.getCollaborationManagerHandler(userId, serverName, viewServiceURLMarker, accessServiceURLMarker, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setTags(handler.getAttachedTags(userId, elementGUID, startFrom, pageSize, requestBody.getEffectiveTime())); + } + else + { + response.setTags(handler.getAttachedTags(userId, elementGUID, startFrom, pageSize, new Date())); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + /* ===================================================================================================================== * A note log maintains an ordered list of notes. It can be used to support release note, blogs and similar * broadcast information. Notelogs are typically maintained by the owners/stewards of an element. diff --git a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/spring/FeedbackManagerResource.java b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/spring/FeedbackManagerResource.java index d2531f64756..aafeee33913 100644 --- a/open-metadata-implementation/view-services/feedback-manager/feedback-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/spring/FeedbackManagerResource.java +++ b/open-metadata-implementation/view-services/feedback-manager/feedback-manager-spring/src/main/java/org/odpi/openmetadata/viewservices/feedbackmanager/server/spring/FeedbackManagerResource.java @@ -632,6 +632,79 @@ public CommentResponse getComment(@PathVariable String se } + /** + * Return the ratings attached to an element. + * + * @param serverName name of the server instances for this request + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) + * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call + * @param requestBody optional effective time + * @return list of ratings or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem updating the element properties in the property server. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + @PostMapping(path = "/elements/{elementGUID}/ratings/retrieve") + + @Operation(summary="getAttachedComments", + description="Return the ratings attached to an element.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public RatingElementsResponse getAttachedRatings(@PathVariable String serverName, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestParam (required = false) + String viewServiceURLMarker, + @RequestParam (required = false, defaultValue = "asset-manager") + String accessServiceURLMarker, + @RequestBody(required = false) EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getAttachedRatings(serverName, elementGUID, startFrom, pageSize, viewServiceURLMarker, accessServiceURLMarker, requestBody); + } + + + + /** + * Return the likes attached to an element. + * + * @param serverName name of the server instances for this request + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) + * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call + * @param requestBody optional effective time + * @return list of likes or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem updating the element properties in the property server. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + @PostMapping(path = "/elements/{elementGUID}/likes/retrieve") + + @Operation(summary="getAttachedLikes", + description="Return the likes attached to an element.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public LikeElementsResponse getAttachedLikes(@PathVariable String serverName, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestParam (required = false) + String viewServiceURLMarker, + @RequestParam (required = false, defaultValue = "asset-manager") + String accessServiceURLMarker, + @RequestBody(required = false) EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getAttachedLikes(serverName, elementGUID, startFrom, pageSize, viewServiceURLMarker, accessServiceURLMarker, requestBody); + } + + /** * Return the comments attached to an element. * @@ -659,15 +732,52 @@ public CommentElementsResponse getAttachedComments(@PathVariable String @RequestParam int startFrom, @RequestParam int pageSize, @RequestParam (required = false) - String viewServiceURLMarker, + String viewServiceURLMarker, @RequestParam (required = false, defaultValue = "asset-manager") - String accessServiceURLMarker, + String accessServiceURLMarker, @RequestBody(required = false) EffectiveTimeQueryRequestBody requestBody) { return restAPI.getAttachedComments(serverName, elementGUID, startFrom, pageSize, viewServiceURLMarker, accessServiceURLMarker, requestBody); } + + /** + * Return the informal tags attached to an element. + * + * @param serverName name of the server instances for this request + * @param elementGUID unique identifier for the element that the comments are connected to (maybe a comment too). + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param viewServiceURLMarker optional view service URL marker (overrides accessServiceURLMarker) + * @param accessServiceURLMarker optional access service URL marker used to identify which back end service to call + * @param requestBody optional effective time + * @return list of informal tags or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem updating the element properties in the property server. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + @PostMapping(path = "/elements/{elementGUID}/tags/retrieve") + + @Operation(summary="getAttachedTags", + description="Return the informal tags attached to an element.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public InformalTagsResponse getAttachedTags(@PathVariable String serverName, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestParam (required = false) + String viewServiceURLMarker, + @RequestParam (required = false, defaultValue = "asset-manager") + String accessServiceURLMarker, + @RequestBody(required = false) EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getAttachedTags(serverName, elementGUID, startFrom, pageSize, viewServiceURLMarker, accessServiceURLMarker, requestBody); + } + + /** * Removes a "Like" added to the element by this user. * @@ -808,7 +918,6 @@ public VoidResponse updateComment(@PathVariable String } - /** * Update an existing comment's visibility. *