From 205478b7ca951aa62b347ba0bf8d20373e8444fe Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Thu, 30 Mar 2023 14:12:35 +0400 Subject: [PATCH] Security, undo, archive and getEntityVersions for glossary elements Signed-off-by: Mandy Chessell --- .../assetconsumer/elements/TaggedElement.java | 4 +- .../properties/InformalTagProperties.java | 4 +- .../assetconsumer/client/AssetConsumer.java | 24 +- .../user/update-tag-description-with-rest.md | 4 +- .../server/AssetConsumerRESTServices.java | 49 +- .../api/CollaborationExchangeInterface.java | 436 +++++ .../api/GlossaryExchangeInterface.java | 152 +- .../api/StewardshipExchangeInterface.java | 37 + .../metadataelements/CommentElement.java | 222 +++ .../FeedbackTargetElement.java | 187 ++ .../metadataelements/GlossaryElement.java | 4 +- .../metadataelements/GlossaryTermElement.java | 4 +- .../metadataelements/InformalTagElement.java | 221 +++ .../metadataelements/LikeElement.java | 221 +++ .../metadataelements/NoteElement.java | 221 +++ .../metadataelements/NoteLogElement.java | 221 +++ .../metadataelements/RatingElement.java | 221 +++ .../properties/ArchiveProperties.java | 190 ++ .../properties/CommentProperties.java | 220 +++ .../assetmanager/properties/CommentType.java | 136 ++ .../properties/FeedbackProperties.java | 123 ++ .../properties/GlossaryTermProperties.java | 4 +- .../properties/InformalTagProperties.java | 214 +++ .../properties/LikeProperties.java | 147 ++ .../properties/NoteLogProperties.java | 165 ++ .../properties/NoteProperties.java | 197 +++ .../properties/RatingProperties.java | 187 ++ .../properties/SecurityTagsProperties.java | 206 +++ .../assetmanager/properties/StarRating.java | 136 ++ .../properties/TagProperties.java | 195 +++ .../assetmanager/rest/ArchiveRequestBody.java | 131 ++ .../rest/CommentElementResponse.java | 140 ++ .../rest/CommentElementsResponse.java | 150 ++ .../rest/ConnectionRequestBody.java | 4 +- .../ControlledGlossaryTermRequestBody.java | 4 +- .../rest/EffectiveTimeQueryRequestBody.java | 4 +- .../rest/GlossaryCategoryRequestBody.java | 4 +- .../rest/GlossaryElementsResponse.java | 6 +- .../rest/GlossaryNameRequestBody.java | 160 ++ .../rest/GlossaryRequestBody.java | 4 +- .../rest/GlossarySearchStringRequestBody.java | 160 ++ .../rest/GlossaryTermElementsResponse.java | 4 +- .../rest/GlossaryTermStatusRequestBody.java | 4 +- .../assetmanager/rest/HistoryRequestBody.java | 154 ++ .../rest/InformalTagResponse.java | 145 ++ .../rest/InformalTagUpdateRequestBody.java | 132 ++ .../rest/InformalTagsResponse.java | 159 ++ .../rest/LikeElementResponse.java | 140 ++ .../rest/LikeElementsResponse.java | 150 ++ .../assetmanager/rest/NameRequestBody.java | 4 +- .../rest/NoteElementResponse.java | 140 ++ .../rest/NoteElementsResponse.java | 150 ++ .../rest/NoteLogElementResponse.java | 140 ++ .../rest/NoteLogElementsResponse.java | 150 ++ .../rest/RatingElementResponse.java | 140 ++ .../rest/RatingElementsResponse.java | 150 ++ .../rest/SchemaTypeElementResponse.java | 7 +- .../rest/SchemaTypeElementsResponse.java | 7 +- .../rest/SearchStringRequestBody.java | 6 +- .../TaxonomyClassificationRequestBody.java | 4 +- .../rest/TemplateRequestBody.java | 4 +- .../rest/TermRelationshipRequestBody.java | 4 +- .../assetmanager/rest/UpdateRequestBody.java | 4 +- .../client/CollaborationExchangeClient.java | 901 +++++++++- .../client/ExchangeClientBase.java | 3 + .../client/GlossaryExchangeClient.java | 507 ++++-- .../client/StewardshipExchangeClient.java | 59 + .../client/rest/AssetManagerRESTClient.java | 371 +++- .../converters/CommentConverter.java | 231 +++ .../converters/InformalTagConverter.java | 134 ++ .../converters/LikeConverter.java | 132 ++ .../converters/NoteConverter.java | 142 ++ .../converters/NoteLogConverter.java | 141 ++ .../converters/RatingConverter.java | 221 +++ .../handlers/GlossaryExchangeHandler.java | 330 +++- .../AssetManagerOMRSTopicListener.java | 3 + .../server/AssetManagerInstanceHandler.java | 131 +- .../server/AssetManagerServicesInstance.java | 123 +- .../CollaborationExchangeRESTServices.java | 1321 ++++++++++++++ .../server/GlossaryExchangeRESTServices.java | 300 +++- .../StewardshipExchangeRESTServices.java | 150 ++ .../spring/CollaborationExchangeResource.java | 670 +++++++ .../spring/GlossaryExchangeResource.java | 219 ++- .../spring/StewardshipExchangeResource.java | 88 + .../api/AssetClassificationInterface.java | 16 +- .../rest/SecurityTagsRequestBody.java | 58 +- .../assetowner/client/AssetOwner.java | 17 +- .../server/AssetOwnerRESTServices.java | 2 + .../properties/ArchiveProperties.java | 4 +- .../ffdc/rest/GUIDResponse.java | 4 +- .../GlossaryCategoryHandler.java | 219 ++- .../generichandlers/GlossaryTermHandler.java | 355 +++- .../OpenMetadataAPIGenericHandler.java | 438 ++++- .../OpenMetadataAPIMapper.java | 1 + .../generichandlers/ReferenceableBuilder.java | 25 +- .../generichandlers/ReferenceableHandler.java | 30 +- .../OpenMetadataGlossarySecurity.java | 2 +- .../metadatasecurity/properties/Asset.java | 70 +- .../metadatasecurity/properties/Glossary.java | 17 +- .../properties/Referenceable.java | 138 +- .../OpenMetadataServerSecurityConnector.java | 83 +- .../ffdc/OpenMetadataSecurityAuditCode.java | 15 + .../ffdc/OpenMetadataSecurityErrorCode.java | 43 +- .../OpenMetadataServerSecurityVerifier.java | 629 ++++++- .../RepositoryFindEntitiesIterator.java | 14 +- .../repositoryhandler/RepositoryHandler.java | 169 +- .../RepositorySelectedEntitiesIterator.java | 4 +- .../converters/package-info.java | 13 - .../converters/CommentConverter.java | 2 +- .../converters/RatingConverter.java | 2 +- .../beans/ElementControlHeader.java | 4 +- .../properties/beans/ElementHeader.java | 4 +- .../properties/beans/ElementType.java | 2 + .../properties/beans/ElementVersions.java | 4 +- .../connectors/properties/beans/Note.java | 4 +- .../connector/GlossaryExchangeService.java | 435 ++++- .../search/PropertyComparisonOperator.java | 6 +- .../properties/search/PropertyCondition.java | 4 +- .../properties/search/SearchProperties.java | 4 +- .../OMRSRepositoryPropertiesHelper.java | 51 + .../OMRSRepositoryPropertiesUtilities.java | 186 +- .../EnterpriseOMRSMetadataCollection.java | 115 +- .../accumulators/EntitiesAccumulator.java | 6 +- .../EntityHistoryAccumulator.java | 334 ++++ .../accumulators/QueryAccumulatorBase.java | 15 +- .../GetEntityDetailHistoryExecutor.java | 250 +++ .../PageableEntityRepositoryExecutorBase.java | 4 +- .../opentypes/OpenMetadataTypesArchive.java | 1364 ++------------- .../OpenMetadataTypesArchive4_0.java | 1547 +++++++++++++++++ .../CocoPharmaServerSecurityConnector.java | 184 +- .../fvt/glossaries/CreateGlossaryTest.java | 6 +- 131 files changed, 17991 insertions(+), 2002 deletions(-) create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/CommentElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/FeedbackTargetElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/InformalTagElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/LikeElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteLogElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/RatingElement.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ArchiveProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentType.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/FeedbackProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/InformalTagProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/LikeProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteLogProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RatingProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/SecurityTagsProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/StarRating.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/TagProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ArchiveRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementsResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryNameRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossarySearchStringRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/HistoryRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagUpdateRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagsResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementsResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementsResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementsResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementsResponse.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/CommentConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/InformalTagConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/LikeConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteLogConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/RatingConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/CollaborationExchangeRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/StewardshipExchangeRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/CollaborationExchangeResource.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/StewardshipExchangeResource.java delete mode 100644 open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/converters/package-info.java create mode 100644 open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityHistoryAccumulator.java create mode 100644 open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailHistoryExecutor.java create mode 100644 open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive4_0.java diff --git a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/elements/TaggedElement.java b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/elements/TaggedElement.java index 5089e5d7cfc..25ec16b368a 100644 --- a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/elements/TaggedElement.java +++ b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/elements/TaggedElement.java @@ -9,6 +9,7 @@ import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementStub; +import java.io.Serial; import java.io.Serializable; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -23,7 +24,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class TaggedElement implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private ElementHeader relationshipHeader = null; private ElementStub relatedElement = null; diff --git a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/properties/InformalTagProperties.java b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/properties/InformalTagProperties.java index 7c1c71080a0..f464f0706d9 100644 --- a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/properties/InformalTagProperties.java +++ b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-api/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/properties/InformalTagProperties.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -31,7 +32,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class InformalTagProperties implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private boolean isPrivateTag = false; private String name = null; diff --git a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-client/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/client/AssetConsumer.java b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-client/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/client/AssetConsumer.java index 67f72216a79..4d9d758f74a 100644 --- a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-client/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/client/AssetConsumer.java +++ b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-client/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/client/AssetConsumer.java @@ -2,23 +2,37 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.accessservices.assetconsumer.client; -import org.odpi.openmetadata.accessservices.assetconsumer.api.*; +import org.odpi.openmetadata.accessservices.assetconsumer.api.AssetConsumerAssetInterface; +import org.odpi.openmetadata.accessservices.assetconsumer.api.AssetConsumerFeedbackInterface; +import org.odpi.openmetadata.accessservices.assetconsumer.api.AssetConsumerGlossaryInterface; +import org.odpi.openmetadata.accessservices.assetconsumer.api.AssetConsumerLoggingInterface; +import org.odpi.openmetadata.accessservices.assetconsumer.api.AssetConsumerTaggingInterface; import org.odpi.openmetadata.accessservices.assetconsumer.client.rest.AssetConsumerRESTClient; import org.odpi.openmetadata.accessservices.assetconsumer.elements.InformalTagElement; import org.odpi.openmetadata.accessservices.assetconsumer.elements.MeaningElement; -import org.odpi.openmetadata.accessservices.assetconsumer.properties.*; -import org.odpi.openmetadata.accessservices.assetconsumer.rest.*; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.CommentRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.FeedbackRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.GlossaryTermListResponse; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.GlossaryTermResponse; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.LogRecordRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.RatingRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagResponse; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagUpdateRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagsResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDListResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; -import org.odpi.openmetadata.frameworkservices.ocf.metadatamanagement.client.ConnectedAssetClientBase; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; -import org.odpi.openmetadata.frameworks.connectors.ffdc.*; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.frameworks.connectors.properties.AssetUniverse; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Asset; import org.odpi.openmetadata.frameworks.connectors.properties.beans.CommentType; import org.odpi.openmetadata.frameworks.connectors.properties.beans.StarRating; +import org.odpi.openmetadata.frameworkservices.ocf.metadatamanagement.client.ConnectedAssetClientBase; import java.util.ArrayList; import java.util.List; diff --git a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/docs/user/update-tag-description-with-rest.md b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/docs/user/update-tag-description-with-rest.md index 9ce10c4e7fe..9c59a7cb2a3 100644 --- a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/docs/user/update-tag-description-with-rest.md +++ b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/docs/user/update-tag-description-with-rest.md @@ -8,8 +8,8 @@ POST {serverURLRoot}/servers/{serverName}/open-metadata/access-services/asset-co ``` ```java -TagRequestBody tagRequestBody = new TagRequestBody(); -tagRequestBody.setTagDescription(tagDescription); +TagRequestBody tagProperties = new TagRequestBody(); +tagProperties.setTagDescription(tagDescription); VoidResponse ``` diff --git a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/server/AssetConsumerRESTServices.java b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/server/AssetConsumerRESTServices.java index db3abf1d9fd..834cbd79f3d 100644 --- a/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/server/AssetConsumerRESTServices.java +++ b/open-metadata-implementation/access-services/asset-consumer/asset-consumer-server/src/main/java/org/odpi/openmetadata/accessservices/assetconsumer/server/AssetConsumerRESTServices.java @@ -2,19 +2,42 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.accessservices.assetconsumer.server; -import org.odpi.openmetadata.accessservices.assetconsumer.elements.*; -import org.odpi.openmetadata.accessservices.assetconsumer.handlers.*; -import org.odpi.openmetadata.accessservices.assetconsumer.properties.*; -import org.odpi.openmetadata.accessservices.assetconsumer.rest.*; +import org.odpi.openmetadata.accessservices.assetconsumer.elements.InformalTagElement; +import org.odpi.openmetadata.accessservices.assetconsumer.elements.MeaningElement; +import org.odpi.openmetadata.accessservices.assetconsumer.handlers.LoggingHandler; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.CommentRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.FeedbackRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.GlossaryTermListResponse; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.GlossaryTermResponse; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.LogRecordRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.RatingRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagResponse; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagUpdateRequestBody; +import org.odpi.openmetadata.accessservices.assetconsumer.rest.TagsResponse; import org.odpi.openmetadata.commonservices.ffdc.RESTCallLogger; import org.odpi.openmetadata.commonservices.ffdc.RESTCallToken; -import org.odpi.openmetadata.commonservices.ffdc.rest.*; -import org.odpi.openmetadata.commonservices.generichandlers.*; import org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler; +import org.odpi.openmetadata.commonservices.ffdc.rest.ConnectionResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDListResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler; +import org.odpi.openmetadata.commonservices.generichandlers.CommentHandler; +import org.odpi.openmetadata.commonservices.generichandlers.GlossaryTermHandler; +import org.odpi.openmetadata.commonservices.generichandlers.InformalTagHandler; +import org.odpi.openmetadata.commonservices.generichandlers.LikeHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIDummyBean; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.RatingHandler; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.properties.beans.CommentType; import org.odpi.openmetadata.frameworks.connectors.properties.beans.StarRating; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; import org.slf4j.LoggerFactory; @@ -854,8 +877,7 @@ public GlossaryTermListResponse getMeaningByName(String serverName, int startFrom, int pageSize) { - final String nameParameterName = "term"; - final String methodName = "getMeaningByName"; + final String methodName = "getMeaningByName"; RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); @@ -870,9 +892,12 @@ public GlossaryTermListResponse getMeaningByName(String serverName, if (requestBody != null) { + List limitStatuses = new ArrayList<>(); + limitStatuses.add(InstanceStatus.ACTIVE); response.setMeanings(glossaryTermHandler.getTermsByName(userId, + null, requestBody.getName(), - nameParameterName, + limitStatuses, startFrom, pageSize, false, @@ -916,7 +941,6 @@ public GlossaryTermListResponse findMeanings(String serverName, int startFrom, int pageSize) { - final String nameParameterName = "term"; final String methodName = "findMeanings"; RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); @@ -932,9 +956,12 @@ public GlossaryTermListResponse findMeanings(String serverName, if (requestBody != null) { + List limitStatuses = new ArrayList<>(); + limitStatuses.add(InstanceStatus.ACTIVE); response.setMeanings(glossaryTermHandler.findTerms(userId, + null, requestBody.getSearchString(), - nameParameterName, + limitStatuses, startFrom, pageSize, false, diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/CollaborationExchangeInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/CollaborationExchangeInterface.java index 73e782de880..d3c86102444 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/CollaborationExchangeInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/CollaborationExchangeInterface.java @@ -2,10 +2,446 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.accessservices.assetmanager.api; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.CommentElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.InformalTagElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.LikeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RatingProperties; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.CommentType; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.StarRating; + +import java.util.List; + /** * The CollaborationExchangeInterface supports the exchange of comments, likes, reviews/ratings and * informal tags. */ public interface CollaborationExchangeInterface { + /** + * Adds a star rating and optional review text to the element. If the user has already attached + * a rating then the original one is over-ridden. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element. + * @param properties properties for the rating + * @return unique identifier of the rating + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + String addRatingToElement(String userId, + String elementGUID, + RatingProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Removes of a review that was added to the element by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element where the rating is attached. + * + * @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 requesting user is not authorized to issue this request. + */ + void removeRatingFromElement(String userId, + String elementGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Adds a "LikeProperties" to the element. If the user has already attached a like then the original one + * is over-ridden. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element where the like is to be attached. + * @param properties indicates whether the feedback should be shared or only be visible to the originating user + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + void addLikeToElement(String userId, + String elementGUID, + LikeProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Removes a "LikeProperties" added to the element by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element where the like is attached. + * + * @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 requesting user is not authorized to issue this request. + */ + void removeLikeFromElement(String userId, + String elementGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Adds a comment to the element. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element. + * @param properties properties of the comment + * + * @return guid of new comment. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + String addCommentToElement(String userId, + String elementGUID, + CommentProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Adds a comment to another comment. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element at the head of this comment chain. + * @param commentGUID unique identifier for an existing comment. Used to add a reply to a comment. + * @param properties properties of the comment + * + * @return guid of new comment. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + String addCommentReply(String userId, + String elementGUID, + String commentGUID, + CommentProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Update an existing comment. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element at the head of this comment chain. + * @param commentGUID unique identifier for the comment to change. + * @param properties properties of the comment + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + void updateComment(String userId, + String elementGUID, + String commentGUID, + CommentProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Removes a comment added to the element by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element at the head of this comment chain. + * @param commentGUID unique identifier for the comment object. + * + * @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. + */ + void removeComment(String userId, + String elementGUID, + String commentGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the requested comment. + * + * @param userId userId of user making request. + * @param commentGUID unique identifier for the comment object. + * @return comment properties + * @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. + */ + CommentElement getComment(String userId, + String commentGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the comments 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. + * @return list of comments + * @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. + */ + List getAttachedComments(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Creates a new public informal tag and returns the unique identifier for it. + * + * @param userId userId of user making request. + * @param tagName name of the tag. + * @param tagDescription (optional) description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @return GUID for new tag. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + String createPublicTag(String userId, + String tagName, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + /** + * Creates a new private informal tag and returns the unique identifier for it. + * + * @param userId userId of user making request. + * @param tagName name of the tag. + * @param tagDescription (optional) description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @return GUID for new tag. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + String createPrivateTag(String userId, + String tagName, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Updates the description of an existing tag (either private or public). + * + * @param userId userId of user making request. + * @param tagGUID unique identifier for the tag. + * @param tagDescription description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + void updateTagDescription(String userId, + String tagGUID, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Removes an informal tag from the repository. All the tagging relationships to this informal tag are lost. + * A private tag can be deleted by its creator and all the references are lost; + * a public tag can be deleted by anyone, but only if it is not attached to any referenceable. + * + * @param userId userId of user making request. + * @param tagGUID unique id for the tag. + * + * @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 requesting user is not authorized to issue this request. + */ + void deleteTag(String userId, + String tagGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the tag for the supplied unique identifier (guid). + * + * @param userId userId of the user making the request. + * @param guid unique identifier of the tag. + * + * @return tag + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + InformalTagElement getTag(String userId, + String guid) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the list of tags exactly matching the supplied name. + * + * @param userId the name of the calling user. + * @param tag name of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + List getTagsByName(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the list of the calling user's private tags exactly matching the supplied name. + * + * @param userId the name of the calling user. + * @param tag name of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + List getMyTagsByName(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the list of tags containing the supplied string in either the name or description. + * + * @param userId the name of the calling user. + * @param tag name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + List findTags(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + /** + * Return the list of the calling user's private tags containing the supplied string in either the name or description. + * + * @param userId the name of the calling user. + * @param tag name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + List findMyTags(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + /** + * Adds a tag (either private of public) to an element. + * + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id of the tag. + * @param isPublic flag indicating whether the attachment of the tag is public or not + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + void addTagToElement(String userId, + String elementGUID, + String tagGUID, + boolean isPublic) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Removes a tag from the element that was added by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id for the tag. + * + * @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 requesting user is not authorized to issue this request. + */ + void removeTagFromElement(String userId, + String elementGUID, + String tagGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return the list of unique identifiers for elements that are linked to a specific tag either directly, or via one + * of its schema elements. An Element's GUID may appear multiple times in the results if it is tagged multiple times + * with the requested tag. + * + * @param userId the name of the calling user. + * @param tagGUID unique identifier of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return element guid list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + List getElementsByTag(String userId, + String tagGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/GlossaryExchangeInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/GlossaryExchangeInterface.java index 026f88c49a3..bea3b33392a 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/GlossaryExchangeInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/GlossaryExchangeInterface.java @@ -29,7 +29,6 @@ public interface GlossaryExchangeInterface * The Glossary entity is the top level element in a glossary. */ - /** * Create a new metadata element to represent the root of a glossary. All categories and terms are linked * to a single glossary. They are owned by this glossary and if the glossary is deleted, any linked terms and @@ -513,6 +512,7 @@ void removeGlossaryCategory(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software capability representing the caller * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID optional glossary unique identifier to scope the search to a glossary. * @param searchString string to find in the properties * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -529,6 +529,7 @@ void removeGlossaryCategory(String userId, List findGlossaryCategories(String userId, String assetManagerGUID, String assetManagerName, + String glossaryGUID, String searchString, int startFrom, int pageSize, @@ -578,6 +579,7 @@ List getCategoriesForGlossary(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software capability representing the caller * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID optional glossary unique identifier to scope the search to a glossary. * @param name name to search for * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -594,6 +596,7 @@ List getCategoriesForGlossary(String userId, List getGlossaryCategoriesByName(String userId, String assetManagerGUID, String assetManagerName, + String glossaryGUID, String name, int startFrom, int pageSize, @@ -1387,6 +1390,64 @@ void clearTermAsObjectIdentifier(String userId, PropertyServerException; + /** + * Undo the last update to the glossary term. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * @param forLineage return elements marked with the Memento classification? + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * @return recovered glossary term + * + * @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) + */ + GlossaryTermElement undoGlossaryTermUpdate(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryTermGUID, + String glossaryTermExternalIdentifier, + Date effectiveTime, + boolean forLineage, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Archive the metadata element representing a glossary term. This removes it from normal access. However, it is still available + * for lineage requests. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryTermGUID unique identifier of the metadata element to archive + * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager + * @param archiveProperties option parameters about the archive process + * @param effectiveTime the time that the retrieved elements must be effective for + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * + * @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) + */ + void archiveGlossaryTerm(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryTermGUID, + String glossaryTermExternalIdentifier, + ArchiveProperties archiveProperties, + Date effectiveTime, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + /** * Remove the metadata element representing a glossary term. * @@ -1422,7 +1483,10 @@ void removeGlossaryTerm(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software capability representing the caller * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param searchString string to find in the properties + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom paging start point * @param pageSize maximum results that can be returned * @param effectiveTime the time that the retrieved elements must be effective for @@ -1435,17 +1499,19 @@ void removeGlossaryTerm(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - List findGlossaryTerms(String userId, - String assetManagerGUID, - String assetManagerName, - String searchString, - int startFrom, - int pageSize, - Date effectiveTime, - boolean forLineage, - boolean forDuplicateProcessing) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException; + List findGlossaryTerms(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryGUID, + String searchString, + List limitResultsByStatus, + int startFrom, + int pageSize, + Date effectiveTime, + boolean forLineage, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -1519,7 +1585,10 @@ List getTermsForGlossaryCategory(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software capability representing the caller * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param name name to search for + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom paging start point * @param pageSize maximum results that can be returned * @param effectiveTime the time that the retrieved elements must be effective for @@ -1532,17 +1601,19 @@ List getTermsForGlossaryCategory(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - List getGlossaryTermsByName(String userId, - String assetManagerGUID, - String assetManagerName, - String name, - int startFrom, - int pageSize, - Date effectiveTime, - boolean forLineage, - boolean forDuplicateProcessing) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException; + List getGlossaryTermsByName(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryGUID, + String name, + List limitResultsByStatus, + int startFrom, + int pageSize, + Date effectiveTime, + boolean forLineage, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -1572,6 +1643,41 @@ GlossaryTermElement getGlossaryTermByGUID(String userId, UserNotAuthorizedException, PropertyServerException; + /** + * Retrieve all the versions of a glossary term. + * + * @param userId calling user + * @param guid unique identifier of object to retrieve + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startFrom the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param oldestFirst defining how the results should be ordered. + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @return list of beans + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem removing the properties from the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + List getGlossaryTermHistory(String userId, + String assetManagerGUID, + String assetManagerName, + String guid, + Date fromTime, + Date toTime, + int startFrom, + int pageSize, + boolean oldestFirst, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; /* ========================================================================================= * Support for linkage to external glossary resources. These glossary resources are not diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/StewardshipExchangeInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/StewardshipExchangeInterface.java index 2f2b69d6cb7..76319ec17c7 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/StewardshipExchangeInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/StewardshipExchangeInterface.java @@ -2,11 +2,14 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.accessservices.assetmanager.api; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SecurityTagsProperties; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import java.util.Date; +import java.util.List; +import java.util.Map; /** * The StewardshipExchangeInterface supports the exchange of relationships (such as SemanticAssignment) @@ -124,4 +127,38 @@ void clearIncompleteClassification(String userId, boolean forDuplicateProcessing) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException; + + + /** + * Add or replace the security tags for an element. + * + * @param userId calling user + * @param elementGUID element to link it to - its type must inherit from Referenceable. + * @param properties details of the security tags + * + * @throws InvalidParameterException element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void addSecurityTags(String userId, + String elementGUID, + SecurityTagsProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove the security tags classification from an element. + * + * @param userId calling user + * @param elementGUID element where the security tags need to be removed. + * + * @throws InvalidParameterException asset or element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void removeSecurityTags(String userId, + String elementGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/CommentElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/CommentElement.java new file mode 100644 index 00000000000..38ab63035ec --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/CommentElement.java @@ -0,0 +1,222 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +import java.io.Serial; +import java.io.Serializable; +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; + +/** + * CommentElement contains the properties and header for a Comment entity retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CommentElement implements MetadataElement, Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private List correlationHeaders = null; + private CommentProperties properties = null; + private FeedbackTargetElement feedbackTargetElement = null; + + + /** + * Default constructor + */ + public CommentElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CommentElement(CommentElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + correlationHeaders = template.getCorrelationHeaders(); + properties = template.getProperties(); + feedbackTargetElement = template.getFeedbackTargetElement(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + @Override + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + @Override + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @return list of correlation properties objects + */ + @Override + public List getCorrelationHeaders() + { + if (correlationHeaders == null) + { + return null; + } + else if (correlationHeaders.isEmpty()) + { + return null; + } + + return correlationHeaders; + } + + + /** + * Set up the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @param correlationHeaders list of correlation properties objects + */ + @Override + public void setCorrelationHeaders(List correlationHeaders) + { + this.correlationHeaders = correlationHeaders; + } + + + /** + * Return the properties of the comment. + * + * @return properties bean + */ + public CommentProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the comment. + * + * @param properties properties bean + */ + public void setProperties(CommentProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship from the element in the request to the comment. This value is null if the comment was retrieved independently + * of any commented element. + * + * @return associated relationship + */ + public FeedbackTargetElement getFeedbackTargetElement() + { + return feedbackTargetElement; + } + + + /** + * Set up details of the relationship from the element in the request to the comment. This value is null if the comment was retrieved independently + * of any commented element. + * + * @param feedbackTargetElement associated relationship + */ + public void setFeedbackTargetElement(FeedbackTargetElement feedbackTargetElement) + { + this.feedbackTargetElement = feedbackTargetElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CommentElement{" + + "elementHeader=" + elementHeader + + ", correlationHeaders=" + correlationHeaders + + ", properties=" + properties + + ", feedbackTargetElement=" + feedbackTargetElement + + '}'; + } + + + /** + * 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 instanceof CommentElement that)) + { + return false; + } + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(correlationHeaders, that.correlationHeaders) && + Objects.equals(properties, that.properties) && + Objects.equals(feedbackTargetElement, that.feedbackTargetElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elementHeader, correlationHeaders, properties, feedbackTargetElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/FeedbackTargetElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/FeedbackTargetElement.java new file mode 100644 index 00000000000..f94a5dbec26 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/FeedbackTargetElement.java @@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementStub; + +import java.io.Serial; +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * FeedbackTargetElement contains the properties and header for a relationship retrieved from the metadata repository along with the stub + * of the related element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class FeedbackTargetElement implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader relationshipHeader = null; + private ElementStub relatedElement = null; + private boolean isPublic = false; + + /** + * Default constructor + */ + public FeedbackTargetElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public FeedbackTargetElement(FeedbackTargetElement template) + { + if (template != null) + { + relationshipHeader = template.getRelationshipHeader(); + relatedElement = template.getRelatedElement(); + isPublic = template.getIsPublic(); + } + } + + + + /** + * Return if the link to the tag is private to the creating user. + * + * @return boolean + */ + public boolean getIsPublic() + { + return isPublic; + } + + + /** + * Set up whether the link to the tag is private to the creating user or not. + * + * @param aPublic boolean + */ + public void setIsPublic(boolean aPublic) + { + isPublic = aPublic; + } + + + /** + * Return the element header associated with the relationship. + * + * @return element header object + */ + public ElementHeader getRelationshipHeader() + { + return relationshipHeader; + } + + + /** + * Set up the element header associated with the relationship. + * + * @param relationshipHeader element header object + */ + public void setRelationshipHeader(ElementHeader relationshipHeader) + { + this.relationshipHeader = relationshipHeader; + } + + + /** + * Return the element header associated with end 1 of the relationship. + * + * @return element stub object + */ + public ElementStub getRelatedElement() + { + return relatedElement; + } + + + /** + * Set up the element header associated with end 1 of the relationship. + * + * @param relatedElement element stub object + */ + public void setRelatedElement(ElementStub relatedElement) + { + this.relatedElement = relatedElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "FeedbackTargetElement{" + + "relationshipHeader=" + relationshipHeader + + ", relatedElement=" + relatedElement + + ", isPublic=" + isPublic + + '}'; + } + + + /** + * 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 instanceof FeedbackTargetElement)) + { + return false; + } + + FeedbackTargetElement that = (FeedbackTargetElement) objectToCompare; + + if (isPublic != that.isPublic) + { + return false; + } + if (relationshipHeader != null ? ! relationshipHeader.equals(that.relationshipHeader) : that.relationshipHeader != null) + { + return false; + } + return relatedElement != null ? relatedElement.equals(that.relatedElement) : that.relatedElement == null; + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + int result = relationshipHeader != null ? relationshipHeader.hashCode() : 0; + result = 31 * result + (relatedElement != null ? relatedElement.hashCode() : 0); + result = 31 * result + (isPublic ? 1 : 0); + return result; + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryElement.java index a24ca07a62a..9ae420c9156 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryElement.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryElement.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryProperties; +import java.io.Serial; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -24,7 +25,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryElement implements MetadataElement, Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private ElementHeader elementHeader = null; private List correlationHeaders = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryTermElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryTermElement.java index 9710c26219d..6fffe513efc 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryTermElement.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/GlossaryTermElement.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermProperties; +import java.io.Serial; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -25,7 +26,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryTermElement implements MetadataElement, Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private ElementHeader elementHeader = null; private List correlationHeaders = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/InformalTagElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/InformalTagElement.java new file mode 100644 index 00000000000..6b54f388593 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/InformalTagElement.java @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.InformalTagProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +import java.io.Serial; +import java.io.Serializable; +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; + +/** + * InformalTagElement contains the properties and header for a InformalTag entity retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class InformalTagElement implements MetadataElement, Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private List correlationHeaders = null; + private InformalTagProperties properties = null; + private FeedbackTargetElement feedbackTargetElement = null; + + + /** + * Default constructor + */ + public InformalTagElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public InformalTagElement(InformalTagElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + correlationHeaders = template.getCorrelationHeaders(); + properties = template.getProperties(); + feedbackTargetElement = template.getFeedbackTargetElement(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + @Override + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + @Override + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @return list of correlation properties objects + */ + @Override + public List getCorrelationHeaders() + { + if (correlationHeaders == null) + { + return null; + } + else if (correlationHeaders.isEmpty()) + { + return null; + } + + return correlationHeaders; + } + + + /** + * Set up the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @param correlationHeaders list of correlation properties objects + */ + @Override + public void setCorrelationHeaders(List correlationHeaders) + { + this.correlationHeaders = correlationHeaders; + } + + + /** + * Return the properties of the informal tag. + * + * @return properties bean + */ + public InformalTagProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the informal tag. + * + * @param properties properties bean + */ + public void setProperties(InformalTagProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship from the element in the request to the tag. This value is null if the tag was retrieved independently + * of any tagged element. + * + * @return associated relationship + */ + public FeedbackTargetElement getFeedbackTargetElement() + { + return feedbackTargetElement; + } + + + /** + * Set up details of the relationship from the element in the request to the tag. This value is null if the tag was retrieved independently + * of any tagged element. + * + * @param feedbackTargetElement associated relationship + */ + public void setFeedbackTargetElement(FeedbackTargetElement feedbackTargetElement) + { + this.feedbackTargetElement = feedbackTargetElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "InformalTagElement{" + + "elementHeader=" + elementHeader + + ", correlationHeaders=" + correlationHeaders + + ", properties=" + properties + + ", feedbackTargetElement=" + feedbackTargetElement + + '}'; + } + + + /** + * 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 instanceof InformalTagElement that)) + { + return false; + } + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(correlationHeaders, that.correlationHeaders) && + Objects.equals(properties, that.properties) && + Objects.equals(feedbackTargetElement, that.feedbackTargetElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elementHeader, correlationHeaders, properties, feedbackTargetElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/LikeElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/LikeElement.java new file mode 100644 index 00000000000..ae23528303e --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/LikeElement.java @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.LikeProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +import java.io.Serial; +import java.io.Serializable; +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; + +/** + * LikeElement contains the properties and header for a Like entity retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LikeElement implements MetadataElement, Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private List correlationHeaders = null; + private LikeProperties properties = null; + private FeedbackTargetElement feedbackTargetElement = null; + + + /** + * Default constructor + */ + public LikeElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LikeElement(LikeElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + correlationHeaders = template.getCorrelationHeaders(); + properties = template.getProperties(); + feedbackTargetElement = template.getFeedbackTargetElement(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + @Override + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + @Override + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @return list of correlation properties objects + */ + @Override + public List getCorrelationHeaders() + { + if (correlationHeaders == null) + { + return null; + } + else if (correlationHeaders.isEmpty()) + { + return null; + } + + return correlationHeaders; + } + + + /** + * Set up the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @param correlationHeaders list of correlation properties objects + */ + @Override + public void setCorrelationHeaders(List correlationHeaders) + { + this.correlationHeaders = correlationHeaders; + } + + + /** + * Return the properties of the like. + * + * @return properties bean + */ + public LikeProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the like. + * + * @param properties properties bean + */ + public void setProperties(LikeProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship from the element in the request to the like. This value is null if the like was retrieved independently + * of any liked element. + * + * @return associated relationship + */ + public FeedbackTargetElement getFeedbackTargetElement() + { + return feedbackTargetElement; + } + + + /** + * Set up details of the relationship from the element in the request to the like. This value is null if the like was retrieved independently + * of any liked element. + * + * @param feedbackTargetElement associated relationship + */ + public void setFeedbackTargetElement(FeedbackTargetElement feedbackTargetElement) + { + this.feedbackTargetElement = feedbackTargetElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LikeElement{" + + "elementHeader=" + elementHeader + + ", correlationHeaders=" + correlationHeaders + + ", properties=" + properties + + ", feedbackTargetElement=" + feedbackTargetElement + + '}'; + } + + + /** + * 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 instanceof LikeElement that)) + { + return false; + } + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(correlationHeaders, that.correlationHeaders) && + Objects.equals(properties, that.properties) && + Objects.equals(feedbackTargetElement, that.feedbackTargetElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elementHeader, correlationHeaders, properties, feedbackTargetElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteElement.java new file mode 100644 index 00000000000..a954d0a7f94 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteElement.java @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.NoteProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +import java.io.Serial; +import java.io.Serializable; +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; + +/** + * NoteElement contains the properties and header for a Note entity retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class NoteElement implements MetadataElement, Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private List correlationHeaders = null; + private NoteProperties properties = null; + private FeedbackTargetElement feedbackTargetElement = null; + + + /** + * Default constructor + */ + public NoteElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public NoteElement(NoteElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + correlationHeaders = template.getCorrelationHeaders(); + properties = template.getProperties(); + feedbackTargetElement = template.getFeedbackTargetElement(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + @Override + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + @Override + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @return list of correlation properties objects + */ + @Override + public List getCorrelationHeaders() + { + if (correlationHeaders == null) + { + return null; + } + else if (correlationHeaders.isEmpty()) + { + return null; + } + + return correlationHeaders; + } + + + /** + * Set up the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @param correlationHeaders list of correlation properties objects + */ + @Override + public void setCorrelationHeaders(List correlationHeaders) + { + this.correlationHeaders = correlationHeaders; + } + + + /** + * Return the properties of the note. + * + * @return properties bean + */ + public NoteProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the note. + * + * @param properties properties bean + */ + public void setProperties(NoteProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship from the element in the request to the note. This value is null if the note was retrieved independently + * of any noted element. + * + * @return associated relationship + */ + public FeedbackTargetElement getFeedbackTargetElement() + { + return feedbackTargetElement; + } + + + /** + * Set up details of the relationship from the element in the request to the note. This value is null if the note was retrieved independently + * of any noted element. + * + * @param feedbackTargetElement associated relationship + */ + public void setFeedbackTargetElement(FeedbackTargetElement feedbackTargetElement) + { + this.feedbackTargetElement = feedbackTargetElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "NoteElement{" + + "elementHeader=" + elementHeader + + ", correlationHeaders=" + correlationHeaders + + ", properties=" + properties + + ", feedbackTargetElement=" + feedbackTargetElement + + '}'; + } + + + /** + * 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 instanceof NoteElement that)) + { + return false; + } + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(correlationHeaders, that.correlationHeaders) && + Objects.equals(properties, that.properties) && + Objects.equals(feedbackTargetElement, that.feedbackTargetElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elementHeader, correlationHeaders, properties, feedbackTargetElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteLogElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteLogElement.java new file mode 100644 index 00000000000..f6f66f66c8f --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/NoteLogElement.java @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.NoteLogProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +import java.io.Serial; +import java.io.Serializable; +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; + +/** + * NoteLogElement contains the properties and header for a NoteLog entity retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class NoteLogElement implements MetadataElement, Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private List correlationHeaders = null; + private NoteLogProperties properties = null; + private FeedbackTargetElement feedbackTargetElement = null; + + + /** + * Default constructor + */ + public NoteLogElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public NoteLogElement(NoteLogElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + correlationHeaders = template.getCorrelationHeaders(); + properties = template.getProperties(); + feedbackTargetElement = template.getFeedbackTargetElement(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + @Override + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + @Override + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @return list of correlation properties objects + */ + @Override + public List getCorrelationHeaders() + { + if (correlationHeaders == null) + { + return null; + } + else if (correlationHeaders.isEmpty()) + { + return null; + } + + return correlationHeaders; + } + + + /** + * Set up the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @param correlationHeaders list of correlation properties objects + */ + @Override + public void setCorrelationHeaders(List correlationHeaders) + { + this.correlationHeaders = correlationHeaders; + } + + + /** + * Return the properties of the note log. + * + * @return properties bean + */ + public NoteLogProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the note log. + * + * @param properties properties bean + */ + public void setProperties(NoteLogProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship from the element in the request to the note log. This value is null if the note log was retrieved independently + * of any note logd element. + * + * @return associated relationship + */ + public FeedbackTargetElement getFeedbackTargetElement() + { + return feedbackTargetElement; + } + + + /** + * Set up details of the relationship from the element in the request to the note log. This value is null if the note log was retrieved independently + * of any note logged element. + * + * @param feedbackTargetElement associated relationship + */ + public void setFeedbackTargetElement(FeedbackTargetElement feedbackTargetElement) + { + this.feedbackTargetElement = feedbackTargetElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "NoteLogElement{" + + "elementHeader=" + elementHeader + + ", correlationHeaders=" + correlationHeaders + + ", properties=" + properties + + ", feedbackTargetElement=" + feedbackTargetElement + + '}'; + } + + + /** + * 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 instanceof NoteLogElement that)) + { + return false; + } + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(correlationHeaders, that.correlationHeaders) && + Objects.equals(properties, that.properties) && + Objects.equals(feedbackTargetElement, that.feedbackTargetElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elementHeader, correlationHeaders, properties, feedbackTargetElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/RatingElement.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/RatingElement.java new file mode 100644 index 00000000000..6eacb7991e5 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/RatingElement.java @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RatingProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +import java.io.Serial; +import java.io.Serializable; +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; + +/** + * RatingElement contains the properties and header for a Rating entity retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class RatingElement implements MetadataElement, Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private List correlationHeaders = null; + private RatingProperties properties = null; + private FeedbackTargetElement feedbackTargetElement = null; + + + /** + * Default constructor + */ + public RatingElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public RatingElement(RatingElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + correlationHeaders = template.getCorrelationHeaders(); + properties = template.getProperties(); + feedbackTargetElement = template.getFeedbackTargetElement(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + @Override + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + @Override + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @return list of correlation properties objects + */ + @Override + public List getCorrelationHeaders() + { + if (correlationHeaders == null) + { + return null; + } + else if (correlationHeaders.isEmpty()) + { + return null; + } + + return correlationHeaders; + } + + + /** + * Set up the details of the external identifier and other correlation properties about the metadata source. + * There is one entry in the list for each element in the third party technology that maps to the single open source + * element. + * + * @param correlationHeaders list of correlation properties objects + */ + @Override + public void setCorrelationHeaders(List correlationHeaders) + { + this.correlationHeaders = correlationHeaders; + } + + + /** + * Return the properties of the rating. + * + * @return properties bean + */ + public RatingProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the rating. + * + * @param properties properties bean + */ + public void setProperties(RatingProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship from the element in the request to the rating. This value is null if the rating was retrieved independently + * of any rated element. + * + * @return associated relationship + */ + public FeedbackTargetElement getFeedbackTargetElement() + { + return feedbackTargetElement; + } + + + /** + * Set up details of the relationship from the element in the request to the rating. This value is null if the rating was retrieved independently + * of any rated element. + * + * @param feedbackTargetElement associated relationship + */ + public void setFeedbackTargetElement(FeedbackTargetElement feedbackTargetElement) + { + this.feedbackTargetElement = feedbackTargetElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "RatingElement{" + + "elementHeader=" + elementHeader + + ", correlationHeaders=" + correlationHeaders + + ", properties=" + properties + + ", feedbackTargetElement=" + feedbackTargetElement + + '}'; + } + + + /** + * 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 instanceof RatingElement that)) + { + return false; + } + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(correlationHeaders, that.correlationHeaders) && + Objects.equals(properties, that.properties) && + Objects.equals(feedbackTargetElement, that.feedbackTargetElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elementHeader, correlationHeaders, properties, feedbackTargetElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ArchiveProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ArchiveProperties.java new file mode 100644 index 00000000000..f4364cfa9d9 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ArchiveProperties.java @@ -0,0 +1,190 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ArchiveProperties defined the properties that are stored when a data source is archived or deleted. This + * allows the Asset to remain in the metadata repository after the real-world artifact has gone. This is important + * to prevent lineage graphs from becoming fragmented. + */ +@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ArchiveProperties implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private Date archiveDate = null; + private String archiveProcess = null; + private Map archiveProperties = null; + + + /** + * Default constructor + */ + public ArchiveProperties() + { + super(); + } + + + /** + * Copy/clone constructor for the template properties. + * + * @param template template object to copy. + */ + public ArchiveProperties(ArchiveProperties template) + { + if (template != null) + { + archiveDate = template.getArchiveDate(); + archiveProcess = template.getArchiveProcess(); + archiveProperties = template.getArchiveProperties(); + } + } + + + /** + * Returns the date when the data source was archived (or discovered missing). Null means "now". + * + * @return date of archive + */ + public Date getArchiveDate() + { + return archiveDate; + } + + + /** + * Set up the date when the data source was archived (or discovered missing). Null means "now". + * + * @param archiveDate date of archive + */ + public void setArchiveDate(Date archiveDate) + { + this.archiveDate = archiveDate; + } + + + /** + * Returns the name of the process that either performed the archive or detected the missing data source. + * + * @return String name + */ + public String getArchiveProcess() + { + return archiveProcess; + } + + + /** + * Set up the name of the process that either performed the archive or detected the missing data source. + * + * @param archiveProcess String name + */ + public void setArchiveProcess(String archiveProcess) + { + this.archiveProcess = archiveProcess; + } + + + /** + * Return the properties that characterize where the data source was archived to. + * + * @return map of name value pairs, all strings + */ + public Map getArchiveProperties() + { + if (archiveProperties == null) + { + return null; + } + else if (archiveProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(archiveProperties); + } + } + + + /** + * Set up the properties that characterize where the data source was archived to. + * + * @param archiveProperties map of name value pairs, all strings + */ + public void setArchiveProperties(Map archiveProperties) + { + this.archiveProperties = archiveProperties; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "ArchiveProperties{" + + "archiveDate=" + archiveDate + + ", archiveProcess='" + archiveProcess + '\'' + + ", archiveProperties='" + archiveProperties + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (objectToCompare == null || getClass() != objectToCompare.getClass()) + { + return false; + } + ArchiveProperties that = (ArchiveProperties) objectToCompare; + return Objects.equals(archiveDate, that.archiveDate) && + Objects.equals(archiveProcess, that.archiveProcess) && + Objects.equals(archiveProperties, that.archiveProperties); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(archiveDate, archiveProcess, archiveProperties); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentProperties.java new file mode 100644 index 00000000000..f3cba972135 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentProperties.java @@ -0,0 +1,220 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * The CommentProperties bean stores information about a comment connected to an asset. Comments provide informal feedback to assets + * and can be added at any time. + * + * Comments have the userId of the person who added the feedback, along with their comment text. + * + * The content of the comment is a personal statement (which is why the user's id is in the comment) + * and there is no formal review of the content. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CommentProperties extends ReferenceableProperties +{ + @Serial + private static final long serialVersionUID = 1L; + + private CommentType commentType = null; + private String commentText = null; + private String user = null; + private boolean isPublic = false; + + /** + * Default constructor + */ + public CommentProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public CommentProperties(CommentProperties template) + { + super(template); + + if (template != null) + { + /* + * Copy the values from the supplied comment. + */ + commentType = template.getCommentType(); + user = template.getUser(); + commentText = template.getCommentText(); + isPublic = template.getIsPublic(); + } + } + + + /** + * Return an enum that describes the type of comment. + * + * @return CommentType enum + */ + public CommentType getCommentType() + { + return commentType; + } + + + /** + * Set up the enum that describes the type of comment. + * + * @param commentType CommentType enum + */ + public void setCommentType(CommentType commentType) + { + this.commentType = commentType; + } + + + /** + * Return the comment text. + * + * @return String commentText + */ + public String getCommentText() + { + return commentText; + } + + + /** + * Set up the comment text. + * + * @param commentText String text + */ + public void setCommentText(String commentText) + { + this.commentText = commentText; + } + + + /** + * Return the user id of the person who created the comment. Null means the user id is not known. + * + * @return String commenting user + */ + public String getUser() + { + return user; + } + + + /** + * Set up the user id of the person who created the comment. Null means the user id is not known. + * + * @param user String commenting user + */ + public void setUser(String user) + { + this.user = user; + } + + + + /** + * Return whether the feedback is private or not + * + * @return boolean + */ + public boolean getIsPublic() + { + return isPublic; + } + + + /** + * Set up the privacy flag. + * + * @param aPrivate boolean + */ + public void setIsPublic(boolean aPrivate) + { + isPublic = aPrivate; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "CommentProperties{" + + "commentType=" + commentType + + ", commentText='" + commentText + '\'' + + ", user='" + user + '\'' + + ", isPublic=" + isPublic + + ", qualifiedName='" + getQualifiedName() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", vendorProperties=" + getVendorProperties() + + ", typeName='" + getTypeName() + '\'' + + ", extendedProperties=" + getExtendedProperties() + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean 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; + } + CommentProperties that = (CommentProperties) objectToCompare; + return commentType == that.commentType && + isPublic == that.isPublic && + Objects.equals(commentText, that.commentText) && + Objects.equals(user, that.user); + } + + + /** + * Create a hash code for this element type. + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), commentType, commentText, user, isPublic); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentType.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentType.java new file mode 100644 index 00000000000..d2a707fefb4 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CommentType.java @@ -0,0 +1,136 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * The CommentType allows comments to be used to ask and answer questions as well as make suggestions and + * provide useful information to other users. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum CommentType implements Serializable +{ + STANDARD_COMMENT (0, 0, "Comment", "General comment about the asset."), + QUESTION (1, 1, "Question", "Asks a question to the people owning, managing or using the asset."), + ANSWER (2, 2, "Answer", "Answers a question (posted as a reply to the question)."), + SUGGESTION (3, 3, "Suggestion", "Provides a suggestion on how to improve the asset or its properties and description."), + USAGE_EXPERIENCE (4, 4, "Experience", "Describes situations where this asset has been used and related hints and tips."), + OTHER (99, 99, "Other", "Unknown comment type."); + + private static final long serialVersionUID = 1L; + + public static final String ENUM_TYPE_GUID = "06d5032e-192a-4f77-ade1-a4b97926e867"; + public static final String ENUM_TYPE_NAME = "CommentType"; + + private final int openTypeOrdinal; + + private final int ordinal; + private final String name; + private final String description; + + + /** + * Constructor to set up the instance of this enum. + * + * @param ordinal code number + * @param openTypeOrdinal code number from the equivalent Enum Type + * @param name default name + * @param description default description + */ + CommentType(int ordinal, + int openTypeOrdinal, + String name, + String description) + { + this.ordinal = ordinal; + this.openTypeOrdinal = openTypeOrdinal; + this.name = name; + this.description = description; + } + + + /** + * Return the code for this enum instance + * + * @return int comment type code + */ + public int getOrdinal() + { + return ordinal; + } + + + /** + * Return the default type name for this enum instance. + * + * @return String default type name + */ + public String getName() + { + return name; + } + + + /** + * Return the default description for the star rating for this enum instance. + * + * @return String default description + */ + public String getDescription() + { + return description; + } + + + /** + * Return the code for this enum that comes from the Open Metadata Type that this enum represents. + * + * @return int code number + */ + public int getOpenTypeOrdinal() + { + return openTypeOrdinal; + } + + + /** + * Return the unique identifier for the open metadata enum type that this enum class represents. + * + * @return string guid + */ + public String getOpenTypeGUID() { return ENUM_TYPE_GUID; } + + + /** + * Return the unique name for the open metadata enum type that this enum class represents. + * + * @return string name + */ + public String getOpenTypeName() { return ENUM_TYPE_NAME; } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "CommentType{" + + "commentTypeCode=" + ordinal + + ", commentType='" + name + '\'' + + ", commentTypeDescription='" + description + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/FeedbackProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/FeedbackProperties.java new file mode 100644 index 00000000000..757b4b76519 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/FeedbackProperties.java @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * FeedbackProperties provides a base class for passing feedback objects as a request body over a REST API. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class FeedbackProperties implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private boolean isPublic = false; + + + /** + * Default constructor + */ + public FeedbackProperties() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public FeedbackProperties(FeedbackProperties template) + { + if (template != null) + { + this.isPublic = template.getIsPublic(); + } + } + + + + + /** + * Return whether the feedback is private or not + * + * @return boolean + */ + public boolean getIsPublic() + { + return isPublic; + } + + + /** + * Set up the privacy flag. + * + * @param aPrivate boolean + */ + public void setIsPublic(boolean aPrivate) + { + isPublic = aPrivate; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "FeedbackProperties{" + + ", isPublic=" + isPublic + + '}'; + } + + + /** + * Equals method that returns true if containing properties are the same. + * + * @param objectToCompare object to compare + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (objectToCompare == null || getClass() != objectToCompare.getClass()) + { + return false; + } + FeedbackProperties that = (FeedbackProperties) objectToCompare; + return getIsPublic() == that.getIsPublic(); + } + + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(getIsPublic()); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/GlossaryTermProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/GlossaryTermProperties.java index 0eb2702d09f..39da00fc12f 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/GlossaryTermProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/GlossaryTermProperties.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -21,7 +22,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryTermProperties extends ReferenceableProperties { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private String displayName = null; private String summary = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/InformalTagProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/InformalTagProperties.java new file mode 100644 index 00000000000..d53358810af --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/InformalTagProperties.java @@ -0,0 +1,214 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * InformalTagProperties stores information about a tag connected to an asset. + * InformalTags provide informal classifications to assets + * and can be added at any time. + * + * InformalTags have the userId of the person who added the tag, the name of the tag and its description. + * + * The content of the tag is a personal judgement (which is why the user's id is in the tag) + * and there is no formal review of the tags. However, they can be used as a basis for crowd-sourcing + * Glossary terms. + * + * Private InformalTags are only returned to the user that created them. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class InformalTagProperties implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private boolean isPrivateTag = false; + private String name = null; + private String description = null; + private String user = null; + + + /** + * Default constructor + */ + public InformalTagProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public InformalTagProperties(InformalTagProperties template) + { + if (template != null) + { + isPrivateTag = template.getIsPrivateTag(); + user = template.getUser(); + name = template.getName(); + description = template.getDescription(); + } + } + + + /** + * Return boolean flag to say whether the tag is private or not. A private tag is only seen by the + * person who set it up. Public tags are visible to everyone. + * + * @return boolean is private flag + */ + public boolean getIsPrivateTag() { + return isPrivateTag; + } + + + /** + * Set up boolean flag to say whether the tag is private or not. A private tag is only seen by the + * person who set it up. Public tags are visible to everyone. + * + * @param privateTag indicator of a private tag + */ + public void setIsPrivateTag(boolean privateTag) + { + isPrivateTag = privateTag; + } + + + /** + * Return the user id of the person who created the tag. Null means the user id is not known. + * + * @return String tagging user + */ + public String getUser() { + return user; + } + + + /** + * Set up the user id of the person who created the tag. Null means the user id is not known. + * + * @param user String identifier of the creator of the tag. + */ + public void setUser(String user) + { + this.user = user; + } + + + /** + * Return the name of the tag. It is not valid to have a tag with no name. However, there is a point where + * the tag object is created and the tag name not yet set, so null is a possible response. + * + * @return String tag name + */ + public String getName() { + return name; + } + + + /** + * Set up the name of the tag. It is not valid to have a tag with no name. However, there is a point where + * the tag object is created and the tag name not yet set, so null is a possible response. + * + * @param name String tag name + */ + public void setName(String name) + { + this.name = name; + } + + + /** + * Return the tag description null means no description is available. + * + * @return String tag description + */ + public String getDescription() + { + return description; + } + + + /** + * Set up the tag description null means no description is available. + * + * @param tagDescription tag description + */ + public void setDescription(String tagDescription) { + this.description = tagDescription; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "InformalTagProperties{" + + ", isPrivateTag=" + isPrivateTag + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", user='" + user + '\'' + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (!(objectToCompare instanceof InformalTagProperties)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + InformalTagProperties that = (InformalTagProperties) objectToCompare; + return getIsPrivateTag() == that.getIsPrivateTag() && + Objects.equals(getName(), that.getName()) && + Objects.equals(getDescription(), that.getDescription()) && + Objects.equals(getUser(), that.getUser()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(isPrivateTag, name, description, user); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/LikeProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/LikeProperties.java new file mode 100644 index 00000000000..fe6fdc25a0e --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/LikeProperties.java @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * The LikeProperties object records a single user's "like" of an element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LikeProperties implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + protected String user = null; + protected boolean isPublic = false; + + + /** + * Default constructor + */ + public LikeProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public LikeProperties(LikeProperties template) + { + if (template != null) + { + user = template.getUser(); + isPublic = template.isPublic; + } + } + + + /** + * Return the user id of the person who created the like. Null means the user id is not known. + * + * @return String liking user + */ + public String getUser() { + return user; + } + + + /** + * Set up the user id of the person who created the like. Null means the user id is not known. + * + * @param user String liking user + */ + public void setUser(String user) + { + this.user = user; + } + + + /** + * Return if this like is private to the creating user. + * + * @return boolean + */ + public boolean getIsPublic() + { + return isPublic; + } + + + /** + * Set up whether the like is private to the creating user or not. + * + * @param aPublic boolean + */ + public void setIsPublic(boolean aPublic) + { + isPublic = aPublic; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "LikeProperties{" + + "user='" + user + '\'' + + ", isPublic=" + isPublic + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (objectToCompare == null || getClass() != objectToCompare.getClass()) + { + return false; + } + LikeProperties like = (LikeProperties) objectToCompare; + return isPublic == like.isPublic && + Objects.equals(getUser(), like.getUser()); + } + + + /** + * Hash of properties + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(getUser(), isPublic); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteLogProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteLogProperties.java new file mode 100644 index 00000000000..dea64eca3fa --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteLogProperties.java @@ -0,0 +1,165 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * NoteLogHeader manages a list of notes for an asset + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class NoteLogProperties extends ReferenceableProperties +{ + @Serial + private static final long serialVersionUID = 1L; + + /* + * Attributes of a note log + */ + protected String displayName = null; + protected String description = null; + + + /** + * Default constructor + */ + public NoteLogProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template note log to copy + */ + public NoteLogProperties(NoteLogProperties template) + { + super(template); + + if (template != null) + { + displayName = template.getDisplayName(); + description = template.getDescription(); + } + } + + + /** + * Return the stored display name property for the note log. + * If no display name is available then null is returned. + * + * @return String Name + */ + public String getDisplayName() + { + return displayName; + } + + + /** + * Set up the stored display name property for the note log. + * + * @param displayName - String name + */ + public void setDisplayName(String displayName) + { + this.displayName = displayName; + } + + + /** + * Return the stored description property for the note log. + * If no description is provided then null is returned. + * + * @return description + */ + public String getDescription() + { + return description; + } + + + /** + * Set up the stored description property for the note log. + * + * @param description String text + */ + public void setDescription(String description) + { + this.description = description; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "NoteLogProperties{" + + "displayName='" + displayName + '\'' + + ", description='" + description + '\'' + + ", qualifiedName='" + getQualifiedName() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", vendorProperties=" + getVendorProperties() + + ", typeName='" + getTypeName() + '\'' + + ", extendedProperties=" + getExtendedProperties() + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean 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; + } + NoteLogProperties noteLog = (NoteLogProperties) objectToCompare; + return Objects.equals(getDisplayName(), noteLog.getDisplayName()) && + Objects.equals(getDescription(), noteLog.getDescription()); + } + + + /** + * Hash of properties + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), getDisplayName(), getDescription()); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteProperties.java new file mode 100644 index 00000000000..6a616998e1e --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/NoteProperties.java @@ -0,0 +1,197 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.util.Date; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Note defines the properties of a single note in a note log. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class NoteProperties extends ReferenceableProperties +{ + @Serial + private static final long serialVersionUID = 1L; + + /* + * Attributes of a Note + */ + protected String text = null; + protected Date lastUpdate = null; + protected String user = null; + + + /** + * Default constructor + */ + public NoteProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template note to copy + */ + public NoteProperties(NoteProperties template) + { + super(template); + + if (template != null) + { + text = template.getText(); + user = template.getUser(); + + Date templateLastUpdate = template.getLastUpdate(); + if (templateLastUpdate != null) + { + lastUpdate = new Date(templateLastUpdate.getTime()); + } + } + } + + + /** + * Return the text of the note. + * + * @return String text + */ + public String getText() { return text; } + + + /** + * Set up the text of the note. + * + * @param text String text + */ + public void setText(String text) + { + this.text = text; + } + + + /** + * Return the last time a change was made to this note. + * + * @return Date last updated + */ + public Date getLastUpdate() + { + if (lastUpdate == null) + { + return null; + } + else + { + return new Date(lastUpdate.getTime()); + } + } + + + /** + * Set up the last time a change was made to this note. + * + * @param lastUpdate Date last updated + */ + public void setLastUpdate(Date lastUpdate) + { + this.lastUpdate = lastUpdate; + } + + + /** + * Return the user id of the person who created the note. Null means the user id is not known. + * + * @return String user making notes + */ + public String getUser() { + return user; + } + + + /** + * Set up the user id of the person who created the note. Null means the user id is not known. + * + * @param user String user making notes + */ + public void setUser(String user) + { + this.user = user; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "NoteProperties{" + + "text='" + text + '\'' + + ", lastUpdate=" + lastUpdate + + ", user='" + user + '\'' + + ", qualifiedName='" + getQualifiedName() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", vendorProperties=" + getVendorProperties() + + ", typeName='" + getTypeName() + '\'' + + ", extendedProperties=" + getExtendedProperties() + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean 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; + } + NoteProperties note = (NoteProperties) objectToCompare; + return Objects.equals(getText(), note.getText()) && + Objects.equals(getLastUpdate(), note.getLastUpdate()) && + Objects.equals(getUser(), note.getUser()); + } + + + /** + * Hash of properties + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), getText(), getLastUpdate(), getUser()); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RatingProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RatingProperties.java new file mode 100644 index 00000000000..917946f660f --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RatingProperties.java @@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * RatingProperties stores information about a rating connected to an asset. Ratings provide informal feedback on the quality of assets + * and can be added at any time. + * + * Ratings have the userId of the person who added it, a star rating and an optional review comment. + * + * The content of the rating is a personal judgement (which is why the user's id is in the object) + * and there is no formal review of the ratings. However, they can be used as a basis for crowd-sourcing + * feedback to asset owners. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class RatingProperties extends FeedbackProperties +{ + @Serial + private static final long serialVersionUID = 1L; + + private StarRating starRating = null; + private String review = null; + private String user = null; + + /** + * Default constructor + */ + public RatingProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public RatingProperties(RatingProperties template) + { + super(template); + + if (template != null) + { + user = template.getUser(); + starRating = template.getStarRating(); + review = template.getReview(); + } + } + + + /** + * Return the user id of the person who created the rating. Null means the user id is not known. + * + * @return String user + */ + public String getUser() { + return user; + } + + + /** + * Set up the user id of the person who created the rating. Null means the user id is not known. + * + * @param user string + */ + public void setUser(String user) + { + this.user = user; + } + + + /** + * Return the stars for the rating. + * + * @return StarRating enum + */ + public StarRating getStarRating() { + return starRating; + } + + + /** + * Set up the stars for the rating. + * + * @param starRating StarRating enum + */ + public void setStarRating(StarRating starRating) + { + this.starRating = starRating; + } + + + /** + * Return the review comments - null means no review is available. + * + * @return String review comments + */ + public String getReview() + { + return review; + } + + + /** + * Set up the review comments - null means no review is available. + * + * @param review String review comments + */ + public void setReview(String review) + { + this.review = review; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "RatingProperties{" + + "starRating=" + starRating + + ", review='" + review + '\'' + + ", user='" + user + '\'' + + ", isPublic='" + getIsPublic() + '\'' + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean 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; + } + RatingProperties rating = (RatingProperties) objectToCompare; + return getStarRating() == rating.getStarRating() && + Objects.equals(getReview(), rating.getReview()) && + Objects.equals(getUser(), rating.getUser()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + int result = super.hashCode(); + result = 31 * result + (starRating != null ? starRating.hashCode() : 0); + result = 31 * result + (review != null ? review.hashCode() : 0); + result = 31 * result + (user != null ? user.hashCode() : 0); + return result; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/SecurityTagsProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/SecurityTagsProperties.java new file mode 100644 index 00000000000..f4180ffd9d9 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/SecurityTagsProperties.java @@ -0,0 +1,206 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * SecurityTagsProperties provides a structure for passing information about the security tags that should be + * attached to an asset or one of its fields. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class SecurityTagsProperties implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private List securityLabels = null; + private Map securityProperties = null; + private Map> accessGroups = null; + + + /** + * Default constructor + */ + public SecurityTagsProperties() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public SecurityTagsProperties(SecurityTagsProperties template) + { + if (template != null) + { + this.securityLabels = template.getSecurityLabels(); + this.securityProperties = template.getSecurityProperties(); + this.accessGroups = template.getAccessGroups(); + } + } + + /** + * Return the list of security labels that should be attached to this element. + * + * @return list of strings + */ + public List getSecurityLabels() + { + if (securityLabels == null) + { + return null; + } + else if (securityLabels.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(securityLabels); + } + } + + + /** + * Set up the list of security labels that should be attached to this element. + * + * @param securityLabels list of strings + */ + public void setSecurityLabels(List securityLabels) + { + this.securityLabels = securityLabels; + } + + + /** + * Return the security properties that should be attached to this element. + * + * @return map of property values + */ + public Map getSecurityProperties() + { + if (securityProperties == null) + { + return null; + } + else if (securityProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(securityProperties); + } + } + + + /** + * Set up the security properties that should be attached to this element. + * + * @param securityProperties map of property values + */ + public void setSecurityProperties(Map securityProperties) + { + this.securityProperties = securityProperties; + } + + + /** + * Return the map from operation to list of security groups. + * + * @return map + */ + public Map> getAccessGroups() + { + if (accessGroups == null) + { + return null; + } + if (accessGroups.isEmpty()) + { + return null; + } + return accessGroups; + } + + + /** + * Setup the map from operation to list of security groups. + * + * @param accessGroups map + */ + public void setAccessGroups(Map> accessGroups) + { + this.accessGroups = accessGroups; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "SecurityTagsProperties{" + + "securityLabels=" + securityLabels + + ", securityProperties=" + securityProperties + + ", accessGroups=" + accessGroups + + '}'; + } + + + /** + * Equals method that returns true if containing properties are the same. + * + * @param objectToCompare object to compare + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (! (objectToCompare instanceof SecurityTagsProperties that)) + { + return false; + } + return Objects.equals(securityLabels, that.securityLabels) && + Objects.equals(securityProperties, that.securityProperties) && + Objects.equals(accessGroups, that.accessGroups); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(securityLabels, securityProperties, accessGroups); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/StarRating.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/StarRating.java new file mode 100644 index 00000000000..9a3983d10b1 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/StarRating.java @@ -0,0 +1,136 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * A StarRating defines the rating that a user has placed against an asset. This ranges from not recommended + * through to five stars (excellent). + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum StarRating implements Serializable +{ + NO_RECOMMENDATION (0, 0, "X", "No recommendation"), + ONE_STAR (1, 1, "*", "Poor"), + TWO_STARS (2, 2, "**", "Usable"), + THREE_STARS (3, 3, "***", "Good"), + FOUR_STARS (4, 4, "****", "Very Good"), + FIVE_STARS (5, 5, "*****", "Excellent"); + + public static final String ENUM_TYPE_GUID = "77fea3ef-6ec1-4223-8408-38567e9d3c93"; + public static final String ENUM_TYPE_NAME = "StarRating"; + + private final int openTypeOrdinal; + + private final int ordinal; + private final String name; + private final String description; + + private static final long serialVersionUID = 1L; + + + /** + * Constructor to set up the instance of this enum. + * + * @param ordinal code number + * @param openTypeOrdinal code number from the equivalent Enum Type + * @param name default name + * @param description default description + */ + StarRating(int ordinal, + int openTypeOrdinal, + String name, + String description) + { + this.ordinal = ordinal; + this.openTypeOrdinal = openTypeOrdinal; + this.name = name; + this.description = description; + } + + + /** + * Return the code for this enum instance + * + * @return int star rating code + */ + public int getOrdinal() + { + return ordinal; + } + + + /** + * Return the default symbol for this enum instance. + * + * @return String default symbol + */ + public String getName() + { + return name; + } + + + /** + * Return the default description for the star rating for this enum instance. + * + * @return String default description + */ + public String getDescription() + { + return description; + } + + + /** + * Return the code for this enum that comes from the Open Metadata Type that this enum represents. + * + * @return int code number + */ + public int getOpenTypeOrdinal() + { + return openTypeOrdinal; + } + + + /** + * Return the unique identifier for the open metadata enum type that this enum class represents. + * + * @return string guid + */ + public String getOpenTypeGUID() { return ENUM_TYPE_GUID; } + + + /** + * Return the unique name for the open metadata enum type that this enum class represents. + * + * @return string name + */ + public String getOpenTypeName() { return ENUM_TYPE_NAME; } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "StarRating{" + + "starRatingCode=" + ordinal + + ", starRatingSymbol='" + name + '\'' + + ", starRatingDescription='" + description + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/TagProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/TagProperties.java new file mode 100644 index 00000000000..77a46478181 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/TagProperties.java @@ -0,0 +1,195 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * InformalTagProperties stores information about a tag connected to an asset. + * InformalTags provide informal classifications to assets + * and can be added at any time. + * + * InformalTags have the userId of the person who added the tag, the name of the tag and its description. + * + * The content of the tag is a personal judgement (which is why the user's id is in the tag) + * and there is no formal review of the tags. However, they can be used as a basis for crowd-sourcing + * Glossary terms. + * + * Private InformalTags are only returned to the user that created them. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class TagProperties implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private boolean isPrivateTag = false; + private String name = null; + private String description = null; + + + /** + * Default constructor + */ + public TagProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public TagProperties(TagProperties template) + { + if (template != null) + { + isPrivateTag = template.getIsPrivateTag(); + name = template.getName(); + description = template.getDescription(); + } + } + + + /** + * Return boolean flag to say whether the tag is private or not. A private tag is only seen by the + * person who set it up. Public tags are visible to everyone. + * + * @return boolean is private flag + */ + public boolean getIsPrivateTag() { + return isPrivateTag; + } + + + /** + * Set up boolean flag to say whether the tag is private or not. A private tag is only seen by the + * person who set it up. Public tags are visible to everyone. + * + * @param privateTag indicator of a private tag + */ + public void setIsPrivateTag(boolean privateTag) + { + isPrivateTag = privateTag; + } + + + /** + * Return the name of the tag. It is not valid to have a tag with no name. However, there is a point where + * the tag object is created and the tag name not yet set, so null is a possible response. + * + * @return String tag name + */ + public String getName() { + return name; + } + + + /** + * Set up the name of the tag. It is not valid to have a tag with no name. However, there is a point where + * the tag object is created and the tag name not yet set, so null is a possible response. + * + * @param name String tag name + */ + public void setName(String name) + { + this.name = name; + } + + + /** + * Return the tag description null means no description is available. + * + * @return String tag description + */ + public String getDescription() + { + return description; + } + + + /** + * Set up the tag description null means no description is available. + * + * @param tagDescription tag description + */ + public void setDescription(String tagDescription) { + this.description = tagDescription; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "TagProperties{" + + "isPrivateTag=" + isPrivateTag + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (! (objectToCompare instanceof TagProperties)) + { + return false; + } + + TagProperties that = (TagProperties) objectToCompare; + + if (isPrivateTag != that.isPrivateTag) + { + return false; + } + if (name != null ? ! name.equals(that.name) : that.name != null) + { + return false; + } + return description != null ? description.equals(that.description) : that.description == null; + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + int result = (isPrivateTag ? 1 : 0); + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + return result; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ArchiveRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ArchiveRequestBody.java new file mode 100644 index 00000000000..2b1c33dd8fa --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ArchiveRequestBody.java @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ArchiveProperties; + +import java.io.Serial; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * ArchiveRequestBody describes the request body used to create/update connection properties. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ArchiveRequestBody extends UpdateRequestBody +{ + @Serial + private static final long serialVersionUID = 1L; + + private ArchiveProperties elementProperties = null; + + + /** + * Default constructor + */ + public ArchiveRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template object to copy + */ + public ArchiveRequestBody(ArchiveRequestBody template) + { + super(template); + + if (template != null) + { + elementProperties = template.getElementProperties(); + } + } + + + /** + * Return the properties for the element. + * + * @return properties object + */ + public ArchiveProperties getElementProperties() + { + return elementProperties; + } + + + /** + * Set up the properties for the element. + * + * @param elementProperties properties object + */ + public void setElementProperties(ArchiveProperties elementProperties) + { + this.elementProperties = elementProperties; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ArchiveRequestBody{" + + "elementProperties=" + elementProperties + + ", metadataCorrelationProperties=" + getMetadataCorrelationProperties() + + ", effectiveTime=" + getEffectiveTime() + + '}'; + } + + + /** + * 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; + } + ArchiveRequestBody that = (ArchiveRequestBody) objectToCompare; + return Objects.equals(elementProperties, that.elementProperties); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), elementProperties); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementResponse.java new file mode 100644 index 00000000000..5918d1b3db0 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementResponse.java @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.CommentElement; + +import java.io.Serial; +import java.util.Arrays; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * CommentElementResponse is the response structure used on the OMAS REST API calls that return the properties for an element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CommentElementResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private CommentElement element = null; + + + /** + * Default constructor + */ + public CommentElementResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CommentElementResponse(CommentElementResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return bean + */ + public CommentElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element bean + */ + public void setElement(CommentElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CommentElementResponse{" + + "element=" + element + + ", 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 instanceof CommentElementResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + CommentElementResponse that = (CommentElementResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(element); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementsResponse.java new file mode 100644 index 00000000000..a85fb11b8f8 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/CommentElementsResponse.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.CommentElement; + +import java.io.Serial; +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; + +/** + * CommentElementsResponse 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 CommentElementsResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private List elementList = null; + + + /** + * Default constructor + */ + public CommentElementsResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CommentElementsResponse(CommentElementsResponse 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 "CommentElementsResponse{" + + "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; + } + CommentElementsResponse that = (CommentElementsResponse) 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/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ConnectionRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ConnectionRequestBody.java index 0b85f06ce69..acd1bf71bcf 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ConnectionRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ConnectionRequestBody.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.ConnectionProperties; +import java.io.Serial; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -22,7 +23,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class ConnectionRequestBody extends UpdateRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private ConnectionProperties elementProperties = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ControlledGlossaryTermRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ControlledGlossaryTermRequestBody.java index f61645e7e5e..1b702ba558d 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ControlledGlossaryTermRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ControlledGlossaryTermRequestBody.java @@ -10,6 +10,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermStatus; import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -25,7 +26,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class ControlledGlossaryTermRequestBody implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private MetadataCorrelationProperties metadataCorrelationProperties = null; private GlossaryTermProperties elementProperties = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java index 039fac966a0..65f2662f7ff 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.util.Date; import java.util.Objects; @@ -20,7 +21,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class EffectiveTimeQueryRequestBody extends AssetManagerIdentifiersRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private Date effectiveTime = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryCategoryRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryCategoryRequestBody.java index fe3fa67cc08..b5d8caa7d8e 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryCategoryRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryCategoryRequestBody.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryCategoryProperties; +import java.io.Serial; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -22,7 +23,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryCategoryRequestBody extends UpdateRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private GlossaryCategoryProperties elementProperties = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryElementsResponse.java index 2fb260fbbef..ce16fc0f95f 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryElementsResponse.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryElementsResponse.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryElement; +import java.io.Serial; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -17,7 +18,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** - * GlossaryElementsResponse is a response object for passing back a a list of glossaries + * GlossaryElementsResponse is a response object for passing back a list of glossaries * or an exception if the request failed. */ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @@ -25,7 +26,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryElementsResponse extends AssetManagerOMASAPIResponse { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private List elementList = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryNameRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryNameRequestBody.java new file mode 100644 index 00000000000..cd7609fd8f5 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryNameRequestBody.java @@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermStatus; + +import java.io.Serial; +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; + + +/** + * GlossaryNameRequestBody is the request body structure used on Glossary REST API calls that passes a name that is used to retrieve + * an element by name. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class GlossaryNameRequestBody extends NameRequestBody +{ + @Serial + private static final long serialVersionUID = 1L; + + private String glossaryGUID = null; + private List limitResultsByStatus = null; + + /** + * Default constructor + */ + public GlossaryNameRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public GlossaryNameRequestBody(GlossaryNameRequestBody template) + { + super(template); + + if (template != null) + { + glossaryGUID = template.getGlossaryGUID(); + limitResultsByStatus = template.getLimitResultsByStatus(); + } + } + + + /** + * Return the unique identifier of the glossary scope. + * + * @return string guid + */ + public String getGlossaryGUID() + { + return glossaryGUID; + } + + + /** + * Set up the unique identifier of the glossary scope. + * + * @param glossaryGUID string + */ + public void setGlossaryGUID(String glossaryGUID) + { + this.glossaryGUID = glossaryGUID; + } + + + /** + * Return the list of statuses to return (null for all). + * + * @return list of statuses (terms only) + */ + public List getLimitResultsByStatus() + { + return limitResultsByStatus; + } + + + /** + * Set up the list of statuses to return (null for all). + * + * @param limitResultsByStatus list of statuses (terms only) + */ + public void setLimitResultsByStatus(List limitResultsByStatus) + { + this.limitResultsByStatus = limitResultsByStatus; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "GlossaryNameRequestBody{" + + "glossaryGUID='" + glossaryGUID + '\'' + + ", limitResultsByStatus='" + limitResultsByStatus + '\'' + + ", name='" + getName() + '\'' + + ", nameParameterName='" + getNameParameterName() + '\'' + + ", effectiveTime=" + getEffectiveTime() + + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + + ", assetManagerName='" + getAssetManagerName() + '\'' + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean 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; + } + GlossaryNameRequestBody that = (GlossaryNameRequestBody) objectToCompare; + return Objects.equals(glossaryGUID, that.glossaryGUID) && + Objects.equals(limitResultsByStatus, that.limitResultsByStatus); + } + + + /** + * Create a hash code for this element type. + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), glossaryGUID, limitResultsByStatus); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryRequestBody.java index d2c638f6525..b22e7941847 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryRequestBody.java @@ -9,6 +9,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryProperties; import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -24,7 +25,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryRequestBody implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private MetadataCorrelationProperties metadataCorrelationProperties = null; private GlossaryProperties elementProperties = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossarySearchStringRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossarySearchStringRequestBody.java new file mode 100644 index 00000000000..6a709808daa --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossarySearchStringRequestBody.java @@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermStatus; + +import java.io.Serial; +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; + + +/** + * GlossarySearchStringRequestBody is the request body structure used on GlossaryCategory/Term REST API calls that passes a regular expression + * to use as a search string and the scope of the results can be optionally restricted by glossary. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class GlossarySearchStringRequestBody extends SearchStringRequestBody +{ + @Serial + private static final long serialVersionUID = 1L; + + private String glossaryGUID = null; + private List limitResultsByStatus = null; + + /** + * Default constructor + */ + public GlossarySearchStringRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public GlossarySearchStringRequestBody(GlossarySearchStringRequestBody template) + { + super(template); + + if (template != null) + { + glossaryGUID = template.getGlossaryGUID(); + limitResultsByStatus = template.getLimitResultsByStatus(); + } + } + + + /** + * Return the unique identifier of the glossary scope. + * + * @return string guid + */ + public String getGlossaryGUID() + { + return glossaryGUID; + } + + + /** + * Set up the unique identifier of the glossary scope. + * + * @param glossaryGUID string + */ + public void setGlossaryGUID(String glossaryGUID) + { + this.glossaryGUID = glossaryGUID; + } + + + /** + * Return the list of statuses to return (null for all). + * + * @return list of statuses (terms only) + */ + public List getLimitResultsByStatus() + { + return limitResultsByStatus; + } + + + /** + * Set up the list of statuses to return (null for all). + * + * @param limitResultsByStatus list of statuses (terms only) + */ + public void setLimitResultsByStatus(List limitResultsByStatus) + { + this.limitResultsByStatus = limitResultsByStatus; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "GlossarySearchStringRequestBody{" + + "glossaryGUID='" + glossaryGUID + '\'' + + ", limitResultsByStatus=" + limitResultsByStatus + + ", searchString='" + getSearchString() + '\'' + + ", searchStringParameterName='" + getSearchStringParameterName() + '\'' + + ", effectiveTime=" + getEffectiveTime() + + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + + ", assetManagerName='" + getAssetManagerName() + '\'' + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean 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; + } + GlossarySearchStringRequestBody that = (GlossarySearchStringRequestBody) objectToCompare; + return Objects.equals(glossaryGUID, that.glossaryGUID) && + Objects.equals(limitResultsByStatus, that.limitResultsByStatus); + } + + + /** + * Create a hash code for this element type. + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), glossaryGUID, limitResultsByStatus); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermElementsResponse.java index b3ae2ddc19f..55e06c1ab71 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermElementsResponse.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermElementsResponse.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; +import java.io.Serial; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -25,7 +26,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryTermElementsResponse extends AssetManagerOMASAPIResponse { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private List elementList = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermStatusRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermStatusRequestBody.java index 28bb1ccc94a..c00b04d81aa 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermStatusRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/GlossaryTermStatusRequestBody.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermStatus; +import java.io.Serial; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -22,7 +23,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GlossaryTermStatusRequestBody extends UpdateRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private GlossaryTermStatus glossaryTermStatus = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/HistoryRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/HistoryRequestBody.java new file mode 100644 index 00000000000..b3bfc5c5964 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/HistoryRequestBody.java @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.util.Date; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * HistoryRequestBody describes the start and stop time of the historical query. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class HistoryRequestBody extends EffectiveTimeQueryRequestBody +{ + @Serial + private static final long serialVersionUID = 1L; + + private Date fromTime = null; + private Date toTime = null; + + + /** + * Default constructor + */ + public HistoryRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public HistoryRequestBody(HistoryRequestBody template) + { + super(template); + + if (template != null) + { + fromTime = template.getFromTime(); + toTime = template.getToTime(); + } + } + + + /** + * Return the starting date/time to use for the query. + * + * @return date object + */ + public Date getFromTime() + { + return fromTime; + } + + + /** + * Set up the starting date/time to use for the query. + * + * @param fromTime date object + */ + public void setFromTime(Date fromTime) + { + this.fromTime = fromTime; + } + + /** + * Return the ending date/time to use for the query. + * + * @return date object + */ + public Date getToTime() + { + return toTime; + } + + /** + * Set up the engine date/time to use for the query. + * + * @param toTime date object + */ + public void setToTime(Date toTime) + { + this.toTime = toTime; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "HistoryRequestBody{" + + "fromTime=" + fromTime + + ", toTime=" + toTime + + ", effectiveTime=" + getEffectiveTime() + + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + + ", assetManagerName='" + getAssetManagerName() + '\'' + + '}'; + } + + + /** + * 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; + } + HistoryRequestBody that = (HistoryRequestBody) objectToCompare; + return Objects.equals(fromTime, that.fromTime) && + Objects.equals(toTime, that.toTime); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), fromTime, toTime); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagResponse.java new file mode 100644 index 00000000000..7d5a54ee167 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagResponse.java @@ -0,0 +1,145 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.InformalTagElement; + +import java.util.Arrays; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * InformalTagResponse is the response structure used on the Asset Consumer OMAS REST API calls that returns a + * Tag object as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class InformalTagResponse extends AssetManagerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private InformalTagElement tag = null; + + /** + * Default constructor + */ + public InformalTagResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public InformalTagResponse(InformalTagResponse template) + { + super(template); + + if (template != null) + { + this.tag = template.getTag(); + } + } + + + /** + * Return the Tag object. + * + * @return tag + */ + public InformalTagElement getTag() + { + if (tag == null) + { + return null; + } + else + { + return new InformalTagElement(tag); + } + } + + + /** + * Set up the Tag object. + * + * @param tag tag object + */ + public void setTag(InformalTagElement tag) + { + this.tag = tag; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "InformalTagResponse{" + + "tag=" + tag + + ", 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; + } + InformalTagResponse that = (InformalTagResponse) objectToCompare; + return Objects.equals(getTag(), that.getTag()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), getTag()); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagUpdateRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagUpdateRequestBody.java new file mode 100644 index 00000000000..87dd59a458d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagUpdateRequestBody.java @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serial; +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * InformalTagProperties stores information about a tag connected to an asset. + * InformalTags provide informal classifications to assets + * and can be added at any time. + * + * InformalTags have the userId of the person who added the tag, the name of the tag and its description. + * + * The content of the tag is a personal judgement (which is why the user's id is in the tag) + * and there is no formal review of the tags. However, they can be used as a basis for crowd-sourcing + * Glossary terms. + * + * Private InformalTags are only returned to the user that created them. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class InformalTagUpdateRequestBody implements Serializable +{ + @Serial + private static final long serialVersionUID = 1L; + + private String description = null; + + + /** + * Default constructor + */ + public InformalTagUpdateRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public InformalTagUpdateRequestBody(InformalTagUpdateRequestBody template) + { + if (template != null) + { + description = template.getDescription(); + } + } + + + /** + * Return the tag description null means no description is available. + * + * @return String tag description + */ + public String getDescription() + { + return description; + } + + + /** + * Set up the tag description null means no description is available. + * + * @param tagDescription tag description + */ + public void setDescription(String tagDescription) { + this.description = tagDescription; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "InformalTagUpdateRequestBody{" + + "description='" + description + '\'' + + '}'; + } + + + /** + * Compare the values of the supplied object with those stored in the current object. + * + * @param objectToCompare supplied object + * @return boolean result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (! (objectToCompare instanceof InformalTagUpdateRequestBody)) + { + return false; + } + + InformalTagUpdateRequestBody that = (InformalTagUpdateRequestBody) objectToCompare; + + return description != null ? description.equals(that.description) : that.description == null; + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return description != null ? description.hashCode() : 0; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagsResponse.java new file mode 100644 index 00000000000..dc74eb04763 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/InformalTagsResponse.java @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.InformalTagElement; + +import java.io.Serial; +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; + +/** + * InformalTagsResponse returns a list of tags from the server. The list may be too long to + * retrieve in a single call so there is support for paging of replies. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class InformalTagsResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private List tags = null; + + + /** + * Default constructor + */ + public InformalTagsResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public InformalTagsResponse(InformalTagsResponse template) + { + super(template); + + if (template != null) + { + this.tags = template.getTags(); + } + } + + + /** + * Return the list of informal tags in the response. + * + * @return list of informal tags + */ + public List getTags() + { + if (tags == null) + { + return null; + } + else if (tags.isEmpty()) + { + return null; + } + else + { + List clonedList = new ArrayList<>(); + + for (InformalTagElement existingElement : tags) + { + clonedList.add(new InformalTagElement(existingElement)); + } + + return clonedList; + } + } + + + /** + * Set up the list of informal tags for the response. + * + * @param tags list + */ + public void setTags(List tags) + { + this.tags = tags; + } + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "InformalTagsResponse{" + + "tags=" + tags + + ", 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; + } + InformalTagsResponse that = (InformalTagsResponse) objectToCompare; + return Objects.equals(getTags(), that.getTags()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), getTags()); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementResponse.java new file mode 100644 index 00000000000..98b03bd9ec5 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementResponse.java @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.LikeElement; + +import java.io.Serial; +import java.util.Arrays; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * LikeElementResponse is the response structure used on the OMAS REST API calls that return the properties for an element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LikeElementResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private LikeElement element = null; + + + /** + * Default constructor + */ + public LikeElementResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LikeElementResponse(LikeElementResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return bean + */ + public LikeElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element bean + */ + public void setElement(LikeElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LikeElementResponse{" + + "element=" + element + + ", 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 instanceof LikeElementResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + LikeElementResponse that = (LikeElementResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(element); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementsResponse.java new file mode 100644 index 00000000000..b31e0da59a6 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/LikeElementsResponse.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.LikeElement; + +import java.io.Serial; +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 AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + 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/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java index 7428328a1fa..f66e5b8d9ed 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -22,7 +23,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class NameRequestBody extends EffectiveTimeQueryRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private String name = null; private String nameParameterName = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementResponse.java new file mode 100644 index 00000000000..200ece4733d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementResponse.java @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.NoteElement; + +import java.io.Serial; +import java.util.Arrays; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * NoteElementResponse is the response structure used on the OMAS REST API calls that return the properties for an element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class NoteElementResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private NoteElement element = null; + + + /** + * Default constructor + */ + public NoteElementResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public NoteElementResponse(NoteElementResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return bean + */ + public NoteElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element bean + */ + public void setElement(NoteElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "NoteElementResponse{" + + "element=" + element + + ", 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 instanceof NoteElementResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + NoteElementResponse that = (NoteElementResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(element); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementsResponse.java new file mode 100644 index 00000000000..221df82db2d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteElementsResponse.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.NoteElement; + +import java.io.Serial; +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; + +/** + * NoteElementsResponse 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 NoteElementsResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private List elementList = null; + + + /** + * Default constructor + */ + public NoteElementsResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public NoteElementsResponse(NoteElementsResponse 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 "NoteElementsResponse{" + + "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; + } + NoteElementsResponse that = (NoteElementsResponse) 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/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementResponse.java new file mode 100644 index 00000000000..e8ef4f28a7c --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementResponse.java @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.NoteLogElement; + +import java.io.Serial; +import java.util.Arrays; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * NoteLogElementResponse is the response structure used on the OMAS REST API calls that return the properties for an element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class NoteLogElementResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private NoteLogElement element = null; + + + /** + * Default constructor + */ + public NoteLogElementResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public NoteLogElementResponse(NoteLogElementResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return bean + */ + public NoteLogElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element bean + */ + public void setElement(NoteLogElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "NoteLogElementResponse{" + + "element=" + element + + ", 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 instanceof NoteLogElementResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + NoteLogElementResponse that = (NoteLogElementResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(element); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementsResponse.java new file mode 100644 index 00000000000..a1543fb6a0d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NoteLogElementsResponse.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.NoteLogElement; + +import java.io.Serial; +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; + +/** + * NoteLogElementsResponse 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 NoteLogElementsResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private List elementList = null; + + + /** + * Default constructor + */ + public NoteLogElementsResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public NoteLogElementsResponse(NoteLogElementsResponse 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 "NoteLogElementsResponse{" + + "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; + } + NoteLogElementsResponse that = (NoteLogElementsResponse) 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/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementResponse.java new file mode 100644 index 00000000000..68cb01f1080 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementResponse.java @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.RatingElement; + +import java.io.Serial; +import java.util.Arrays; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * RatingElementResponse is the response structure used on the OMAS REST API calls that return the properties for an element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class RatingElementResponse extends AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + private RatingElement element = null; + + + /** + * Default constructor + */ + public RatingElementResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public RatingElementResponse(RatingElementResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return bean + */ + public RatingElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element bean + */ + public void setElement(RatingElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "RatingElementResponse{" + + "element=" + element + + ", 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 instanceof RatingElementResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + RatingElementResponse that = (RatingElementResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(element); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementsResponse.java new file mode 100644 index 00000000000..b7e4a4d6fa0 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/RatingElementsResponse.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.RatingElement; + +import java.io.Serial; +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 AssetManagerOMASAPIResponse +{ + @Serial + private static final long serialVersionUID = 1L; + + 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/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementResponse.java index d145dc537c4..03e3e46ba12 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementResponse.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementResponse.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.SchemaTypeElement; +import java.io.Serial; import java.util.Arrays; import java.util.Objects; @@ -16,15 +17,15 @@ /** - * SchemaTypeElementResponse is the response structure used on the OMAS REST API calls that return the properties - * for a element. + * SchemaTypeElementResponse is the response structure used on the OMAS REST API calls that return the properties for an element. */ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) public class SchemaTypeElementResponse extends AssetManagerOMASAPIResponse { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private SchemaTypeElement element = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementsResponse.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementsResponse.java index 16ca4848b00..e596dac4fc4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementsResponse.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SchemaTypeElementsResponse.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.SchemaTypeElement; +import java.io.Serial; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -17,15 +18,15 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** - * SchemaTypeElementsResponse is a response object for passing back a a list of glossaries - * or an exception if the request failed. + * SchemaTypeElementsResponse 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 SchemaTypeElementsResponse extends AssetManagerOMASAPIResponse { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private List elementList = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java index be130bfa6c4..d26fde8918f 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import java.io.Serializable; +import java.io.Serial; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -22,7 +22,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class SearchStringRequestBody extends EffectiveTimeQueryRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private String searchString = null; private String searchStringParameterName = null; @@ -49,6 +50,7 @@ public SearchStringRequestBody(SearchStringRequestBody template) if (template != null) { searchString = template.getSearchString(); + searchStringParameterName = template.getSearchStringParameterName(); } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TaxonomyClassificationRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TaxonomyClassificationRequestBody.java index 25edcf8f3e4..5cd6306fd06 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TaxonomyClassificationRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TaxonomyClassificationRequestBody.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -27,7 +28,8 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class TaxonomyClassificationRequestBody implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private MetadataCorrelationProperties metadataCorrelationProperties = null; private String organizingPrinciple = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TemplateRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TemplateRequestBody.java index 6eaf4699595..6cce32f9ef4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TemplateRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TemplateRequestBody.java @@ -9,6 +9,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; import org.odpi.openmetadata.accessservices.assetmanager.properties.TemplateProperties; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -24,7 +25,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class TemplateRequestBody extends UpdateRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private TemplateProperties elementProperties = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TermRelationshipRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TermRelationshipRequestBody.java index 7db43aa73c5..3b34d843520 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TermRelationshipRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/TermRelationshipRequestBody.java @@ -9,6 +9,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermCategorization; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermRelationship; +import java.io.Serial; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -23,7 +24,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class TermRelationshipRequestBody extends AssetManagerIdentifiersRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private GlossaryTermRelationship properties = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/UpdateRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/UpdateRequestBody.java index 417da2b184a..30b224cf8a7 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/UpdateRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/UpdateRequestBody.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import java.io.Serial; import java.io.Serializable; import java.util.Date; import java.util.Objects; @@ -22,7 +23,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class UpdateRequestBody implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private MetadataCorrelationProperties metadataCorrelationProperties = null; private Date effectiveTime = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/CollaborationExchangeClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/CollaborationExchangeClient.java index b27a6ef460e..dc1a9320e6d 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/CollaborationExchangeClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/CollaborationExchangeClient.java @@ -5,15 +5,38 @@ import org.odpi.openmetadata.accessservices.assetmanager.api.CollaborationExchangeInterface; import org.odpi.openmetadata.accessservices.assetmanager.client.rest.AssetManagerRESTClient; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.CommentElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.InformalTagElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.FeedbackProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.LikeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RatingProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.TagProperties; +import org.odpi.openmetadata.accessservices.assetmanager.rest.CommentElementResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.CommentElementsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagUpdateRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagsResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDListResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; + +import java.util.List; /** - * DataAssetExchangeClient is the client for managing comments, ratings, likes and tags. + * DataElementExchangeClient is the client for managing comments, ratings, likes and tags. */ public class CollaborationExchangeClient extends ExchangeClientBase implements CollaborationExchangeInterface { + static final NullRequestBody nullRequestBody = new NullRequestBody(); + /** * Create a new client with no authentication embedded in the HTTP request. * @@ -108,4 +131,880 @@ public CollaborationExchangeClient(String serverName, { super(serverName, serverPlatformURLRoot, userId, password); } + + + /** + * Adds a star rating and optional review text to the element. If the user has already attached + * a rating then the original one is over-ridden. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element. + * @param properties properties of the rating + * @return unique identifier of the rating + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public String addRatingToElement(String userId, + String elementGUID, + RatingProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "addRatingToElement"; + final String guidParameter = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/ratings"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameter, methodName); + + GUIDResponse response = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + properties, + serverName, + userId, + elementGUID); + + return response.getGUID(); + } + + + /** + * Removes of a review that was added to the element by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the attached element. + * + * @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 requesting user is not authorized to issue this request. + */ + @Override + public void removeRatingFromElement(String userId, + String elementGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "removeRatingFromElement"; + final String guidParameter = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/ratings/remove"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + nullRequestBody, + serverName, + userId, + elementGUID); + } + + + /** + * Adds a "LikeProperties" to the element. + * + * @param userId userId of user making request + * @param elementGUID unique identifier for the element + * @param properties indicates whether the feedback should be shared or only be visible to the originating user + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public void addLikeToElement(String userId, + String elementGUID, + LikeProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "addLikeToElement"; + final String guidParameter = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/likes"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + properties, + serverName, + userId, + elementGUID); + } + + + /** + * Removes a "LikeProperties" added to the element by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the like object. + * + * @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 requesting user is not authorized to issue this request. + */ + @Override + public void removeLikeFromElement(String userId, + String elementGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "removeLikeFromElement"; + final String guidParameter = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/likes/remove"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + nullRequestBody, + serverName, + userId, + elementGUID); + } + + + /** + * Adds a comment to the element. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element. + * @param properties properties of the comment + * + * @return guid of new comment. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public String addCommentToElement(String userId, + String elementGUID, + CommentProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "addCommentToElement"; + final String guidParameter = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/comments"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameter, methodName); + + GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + properties, + serverName, + userId, + elementGUID); + + return restResult.getGUID(); + } + + + /** + * Adds a comment to another comment. + * + * @param userId userId of user making request. + * @param elementGUID String - unique id of element that this chain of comments is linked. + * @param commentGUID unique identifier for an existing comment. Used to add a reply to a comment. + * @param properties properties of the comment + * + * @return guid of new comment. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public String addCommentReply(String userId, + String elementGUID, + String commentGUID, + CommentProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "addCommentReply"; + final String commentGUIDParameter = "commentGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/comments/{2}/replies"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(commentGUID, commentGUIDParameter, methodName); + + GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + properties, + serverName, + userId, + commentGUID); + + return restResult.getGUID(); + } + + + /** + * Update an existing comment. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element that the comment is attached to (directly or indirectly). + * @param commentGUID unique identifier for the comment to change. + * @param properties comment properties + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public void updateComment(String userId, + String elementGUID, + String commentGUID, + CommentProperties properties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "updateComment"; + final String elementGUIDParameter = "elementGUID"; + final String commentGUIDParameter = "commentGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/comments/{3}/update"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameter, methodName); + invalidParameterHandler.validateGUID(commentGUID, commentGUIDParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + properties, + serverName, + userId, + elementGUID, + commentGUID); + } + + + /** + * Removes a comment added to the element by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element object. + * @param commentGUID unique identifier for the comment object. + * + * @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. + */ + @Override + public void removeComment(String userId, + String elementGUID, + String commentGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "removeComment"; + final String elementGUIDParameter = "elementGUID"; + final String commentGUIDParameter = "commentGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/comments/{3}/remove"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameter, methodName); + invalidParameterHandler.validateGUID(commentGUID, commentGUIDParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + nullRequestBody, + serverName, + userId, + elementGUID, + commentGUID); + } + + + /** + * Return the requested comment. + * + * @param userId userId of user making request. + * @param commentGUID unique identifier for the comment object. + * @return comment properties + * @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. + */ + @Override + public CommentElement getComment(String userId, + String commentGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getComment"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/comments/{2}"; + final String guidParameter = "commentGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(commentGUID, guidParameter, methodName); + + CommentElementResponse restResult = restClient.callCommentElementGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + commentGUID); + + return restResult.getElement(); + } + + + /** + * Return the comments 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. + * @return list of comments + * @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. + */ + @Override + public List getAttachedComments(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getAttachedComments"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/comments?startFrom={3}&pageSize={4}"; + final String guidParameter = "elementGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameter, methodName); + + CommentElementsResponse restResult = restClient.callCommentElementsGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + elementGUID, + startFrom, + pageSize); + + return restResult.getElementList(); + } + + + /** + * Creates a new informal tag and returns the unique identifier for it. + * + * @param isPublic Flg to indicate whether the tag is a public or private tag. + * @param methodName name of calling method. + * @param userId userId of user making request. + * @param tagName name of the tag. + * @param tagDescription (optional) description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @return GUID for new tag. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + private String createTag(boolean isPublic, + String methodName, + String userId, + String tagName, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags"; + + invalidParameterHandler.validateUserId(userId, methodName); + + TagProperties tagProperties = new TagProperties(); + tagProperties.setIsPrivateTag(! isPublic); + tagProperties.setName(tagName); + tagProperties.setDescription(tagDescription); + + GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + tagProperties, + serverName, + userId); + + return restResult.getGUID(); + } + + + /** + * Creates a new public informal tag and returns the unique identifier for it. + * + * @param userId userId of user making request. + * @param tagName name of the tag. + * @param tagDescription (optional) description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @return GUID for new tag. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public String createPublicTag(String userId, + String tagName, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "createPublicTag"; + + return this.createTag(true, methodName, userId, tagName, tagDescription); + } + + + /** + * Creates a new private informal tag and returns the unique identifier for it. + * + * @param userId userId of user making request. + * @param tagName name of the tag. + * @param tagDescription (optional) description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @return GUID for new tag. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public String createPrivateTag(String userId, + String tagName, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "createPrivateTag"; + + return this.createTag(false, methodName, userId, tagName, tagDescription); + } + + + /** + * Updates the description of an existing tag (either private or public). + * + * @param userId userId of user making request. + * @param tagGUID unique identifier for the tag. + * @param tagDescription description of the tag. Setting a description, particularly in a public tag + * makes the tag more valuable to other users and can act as an embryonic glossary term. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public void updateTagDescription(String userId, + String tagGUID, + String tagDescription) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "updateTagDescription"; + final String guidParameter = "tagGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/{2}/update"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(tagGUID, guidParameter, methodName); + + InformalTagUpdateRequestBody tagRequestBody = new InformalTagUpdateRequestBody(); + tagRequestBody.setDescription(tagDescription); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + tagRequestBody, + serverName, + userId, + tagGUID); + } + + + /** + * Removes a tag from the repository. + * A private tag can be deleted by its creator and all the references are lost; + * a public tag can be deleted by anyone, but only if it is not attached to any referenceable. + * + * @param userId userId of user making request. + * @param tagGUID unique id for the tag. + * + * @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 requesting user is not authorized to issue this request. + */ + @Override + public void deleteTag(String userId, + String tagGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "deleteTag"; + final String guidParameter = "tagGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/{2}/remove"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(tagGUID, guidParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + nullRequestBody, + serverName, + userId, + tagGUID); + } + + + /** + * Return the tag for the supplied unique identifier (guid). + * + * @param userId userId of the user making the request. + * @param guid unique identifier of the tag. + * + * @return tag + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public InformalTagElement getTag(String userId, + String guid) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getTag"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/{2}"; + final String guidParameter = "guid"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(guid, guidParameter, methodName); + + InformalTagResponse restResult = restClient.callInformalTagGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + guid); + + return restResult.getTag(); + } + + + /** + * Return the list of tags exactly matching the supplied name. + * + * @param userId the name of the calling user. + * @param tag name of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public List getTagsByName(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getTagsByName"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/by-name?startFrom={2}&pageSize={3}"; + final String nameParameter = "tag"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(tag, nameParameter, methodName); + + NameRequestBody requestBody = new NameRequestBody(); + + requestBody.setName(tag); + requestBody.setNameParameterName(nameParameter); + + InformalTagsResponse restResult = restClient.callInformalTagListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + pageSize); + + return restResult.getTags(); + } + + + /** + * Return the list of the calling user's private tags exactly matching the supplied name. + * + * @param userId the name of the calling user. + * @param tag name of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public List getMyTagsByName(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getTagsByName"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/private/by-name?startFrom={2}&pageSize={3}"; + final String nameParameter = "tag"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(tag, nameParameter, methodName); + + NameRequestBody requestBody = new NameRequestBody(); + + requestBody.setName(tag); + requestBody.setNameParameterName(nameParameter); + + InformalTagsResponse restResult = restClient.callInformalTagListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + pageSize); + + return restResult.getTags(); + } + + + /** + * Return the list of tags containing the supplied string in either the name or description. + * + * @param userId the name of the calling user. + * @param tag name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public List findTags(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "findTags"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/by-search-string?startFrom={2}&pageSize={3}"; + final String nameParameter = "tag"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(tag, nameParameter, methodName); + + SearchStringRequestBody requestBody = new SearchStringRequestBody(); + + requestBody.setSearchString(tag); + requestBody.setSearchStringParameterName(nameParameter); + + InformalTagsResponse restResult = restClient.callInformalTagListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + pageSize); + + return restResult.getTags(); + } + + + /** + * Return the list of the calling user's private tags containing the supplied string in either the name or description. + * + * @param userId the name of the calling user. + * @param tag name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public List findMyTags(String userId, + String tag, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "findTags"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/tags/private/by-search-string?startFrom={2}&pageSize={3}"; + final String nameParameter = "tag"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(tag, nameParameter, methodName); + + SearchStringRequestBody requestBody = new SearchStringRequestBody(); + + requestBody.setSearchString(tag); + requestBody.setSearchStringParameterName(nameParameter); + + InformalTagsResponse restResult = restClient.callInformalTagListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + pageSize); + + return restResult.getTags(); + } + + + /** + * Adds a tag (either private of public) to an element. + * + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id of the tag. + * @param isPublic flag indicating whether the attachment of the tag is public or not + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the element properties to the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public void addTagToElement(String userId, + String elementGUID, + String tagGUID, + boolean isPublic) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "addTagToElement"; + final String elementGUIDParameterName = "elementGUID"; + final String tagGUIDParameterName = "tagGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/tags/{3}"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameterName, methodName); + invalidParameterHandler.validateGUID(tagGUID, tagGUIDParameterName, methodName); + + FeedbackProperties requestBody = new FeedbackProperties(); + requestBody.setIsPublic(isPublic); + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + elementGUID, + tagGUID); + } + + + /** + * Removes a tag from the element that was added by this user. + * + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id for the tag. + * + * @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 requesting user is not authorized to issue this request. + */ + @Override + public void removeTagFromElement(String userId, + String elementGUID, + String tagGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "removeTagFromElement"; + final String elementGUIDParameterName = "elementGUID"; + final String tagGUIDParameterName = "tagGUID"; + + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/tags/{3}/remove"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameterName, methodName); + invalidParameterHandler.validateGUID(tagGUID, tagGUIDParameterName, methodName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + nullRequestBody, + serverName, + userId, + elementGUID, + tagGUID); + } + + + + /** + * Return the list of unique identifiers for elements that are linked to a specific tag either directly, or via one + * of its schema elements. An Element's GUID may appear multiple times in the results if it is tagged multiple times + * with the requested tag. + * + * @param userId the name of the calling user. + * @param tagGUID unique identifier of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return element guid list + * @throws InvalidParameterException the userId is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public List getElementsByTag(String userId, + String tagGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getElementsByTag"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/by-tag/{2}?startFrom={3}&pageSize={4}"; + final String tagGUIDParameterName = "tagGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(tagGUID, tagGUIDParameterName, methodName); + + GUIDListResponse restResult = restClient.callGUIDListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + tagGUID, + startFrom, + pageSize); + + return restResult.getGUIDs(); + } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java index 13e1cd853b1..62c04dc07dc 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java @@ -8,6 +8,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.properties.*; import org.odpi.openmetadata.accessservices.assetmanager.rest.*; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; @@ -27,6 +28,8 @@ public class ExchangeClientBase InvalidParameterHandler invalidParameterHandler = new InvalidParameterHandler(); AssetManagerRESTClient restClient; /* Initialized in constructor */ + final NullRequestBody nullRequestBody = new NullRequestBody(); + AuditLog auditLog = null; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/GlossaryExchangeClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/GlossaryExchangeClient.java index 7700d8b1d65..f7f83ed0caa 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/GlossaryExchangeClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/GlossaryExchangeClient.java @@ -129,8 +129,8 @@ public GlossaryExchangeClient(String serverName, * categories are deleted as well. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalIdentifierProperties optional properties used to define an external identifier * @param glossaryProperties properties to store * @@ -184,8 +184,8 @@ public String createGlossary(String userId, * glossary is deleted, any linked terms and categories are deleted as well. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param templateGUID unique identifier of the metadata element to copy * @param externalIdentifierProperties optional properties used to define an external identifier * @param templateProperties properties that override the template @@ -240,8 +240,8 @@ public String createGlossaryFromTemplate(String userId, * Update the metadata element representing a glossary. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the metadata element to update * @param glossaryExternalIdentifier unique identifier of the glossary in the external asset manager * @param glossaryProperties new properties for this element @@ -297,8 +297,8 @@ public void updateGlossary(String userId, * are linked to the assets etc. and as such they are logically categorized by the linked category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the metadata element to remove * @param glossaryExternalIdentifier unique identifier of the glossary in the external asset manager * @param organizingPrinciple description of how the glossary is organized @@ -345,8 +345,8 @@ public void setGlossaryAsTaxonomy(String userId, * Remove the taxonomy designation from the glossary. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the metadata element to remove * @param glossaryExternalIdentifier unique identifier of the glossary in the external asset manager * @@ -391,8 +391,8 @@ public void clearGlossaryAsTaxonomy(String userId, * Canonical vocabularies are used to semantically classify assets in an unambiguous way. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the metadata element to remove * @param glossaryExternalIdentifier unique identifier of the glossary in the external asset manager * @param scope description of the situations where this glossary is relevant. @@ -439,8 +439,8 @@ public void setGlossaryAsCanonical(String userId, * Remove the canonical designation from the glossary. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the metadata element to remove * @param glossaryExternalIdentifier unique identifier of the glossary in the external asset manager * @@ -482,8 +482,8 @@ public void clearGlossaryAsCanonical(String userId, * and terms. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the metadata element to remove * @param glossaryExternalIdentifier unique identifier of the glossary in the external asset manager * @@ -525,8 +525,8 @@ public void removeGlossary(String userId, * The search string is treated as a regular expression. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param searchString string to find in the properties * @param startFrom paging start point * @param pageSize maximum results that can be returned* @@ -578,8 +578,8 @@ public List findGlossaries(String userId, * There are no wildcards supported on this request. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param name name to search for * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -632,8 +632,8 @@ public List getGlossariesByName(String userId, * Retrieve the list of glossaries created on behalf of the named asset manager. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param startFrom paging start point * @param pageSize maximum results that can be returned * @@ -675,8 +675,8 @@ public List getGlossariesForAssetManager(String userId, * Retrieve the glossary metadata element with the supplied unique identifier. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param guid unique identifier of the requested metadata element * * @return matching metadata element @@ -721,8 +721,8 @@ public GlossaryElement getGlossaryByGUID(String userId, * Create a new metadata element to represent a glossary category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the glossary where the category is located * @param externalIdentifierProperties optional properties used to define an external identifier * @param glossaryCategoryProperties properties about the glossary category to store @@ -777,8 +777,8 @@ public String createGlossaryCategory(String userId, * Create a new metadata element to represent a glossary category using an existing metadata element as a template. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param templateGUID unique identifier of the metadata element to copy * @param externalIdentifierProperties optional properties used to define an external identifier * @param templateProperties properties that override the template @@ -833,8 +833,8 @@ public String createGlossaryCategoryFromTemplate(String us * Update the metadata element representing a glossary category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the metadata element to update * @param glossaryCategoryExternalIdentifier unique identifier of the glossary category in the external asset manager * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? @@ -897,8 +897,8 @@ public void updateGlossaryCategory(String userId, * Create a parent-child relationship between two categories. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryParentCategoryGUID unique identifier of the glossary category in the external asset manager that is to be the super-category * @param glossaryChildCategoryGUID unique identifier of the glossary category in the external asset manager that is to be the subcategory * @param effectiveTime the time that the retrieved elements must be effective for @@ -948,8 +948,8 @@ public void setupCategoryParent(String userId, * Remove a parent-child relationship between two categories. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryParentCategoryGUID unique identifier of the glossary category in the external asset manager that is to be the super-category * @param glossaryChildCategoryGUID unique identifier of the glossary category in the external asset manager that is to be the subcategory * @param effectiveTime the time that the retrieved elements must be effective for @@ -998,8 +998,8 @@ public void clearCategoryParent(String userId, * Remove the metadata element representing a glossary category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the metadata element to remove * @param glossaryCategoryExternalIdentifier unique identifier of the glossary category in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -1046,8 +1046,9 @@ public void removeGlossaryCategory(String userId, * The search string is treated as a regular expression. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID optional glossary unique identifier to scope the search to a glossary. * @param searchString string to find in the properties * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -1065,6 +1066,7 @@ public void removeGlossaryCategory(String userId, public List findGlossaryCategories(String userId, String assetManagerGUID, String assetManagerName, + String glossaryGUID, String searchString, int startFrom, int pageSize, @@ -1081,10 +1083,11 @@ public List findGlossaryCategories(String userId, invalidParameterHandler.validateSearchString(searchString, searchStringParameterName, methodName); int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); - SearchStringRequestBody requestBody = new SearchStringRequestBody(); + GlossarySearchStringRequestBody requestBody = new GlossarySearchStringRequestBody(); requestBody.setAssetManagerGUID(assetManagerGUID); requestBody.setAssetManagerName(assetManagerName);requestBody.setSearchString(searchString); requestBody.setSearchStringParameterName(searchStringParameterName); + requestBody.setGlossaryGUID(glossaryGUID); requestBody.setEffectiveTime(effectiveTime); final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/glossaries/categories/by-search-string?startFrom={2}&pageSize={3}&forLineage={4}&forDuplicateProcessing={5}"; @@ -1107,8 +1110,8 @@ public List findGlossaryCategories(String userId, * Return the list of categories associated with a glossary. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the glossary to query * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -1164,8 +1167,9 @@ public List getCategoriesForGlossary(String userId, * There are no wildcards supported on this request. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID optional glossary unique identifier to scope the search to a glossary. * @param name name to search for * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -1183,6 +1187,7 @@ public List getCategoriesForGlossary(String userId, public List getGlossaryCategoriesByName(String userId, String assetManagerGUID, String assetManagerName, + String glossaryGUID, String name, int startFrom, int pageSize, @@ -1199,9 +1204,10 @@ public List getGlossaryCategoriesByName(String userI invalidParameterHandler.validateName(name, nameParameterName, methodName); int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); - NameRequestBody requestBody = new NameRequestBody(); + GlossaryNameRequestBody requestBody = new GlossaryNameRequestBody(); requestBody.setAssetManagerGUID(assetManagerGUID); requestBody.setAssetManagerName(assetManagerName); + requestBody.setGlossaryGUID(glossaryGUID); requestBody.setName(name); requestBody.setNameParameterName(nameParameterName); requestBody.setEffectiveTime(effectiveTime); @@ -1226,8 +1232,8 @@ public List getGlossaryCategoriesByName(String userI * Retrieve the glossary category metadata element with the supplied unique identifier. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the requested metadata element * @param effectiveTime the time that the retrieved elements must be effective for * @param forLineage return elements marked with the Memento classification? @@ -1275,8 +1281,8 @@ public GlossaryCategoryElement getGlossaryCategoryByGUID(String userId, * Retrieve the glossary category metadata element with the supplied unique identifier. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the requested metadata element * @param effectiveTime the time that the retrieved elements must be effective for * @param forLineage return elements marked with the Memento classification? @@ -1324,8 +1330,8 @@ public GlossaryCategoryElement getGlossaryCategoryParent(String userId, * Retrieve the glossary category metadata element with the supplied unique identifier. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the requested metadata element * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -1384,8 +1390,8 @@ public List getGlossarySubCategories(String userId, * Create a new metadata element to represent a glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the glossary where the term is located * @param externalIdentifierProperties optional properties used to define an external identifier * @param glossaryTermProperties properties for the glossary term @@ -1440,8 +1446,8 @@ public String createGlossaryTerm(String userId, * Create a new metadata element to represent a glossary term whose lifecycle is managed through a controlled workflow. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the glossary where the term is located * @param externalIdentifierProperties optional properties used to define an external identifier * @param glossaryTermProperties properties for the glossary term @@ -1499,8 +1505,8 @@ public String createControlledGlossaryTerm(String userId, * Create a new metadata element to represent a glossary term using an existing metadata element as a template. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param templateGUID unique identifier of the metadata element to copy * @param externalIdentifierProperties optional properties used to define an external identifier * @param templateProperties properties that override the template @@ -1555,8 +1561,8 @@ public String createGlossaryTermFromTemplate(String userId * Update the metadata element representing a glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the glossary term to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? @@ -1591,7 +1597,11 @@ public void updateGlossaryTerm(String userId, invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(glossaryTermGUID, glossaryGUIDParameterName, methodName); invalidParameterHandler.validateObject(glossaryTermProperties, propertiesParameterName, methodName); - invalidParameterHandler.validateName(glossaryTermProperties.getQualifiedName(), qualifiedNameParameterName, methodName); + + if (! isMergeUpdate) + { + invalidParameterHandler.validateName(glossaryTermProperties.getQualifiedName(), qualifiedNameParameterName, methodName); + } GlossaryTermRequestBody requestBody = new GlossaryTermRequestBody(); requestBody.setElementProperties(glossaryTermProperties); @@ -1620,8 +1630,8 @@ public void updateGlossaryTerm(String userId, * a controlled glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the glossary term to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param glossaryTermStatus new properties for the glossary term @@ -1679,8 +1689,8 @@ public void updateGlossaryTermStatus(String userId, * Link a term to a category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the glossary category * @param glossaryTermGUID unique identifier of the glossary term * @param categorizationProperties properties for the categorization relationship @@ -1731,8 +1741,8 @@ public void setupTermCategory(String userId, * Unlink a term from a category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the glossary category * @param glossaryTermGUID unique identifier of the glossary term * @param effectiveTime the time that the retrieved elements must be effective for @@ -1781,8 +1791,8 @@ public void clearTermCategory(String userId, * Link two terms together using a specialist relationship. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param relationshipTypeName name of the type of relationship to create * @param glossaryTermOneGUID unique identifier of the glossary term at end 1 * @param glossaryTermTwoGUID unique identifier of the glossary term at end 2 @@ -1843,8 +1853,8 @@ public void setupTermRelationship(String userId, * Update the relationship properties for the two terms. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param relationshipTypeName name of the type of relationship to create * @param glossaryTermOneGUID unique identifier of the glossary term at end 1 * @param glossaryTermTwoGUID unique identifier of the glossary term at end 2 @@ -1903,8 +1913,8 @@ public void updateTermRelationship(String userId, * Remove the relationship between two terms. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param relationshipTypeName name of the type of relationship to create * @param glossaryTermOneGUID unique identifier of the glossary term at end 1 * @param glossaryTermTwoGUID unique identifier of the glossary term at end 2 @@ -1956,8 +1966,8 @@ public void clearTermRelationship(String userId, * Classify the glossary term to indicate that it describes an abstract concept. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2003,8 +2013,8 @@ public void setTermAsAbstractConcept(String userId, * Remove the abstract concept designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2050,8 +2060,8 @@ public void clearTermAsAbstractConcept(String userId, * Classify the glossary term to indicate that it describes a data value. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2097,8 +2107,8 @@ public void setTermAsDataValue(String userId, * Remove the data value designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2144,8 +2154,8 @@ public void clearTermAsDataValue(String userId, * Classify the glossary term to indicate that it describes a data value. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param activityType type of activity @@ -2201,8 +2211,8 @@ public void setTermAsActivity(String userId, * Remove the activity designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2248,8 +2258,8 @@ public void clearTermAsActivity(String userId, * Classify the glossary term to indicate that it describes a context. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param contextDefinition more details of the context @@ -2305,8 +2315,8 @@ public void setTermAsContext(String userId, * Remove the context definition designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2352,8 +2362,8 @@ public void clearTermAsContext(String userId, * Classify the glossary term to indicate that it describes a spine object. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2399,8 +2409,8 @@ public void setTermAsSpineObject(String userId, * Remove the spine object designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2446,8 +2456,8 @@ public void clearTermAsSpineObject(String userId, * Classify the glossary term to indicate that it describes a spine attribute. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2493,8 +2503,8 @@ public void setTermAsSpineAttribute(String userId, * Remove the spine attribute designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2540,8 +2550,8 @@ public void clearTermAsSpineAttribute(String userId, * Classify the glossary term to indicate that it describes an object identifier. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2587,8 +2597,8 @@ public void setTermAsObjectIdentifier(String userId, * Remove the object identifier designation from the glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2630,12 +2640,115 @@ public void clearTermAsObjectIdentifier(String userId, } + /** + * Undo the last update to the glossary term. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * @param forLineage return elements marked with the Memento classification? + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * + * @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 GlossaryTermElement undoGlossaryTermUpdate(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryTermGUID, + String glossaryTermExternalIdentifier, + Date effectiveTime, + boolean forLineage, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "undoGlossaryTermUpdate"; + final String glossaryGUIDParameterName = "glossaryTermGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(glossaryTermGUID, glossaryGUIDParameterName, methodName); + + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/glossaries/terms/{2}/undo&forLineage={3}&forDuplicateProcessing={4}"; + + GlossaryTermElementResponse response = restClient.callGlossaryTermPostRESTCall(methodName, + urlTemplate, + getUpdateRequestBody(assetManagerGUID, assetManagerName, glossaryTermExternalIdentifier, effectiveTime, methodName), + serverName, + userId, + glossaryTermGUID, + forLineage, + forDuplicateProcessing); + + return response.getElement(); + } + + + /** + * Archive the metadata element representing a glossary term. This removes it from normal access. However, it is still available + * for lineage requests. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryTermGUID unique identifier of the metadata element to archive + * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager + * @param archiveProperties option parameters about the archive process + * @param effectiveTime the time that the retrieved elements must be effective for + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * + * @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 void archiveGlossaryTerm(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryTermGUID, + String glossaryTermExternalIdentifier, + ArchiveProperties archiveProperties, + Date effectiveTime, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "archiveGlossaryTerm"; + final String glossaryGUIDParameterName = "glossaryTermGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(glossaryTermGUID, glossaryGUIDParameterName, methodName); + + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/glossaries/terms/{2}/archive?forDuplicateProcessing={3}"; + + ArchiveRequestBody requestBody = new ArchiveRequestBody(); + requestBody.setElementProperties(archiveProperties); + requestBody.setMetadataCorrelationProperties(this.getCorrelationProperties(assetManagerGUID, + assetManagerName, + glossaryTermExternalIdentifier, + methodName)); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + glossaryTermGUID, + forDuplicateProcessing); + } + + /** * Remove the metadata element representing a glossary term. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the metadata element to remove * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param effectiveTime the time that the retrieved elements must be effective for @@ -2682,9 +2795,12 @@ public void removeGlossaryTerm(String userId, * The search string is treated as a regular expression. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param searchString string to find in the properties + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom paging start point * @param pageSize maximum results that can be returned * @param effectiveTime the time that the retrieved elements must be effective for @@ -2698,17 +2814,19 @@ public void removeGlossaryTerm(String userId, * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ @Override - public List findGlossaryTerms(String userId, - String assetManagerGUID, - String assetManagerName, - String searchString, - int startFrom, - int pageSize, - Date effectiveTime, - boolean forLineage, - boolean forDuplicateProcessing) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public List findGlossaryTerms(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryGUID, + String searchString, + List limitResultsByStatus, + int startFrom, + int pageSize, + Date effectiveTime, + boolean forLineage, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { final String methodName = "findGlossaryTerms"; final String searchStringParameterName = "searchString"; @@ -2717,11 +2835,13 @@ public List findGlossaryTerms(String userId, invalidParameterHandler.validateSearchString(searchString, searchStringParameterName, methodName); int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); - SearchStringRequestBody requestBody = new SearchStringRequestBody(); + GlossarySearchStringRequestBody requestBody = new GlossarySearchStringRequestBody(); requestBody.setAssetManagerGUID(assetManagerGUID); requestBody.setAssetManagerName(assetManagerName); + requestBody.setGlossaryGUID(glossaryGUID); requestBody.setSearchString(searchString); requestBody.setSearchStringParameterName(searchStringParameterName); + requestBody.setLimitResultsByStatus(limitResultsByStatus); requestBody.setEffectiveTime(effectiveTime); final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/glossaries/terms/by-search-string?startFrom={2}&pageSize={3}&forLineage={4}&forDuplicateProcessing={5}"; @@ -2744,8 +2864,8 @@ public List findGlossaryTerms(String userId, * Retrieve the list of glossary terms associated with a glossary. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryGUID unique identifier of the glossary of interest * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -2800,8 +2920,8 @@ public List getTermsForGlossary(String userId, * Retrieve the list of glossary terms associated with a glossary category. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryCategoryGUID unique identifier of the glossary category of interest * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -2857,9 +2977,12 @@ public List getTermsForGlossaryCategory(String userId, * There are no wildcards supported on this request. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param name name to search for + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom paging start point * @param pageSize maximum results that can be returned * @param effectiveTime the time that the retrieved elements must be effective for @@ -2873,17 +2996,19 @@ public List getTermsForGlossaryCategory(String userId, * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ @Override - public List getGlossaryTermsByName(String userId, - String assetManagerGUID, - String assetManagerName, - String name, - int startFrom, - int pageSize, - Date effectiveTime, - boolean forLineage, - boolean forDuplicateProcessing) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public List getGlossaryTermsByName(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryGUID, + String name, + List limitResultsByStatus, + int startFrom, + int pageSize, + Date effectiveTime, + boolean forLineage, + boolean forDuplicateProcessing) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { final String methodName = "getGlossaryTermsByName"; final String nameParameterName = "name"; @@ -2892,11 +3017,13 @@ public List getGlossaryTermsByName(String userId, invalidParameterHandler.validateName(name, nameParameterName, methodName); int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); - NameRequestBody requestBody = new NameRequestBody(); + GlossaryNameRequestBody requestBody = new GlossaryNameRequestBody(); requestBody.setAssetManagerGUID(assetManagerGUID); requestBody.setAssetManagerName(assetManagerName); + requestBody.setGlossaryGUID(glossaryGUID); requestBody.setName(name); requestBody.setNameParameterName(nameParameterName); + requestBody.setLimitResultsByStatus(limitResultsByStatus); requestBody.setEffectiveTime(effectiveTime); final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/glossaries/terms/by-name?startFrom={2}&pageSize={3}&forLineage={4}&forDuplicateProcessing={5}"; @@ -2919,8 +3046,8 @@ public List getGlossaryTermsByName(String userId, * Retrieve the glossary term metadata element with the supplied unique identifier. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the requested metadata element * @param effectiveTime the time that the retrieved elements must be effective for * @param forLineage return elements marked with the Memento classification? @@ -2964,6 +3091,76 @@ public GlossaryTermElement getGlossaryTermByGUID(String userId, } + /** + * Retrieve all the versions of a glossary term. + * + * @param userId calling user + * @param glossaryTermGUID unique identifier of object to retrieve + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startFrom the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param oldestFirst defining how the results should be ordered. + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @return list of beans + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem removing the properties from the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public List getGlossaryTermHistory(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryTermGUID, + Date fromTime, + Date toTime, + int startFrom, + int pageSize, + boolean oldestFirst, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getGlossaryTermHistory"; + final String guidParameterName = "glossaryTermGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(glossaryTermGUID, guidParameterName, methodName); + + int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + HistoryRequestBody requestBody = new HistoryRequestBody(); + requestBody.setAssetManagerGUID(assetManagerGUID); + requestBody.setAssetManagerName(assetManagerName); + requestBody.setFromTime(fromTime); + requestBody.setToTime(toTime); + requestBody.setEffectiveTime(effectiveTime); + + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/glossaries/terms/{2}/history?startFrom={3}&pageSize={4}&oldestFirst={5}&forLineage={6}&forDuplicateProcessing={7}"; + + GlossaryTermElementsResponse restResult = restClient.callGlossaryTermsPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + glossaryTermGUID, + startFrom, + validatedPageSize, + oldestFirst, + forLineage, + forDuplicateProcessing); + + return restResult.getElementList(); + } + + /* ========================================================================================= * Support for linkage to external glossary resources. These glossary resources are not * stored as metadata - they could be web pages, ontologies or some other format. @@ -2977,8 +3174,8 @@ public GlossaryTermElement getGlossaryTermByGUID(String userId, * It is possible that this resource was generated from the glossary content or was the source for it. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param linkProperties properties of the link * * @return unique identifier of the external reference @@ -3022,8 +3219,8 @@ public String createExternalGlossaryLink(String userId, * Update the properties of a reference to an external glossary resource. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? * @param linkProperties properties of the link @@ -3080,8 +3277,8 @@ public void updateExternalGlossaryLink(String userId, * Remove information about a link to an external glossary resource (and the relationships that attached it to the glossaries). * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param effectiveTime the time that the retrieved elements must be effective for * @param forLineage return elements marked with the Memento classification? @@ -3125,8 +3322,8 @@ public void removeExternalGlossaryLink(String userId, * Connect a glossary to a reference to an external glossary resource. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param glossaryGUID unique identifier of the metadata element to attach * @param effectiveTime the time that the retrieved elements must be effective for @@ -3175,8 +3372,8 @@ public void attachExternalLinkToGlossary(String userId, * Disconnect a glossary from a reference to an external glossary resource. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param glossaryGUID unique identifier of the metadata element to remove * @param effectiveTime the time that the retrieved elements must be effective for @@ -3279,8 +3476,8 @@ public List getExternalLinksForGlossary(String use * Return the glossaries connected to an external glossary source. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the metadata element for the external glossary link of interest * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -3336,8 +3533,8 @@ public List getGlossariesForExternalLink(String userId, * It is possible that this resource was generated from the glossary content or was the source for it. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param glossaryCategoryGUID unique identifier for the glossary category * @param linkProperties properties of the link @@ -3393,8 +3590,8 @@ public void attachExternalCategoryLink(String use * Remove the link to an external glossary category resource. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param glossaryCategoryGUID unique identifier for the glossary category * @param effectiveTime the time that the retrieved elements must be effective for @@ -3444,8 +3641,8 @@ public void detachExternalCategoryLink(String userId, * It is possible that this resource was generated from the glossary content or was the source for it. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param glossaryTermGUID unique identifier for the glossary category * @param linkProperties properties of the link @@ -3501,8 +3698,8 @@ public void attachExternalTermLink(String userId, * Remove the link to an external glossary term resource. * * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerGUID unique identifier of software capability representing the caller + * @param assetManagerName unique name of software capability representing the caller * @param externalLinkGUID unique identifier of the external reference * @param glossaryTermGUID unique identifier for the glossary category * @param effectiveTime the time that the retrieved elements must be effective for diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/StewardshipExchangeClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/StewardshipExchangeClient.java index e18cf0f71a9..af8124af03f 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/StewardshipExchangeClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/StewardshipExchangeClient.java @@ -5,6 +5,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.api.StewardshipExchangeInterface; import org.odpi.openmetadata.accessservices.assetmanager.client.rest.AssetManagerRESTClient; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SecurityTagsProperties; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; @@ -241,4 +242,62 @@ public void clearIncompleteClassification(String userId, { } + + + /** + * Add or replace the security tags for an element. + * + * @param userId calling user + * @param elementGUID element to link it to - its type must inherit from Referenceable. + * @param properties details of the security tags + * + * @throws InvalidParameterException element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void addSecurityTags(String userId, + String elementGUID, + SecurityTagsProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "addSecurityTags"; + final String elementGUIDParameter = "elementGUID"; + final String propertiesParameter = "properties"; + final String assetURLTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/security-tags"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameter, methodName); + invalidParameterHandler.validateObject(properties, propertiesParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, assetURLTemplate, properties, serverName, userId, elementGUID); + } + + + /** + * Remove the security tags classification from an element. + * + * @param userId calling user + * @param elementGUID element where the security tags need to be removed. + * + * @throws InvalidParameterException asset or element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void removeSecurityTags(String userId, + String elementGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "removeSecurityTags"; + final String elementGUIDParameter = "elementGUID"; + final String assetURLTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-manager/users/{1}/elements/{2}/security-tags/remove"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameter, methodName); + + restClient.callVoidPostRESTCall(methodName, assetURLTemplate, nullRequestBody, serverName, userId, elementGUID); + } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/rest/AssetManagerRESTClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/rest/AssetManagerRESTClient.java index 25bc9801565..373c271834a 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/rest/AssetManagerRESTClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/rest/AssetManagerRESTClient.java @@ -173,6 +173,357 @@ public ExternalReferenceLinkElementsResponse callExternalReferenceLinksPostRESTC } + /** + * Issue a POST REST call that returns a InformalTagsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody object that passes additional parameters + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public InformalTagsResponse callInformalTagListPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + InformalTagsResponse restResult = this.callPostRESTCall(methodName, InformalTagsResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a InformalTagsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public InformalTagResponse callInformalTagGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + InformalTagResponse restResult = this.callGetRESTCall(methodName, InformalTagResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a LikeElementsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody object that passes additional parameters + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public LikeElementsResponse callLikeElementsPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + LikeElementsResponse restResult = this.callPostRESTCall(methodName, LikeElementsResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a LikeElementResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public LikeElementResponse callLikeElementGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + LikeElementResponse restResult = this.callGetRESTCall(methodName, LikeElementResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a RatingElementsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody object that passes additional parameters + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public RatingElementsResponse callRatingElementsPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + RatingElementsResponse restResult = this.callPostRESTCall(methodName, RatingElementsResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a RatingElementResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public RatingElementResponse callRatingElementGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + RatingElementResponse restResult = this.callGetRESTCall(methodName, RatingElementResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a CommentElementsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody object that passes additional parameters + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public CommentElementsResponse callCommentElementsPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + CommentElementsResponse restResult = this.callPostRESTCall(methodName, CommentElementsResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a CommentElementResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public CommentElementResponse callCommentElementGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + CommentElementResponse restResult = this.callGetRESTCall(methodName, CommentElementResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a CommentElementsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public CommentElementsResponse callCommentElementsGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + CommentElementsResponse restResult = this.callGetRESTCall(methodName, CommentElementsResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a NoteLogElementsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody object that passes additional parameters + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public NoteLogElementsResponse callNoteLogElementsPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + NoteLogElementsResponse restResult = this.callPostRESTCall(methodName, NoteLogElementsResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a NoteLogElementResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public NoteLogElementResponse callNoteLogElementGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + NoteLogElementResponse restResult = this.callGetRESTCall(methodName, NoteLogElementResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + + /** + * Issue a POST REST call that returns a NoteElementsResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody object that passes additional parameters + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public NoteElementsResponse callNoteElementsPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + NoteElementsResponse restResult = this.callPostRESTCall(methodName, NoteElementsResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a NoteLogElementResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws InvalidParameterException one of the parameters is invalid. + * @throws UserNotAuthorizedException the user is not authorized to make this request. + * @throws PropertyServerException the repository is not available or not working properly. + */ + public NoteElementResponse callNoteElementGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + NoteElementResponse restResult = this.callGetRESTCall(methodName, NoteElementResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + /** * Issue a POST REST call that returns a GlossaryElementResponse object. * @@ -358,8 +709,8 @@ public ExternalGlossaryLinkElementsResponse callExternalGlossaryLinksPostRESTCal String urlTemplate, Object requestBody, Object... params) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { ExternalGlossaryLinkElementsResponse restResult = this.callPostRESTCall(methodName, ExternalGlossaryLinkElementsResponse.class, @@ -621,8 +972,8 @@ public EndpointResponse callEndpointPostRESTCall(String methodName, String urlTemplate, Object requestBody, Object... params) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { EndpointResponse restResult = this.callPostRESTCall(methodName, EndpointResponse.class, urlTemplate, requestBody, params); @@ -677,8 +1028,8 @@ public DataAssetElementResponse callDataAssetPostRESTCall(String methodName, String urlTemplate, Object requestBody, Object... params) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { DataAssetElementResponse restResult = this.callPostRESTCall(methodName, DataAssetElementResponse.class, urlTemplate, requestBody, params); @@ -705,8 +1056,8 @@ public DataAssetElementsResponse callDataAssetsPostRESTCall(String methodName String urlTemplate, Object requestBody, Object... params) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { DataAssetElementsResponse restResult = this.callPostRESTCall(methodName, DataAssetElementsResponse.class, urlTemplate, requestBody, params); @@ -1183,8 +1534,8 @@ public LineageMappingElementResponse callLineageMappingPostRESTCall(String me String urlTemplate, Object requestBody, Object... params) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { LineageMappingElementResponse restResult = this.callPostRESTCall(methodName, LineageMappingElementResponse.class, urlTemplate, requestBody, params); diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/CommentConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/CommentConverter.java new file mode 100644 index 00000000000..611a1c6984c --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/CommentConverter.java @@ -0,0 +1,231 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.FeedbackTargetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.CommentElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentType; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EnumPropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + + +/** + * CommentConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into an CommentElement bean. + */ +public class CommentConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public CommentConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + /* + * This is initial confirmation that the generic converter has been initialized with an appropriate bean class. + */ + B returnBean = beanClass.getDeclaredConstructor().newInstance(); + + if (returnBean instanceof CommentElement) + { + CommentElement bean = (CommentElement) returnBean; + CommentProperties properties = new CommentProperties(); + + bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties; + + /* + * The initial set of values come from the entity. + */ + if (entity != null) + { + instanceProperties = new InstanceProperties(entity.getProperties()); + properties.setUser(entity.getCreatedBy()); + + properties.setQualifiedName(this.removeQualifiedName(instanceProperties)); + properties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + properties.setCommentText(this.removeCommentText(instanceProperties)); + properties.setCommentType(this.removeCommentTypeFromProperties(instanceProperties)); + properties.setIsPublic(this.removeIsPublic(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + properties.setTypeName(bean.getElementHeader().getType().getTypeName()); + properties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + bean.setProperties(properties); + + if (relationship != null) + { + FeedbackTargetElement feedbackTargetElement = new FeedbackTargetElement(); + + instanceProperties = new InstanceProperties(relationship.getProperties()); + + feedbackTargetElement.setRelationshipHeader(super.getMetadataElementHeader(beanClass, relationship, null, methodName)); + feedbackTargetElement.setRelatedElement(super.getElementStub(beanClass, relationship.getEntityOneProxy(), methodName)); + feedbackTargetElement.setIsPublic(this.getIsPublic(instanceProperties)); + + bean.setFeedbackTargetElement(feedbackTargetElement); + } + + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + return getNewBean(beanClass, entity, null, methodName); + } + + + /** + * Retrieve and delete the CommentType enum property from the instance properties of an entity + * + * @param properties entity properties + * @return CommentType enum value + */ + private CommentType removeCommentTypeFromProperties(InstanceProperties properties) + { + CommentType commentType = this.getCommentTypeFromProperties(properties); + + if (properties != null) + { + Map instancePropertiesMap = properties.getInstanceProperties(); + + if (instancePropertiesMap != null) + { + instancePropertiesMap.remove(OpenMetadataAPIMapper.COMMENT_TYPE_PROPERTY_NAME); + instancePropertiesMap.remove(OpenMetadataAPIMapper.COMMENT_TYPE_PROPERTY_NAME_DEP); + } + + properties.setInstanceProperties(instancePropertiesMap); + } + + return commentType; + } + + + /** + * Retrieve the CommentType enum property from the instance properties of an entity + * + * @param properties entity properties + * @return CommentType enum value + */ + private CommentType getCommentTypeFromProperties(InstanceProperties properties) + { + CommentType commentType = CommentType.STANDARD_COMMENT; + + if (properties != null) + { + Map instancePropertiesMap = properties.getInstanceProperties(); + + if (instancePropertiesMap != null) + { + InstancePropertyValue instancePropertyValue = instancePropertiesMap.get(OpenMetadataAPIMapper.COMMENT_TYPE_PROPERTY_NAME); + + if (instancePropertyValue instanceof EnumPropertyValue) + { + EnumPropertyValue enumPropertyValue = (EnumPropertyValue) instancePropertyValue; + + switch (enumPropertyValue.getOrdinal()) + { + case 0: + commentType = CommentType.STANDARD_COMMENT; + break; + + case 1: + commentType = CommentType.QUESTION; + break; + + case 2: + commentType = CommentType.ANSWER; + break; + + case 3: + commentType = CommentType.SUGGESTION; + break; + + case 4: + commentType = CommentType.USAGE_EXPERIENCE; + break; + + case 99: + commentType = CommentType.OTHER; + break; + } + } + } + } + + return commentType; + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/InformalTagConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/InformalTagConverter.java new file mode 100644 index 00000000000..88b13d2ea4c --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/InformalTagConverter.java @@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.FeedbackTargetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.InformalTagElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.InformalTagProperties; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.lang.reflect.InvocationTargetException; + + +/** + * InformalTagConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into an InformalTagElement bean. + */ +public class InformalTagConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public InformalTagConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + /* + * This is initial confirmation that the generic converter has been initialized with an appropriate bean class. + */ + B returnBean = beanClass.getDeclaredConstructor().newInstance(); + + if (returnBean instanceof InformalTagElement) + { + InformalTagElement bean = (InformalTagElement) returnBean; + InformalTagProperties properties = new InformalTagProperties(); + + bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties; + + /* + * The initial set of values come from the entity. + */ + if (entity != null) + { + instanceProperties = new InstanceProperties(entity.getProperties()); + properties.setUser(entity.getCreatedBy()); + + properties.setName(this.removeTagName(instanceProperties)); + properties.setDescription(this.removeTagDescription(instanceProperties)); + properties.setIsPrivateTag(! this.removeIsPublic(instanceProperties)); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + bean.setProperties(properties); + + if (relationship != null) + { + FeedbackTargetElement feedbackTargetElement = new FeedbackTargetElement(); + + instanceProperties = new InstanceProperties(relationship.getProperties()); + + feedbackTargetElement.setRelationshipHeader(super.getMetadataElementHeader(beanClass, relationship, null, methodName)); + feedbackTargetElement.setRelatedElement(super.getElementStub(beanClass, relationship.getEntityOneProxy(), methodName)); + feedbackTargetElement.setIsPublic(this.getIsPublic(instanceProperties)); + + bean.setFeedbackTargetElement(feedbackTargetElement); + } + + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + return getNewBean(beanClass, entity, null, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/LikeConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/LikeConverter.java new file mode 100644 index 00000000000..c41c0c874b7 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/LikeConverter.java @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.FeedbackTargetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.LikeElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.LikeProperties; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.lang.reflect.InvocationTargetException; + + +/** + * LikeConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into an LikeElement bean. + */ +public class LikeConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public LikeConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + /* + * This is initial confirmation that the generic converter has been initialized with an appropriate bean class. + */ + B returnBean = beanClass.getDeclaredConstructor().newInstance(); + + if (returnBean instanceof LikeElement) + { + LikeElement bean = (LikeElement) returnBean; + LikeProperties properties = new LikeProperties(); + + bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties; + + /* + * The initial set of values come from the entity. + */ + if (entity != null) + { + instanceProperties = new InstanceProperties(entity.getProperties()); + properties.setUser(entity.getCreatedBy()); + + properties.setIsPublic(this.removeIsPublic(instanceProperties)); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + bean.setProperties(properties); + + if (relationship != null) + { + FeedbackTargetElement feedbackTargetElement = new FeedbackTargetElement(); + + instanceProperties = new InstanceProperties(relationship.getProperties()); + + feedbackTargetElement.setRelationshipHeader(super.getMetadataElementHeader(beanClass, relationship, null, methodName)); + feedbackTargetElement.setRelatedElement(super.getElementStub(beanClass, relationship.getEntityOneProxy(), methodName)); + feedbackTargetElement.setIsPublic(this.getIsPublic(instanceProperties)); + + bean.setFeedbackTargetElement(feedbackTargetElement); + } + + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + return getNewBean(beanClass, entity, null, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteConverter.java new file mode 100644 index 00000000000..707b81dd83b --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteConverter.java @@ -0,0 +1,142 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.FeedbackTargetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.NoteElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.NoteProperties; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.lang.reflect.InvocationTargetException; + + +/** + * NoteConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into an NoteElement bean. + */ +public class NoteConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public NoteConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + /* + * This is initial confirmation that the generic converter has been initialized with an appropriate bean class. + */ + B returnBean = beanClass.getDeclaredConstructor().newInstance(); + + if (returnBean instanceof NoteElement) + { + NoteElement bean = (NoteElement) returnBean; + NoteProperties properties = new NoteProperties(); + + bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties; + + /* + * The initial set of values come from the entity. + */ + if (entity != null) + { + instanceProperties = new InstanceProperties(entity.getProperties()); + properties.setUser(entity.getCreatedBy()); + properties.setLastUpdate(entity.getUpdateTime()); + + properties.setQualifiedName(this.removeQualifiedName(instanceProperties)); + properties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + properties.setText(this.removeText(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + properties.setTypeName(bean.getElementHeader().getType().getTypeName()); + properties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + bean.setProperties(properties); + + if (relationship != null) + { + FeedbackTargetElement feedbackTargetElement = new FeedbackTargetElement(); + + instanceProperties = new InstanceProperties(relationship.getProperties()); + + feedbackTargetElement.setRelationshipHeader(super.getMetadataElementHeader(beanClass, relationship, null, methodName)); + feedbackTargetElement.setRelatedElement(super.getElementStub(beanClass, relationship.getEntityOneProxy(), methodName)); + feedbackTargetElement.setIsPublic(this.getIsPublic(instanceProperties)); + + bean.setFeedbackTargetElement(feedbackTargetElement); + } + + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + return getNewBean(beanClass, entity, null, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteLogConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteLogConverter.java new file mode 100644 index 00000000000..f1be12d1d3f --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/NoteLogConverter.java @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.FeedbackTargetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.NoteLogElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.NoteLogProperties; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.lang.reflect.InvocationTargetException; + + +/** + * NoteLogConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into an NoteLogElement bean. + */ +public class NoteLogConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public NoteLogConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + /* + * This is initial confirmation that the generic converter has been initialized with an appropriate bean class. + */ + B returnBean = beanClass.getDeclaredConstructor().newInstance(); + + if (returnBean instanceof NoteLogElement) + { + NoteLogElement bean = (NoteLogElement) returnBean; + NoteLogProperties properties = new NoteLogProperties(); + + bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties; + + /* + * The initial set of values come from the entity. + */ + if (entity != null) + { + instanceProperties = new InstanceProperties(entity.getProperties()); + + properties.setQualifiedName(this.removeQualifiedName(instanceProperties)); + properties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + properties.setDisplayName(this.removeDisplayName(instanceProperties)); + properties.setDescription(this.removeDescription(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + properties.setTypeName(bean.getElementHeader().getType().getTypeName()); + properties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + bean.setProperties(properties); + + if (relationship != null) + { + FeedbackTargetElement feedbackTargetElement = new FeedbackTargetElement(); + + instanceProperties = new InstanceProperties(relationship.getProperties()); + + feedbackTargetElement.setRelationshipHeader(super.getMetadataElementHeader(beanClass, relationship, null, methodName)); + feedbackTargetElement.setRelatedElement(super.getElementStub(beanClass, relationship.getEntityOneProxy(), methodName)); + feedbackTargetElement.setIsPublic(this.getIsPublic(instanceProperties)); + + bean.setFeedbackTargetElement(feedbackTargetElement); + } + + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + return getNewBean(beanClass, entity, null, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/RatingConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/RatingConverter.java new file mode 100644 index 00000000000..e9934771c63 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/RatingConverter.java @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.FeedbackTargetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.RatingElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RatingProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.StarRating; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EnumPropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + + +/** + * RatingConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into an RatingElement bean. + */ +public class RatingConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public RatingConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + /* + * This is initial confirmation that the generic converter has been initialized with an appropriate bean class. + */ + B returnBean = beanClass.getDeclaredConstructor().newInstance(); + + if (returnBean instanceof RatingElement) + { + RatingElement bean = (RatingElement) returnBean; + RatingProperties properties = new RatingProperties(); + + bean.setElementHeader(super.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties; + + /* + * The initial set of values come from the entity. + */ + if (entity != null) + { + instanceProperties = new InstanceProperties(entity.getProperties()); + properties.setUser(entity.getCreatedBy()); + + properties.setReview(this.removeReview(instanceProperties)); + properties.setStarRating(this.removeStarRatingFromProperties(instanceProperties)); + properties.setIsPublic(this.removeIsPublic(instanceProperties)); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + bean.setProperties(properties); + + if (relationship != null) + { + FeedbackTargetElement feedbackTargetElement = new FeedbackTargetElement(); + + instanceProperties = new InstanceProperties(relationship.getProperties()); + + feedbackTargetElement.setRelationshipHeader(super.getMetadataElementHeader(beanClass, relationship, null, methodName)); + feedbackTargetElement.setRelatedElement(super.getElementStub(beanClass, relationship.getEntityOneProxy(), methodName)); + feedbackTargetElement.setIsPublic(this.getIsPublic(instanceProperties)); + + bean.setFeedbackTargetElement(feedbackTargetElement); + } + + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + return getNewBean(beanClass, entity, null, methodName); + } + + + /** + * Retrieve and delete the StarRating enum property from the instance properties of an entity + * + * @param properties entity properties + * @return StarRating enum value + */ + private StarRating removeStarRatingFromProperties(InstanceProperties properties) + { + StarRating starRating = this.getStarRatingFromProperties(properties); + + if (properties != null) + { + Map instancePropertiesMap = properties.getInstanceProperties(); + + if (instancePropertiesMap != null) + { + instancePropertiesMap.remove(OpenMetadataAPIMapper.STARS_PROPERTY_NAME); + } + + properties.setInstanceProperties(instancePropertiesMap); + } + + return starRating; + } + + + /** + * Retrieve the StarRating enum property from the instance properties of an entity + * + * @param properties entity properties + * @return StarRating enum value + */ + private StarRating getStarRatingFromProperties(InstanceProperties properties) + { + StarRating starRating = StarRating.NO_RECOMMENDATION; + + if (properties != null) + { + Map instancePropertiesMap = properties.getInstanceProperties(); + + if (instancePropertiesMap != null) + { + InstancePropertyValue instancePropertyValue = instancePropertiesMap.get(OpenMetadataAPIMapper.STARS_PROPERTY_NAME); + + if (instancePropertyValue instanceof EnumPropertyValue) + { + EnumPropertyValue enumPropertyValue = (EnumPropertyValue) instancePropertyValue; + + switch (enumPropertyValue.getOrdinal()) + { + case 0: + starRating = StarRating.NO_RECOMMENDATION; + break; + + case 1: + starRating = StarRating.ONE_STAR; + break; + + case 2: + starRating = StarRating.TWO_STARS; + break; + + case 3: + starRating = StarRating.THREE_STARS; + break; + + case 4: + starRating = StarRating.FOUR_STARS; + break; + + case 99: + starRating = StarRating.FIVE_STARS; + break; + } + } + } + } + + return starRating; + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/GlossaryExchangeHandler.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/GlossaryExchangeHandler.java index 5e6cb2cf964..5b7d2f7eae3 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/GlossaryExchangeHandler.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/GlossaryExchangeHandler.java @@ -15,7 +15,9 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; @@ -1226,6 +1228,7 @@ public void removeGlossaryCategory(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param searchString string to find in the properties * @param searchStringParameterName name of parameter for searchString * @param startFrom paging start point @@ -1244,6 +1247,7 @@ public void removeGlossaryCategory(String userId, public List findGlossaryCategories(String userId, String assetManagerGUID, String assetManagerName, + String glossaryGUID, String searchString, String searchStringParameterName, int startFrom, @@ -1256,6 +1260,7 @@ public List findGlossaryCategories(String userId, PropertyServerException { List results = glossaryCategoryHandler.findGlossaryCategories(userId, + glossaryGUID, searchString, searchStringParameterName, startFrom, @@ -1341,6 +1346,7 @@ public List getCategoriesForGlossary(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param name name to search for * @param nameParameterName parameter name * @param startFrom paging start point @@ -1359,6 +1365,7 @@ public List getCategoriesForGlossary(String userId, public List getGlossaryCategoriesByName(String userId, String assetManagerGUID, String assetManagerName, + String glossaryGUID, String name, String nameParameterName, int startFrom, @@ -1371,6 +1378,7 @@ public List getGlossaryCategoriesByName(String userI PropertyServerException { List results = glossaryCategoryHandler.getGlossaryCategoriesByName(userId, + glossaryGUID, name, nameParameterName, startFrom, @@ -1815,6 +1823,7 @@ public String createGlossaryTermFromTemplate(String userI * @param correlationProperties properties to help with the mapping of the elements in the external asset manager and open metadata * @param glossaryTermGUID unique identifier of the glossary term to update * @param glossaryTermProperties new properties for the glossary term + * @param isMergeUpdate should the properties be merged with the existing properties or completely over-write them * @param forLineage return elements marked with the Memento classification? * @param forDuplicateProcessing do not merge elements marked as duplicates? * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -1828,6 +1837,7 @@ public void updateGlossaryTerm(String userId, MetadataCorrelationProperties correlationProperties, String glossaryTermGUID, GlossaryTermProperties glossaryTermProperties, + boolean isMergeUpdate, boolean forLineage, boolean forDuplicateProcessing, Date effectiveTime, @@ -1841,7 +1851,11 @@ public void updateGlossaryTerm(String userId, invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(glossaryTermGUID, glossaryTermGUIDParameterName, methodName); invalidParameterHandler.validateObject(glossaryTermProperties, propertiesParameterName, methodName); - invalidParameterHandler.validateName(glossaryTermProperties.getQualifiedName(), qualifiedNameParameterName, methodName); + + if (! isMergeUpdate) + { + invalidParameterHandler.validateName(glossaryTermProperties.getQualifiedName(), qualifiedNameParameterName, methodName); + } this.validateExternalIdentifier(userId, glossaryTermGUID, @@ -1870,7 +1884,7 @@ public void updateGlossaryTerm(String userId, glossaryTermProperties.getExtendedProperties(), glossaryTermProperties.getEffectiveFrom(), glossaryTermProperties.getEffectiveTo(), - true, + isMergeUpdate, forLineage, forDuplicateProcessing, effectiveTime, @@ -3095,6 +3109,128 @@ public void clearTermAsObjectIdentifier(String userId, } + /** + * Undo the last update to the glossary term. + * + * @param userId calling user + * @param correlationProperties properties to help with the mapping of the elements in the external asset manager and open metadata + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the new properties to the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public GlossaryTermElement undoGlossaryTermUpdate(String userId, + MetadataCorrelationProperties correlationProperties, + String glossaryTermGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + GlossaryTermElement glossaryTerm = glossaryTermHandler.undoBeanUpdateInRepository(userId, + getExternalSourceGUID(correlationProperties), + getExternalSourceName(correlationProperties), + glossaryTermGUID, + glossaryTermGUIDParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + + if (glossaryTerm != null) + { + glossaryTerm.setCorrelationHeaders(this.getCorrelationProperties(userId, + glossaryTermGUID, + glossaryTermGUIDParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + getExternalSourceGUID(correlationProperties), + getExternalSourceName(correlationProperties), + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName)); + } + + return glossaryTerm; + } + + + /** + * Classify the glossary term in the repository to show that it has been archived and is only needed for lineage. + * + * @param userId calling user + * @param correlationProperties properties to help with the mapping of the elements in the external asset manager and open metadata + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem removing the properties from the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public void archiveGlossaryTerm(String userId, + MetadataCorrelationProperties correlationProperties, + String glossaryTermGUID, + ArchiveProperties archiveProperties, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(glossaryTermGUID, glossaryTermGUIDParameterName, methodName); + + this.validateExternalIdentifier(userId, + glossaryTermGUID, + glossaryTermGUIDParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + correlationProperties, + true, + forDuplicateProcessing, + effectiveTime, + methodName); + + if (archiveProperties == null) + { + glossaryTermHandler.archiveGlossaryTerm(userId, + getExternalSourceGUID(correlationProperties), + getExternalSourceName(correlationProperties), + glossaryTermGUID, + glossaryTermGUIDParameterName, + null, + null, + null, + forDuplicateProcessing, + effectiveTime, + methodName); + } + else + { + glossaryTermHandler.archiveGlossaryTerm(userId, + getExternalSourceGUID(correlationProperties), + getExternalSourceName(correlationProperties), + glossaryTermGUID, + glossaryTermGUIDParameterName, + archiveProperties.getArchiveDate(), + archiveProperties.getArchiveProcess(), + archiveProperties.getArchiveProperties(), + forDuplicateProcessing, + effectiveTime, + methodName); + } + } + + /** * Remove the metadata element representing a glossary term. * @@ -3152,8 +3288,10 @@ public void removeGlossaryTerm(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param searchString string to find in the properties - * @param searchStringParameterName parameter supplying search string + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom paging start point * @param pageSize maximum results that can be returned * @param forLineage return elements marked with the Memento classification? @@ -3167,23 +3305,25 @@ public void removeGlossaryTerm(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public List findGlossaryTerms(String userId, - String assetManagerGUID, - String assetManagerName, - String searchString, - String searchStringParameterName, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime, - String methodName) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public List findGlossaryTerms(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryGUID, + String searchString, + List limitResultsByStatus, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { List results = glossaryTermHandler.findTerms(userId, + glossaryGUID, searchString, - searchStringParameterName, + getInstanceStatuses(limitResultsByStatus), startFrom, pageSize, forLineage, @@ -3204,6 +3344,32 @@ public List findGlossaryTerms(String userId, } + /** + * Transform a list of GlossaryTermStatus into InstanceStatuses. + * + * @param glossaryTermStatuses supplied glossary term statuses + * @return converted statuses + */ + private List getInstanceStatuses(List glossaryTermStatuses) + { + if (glossaryTermStatuses != null) + { + List instanceStatuses = new ArrayList<>(); + + for (GlossaryTermStatus glossaryTermStatus : glossaryTermStatuses) + { + instanceStatuses.add(getInstanceStatus(glossaryTermStatus)); + } + + if (!instanceStatuses.isEmpty()) + { + return instanceStatuses; + } + } + + return null; + } + /** * Retrieve the list of glossary terms associated with a glossary. * @@ -3325,8 +3491,10 @@ public List getTermsForGlossaryCategory(String userId, * @param userId calling user * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param glossaryGUID unique identifier of the glossary to query * @param name name to search for - * @param nameParameterName parameter supplying the name property + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom paging start point * @param pageSize maximum results that can be returned * @param forLineage return elements marked with the Memento classification? @@ -3340,23 +3508,25 @@ public List getTermsForGlossaryCategory(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public List getGlossaryTermsByName(String userId, - String assetManagerGUID, - String assetManagerName, - String name, - String nameParameterName, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime, - String methodName) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public List getGlossaryTermsByName(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryGUID, + String name, + List limitResultsByStatus, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { List results = glossaryTermHandler.getTermsByName(userId, + glossaryGUID, name, - nameParameterName, + getInstanceStatuses(limitResultsByStatus), startFrom, pageSize, forLineage, @@ -3406,7 +3576,7 @@ public GlossaryTermElement getGlossaryTermByGUID(String userId, UserNotAuthorizedException, PropertyServerException { - final String guidParameterName = "guid"; + final String guidParameterName = "guid"; GlossaryTermElement glossaryTerm = glossaryTermHandler.getTerm(userId, guid, @@ -3418,21 +3588,97 @@ public GlossaryTermElement getGlossaryTermByGUID(String userId, if (glossaryTerm != null) { glossaryTerm.setCorrelationHeaders(this.getCorrelationProperties(userId, - guid, - guidParameterName, - OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, - assetManagerGUID, - assetManagerName, - forLineage, - forDuplicateProcessing, - effectiveTime, - methodName)); + guid, + guidParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + assetManagerGUID, + assetManagerName, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName)); } return glossaryTerm; } + /** + * Retrieve all the versions of a glossary term. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param guid unique identifier of object to retrieve + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startFrom the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param oldestFirst defining how the results should be ordered. + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * @return list of beans + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem removing the properties from the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public List getGlossaryTermHistory(String userId, + String assetManagerGUID, + String assetManagerName, + String guid, + Date fromTime, + Date toTime, + int startFrom, + int pageSize, + boolean oldestFirst, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String guidParameterName = "guid"; + + HistorySequencingOrder sequencingOrder = HistorySequencingOrder.BACKWARDS; + + if (oldestFirst) + { + sequencingOrder = HistorySequencingOrder.FORWARDS; + } + List results = glossaryTermHandler.getBeanHistory(userId, + guid, + guidParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + fromTime, + toTime, + startFrom, + pageSize, + sequencingOrder, + forLineage, + forDuplicateProcessing, + glossaryTermHandler.getSupportedZones(), + effectiveTime, + methodName); + + this.addCorrelationPropertiesToGlossaryTerms(userId, + assetManagerGUID, + assetManagerName, + results, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + + return results; + } + + /* ========================================================================================= * Support for linkage to external glossary resources. These glossary resources are not * stored as metadata - they could be web pages, ontologies or some other format. diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/listener/AssetManagerOMRSTopicListener.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/listener/AssetManagerOMRSTopicListener.java index 8fea3f97c18..c78ab450ec4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/listener/AssetManagerOMRSTopicListener.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/listener/AssetManagerOMRSTopicListener.java @@ -490,9 +490,11 @@ public void processReclassifiedEntityEvent(String sourceName, *

* All relationships to the entity are also soft-deleted and will no longer be usable. These deleted relationships * will be notified through separate events. + *

*

* Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is deleted in * the remote repositories. + *

* * @param sourceName name of the source of the event. It may be the cohort name for incoming events or the * local repository, or event mapper name. @@ -800,6 +802,7 @@ public void processUpdatedRelationshipEvent(String sourceName, *

* Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right * relationship is deleted in the remote repositories. + *

* * @param sourceName name of the source of the event. It may be the cohort name for incoming events or the * local repository, or event mapper name. diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java index e62d1a4e623..ed30d8dc57e 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java @@ -44,12 +44,12 @@ class AssetManagerInstanceHandler extends OMASServiceInstanceHandler SoftwareCapabilityHandler getAssetManagerHandler(String userId, String serverName, String serviceOperationName) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { AssetManagerServicesInstance instance = (AssetManagerServicesInstance)super.getServerServiceInstance(userId, - serverName, - serviceOperationName); + serverName, + serviceOperationName); if (instance != null) { @@ -343,4 +343,127 @@ GovernanceActionHandler getGovernanceActionHandler(Stri return null; } + + + + /** + * Retrieve the specific handler for the access service. + * + * @param userId calling user + * @param serverName name of the server tied to the request + * @param serviceOperationName name of the REST API call (typically the top-level methodName) + * @return handler for use by the requested instance + * @throws InvalidParameterException no available instance for the requested server + * @throws UserNotAuthorizedException user does not have access to the requested server + * @throws PropertyServerException error in the requested server + */ + InformalTagHandler getInformalTagHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetManagerServicesInstance instance = (AssetManagerServicesInstance)super.getServerServiceInstance(userId, + serverName, + serviceOperationName); + + if (instance != null) + { + return instance.getInformalTagHandler(); + } + + return null; + } + + + /** + * Retrieve the specific handler for the access service. + * + * @param userId calling user + * @param serverName name of the server tied to the request + * @param serviceOperationName name of the REST API call (typically the top-level methodName) + * @return handler for use by the requested instance + * @throws InvalidParameterException no available instance for the requested server + * @throws UserNotAuthorizedException user does not have access to the requested server + * @throws PropertyServerException error in the requested server + */ + LikeHandler getLikeHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetManagerServicesInstance instance = (AssetManagerServicesInstance)super.getServerServiceInstance(userId, + serverName, + serviceOperationName); + + if (instance != null) + { + return instance.getLikeHandler(); + } + + return null; + } + + + /** + * Retrieve the specific handler for the access service. + * + * @param userId calling user + * @param serverName name of the server tied to the request + * @param serviceOperationName name of the REST API call (typically the top-level methodName) + * @return handler for use by the requested instance + * @throws InvalidParameterException no available instance for the requested server + * @throws UserNotAuthorizedException user does not have access to the requested server + * @throws PropertyServerException error in the requested server + */ + RatingHandler getRatingHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetManagerServicesInstance instance = (AssetManagerServicesInstance)super.getServerServiceInstance(userId, + serverName, + serviceOperationName); + + if (instance != null) + { + return instance.getRatingHandler(); + } + + return null; + } + + + /** + * Retrieve the specific handler for the access service. + * + * @param userId calling user + * @param serverName name of the server tied to the request + * @param serviceOperationName name of the REST API call (typically the top-level methodName) + * @return handler for use by the requested instance + * @throws InvalidParameterException no available instance for the requested server + * @throws UserNotAuthorizedException user does not have access to the requested server + * @throws PropertyServerException error in the requested server + */ + CommentHandler getCommentHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + + AssetManagerServicesInstance instance = (AssetManagerServicesInstance)super.getServerServiceInstance(userId, + serverName, + serviceOperationName); + + if (instance != null) + { + return instance.getCommentHandler(); + } + + return null; + } + } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java index 329a4e7a663..517ad43485c 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java @@ -43,7 +43,10 @@ public class AssetManagerServicesInstance extends OMASServiceInstance private final GovernanceActionHandler governanceActionHandler; private final AssetHandler governanceActionProcessHandler; private final GovernanceActionTypeHandler governanceActionTypeHandler; - + private final InformalTagHandler informalTagHandler; + private final LikeHandler likeHandler; + private final RatingHandler ratingHandler; + private final CommentHandler commentHandler; /** * Set up the local repository connector that will service the REST Calls. @@ -233,6 +236,61 @@ public AssetManagerServicesInstance(OMRSRepositoryConnector repositoryConnector, defaultZones, publishZones, auditLog); + + this.informalTagHandler = new InformalTagHandler<>(new InformalTagConverter<>(repositoryHelper, serviceName, serverName), + InformalTagElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + this.likeHandler = new LikeHandler<>(new LikeConverter<>(repositoryHelper, serviceName, serverName), + LikeElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + + this.ratingHandler = new RatingHandler<>(new RatingConverter<>(repositoryHelper, serviceName, serverName), + RatingElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + + this.commentHandler = new CommentHandler<>(new CommentConverter<>(repositoryHelper, serviceName, serverName), + CommentElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); } @@ -412,4 +470,67 @@ GovernanceActionHandler getGovernanceActionHandler() th return governanceActionHandler; } + + /** + * Return the handler for managing informal tag objects. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + InformalTagHandler getInformalTagHandler() throws PropertyServerException + { + final String methodName = "getInformalTagHandler"; + + validateActiveRepository(methodName); + + return informalTagHandler; + } + + + /** + * Return the handler for managing like objects. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + LikeHandler getLikeHandler() throws PropertyServerException + { + final String methodName = "getLikeHandler"; + + validateActiveRepository(methodName); + + return likeHandler; + } + + + /** + * Return the handler for managing rating objects. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + RatingHandler getRatingHandler() throws PropertyServerException + { + final String methodName = "getRatingHandler"; + + validateActiveRepository(methodName); + + return ratingHandler; + } + + + /** + * Return the handler for managing comment objects. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + CommentHandler getCommentHandler() throws PropertyServerException + { + final String methodName = "getCommentHandler"; + + validateActiveRepository(methodName); + + return commentHandler; + } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/CollaborationExchangeRESTServices.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/CollaborationExchangeRESTServices.java new file mode 100644 index 00000000000..fa223031d7a --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/CollaborationExchangeRESTServices.java @@ -0,0 +1,1321 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.server; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.CommentElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.InformalTagElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.LikeElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.RatingElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentType; +import org.odpi.openmetadata.accessservices.assetmanager.properties.FeedbackProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RatingProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.StarRating; +import org.odpi.openmetadata.accessservices.assetmanager.properties.TagProperties; +import org.odpi.openmetadata.accessservices.assetmanager.rest.CommentElementResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.CommentElementsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagUpdateRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagsResponse; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallLogger; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallToken; +import org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDListResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.CommentHandler; +import org.odpi.openmetadata.commonservices.generichandlers.InformalTagHandler; +import org.odpi.openmetadata.commonservices.generichandlers.LikeHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.RatingHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + +import java.util.Date; + + +/** + * The AssetManagerRESTServices provides the server-side implementation of the Asset Manager Open Metadata + * Assess Service (OMAS). This interface provides connections to elements and APIs for adding feedback + * on the element. + */ +public class CollaborationExchangeRESTServices +{ + private static final AssetManagerInstanceHandler instanceHandler = new AssetManagerInstanceHandler(); + private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(AssetManagerRESTServices.class), + instanceHandler.getServiceName()); + + /** + * Default constructor + */ + public CollaborationExchangeRESTServices() + { + } + + + + /** + * Adds a star rating and optional review text to the element. If the user has already attached + * a rating then the original one is over-ridden. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param guid String - unique id for the element. + * @param requestBody containing the StarRating and user review of referenceable (probably element). + * + * @return void or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public VoidResponse addRatingToElement(String serverName, + String userId, + String guid, + RatingProperties requestBody) + { + final String methodName = "addRatingToElement"; + final String guidParameterName = "guid"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + RatingHandler handler = instanceHandler.getRatingHandler(userId, serverName, methodName); + + int starRating = StarRating.NO_RECOMMENDATION.getOpenTypeOrdinal(); + + if (requestBody.getStarRating() != null) + { + starRating = requestBody.getStarRating().getOpenTypeOrdinal(); + } + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.saveRating(userId, + null, + null, + guid, + guidParameterName, + starRating, + requestBody.getReview(), + requestBody.getIsPublic(), + false, + false, + new Date(), + methodName); + + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Removes a star rating that was added to the element by this user. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param guid String - unique id for the rating object + * @param requestBody null request body needed to satisfy the HTTP Post request + * + * @return void or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem updating the element properties in + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @SuppressWarnings(value = "unused") + public VoidResponse removeRatingFromElement(String serverName, + String userId, + String guid, + NullRequestBody requestBody) + { + final String methodName = "removeRatingFromElement"; + final String guidParameterName = "guid"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + RatingHandler handler = instanceHandler.getRatingHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.removeRating(userId, + null, + null, + guid, + guidParameterName, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Adds a "LikeProperties" to the element. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param guid String - unique id for the element. + * @param requestBody feedback request body . + * + * @return void or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public VoidResponse addLikeToElement(String serverName, + String userId, + String guid, + FeedbackProperties requestBody) + { + final String methodName = "addLikeToElement"; + final String guidParameterName = "guid"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + LikeHandler handler = instanceHandler.getLikeHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.saveLike(userId, + null, + null, + guid, + guidParameterName, + requestBody.getIsPublic(), + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Removes a "LikeProperties" added to the element by this user. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param guid String - unique id for the like object + * @param requestBody null request body needed to satisfy the HTTP Post request + * + * @return void or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem updating the element properties in + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @SuppressWarnings(value = "unused") + public VoidResponse removeLikeFromElement(String serverName, + String userId, + String guid, + NullRequestBody requestBody) + { + final String methodName = "removeLikeFromElement"; + final String guidParameterName = "guid"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + LikeHandler handler = instanceHandler.getLikeHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.removeLike(userId, + null, + null, + guid, + guidParameterName, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Adds a comment to the element. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param guid String - unique id for the element. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return guid for new comment object or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public GUIDResponse addCommentToElement(String serverName, + String userId, + String guid, + CommentProperties requestBody) + { + final String methodName = "addCommentToElement"; + final String guidParameterName = "guid"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + int commentType = CommentType.STANDARD_COMMENT.getOpenTypeOrdinal(); + + if (requestBody.getCommentType() != null) + { + commentType = requestBody.getCommentType().getOpenTypeOrdinal(); + } + CommentHandler handler = instanceHandler.getCommentHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setGUID(handler.attachNewComment(userId, + null, + null, + guid, + guid, + guidParameterName, + commentType, + requestBody.getCommentText(), + requestBody.getIsPublic(), + null, + null, + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Adds a reply to a comment. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param elementGUID String - unique id of element that this chain of comments is linked. + * @param commentGUID String - unique id for an existing comment. Used to add a reply to a comment. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return guid for new comment object or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public GUIDResponse addCommentReply(String serverName, + String userId, + String elementGUID, + String commentGUID, + CommentProperties requestBody) + { + final String guidParameterName = "commentGUID"; + final String methodName = "addCommentReply"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + int commentType = CommentType.STANDARD_COMMENT.getOpenTypeOrdinal(); + + if (requestBody.getCommentType() != null) + { + commentType = requestBody.getCommentType().getOpenTypeOrdinal(); + } + + CommentHandler handler = instanceHandler.getCommentHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setGUID(handler.attachNewComment(userId, + null, + null, + elementGUID, + commentGUID, + guidParameterName, + commentType, + requestBody.getCommentText(), + requestBody.getIsPublic(), + null, + null, + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update an existing comment. + * + * @param serverName name of the server instances for this request. + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element that the comment is attached to (directly or indirectly). + * @param commentGUID unique identifier for the comment to change. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException There is a problem updating the element properties in the metadata repository. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @SuppressWarnings(value = "unused") + public VoidResponse updateComment(String serverName, + String userId, + String elementGUID, + String commentGUID, + CommentProperties requestBody) + { + final String guidParameterName = "commentGUID"; + final String methodName = "updateComment"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + int commentType = CommentType.STANDARD_COMMENT.getOpenTypeOrdinal(); + + if (requestBody.getCommentType() != null) + { + commentType = requestBody.getCommentType().getOpenTypeOrdinal(); + } + + CommentHandler handler = instanceHandler.getCommentHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.updateComment(userId, + null, + null, + commentGUID, + guidParameterName, + commentType, + requestBody.getCommentText(), + requestBody.getIsPublic(), + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Removes a comment added to the element by this user. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param elementGUID String - unique id for the element object + * @param commentGUID String - unique id for the comment object + * @param requestBody null request body needed to satisfy the HTTP Post request + * + * @return void or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem updating the element properties in + * the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @SuppressWarnings(value = "unused") + public VoidResponse removeCommentFromElement(String serverName, + String userId, + String elementGUID, + String commentGUID, + NullRequestBody requestBody) + { + final String guidParameterName = "commentGUID"; + final String methodName = "removeElementComment"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + CommentHandler handler = instanceHandler.getCommentHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.removeCommentFromElement(userId, + null, + null, + commentGUID, + guidParameterName, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the requested comment. + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param commentGUID unique identifier for the comment object. + * @return comment properties 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 CommentElementResponse getComment(String serverName, + String userId, + String commentGUID) + { + final String methodName = "getComment"; + final String guidParameterName = "commentGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + CommentElementResponse response = new CommentElementResponse(); + AuditLog auditLog = null; + + try + { + CommentHandler handler = instanceHandler.getCommentHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setElement(handler.getBeanFromRepository(userId, + commentGUID, + guidParameterName, + OpenMetadataAPIMapper.COMMENT_TYPE_NAME, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the comments attached to an element. + * + * @param serverName name of the server instances for this request + * @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. + * @return list of comments 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 CommentElementsResponse getAttachedComments(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getAttachedComments"; + final String guidParameterName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + CommentElementsResponse response = new CommentElementsResponse(); + AuditLog auditLog = null; + + try + { + CommentHandler handler = instanceHandler.getCommentHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setElementList(handler.getAttachedElements(userId, + elementGUID, + guidParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TO_COMMENT_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_COMMENT_TYPE_NAME, + OpenMetadataAPIMapper.COMMENT_TYPE_NAME, + null, + null, + 2, + false, + false, + startFrom, + pageSize, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Creates a new informal tag and returns the unique identifier for it. + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request + * @param requestBody contains the name of the tag and (optional) description of the tag + * + * @return guid for new tag or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public GUIDResponse createTag(String serverName, + String userId, + TagProperties requestBody) + { + final String methodName = "createTag"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setGUID(handler.createTag(userId, + null, + null, + requestBody.getName(), + requestBody.getDescription(), + (!requestBody.getIsPrivateTag()), + null, + null, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Updates the description of an existing tag (either private or public). + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param tagGUID unique id for the tag. + * @param requestBody contains the name of the tag and (optional) description of the tag. + * + * @return void or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public VoidResponse updateTagDescription(String serverName, + String userId, + String tagGUID, + InformalTagUpdateRequestBody requestBody) + { + final String methodName = "updateTagDescription"; + final String tagGUIDParameterName = "tagGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.updateTagDescription(userId, + null, + null, + tagGUID, + tagGUIDParameterName, + requestBody.getDescription(), + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Removes a tag from the repository. All the relationships to referenceables are lost. + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param tagGUID unique id for the tag. + * @param requestBody null request body. + * + * @return void or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @SuppressWarnings(value = "unused") + public VoidResponse deleteTag(String serverName, + String userId, + String tagGUID, + NullRequestBody requestBody) + { + final String methodName = "deleteTag"; + final String tagGUIDParameterName = "tagGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.deleteTag(userId, + null, + null, + tagGUID, + tagGUIDParameterName, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the tag for the supplied unique identifier (guid). + * + * @param serverName name of the server instances for this request + * @param userId userId of the user making the request. + * @param guid unique identifier of the tag. + * + * @return Tag object or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public InformalTagResponse getTag(String serverName, + String userId, + String guid) + { + final String methodName = "getTag"; + final String guidParameterName = "guid"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + InformalTagResponse response = new InformalTagResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setTag(handler.getTag(userId, + guid, + guidParameterName, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the list of tags exactly matching the supplied name. + * + * @param serverName name of the server instances for this request + * @param userId the name of the calling user. + * @param requestBody name of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public InformalTagsResponse getTagsByName(String serverName, + String userId, + NameRequestBody requestBody, + int startFrom, + int pageSize) + { + final String methodName = "getTagsByName"; + final String nameParameterName = "tagName"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + InformalTagsResponse response = new InformalTagsResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setTags(handler.getTagsByName(userId, + requestBody.getName(), + nameParameterName, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the list of the calling user's private tags exactly matching the supplied name. + * + * @param serverName name of the server instances for this request + * @param userId the name of the calling user. + * @param requestBody name of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public InformalTagsResponse getMyTagsByName(String serverName, + String userId, + NameRequestBody requestBody, + int startFrom, + int pageSize) + { + final String methodName = "getMyTagsByName"; + final String nameParameterName = "tagName"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + InformalTagsResponse response = new InformalTagsResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setTags(handler.getMyTagsByName(userId, + requestBody.getName(), + nameParameterName, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the list of tags containing the supplied string in either the name or description. + * + * @param serverName name of the server instances for this request + * @param userId the name of the calling user. + * @param requestBody name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public InformalTagsResponse findTags(String serverName, + String userId, + SearchStringRequestBody requestBody, + int startFrom, + int pageSize) + { + final String methodName = "findTags"; + final String nameParameterName = "tagName"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + InformalTagsResponse response = new InformalTagsResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setTags(handler.findTags(userId, + requestBody.getSearchString(), + nameParameterName, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the list of the calling user's private tags containing the supplied string in either the name or description. + * + * @param serverName name of the server instances for this request + * @param userId the name of the calling user. + * @param requestBody name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return tag list or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public InformalTagsResponse findMyTags(String serverName, + String userId, + SearchStringRequestBody requestBody, + int startFrom, + int pageSize) + { + final String methodName = "findMyTags"; + final String nameParameterName = "tagName"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + InformalTagsResponse response = new InformalTagsResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + response.setTags(handler.findMyTags(userId, + requestBody.getSearchString(), + nameParameterName, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Adds a tag (either private of public) to an element. + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id of the tag. + * @param requestBody feedback request body. + * + * @return void or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public VoidResponse addTagToElement(String serverName, + String userId, + String elementGUID, + String tagGUID, + FeedbackProperties requestBody) + { + final String methodName = "addTagToElement"; + final String elementGUIDParameterName = "elementGUID"; + final String tagGUIDParameterName = "tagGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + boolean isPublic = false; + + if (requestBody != null) + { + isPublic = requestBody.getIsPublic(); + } + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + handler.addTagToElement(userId, + null, + null, + elementGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.ASSET_TYPE_NAME, + tagGUID, + tagGUIDParameterName, + instanceHandler.getSupportedZones(userId, serverName, methodName), + isPublic, + null, + null, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Removes a tag from the element that was added by this user. + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id for the tag. + * @param requestBody null request body needed for correct protocol exchange. + * + * @return void or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @SuppressWarnings(value = "unused") + public VoidResponse removeTagFromElement(String serverName, + String userId, + String elementGUID, + String tagGUID, + NullRequestBody requestBody) + { + final String methodName = "removeTagFromElement"; + final String elementGUIDParameterName = "elementGUID"; + final String tagGUIDParameterName = "tagGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + handler.removeTagFromElement(userId, + null, + null, + elementGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.ASSET_TYPE_NAME, + tagGUID, + tagGUIDParameterName, + instanceHandler.getSupportedZones(userId, serverName, methodName), + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return the list of unique identifiers for elements that are linked to a specific tag either directly, or via one + * of its schema elements. + * + * @param serverName name of the server instances for this request + * @param userId the name of the calling user. + * @param tagGUID unique identifier of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return element guid list or + * InvalidParameterException the userId is null or invalid or + * PropertyServerException there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public GUIDListResponse getElementsByTag(String serverName, + String userId, + String tagGUID, + int startFrom, + int pageSize) + { + final String methodName = "getElementsByTag"; + final String tagGUIDParameterName = "tagGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDListResponse response = new GUIDListResponse(); + AuditLog auditLog = null; + + try + { + InformalTagHandler handler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); + + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + response.setGUIDs(handler.getAttachedElementGUIDs(userId, + tagGUID, + tagGUIDParameterName, + OpenMetadataAPIMapper.INFORMAL_TAG_TYPE_NAME, + null, + null, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + false, + false, + startFrom, + pageSize, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/GlossaryExchangeRESTServices.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/GlossaryExchangeRESTServices.java index f6fa01cffff..57e5d5e3b58 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/GlossaryExchangeRESTServices.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/GlossaryExchangeRESTServices.java @@ -4,6 +4,7 @@ package org.odpi.openmetadata.accessservices.assetmanager.server; import org.odpi.openmetadata.accessservices.assetmanager.handlers.GlossaryExchangeHandler; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermCategorization; import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermRelationship; import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; @@ -14,8 +15,13 @@ import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.slf4j.LoggerFactory; +import java.util.Date; +import java.util.List; /** @@ -1136,13 +1142,13 @@ public VoidResponse removeGlossaryCategory(String serverName, * UserNotAuthorizedException the user is not authorized to issue this request * PropertyServerException there is a problem reported in the open metadata server(s) */ - public GlossaryCategoryElementsResponse findGlossaryCategories(String serverName, - String userId, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - SearchStringRequestBody requestBody) + public GlossaryCategoryElementsResponse findGlossaryCategories(String serverName, + String userId, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + GlossarySearchStringRequestBody requestBody) { final String methodName = "findGlossaryCategories"; @@ -1162,6 +1168,7 @@ public GlossaryCategoryElementsResponse findGlossaryCategories(String response.setElementList(handler.findGlossaryCategories(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), + requestBody.getGlossaryGUID(), requestBody.getSearchString(), requestBody.getSearchStringParameterName(), startFrom, @@ -1281,13 +1288,13 @@ public GlossaryCategoryElementsResponse getCategoriesForGlossary(String * UserNotAuthorizedException the user is not authorized to issue this request * PropertyServerException there is a problem reported in the open metadata server(s) */ - public GlossaryCategoryElementsResponse getGlossaryCategoriesByName(String serverName, - String userId, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - NameRequestBody requestBody) + public GlossaryCategoryElementsResponse getGlossaryCategoriesByName(String serverName, + String userId, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + GlossaryNameRequestBody requestBody) { final String methodName = "getGlossaryCategoriesByName"; @@ -1307,6 +1314,7 @@ public GlossaryCategoryElementsResponse getGlossaryCategoriesByName(String response.setElementList(handler.getGlossaryCategoriesByName(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), + requestBody.getGlossaryGUID(), requestBody.getName(), requestBody.getNameParameterName(), startFrom, @@ -1724,6 +1732,7 @@ public GUIDResponse createGlossaryTermFromTemplate(String serverNa * @param serverName name of the server to route the request to * @param userId calling user * @param glossaryTermGUID unique identifier of the glossary term to update + * @param isMergeUpdate should the properties be merged with the existing properties or completely over-write them * @param forLineage return elements marked with the Memento classification? * @param forDuplicateProcessing do not merge elements marked as duplicates? * @param requestBody new properties for the glossary term @@ -1736,6 +1745,7 @@ public GUIDResponse createGlossaryTermFromTemplate(String serverNa public VoidResponse updateGlossaryTerm(String serverName, String userId, String glossaryTermGUID, + boolean isMergeUpdate, boolean forLineage, boolean forDuplicateProcessing, GlossaryTermRequestBody requestBody) @@ -1759,6 +1769,7 @@ public VoidResponse updateGlossaryTerm(String serverName, requestBody.getMetadataCorrelationProperties(), glossaryTermGUID, requestBody.getElementProperties(), + isMergeUpdate, forLineage, forDuplicateProcessing, requestBody.getEffectiveTime(), @@ -1878,12 +1889,10 @@ public VoidResponse setupTermCategory(String serverName, { auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof GlossaryTermCategorization)) + if ((requestBody != null) && (requestBody.getProperties() instanceof GlossaryTermCategorization properties)) { GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName); - GlossaryTermCategorization properties = (GlossaryTermCategorization)requestBody.getProperties(); - handler.setupTermCategory(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -2021,12 +2030,10 @@ public VoidResponse setupTermRelationship(String serverName, { auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof GlossaryTermRelationship)) + if ((requestBody != null) && (requestBody.getProperties() instanceof GlossaryTermRelationship properties)) { GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName); - GlossaryTermRelationship properties = (GlossaryTermRelationship) requestBody.getProperties(); - handler.setupTermRelationship(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -2092,12 +2099,10 @@ public VoidResponse updateTermRelationship(String serverName, { auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof GlossaryTermRelationship)) + if ((requestBody != null) && (requestBody.getProperties() instanceof GlossaryTermRelationship properties)) { GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName); - GlossaryTermRelationship properties = (GlossaryTermRelationship) requestBody.getProperties(); - handler.updateTermRelationship(userId, glossaryTermOneGUID, relationshipTypeName, @@ -3049,6 +3054,132 @@ public VoidResponse clearTermAsObjectIdentifier(String serverName, } + /** + * Undo the last update to the glossary term. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param forLineage return elements marked with the Memento classification? + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * @param requestBody properties to help with the mapping of the elements in the external asset manager and open metadata + * + * @return void or + * InvalidParameterException one of the parameters is invalid + * UserNotAuthorizedException the user is not authorized to issue this request + * PropertyServerException there is a problem reported in the open metadata server(s) + */ + public GlossaryTermElementResponse undoGlossaryTermUpdate(String serverName, + String userId, + String glossaryTermGUID, + boolean forLineage, + boolean forDuplicateProcessing, + UpdateRequestBody requestBody) + { + final String methodName = "undoGlossaryTermUpdate"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GlossaryTermElementResponse response = new GlossaryTermElementResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName); + + if (requestBody != null) + { + response.setElement(handler.undoGlossaryTermUpdate(userId, + requestBody.getMetadataCorrelationProperties(), + glossaryTermGUID, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Archive the metadata element representing a glossary term. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param glossaryTermGUID unique identifier of the metadata element to archive + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * @param requestBody properties to help with the mapping of the elements in the external asset manager and open metadata + * + * @return void or + * InvalidParameterException one of the parameters is invalid + * UserNotAuthorizedException the user is not authorized to issue this request + * PropertyServerException there is a problem reported in the open metadata server(s) + */ + public VoidResponse archiveGlossaryTerm(String serverName, + String userId, + String glossaryTermGUID, + boolean forDuplicateProcessing, + ArchiveRequestBody requestBody) + { + final String methodName = "archiveGlossaryTerm"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.archiveGlossaryTerm(userId, + requestBody.getMetadataCorrelationProperties(), + glossaryTermGUID, + requestBody.getElementProperties(), + forDuplicateProcessing, + requestBody.getEffectiveTime(), + methodName); + } + else + { + handler.archiveGlossaryTerm(userId, + null, + glossaryTermGUID, + null, + forDuplicateProcessing, + null, + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + /** * Remove the metadata element representing a glossary term. * @@ -3064,10 +3195,10 @@ public VoidResponse clearTermAsObjectIdentifier(String serverName, * UserNotAuthorizedException the user is not authorized to issue this request * PropertyServerException there is a problem reported in the open metadata server(s) */ - public VoidResponse removeGlossaryTerm(String serverName, - String userId, - String glossaryTermGUID, - boolean forLineage, + public VoidResponse removeGlossaryTerm(String serverName, + String userId, + String glossaryTermGUID, + boolean forLineage, boolean forDuplicateProcessing, UpdateRequestBody requestBody) { @@ -3096,7 +3227,13 @@ public VoidResponse removeGlossaryTerm(String serverName, } else { - restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + handler.removeGlossaryTerm(userId, + null, + glossaryTermGUID, + forLineage, + forDuplicateProcessing, + null, + methodName); } } catch (Exception error) @@ -3127,13 +3264,13 @@ public VoidResponse removeGlossaryTerm(String serverName, * UserNotAuthorizedException the user is not authorized to issue this request * PropertyServerException there is a problem reported in the open metadata server(s) */ - public GlossaryTermElementsResponse findGlossaryTerms(String serverName, - String userId, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - SearchStringRequestBody requestBody) + public GlossaryTermElementsResponse findGlossaryTerms(String serverName, + String userId, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + GlossarySearchStringRequestBody requestBody) { final String methodName = "findGlossaryTerms"; @@ -3153,8 +3290,9 @@ public GlossaryTermElementsResponse findGlossaryTerms(String se response.setElementList(handler.findGlossaryTerms(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), + requestBody.getGlossaryGUID(), requestBody.getSearchString(), - requestBody.getSearchStringParameterName(), + requestBody.getLimitResultsByStatus(), startFrom, pageSize, forLineage, @@ -3350,13 +3488,13 @@ public GlossaryTermElementsResponse getTermsForGlossaryCategory(String * UserNotAuthorizedException the user is not authorized to issue this request * PropertyServerException there is a problem reported in the open metadata server(s) */ - public GlossaryTermElementsResponse getGlossaryTermsByName(String serverName, - String userId, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - NameRequestBody requestBody) + public GlossaryTermElementsResponse getGlossaryTermsByName(String serverName, + String userId, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + GlossaryNameRequestBody requestBody) { final String methodName = "getGlossaryTermsByName"; @@ -3376,8 +3514,9 @@ public GlossaryTermElementsResponse getGlossaryTermsByName(String ser response.setElementList(handler.getGlossaryTermsByName(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), + requestBody.getGlossaryGUID(), requestBody.getName(), - requestBody.getNameParameterName(), + requestBody.getLimitResultsByStatus(), startFrom, pageSize, forLineage, @@ -3469,6 +3608,79 @@ public GlossaryTermElementResponse getGlossaryTermByGUID(String } + /** + * Retrieve all the versions of a glossary term. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param guid unique identifier of object to retrieve + * @param startFrom the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param oldestFirst defining how the results should be ordered. + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param requestBody the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @return list of beans or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem removing the properties from the repositories. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public GlossaryTermElementsResponse getGlossaryTermHistory(String serverName, + String userId, + String guid, + int startFrom, + int pageSize, + boolean oldestFirst, + boolean forLineage, + boolean forDuplicateProcessing, + HistoryRequestBody requestBody) + { + final String methodName = "getGlossaryTermHistory"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GlossaryTermElementsResponse response = new GlossaryTermElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + GlossaryExchangeHandler handler = instanceHandler.getGlossaryExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.getGlossaryTermHistory(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + guid, + requestBody.getFromTime(), + requestBody.getToTime(), + startFrom, + pageSize, + oldestFirst, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + /* ========================================================================================= * Support for linkage to external glossary resources. These glossary resources are not * stored as metadata - they could be web pages, ontologies or some other format. diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/StewardshipExchangeRESTServices.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/StewardshipExchangeRESTServices.java new file mode 100644 index 00000000000..5a5701fc15a --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/StewardshipExchangeRESTServices.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.server; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.SoftwareCapabilityElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SecurityTagsProperties; +import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallLogger; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallToken; +import org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.SoftwareCapabilityHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +/** + * AssetManagerRESTServices provides part of the server-side support for the Asset Owner Open Metadata Access Service (OMAS). + * There are other REST services that provide specialized methods for specific types of Asset. + */ +public class StewardshipExchangeRESTServices +{ + private static final AssetManagerInstanceHandler instanceHandler = new AssetManagerInstanceHandler(); + private static final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(StewardshipExchangeRESTServices.class), + instanceHandler.getServiceName()); + + + /** + * Default constructor + */ + public StewardshipExchangeRESTServices() + { + } + + + /** + * Add or replace the security tags for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of element to attach to + * @param requestBody list of security labels and properties + * + * @return void or + * InvalidParameterException full path or userId is null or + * PropertyServerException problem accessing property server or + * UserNotAuthorizedException security access problem + */ + public VoidResponse addSecurityTags(String serverName, + String userId, + String elementGUID, + SecurityTagsProperties requestBody) + { + final String methodName = "addSecurityTags"; + final String assetGUIDParameterName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + SoftwareCapabilityHandler handler = instanceHandler.getAssetManagerHandler(userId, serverName, methodName); + + handler.addSecurityTags(userId, + elementGUID, + assetGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + requestBody.getSecurityLabels(), + requestBody.getSecurityProperties(), + requestBody.getAccessGroups(), + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Remove the security tags classification from an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of element + * @param requestBody null request body + * + * @return void or + * InvalidParameterException full path or userId is null or + * PropertyServerException problem accessing property server or + * UserNotAuthorizedException security access problem + */ + @SuppressWarnings(value = "unused") + public VoidResponse removeSecurityTags(String serverName, + String userId, + String elementGUID, + NullRequestBody requestBody) + { + final String methodName = "removeSecurityTags"; + final String assetGUIDParameterName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + SoftwareCapabilityHandler handler = instanceHandler.getAssetManagerHandler(userId, serverName, methodName); + + handler.removeSecurityTags(userId, + elementGUID, + assetGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/CollaborationExchangeResource.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/CollaborationExchangeResource.java new file mode 100644 index 00000000000..a1fee892c8d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/CollaborationExchangeResource.java @@ -0,0 +1,670 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.assetmanager.properties.CommentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.FeedbackProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RatingProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.TagProperties; +import org.odpi.openmetadata.accessservices.assetmanager.rest.CommentElementResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.CommentElementsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagUpdateRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.InformalTagsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.server.CollaborationExchangeRESTServices; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDListResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The CollaborationExchangeResource provides part of the server-side implementation of the Asset Manager Open Metadata + * Assess Service (OMAS). This interface provides collaboration elements support - such as comments, likes, ratings, informal tags. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-manager/users/{userId}") + +@Tag(name="Asset Manager OMAS", + description="The Asset Manager OMAS provides APIs and events for managing metadata exchange with third party asset managers, such as data catalogs.", + externalDocs=@ExternalDocumentation(description="Asset Manager Open Metadata Access Service (OMAS)", + url="https://egeria-project.org/services/omas/asset-manager/overview/")) + +public class CollaborationExchangeResource +{ + private final CollaborationExchangeRESTServices restAPI = new CollaborationExchangeRESTServices(); + + /** + * Default constructor + */ + public CollaborationExchangeResource() + { + } + + + /** + * Adds a reply to a comment. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID String - unique id of element that this chain of comments is linked. + * @param commentGUID String - unique id for an existing comment. Used to add a reply to a comment. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return elementGUID for new comment object or + * InvalidParameterException one of the parameters is null or invalid or + * PropertyServerException There is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/comments/{commentGUID}/replies") + + @Operation(summary="addCommentReply", + description="Adds a reply to a comment.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public GUIDResponse addCommentReply(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String commentGUID, + @RequestBody CommentProperties requestBody) + { + return restAPI.addCommentReply(serverName, userId, elementGUID, commentGUID, requestBody); + } + + + /** + * Creates a comment and attaches it to an element. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID String - unique id for the element. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return elementGUID for new comment object or + * InvalidParameterException one of the parameters is null or invalid or + * PropertyServerException There is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/comments") + + @Operation(summary="addCommentToElement", + description="Creates a comment and attaches it to an element.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public GUIDResponse addCommentToElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody CommentProperties requestBody) + { + return restAPI.addCommentToElement(serverName, userId, elementGUID, requestBody); + } + + + /** + * Creates a "like" object and attaches it to an element. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID String - unique id for the element. + * @param requestBody feedback request body. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid or + * PropertyServerException There is a problem adding the element properties to + * the metadata repository or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/likes") + + @Operation(summary="addLikeToElement", + description="Creates a like object and attaches it to an element.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public VoidResponse addLikeToElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody FeedbackProperties requestBody) + { + return restAPI.addLikeToElement(serverName, userId, elementGUID, requestBody); + } + + + /** + * Adds a star rating and optional review text to the element. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID String - unique id for the element. + * @param requestBody containing the StarRating and user review of element. + * + * @return elementGUID for new review object or + * InvalidParameterException one of the parameters is null or invalid or + * PropertyServerException There is a problem adding the element properties to the metadata repository or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/ratings") + + @Operation(summary="addRatingToElement", + description="Adds a star rating and optional review text to the element.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public VoidResponse addRatingToElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody RatingProperties requestBody) + { + return restAPI.addRatingToElement(serverName, userId, elementGUID, requestBody); + } + + + /** + * Adds an informal tag (either private of public) to an element. + * + * @param serverName name of the server instances for this request. + * @param userId userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id of the tag. + * @param requestBody null request body needed for correct protocol exchange. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid or + * PropertyServerException There is a problem adding the element properties to the metadata repository or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/tags/{tagGUID}") + + @Operation(summary="addTagToElement", + description="Adds an informal tag (either private of public) to an element.", + externalDocs=@ExternalDocumentation(description="Element Classifiers", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-classifiers")) + + public VoidResponse addTagToElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String tagGUID, + @RequestBody FeedbackProperties requestBody) + { + return restAPI.addTagToElement(serverName, userId, elementGUID, tagGUID, requestBody); + } + + + /** + * Creates a new informal tag and returns the unique identifier for it. + * + * @param serverName name of the server instances for this request. + * @param userId userId of user making request. + * @param requestBody public/private flag, name of the tag and (optional) description of the tag. + * + * @return new elementGUID or + * InvalidParameterException one of the parameters is null or invalid or + * PropertyServerException There is a problem adding the element properties to the metadata repository or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags") + + @Operation(summary="createTag", + description="Creates a new informal tag and returns the unique identifier for it.", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public GUIDResponse createTag(@PathVariable String serverName, + @PathVariable String userId, + @RequestBody TagProperties requestBody) + { + return restAPI.createTag(serverName, userId, requestBody); + } + + + /** + * Removes an informal tag from the repository. All the tagging relationships to this informal tag are lost. + * A private tag can be deleted by its creator and all the references are lost; + * a public tag can be deleted by anyone, but only if it is not attached to any referenceable. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param tagGUID String - unique id for the tag. + * @param requestBody null request body. + * + * @return void or + * InvalidParameterException - one of the parameters is null or invalid or + * PropertyServerException - there is a problem updating the element properties in the metadata repository or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags/{tagGUID}/remove") + + @Operation(summary="deleteTag", + description="Removes an informal tag from the repository. All the tagging relationships to this informal tag are lost. A private tag can be deleted by its creator and all the references are lost; a public tag can be deleted by anyone, but only if it is not attached to any referenceable.", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public VoidResponse deleteTag(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String tagGUID, + @RequestBody(required = false) NullRequestBody requestBody) + { + return restAPI.deleteTag(serverName, userId, tagGUID, requestBody); + } + + + /** + * Return the list of unique identifiers for elements that are linked to a specific tag either directly, or via one of its schema elements. + * + * @param serverName name of the server instances for this request + * @param userId the name of the calling user. + * @param tagGUID unique identifier of tag. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return element guid list or + * InvalidParameterException the userId is null or invalid or + * PropertyServerException there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @GetMapping(path = "/elements/by-tag/{tagGUID}") + + @Operation(summary="getElementsByTag", + description="Return the list of unique identifiers for elements that are linked to a specific tag either directly, or via one of its schema elements.", + externalDocs=@ExternalDocumentation(description="Element classifiers", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-classifiers")) + + public GUIDListResponse getElementsByTag(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String tagGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + + { + return restAPI.getElementsByTag(serverName, userId, tagGUID, startFrom, pageSize); + } + + + /** + * Return the informal tag for the supplied unique identifier (tagGUID). + * + * @param serverName name of the server instances for this request. + * @param userId userId of the user making the request. + * @param tagGUID unique identifier of the meaning. + * + * @return tag object or + * InvalidParameterException the userId is null or invalid or + * PropertyServerException there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @GetMapping(path = "/tags/{tagGUID}") + + @Operation(summary="getTag", + description="Return the informal tag for the supplied unique identifier (tagGUID).", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public InformalTagResponse getTag(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String tagGUID) + { + return restAPI.getTag(serverName, userId, tagGUID); + } + + + /** + * Return the tags exactly matching the supplied name. + * + * @param serverName name of the server instances for this request. + * @param userId the name of the calling user. + * @param requestBody name of tag. + * @param startFrom index of the list to start from (0 for start). + * @param pageSize maximum number of elements to return. + * @return list of tag objects or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags/by-name") + + @Operation(summary="getTagsByName", + description="Return the tags exactly matching the supplied name.", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public InformalTagsResponse getTagsByName(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody NameRequestBody requestBody) + { + return restAPI.getTagsByName(serverName, userId, requestBody, startFrom, pageSize); + } + + + /** + * Return the list of the calling user's private informal tags exactly matching the supplied name. + * + * @param serverName name of the server instances for this request. + * @param userId the name of the calling user. + * @param requestBody name of tag. + * @param startFrom index of the list to start from (0 for start). + * @param pageSize maximum number of elements to return. + * @return list of tag objects or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags/private/by-name") + + @Operation(summary="getMyTagsByName", + description="Return the list of the calling user's private informal tags exactly matching the supplied name.", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public InformalTagsResponse getMyTagsByName(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody NameRequestBody requestBody) + { + return restAPI.getMyTagsByName(serverName, userId, requestBody, startFrom, pageSize); + } + + + /** + * Return the list of informal tags containing the supplied string in either the name or description. The search string is a regular expression (RegEx). + * + * @param serverName name of the server instances for this request. + * @param userId the name of the calling user. + * @param requestBody name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start). + * @param pageSize maximum number of elements to return. + * @return list of tag objects or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags/by-search-string") + + @Operation(summary="findTags", + description="Return the list of informal tags containing the supplied string in either the name or description. The search string is a regular expression (RegEx).", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public InformalTagsResponse findTags(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.findTags(serverName, userId, requestBody, startFrom, pageSize); + } + + + /** + * Return the list of the calling user's private tags containing the supplied string in either the name or description. The search string is a regular expression (RegEx). + * + * @param serverName name of the server instances for this request. + * @param userId the name of the calling user. + * @param requestBody name of tag. This may include wild card characters. + * @param startFrom index of the list to start from (0 for start). + * @param pageSize maximum number of elements to return. + * @return list of tag objects or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags/private/by-search-string") + + @Operation(summary="findMyTags", + description="Return the list of the calling user's private tags containing the supplied string in either the name or description. The search string is a regular expression (RegEx).", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public InformalTagsResponse findMyTags(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.findMyTags(serverName, userId, requestBody, startFrom, pageSize); + } + + + /** + * Removes a comment added to the element by this user. This deletes the link to the comment, the comment itself and any comment replies attached to it. + * + * @param serverName name of the server instances for this request + * @param userId String - userId of user making request. + * @param elementGUID String - unique id for the element object + * @param commentGUID String - unique id for the comment object + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException There is a problem updating the element properties in the metadata repository. + * UserNotAuthorizedException the user does not have permission to perform this request. + */ + @PostMapping(path = "/elements/{elementGUID}/comments/{commentGUID}/remove") + + @Operation(summary="removeCommentFromElement", + description="Removes a comment added to the element by this user. This deletes the link to the comment, the comment itself and any comment replies attached to it.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public VoidResponse removeCommentFromElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String commentGUID, + @RequestBody(required = false) NullRequestBody requestBody) + { + return restAPI.removeCommentFromElement(serverName, userId, elementGUID, commentGUID, requestBody); + } + + + /** + * Return the requested comment. + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param commentGUID unique identifier for the comment object. + * @return comment properties 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. + */ + @GetMapping(path = "/comments/{commentGUID}") + + public CommentElementResponse getComment(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String commentGUID) + { + return restAPI.getComment(serverName, userId, commentGUID); + } + + + /** + * Return the comments attached to an element. + * + * @param serverName name of the server instances for this request + * @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. + * @return list of comments 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. + */ + @GetMapping(path = "/elements/{elementGUID}/comments") + + public CommentElementsResponse getAttachedComments(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getAttachedComments(serverName, userId, elementGUID, startFrom, pageSize); + } + + + /** + * Removes a "Like" added to the element by this user. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID unique identifier for the element where the like is attached. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException There is a problem updating the element properties in the metadata repository. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/likes/remove") + + @Operation(summary="removeLikeFromElement", + description="Removes a Like added to the element by this user.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#element-feedback")) + + public VoidResponse removeLikeFromElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody(required = false) NullRequestBody requestBody) + { + return restAPI.removeLikeFromElement(serverName, userId, elementGUID, requestBody); + } + + + /** + * Removes of a star rating/review that was added to the element by this user. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID unique identifier for the element where the rating is attached. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException There is a problem updating the element properties in the metadata repository. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/ratings/remove") + + @Operation(summary="removeRatingFromElement", + description="Removes of a star rating/review that was added to the element by this user.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public VoidResponse removeRatingFromElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody(required = false) NullRequestBody requestBody) + { + return restAPI.removeRatingFromElement(serverName, userId, elementGUID, requestBody); + } + + + /** + * Removes a link between a tag and an element that was added by this user. + * + * @param serverName name of the server instances for this request. + * @param userId String - userId of user making request. + * @param elementGUID unique id for the element. + * @param tagGUID unique id of the tag. + * @param requestBody null request body needed for correct protocol exchange. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException There is a problem updating the element properties in the metadata repository. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/elements/{elementGUID}/tags/{tagGUID}/remove") + + @Operation(summary="removeTagFromElement", + description="Removes a link between a tag and an element that was added by this user.", + externalDocs=@ExternalDocumentation(description="Element classifiers", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-classifiers")) + + public VoidResponse removeTagFromElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String tagGUID, + @RequestBody(required = false) NullRequestBody requestBody) + { + return restAPI.removeTagFromElement(serverName, userId, elementGUID, tagGUID, requestBody); + } + + + /** + * Update an existing comment. + * + * @param serverName name of the server instances for this request. + * @param userId userId of user making request. + * @param elementGUID unique identifier for the element that the comment is attached to (directly or indirectly). + * @param commentGUID unique identifier for the comment to change. + * @param requestBody containing type of comment enum and the text of the comment. + * + * @return void or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException There is a problem updating the element properties in the metadata repository. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "elements/{elementGUID}/comments/{commentGUID}/update") + + @Operation(summary="updateComment", + description="Update an existing comment.", + externalDocs=@ExternalDocumentation(description="Element Feedback", + url="https://egeria-project.org/patterns/metadata-manager/overview/#asset-feedback")) + + public VoidResponse updateComment(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String commentGUID, + @RequestBody CommentProperties requestBody) + { + return restAPI.updateComment(serverName, userId, elementGUID, commentGUID, requestBody); + } + + + /** + * Updates the description of an existing tag (either private or public). + * + * @param serverName name of the server instances for this request + * @param userId userId of user making request. + * @param tagGUID unique id for the tag. + * @param requestBody contains the name of the tag and (optional) description of the tag. + * + * @return void or + * InvalidParameterException - one of the parameters is invalid or + * PropertyServerException - there is a problem retrieving information from the property server(s) or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/tags/{tagGUID}/update") + + @Operation(summary="updateTagDescription", + description="Updates the description of an existing tag (either private or public).", + externalDocs=@ExternalDocumentation(description="Informal Tag", + url="https://egeria-project.org/concepts/informal-tag/")) + + public VoidResponse updateTagDescription(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String tagGUID, + @RequestBody InformalTagUpdateRequestBody requestBody) + { + return restAPI.updateTagDescription(serverName, userId, tagGUID, requestBody); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/GlossaryExchangeResource.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/GlossaryExchangeResource.java index 57161d63363..83c4fd5c081 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/GlossaryExchangeResource.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/GlossaryExchangeResource.java @@ -463,16 +463,16 @@ public VoidResponse updateGlossaryCategory(@PathVariable String */ @PostMapping(path = "/glossaries/categories/{glossaryParentCategoryGUID}/subcategories/{glossaryChildCategoryGUID}") - public VoidResponse setupCategoryParent(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String glossaryParentCategoryGUID, - @PathVariable String glossaryChildCategoryGUID, + public VoidResponse setupCategoryParent(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String glossaryParentCategoryGUID, + @PathVariable String glossaryChildCategoryGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - RelationshipRequestBody requestBody) + RelationshipRequestBody requestBody) { return restAPI.setupCategoryParent(serverName, userId, glossaryParentCategoryGUID, glossaryChildCategoryGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -561,15 +561,15 @@ public VoidResponse removeGlossaryCategory(@PathVariable String */ @PostMapping(path = "/glossaries/categories/by-search-string") - public GlossaryCategoryElementsResponse findGlossaryCategories(@PathVariable String serverName, - @PathVariable String userId, - @RequestParam int startFrom, - @RequestParam int pageSize, + public GlossaryCategoryElementsResponse findGlossaryCategories(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody SearchStringRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody GlossarySearchStringRequestBody requestBody) { return restAPI.findGlossaryCategories(serverName, userId, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -629,15 +629,15 @@ public GlossaryCategoryElementsResponse getCategoriesForGlossary(@PathVariable S */ @PostMapping(path = "/glossaries/categories/by-name") - public GlossaryCategoryElementsResponse getGlossaryCategoriesByName(@PathVariable String serverName, - @PathVariable String userId, - @RequestParam int startFrom, - @RequestParam int pageSize, + public GlossaryCategoryElementsResponse getGlossaryCategoriesByName(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody NameRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody GlossaryNameRequestBody requestBody) { return restAPI.getGlossaryCategoriesByName(serverName, userId, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -824,6 +824,7 @@ public GUIDResponse createGlossaryTermFromTemplate(@PathVariable String * @param serverName name of the server to route the request to * @param userId calling user * @param glossaryTermGUID unique identifier of the glossary term to update + * @param isMergeUpdate should the properties be merged with the existing properties or completely over-write them * @param forLineage return elements marked with the Memento classification? * @param forDuplicateProcessing do not merge elements marked as duplicates? * @param requestBody new properties for the glossary term @@ -839,12 +840,14 @@ public VoidResponse updateGlossaryTerm(@PathVariable String ser @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean isMergeUpdate, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forLineage, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, @RequestBody GlossaryTermRequestBody requestBody) { - return restAPI.updateGlossaryTerm(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); + return restAPI.updateGlossaryTerm(serverName, userId, glossaryTermGUID, isMergeUpdate, forLineage, forDuplicateProcessing, requestBody); } @@ -902,9 +905,9 @@ public VoidResponse setupTermCategory(@PathVariable String serv @PathVariable String glossaryCategoryGUID, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody RelationshipRequestBody requestBody) { return restAPI.setupTermCategory(serverName, userId, glossaryCategoryGUID, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); @@ -1344,11 +1347,11 @@ public VoidResponse clearTermAsSpineObject(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - UpdateRequestBody requestBody) + UpdateRequestBody requestBody) { return restAPI.clearTermAsSpineObject(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1375,11 +1378,11 @@ public VoidResponse setTermAsSpineAttribute(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - UpdateRequestBody requestBody) + UpdateRequestBody requestBody) { return restAPI.setTermAsSpineAttribute(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1406,11 +1409,11 @@ public VoidResponse clearTermAsSpineAttribute(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - UpdateRequestBody requestBody) + UpdateRequestBody requestBody) { return restAPI.clearTermAsSpineAttribute(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1437,11 +1440,11 @@ public VoidResponse setTermAsObjectIdentifier(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - UpdateRequestBody requestBody) + UpdateRequestBody requestBody) { return restAPI.setTermAsObjectIdentifier(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1468,16 +1471,75 @@ public VoidResponse clearTermAsObjectIdentifier(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - UpdateRequestBody requestBody) + UpdateRequestBody requestBody) { return restAPI.clearTermAsObjectIdentifier(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); } + /** + * Undo the last update to the glossary term. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param forLineage return elements marked with the Memento classification? + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * @param requestBody properties to help with the mapping of the elements in the external asset manager and open metadata + * + * @return void or + * InvalidParameterException one of the parameters is invalid + * UserNotAuthorizedException the user is not authorized to issue this request + * PropertyServerException there is a problem reported in the open metadata server(s) + */ + @PostMapping(path = "/glossaries/terms/{glossaryTermGUID}/undo") + + public GlossaryTermElementResponse undoGlossaryTermUpdate(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String glossaryTermGUID, + @RequestParam (required = false, defaultValue = "false") + boolean forLineage, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, + @RequestBody(required = false) + UpdateRequestBody requestBody) + { + return restAPI.undoGlossaryTermUpdate(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); + } + + + /** + * Archive the metadata element representing a glossary term. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param glossaryTermGUID unique identifier of the metadata element to archive + * @param forDuplicateProcessing do not merge elements marked as duplicates? + * @param requestBody properties to help with the mapping of the elements in the external asset manager and open metadata + * + * @return void or + * InvalidParameterException one of the parameters is invalid + * UserNotAuthorizedException the user is not authorized to issue this request + * PropertyServerException there is a problem reported in the open metadata server(s) + */ + @PostMapping(path = "/glossaries/terms/{glossaryTermGUID}/archive") + + public VoidResponse archiveGlossaryTerm(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String glossaryTermGUID, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, + @RequestBody(required = false) + ArchiveRequestBody requestBody) + { + return restAPI.archiveGlossaryTerm(serverName, userId, glossaryTermGUID, forDuplicateProcessing, requestBody); + } + + /** * Remove the metadata element representing a glossary term. * @@ -1499,11 +1561,11 @@ public VoidResponse removeGlossaryTerm(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) - UpdateRequestBody requestBody) + UpdateRequestBody requestBody) { return restAPI.removeGlossaryTerm(serverName, userId, glossaryTermGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1528,15 +1590,15 @@ public VoidResponse removeGlossaryTerm(@PathVariable String */ @PostMapping(path = "/glossaries/terms/by-search-string") - public GlossaryTermElementsResponse findGlossaryTerms(@PathVariable String serverName, - @PathVariable String userId, - @RequestParam int startFrom, - @RequestParam int pageSize, + public GlossaryTermElementsResponse findGlossaryTerms(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody SearchStringRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody GlossarySearchStringRequestBody requestBody) { return restAPI.findGlossaryTerms(serverName, userId, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1631,15 +1693,15 @@ public GlossaryTermElementsResponse getTermsForGlossaryCategory(@PathVariable St */ @PostMapping(path = "/glossaries/terms/by-name") - public GlossaryTermElementsResponse getGlossaryTermsByName(@PathVariable String serverName, - @PathVariable String userId, - @RequestParam int startFrom, - @RequestParam int pageSize, + public GlossaryTermElementsResponse getGlossaryTermsByName(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody NameRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody GlossaryNameRequestBody requestBody) { return restAPI.getGlossaryTermsByName(serverName, userId, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1666,9 +1728,9 @@ public GlossaryTermElementResponse getGlossaryTermByGUID(@PathVariable String @PathVariable String userId, @PathVariable String glossaryTermGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, + boolean forDuplicateProcessing, @RequestBody(required = false) EffectiveTimeQueryRequestBody requestBody) { @@ -1676,6 +1738,43 @@ public GlossaryTermElementResponse getGlossaryTermByGUID(@PathVariable String } + /** + * Retrieve all the versions of a glossary term. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param glossaryTermGUID unique identifier of object to retrieve + * @param startFrom the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param oldestFirst defining how the results should be ordered. + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param requestBody the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @return list of beans or + * InvalidParameterException one of the parameters is null or invalid. + * PropertyServerException there is a problem removing the properties from the repositories. + * UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @PostMapping(path = "/glossaries/terms/{glossaryTermGUID}/history") + + public GlossaryTermElementsResponse getGlossaryTermHistory(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String glossaryTermGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestParam (required = false, defaultValue = "false") + boolean oldestFirst, + @RequestParam (required = false, defaultValue = "false") + boolean forLineage, + @RequestParam (required = false, defaultValue = "false") + boolean forDuplicateProcessing, + @RequestBody(required = false) + HistoryRequestBody requestBody) + { + return restAPI.getGlossaryTermHistory(serverName, userId, glossaryTermGUID, startFrom, pageSize, oldestFirst, forLineage, forDuplicateProcessing, requestBody); + } /* ========================================================================================= * Support for linkage to external glossary resources. These glossary resources are not diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/StewardshipExchangeResource.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/StewardshipExchangeResource.java new file mode 100644 index 00000000000..7539e67bd42 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/StewardshipExchangeResource.java @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SecurityTagsProperties; +import org.odpi.openmetadata.accessservices.assetmanager.server.StewardshipExchangeRESTServices; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The StewardshipExchangeResource provides part of the server-side implementation of the Asset Manager Open Metadata + * Assess Service (OMAS). This interface provides the ability to add governance related classifications and relationship to elements. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-manager/users/{userId}") + +@Tag(name="Asset Manager OMAS", + description="The Asset Manager OMAS provides APIs and events for managing metadata exchange with third party asset managers, such as data catalogs.", + externalDocs=@ExternalDocumentation(description="Asset Manager Open Metadata Access Service (OMAS)", + url="https://egeria-project.org/services/omas/asset-manager/overview/")) + +public class StewardshipExchangeResource +{ + private final StewardshipExchangeRESTServices restAPI = new StewardshipExchangeRESTServices(); + + /** + * Default constructor + */ + public StewardshipExchangeResource() + { + } + + + /** + * Add or replace the security tags for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of element to attach to + * @param requestBody list of security labels and properties + * + * @return void or + * InvalidParameterException full path or userId is null or + * PropertyServerException problem accessing property server or + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/elements/{elementGUID}/security-tags") + + public VoidResponse addSecurityTags(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody SecurityTagsProperties requestBody) + { + return restAPI.addSecurityTags(serverName, userId, elementGUID, requestBody); + } + + + /** + * Remove the security tags classification from an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of element + * @param requestBody null request body + * + * @return void or + * InvalidParameterException full path or userId is null or + * PropertyServerException problem accessing property server or + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/elements/{elementGUID}/security-tags/remove") + + public VoidResponse removeSecurityTags(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestBody NullRequestBody requestBody) + { + return restAPI.removeSecurityTags(serverName, userId, elementGUID, requestBody); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetClassificationInterface.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetClassificationInterface.java index b7a015cb593..2109b7e5cd7 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetClassificationInterface.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetClassificationInterface.java @@ -200,18 +200,20 @@ void updateAssetOwner(String userId, * If null then the assetGUID is used. * @param securityLabels list of security labels defining the security characteristics of the element * @param securityProperties Descriptive labels describing the security properties of the element + * @param accessGroups map from operation to list of security groups * * @throws InvalidParameterException asset or element not known, null userId or guid * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - void addSecurityTags(String userId, - String assetGUID, - String assetElementGUID, - List securityLabels, - Map securityProperties) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException; + void addSecurityTags(String userId, + String assetGUID, + String assetElementGUID, + List securityLabels, + Map securityProperties, + Map> accessGroups) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/SecurityTagsRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/SecurityTagsRequestBody.java index ba5b66358a2..79daf156420 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/SecurityTagsRequestBody.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/SecurityTagsRequestBody.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.util.*; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -21,10 +22,12 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class SecurityTagsRequestBody extends AssetOwnerOMASAPIRequestBody { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; - private List securityLabels = null; - private Map securityProperties = null; + private List securityLabels = null; + private Map securityProperties = null; + private Map> accessGroups = null; /** @@ -48,6 +51,7 @@ public SecurityTagsRequestBody(SecurityTagsRequestBody template) { this.securityLabels = template.getSecurityLabels(); this.securityProperties = template.getSecurityProperties(); + this.accessGroups = template.getAccessGroups(); } } @@ -117,6 +121,36 @@ public void setSecurityProperties(Map securityProperties) } + /** + * Return the map from operation to list of security groups. + * + * @return map + */ + public Map> getAccessGroups() + { + if (accessGroups == null) + { + return null; + } + if (accessGroups.isEmpty()) + { + return null; + } + return accessGroups; + } + + + /** + * Setup the map from operation to list of security groups. + * + * @param accessGroups map + */ + public void setAccessGroups(Map> accessGroups) + { + this.accessGroups = accessGroups; + } + + /** * JSON-style toString. * @@ -126,9 +160,10 @@ public void setSecurityProperties(Map securityProperties) public String toString() { return "SecurityTagsRequestBody{" + - ", securityLabels='" + securityLabels + '\'' + - ", securityProperties=" + securityProperties + - '}'; + "securityLabels=" + securityLabels + + ", securityProperties=" + securityProperties + + ", accessGroups=" + accessGroups + + '}'; } @@ -145,17 +180,16 @@ public boolean equals(Object objectToCompare) { return true; } - if (objectToCompare == null || getClass() != objectToCompare.getClass()) + if (! (objectToCompare instanceof SecurityTagsRequestBody that)) { return false; } - SecurityTagsRequestBody that = (SecurityTagsRequestBody) objectToCompare; - return Objects.equals(getSecurityLabels(), that.getSecurityLabels()) && - Objects.equals(getSecurityProperties(), that.getSecurityProperties()); + return Objects.equals(securityLabels, that.securityLabels) && + Objects.equals(securityProperties, that.securityProperties) && + Objects.equals(accessGroups, that.accessGroups); } - /** * Return hash code for this object * @@ -164,6 +198,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(getSecurityLabels(), getSecurityProperties()); + return Objects.hash(securityLabels, securityProperties, accessGroups); } } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwner.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwner.java index ac4b3a6ff76..21c8769a6c2 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwner.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwner.java @@ -1112,18 +1112,20 @@ public void updateAssetOwner(String userId, * If null then the assetGUID is used. * @param securityLabels list of security labels defining the security characteristics of the element * @param securityProperties Descriptive labels describing origin of the asset + * @param accessGroups map from operation to list of security groups * @throws InvalidParameterException entity not known, null userId or guid * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ @Override - public void addSecurityTags(String userId, - String assetGUID, - String assetElementGUID, - List securityLabels, - Map securityProperties) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public void addSecurityTags(String userId, + String assetGUID, + String assetElementGUID, + List securityLabels, + Map securityProperties, + Map> accessGroups) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { final String methodName = "addSecurityTags"; final String assetGUIDParameter = "assetGUID"; @@ -1136,6 +1138,7 @@ public void addSecurityTags(String userId, SecurityTagsRequestBody requestBody = new SecurityTagsRequestBody(); requestBody.setSecurityLabels(securityLabels); requestBody.setSecurityProperties(securityProperties); + requestBody.setAccessGroups(accessGroups); if (assetElementGUID == null) { diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerRESTServices.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerRESTServices.java index 263a78b3c76..aea5b77184d 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerRESTServices.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerRESTServices.java @@ -1989,6 +1989,7 @@ public VoidResponse addSecurityTags(String serverName, assetTypeName, requestBody.getSecurityLabels(), requestBody.getSecurityProperties(), + requestBody.getAccessGroups(), false, false, new Date(), @@ -2052,6 +2053,7 @@ public VoidResponse addSecurityTags(String serverName, assetElementTypeName, requestBody.getSecurityLabels(), requestBody.getSecurityProperties(), + requestBody.getAccessGroups(), false, false, new Date(), diff --git a/open-metadata-implementation/access-services/data-manager/data-manager-api/src/main/java/org/odpi/openmetadata/accessservices/datamanager/properties/ArchiveProperties.java b/open-metadata-implementation/access-services/data-manager/data-manager-api/src/main/java/org/odpi/openmetadata/accessservices/datamanager/properties/ArchiveProperties.java index 6b192e8339c..77f818613f6 100644 --- a/open-metadata-implementation/access-services/data-manager/data-manager-api/src/main/java/org/odpi/openmetadata/accessservices/datamanager/properties/ArchiveProperties.java +++ b/open-metadata-implementation/access-services/data-manager/data-manager-api/src/main/java/org/odpi/openmetadata/accessservices/datamanager/properties/ArchiveProperties.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.io.Serializable; import java.util.Date; import java.util.HashMap; @@ -26,7 +27,8 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class ArchiveProperties implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private Date archiveDate = null; private String archiveProcess = null; diff --git a/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/GUIDResponse.java b/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/GUIDResponse.java index 821ee6966ff..0384aad8fff 100644 --- a/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/GUIDResponse.java +++ b/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/GUIDResponse.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.util.Arrays; import java.util.Objects; @@ -23,7 +24,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class GUIDResponse extends FFDCResponseBase { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private String guid = null; diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryCategoryHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryCategoryHandler.java index 1e1507692a4..6ea007ae59d 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryCategoryHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryCategoryHandler.java @@ -6,11 +6,13 @@ import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; import org.odpi.openmetadata.commonservices.generichandlers.ffdc.GenericHandlersErrorCode; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; +import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryIteratorForEntities; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; import java.util.ArrayList; @@ -470,6 +472,7 @@ public void removeGlossaryCategory(String userId, * The search string is treated as a regular expression. * * @param userId calling user + * @param glossaryGUID unique identifier of the glossary to query * @param searchString string to find in the properties * @param searchStringParameterName name of parameter supplying the search string * @param startFrom paging start point @@ -486,6 +489,7 @@ public void removeGlossaryCategory(String userId, * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ public List findGlossaryCategories(String userId, + String glossaryGUID, String searchString, String searchStringParameterName, int startFrom, @@ -497,21 +501,96 @@ public List findGlossaryCategories(String userId, UserNotAuthorizedException, PropertyServerException { - return this.findBeans(userId, - searchString, - searchStringParameterName, - OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID, - OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, - forLineage, - forDuplicateProcessing, - supportedZones, - null, - startFrom, - pageSize, - effectiveTime, - methodName); - } + if (glossaryGUID == null) + { + return this.findBeans(userId, + searchString, + searchStringParameterName, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, + forLineage, + forDuplicateProcessing, + supportedZones, + null, + startFrom, + pageSize, + effectiveTime, + methodName); + } + else + { + final String entityGUIDParameterName = "categoryEntity.getGUID"; + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + /* + * Need to filter results for glossary. + */ + RepositoryIteratorForEntities iterator = getEntitySearchIterator(userId, + searchString, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, + null, + false, + false, + null, + forLineage, + forDuplicateProcessing, + 0, + queryPageSize, + effectiveTime, + methodName); + + List results = new ArrayList<>(); + + while ((iterator.moreToReceive()) && ((queryPageSize == 0) || (results.size() < queryPageSize))) + { + EntityDetail entity = iterator.getNext(); + + int matchCount = 0; + + if (entity != null) + { + try + { + this.validateAnchorEntity(userId, + entity.getGUID(), + entity.getType().getTypeDefName(), + entity, + entityGUIDParameterName, + false, + forLineage, + forDuplicateProcessing, + supportedZones, + effectiveTime, + methodName); + + String anchorGUID = this.getAnchorGUIDFromAnchorsClassification(entity, methodName); + + if (glossaryGUID.equals(anchorGUID)) + { + matchCount ++; + if (matchCount > startFrom) + { + results.add(converter.getNewBean(beanClass, entity, methodName)); + } + } + } + catch (Exception notVisible) + { + // ignore entity + } + } + } + + if (! results.isEmpty()) + { + return results; + } + + return null; + } + } /** @@ -569,6 +648,7 @@ public List getCategoriesForGlossary(String userId, * There are no wildcards supported on this request. * * @param userId calling user + * @param glossaryGUID unique identifier of the glossary to query * @param name name to search for * @param nameParameterName parameter supplying name * @param startFrom paging start point @@ -585,6 +665,7 @@ public List getCategoriesForGlossary(String userId, * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ public List getGlossaryCategoriesByName(String userId, + String glossaryGUID, String name, String nameParameterName, int startFrom, @@ -603,23 +684,99 @@ public List getGlossaryCategoriesByName(String userId, specificMatchPropertyNames.add(OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME); specificMatchPropertyNames.add(OpenMetadataAPIMapper.DISPLAY_NAME_PROPERTY_NAME); - return this.getBeansByValue(userId, - name, - nameParameterName, - OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID, - OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, - specificMatchPropertyNames, - true, - null, - null, - forLineage, - forDuplicateProcessing, - supportedZones, - null, - startFrom, - pageSize, - effectiveTime, - methodName); + if (glossaryGUID == null) + { + return this.getBeansByValue(userId, + name, + nameParameterName, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, + specificMatchPropertyNames, + true, + null, + null, + forLineage, + forDuplicateProcessing, + supportedZones, + null, + startFrom, + pageSize, + effectiveTime, + methodName); + } + else + { + final String entityGUIDParameterName = "categoryEntity.getGUID"; + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + /* + * Need to filter results for glossary. + */ + RepositoryIteratorForEntities iterator = getEntitySearchIterator(userId, + name, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, + specificMatchPropertyNames, + true, + false, + null, + forLineage, + forDuplicateProcessing, + 0, + queryPageSize, + effectiveTime, + methodName); + + List results = new ArrayList<>(); + + while ((iterator.moreToReceive()) && ((queryPageSize == 0) || (results.size() < queryPageSize))) + { + EntityDetail entity = iterator.getNext(); + + int matchCount = 0; + + if (entity != null) + { + try + { + this.validateAnchorEntity(userId, + entity.getGUID(), + entity.getType().getTypeDefName(), + entity, + entityGUIDParameterName, + false, + forLineage, + forDuplicateProcessing, + supportedZones, + effectiveTime, + methodName); + + String anchorGUID = this.getAnchorGUIDFromAnchorsClassification(entity, methodName); + + if (glossaryGUID.equals(anchorGUID)) + { + matchCount ++; + if (matchCount > startFrom) + { + results.add(converter.getNewBean(beanClass, entity, methodName)); + } + } + } + catch (Exception notVisible) + { + // ignore entity + } + } + } + + if (! results.isEmpty()) + { + return results; + } + + return null; + } } diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryTermHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryTermHandler.java index 53097661cfb..75a57f226e4 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryTermHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GlossaryTermHandler.java @@ -4,11 +4,14 @@ import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; +import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryIteratorForEntities; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ClassificationOrigin; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; @@ -323,7 +326,10 @@ public void updateGlossaryTerm(String userId, invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(glossaryTermGUID, glossaryTermGUIDParameterName, methodName); - invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName); + if (!isMergeUpdate) + { + invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName); + } String typeGUID = invalidParameterHandler.validateTypeName(typeName, OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, @@ -1522,6 +1528,75 @@ public void clearTermAsObjectIdentifier(String userId, } + /** + * Classify the glossary term in the repository to show that it has been archived and is only needed for lineage. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param glossaryTermGUID unique identifier of the metadata element to update + * @param glossaryTermGUIDParameterName parameter supplying glossaryTermGUID + * @param archiveDate date that the file was archived or discovered to have been archived. Null means now. + * @param archiveProcess name of archiving process + * @param archiveProperties properties to help locate the archive copy + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem removing the properties from the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public void archiveGlossaryTerm(String userId, + String assetManagerGUID, + String assetManagerName, + String glossaryTermGUID, + String glossaryTermGUIDParameterName, + Date archiveDate, + String archiveProcess, + Map archiveProperties, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + EntityDetail entity = this.getEntityFromRepository(userId, + glossaryTermGUID, + glossaryTermGUIDParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + null, + null, + true, + forDuplicateProcessing, + effectiveTime, + methodName); + + ReferenceableBuilder builder = new ReferenceableBuilder(repositoryHelper, serviceName, serverName); + + repositoryHandler.classifyEntity(userId, + assetManagerGUID, + assetManagerName, + entity.getGUID(), + entity, + glossaryTermGUIDParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + OpenMetadataAPIMapper.MEMENTO_CLASSIFICATION_TYPE_GUID, + OpenMetadataAPIMapper.MEMENTO_CLASSIFICATION_TYPE_NAME, + ClassificationOrigin.ASSIGNED, + entity.getGUID(), + builder.getMementoProperties(archiveDate, + userId, + archiveProcess, + archiveProperties, + methodName), + true, + forDuplicateProcessing, + effectiveTime, + methodName); + } + + /** * Remove the metadata element representing a glossary term. * @@ -1571,8 +1646,10 @@ public void removeGlossaryTerm(String userId, * Returns the glossary term object corresponding to the supplied term name. * * @param userId String - userId of user making request. + * @param glossaryGUID unique identifier of the glossary to query * @param name this may be the qualifiedName or displayName of the term. - * @param nameParameterName property that provided the name + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned @@ -1585,39 +1662,94 @@ public void removeGlossaryTerm(String userId, * @throws PropertyServerException there is a problem retrieving information from the property (metadata) server. * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. */ - public List getTermsByName(String userId, - String name, - String nameParameterName, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime, - String methodName) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public List getTermsByName(String userId, + String glossaryGUID, + String name, + List limitResultsByStatus, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { + final String entityGUIDParameterName = "termEntity.getGUID"; + List specificMatchPropertyNames = new ArrayList<>(); specificMatchPropertyNames.add(OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME); specificMatchPropertyNames.add(OpenMetadataAPIMapper.DISPLAY_NAME_PROPERTY_NAME); - return this.getBeansByValue(userId, - name, - nameParameterName, - OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_GUID, - OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, - specificMatchPropertyNames, - true, - null, - null, - forLineage, - forDuplicateProcessing, - supportedZones, - null, - startFrom, - pageSize, - effectiveTime, - methodName); + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + /* + * Need to filter results for glossary. + */ + RepositoryIteratorForEntities iterator = getEntitySearchIterator(userId, + name, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_GUID, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + specificMatchPropertyNames, + true, + false, + null, + forLineage, + forDuplicateProcessing, + 0, + queryPageSize, + effectiveTime, + methodName); + + List results = new ArrayList<>(); + + while ((iterator.moreToReceive()) && ((queryPageSize == 0) || (results.size() < queryPageSize))) + { + EntityDetail entity = iterator.getNext(); + + int matchCount = 0; + + if (entity != null) + { + try + { + this.validateAnchorEntity(userId, + entity.getGUID(), + entity.getType().getTypeDefName(), + entity, + entityGUIDParameterName, + false, + forLineage, + forDuplicateProcessing, + supportedZones, + effectiveTime, + methodName); + + String anchorGUID = this.getAnchorGUIDFromAnchorsClassification(entity, methodName); + + if (((glossaryGUID == null) || (glossaryGUID.equals(anchorGUID))) && + ((limitResultsByStatus == null) || (limitResultsByStatus.contains(entity.getStatus())))) + { + matchCount ++; + if (matchCount > startFrom) + { + results.add(converter.getNewBean(beanClass, entity, methodName)); + } + } + } + catch (Exception notVisible) + { + // ignore entity + } + } + } + + if (! results.isEmpty()) + { + return results; + } + + return null; } @@ -1625,8 +1757,10 @@ public List getTermsByName(String userId, * Returns the glossary term object containing the supplied term name. This may include wildcard characters * * @param userId String - userId of user making request. - * @param name this may be the qualifiedName or displayName of the term - * @param nameParameterName property that provided the name - interpreted as a regular expression + * @param glossaryGUID unique identifier of the glossary to query + * @param searchString string to find in the properties + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned @@ -1639,39 +1773,134 @@ public List getTermsByName(String userId, * @throws PropertyServerException there is a problem retrieving information from the property (metadata) server. * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. */ - public List findTerms(String userId, - String name, - String nameParameterName, - int startFrom, - int pageSize, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime, - String methodName) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public List findTerms(String userId, + String glossaryGUID, + String searchString, + List limitResultsByStatus, + int startFrom, + int pageSize, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { - List specificMatchPropertyNames = new ArrayList<>(); - specificMatchPropertyNames.add(OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME); - specificMatchPropertyNames.add(OpenMetadataAPIMapper.DISPLAY_NAME_PROPERTY_NAME); + final String entityGUIDParameterName = "termEntity.getGUID"; + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + /* + * Need to filter results for glossary. + */ + RepositoryIteratorForEntities iterator = getEntitySearchIterator(userId, + searchString, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_GUID, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + null, + false, + false, + null, + forLineage, + forDuplicateProcessing, + 0, + queryPageSize, + effectiveTime, + methodName); + + List results = new ArrayList<>(); + + while ((iterator.moreToReceive()) && ((queryPageSize == 0) || (results.size() < queryPageSize))) + { + EntityDetail termEntity = iterator.getNext(); + + int matchCount = 0; + + if (termEntity != null) + { + try + { + this.validateAnchorEntity(userId, + termEntity.getGUID(), + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + termEntity, + entityGUIDParameterName, + false, + forLineage, + forDuplicateProcessing, + supportedZones, + effectiveTime, + methodName); + + String termAnchorGUID = this.getAnchorGUIDFromAnchorsClassification(termEntity, methodName); + + if (((glossaryGUID == null) || (glossaryGUID.equals(termAnchorGUID))) && + ((limitResultsByStatus == null) || (limitResultsByStatus.contains(termEntity.getStatus())))) + { + matchCount ++; + if (matchCount > startFrom) + { + results.add(converter.getNewBean(beanClass, termEntity, methodName)); + } + } + else if (glossaryGUID != null) + { + /* + * The term is not anchored in the requested glossary. Maybe it is linked to a category in the requested glossary? + */ + List categoryEntities = this.getAttachedEntities(userId, + termEntity.getGUID(), + entityGUIDParameterName, + OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, + OpenMetadataAPIMapper.TERM_CATEGORIZATION_TYPE_GUID, + OpenMetadataAPIMapper.TERM_CATEGORIZATION_TYPE_NAME, + OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME, + null, + null, + 1, + forLineage, + forDuplicateProcessing, + supportedZones, + 0, + 0, + effectiveTime, + methodName); + + if (categoryEntities != null) + { + for (EntityDetail categoryEntity : categoryEntities) + { + if (categoryEntity != null) + { + String categoryAnchorGUID = this.getAnchorGUIDFromAnchorsClassification(categoryEntity, methodName); + + if ((glossaryGUID.equals(categoryAnchorGUID)) && + ((limitResultsByStatus == null) || (limitResultsByStatus.contains(termEntity.getStatus())))) + { + matchCount ++; + if (matchCount > startFrom) + { + results.add(converter.getNewBean(beanClass, termEntity, methodName)); + } + } + } + } + } + } + } + catch (Exception notVisible) + { + // ignore entity + } + } + } - return this.getBeansByValue(userId, - name, - nameParameterName, - OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_GUID, - OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME, - specificMatchPropertyNames, - false, - null, - null, - forLineage, - forDuplicateProcessing, - supportedZones, - null, - startFrom, - pageSize, - effectiveTime, - methodName); + if (! results.isEmpty()) + { + return results; + } + + return null; } 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 f7b3445fe3c..f9abaf3bf31 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 @@ -10,6 +10,7 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; @@ -3121,6 +3122,18 @@ else if (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMa serviceName, methodName); } + else if (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.GLOSSARY_TYPE_NAME)) + { + /* + * Even if the request is an update request, the security module is first called for read - the update + * is validated once the properties have been updated. + */ + securityVerifier.validateUserForGlossaryRead(userId, + connectToEntity, + repositoryHelper, + serviceName, + methodName); + } /* * Most referenceables have an independent lifecycle. They are their own anchor. This method is handling the special cases. @@ -3188,17 +3201,17 @@ else if (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMa if (anchorEntityType != null) { + boolean isFeedbackEntity = (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.INFORMAL_TAG_TYPE_NAME)) || + (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.COMMENT_TYPE_NAME)) || + (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.RATING_TYPE_NAME)) || + (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.LIKE_TYPE_NAME)); + /* * Determine if the element is attached directly or indirectly to an asset (or is an asset) so it is possible to determine * if this asset is in a supported zone or if the user is allowed to change its attachments. */ if (OpenMetadataAPIMapper.ASSET_TYPE_NAME.equals(anchorEntityType.getTypeDefName())) { - boolean isFeedbackEntity = (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.INFORMAL_TAG_TYPE_NAME)) || - (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.COMMENT_TYPE_NAME)) || - (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.RATING_TYPE_NAME)) || - (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMapper.LIKE_TYPE_NAME)); - securityVerifier.validateUserForAssetAttachment(userId, connectToGUID, connectToGUIDParameterName, @@ -3210,6 +3223,33 @@ else if (repositoryHelper.isTypeOf(serviceName, connectToType, OpenMetadataAPIMa serviceName, methodName); } + else if (OpenMetadataAPIMapper.GLOSSARY_TYPE_NAME.equals(anchorEntityType.getTypeDefName())) + { + if (isFeedbackEntity) + { + securityVerifier.validateUserForGlossaryFeedback(userId, + anchorEntity, + repositoryHelper, + serviceName, + methodName); + } + else if (isUpdate) + { + securityVerifier.validateUserForGlossaryMemberUpdate(userId, + anchorEntity, + repositoryHelper, + serviceName, + methodName); + } + else + { + securityVerifier.validateUserForGlossaryRead(userId, + anchorEntity, + repositoryHelper, + serviceName, + methodName); + } + } /* * This list is likely to expand as more anchor types get specialized visibility/security mechanisms. @@ -3428,6 +3468,18 @@ private void validateNewEntityRequest(String userId, serviceName, methodName); } + else if (repositoryHelper.isTypeOf(serviceName, entityTypeName, OpenMetadataAPIMapper.GLOSSARY_TYPE_NAME)) + { + securityVerifier.validateUserForGlossaryCreate(userId, + entityTypeGUID, + entityTypeName, + newProperties, + classifications, + instanceStatus, + repositoryHelper, + serviceName, + methodName); + } } @@ -6361,6 +6413,15 @@ public void updateBeanInRepository(String userId, serviceName, methodName); } + else if (repositoryHelper.isTypeOf(serviceName, originalEntity.getType().getTypeDefName(), OpenMetadataAPIMapper.GLOSSARY_TYPE_NAME)) + { + securityVerifier.validateUserForGlossaryDetailUpdate(userId, + originalEntity, + newProperties, + repositoryHelper, + serviceName, + methodName); + } repositoryHandler.updateEntityProperties(userId, externalSourceGUID, @@ -6565,6 +6626,14 @@ public void updateBeanStatusInRepository(String userId, serviceName, methodName); } + else if (repositoryHelper.isTypeOf(serviceName, originalEntity.getType().getTypeDefName(), OpenMetadataAPIMapper.GLOSSARY_TERM_TYPE_NAME)) + { + securityVerifier.validateUserForGlossaryMemberStatusUpdate(userId, + anchorEntity, + repositoryHelper, + serviceName, + methodName); + } repositoryHandler.updateEntityStatus(userId, externalSourceGUID, @@ -6630,6 +6699,277 @@ else if (repositoryHelper.isTypeOf(serviceName, entityTypeName, OpenMetadataAPIM } + /** + * Undo the last update to the entity. + * + * @param userId calling user + * @param externalSourceGUID guid of the software capability entity that represented the external source - null for local + * @param externalSourceName name of the software capability entity that represented the external source + * @param entityGUID unique identifier of object to update + * @param entityGUIDParameterName name of parameter supplying the GUID + * @param entityTypeName unique name of the entity's type + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * @return recovered bean + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the new properties to the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public B undoBeanUpdateInRepository(String userId, + String externalSourceGUID, + String externalSourceName, + String entityGUID, + String entityGUIDParameterName, + String entityTypeName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + return this.undoBeanUpdateInRepository(userId, + externalSourceGUID, + externalSourceName, + entityGUID, + entityGUIDParameterName, + entityTypeName, + forLineage, + forDuplicateProcessing, + supportedZones, + effectiveTime, + methodName); + } + + + /** + * Undo the last update to the entity. + * + * @param userId calling user + * @param externalSourceGUID guid of the software capability entity that represented the external source - null for local + * @param externalSourceName name of the software capability entity that represented the external source + * @param entityGUID unique identifier of object to update + * @param entityGUIDParameterName name of parameter supplying the GUID + * @param entityTypeName unique name of the entity's type + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param serviceSupportedZones supported zones for calling service + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * @return recovered bean + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the new properties to the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public B undoBeanUpdateInRepository(String userId, + String externalSourceGUID, + String externalSourceName, + String entityGUID, + String entityGUIDParameterName, + String entityTypeName, + boolean forLineage, + boolean forDuplicateProcessing, + List serviceSupportedZones, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + EntityDetail startingEntity = repositoryHandler.getEntityByGUID(userId, + entityGUID, + entityGUIDParameterName, + entityTypeName, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + + return undoBeanUpdateInRepository(userId, + externalSourceGUID, + externalSourceName, + startingEntity, + entityGUIDParameterName, + entityTypeName, + forLineage, + forDuplicateProcessing, + serviceSupportedZones, + effectiveTime, + methodName); + } + + + /** + * Undo the last update to the entity. + * + * @param userId calling user + * @param externalSourceGUID guid of the software capability entity that represented the external source - null for local + * @param externalSourceName name of the software capability entity that represented the external source + * @param originalEntity unique identifier of object to update + * @param entityGUIDParameterName name of parameter supplying the GUID + * @param entityTypeName unique name of the entity's type + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param serviceSupportedZones supported zones for calling service + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * @return recovered bean + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem adding the new properties to the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public B undoBeanUpdateInRepository(String userId, + String externalSourceGUID, + String externalSourceName, + EntityDetail originalEntity, + String entityGUIDParameterName, + String entityTypeName, + boolean forLineage, + boolean forDuplicateProcessing, + List serviceSupportedZones, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String originalEntityParameterName = "originalEntity"; + + invalidParameterHandler.validateUserId(userId, methodName); + + if ((originalEntity != null) && (originalEntity.getType() != null)) + { + EntityDetail anchorEntity = this.validateAnchorEntity(userId, + originalEntity.getGUID(), + entityTypeName, + originalEntity, + entityGUIDParameterName, + true, + forLineage, + forDuplicateProcessing, + serviceSupportedZones, + effectiveTime, + methodName); + + EntityDetail recoveredEntity = repositoryHandler.undoEntityUpdate(userId, + externalSourceGUID, + externalSourceName, + originalEntity.getGUID(), + methodName); + + /* + * There is an extra security check if the update is for an asset or glossary. + */ + try + { + if (repositoryHelper.isTypeOf(serviceName, originalEntity.getType().getTypeDefName(), OpenMetadataAPIMapper.ASSET_TYPE_NAME)) + { + securityVerifier.validateUserForAssetUpdate(userId, + originalEntity, + recoveredEntity.getProperties(), + recoveredEntity.getStatus(), + repositoryHelper, + serviceName, + methodName); + } + else if (repositoryHelper.isTypeOf(serviceName, originalEntity.getType().getTypeDefName(), OpenMetadataAPIMapper.GLOSSARY_TYPE_NAME)) + { + securityVerifier.validateUserForGlossaryDetailUpdate(userId, + originalEntity, + recoveredEntity.getProperties(), + repositoryHelper, + serviceName, + methodName); + } + } + catch (UserNotAuthorizedException notAuth) + { + /* + * Put the original entity back. + */ + repositoryHandler.updateEntity(userId, + externalSourceGUID, + externalSourceName, + originalEntity.getGUID(), + originalEntityParameterName, + originalEntity.getType().getTypeDefGUID(), + originalEntity.getType().getTypeDefName(), + originalEntity.getProperties(), + originalEntity.getClassifications(), + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + throw notAuth; + } + + /* + * Update is OK so record that it occurred in the LatestChange classification if there is an anchor entity. + */ + final String actionDescriptionTemplate = "Undo last update of properties in %s %s"; + String actionDescription = String.format(actionDescriptionTemplate, entityTypeName, originalEntity.getGUID()); + + if (anchorEntity != null) + { + this.addLatestChangeToAnchor(anchorEntity, + OpenMetadataAPIMapper.ATTACHMENT_PROPERTY_LATEST_CHANGE_TARGET_ORDINAL, + OpenMetadataAPIMapper.UPDATED_LATEST_CHANGE_ACTION_ORDINAL, + null, + originalEntity.getGUID(), + entityTypeName, + null, + userId, + actionDescription, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + } + else if (repositoryHelper.isTypeOf(serviceName, entityTypeName, OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME)) + { + this.addLatestChangeToAnchor(originalEntity, + OpenMetadataAPIMapper.ENTITY_PROPERTY_LATEST_CHANGE_TARGET_ORDINAL, + OpenMetadataAPIMapper.UPDATED_LATEST_CHANGE_ACTION_ORDINAL, + null, + null, + null, + null, + userId, + actionDescription, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + } + + if (recoveredEntity != null) + { + return converter.getNewBean(beanClass, recoveredEntity, methodName); + } + } + else + { + String entityGUID = ""; + + if (originalEntity != null) + { + entityGUID = originalEntity.getGUID(); + } + invalidParameterHandler.throwUnknownElement(userId, + entityGUID, + entityTypeName, + serviceName, + serverName, + methodName); + } + + return null; + } + + /** * Classify as a Memento any entity if it is anchored to the anchor entity. * @@ -6705,8 +7045,8 @@ private void archiveAnchoredEntity(String userId, /** - * Classify an entity in the repository to show that its asset/artifact counterpart in the real world has either - * been deleted or archived. + * Classify an entity in the repository to show that its asset/artifact counterpart in the real world has either been deleted or archived. + * The entity is preserved because it is needed for lineage. * * @param userId calling user * @param externalSourceGUID guid of the software capability entity that represented the external source - null for local @@ -6735,8 +7075,8 @@ public void archiveBeanInRepository(String userId, boolean forDuplicateProcessing, Date effectiveTime, String methodName) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + PropertyServerException, + UserNotAuthorizedException { this.archiveBeanInRepository(userId, externalSourceGUID, @@ -9715,6 +10055,83 @@ else if (duplicateEntities.size() == 1) } + /** + * Classify an entity in the repository to show that its asset/artifact counterpart in the real world has either + * been deleted or archived. Note, this method is designed to work only on anchor entities or entities with no anchor. + * + * @param userId calling user + * @param guid unique identifier of object to update + * @param guidParameterName name of parameter supplying the GUID + * @param entityTypeName unique name of the entity's type + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate + * @param serviceSupportedZones supported zones for calling service + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * @return list of beans + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem removing the properties from the repositories. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + public List getBeanHistory(String userId, + String guid, + String guidParameterName, + String entityTypeName, + Date fromTime, + Date toTime, + int startingFrom, + int pageSize, + HistorySequencingOrder sequencingOrder, + boolean forLineage, + boolean forDuplicateProcessing, + List serviceSupportedZones, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(guid, guidParameterName, methodName); + + this.validateAnchorEntity(userId, + guid, + guidParameterName, + entityTypeName, + true, + forLineage, + forDuplicateProcessing, + serviceSupportedZones, + effectiveTime, + methodName); + + List entities = repositoryHandler.getEntityDetailHistory(userId, + guid, + fromTime, + toTime, + startingFrom, + pageSize, + sequencingOrder, + methodName); + + if (entities != null) + { + List results = new ArrayList<>(); + + for (EntityDetail entity : entities) + { + results.add(converter.getNewBean(beanClass, entity, methodName)); + } + + if (! results.isEmpty()) + { + return results; + } + } + + return null; + } + /** * Return the bean that matches the requested value. * @@ -10089,8 +10506,7 @@ public List findEntities(String userId, /* - * Now need to ensure that the anchor's classification is pushed down to the dependent elements. This is done by retrieving the - * relationships. + * Validate that the anchor guid means that the entity is visible to caller. */ RepositoryFindEntitiesIterator iterator = new RepositoryFindEntitiesIterator(repositoryHandler, invalidParameterHandler, diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java index 021cc2cd762..cfff33f8280 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java @@ -1537,6 +1537,7 @@ public class OpenMetadataAPIMapper public static final String SECURITY_TAG_CLASSIFICATION_TYPE_NAME = "SecurityTags"; public static final String SECURITY_LABELS_PROPERTY_NAME = "securityLabels"; public static final String SECURITY_PROPERTIES_PROPERTY_NAME = "securityProperties"; + public static final String ACCESS_GROUPS_PROPERTY_NAME = "accessGroups"; public static final String ZONE_TYPE_GUID = "290a192b-42a7-449a-935a-269ca62cfdac"; diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableBuilder.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableBuilder.java index 9cd76fb4baf..7363d7b839a 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableBuilder.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableBuilder.java @@ -515,14 +515,16 @@ InstanceProperties getMementoProperties(Date archiveDate, * @param userId calling user * @param securityLabels list of security labels * @param securityProperties map of name value pairs + * @param accessGroups map from operation to list of security groups * @param methodName calling method * @throws InvalidParameterException security tags is not supported in the local repository, or any repository * connected by an open metadata repository cohort */ - public void setSecurityTags(String userId, - List securityLabels, - Map securityProperties, - String methodName) throws InvalidParameterException + public void setSecurityTags(String userId, + List securityLabels, + Map securityProperties, + Map> accessGroups, + String methodName) throws InvalidParameterException { try { @@ -537,6 +539,7 @@ public void setSecurityTags(String userId, null, getSecurityTagProperties(securityLabels, securityProperties, + accessGroups, methodName)); newClassifications.put(classification.getName(), classification); } @@ -553,11 +556,13 @@ public void setSecurityTags(String userId, * @param methodName name of the calling method * @param securityLabels list of security labels * @param securityProperties map of name value pairs + * @param accessGroups map from operation to list of security groups * @return InstanceProperties object */ - InstanceProperties getSecurityTagProperties(List securityLabels, - Map securityProperties, - String methodName) + InstanceProperties getSecurityTagProperties(List securityLabels, + Map securityProperties, + Map> accessGroups, + String methodName) { InstanceProperties properties = repositoryHelper.addStringArrayPropertyToInstance(serviceName, null, @@ -570,6 +575,12 @@ InstanceProperties getSecurityTagProperties(List securityLabels, securityProperties, methodName); + properties = repositoryHelper.addStringArrayStringMapPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.ACCESS_GROUPS_PROPERTY_NAME, + accessGroups, + methodName); + setEffectivityDates(properties); return properties; diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableHandler.java index 023e8cac629..6f2cbbfa6a3 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ReferenceableHandler.java @@ -922,7 +922,8 @@ public void removeOwner(String userId, * @param beanGUIDParameterName name of parameter supplying the beanGUID * @param beanGUIDTypeName type of bean * @param securityLabels list of security labels defining the security characteristics of the element - * @param securityProperties Descriptive labels describing origin of the asset + * @param securityProperties descriptive labels describing origin of the element + * @param accessGroups map from operation to list of security groups * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate * @param effectiveTime the time that the retrieved elements must be effective for @@ -932,18 +933,19 @@ public void removeOwner(String userId, * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - public void addSecurityTags(String userId, - String beanGUID, - String beanGUIDParameterName, - String beanGUIDTypeName, - List securityLabels, - Map securityProperties, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime, - String methodName) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public void addSecurityTags(String userId, + String beanGUID, + String beanGUIDParameterName, + String beanGUIDTypeName, + List securityLabels, + Map securityProperties, + Map> accessGroups, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { ReferenceableBuilder builder = new ReferenceableBuilder(OpenMetadataAPIMapper.REFERENCEABLE_TYPE_GUID, OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, @@ -959,7 +961,7 @@ public void addSecurityTags(String userId, beanGUIDTypeName, OpenMetadataAPIMapper.SECURITY_TAG_CLASSIFICATION_TYPE_GUID, OpenMetadataAPIMapper.SECURITY_TAG_CLASSIFICATION_TYPE_NAME, - builder.getSecurityTagProperties(securityLabels, securityProperties, methodName), + builder.getSecurityTagProperties(securityLabels, securityProperties, accessGroups, methodName), true, forLineage, forDuplicateProcessing, diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/OpenMetadataGlossarySecurity.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/OpenMetadataGlossarySecurity.java index f860b08ca0e..2f92c8ee93f 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/OpenMetadataGlossarySecurity.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/OpenMetadataGlossarySecurity.java @@ -54,7 +54,7 @@ void validateUserForGlossaryRead(String userId, /** - * Tests for whether a specific user should have the right to update the properties of a glossary. + * Tests for whether a specific user should have the right to update the properties/classifications of a glossary. * * @param userId identifier of user * @param originalGlossary original glossary details diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Asset.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Asset.java index 9ce30b68bd9..ebf287907cd 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Asset.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Asset.java @@ -17,8 +17,6 @@ public class Asset extends Referenceable private String displayName = null; private String description = null; - private String owner = null; - private int ownerType = 0; private List zoneMembership = null; private Map origin = null; @@ -44,8 +42,7 @@ public Asset(Asset template) { displayName = template.getDisplayName(); description = template.getDescription(); - owner = template.getOwner(); - ownerType = template.getOwnerType(); + zoneMembership = template.getZoneMembership(); origin = template.getOrigin(); } @@ -98,49 +95,6 @@ public void setDescription(String description) } - /** - * Returns the name of the owner for this asset. - * - * @return owner String - */ - public String getOwner() { - return owner; - } - - - /** - * Set up the name of the owner for this asset. - * - * @param owner String name - */ - public void setOwner(String owner) - { - this.owner = owner; - } - - - /** - * Return the type of owner stored in the owner property. - * - * @return OwnerType enum - */ - public int getOwnerType() - { - return ownerType; - } - - - /** - * Set up the owner type for this asset. - * - * @param ownerType OwnerType enum - */ - public void setOwnerType(int ownerType) - { - this.ownerType = ownerType; - } - - /** * Return the names of the zones that this asset is a member of. * @@ -216,23 +170,26 @@ public void setOrigin(Map origin) public String toString() { return "Asset{" + - "typeGUID='" + getTypeGUID() + '\'' + - ", typeName='" + getTypeName() + '\'' + - ", qualifiedName='" + getQualifiedName() + '\'' + - ", displayName='" + displayName + '\'' + + "displayName='" + displayName + '\'' + ", description='" + description + '\'' + - ", owner='" + owner + '\'' + - ", ownerType=" + ownerType + ", zoneMembership=" + zoneMembership + ", origin=" + origin + + ", typeGUID='" + getTypeGUID() + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", status=" + getStatus() + + ", GUID='" + getGUID() + '\'' + + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", owner='" + getOwner() + '\'' + + ", ownerType=" + getOwnerType() + ", extendedProperties=" + getExtendedProperties() + ", securityLabels=" + getSecurityLabels() + ", securityProperties=" + getSecurityProperties() + + ", accessGroups=" + getAccessGroups() + ", confidentiality=" + getConfidentiality() + ", confidence=" + getConfidence() + - ", impact=" + getImpact() + ", criticality=" + getCriticality() + + ", impact=" + getImpact() + ", retention=" + getRetention() + '}'; } @@ -262,8 +219,6 @@ public boolean equals(Object objectToCompare) Asset asset = (Asset) objectToCompare; return Objects.equals(getDisplayName(), asset.getDisplayName()) && Objects.equals(getDescription(), asset.getDescription()) && - Objects.equals(getOwner(), asset.getOwner()) && - getOwnerType() == asset.getOwnerType() && Objects.equals(getZoneMembership(), asset.getZoneMembership()) && Objects.equals(getOrigin(), asset.getOrigin()); } @@ -278,7 +233,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), getDisplayName(), getDescription(), getOwner(), - getOwnerType(), getZoneMembership(), getOrigin()); + return Objects.hash(super.hashCode(), getDisplayName(), getDescription(), getZoneMembership(), getOrigin()); } } diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Glossary.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Glossary.java index bd577391821..d249404503e 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Glossary.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Glossary.java @@ -153,15 +153,28 @@ public void setUsage(String usage) @Override public String toString() { - return "GlossaryProperties{" + + return "Glossary{" + "displayName='" + displayName + '\'' + ", description='" + description + '\'' + ", language='" + language + '\'' + ", usage='" + usage + '\'' + + ", typeGUID='" + getTypeGUID() + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", status=" + getStatus() + + ", GUID='" + getGUID() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + - ", typeName='" + getTypeName() + '\'' + + ", owner='" + getOwner() + '\'' + + ", ownerType=" + getOwnerType() + ", extendedProperties=" + getExtendedProperties() + + ", securityLabels=" + getSecurityLabels() + + ", securityProperties=" + getSecurityProperties() + + ", accessGroups=" + getAccessGroups() + + ", confidentiality=" + getConfidentiality() + + ", confidence=" + getConfidence() + + ", criticality=" + getCriticality() + + ", impact=" + getImpact() + + ", retention=" + getRetention() + '}'; } diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Referenceable.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Referenceable.java index 09ff2495b02..544d15dfa61 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Referenceable.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-apis/src/main/java/org/odpi/openmetadata/metadatasecurity/properties/Referenceable.java @@ -20,13 +20,16 @@ public class Referenceable implements Serializable private String typeGUID = null; private String typeName = null; private ReferenceableStatus status = null; - private String guid = null; - private String qualifiedName = null; - private Map additionalProperties = null; - private Map extendedProperties = null; + private String guid = null; + private String qualifiedName = null; + private Map additionalProperties = null; + private Map extendedProperties = null; + private String owner = null; + private int ownerType = 0; private List securityLabels = null; private Map securityProperties = null; + private Map> accessGroups = null; private ConfidentialityGovernanceClassification confidentiality = null; private ConfidenceGovernanceClassification confidence = null; private CriticalityGovernanceClassification criticality = null; @@ -45,7 +48,7 @@ public Referenceable() /** - * Copy/clone constructor. Retrieves values from the supplied template + * Copy/clone constructor. Retrieve values from the supplied template * * @param template element to copy */ @@ -59,15 +62,17 @@ public Referenceable(Referenceable template) guid = template.getGUID(); qualifiedName = template.getQualifiedName(); additionalProperties = template.getAdditionalProperties(); + owner = template.getOwner(); + ownerType = template.getOwnerType(); securityLabels = template.getSecurityLabels(); securityProperties = template.getSecurityProperties(); + accessGroups = template.getAccessGroups(); confidentiality = template.getConfidentiality(); confidence = template.getConfidence(); criticality = template.getCriticality(); impact = template.getImpact(); retention = template.getRetention(); extendedProperties = template.getExtendedProperties(); - } } @@ -216,6 +221,49 @@ else if (additionalProperties.isEmpty()) } + /** + * Returns the name of the owner for this asset. + * + * @return owner String + */ + public String getOwner() { + return owner; + } + + + /** + * Set up the name of the owner for this asset. + * + * @param owner String name + */ + public void setOwner(String owner) + { + this.owner = owner; + } + + + /** + * Return the type of owner stored in the owner property. + * + * @return OwnerType enum + */ + public int getOwnerType() + { + return ownerType; + } + + + /** + * Set up the owner type for this asset. + * + * @param ownerType OwnerType enum + */ + public void setOwnerType(int ownerType) + { + this.ownerType = ownerType; + } + + /** * Return the properties that have been defined for a subtype of this object that are not supported explicitly * by this bean. @@ -317,6 +365,28 @@ public void setSecurityProperties(Map securityProperties) } + /** + * Return the map of operations to access groups. + * + * @return map from string to list of strings + */ + public Map> getAccessGroups() + { + return accessGroups; + } + + + /** + * Set up the map of operations to access groups. + * + * @param accessGroups map from string to list of strings + */ + public void setAccessGroups(Map> accessGroups) + { + this.accessGroups = accessGroups; + } + + /** * Return the classification that defines how confidential the contents of this referenceable are. * @@ -436,19 +506,22 @@ public void setRetention(RetentionGovernanceClassification retention) public String toString() { return "Referenceable{" + - "typeGUID='" + typeGUID + '\'' + - ", typeName='" + typeName + '\'' + - ", guid='" + guid + '\'' + - ", qualifiedName='" + qualifiedName + '\'' + - ", additionalProperties=" + additionalProperties + - ", extendedProperties=" + extendedProperties + - ", securityLabels=" + securityLabels + - ", securityProperties=" + securityProperties + - ", confidentiality=" + confidentiality + - ", confidence=" + confidence + - ", criticality=" + criticality + - ", retention=" + retention + - '}'; + "typeGUID='" + typeGUID + '\'' + + ", typeName='" + typeName + '\'' + + ", guid='" + guid + '\'' + + ", qualifiedName='" + qualifiedName + '\'' + + ", additionalProperties=" + additionalProperties + + ", owner='" + owner + '\'' + + ", ownerType=" + ownerType + + ", extendedProperties=" + extendedProperties + + ", securityLabels=" + securityLabels + + ", securityProperties=" + securityProperties + + ", accessGroups=" + accessGroups + + ", confidentiality=" + confidentiality + + ", confidence=" + confidence + + ", criticality=" + criticality + + ", retention=" + retention + + '}'; } @@ -471,17 +544,20 @@ public boolean equals(Object objectToCompare) } Referenceable that = (Referenceable) objectToCompare; return Objects.equals(typeGUID, that.typeGUID) && - Objects.equals(typeName, that.typeName) && - Objects.equals(guid, that.guid) && - Objects.equals(qualifiedName, that.qualifiedName) && - Objects.equals(additionalProperties, that.additionalProperties) && - Objects.equals(extendedProperties, that.extendedProperties) && - Objects.equals(securityLabels, that.securityLabels) && - Objects.equals(securityProperties, that.securityProperties) && - Objects.equals(confidentiality, that.confidentiality) && - Objects.equals(confidence, that.confidence) && - Objects.equals(criticality, that.criticality) && - Objects.equals(retention, that.retention); + Objects.equals(typeName, that.typeName) && + Objects.equals(guid, that.guid) && + Objects.equals(qualifiedName, that.qualifiedName) && + Objects.equals(additionalProperties, that.additionalProperties) && + Objects.equals(owner, that.owner) && + getOwnerType() == that.ownerType && + Objects.equals(extendedProperties, that.extendedProperties) && + Objects.equals(securityLabels, that.securityLabels) && + Objects.equals(securityProperties, that.securityProperties) && + Objects.equals(accessGroups, that.accessGroups) && + Objects.equals(confidentiality, that.confidentiality) && + Objects.equals(confidence, that.confidence) && + Objects.equals(criticality, that.criticality) && + Objects.equals(retention, that.retention); } @@ -493,6 +569,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(typeGUID, typeName, guid, qualifiedName, additionalProperties, extendedProperties, securityLabels, securityProperties, confidentiality, confidence, criticality, retention); + return Objects.hash(typeGUID, typeName, guid, qualifiedName, additionalProperties, owner, ownerType, extendedProperties, securityLabels, securityProperties, confidentiality, confidence, criticality, retention); } } diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java index 8dcd42bd99f..3bcd8bc6374 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java @@ -15,6 +15,7 @@ import org.odpi.openmetadata.metadatasecurity.properties.AssetAuditHeader; import org.odpi.openmetadata.metadatasecurity.properties.Asset; import org.odpi.openmetadata.metadatasecurity.properties.Connection; +import org.odpi.openmetadata.metadatasecurity.properties.Glossary; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.AttributeTypeDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef; @@ -585,6 +586,60 @@ protected void throwUnauthorizedConnectionAccess(String userId, } + /** + * Write an audit log message and throw exception to record an unauthorized access. + * + * @param userId calling user + * @param operation of requested operation + * @param methodName calling method + * + * @throws UserNotAuthorizedException the authorization check failed + */ + protected void throwMissingGlossary(String userId, + String operation, + String methodName) throws UserNotAuthorizedException + { + if (auditLog != null) + { + auditLog.logMessage(methodName, OpenMetadataSecurityAuditCode.NULL_GLOSSARY.getMessageDefinition(userId, operation)); + } + + throw new UserNotAuthorizedException(OpenMetadataSecurityErrorCode.NULL_GLOSSARY.getMessageDefinition(userId,operation), + this.getClass().getName(), + methodName, + userId); + } + + + /** + * Write an audit log message and throw exception to record an unauthorized access. + * + * @param userId calling user + * @param operation of requested operation + * @param methodName calling method + * + * @throws UserNotAuthorizedException the authorization check failed + */ + protected void throwUnauthorizedGlossaryAccess(String userId, + String operation, + Glossary glossary, + String methodName) throws UserNotAuthorizedException + { + if (auditLog != null) + { + auditLog.logMessage(methodName, OpenMetadataSecurityAuditCode.UNAUTHORIZED_GLOSSARY_ACCESS.getMessageDefinition(userId, operation, glossary.getGUID()), + glossary.toString()); + } + + throw new UserNotAuthorizedException(OpenMetadataSecurityErrorCode.UNAUTHORIZED_GLOSSARY_ACCESS.getMessageDefinition(userId, + operation, + glossary.getGUID()), + this.getClass().getName(), + methodName, + userId); + } + + /** * Receive an audit log object that can be used to record audit log messages. The caller has initialized it * with the correct component description and log destinations. @@ -1213,7 +1268,7 @@ protected void validateUserForTypeReIdentify(String userId, /** - * Tests for whether a specific user should have the right to create a instance within a repository. + * Tests for whether a specific user should have the right to create an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1323,7 +1378,7 @@ protected void validateUserForEntityProxyRead(String userId, /** - * Tests for whether a specific user should have the right to update a instance within a repository. + * Tests for whether a specific user should have the right to update an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1444,7 +1499,7 @@ protected void validateUserForEntityClassificationDelete(String u /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1471,7 +1526,7 @@ protected void validateUserForEntityDelete(String userId, /** - * Tests for whether a specific user should have the right to restore a instance within a repository. + * Tests for whether a specific user should have the right to restore an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1489,7 +1544,7 @@ protected void validateUserForEntityRestore(String userId, /** - * Tests for whether a specific user should have the right to change the guid on a instance within a repository. + * Tests for whether a specific user should have the right to change the guid on an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1521,7 +1576,7 @@ protected void validateUserForEntityReIdentification(String userId, /** - * Tests for whether a specific user should have the right to change the type of a instance within a repository. + * Tests for whether a specific user should have the right to change an instance's type within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1553,7 +1608,7 @@ protected void validateUserForEntityReTyping(String userId, /** - * Tests for whether a specific user should have the right to change the home of a instance within a repository. + * Tests for whether a specific user should have the right to change the home of an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1587,7 +1642,7 @@ protected void validateUserForEntityReHoming(String userId, /** - * Tests for whether a specific user should have the right to create a instance within a repository. + * Tests for whether a specific user should have the right to create an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1643,7 +1698,7 @@ protected Relationship validateUserForRelationshipRead(String userId, /** - * Tests for whether a specific user should have the right to update a instance within a repository. + * Tests for whether a specific user should have the right to update an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1670,7 +1725,7 @@ protected void validateUserForRelationshipUpdate(String userId, /** - * Tests for whether a specific user should have the right to delete a instance within a repository. + * Tests for whether a specific user should have the right to delete an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1697,7 +1752,7 @@ protected void validateUserForRelationshipDelete(String userId, /** - * Tests for whether a specific user should have the right to restore a instance within a repository. + * Tests for whether a specific user should have the right to restore an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1715,7 +1770,7 @@ protected void validateUserForRelationshipRestore(String userId, /** - * Tests for whether a specific user should have the right to change the guid on a instance within a repository. + * Tests for whether a specific user should have the right to change the guid on an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1747,7 +1802,7 @@ protected void validateUserForRelationshipReIdentification(String userId, /** - * Tests for whether a specific user should have the right to change the type of a instance within a repository. + * Tests for whether a specific user should have the right to change an instance's type within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection @@ -1779,7 +1834,7 @@ protected void validateUserForRelationshipReTyping(String userId, /** - * Tests for whether a specific user should have the right to change the home of a instance within a repository. + * Tests for whether a specific user should have the right to change the home of an instance within a repository. * * @param userId identifier of user * @param metadataCollectionName configurable name of the metadata collection diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityAuditCode.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityAuditCode.java index 5970f0b39e2..7ac2f26e76a 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityAuditCode.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityAuditCode.java @@ -151,6 +151,21 @@ public enum OpenMetadataSecurityAuditCode implements AuditLogMessageSet "The security service detected an unauthorized change of an open metadata instance.", "Review the security policies and settings to determine if this access should be allowed or not." + " Take action to either change the security sessions or determine the reason for the unauthorized request."), + + UNAUTHORIZED_GLOSSARY_ACCESS("OPEN-METADATA-SECURITY-0020", + OMRSAuditLogRecordSeverity.SECURITY, + "User {0} is not authorized to issue operation {1} on glossary {2}", + "The security service detected an unauthorized access to a glossary.", + "Review the security policies and settings to determine if this access to a glossary should be allowed or not." + + " Take action to either change the security sessions or determine the reason for the unauthorized request."), + + NULL_GLOSSARY("OPEN-METADATA-SECURITY-0021", + OMRSAuditLogRecordSeverity.SECURITY, + "User {0} is not authorized to iss operation {1} because the glossary is null", + "The system is unable to process a request from the user because the glossary element is not correctly anchored on a glossary.", + "The request fails with a UserNotAuthorizedException exception. Add the anchor relationship of the glossary element to its glossary and corresponding Anchors classification. When both are in place, re-run the request."), + + ; private final String logMessageId; diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityErrorCode.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityErrorCode.java index c5b67745fa1..70558d6b96a 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityErrorCode.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/ffdc/OpenMetadataSecurityErrorCode.java @@ -46,7 +46,7 @@ public enum OpenMetadataSecurityErrorCode implements ExceptionMessageSet "configuration error and re-run the request, if it is a valid request; otherwise contact your security " + "team."), - UNAUTHORIZED_SERVER_ACCESS(403, "OMAG-PLATFORM-SECURITY-403-002", + UNAUTHORIZED_SERVER_ACCESS(403, "OMAG-SERVER-SECURITY-403-002", "User {0} is not authorized to issue a request to server {1}", "The system is unable to process a request from the user because they do not have access to the requested " + "OMAG server. The request fails with a UserNotAuthorizedException exception.", @@ -55,7 +55,7 @@ public enum OpenMetadataSecurityErrorCode implements ExceptionMessageSet "came from to determine if the system is under attack, or it was a mistake, or the user's tool is not " + "configured to connect to the correct server."), - UNAUTHORIZED_SERVICE_ACCESS(403, "OMAG-PLATFORM-SECURITY-403-003", + UNAUTHORIZED_SERVICE_ACCESS(403, "OMAG-SERVER-SECURITY-403-003", "User {0} is not authorized to issue {1} requests", "The system is unable to process a request from the user because they do not have access to the " + "requested services. The request fails with a UserNotAuthorizedException exception.", @@ -64,56 +64,56 @@ public enum OpenMetadataSecurityErrorCode implements ExceptionMessageSet "have access, investigate where the request came from to determine if the system is under attack, or it was a" + " mistake."), - UNAUTHORIZED_ASSET_FEEDBACK(403, "OMAG-PLATFORM-SECURITY-403-004", + UNAUTHORIZED_ASSET_FEEDBACK(403, "OMAG-SERVER-SECURITY-403-004", "User {0} is not authorized to attach feedback to asset {1}", "The system is unable to process a request from the user because they do not have access to augment the " + "requested asset. The request fails with a UserNotAuthorizedException exception.", "Using information about the asset and the user, determine if this result is expected, or if the configuration needs " + "to be adjusted to allow this user to perform the request."), - UNAUTHORIZED_ZONE_CHANGE(403, "OMAG-PLATFORM-SECURITY-403-005", + UNAUTHORIZED_ZONE_CHANGE(403, "OMAG-SERVER-SECURITY-403-005", "User {0} is not authorized to change the zone membership for asset {1} from {2} to {3}", "The system is unable to process a request from the user because they do not have access to update " + "the requested asset. The request fails with a UserNotAuthorizedException exception.", "Using information about the asset, the zones and the user, determine if this result is expected, " + "or if the configuration needs to be adjusted to allow this user to perform the request."), - UNAUTHORIZED_CONNECTION_ACCESS(403, "OMAG-PLATFORM-SECURITY-403-006", + UNAUTHORIZED_CONNECTION_ACCESS(403, "OMAG-SERVER-SECURITY-403-006", "User {0} is not authorized to access connection {1}", "The system is unable to process a request from the user because they do not have access to the" + "requested connection. The request fails with a UserNotAuthorizedException exception.", "Using knowledge about the connection and the user, determine if this result is expected, " + "or if the configuration needs to be adjusted to allow this user to perform the request."), - UNAUTHORIZED_ASSET_ACCESS(403, "OMAG-PLATFORM-SECURITY-403-007", + UNAUTHORIZED_ASSET_ACCESS(403, "OMAG-SERVER-SECURITY-403-007", "User {0} is not authorized to access asset {1}", "The system is unable to process a request from the user because they do not have access to the " + "requested asset. The request fails with a UserNotAuthorizedException exception.", "Using knowledge about the user and the asset, determine if this is the correct result or " + "the configuration needs to be changed to allow access."), - UNAUTHORIZED_ASSET_CREATE(403, "OMAG-PLATFORM-SECURITY-403-008", + UNAUTHORIZED_ASSET_CREATE(403, "OMAG-SERVER-SECURITY-403-008", "User {0} is not authorized to create an asset of type {1}", "The system is unable to process a request from the user because they do not have authority to create " + "an asset of the requested type. The request fails with a UserNotAuthorizedException exception.", "Using knowledge about the user and the asset, determine if this is the correct result or " + "the configuration needs to be changed to allow the user to create the asset."), - UNAUTHORIZED_ASSET_CHANGE(403, "OMAG-PLATFORM-SECURITY-403-009", + UNAUTHORIZED_ASSET_CHANGE(403, "OMAG-SERVER-SECURITY-403-009", "User {0} is not authorized to change asset {1}", "The system is unable to process a request from the user because they do not have access to change the " + "properties of the requested asset. The request fails with a UserNotAuthorizedException exception.", "Using knowledge about the user and the asset, determine if this is the correct result or " + "the configuration needs to be changed to allow the user to update the asset."), - INCOMPLETE_ASSET( 403, "OMAG-PLATFORM-SECURITY-403-010", + INCOMPLETE_ASSET( 403, "OMAG-SERVER-SECURITY-403-010", "User {0} is not authorized to change asset {1} because it has missing properties: {2}", "The system is unable to process a request from the user because the asset is not correctly or completely filled out." + " The request fails with a UserNotAuthorizedException exception.", "Using knowledge about the asset determine why the properties are missing and whether it needs to be " + "updated, or that the user should not be accessing the asset."), - UNAUTHORIZED_TYPE_ACCESS(403, "OMAG-PLATFORM-SECURITY-403-011", + UNAUTHORIZED_TYPE_ACCESS(403, "OMAG-SERVER-SECURITY-403-011", "User {0} is not authorized to access open metadata type {1} ({2}) on server {3}", "The system is unable to process a request from the user because they do not have access to the " + "necessary services and/or resources to retrieve type information. The request fails with a " + @@ -121,7 +121,7 @@ public enum OpenMetadataSecurityErrorCode implements ExceptionMessageSet "Determine if the user should be allowed access to the type information or not. If they should then " + "change the configuration to give them access."), - UNAUTHORIZED_TYPE_CHANGE(403, "OMAG-PLATFORM-SECURITY-403-012", + UNAUTHORIZED_TYPE_CHANGE(403, "OMAG-SERVER-SECURITY-403-012", "User {0} is not authorized to change open metadata type {1} ({2}) on server {3}", "The system is unable to process a request from the user because they do not have access to " + "update an open metadata type. The request fails with a UserNotAuthorizedException exception.", @@ -129,34 +129,47 @@ public enum OpenMetadataSecurityErrorCode implements ExceptionMessageSet "if the user is privileged to make these changes. If they are then update the configuration to grant them " + "access."), - UNAUTHORIZED_INSTANCE_ACCESS(403, "OMAG-PLATFORM-SECURITY-403-013", + UNAUTHORIZED_INSTANCE_ACCESS(403, "OMAG-SERVER-SECURITY-403-013", "User {0} is not authorized to access open metadata instance {1} of type {2} on server {3}", "The system is unable to process a request from the user because they do not have read access to the " + "requested metadata. The request fails with a UserNotAuthorizedException exception.", "Determine if the user should have access to this metadata instance and if they should then" + " change the configuration to give them the required privileges."), - UNAUTHORIZED_INSTANCE_CHANGE(403, "OMAG-PLATFORM-SECURITY-403-014", + UNAUTHORIZED_INSTANCE_CHANGE(403, "OMAG-SERVER-SECURITY-403-014", "User {0} is not authorized to change open metadata instance {1} of type {2} on server {3}", "The system is unable to process a request from the user because they do not have access to " + "make changes to the requested metadata instance. The request fails with a UserNotAuthorizedException exception.", "Determine if the user should have access to this metadata instance and if they should then " + "change the configuration to give them the required update privileges."), - MULTIPLE_CONNECTIONS_FOUND(403, "OMAG-PLATFORM-SECURITY-403-015", + MULTIPLE_CONNECTIONS_FOUND(403, "OMAG-SERVER-SECURITY-403-015", "{0} connections are connected to the asset with unique identifier {1} but there is no security connector to select a connection for user {2}; the calling method is {3}", "The system is unable to process a request because multiple connections have been discovered and it is unsure which connection to return.", "Either add a server security connection or use a method such as getConnectionsForAsset() to page through the list of connections to select the one that is appropriate for their use case."), - NO_CONNECTIONS_ALLOWED(403, "OMAG-PLATFORM-SECURITY-403-016", + NO_CONNECTIONS_ALLOWED(403, "OMAG-SERVER-SECURITY-403-016", "{0} connections are connected to the asset with unique identifier {1} but the user {2} is not permitted to use any of them; the calling method is {3}", "The system is unable to process a request because the calling user does not have sufficient privileges.", "No action is required if this user should not have access to the connection. To gain access to the connection, either the security credentials of the user need changing, or a different userId is required."), + UNAUTHORIZED_GLOSSARY_ACCESS(403, "OMAG-SERVER-SECURITY-403-020", + "User {0} is not authorized to issue an operation {1} on glossary {2}", + "The security service detected an unauthorized access to a glossary.", + "Review the security policies and settings to determine if this access to a glossary should be allowed or not." + + " Take action to either change the security sessions or determine the reason for the unauthorized request."), + + UNKNOWN_CONNECTION_RETURNED(500, "OMAG-PLATFORM-SECURITY-500-001", "{0} connections are connected to the asset with unique identifier {1} but the connector selecting the connection for user {2} has returned an unrecognized connection; the calling method is {3}", "The system is unable to process a request because the security connector is behaving strangely.", "Investigate and correct the behaviour of the server security connector."), + + NULL_GLOSSARY(500, "OMAG-SERVER-SECURITY-500-002", + "User {0} is not authorized to iss operation {1} because the glossary is null", + "The system is unable to process a request from the user because the glossary element is not correctly anchored on a glossary.", + "The request fails with a UserNotAuthorizedException exception. Add the anchor relationship of the glossary element to its glossary and corresponding Anchors classification. When both are in place, re-run the request."), + ; private final ExceptionMessageDefinition messageDefinition; diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java index eb127ea3b4b..cf48bdde02c 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java @@ -18,6 +18,7 @@ import org.odpi.openmetadata.metadatasecurity.properties.ConfidentialityGovernanceClassification; import org.odpi.openmetadata.metadatasecurity.properties.Connection; import org.odpi.openmetadata.metadatasecurity.properties.CriticalityGovernanceClassification; +import org.odpi.openmetadata.metadatasecurity.properties.Glossary; import org.odpi.openmetadata.metadatasecurity.properties.GovernanceClassificationStatus; import org.odpi.openmetadata.metadatasecurity.properties.ImpactGovernanceClassification; import org.odpi.openmetadata.metadatasecurity.properties.ReferenceableStatus; @@ -53,7 +54,7 @@ public class OpenMetadataServerSecurityVerifier implements OpenMetadataRepositor private static final String NAME_PROPERTY_NAME = "name"; /* from Asset entity */ - private static final String DISPLAY_NAME_PROPERTY_NAME = "displayName"; /* from many entities */ + private static final String DISPLAY_NAME_PROPERTY_NAME = "displayName"; /* from many entities */ private static final String DESCRIPTION_PROPERTY_NAME = "description"; /* from many entity */ private static final String SECURED_PROPERTIES_PROPERTY_NAME = "securedProperties"; /* from Connection entity */ @@ -61,6 +62,8 @@ public class OpenMetadataServerSecurityVerifier implements OpenMetadataRepositor private static final String USER_ID_PROPERTY_NAME = "userId"; /* from Connection entity */ private static final String CLEAR_PASSWORD_PROPERTY_NAME = "clearPassword"; /* from Connection entity */ private static final String ENCRYPTED_PASSWORD_PROPERTY_NAME = "encryptedPassword"; /* from Connection entity */ + private static final String LANGUAGE_PROPERTY_NAME = "language"; /* from Glossary entity */ + private static final String USAGE_PROPERTY_NAME = "usage"; /* from Glossary entity */ private static final String LEVEL_IDENTIFIER_PROPERTY_NAME = "levelIdentifier"; /* from many governance entities and classifications */ private static final String BASIS_IDENTIFIER_PROPERTY_NAME = "basisIdentifier"; /* from Retention classification */ @@ -91,6 +94,7 @@ public class OpenMetadataServerSecurityVerifier implements OpenMetadataRepositor private static final String SECURITY_TAG_CLASSIFICATION_TYPE_NAME = "SecurityTags"; private static final String SECURITY_LABELS_PROPERTY_NAME = "securityLabels"; private static final String SECURITY_PROPERTIES_PROPERTY_NAME = "securityProperties"; + private static final String ACCESS_GROUPS_PROPERTY_NAME = "accessGroups"; private static final String ASSET_ZONES_CLASSIFICATION_NAME = "AssetZoneMembership"; @@ -105,7 +109,7 @@ public class OpenMetadataServerSecurityVerifier implements OpenMetadataRepositor private static final String ASSET_OWNERSHIP_CLASSIFICATION_NAME = "AssetOwnership"; - private static final String OWNERSHIP_CLASSIFICATION_TYPE_NAME = "Ownership"; + private static final String OWNERSHIP_CLASSIFICATION_TYPE_NAME = "Ownership"; private static final String OWNER_PROPERTY_NAME = "owner"; /* from Area 4 */ private static final String OWNER_TYPE_PROPERTY_NAME = "ownerType"; /* deprecated */ @@ -117,6 +121,7 @@ public class OpenMetadataServerSecurityVerifier implements OpenMetadataRepositor private OpenMetadataServiceSecurity serviceSecurityConnector = null; private OpenMetadataConnectionSecurity connectionSecurityConnector = null; private OpenMetadataAssetSecurity assetSecurityConnector = null; + private OpenMetadataGlossarySecurity glossarySecurityConnector = null; private final InvalidParameterHandler invalidParameterHandler = new InvalidParameterHandler(); @@ -180,6 +185,10 @@ synchronized public void registerSecurityValidator(String { assetSecurityConnector = (OpenMetadataAssetSecurity)connector; } + if (connector instanceof OpenMetadataGlossarySecurity) + { + glossarySecurityConnector = (OpenMetadataGlossarySecurity)connector; + } } catch (InvalidParameterException error) { @@ -563,6 +572,10 @@ private void setupAssetBeanWithEntityProperties(Asset assetBean, SECURITY_PROPERTIES_PROPERTY_NAME, securityTagProperties, methodName)); + assetBean.setAccessGroups(repositoryHelper.getStringArrayStringMapFromProperty(serviceName, + ACCESS_GROUPS_PROPERTY_NAME, + securityTagProperties, + methodName)); } if (confidentialityProperties != null) @@ -794,9 +807,6 @@ private void setupAssetBeanWithEntityProperties(Asset assetBean, } - - - /** * Fill in information about a connection from an entity. This is to pass to the Open Metadata Security verifier. * @@ -1203,7 +1213,7 @@ public void validateUserForAssetCreate(String userId, repositoryHelper.getClassificationProperties(serviceName, classifications, CRITICALITY_CLASSIFICATION_TYPE_NAME, methodName), repositoryHelper.getClassificationProperties(serviceName, classifications, IMPACT_CLASSIFICATION_TYPE_NAME, methodName), repositoryHelper.getClassificationProperties(serviceName, classifications, RETENTION_CLASSIFICATION_TYPE_NAME, methodName), - repositoryHelper.getClassificationProperties(serviceName, classifications, ASSET_OWNERSHIP_CLASSIFICATION_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, OWNERSHIP_CLASSIFICATION_TYPE_NAME, methodName), repositoryHelper.getClassificationProperties(serviceName, classifications, ASSET_ZONES_CLASSIFICATION_NAME, methodName), repositoryHelper.getClassificationProperties(serviceName, classifications, ASSET_ORIGIN_CLASSIFICATION_NAME, methodName), repositoryHelper, @@ -1339,9 +1349,8 @@ public void validateUserForAssetAttachment(String userId, /** - * Validate that the user is able to perform the requested action on an attachment. This method should be used by the other - * handlers to verify whether the element they are working with is attached to a visible asset - * (ie is a member of one of the supported zones) that can be operated on by the calling user. + * Validate that the user is able to perform the requested action on an asset. This method should be used by the other + * handlers to verify whether the asset they are working with that can be operated on by the calling user. * * @param userId calling user * @param originalAssetEntity entity storing the current asset @@ -1352,13 +1361,13 @@ public void validateUserForAssetAttachment(String userId, * @param methodName calling method * @throws UserNotAuthorizedException user not authorized to issue this request */ - public void validateUserForAssetUpdate(String userId, - EntityDetail originalAssetEntity, - InstanceProperties updatedAssetProperties, - InstanceStatus newInstanceStatus, + public void validateUserForAssetUpdate(String userId, + EntityDetail originalAssetEntity, + InstanceProperties updatedAssetProperties, + InstanceStatus newInstanceStatus, OMRSRepositoryHelper repositoryHelper, - String serviceName, - String methodName) throws UserNotAuthorizedException + String serviceName, + String methodName) throws UserNotAuthorizedException { if (assetSecurityConnector != null) { @@ -1411,6 +1420,596 @@ public void validateUserForAssetDelete(String userId, } } + /* + * ========================================================================================================= + * Glossary Security + */ + + /** + * Fill in information about a glossary from an entity. This is to pass to the Open Metadata Security verifier. + * + * @param entity properties to add to the bean + * @param methodName calling method + * @return glossary bean + */ + private Glossary getGlossaryBeanFromEntity(EntityDetail entity, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) + { + if ((entity != null) && (entity.getType() != null)) + { + Glossary glossary = new Glossary(); + + String typeId = entity.getType().getTypeDefGUID(); + String typeName = entity.getType().getTypeDefName(); + InstanceStatus instanceStatus = entity.getStatus(); + String glossaryGUID = entity.getGUID(); + InstanceProperties entityProperties = entity.getProperties(); + InstanceProperties securityTagProperties = null; + InstanceProperties confidentialityProperties = null; + InstanceProperties confidenceProperties = null; + InstanceProperties criticalityProperties = null; + InstanceProperties impactProperties = null; + InstanceProperties retentionProperties = null; + InstanceProperties ownershipProperties = null; + + if (entity.getClassifications() != null) + { + for (Classification classification : entity.getClassifications()) + { + if (classification != null) + { + if (SECURITY_TAG_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + securityTagProperties = classification.getProperties(); + } + else if (CONFIDENTIALITY_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + confidentialityProperties = classification.getProperties(); + } + else if (CONFIDENCE_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + confidenceProperties = classification.getProperties(); + } + else if (CRITICALITY_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + criticalityProperties = classification.getProperties(); + } + else if (IMPACT_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + impactProperties = classification.getProperties(); + } + else if (RETENTION_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + retentionProperties = classification.getProperties(); + } + else if (OWNERSHIP_CLASSIFICATION_TYPE_NAME.equals(classification.getName())) + { + ownershipProperties = classification.getProperties(); + } + } + } + } + + setupGlossaryBeanWithEntityProperties(glossary, + typeId, + typeName, + instanceStatus, + glossaryGUID, + entityProperties, + securityTagProperties, + confidentialityProperties, + confidenceProperties, + criticalityProperties, + impactProperties, + retentionProperties, + ownershipProperties, + repositoryHelper, + serviceName, + methodName); + return glossary; + } + + return null; + } + + + /** + * Fill in information about a glossary from an entity. This is to pass to the Open Metadata Security verifier. + * + * @param glossary bean to fill out + * @param typeId unique identifier for the type of the entity + * @param typeName unique name for the type of the entity + * @param instanceStatus status from the entity + * @param assetGUID unique identifier for the entity + * @param entityProperties properties from the entity + * @param securityTagProperties properties from the SecurityTags classification + * @param confidentialityProperties properties from the Confidentiality classification + * @param confidenceProperties properties from the Confidence classification + * @param criticalityProperties properties from the Criticality classification + * @param impactProperties properties from the Impact classification + * @param retentionProperties properties from the Retention classification + * @param ownershipProperties properties from the Ownership classification + * @param repositoryHelper for working with OMRS objects + * @param serviceName calling service + * @param methodName calling method + */ + private void setupGlossaryBeanWithEntityProperties(Glossary glossary, + String typeId, + String typeName, + InstanceStatus instanceStatus, + String assetGUID, + InstanceProperties entityProperties, + InstanceProperties securityTagProperties, + InstanceProperties confidentialityProperties, + InstanceProperties confidenceProperties, + InstanceProperties criticalityProperties, + InstanceProperties impactProperties, + InstanceProperties retentionProperties, + InstanceProperties ownershipProperties, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) + { + glossary.setTypeGUID(typeId); + glossary.setTypeName(typeName); + glossary.setStatus(this.getReferenceableStatus(instanceStatus)); + glossary.setGUID(assetGUID); + + InstanceProperties properties = new InstanceProperties(entityProperties); + + glossary.setQualifiedName(repositoryHelper.removeStringProperty(serviceName, + QUALIFIED_NAME_PROPERTY_NAME, + properties, + methodName)); + glossary.setAdditionalProperties(repositoryHelper.removeStringMapFromProperty(serviceName, + ADDITIONAL_PROPERTIES_PROPERTY_NAME, + properties, + methodName)); + glossary.setDisplayName(repositoryHelper.removeStringProperty(serviceName, + NAME_PROPERTY_NAME, + properties, + methodName)); + glossary.setDescription(repositoryHelper.removeStringProperty(serviceName, + DESCRIPTION_PROPERTY_NAME, + properties, + methodName)); + + glossary.setLanguage(repositoryHelper.removeStringProperty(serviceName, + LANGUAGE_PROPERTY_NAME, + properties, + methodName)); + glossary.setUsage(repositoryHelper.removeStringProperty(serviceName, + USAGE_PROPERTY_NAME, + properties, + methodName)); + + glossary.setExtendedProperties(repositoryHelper.getInstancePropertiesAsMap(properties)); + + if (securityTagProperties != null) + { + glossary.setSecurityLabels(repositoryHelper.getStringArrayProperty(serviceName, + SECURITY_LABELS_PROPERTY_NAME, + securityTagProperties, + methodName)); + glossary.setSecurityProperties(repositoryHelper.getMapFromProperty(serviceName, + SECURITY_PROPERTIES_PROPERTY_NAME, + securityTagProperties, + methodName)); + glossary.setAccessGroups(repositoryHelper.getStringArrayStringMapFromProperty(serviceName, + ACCESS_GROUPS_PROPERTY_NAME, + securityTagProperties, + methodName)); + } + + if (confidentialityProperties != null) + { + ConfidentialityGovernanceClassification classification = new ConfidentialityGovernanceClassification(); + + classification.setStatus(repositoryHelper.getIntProperty(serviceName, + STATUS_IDENTIFIER_PROPERTY_NAME, + confidentialityProperties, + methodName)); + classification.setConfidence(repositoryHelper.getIntProperty(serviceName, + GOVERNANCE_CLASSIFICATION_CONFIDENCE_PROPERTY_NAME, + confidentialityProperties, + methodName)); + classification.setSteward(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_STEWARD_PROPERTY_NAME, + confidentialityProperties, + methodName)); + classification.setSource(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_SOURCE_PROPERTY_NAME, + confidentialityProperties, + methodName)); + classification.setNotes(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_NOTES_PROPERTY_NAME, + confidentialityProperties, + methodName)); + classification.setConfidentialityLevel(repositoryHelper.getIntProperty(serviceName, + LEVEL_IDENTIFIER_PROPERTY_NAME, + confidentialityProperties, + methodName)); + } + + if (confidenceProperties != null) + { + ConfidenceGovernanceClassification classification = new ConfidenceGovernanceClassification(); + + classification.setStatus(repositoryHelper.getIntProperty(serviceName, + STATUS_IDENTIFIER_PROPERTY_NAME, + confidenceProperties, + methodName)); + classification.setConfidence(repositoryHelper.getIntProperty(serviceName, + GOVERNANCE_CLASSIFICATION_CONFIDENCE_PROPERTY_NAME, + confidenceProperties, + methodName)); + classification.setSteward(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_STEWARD_PROPERTY_NAME, + confidenceProperties, + methodName)); + classification.setSource(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_SOURCE_PROPERTY_NAME, + confidenceProperties, + methodName)); + classification.setNotes(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_NOTES_PROPERTY_NAME, + confidenceProperties, + methodName)); + classification.setConfidenceLevel(repositoryHelper.getIntProperty(serviceName, + LEVEL_IDENTIFIER_PROPERTY_NAME, + confidenceProperties, + methodName)); + } + + if (criticalityProperties != null) + { + CriticalityGovernanceClassification classification = new CriticalityGovernanceClassification(); + + classification.setStatus(repositoryHelper.getIntProperty(serviceName, + STATUS_IDENTIFIER_PROPERTY_NAME, + criticalityProperties, + methodName)); + classification.setConfidence(repositoryHelper.getIntProperty(serviceName, + GOVERNANCE_CLASSIFICATION_CONFIDENCE_PROPERTY_NAME, + criticalityProperties, + methodName)); + classification.setSteward(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_STEWARD_PROPERTY_NAME, + criticalityProperties, + methodName)); + classification.setSource(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_SOURCE_PROPERTY_NAME, + criticalityProperties, + methodName)); + classification.setNotes(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_NOTES_PROPERTY_NAME, + criticalityProperties, + methodName)); + classification.setCriticalityLevel(repositoryHelper.getIntProperty(serviceName, + LEVEL_IDENTIFIER_PROPERTY_NAME, + criticalityProperties, + methodName)); + } + + if (impactProperties != null) + { + ImpactGovernanceClassification classification = new ImpactGovernanceClassification(); + + classification.setStatus(repositoryHelper.getIntProperty(serviceName, + STATUS_IDENTIFIER_PROPERTY_NAME, + impactProperties, + methodName)); + classification.setConfidence(repositoryHelper.getIntProperty(serviceName, + GOVERNANCE_CLASSIFICATION_CONFIDENCE_PROPERTY_NAME, + impactProperties, + methodName)); + classification.setSteward(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_STEWARD_PROPERTY_NAME, + impactProperties, + methodName)); + classification.setSource(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_SOURCE_PROPERTY_NAME, + impactProperties, + methodName)); + classification.setNotes(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_NOTES_PROPERTY_NAME, + impactProperties, + methodName)); + classification.setImpactSeverityLevel(repositoryHelper.getIntProperty(serviceName, + SEVERITY_LEVEL_IDENTIFIER_PROPERTY_NAME, + impactProperties, + methodName)); + } + + if (retentionProperties != null) + { + RetentionGovernanceClassification classification = new RetentionGovernanceClassification(); + + classification.setStatus(repositoryHelper.getIntProperty(serviceName, + STATUS_IDENTIFIER_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setConfidence(repositoryHelper.getIntProperty(serviceName, + GOVERNANCE_CLASSIFICATION_CONFIDENCE_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setSteward(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_STEWARD_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setSource(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_SOURCE_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setNotes(repositoryHelper.getStringProperty(serviceName, + GOVERNANCE_CLASSIFICATION_NOTES_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setRetentionBasis(repositoryHelper.getIntProperty(serviceName, + BASIS_IDENTIFIER_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setAssociatedGUID(repositoryHelper.getStringProperty(serviceName, + RETENTION_ASSOCIATED_GUID_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setArchiveAfter(repositoryHelper.getDateProperty(serviceName, + RETENTION_ARCHIVE_AFTER_PROPERTY_NAME, + retentionProperties, + methodName)); + classification.setDeleteAfter(repositoryHelper.getDateProperty(serviceName, + RETENTION_DELETE_AFTER_PROPERTY_NAME, + retentionProperties, + methodName)); + } + + if (ownershipProperties != null) + { + glossary.setOwner(repositoryHelper.getStringProperty(serviceName, + OWNER_PROPERTY_NAME, + ownershipProperties, + methodName)); + glossary.setOwnerType(repositoryHelper.getEnumPropertyOrdinal(serviceName, + OWNER_TYPE_PROPERTY_NAME, + ownershipProperties, + methodName)); + } + } + + + /** + * Tests for whether a specific user should have the right to create a glossary. + * + * @param userId identifier of user + * @param entityTypeGUID unique identifier of the type of entity to create + * @param entityTypeName unique name of the type of entity to create + * @param newProperties properties for new entity + * @param classifications classifications for new entity + * @param instanceStatus status for new entity + * @param repositoryHelper manipulates repository service objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException the user is not authorized to perform this command + */ + public void validateUserForGlossaryCreate(String userId, + String entityTypeGUID, + String entityTypeName, + InstanceProperties newProperties, + List classifications, + InstanceStatus instanceStatus, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Need to build a description of the glossary to pass to the metadata security object. + */ + Glossary glossaryBeanForMetadataSecurity = new Glossary(); + + setupGlossaryBeanWithEntityProperties(glossaryBeanForMetadataSecurity, + entityTypeGUID, + entityTypeName, + instanceStatus, + null, + newProperties, + repositoryHelper.getClassificationProperties(serviceName, classifications, SECURITY_TAG_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, CONFIDENTIALITY_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, CONFIDENCE_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, CRITICALITY_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, IMPACT_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, RETENTION_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper.getClassificationProperties(serviceName, classifications, OWNERSHIP_CLASSIFICATION_TYPE_NAME, methodName), + repositoryHelper, + serviceName, + methodName); + + glossarySecurityConnector.validateUserForGlossaryCreate(userId, new Glossary(glossaryBeanForMetadataSecurity)); + } + } + + + /** + * Tests for whether a specific user should have read access to a specific glossary and its contents. + * + * @param userId calling user + * @param entity entity storing the glossary's properties + * @param repositoryHelper helper for OMRS objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException user not authorized to issue this request + */ + public void validateUserForGlossaryRead(String userId, + EntityDetail entity, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Create the bean for the security module then call the appropriate security method. + */ + Glossary glossary = this.getGlossaryBeanFromEntity(entity, repositoryHelper, serviceName, methodName); + + glossarySecurityConnector.validateUserForGlossaryRead(userId, glossary); + } + } + + + /** + * Tests for whether a specific user should have the right to update the properties of a glossary. + * + * @param userId identifier of user + * @param originalEntity original glossary details + * @param newEntityProperties new glossary details + * @param repositoryHelper helper for OMRS objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + public void validateUserForGlossaryDetailUpdate(String userId, + EntityDetail originalEntity, + InstanceProperties newEntityProperties, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Create the bean for the security module then call the appropriate security method. + */ + Glossary originalGlossary = this.getGlossaryBeanFromEntity(originalEntity, repositoryHelper, serviceName, methodName); + + EntityDetail updatedGlossaryEntity = new EntityDetail(originalEntity); + updatedGlossaryEntity.setProperties(newEntityProperties); + Glossary newGlossary = this.getGlossaryBeanFromEntity(updatedGlossaryEntity, repositoryHelper, serviceName, methodName); + + glossarySecurityConnector.validateUserForGlossaryDetailUpdate(userId, originalGlossary, newGlossary); + } + } + + + /** + * Tests for whether a specific user should have the right to update elements attached directly + * to a glossary such as glossary terms and categories. These updates could be to their properties, + * classifications and relationships. It also includes attaching valid values but not semantic assignments + * since they are considered updates to the associated asset. + * + * @param userId identifier of user + * @param entity glossary details + * @param repositoryHelper helper for OMRS objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + public void validateUserForGlossaryMemberUpdate(String userId, + EntityDetail entity, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Create the bean for the security module then call the appropriate security method. + */ + Glossary glossary = this.getGlossaryBeanFromEntity(entity, repositoryHelper, serviceName, methodName); + + glossarySecurityConnector.validateUserForGlossaryMemberUpdate(userId, glossary); + } + } + + + /** + * Tests for whether a specific user should have the right to update the instance status of a term + * anchored in a glossary. + * + * @param userId identifier of user + * @param entity glossary details + * @param repositoryHelper helper for OMRS objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + public void validateUserForGlossaryMemberStatusUpdate(String userId, + EntityDetail entity, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Create the bean for the security module then call the appropriate security method. + */ + Glossary glossary = this.getGlossaryBeanFromEntity(entity, repositoryHelper, serviceName, methodName); + + glossarySecurityConnector.validateUserForGlossaryMemberStatusUpdate(userId, glossary); + } + } + + + /** + * Tests for whether a specific user should have the right to attach feedback - such as comments, + * ratings, tags and likes, to the glossary. + * + * @param userId identifier of user + * @param entity original glossary details + * @param repositoryHelper helper for OMRS objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + public void validateUserForGlossaryFeedback(String userId, + EntityDetail entity, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Create the bean for the security module then call the appropriate security method. + */ + Glossary glossary = this.getGlossaryBeanFromEntity(entity, repositoryHelper, serviceName, methodName); + + glossarySecurityConnector.validateUserForGlossaryFeedback(userId, glossary); + } + } + + + /** + * Tests for whether a specific user should have the right to delete a glossary and all of its contents. + * + * @param userId identifier of user + * @param entity original glossary details + * @param repositoryHelper helper for OMRS objects + * @param serviceName calling service + * @param methodName calling method + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + public void validateUserForGlossaryDelete(String userId, + EntityDetail entity, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String methodName) throws UserNotAuthorizedException + { + if (glossarySecurityConnector != null) + { + /* + * Create the bean for the security module then call the appropriate security method. + */ + Glossary glossary = this.getGlossaryBeanFromEntity(entity, repositoryHelper, serviceName, methodName); + + glossarySecurityConnector.validateUserForGlossaryDelete(userId, glossary); + } + } + /* * ========================================================================================================= diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java index b22193b0961..2c380b92739 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java @@ -26,13 +26,13 @@ */ public class RepositoryFindEntitiesIterator extends RepositoryIteratorForEntities { - private List entitySubtypeGUIDs; - private SearchProperties searchProperties; - private List limitResultsByStatus; - private SearchClassifications searchClassifications; - private Date asOfTime; - private String sequencingProperty; - private SequencingOrder sequencingOrder; + private final List entitySubtypeGUIDs; + private final SearchProperties searchProperties; + private final List limitResultsByStatus; + private final SearchClassifications searchClassifications; + private final Date asOfTime; + private final String sequencingProperty; + private final SequencingOrder sequencingOrder; /** * Constructor takes the parameters used to call the repository handler. diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java index dd50bae2cf2..41795bdcf6a 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java @@ -8,6 +8,7 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; @@ -1249,6 +1250,121 @@ public void updateEntityProperties(String userId, } + /** + * Undo the last update to the requested entity. + * + * @param userId unique identifier for requesting user. + * @param externalSourceGUID unique identifier (guid) for the external source, or null for local. + * @param externalSourceName unique name for the external source. + * @param updatedEntityGUID String unique identifier (guid) for the entity. + * @param methodName name of calling method + * @return recovered entity + * + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public EntityDetail undoEntityUpdate(String userId, + String externalSourceGUID, + String externalSourceName, + String updatedEntityGUID, + String methodName) throws UserNotAuthorizedException, + PropertyServerException + { + final String localMethodName = "undoEntityUpdate"; + + try + { + EntityDetail entity = metadataCollection.undoEntityUpdate(userId, updatedEntityGUID); + + if (entity != null) + { + errorHandler.validateProvenance(userId, + entity, + updatedEntityGUID, + externalSourceGUID, + externalSourceName, + methodName); + } + + return entity; + } + catch (UserNotAuthorizedException error) + { + /* + * This comes from validateProvenance. The call to validate provenance is in the try...catch + * in case the caller has passed bad parameters. + */ + throw error; + } + catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException error) + { + errorHandler.handleUnauthorizedUser(userId, methodName); + } + catch (Exception error) + { + errorHandler.handleRepositoryError(error, methodName, localMethodName); + } + + return null; + } + + + + /** + * Return all historical versions of an entity within the bounds of the provided timestamps. To retrieve all historical + * versions of an entity, set both the 'fromTime' and 'toTime' to null. + * + * @param userId unique identifier for requesting user. + * @param guid String unique identifier for the entity. + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startingFrom the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param sequencingOrder Enum defining how the results should be ordered. + * @param methodName name of calling method + * @return list of versions of an entity + * + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getEntityDetailHistory(String userId, + String guid, + Date fromTime, + Date toTime, + int startingFrom, + int pageSize, + HistorySequencingOrder sequencingOrder, + String methodName) throws UserNotAuthorizedException, + PropertyServerException + { + final String localMethodName = "getEntityDetailHistory"; + + try + { + return metadataCollection.getEntityDetailHistory(userId, + guid, + fromTime, + toTime, + startingFrom, + pageSize, + sequencingOrder); + } + catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException error) + { + errorHandler.handleUnauthorizedUser(userId, methodName); + } + catch (Exception error) + { + errorHandler.handleRepositoryError(error, methodName, localMethodName); + } + + return null; + } + + + /** * Update an existing entity status in the open metadata repository. The external source identifiers * are used to validate the provenance of the entity before the update. If they are null, @@ -2101,6 +2217,42 @@ private void isolateAndRemoveEntity(String userId, } + /** + * Remove an entity from the open metadata repository without additional checks. + * + * @param userId calling user + * @param obsoleteEntityGUID unique identifier of the entity + * @param entityTypeGUID type of entity to delete + * @param entityTypeName name of the entity's type + * @param methodName name of calling method + * + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void simpleDeleteEntity(String userId, + String obsoleteEntityGUID, + String entityTypeGUID, + String entityTypeName, + String methodName) throws UserNotAuthorizedException, + PropertyServerException + { + final String localMethodName = "simpleDeleteEntity"; + + try + { + metadataCollection.deleteEntity(userId, entityTypeGUID, entityTypeName, obsoleteEntityGUID); + } + catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.FunctionNotSupportedException error) + { + this.purgeEntity(userId, obsoleteEntityGUID, entityTypeGUID, entityTypeName, methodName); + } + catch (Exception error) + { + errorHandler.handleRepositoryError(error, methodName, localMethodName); + } + } + + /** * Purge an entity stored in a repository that does not support delete. * @@ -2163,15 +2315,16 @@ public void purgeEntity(String userId, * @param deletedEntityGUID String unique identifier (guid) for the entity. * @param methodName name of calling method * + * @return restored entity * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - public void restoreEntity(String userId, - String externalSourceGUID, - String externalSourceName, - String deletedEntityGUID, - String methodName) throws UserNotAuthorizedException, - PropertyServerException + public EntityDetail restoreEntity(String userId, + String externalSourceGUID, + String externalSourceName, + String deletedEntityGUID, + String methodName) throws UserNotAuthorizedException, + PropertyServerException { final String localMethodName = "restoreEntity"; @@ -2188,6 +2341,8 @@ public void restoreEntity(String userId, externalSourceName, methodName); } + + return entity; } catch (UserNotAuthorizedException error) { @@ -2205,6 +2360,8 @@ public void restoreEntity(String userId, { errorHandler.handleRepositoryError(error, methodName, localMethodName); } + + return null; } diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java index d36f7e54f41..2770305645b 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java @@ -95,8 +95,8 @@ public RepositorySelectedEntitiesIterator(RepositoryHandler repositoryHand * @param methodName name of calling method * @throws InvalidParameterException bad parameter - probably page size */ - public RepositorySelectedEntitiesIterator(RepositoryHandler repositoryHandler, - InvalidParameterHandler invalidParameterHandler, + public RepositorySelectedEntitiesIterator(RepositoryHandler repositoryHandler, + InvalidParameterHandler invalidParameterHandler, String userId, String entityTypeGUID, String searchCriteria, diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/converters/package-info.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/converters/package-info.java deleted file mode 100644 index 9ce1f60c34e..00000000000 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/converters/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.commonservices.ocf.metadatamanagement.converters; - -/** - * The converters are responsible for converting entities, classifications and relationships retrieved from the - * open metadata repositories into Open Connector Framework (OCF) beans. - * - * The inheritance structure follows closely to the inheritance structure of the beans themselves and the naming - * convention is consistent. The converter used is the one that corresponds to the desired bean. - * When a converter is created, it is passed the entity with its embedded classifications and a relationship if - * required on the constructor. The bean is retrieved by calling getBean(). - */ diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/CommentConverter.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/CommentConverter.java index 96a794fe01b..340c2440073 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/CommentConverter.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/CommentConverter.java @@ -112,7 +112,7 @@ public B getNewBean(Class beanClass, /** - * Retrieve and delete the OwnerType enum property from the instance properties of an entity + * Retrieve and delete the CommentType enum property from the instance properties of an entity * * @param properties entity properties * @return CommentType enum value diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/RatingConverter.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/RatingConverter.java index bcb943ac0d7..9e9fcc67c43 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/RatingConverter.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/RatingConverter.java @@ -97,7 +97,7 @@ public B getNewBean(Class beanClass, /** - * Retrieve and delete the OwnerType enum property from the instance properties of an entity + * Retrieve and delete the StarRating enum property from the instance properties of an entity * * @param properties entity properties * @return StarRating enum value diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementControlHeader.java b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementControlHeader.java index e163e818e6c..87026ca7874 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementControlHeader.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementControlHeader.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.*; +import java.io.Serial; import java.util.*; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -25,7 +26,8 @@ }) public class ElementControlHeader extends PropertyBase { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; /* * Common header for first class elements from a metadata repository diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementHeader.java b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementHeader.java index 39454e69ebb..3ce44fb1d6f 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementHeader.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementHeader.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import java.io.Serial; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -32,7 +33,8 @@ }) public class ElementHeader extends ElementControlHeader { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; /* * Common header for entities from a metadata repository diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementType.java b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementType.java index 7805e97894e..06f085b8b69 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementType.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementType.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -22,6 +23,7 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class ElementType implements Serializable { + @Serial private static final long serialVersionUID = 1L; private String typeId = null; diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementVersions.java b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementVersions.java index 3c5c8ed23f4..cf5d5dc6611 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementVersions.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ElementVersions.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; @@ -24,7 +25,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class ElementVersions implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private String createdBy = null; private String updatedBy = null; diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/Note.java b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/Note.java index cd8a7987dba..bc013f5ace5 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/Note.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/Note.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; import java.util.Date; import java.util.Objects; @@ -20,7 +21,8 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class Note extends Referenceable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; /* * Attributes of a Note diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java index df555fdc96b..23ffd5aaafc 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java @@ -783,7 +783,52 @@ public List findGlossaryCategories(String searchStrin UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.findGlossaryCategories(userId, assetManagerGUID, assetManagerName, searchString, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.findGlossaryCategories(userId, + assetManagerGUID, + assetManagerName, + null, + searchString, + startFrom, + pageSize, + effectiveTime, + forLineage, + forDuplicateProcessing); + } + + + /** + * Retrieve the list of glossary category metadata elements that contain the search string. + * The search string is treated as a regular expression. + * + * @param glossaryGUID optional glossary unique identifier to scope the search to a glossary. + * @param searchString string to find in the properties + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of matching metadata elements + * + * @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) + */ + public List findGlossaryCategories(String glossaryGUID, + String searchString, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return glossaryManagerClient.findGlossaryCategories(userId, + assetManagerGUID, + assetManagerName, + glossaryGUID, + searchString, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -809,7 +854,14 @@ public List getCategoriesForGlossary(String glossaryG UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getCategoriesForGlossary(userId, assetManagerGUID, assetManagerName, glossaryGUID, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.getCategoriesForGlossary(userId, + assetManagerGUID, + assetManagerName, + glossaryGUID, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -836,7 +888,52 @@ public List getGlossaryCategoriesByName(String name, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getGlossaryCategoriesByName(userId, assetManagerGUID, assetManagerName, name, startFrom, pageSize, effectiveTime , forLineage, + return glossaryManagerClient.getGlossaryCategoriesByName(userId, + assetManagerGUID, + assetManagerName, + null, + name, + startFrom, + pageSize, + effectiveTime, + forLineage, + forDuplicateProcessing); + } + + + /** + * Retrieve the list of glossary category metadata elements with a matching qualified or display name. + * There are no wildcards supported on this request. + * + * @param glossaryGUID optional glossary unique identifier to scope the search to a glossary. + * @param name name to search for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of matching metadata elements + * + * @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) + */ + public List getGlossaryCategoriesByName(String glossaryGUID, + String name, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return glossaryManagerClient.getGlossaryCategoriesByName(userId, + assetManagerGUID, + assetManagerName, + glossaryGUID, + name, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -858,7 +955,12 @@ public GlossaryCategoryElement getGlossaryCategoryByGUID(String guid, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getGlossaryCategoryByGUID(userId, assetManagerGUID, assetManagerName, guid, effectiveTime, forLineage, + return glossaryManagerClient.getGlossaryCategoryByGUID(userId, + assetManagerGUID, + assetManagerName, + guid, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -886,7 +988,12 @@ public GlossaryCategoryElement getGlossaryCategoryParent(String userId, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getGlossaryCategoryParent(userId, assetManagerGUID, assetManagerName, glossaryCategoryGUID, effectiveTime, forLineage, + return glossaryManagerClient.getGlossaryCategoryParent(userId, + assetManagerGUID, + assetManagerName, + glossaryCategoryGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -918,7 +1025,14 @@ public List getGlossarySubCategories(String userId, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getGlossarySubCategories(userId, assetManagerGUID, assetManagerName, glossaryCategoryGUID, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.getGlossarySubCategories(userId, + assetManagerGUID, + assetManagerName, + glossaryCategoryGUID, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1090,7 +1204,15 @@ public void updateGlossaryTerm(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.updateGlossaryTerm(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, isMergeUpdate, glossaryTermProperties, effectiveTime, forLineage, + glossaryManagerClient.updateGlossaryTerm(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + isMergeUpdate, + glossaryTermProperties, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1136,7 +1258,14 @@ public void updateGlossaryTermStatus(String userId, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.updateGlossaryTermStatus(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, glossaryTermStatus, effectiveTime, forLineage, + glossaryManagerClient.updateGlossaryTermStatus(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + glossaryTermStatus, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1175,7 +1304,14 @@ public void setupTermCategory(String glossaryCategoryGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setupTermCategory(userId, assetManagerGUID, assetManagerName, glossaryCategoryGUID, glossaryTermGUID, categorizationProperties, effectiveTime, forLineage, + glossaryManagerClient.setupTermCategory(userId, + assetManagerGUID, + assetManagerName, + glossaryCategoryGUID, + glossaryTermGUID, + categorizationProperties, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1212,7 +1348,13 @@ public void clearTermCategory(String glossaryCategoryGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermCategory(userId, assetManagerGUID, assetManagerName, glossaryCategoryGUID, glossaryTermGUID, effectiveTime, forLineage, + glossaryManagerClient.clearTermCategory(userId, + assetManagerGUID, + assetManagerName, + glossaryCategoryGUID, + glossaryTermGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1253,7 +1395,15 @@ public void setupTermRelationship(String relationshipTypeName, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setupTermRelationship(userId, assetManagerGUID, assetManagerName, relationshipTypeName, glossaryTermOneGUID, glossaryTermTwoGUID, relationshipsProperties, effectiveTime, forLineage, + glossaryManagerClient.setupTermRelationship(userId, + assetManagerGUID, + assetManagerName, + relationshipTypeName, + glossaryTermOneGUID, + glossaryTermTwoGUID, + relationshipsProperties, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1294,7 +1444,15 @@ public void updateTermRelationship(String relationshipTypeName if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.updateTermRelationship(userId, assetManagerGUID, assetManagerName, relationshipTypeName, glossaryTermOneGUID, glossaryTermTwoGUID, relationshipsProperties, effectiveTime, forLineage, + glossaryManagerClient.updateTermRelationship(userId, + assetManagerGUID, + assetManagerName, + relationshipTypeName, + glossaryTermOneGUID, + glossaryTermTwoGUID, + relationshipsProperties, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1333,7 +1491,14 @@ public void clearTermRelationship(String relationshipTypeName, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermRelationship(userId, assetManagerGUID, assetManagerName, relationshipTypeName, glossaryTermOneGUID, glossaryTermTwoGUID, effectiveTime, forLineage, + glossaryManagerClient.clearTermRelationship(userId, + assetManagerGUID, + assetManagerName, + relationshipTypeName, + glossaryTermOneGUID, + glossaryTermTwoGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1370,7 +1535,13 @@ public void setTermAsAbstractConcept(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsAbstractConcept(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.setTermAsAbstractConcept(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1407,7 +1578,13 @@ public void clearTermAsAbstractConcept(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsAbstractConcept(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsAbstractConcept(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1444,7 +1621,13 @@ public void setTermAsDataValue(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsDataValue(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.setTermAsDataValue(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1481,7 +1664,13 @@ public void clearTermAsDataValue(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsDataValue(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsDataValue(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1520,7 +1709,14 @@ public void setTermAsActivity(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsActivity(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, activityType, effectiveTime, forLineage, + glossaryManagerClient.setTermAsActivity(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + activityType, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1557,7 +1753,13 @@ public void clearTermAsActivity(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsActivity(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsActivity(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1596,7 +1798,14 @@ public void setTermAsContext(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsContext(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, contextDefinition, effectiveTime, forLineage, + glossaryManagerClient.setTermAsContext(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + contextDefinition, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1633,7 +1842,13 @@ public void clearTermAsContext(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsContext(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsContext(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1670,7 +1885,13 @@ public void setTermAsSpineObject(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsSpineObject(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.setTermAsSpineObject(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1707,7 +1928,13 @@ public void clearTermAsSpineObject(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsSpineObject(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsSpineObject(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1745,7 +1972,13 @@ public void setTermAsSpineAttribute(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsSpineAttribute(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.setTermAsSpineAttribute(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1782,7 +2015,13 @@ public void clearTermAsSpineAttribute(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsSpineAttribute(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsSpineAttribute(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1819,7 +2058,13 @@ public void setTermAsObjectIdentifier(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.setTermAsObjectIdentifier(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.setTermAsObjectIdentifier(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1856,7 +2101,13 @@ public void clearTermAsObjectIdentifier(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.clearTermAsObjectIdentifier(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.clearTermAsObjectIdentifier(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1893,7 +2144,13 @@ public void removeGlossaryTerm(String glossaryTermGUID, if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - glossaryManagerClient.removeGlossaryTerm(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, glossaryTermExternalIdentifier, effectiveTime, forLineage, + glossaryManagerClient.removeGlossaryTerm(userId, + assetManagerGUID, + assetManagerName, + glossaryTermGUID, + glossaryTermExternalIdentifier, + effectiveTime, + forLineage, forDuplicateProcessing); } else @@ -1931,7 +2188,57 @@ public List findGlossaryTerms(String searchString, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.findGlossaryTerms(userId, assetManagerGUID, assetManagerName, searchString, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.findGlossaryTerms(userId, + assetManagerGUID, + assetManagerName, + null, + searchString, + null, + startFrom, + pageSize, + effectiveTime, + forLineage, + forDuplicateProcessing); + } + + + /** + * Retrieve the list of glossary term metadata elements that contain the search string. + * The search string is treated as a regular expression. + * + * @param glossaryGUID unique identifier of the glossary to query + * @param searchString string to find in the properties + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of matching metadata elements + * + * @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) + */ + public List findGlossaryTerms(String glossaryGUID, + String searchString, + List limitResultsByStatus, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return glossaryManagerClient.findGlossaryTerms(userId, + assetManagerGUID, + assetManagerName, + glossaryGUID, + searchString, + limitResultsByStatus, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1957,7 +2264,14 @@ public List getTermsForGlossary(String glossaryGUID, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getTermsForGlossary(userId, assetManagerGUID, assetManagerName, glossaryGUID, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.getTermsForGlossary(userId, + assetManagerGUID, + assetManagerName, + glossaryGUID, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1983,7 +2297,14 @@ public List getTermsForGlossaryCategory(String glossaryC UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getTermsForGlossaryCategory(userId, assetManagerGUID, assetManagerName, glossaryCategoryGUID, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.getTermsForGlossaryCategory(userId, + assetManagerGUID, + assetManagerName, + glossaryCategoryGUID, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -2010,7 +2331,57 @@ public List getGlossaryTermsByName(String name, UserNotAuthorizedException, PropertyServerException { - return glossaryManagerClient.getGlossaryTermsByName(userId, assetManagerGUID, assetManagerName, name, startFrom, pageSize, effectiveTime, forLineage, + return glossaryManagerClient.getGlossaryTermsByName(userId, + assetManagerGUID, + assetManagerName, + null, + name, + null, + startFrom, + pageSize, + effectiveTime, + forLineage, + forDuplicateProcessing); + } + + + /** + * Retrieve the list of glossary term metadata elements with a matching qualified or display name. + * There are no wildcards supported on this request. + * + * @param glossaryGUID unique identifier of the glossary to query + * @param name name to search for + * @param limitResultsByStatus By default, terms in all statuses are returned. However, it is possible + * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all status values. + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of matching metadata elements + * + * @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) + */ + public List getGlossaryTermsByName(String glossaryGUID, + String name, + List limitResultsByStatus, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return glossaryManagerClient.getGlossaryTermsByName(userId, + assetManagerGUID, + assetManagerName, + glossaryGUID, + name, + limitResultsByStatus, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyComparisonOperator.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyComparisonOperator.java index 0ef7c5ebbdc..0d350c94e20 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyComparisonOperator.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyComparisonOperator.java @@ -68,9 +68,9 @@ public enum PropertyComparisonOperator implements Serializable private static final long serialVersionUID = 1L; - private int ordinal; - private String name; - private String description; + private final int ordinal; + private final String name; + private final String description; /** * Constructor to set up a single instances of the enum. diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyCondition.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyCondition.java index 710348d866e..a36450a1785 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyCondition.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/PropertyCondition.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -26,7 +27,8 @@ public class PropertyCondition implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private String property; private PropertyComparisonOperator operator; diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/SearchProperties.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/SearchProperties.java index 0f8414649b6..8df3a5c7a62 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/SearchProperties.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/properties/search/SearchProperties.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -25,7 +26,8 @@ public class SearchProperties implements Serializable { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private List conditions; private MatchCriteria matchCriteria; diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesHelper.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesHelper.java index 9dcbf29b2f2..61c1f4fa311 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesHelper.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesHelper.java @@ -8,6 +8,7 @@ import org.odpi.openmetadata.repositoryservices.ffdc.exception.*; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -231,6 +232,38 @@ Map removeIntegerMapFromProperty(String sourceName, String methodName); + /** + * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. + * + * @param sourceName source of call + * @param propertyName name of requested map property + * @param properties values of the property + * @param methodName method of caller + * @return map property value or null + */ + Map> getStringArrayStringMapFromProperty(String sourceName, + String propertyName, + InstanceProperties properties, + String methodName); + + + /** + * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. + * If the property is found, it is removed from the InstanceProperties structure. + * If the property is not a map property then a logic exception is thrown. + * + * @param sourceName source of call + * @param propertyName name of requested map property + * @param properties values of the property + * @param methodName method of caller + * @return map property value or null + */ + Map> removeStringArrayStringMapFromProperty(String sourceName, + String propertyName, + InstanceProperties properties, + String methodName); + + /** * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. * If the property is found, it is removed from the InstanceProperties structure. @@ -682,6 +715,24 @@ InstanceProperties addIntMapPropertyToInstance(String sourceName, String methodName); + /** + * If the supplied map property is not null, add it to an instance properties object. The supplied map is stored as a single + * property in the instances properties. If the instance properties object + * supplied is null, a new instance properties object is created. + * + * @param sourceName name of caller + * @param properties properties object to add property to, may be null. + * @param propertyName name of property + * @param mapValues contents of the map + * @param methodName calling method name + * @return instance properties object. + */ + InstanceProperties addStringArrayStringMapPropertyToInstance(String sourceName, + InstanceProperties properties, + String propertyName, + Map> mapValues, + String methodName); + /** * Add the supplied property map to an instance properties object. Each of the entries in the map is added diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesUtilities.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesUtilities.java index 04bebc240be..2a4b9f1109a 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesUtilities.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/utilities/OMRSRepositoryPropertiesUtilities.java @@ -716,6 +716,97 @@ public Map removeIntegerMapFromProperty(String sour } + + /** + * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. + * + * @param sourceName source of call + * @param propertyName name of requested map property + * @param properties values of the property + * @param methodName method of caller + * @return map property value or null + */ + @Override + public Map> getStringArrayStringMapFromProperty(String sourceName, + String propertyName, + InstanceProperties properties, + String methodName) + { + final String thisMethodName = "getStringArrayStringMapFromProperty"; + + Map mapFromProperty = this.getMapFromProperty(sourceName, propertyName, properties, methodName); + + if (mapFromProperty != null) + { + Map> stringArrayMap = new HashMap<>(); + + for (String mapPropertyName : mapFromProperty.keySet()) + { + Object actualPropertyValue = mapFromProperty.get(mapPropertyName); + + if (actualPropertyValue instanceof HashMap) + { + /* + * There are values to extract + */ + HashMap propertyValue = (HashMap) actualPropertyValue; + List unpackedValue = new ArrayList<>(); + + for (Object value : propertyValue.values()) + { + unpackedValue.add(value.toString()); + } + log.debug(thisMethodName + " found that array property " + propertyName + " has elements: " + unpackedValue); + + stringArrayMap.put(mapPropertyName, unpackedValue); + } + } + + if (! stringArrayMap.isEmpty()) + { + return stringArrayMap; + } + } + + return null; + } + + + /** + * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. + * If the property is found, it is removed from the InstanceProperties structure. + * If the property is not a map property then a logic exception is thrown. + * + * @param sourceName source of call + * @param propertyName name of requested map property + * @param properties values of the property + * @param methodName method of caller + * @return map property value or null + */ + @Override + public Map> removeStringArrayStringMapFromProperty(String sourceName, + String propertyName, + InstanceProperties properties, + String methodName) + { + Map> retrievedProperty = null; + + if (properties != null) + { + retrievedProperty = this.getStringArrayStringMapFromProperty(sourceName, propertyName, properties, methodName); + + if (retrievedProperty != null) + { + this.removeProperty(propertyName, properties); + log.debug("Properties left: " + properties); + } + } + + log.debug("Retrieved " + propertyName + " property: " + retrievedProperty); + return retrievedProperty; + } + + /** * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. * @@ -762,6 +853,7 @@ public Map getMapFromProperty(String sourceName, } + /** * Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. * If the property is found, it is removed from the InstanceProperties structure. @@ -1980,8 +2072,8 @@ public InstanceProperties addIntMapPropertyToInstance(String sourc mapPropertyValue.setHeaderVersion(InstancePropertyValue.CURRENT_INSTANCE_PROPERTY_VALUE_HEADER_VERSION); mapPropertyValue.setMapValues(mapInstanceProperties); - mapPropertyValue.setTypeGUID(longMapTypeGUID); - mapPropertyValue.setTypeName(longMapTypeName); + mapPropertyValue.setTypeGUID(intMapTypeGUID); + mapPropertyValue.setTypeName(intMapTypeName); resultingProperties.setProperty(propertyName, mapPropertyValue); log.debug("Returning instanceProperty: " + resultingProperties); @@ -1996,6 +2088,96 @@ public InstanceProperties addIntMapPropertyToInstance(String sourc } + /** + * If the supplied map property is not null, add it to an instance properties object. The supplied map is stored as a single + * property in the instances properties. If the instance properties object + * supplied is null, a new instance properties object is created. + * + * @param sourceName name of caller + * @param properties properties object to add property to, may be null. + * @param propertyName name of property + * @param mapValues contents of the map + * @param methodName calling method name + * @return instance properties object. + */ + @Override + public InstanceProperties addStringArrayStringMapPropertyToInstance(String sourceName, + InstanceProperties properties, + String propertyName, + Map> mapValues, + String methodName) + { + if (mapValues != null) + { + log.debug("Adding property " + propertyName + " for " + methodName); + + if (! mapValues.isEmpty()) + { + InstanceProperties resultingInstanceProperties; + + if (properties == null) + { + resultingInstanceProperties = new InstanceProperties(); + resultingInstanceProperties.setHeaderVersion(InstanceProperties.CURRENT_INSTANCE_PROPERTIES_HEADER_VERSION); + } + else + { + resultingInstanceProperties = properties; + } + + /* + * The values of a map property are stored as an embedded InstanceProperties object. + */ + InstanceProperties mapInstanceProperties = new InstanceProperties(); + + for (String mapKey : mapValues.keySet()) + { + List mapEntry = mapValues.get(mapKey); + ArrayPropertyValue arrayPropertyValue = new ArrayPropertyValue(); + + arrayPropertyValue.setHeaderVersion(InstancePropertyValue.CURRENT_INSTANCE_PROPERTY_VALUE_HEADER_VERSION); + arrayPropertyValue.setTypeGUID(stringArrayTypeGUID); + arrayPropertyValue.setTypeName(stringArrayTypeName); + arrayPropertyValue.setArrayCount(mapEntry.size()); + + int index = 0; + for (String arrayValue : mapEntry) + { + PrimitivePropertyValue primitivePropertyValue = new PrimitivePropertyValue(); + + primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); + primitivePropertyValue.setPrimitiveValue(arrayValue); + + arrayPropertyValue.setArrayValue(index, primitivePropertyValue); + index++; + } + + mapInstanceProperties.setProperty(mapKey, arrayPropertyValue); + } + + /* + * If there was content in the map then the resulting InstanceProperties are added as + * a property to the resulting properties. + */ + MapPropertyValue mapPropertyValue = new MapPropertyValue(); + + mapPropertyValue.setHeaderVersion(InstancePropertyValue.CURRENT_INSTANCE_PROPERTY_VALUE_HEADER_VERSION); + mapPropertyValue.setMapValues(mapInstanceProperties); + mapPropertyValue.setTypeGUID(objectMapTypeGUID); + mapPropertyValue.setTypeName(objectMapTypeName); + resultingInstanceProperties.setProperty(propertyName, mapPropertyValue); + + log.debug("Returning instanceProperty: " + resultingInstanceProperties); + + return resultingInstanceProperties; + } + } + + log.debug("Null property"); + return properties; + } + + /** * Add the supplied property map to an instance properties object. Each of the entries in the map is added * as a separate property in instance properties. If the instance properties object diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java index d41ce3cd8f3..7a82ff49156 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java @@ -5,6 +5,7 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollectionBase; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; @@ -64,7 +65,7 @@ class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollectionBase /** - * Constructor ensures the metadata collection is linked to its connector and knows its metadata collection Id. + * Constructor ensures the metadata collection is linked to its connector and knows its metadata collection id. * * @param enterpriseParentConnector connector that this metadata collection supports. The connector has the information * to call the metadata repository. @@ -72,19 +73,18 @@ class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollectionBase * @param repositoryHelper class used to build type definitions and instances. * @param repositoryValidator class used to validate type definitions and instances. * @param metadataCollectionId unique Identifier of the enterprise metadata collection Id. - * @param localMetadataCollectionId unique Identifier of the local repository's metadata collection Id (will be null - * if no local repository. + * @param localMetadataCollectionId unique Identifier of the local repository's metadata collection id (will be null if no local repository). */ EnterpriseOMRSMetadataCollection(EnterpriseOMRSRepositoryConnector enterpriseParentConnector, String repositoryName, - OMRSRepositoryHelper repositoryHelper, - OMRSRepositoryValidator repositoryValidator, + OMRSRepositoryHelper repositoryHelper, + OMRSRepositoryValidator repositoryValidator, String metadataCollectionId, String localMetadataCollectionId, AuditLog auditLog) { /* - * The metadata collection Id is the unique identifier for the metadata collection. It is managed by the super class. + * The metadata collection id is the unique identifier for the metadata collection. It is managed by the super class. */ super(enterpriseParentConnector, repositoryName, repositoryHelper, repositoryValidator, metadataCollectionId); @@ -315,9 +315,9 @@ public List findTypeDefsByProperty(String userId, * @param standard name of the standard null means any. * @param organization name of the organization null means any. * @param identifier identifier of the element in the standard null means any. - * @return TypeDefs list each entry in the list contains a typedef. This is is a structure + * @return TypeDefs list each entry in the list contains a typedef. This is a structure * describing the TypeDef's category and properties. - * @throws InvalidParameterException all attributes of the external Id are null. + * @throws InvalidParameterException all attributes of the external id are null. * @throws RepositoryErrorException there is a problem communicating with the metadata repository. * @throws UserNotAuthorizedException the userId is not permitted to perform this operation. */ @@ -355,7 +355,7 @@ public List findTypesByExternalID(String userId, * * @param userId unique identifier for requesting user. * @param searchCriteria String search criteria. - * @return TypeDefs list each entry in the list contains a typedef. This is is a structure + * @return TypeDefs list each entry in the list contains a typedef. This is a structure * describing the TypeDef's category and properties. * @throws InvalidParameterException the searchCriteria is null. * @throws RepositoryErrorException there is a problem communicating with the metadata repository. @@ -393,7 +393,7 @@ public List searchForTypeDefs(String userId, * Return the TypeDef identified by the GUID. * * @param userId unique identifier for requesting user. - * @param guid String unique Id of the TypeDef + * @param guid String unique id of the TypeDef * @return TypeDef structure describing its category and properties. * @throws InvalidParameterException the guid is null. * @throws RepositoryErrorException there is a problem communicating with the metadata repository where @@ -1079,6 +1079,81 @@ public EntityDetail getEntityDetail(String userId, } + /** + * Return all historical versions of an entity within the bounds of the provided timestamps. To retrieve all historical + * versions of an entity, set both the 'fromTime' and 'toTime' to null. + * + * @param userId unique identifier for requesting user. + * @param guid String unique identifier for the entity. + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startFromElement the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param sequencingOrder Enum defining how the results should be ordered. + * @return {@code List} of each historical version of the entity detail within the bounds, and in the order requested. + * @throws InvalidParameterException the guid or date is null or fromTime is after the toTime + * @throws RepositoryErrorException there is a problem communicating with the metadata repository where + * the metadata collection is stored. + * @throws EntityNotKnownException the requested entity instance is not known in the metadata collection at the time requested. + * @throws EntityProxyOnlyException the requested entity instance is only a proxy in the metadata collection. + * @throws FunctionNotSupportedException the repository does not support history. + * @throws UserNotAuthorizedException the userId is not permitted to perform this operation. + */ + @Override + public List getEntityDetailHistory(String userId, + String guid, + Date fromTime, + Date toTime, + int startFromElement, + int pageSize, + HistorySequencingOrder sequencingOrder) throws InvalidParameterException, + RepositoryErrorException, + EntityNotKnownException, + EntityProxyOnlyException, + FunctionNotSupportedException, + UserNotAuthorizedException + { + final String methodName = "getEntityDetailHistory"; + + /* + * Validate parameters + */ + this.getInstanceHistoryParameterValidation(userId, guid, fromTime, toTime, methodName); + + /* + * Validation complete, ok to continue with request + * + * The list of cohort connectors are retrieved for each request to ensure that any changes in + * the shape of the cohort are reflected immediately. + */ + List cohortConnectors = enterpriseParentConnector.getCohortConnectors(methodName); + + FederationControl federationControl = new ParallelFederationControl(userId, cohortConnectors, auditLog, methodName); + GetEntityDetailHistoryExecutor executor = new GetEntityDetailHistoryExecutor(userId, + guid, + fromTime, + toTime, + startFromElement, + pageSize, + sequencingOrder, + localMetadataCollectionId, + auditLog, + repositoryValidator, + methodName); + + /* + * Ready to process the request. Create requests occur in the first repository that accepts the call. + * Some repositories may produce exceptions. These exceptions are saved and will be returned if + * there are no positive results from any repository. + */ + federationControl.executeCommand(executor); + + return executor.getHistoryResults(enterpriseParentConnector, this); + } + + /** * Return the relationships for a specific entity. * @@ -1409,7 +1484,7 @@ public List findEntities(String userId, * * @param userId unique identifier for requesting user. * @param entityTypeGUID unique identifier for the type of entity requested. Null means any type of entity - * (but could be slow so not recommended. + * (but could be slow so not recommended). * @param classificationName name of the classification, note a null is not valid. * @param matchClassificationProperties list of classification properties used to narrow the search (where any String * property's value should be defined as a Java regular expression, even if it @@ -2673,7 +2748,7 @@ public EntityDetail addEntity(String userId, /** * Save a new entity that is sourced from an external technology. The external * technology is identified by a GUID and a name. These can be recorded in a - * Software Server Capability (guid and qualifiedName respectively. + * Software Capability (guid and qualifiedName respectively). * The new entity is assigned a new GUID and put * in the requested state. The new entity is returned. * @@ -2926,7 +3001,7 @@ public EntityDetail undoEntityUpdate(String userId, /** - * Delete an entity. The entity is soft deleted. This means it is still in the graph but it is no longer returned + * Delete an entity. The entity is soft-deleted. This means it is still in the graph, but it is no longer returned * on queries. All homed relationships to the entity are also soft-deleted and will no longer be usable, while any * reference copy relationships to the entity will be purged (and will no longer be accessible in this repository). * To completely eliminate the entity from the graph requires a call to the purgeEntity() method after the delete call. @@ -3786,7 +3861,7 @@ public Relationship addRelationship(String userId, /** * Save a new relationship that is sourced from an external technology. The external * technology is identified by a GUID and a name. These can be recorded in a - * Software Server Capability (guid and qualifiedName respectively. + * Software Server Capability (guid and qualifiedName respectively). * The new relationship is assigned a new GUID and put * in the requested state. The new relationship is returned. * @@ -4031,7 +4106,7 @@ public Relationship undoRelationshipUpdate(String userId, /** * Delete a specific relationship. This is a soft-delete which means the relationship's status is updated to - * DELETED and it is no longer available for queries. To remove the relationship permanently from the + * DELETED, and it is no longer available for queries. To remove the relationship permanently from the * metadata collection, use purgeRelationship(). * * @param userId unique identifier for requesting user. @@ -4249,7 +4324,7 @@ public EntityDetail reIdentifyEntity(String userId, /** - * Change the type of an existing entity. Typically this action is taken to move an entity's + * Change an existing entity's type. Typically, this action is taken to move an entity's * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be * added.) However, the type can be changed to any compatible type and the properties adjusted. * @@ -4335,7 +4410,7 @@ public Relationship reIdentifyRelationship(String userId, /** - * Change the type of an existing relationship. Typically this action is taken to move a relationship's + * Change an existing relationship's type. Typically, this action is taken to move a relationship's * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be * added.) However, the type can be changed to any compatible type. * @@ -4487,7 +4562,7 @@ public void deleteEntityReferenceCopy(String userId, * * This method is called when a remote repository calls the variant of purgeEntity that * passes the EntityDetail object. This is typically used if purge is called without a previous soft-delete. - * However it may also be used to purge after a soft-delete. + * However, it may also be used to purge after a soft-delete. * * @param userId unique identifier for requesting server. * @param entity details of the entity to purge. @@ -4656,7 +4731,7 @@ public void deleteRelationshipReferenceCopy(String userId, /** * This method is called when a remote repository calls the variant of purgeRelationship that * passes the relationship object. This is typically used if purge is called without a previous soft-delete. - * However it may also be used to purge after a soft-delete. + * However, it may also be used to purge after a soft-delete. * * Remove the reference copy of the relationship from the local repository. This method can be used to * remove reference copies from the local cohort, repositories that have left the cohort, @@ -4874,7 +4949,7 @@ private void validateMetadataCollection(OMRSMetadataCollection cohortMetadataCol if (cohortMetadataCollection == null) { /* - * A problem in the set up of the metadata collection list. Repository connectors implemented + * A problem in the set-up of the metadata collection list. Repository connectors implemented * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something * else has gone wrong. */ diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitiesAccumulator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitiesAccumulator.java index cc4d5c649f2..2f6d7a0c0c8 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitiesAccumulator.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitiesAccumulator.java @@ -26,9 +26,9 @@ public class EntitiesAccumulator extends QueryInstanceAccumulatorBase /* * Map of entityGUID to entity detail retrieved from the repositories */ - private volatile Map accumulatedEntities = new HashMap<>(); - private volatile Map> accumulatedClassifications = new HashMap<>(); - private volatile Map> accumulatedEntitySources = new HashMap<>(); + private final Map accumulatedEntities = new HashMap<>(); + private final Map> accumulatedClassifications = new HashMap<>(); + private final Map> accumulatedEntitySources = new HashMap<>(); /** diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityHistoryAccumulator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityHistoryAccumulator.java new file mode 100644 index 00000000000..b7d0b3839f1 --- /dev/null +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityHistoryAccumulator.java @@ -0,0 +1,334 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.accumulators; + + +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryValidator; +import org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.EnterpriseOMRSRepositoryConnector; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * EntityHistoryAccumulator accumulates and validates historical versions of entities received from a collection of open metadata + * repositories. It removes duplicates from the list but preserves one instance of each version. + * + * This class may be called simultaneously from different threads, so it must be thread-safe. + */ +public class EntityHistoryAccumulator extends EntitiesAccumulator +{ + /* + * Map of version to entity detail retrieved from the repositories + */ + private final Map accumulatedEntities = new HashMap<>(); + private final Map> accumulatedClassifications = new HashMap<>(); + private final Map> accumulatedEntitySources = new HashMap<>(); + + private String entityGUID = null; + + + /** + * Construct an entity accumulator. Its base class manages the common variables needed to + * control the execution of requests across all members of the cohort(s). + * + * @param localMetadataCollectionId collection id of local repository - null means no local repository + * @param auditLog audit log provides destination for log messages + * @param repositoryValidator validator provides common validation routines + */ + public EntityHistoryAccumulator(String localMetadataCollectionId, + AuditLog auditLog, + OMRSRepositoryValidator repositoryValidator) + { + super(localMetadataCollectionId, auditLog, repositoryValidator); + } + + + /** + * Provide an entity received from an open metadata repository. + * + * @param incomingEntity entity returned from an open metadata repository + * @param metadataCollectionId unique identifier for the collection of metadata stored in this repository + * This is used for error reporting. + */ + private void addEntity(EntityDetail incomingEntity, + String metadataCollectionId) + { + if ((incomingEntity != null) && (incomingEntity.getGUID() != null) && (metadataCollectionId != null)) + { + entityGUID = incomingEntity.getGUID(); + + /* + * Remember that this metadata collection has already returned this entity. + */ + List contributingMetadataCollections = accumulatedEntitySources.get(entityGUID); + + if (contributingMetadataCollections == null) + { + contributingMetadataCollections = new ArrayList<>(); + } + + contributingMetadataCollections.add(metadataCollectionId); + + accumulatedEntitySources.put(entityGUID, contributingMetadataCollections); + + accumulatedEntities.put(incomingEntity.getVersion(), incomingEntity); + + if (metadataCollectionId.equals(localMetadataCollectionId)) + { + super.captureLocalInstance(entityGUID); + } + + /* + * Now consider the classifications. Each received entity may have a different set of classifications attached and + * the enterprise connector should create an accumulated list of the best ones. + */ + this.saveClassifications(entityGUID, incomingEntity.getClassifications()); + } + } + + + /** + * Add a list of entities to the accumulator. This method is included to save the executors from coding this + * loop to process each entity. + * + * @param entities list of retrieved entities + * @param metadataCollectionId source metadata collection + */ + @Override + public synchronized void addEntities(List entities, + String metadataCollectionId) + { + if (entities != null) + { + for (EntityDetail entity : entities) + { + entityGUID = entity.getGUID(); + + this.addEntity(entity, metadataCollectionId); + } + + /* + * Record that this repository has returned results from the request. + */ + super.setResultsReturned(metadataCollectionId, entities.size()); + } + else + { + /* + * Even though results were not found it was still a successful request. + */ + super.setResultsReturned(metadataCollectionId, 0); + } + } + + + /** + * Add a list of classifications to the accumulator. These are extracted from the retrieved entities, or they are separately + * retrieved from metadata collections that only have an entity proxy with + * classifications connected to it that are uniquely stored in the metadata collection. + * + * @param entityGUID unique identifier + * @param incomingClassifications list of retrieved classifications + */ + @Override + public synchronized void saveClassifications(String entityGUID, + List incomingClassifications) + { + + /* + * Each received entity may have a different set of classifications attached and + * the enterprise connector should create an accumulated list of the best ones. + */ + List currentSavedClassifications = accumulatedClassifications.get(entityGUID); + + if (currentSavedClassifications == null) + { + /* + * No classifications currently saved for this entity + */ + if (incomingClassifications != null) + { + accumulatedClassifications.put(entityGUID, incomingClassifications); + } + } + else if (incomingClassifications != null) + { + /* + * Need to merge the two lists + */ + Map entityClassificationsMap = new HashMap<>(); + + /* + * Add the current classifications to the map. + */ + for (Classification existingClassification : currentSavedClassifications) + { + if (existingClassification != null) + { + entityClassificationsMap.put(existingClassification.getName(), existingClassification); + } + } + + /* + * Add the incoming classifications if they are a later version. + */ + for (Classification newClassification : incomingClassifications) + { + if (newClassification != null) + { + Classification existingClassification = entityClassificationsMap.get(newClassification.getName()); + + /* + * Ignore older versions of the classification + */ + if ((existingClassification == null) || (existingClassification.getVersion() < newClassification.getVersion())) + { + entityClassificationsMap.put(newClassification.getName(), newClassification); + } + } + } + + /* + * Save the merged list. + */ + if (! entityClassificationsMap.isEmpty()) + { + accumulatedClassifications.put(entityGUID, new ArrayList<>(entityClassificationsMap.values())); + } + } + } + + + /** + * Return the list of metadata collection Ids for the metadata collections that retrieved this entity. + * + * @param entityGUID unique identifier for entity of interest + * @return null or list of metadata collection ids + */ + @Override + public List getContributingMetadataCollections(String entityGUID) + { + return accumulatedEntitySources.get(entityGUID); + } + + + /** + * Return the list of GUIDs for the entities returned from the query. + * + * @return null or list of GUIDs + */ + @Override + public List getResultsForAugmentation() + { + if ((! accumulatedEntities.isEmpty() && (entityGUID != null))) + { + List guids = new ArrayList<>(); + + guids.add(entityGUID); + + return guids; + } + + return null; + } + + + /** + * Extract the results - this will be a unique list of entities selected from the instances + * supplied to this accumulator. It should be called once all the executors have completed processing + * their request(s). + * + * @param repositoryConnector enterprise connector + * @param metadataCollection enterprise metadata collection + * @return list of entities + */ + @Override + public synchronized List getResults(EnterpriseOMRSRepositoryConnector repositoryConnector, + OMRSMetadataCollection metadataCollection) + { + if (accumulatedEntities.isEmpty()) + { + return null; + } + else + { + this.makeRefreshRecommendations(repositoryConnector); + + List results = new ArrayList<>(); + + if (metadataCollection != null) + { + for (EntityDetail accumulatedEntity : accumulatedEntities.values()) + { + if (accumulatedEntity != null) + { + EntityDetail resultEntity = new EntityDetail(accumulatedEntity); + + resultEntity.setClassifications(accumulatedClassifications.get(accumulatedEntity.getGUID())); + + results.add(resultEntity); + } + } + } + + if (results.isEmpty()) + { + return null; + } + else + { + return results; + } + } + } + + + /** + * Return the list of entities that where retrieved from other repositories and not stored in the local repository. + * The local repository may use this list to send out refresh requests on the OMRS Topic. If the rules allow, and + * the remote repository response with a refresh response, this entity could be replicated into the local + * repository. + * + * The value of this processing is that the entity is of interest to the local users so having a local copy could + * reduce the access time for the entity. + * + * This call should be made once all processing has stopped. + * + * @param repositoryConnector enterprise connector + */ + private void makeRefreshRecommendations(EnterpriseOMRSRepositoryConnector repositoryConnector) + { + /* + * Either no local repository or nothing accumulated so nothing to return + */ + if ((localMetadataCollectionId == null) || (accumulatedEntities.isEmpty())) + { + return; + } + + /* + * Ignore all entities that came from the local repository + */ + for (EntityDetail accumulatedEntity : accumulatedEntities.values()) + { + if (accumulatedEntity != null) + { + String entityGUID = accumulatedEntity.getGUID(); + + if (entityGUID != null) + { + if (super.notLocal(entityGUID)) + { + repositoryConnector.requestRefreshOfEntity(accumulatedEntity); + } + } + } + } + } +} diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/QueryAccumulatorBase.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/QueryAccumulatorBase.java index 98a818b2639..b132f952409 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/QueryAccumulatorBase.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/QueryAccumulatorBase.java @@ -33,7 +33,7 @@ public class QueryAccumulatorBase extends ExceptionAccumulatorBase * @param repositoryValidator validator provides common validation routines */ QueryAccumulatorBase(String localMetadataCollectionId, - AuditLog auditLog, + AuditLog auditLog, OMRSRepositoryValidator repositoryValidator) { super(auditLog); @@ -134,7 +134,18 @@ public synchronized void captureException(String metadataCollec entityNotKnownException = exception; } - + /** + * Save the supplied exception. + * + * @param metadataCollectionId unique identifier for metadata collection this issued this exception + * @param exception exception from remote call + */ + public synchronized void captureException(String metadataCollectionId, + EntityProxyOnlyException exception) + { + setRequestReturned(metadataCollectionId, 0); + entityProxyOnlyException = exception; + } /** * Save the supplied exception. diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailHistoryExecutor.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailHistoryExecutor.java new file mode 100644 index 00000000000..8143c753d24 --- /dev/null +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailHistoryExecutor.java @@ -0,0 +1,250 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.executors; + +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.HistorySequencingOrder; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryValidator; +import org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.EnterpriseOMRSRepositoryConnector; +import org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.accumulators.EntitiesAccumulator; +import org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.accumulators.EntityHistoryAccumulator; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityProxyOnlyException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.FunctionNotSupportedException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.PagingErrorException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.PropertyErrorException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException; + +import java.util.Date; +import java.util.List; + +/** + * GetEntityDetailHistoryExecutor is the executor for the findEntitiesByPropertyValue request. + * This request can be issued in parallel - the call to each request potentially running in a different thread. + */ +public class GetEntityDetailHistoryExecutor extends PageableEntityRepositoryExecutorBase +{ + private final String guid; + private final Date fromTime; + private final Date toTime; + private final HistorySequencingOrder historySequencingOrder; + + private EntityHistoryAccumulator historyAccumulator; + + + /** + * Create the executor. The parameters provide the parameters for issuing the requests and + * combining the results. + * + * @param userId unique identifier for requesting user. + * @param guid String unique identifier for the entity. + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startFromElement the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param sequencingOrder Enum defining how the results should be ordered. + * @param localMetadataCollectionId unique identifier for the local repository - may be null if no local repository + * @param auditLog logging destination + * @param repositoryValidator validator for resulting relationships + * @param methodName calling method + */ + public GetEntityDetailHistoryExecutor(String userId, + String guid, + Date fromTime, + Date toTime, + int startFromElement, + int pageSize, + HistorySequencingOrder sequencingOrder, + String localMetadataCollectionId, + AuditLog auditLog, + OMRSRepositoryValidator repositoryValidator, + String methodName) + { + this(userId, + guid, + fromTime, + toTime, + startFromElement, + pageSize, + sequencingOrder, + new EntityHistoryAccumulator(localMetadataCollectionId, auditLog, repositoryValidator), + methodName); + } + + + /** + * Create the executor. The parameters provide the parameters for issuing the requests and + * combining the results. + * + * @param userId unique identifier for requesting user. + * @param guid String unique identifier for the entity. + * @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive) + * @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive) + * @param startFromElement the starting element number of the historical versions to return. This is used when retrieving + * versions beyond the first page of results. Zero means start from the first element. + * @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted + * return results size. + * @param sequencingOrder Enum defining how the results should be ordered. + * @param accumulator location for results and returned exceptions + * @param methodName calling method + */ + private GetEntityDetailHistoryExecutor(String userId, + String guid, + Date fromTime, + Date toTime, + int startFromElement, + int pageSize, + HistorySequencingOrder sequencingOrder, + EntityHistoryAccumulator accumulator, + String methodName) + { + super(userId, + null, + startFromElement, + null, + null, + null, + null, + pageSize, + accumulator, + methodName); + + this.guid = guid; + this.fromTime = fromTime; + this.toTime = toTime; + this.historySequencingOrder = sequencingOrder; + this.historyAccumulator = accumulator; + } + + + /** + * Return a clone of this executor with the same command parameters and accumulator instance. + * This is used when setting up the parallel execution of the work. Each clone executes + * the calls to a single open metadata repository. + * + * @return clone of this executor + */ + @Override + public CloneableRepositoryExecutor getClone() + { + return new GetEntityDetailHistoryExecutor(userId, + guid, + fromTime, + toTime, + startingElement, + pageSize, + historySequencingOrder, + historyAccumulator, + methodName); + } + + + /** + * Perform the required action for the supplied repository. + * + * @param metadataCollectionId unique identifier for the metadata collection for the repository + * @param metadataCollection metadata collection object for the repository + * @return boolean true means that the required results have been achieved + */ + @Override + + public boolean issueRequestToRepository(String metadataCollectionId, + OMRSMetadataCollection metadataCollection) + { + try + { + /* + * Issue the request + */ + List results = metadataCollection.getEntityDetailHistory(userId, + guid, + fromTime, + toTime, + startingElement, + pageSize, + historySequencingOrder); + + accumulator.addEntities(results, metadataCollectionId); + } + catch (InvalidParameterException error) + { + accumulator.captureException(metadataCollectionId, error); + } + catch (FunctionNotSupportedException error) + { + accumulator.captureException(metadataCollectionId, error); + } + catch (RepositoryErrorException error) + { + accumulator.captureException(metadataCollectionId, error); + } + catch (UserNotAuthorizedException error) + { + accumulator.captureException(metadataCollectionId, error); + } + catch (EntityNotKnownException error) + { + accumulator.captureException(metadataCollectionId, error); + } + catch (EntityProxyOnlyException error) + { + accumulator.captureException(metadataCollectionId, error); + } + catch (Exception error) + { + accumulator.captureGenericException(methodName, metadataCollectionId, error); + } + + return false; + } + + + /** + * Return the results or exception. + * + * @param repositoryConnector enterprise connector + * @param metadataCollection enterprise metadata collection + * + * @return a list of entities matching the supplied criteria; null means no matching entities in the metadata + * collection. + * @throws InvalidParameterException a parameter is invalid or null. + * @throws RepositoryErrorException there is a problem communicating with the metadata repository where + * the metadata collection is stored. + * @throws FunctionNotSupportedException the repository does not support the asOfTime parameter. + * @throws UserNotAuthorizedException the userId is not permitted to perform this operation. + * @throws EntityNotKnownException the requested entity instance is not known in the metadata collection at the time requested. + * @throws EntityProxyOnlyException the requested entity instance is only a proxy in the metadata collection. + */ + public List getHistoryResults(EnterpriseOMRSRepositoryConnector repositoryConnector, + OMRSMetadataCollection metadataCollection) throws InvalidParameterException, + RepositoryErrorException, + EntityNotKnownException, + EntityProxyOnlyException, + FunctionNotSupportedException, + UserNotAuthorizedException + { + if (accumulator.resultsReturned()) + { + return accumulator.getResults(repositoryConnector, metadataCollection); + } + + accumulator.throwCapturedUserNotAuthorizedException(); + accumulator.throwCapturedRepositoryErrorException(); + accumulator.throwCapturedEntityNotKnownException(); + accumulator.throwCapturedEntityProxyOnlyException(); + accumulator.throwCapturedGenericException(methodName); + accumulator.throwCapturedInvalidParameterException(); + accumulator.throwCapturedFunctionNotSupportedException(); + + return null; + } +} diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/PageableEntityRepositoryExecutorBase.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/PageableEntityRepositoryExecutorBase.java index c8b4bb07850..cd56dd15293 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/PageableEntityRepositoryExecutorBase.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/PageableEntityRepositoryExecutorBase.java @@ -58,7 +58,7 @@ public abstract class PageableEntityRepositoryExecutorBase extends PageableRepos String sequencingProperty, SequencingOrder sequencingOrder, int pageSize, - EntitiesAccumulator accumulator, + EntitiesAccumulator accumulator, String methodName) { super(userId, @@ -81,6 +81,7 @@ public abstract class PageableEntityRepositoryExecutorBase extends PageableRepos * * @return null (if no augmentation of results is required) or a list containing the guids of the results. */ + @Override public List getResultsForAugmentation() { return accumulator.getResultsForAugmentation(); @@ -94,6 +95,7 @@ public List getResultsForAugmentation() * @param metadataCollectionId identifier for the metadata collection * @param metadataCollection metadata collection object for the repository */ + @Override public void augmentResultFromRepository(String resultGUID, String metadataCollectionId, OMRSMetadataCollection metadataCollection) diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java index 8f38c8836a7..14edcfe32a8 100644 --- a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java @@ -8,15 +8,15 @@ import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchive; import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchiveType; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationPropagationRule; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EntityDef; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EnumDef; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EnumElementDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndCardinality; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefPatch; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefStatus; import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode; import org.odpi.openmetadata.repositoryservices.ffdc.exception.OMRSLogicErrorException; @@ -46,7 +46,7 @@ public class OpenMetadataTypesArchive private static final String archiveName = "Open Metadata Types"; private static final String archiveDescription = "Standard types for open metadata repositories."; private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; - private static final String archiveVersion = "4.0"; + private static final String archiveVersion = "4.1"; private static final String originatorName = "Egeria"; private static final String originatorLicense = "Apache-2.0"; private static final Date creationDate = new Date(1588261366992L); @@ -154,7 +154,7 @@ public OpenMetadataArchive getOpenMetadataArchive() */ public void getOriginalTypes() { - OpenMetadataTypesArchive3_15 previousTypes = new OpenMetadataTypesArchive3_15(archiveBuilder); + OpenMetadataTypesArchive4_0 previousTypes = new OpenMetadataTypesArchive4_0(archiveBuilder); /* * Pull the types from previous releases. @@ -164,1034 +164,40 @@ public void getOriginalTypes() /* * Add the type updates */ - update0021Collections(); - update0137ToDos(); - add0220DataFileCollectionDataSet(); - add0224TableDataSet(); - add0239DeployedReportType(); - update0385ControlledGlossaries(); - update0462GovernanceActionType(); - create0464DynamicIntegrationGroups(); - update0470IncidentClassifierSet(); - update0484AgreementActor(); - update0545ReferenceData(); - update0720InformationSupplyChains(); - addFormulaTypeAttribute(); + update0385ControlledGlossaryDevelopment(); + update0423SecurityAccessControl(); + update504ImplementationSnippets(); + update0710DigitalServices(); } - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void update0385ControlledGlossaries() - { - this.archiveBuilder.addTypeDefPatch(updateControlledGlossaryTermEntity()); - this.archiveBuilder.addRelationshipDef(addGlossaryTermEvolutionRelationship()); - } - - - private TypeDefPatch updateControlledGlossaryTermEntity() - { - /* - * Create the Patch - */ - final String typeName = "ControlledGlossaryTerm"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "userDefinedStatus"; - final String attribute1Description = "Extend or replace the valid instance statuses with additional statuses controlled through valid metadata values."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); - - /* - * Update the valid instance statuses - */ - ArrayList validInstanceStatusList = new ArrayList<>(); - - validInstanceStatusList.add(InstanceStatus.DRAFT); - validInstanceStatusList.add(InstanceStatus.PREPARED); - validInstanceStatusList.add(InstanceStatus.PROPOSED); - validInstanceStatusList.add(InstanceStatus.APPROVED); - validInstanceStatusList.add(InstanceStatus.REJECTED); - validInstanceStatusList.add(InstanceStatus.ACTIVE); - validInstanceStatusList.add(InstanceStatus.DEPRECATED); - validInstanceStatusList.add(InstanceStatus.OTHER); - validInstanceStatusList.add(InstanceStatus.DELETED); - - typeDefPatch.setValidInstanceStatusList(validInstanceStatusList); - - return typeDefPatch; - } - - - private RelationshipDef addGlossaryTermEvolutionRelationship() - { - final String guid = "b323c9cf-f254-49c7-a391-11222e9da70f"; - final String name = "GlossaryTermEvolution"; - final String description = "Links a live glossary term with a future version of ."; - final String descriptionGUID = null; - - final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - - RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - classificationPropagationRule); - - RelationshipEndDef relationshipEndDef; - - /* - * Set up end 1. - */ - final String end1EntityType = "ControlledGlossaryTerm"; - final String end1AttributeName = "glossaryTermUpdates"; - final String end1AttributeDescription = "A glossary term that contains proposed updates to the live glossary term."; - final String end1AttributeDescriptionGUID = null; - final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); - relationshipDef.setEndDef1(relationshipEndDef); - - - /* - * Set up end 2. - */ - final String end2EntityType = "GlossaryTerm"; - final String end2AttributeName = "liveGlossaryTerm"; - final String end2AttributeDescription = "The approved term that is in use."; - final String end2AttributeDescriptionGUID = null; - final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.AT_MOST_ONE; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); - relationshipDef.setEndDef2(relationshipEndDef); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "description"; - final String attribute1Description = "Short description of the update."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - - relationshipDef.setPropertiesDefinition(properties); - - return relationshipDef; - } - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void update0021Collections() - { - this.archiveBuilder.addEnumDef(getMembershipStatusEnum()); - this.archiveBuilder.addTypeDefPatch(updateCollectionMembershipRelationship()); - } - - private EnumDef getMembershipStatusEnum() - { - final String guid = "a3bdb2ac-c28e-4e5a-8ab7-76aa01038832"; - final String name = "MembershipStatus"; - final String description = "Defines the provenance and confidence that a member belongs in a collection."; - final String descriptionGUID = null; - - EnumDef enumDef = archiveHelper.getEmptyEnumDef(guid, name, description, descriptionGUID); - - ArrayList elementDefs = new ArrayList<>(); - EnumElementDef elementDef; - - final int element0Ordinal = 0; - final String element0Value = "Unknown"; - final String element0Description = "The membership origin is unknown."; - final String element0DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element0Ordinal, - element0Value, - element0Description, - element0DescriptionGUID); - elementDefs.add(elementDef); - enumDef.setDefaultValue(elementDef); - - final int element1Ordinal = 1; - final String element1Value = "Discovered"; - final String element1Description = "The membership was discovered by an automated process."; - final String element1DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element1Ordinal, - element1Value, - element1Description, - element1DescriptionGUID); - elementDefs.add(elementDef); - - final int element2Ordinal = 2; - final String element2Value = "Assigned"; - final String element2Description = "The membership was proposed by an expert curator."; - final String element2DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element2Ordinal, - element2Value, - element2Description, - element2DescriptionGUID); - elementDefs.add(elementDef); - - final int element3Ordinal = 3; - final String element3Value = "Imported"; - final String element3Description = "The membership was imported from another metadata system."; - final String element3DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element3Ordinal, - element3Value, - element3Description, - element3DescriptionGUID); - elementDefs.add(elementDef); - - final int element4Ordinal = 4; - final String element4Value = "Validated"; - final String element4Description = "The membership created by an automated process has been validated and approved by an expert curator."; - final String element4DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element4Ordinal, - element4Value, - element4Description, - element4DescriptionGUID); - elementDefs.add(elementDef); - - final int element5Ordinal = 5; - final String element5Value = "Deprecated"; - final String element5Description = "The membership should no longer be used."; - final String element5DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element5Ordinal, - element5Value, - element5Description, - element5DescriptionGUID); - elementDefs.add(elementDef); - - final int element6Ordinal = 6; - final String element6Value = "Obsolete"; - final String element6Description = "The membership must no longer be used."; - final String element6DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element6Ordinal, - element6Value, - element6Description, - element6DescriptionGUID); - elementDefs.add(elementDef); - - final int element99Ordinal = 99; - final String element99Value = "Other"; - final String element99Description = "Another membership status."; - final String element99DescriptionGUID = null; - - elementDef = archiveHelper.getEnumElementDef(element99Ordinal, - element99Value, - element99Description, - element99DescriptionGUID); - elementDefs.add(elementDef); - - enumDef.setElementDefs(elementDefs); - return enumDef; - } - - private TypeDefPatch updateCollectionMembershipRelationship() - { - /* - * Create the Patch - */ - final String typeName = "CollectionMembership"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "membershipRationale"; - final String attribute1Description = "Description of how the member is used, or why it is useful in this collection."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "expression"; - final String attribute2Description = "Expression describing the membership relationship."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "status"; - final String attribute3Description = "The status of the membership relationship."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "confidence"; - final String attribute4Description = "Level of confidence in the correctness of the membership relationship."; - final String attribute4DescriptionGUID = null; - final String attribute5Name = "steward"; - final String attribute5Description = "Person responsible for the membership relationship."; - final String attribute5DescriptionGUID = null; - final String attribute6Name = "source"; - final String attribute6Description = "Person, organization or automated process that created the membership relationship."; - final String attribute6DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getEnumTypeDefAttribute("MembershipStatus", - attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getIntTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute5Name, - attribute5Description, - attribute5DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute6Name, - attribute6Description, - attribute6DescriptionGUID); - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); - - return typeDefPatch; - } - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void update0137ToDos() - { - this.archiveBuilder.addTypeDefPatch(updateActionTargetRelationship()); - } - - private TypeDefPatch updateActionTargetRelationship() - { - /* - * Create the Patch - */ - final String typeName = "ActionTarget"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "status"; - final String attribute1Description = "The status of the work on this element."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "startDate"; - final String attribute2Description = "Date/time that work started on this element."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "completionDate"; - final String attribute3Description = "Date/time that work stopped on this element."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "actionTargetName"; - final String attribute4Description = "The name to identify the action target to the actor that processes it."; - final String attribute4DescriptionGUID = null; - final String attribute5Name = "completionMessage"; - final String attribute5Description = "Message to provide additional information on the results of acting on the target by the actor or the reasons for any failures."; - final String attribute5DescriptionGUID = null; - - property = archiveHelper.getEnumTypeDefAttribute("ToDoStatus", - attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute5Name, - attribute5Description, - attribute5DescriptionGUID); - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); - - return typeDefPatch; - } - - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void add0220DataFileCollectionDataSet() - { - this.archiveBuilder.addEntityDef(getDataFileCollectionDataSetEntity()); - - } - - private EntityDef getDataFileCollectionDataSetEntity() - { - final String guid = "962de053-ab51-40eb-b843-85b98013f5ca"; - final String name = "DataFileCollection"; - final String description = "A data set that consists of a collection files (do not need to be co-located)."; - final String descriptionGUID = null; - - final String superTypeName = "DataSet"; - - return archiveHelper.getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - } - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void add0224TableDataSet() - { - this.archiveBuilder.addEntityDef(getTableDataSetEntity()); - - } - - private EntityDef getTableDataSetEntity() - { - final String guid = "20c45531-5d2e-4eb6-9a47-035cb1067b82"; - final String name = "TableDataSet"; - final String description = "A tabular data source (typically a database table) that is an asset in its own right."; - final String descriptionGUID = null; - - final String superTypeName = "DataSet"; - - return archiveHelper.getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - } - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void add0239DeployedReportType() - { - this.archiveBuilder.addEntityDef(getDeployedReportTypeEntity()); - - } - - private EntityDef getDeployedReportTypeEntity() - { - final String guid = "ed53a480-e6d4-44f1-aac7-3fac60bbb00e"; - final String name = "DeployedReportType"; - final String description = "A template for generating report."; - final String descriptionGUID = null; - - final String superTypeName = "Asset"; - - EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "id"; - final String attribute1Description = "Id of report."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "author"; - final String attribute2Description = "Author of the report."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "url"; - final String attribute3Description = "url of the report."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "createdTime"; - final String attribute4Description = "Report create time."; - final String attribute4DescriptionGUID = null; - final String attribute5Name = "lastModifiedTime"; - final String attribute5Description = "Report last modified time."; - final String attribute5DescriptionGUID = null; - final String attribute6Name = "lastModifier"; - final String attribute6Description = "Report last modifier."; - final String attribute6DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute5Name, - attribute5Description, - attribute5DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute6Name, - attribute6Description, - attribute6DescriptionGUID); - properties.add(property); - - entityDef.setPropertiesDefinition(properties); - - return entityDef; - } - - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - - private void update0462GovernanceActionType() - { - this.archiveBuilder.addTypeDefPatch(update0462GovernanceActionTypeExecutorRelationship()); - } - - private TypeDefPatch update0462GovernanceActionTypeExecutorRelationship() - { - /* - * Create the Patch - */ - final String typeName = "GovernanceActionTypeExecutor"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "requestParameterFilter"; - final String attribute1Description = "Which requestParameters to remove before calling governance action."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "requestParameterMap"; - final String attribute2Description = "The request parameters to rename before calling the governance action. Map is from old name to new name."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "actionTargetFilter"; - final String attribute3Description = "Which actionTargets to remove before calling governance action."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "actionTargetMap"; - final String attribute4Description = "The action target to rename before calling the governance action. Map is from old name to new name."; - final String attribute4DescriptionGUID = null; - - property = archiveHelper.getArrayStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getMapStringStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getArrayStringTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getMapStringStringTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); - - return typeDefPatch; - } - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void create0464DynamicIntegrationGroups() - { - this.archiveBuilder.addEntityDef(addIntegrationGroupEntity()); - this.archiveBuilder.addEntityDef(addIntegrationConnectorEntity()); - this.archiveBuilder.addEntityDef(addIntegrationReportEntity()); - this.archiveBuilder.addRelationshipDef(addRegisteredIntegrationConnectorRelationship()); - this.archiveBuilder.addRelationshipDef(addCatalogTargetRelationship()); - this.archiveBuilder.addRelationshipDef(addRelatedIntegrationReportRelationship()); - } - - - private EntityDef addIntegrationGroupEntity() - { - final String guid = "4d7c43ec-983b-40e4-af78-6fb66c4f5136"; - final String name = "IntegrationGroup"; - final String description = "A collection of integration connectors to run together."; - final String descriptionGUID = null; - - final String superTypeName = "SoftwareServerCapability"; - - return archiveHelper.getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - } - - private EntityDef addIntegrationConnectorEntity() - { - final String guid = "759da11b-ebb6-4382-bdc9-72adc7c922db"; - final String name = "IntegrationConnector"; - final String description = "A definition to control the execution of an integration connector."; - final String descriptionGUID = null; - - final String superTypeName = "DeployedConnector"; - - EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "usesBlockingCalls"; - final String attribute1Description = "The integration connector needs to use blocking calls to a third party technology and so needs to" + - " run in its own thread."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getBooleanTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - - entityDef.setPropertiesDefinition(properties); - - return entityDef; - } - - private EntityDef addIntegrationReportEntity() - { - final String guid = "b8703d3f-8668-4e6a-bf26-27db1607220d"; - final String name = "IntegrationReport"; - final String description = "Details of the metadata changes made by the execution of the refresh() method by an integration connector."; - final String descriptionGUID = null; - - final String superTypeName = "OpenMetadataRoot"; - - EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "connectorName"; - final String attribute1Description = "Name of the integration connector for logging purposes."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "connectorId"; - final String attribute2Description = "Unique identifier of the integration connector deployment."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "serverName"; - final String attribute3Description = "Name of the integration daemon where the integration connector is/was running."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "refreshStartDate"; - final String attribute4Description = "Date/time when the refresh() call was made."; - final String attribute4DescriptionGUID = null; - final String attribute5Name = "refreshCompletionDate"; - final String attribute5Description = "Date/time when the integration connector returned from the refresh() call."; - final String attribute5DescriptionGUID = null; - final String attribute6Name = "createdElements"; - final String attribute6Description = "List of elements that were created."; - final String attribute6DescriptionGUID = null; - final String attribute7Name = "updatedElements"; - final String attribute7Description = "List of elements that were updated."; - final String attribute7DescriptionGUID = null; - final String attribute8Name = "deletedElements"; - final String attribute8Description = "List of elements that were deleted."; - final String attribute8DescriptionGUID = null; - final String attribute9Name = "additionalProperties"; - final String attribute9Description = "Additional properties of importance to the integration connector."; - final String attribute9DescriptionGUID = null; - - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute5Name, - attribute5Description, - attribute5DescriptionGUID); - properties.add(property); - property = archiveHelper.getArrayStringTypeDefAttribute(attribute6Name, - attribute6Description, - attribute6DescriptionGUID); - properties.add(property); - property = archiveHelper.getArrayStringTypeDefAttribute(attribute7Name, - attribute7Description, - attribute7DescriptionGUID); - properties.add(property); - property = archiveHelper.getArrayStringTypeDefAttribute(attribute8Name, - attribute8Description, - attribute8DescriptionGUID); - properties.add(property); - property = archiveHelper.getMapStringStringTypeDefAttribute(attribute9Name, - attribute9Description, - attribute9DescriptionGUID); - properties.add(property); - - entityDef.setPropertiesDefinition(properties); - - return entityDef; - } - - private RelationshipDef addRegisteredIntegrationConnectorRelationship() - { - final String guid = "7528bcd4-ae4c-47d0-a33f-4aeebbaa92c2"; - final String name = "RegisteredIntegrationConnector"; - final String description = "A link between an integration group and an integration connector that is part of the group."; - final String descriptionGUID = null; - - final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - - RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - classificationPropagationRule); - - RelationshipEndDef relationshipEndDef; - - /* - * Set up end 1. - */ - final String end1EntityType = "IntegrationGroup"; - final String end1AttributeName = "includedInIntegrationGroups"; - final String end1AttributeDescription = "An integration group that this integration connector is a member of."; - final String end1AttributeDescriptionGUID = null; - final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); - relationshipDef.setEndDef1(relationshipEndDef); - - - /* - * Set up end 2. - */ - final String end2EntityType = "IntegrationConnector"; - final String end2AttributeName = "registeredIntegrationConnectors"; - final String end2AttributeDescription = "An integration connector that should run as part of the integration group."; - final String end2AttributeDescriptionGUID = null; - final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); - relationshipDef.setEndDef2(relationshipEndDef); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "connectorName"; - final String attribute1Description = "Name of the connector for logging purposes."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "connectorUserId"; - final String attribute2Description = "UserId for the integration connector to use when working with open metadata. The default userId " + - "comes from the hosting server if this value is blank."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "metadataSourceQualifiedName"; - final String attribute3Description = "Qualified name of a software server capability that is the owner/home of the metadata catalogued " + - "by the integration connector."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "startDate"; - final String attribute4Description = "Earliest time that the connector can run."; - final String attribute4DescriptionGUID = null; - final String attribute5Name = "stopTime"; - final String attribute5Description = "Latest time that the connector can run."; - final String attribute5DescriptionGUID = null; - final String attribute6Name = "refreshTimeInterval"; - final String attribute6Description = "Describes how frequently the integration connector should run - in minutes."; - final String attribute6DescriptionGUID = null; - final String attribute7Name = "permittedSynchronization"; - final String attribute7Description = "Defines the permitted directions of flow of metadata updates between open metadata and a third party technology."; - final String attribute7DescriptionGUID = null; - final String attribute8Name = "generateIntegrationReport"; - final String attribute8Description = "Should the integration daemon create integration reports based on the integration connector's " + - "activity? (Default is true.)"; - final String attribute8DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - property = archiveHelper.getDateTypeDefAttribute(attribute5Name, - attribute5Description, - attribute5DescriptionGUID); - properties.add(property); - property = archiveHelper.getLongTypeDefAttribute(attribute6Name, - attribute6Description, - attribute6DescriptionGUID); - properties.add(property); - property = archiveHelper.getEnumTypeDefAttribute("PermittedSynchronization", - attribute7Name, - attribute7Description, - attribute7DescriptionGUID); - properties.add(property); - property = archiveHelper.getBooleanTypeDefAttribute(attribute8Name, - attribute8Description, - attribute8DescriptionGUID); - properties.add(property); - - relationshipDef.setPropertiesDefinition(properties); - - return relationshipDef; - } - - private RelationshipDef addCatalogTargetRelationship() - { - final String guid = "bc5a5eb1-881b-4055-aa2c-78f314282ac2"; - final String name = "CatalogTarget"; - final String description = "Identifies an element that an integration connector is to work with."; - final String descriptionGUID = null; - - final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - - RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - classificationPropagationRule); - - RelationshipEndDef relationshipEndDef; - - /* - * Set up end 1. - */ - final String end1EntityType = "IntegrationConnector"; - final String end1AttributeName = "cataloguedByConnectors"; - final String end1AttributeDescription = "An integration connector managing metadata synchronization."; - final String end1AttributeDescriptionGUID = null; - final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); - relationshipDef.setEndDef1(relationshipEndDef); - - - /* - * Set up end 2. - */ - final String end2EntityType = "OpenMetadataRoot"; - final String end2AttributeName = "catalogTargets"; - final String end2AttributeDescription = "An open metadata element that the integration connector is working on."; - final String end2AttributeDescriptionGUID = null; - final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); - relationshipDef.setEndDef2(relationshipEndDef); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "catalogTargetName"; - final String attribute1Description = "Symbolic name of the catalog target to help the integration connector to choose when to use it."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - - relationshipDef.setPropertiesDefinition(properties); - - return relationshipDef; - } - - - private RelationshipDef addRelatedIntegrationReportRelationship() - { - final String guid = "83d12156-f8f3-4b4b-b31b-18c140df9aa3"; - final String name = "RelatedIntegrationReport"; - final String description = "Links an integration report to the anchor entity it describes."; - final String descriptionGUID = null; - final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - - RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - classificationPropagationRule); - - RelationshipEndDef relationshipEndDef; - - /* - * Set up end 1. - */ - final String end1EntityType = "OpenMetadataRoot"; - final String end1AttributeName = "anchorSubject"; - final String end1AttributeDescription = "The anchor entity that the integration report describes."; - final String end1AttributeDescriptionGUID = null; - final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.AT_MOST_ONE; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); - relationshipDef.setEndDef1(relationshipEndDef); - - - /* - * Set up end 2. - */ - final String end2EntityType = "IntegrationReport"; - final String end2AttributeName = "integrationReports"; - final String end2AttributeDescription = "A description of the changes made to the anchor entity by an integration " + - "report."; - final String end2AttributeDescriptionGUID = null; - final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); - relationshipDef.setEndDef2(relationshipEndDef); - - return relationshipDef; - } /* * ------------------------------------------------------------------------------------------------------- */ - private void update0545ReferenceData() + + private void update0385ControlledGlossaryDevelopment() { - this.archiveBuilder.addTypeDefPatch(updateReferenceValueAssignment()); + this.archiveBuilder.addClassificationDef(getEditingGlossaryClassification()); } - - private TypeDefPatch updateReferenceValueAssignment() + private ClassificationDef getEditingGlossaryClassification() { - /* - * Create the Patch - */ - final String typeName = "ReferenceValueAssignment"; + final String guid = "173614ba-c582-4ecc-8fcc-cde5fb664548"; + final String name = "EditingGlossary"; + final String description = "A temporary glossary holding glossary content that is being edited."; + final String descriptionGUID = null; - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + final String linkedToEntity = "Glossary"; - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); + ClassificationDef classificationDef = archiveHelper.getClassificationDef(guid, + name, + null, + description, + descriptionGUID, + this.archiveBuilder.getEntityDef(linkedToEntity), + false); /* * Build the attributes @@ -1199,8 +205,8 @@ private TypeDefPatch updateReferenceValueAssignment() List properties = new ArrayList<>(); TypeDefAttribute property; - final String attribute1Name = "attributeName"; - final String attribute1Description = "The name of the attribute that the reference data assignment represents."; + final String attribute1Name = "description"; + final String attribute1Description = "Description of the updates."; final String attribute1DescriptionGUID = null; property = archiveHelper.getStringTypeDefAttribute(attribute1Name, @@ -1208,66 +214,33 @@ private TypeDefPatch updateReferenceValueAssignment() attribute1DescriptionGUID); properties.add(property); - typeDefPatch.setPropertyDefinitions(properties); + classificationDef.setPropertiesDefinition(properties); - return typeDefPatch; + return classificationDef; } + /* * ------------------------------------------------------------------------------------------------------- */ - private void addFormulaTypeAttribute() - { - this.archiveBuilder.addTypeDefPatch(updateDataSet()); - this.archiveBuilder.addTypeDefPatch(updateProcess()); - this.archiveBuilder.addTypeDefPatch(updateCalculatedValue()); - this.archiveBuilder.addTypeDefPatch(updateProcessCall()); - this.archiveBuilder.addTypeDefPatch(updateDataFlow()); - } - - private TypeDefPatch updateDataSet() + private void update0423SecurityAccessControl() { - /* - * Create the Patch - */ - final String typeName = "DataSet"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "formulaType"; - final String attribute1Description = "Format of the expression provided in the formula attribute."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); - - return typeDefPatch; + this.archiveBuilder.addTypeDefPatch(updateSecurityTagsClassification()); + this.archiveBuilder.addEntityDef(addSecurityAccessControlEntity()); + this.archiveBuilder.addRelationshipDef(addAssociatedGroupRelationship()); } - private TypeDefPatch updateProcess() + private TypeDefPatch updateSecurityTagsClassification() { /* * Create the Patch */ - final String typeName = "Process"; + final String typeName = "SecurityTags"; - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); typeDefPatch.setUpdatedBy(originatorName); typeDefPatch.setUpdateTime(creationDate); @@ -1278,13 +251,13 @@ private TypeDefPatch updateProcess() List properties = new ArrayList<>(); TypeDefAttribute property; - final String attribute1Name = "formulaType"; - final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1Name = "accessGroups"; + final String attribute1Description = "Map of access groups."; final String attribute1DescriptionGUID = null; - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); + property = archiveHelper.getMapStringObjectTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); properties.add(property); typeDefPatch.setPropertyDefinitions(properties); @@ -1293,49 +266,56 @@ private TypeDefPatch updateProcess() } - private TypeDefPatch updateCalculatedValue() + private RelationshipDef addAssociatedGroupRelationship() { - /* - * Create the Patch - */ - final String typeName = "CalculatedValue"; + final String guid = "e47a19d0-7e12-4cf7-9ad7-50856da7faa2"; + final String name = "AssociatedGroup"; + final String description = "Links a security access control to a security group."; + final String descriptionGUID = null; - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; /* - * Build the attributes + * Set up end 1. */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "formulaType"; - final String attribute1Description = "Format of the expression provided in the formula attribute."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); + final String end1EntityType = "SecurityAccessControl"; + final String end1AttributeName = "usedInAccessControls"; + final String end1AttributeDescription = "An access control definition that uses the security group."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; - typeDefPatch.setPropertyDefinitions(properties); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); - return typeDefPatch; - } - private TypeDefPatch updateProcessCall() - { /* - * Create the Patch + * Set up end 2. */ - final String typeName = "ProcessCall"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + final String end2EntityType = "SecurityGroup"; + final String end2AttributeName = "associatedSecurityGroups"; + final String end2AttributeDescription = "The security groups to use to validate access for the operation."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); /* * Build the attributes @@ -1343,8 +323,8 @@ private TypeDefPatch updateProcessCall() List properties = new ArrayList<>(); TypeDefAttribute property; - final String attribute1Name = "formulaType"; - final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1Name = "operationName"; + final String attribute1Description = "Name of the operation to that is controlled by the linked security group."; final String attribute1DescriptionGUID = null; property = archiveHelper.getStringTypeDefAttribute(attribute1Name, @@ -1352,42 +332,26 @@ private TypeDefPatch updateProcessCall() attribute1DescriptionGUID); properties.add(property); - typeDefPatch.setPropertyDefinitions(properties); + relationshipDef.setPropertiesDefinition(properties); - return typeDefPatch; + return relationshipDef; } - private TypeDefPatch updateDataFlow() + private EntityDef addSecurityAccessControlEntity() { - /* - * Create the Patch - */ - final String typeName = "DataFlow"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "formulaType"; - final String attribute1Description = "Format of the expression provided in the formula attribute."; - final String attribute1DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); + final String guid = "f53bd594-5f75-4cf9-9f77-f5c35396590e"; + final String name = "SecurityAccessControl"; + final String description = "A technical control that defines who has access to the attach element."; + final String descriptionGUID = null; - typeDefPatch.setPropertyDefinitions(properties); + final String superTypeName = "TechnicalControl"; - return typeDefPatch; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); } @@ -1395,84 +359,30 @@ private TypeDefPatch updateDataFlow() * ------------------------------------------------------------------------------------------------------- */ - private void update0470IncidentClassifierSet() + private void update504ImplementationSnippets() { - this.archiveBuilder.addTypeDefPatch(updateIncidentClassifierSetClassification()); + this.archiveBuilder.addTypeDefPatch(deprecateSchemaTypeSnippet()); + this.archiveBuilder.addRelationshipDef(getAssociatedSnippetRelationship()); } - private TypeDefPatch updateIncidentClassifierSetClassification() + private TypeDefPatch deprecateSchemaTypeSnippet() { - /* - * Create the Patch - */ - final String typeName = "IncidentClassifierSet"; + final String typeName = "SchemaTypeSnippet"; TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); typeDefPatch.setUpdatedBy(originatorName); typeDefPatch.setUpdateTime(creationDate); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "incidentClassifierCategory"; - final String attribute1Description = "The category of classifiers used to set the incidentClassifiers in IncidentReport."; - final String attribute1DescriptionGUID = null; - - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); - - return typeDefPatch; - } - - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void update0484AgreementActor() - { - this.archiveBuilder.addTypeDefPatch(updateAgreementActorRelationship()); - } - - private TypeDefPatch updateAgreementActorRelationship() - { - /* - * Create the Patch - */ - final String typeName = "AgreementActor"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setUpdateMultiLink(true); - typeDefPatch.setMultiLink(true); + typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); return typeDefPatch; } - /* - * ------------------------------------------------------------------------------------------------------- - */ - - private void update0720InformationSupplyChains() - { - this.archiveBuilder.addRelationshipDef(getInformationSupplyChainLinkRelationship()); - } - - private RelationshipDef getInformationSupplyChainLinkRelationship() + private RelationshipDef getAssociatedSnippetRelationship() { - final String guid = "207e5130-ab7c-4048-9249-a63a43c13d60"; - final String name = "InformationSupplyChainLink"; - final String description = "A link between two related information supply chain segments -or to their source or destination."; + final String guid = "6f89c320-22aa-4d99-9a97-442e8d214655"; + final String name = "AssociatedSnippet"; + final String description = "Link between an element such as a schema type or data class and an implementation snippet."; final String descriptionGUID = null; final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; @@ -1490,8 +400,8 @@ private RelationshipDef getInformationSupplyChainLinkRelationship() * Set up end 1. */ final String end1EntityType = "Referenceable"; - final String end1AttributeName = "supplyFrom"; - final String end1AttributeDescription = "Logical source of the information supply chain."; + final String end1AttributeName = "snippetRelevantForElements"; + final String end1AttributeDescription = "Element describing logical structure for data element."; final String end1AttributeDescriptionGUID = null; final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; @@ -1506,9 +416,9 @@ private RelationshipDef getInformationSupplyChainLinkRelationship() /* * Set up end 2. */ - final String end2EntityType = "Referenceable"; - final String end2AttributeName = "supplyTo"; - final String end2AttributeDescription = "Logical destination of an information supply chain."; + final String end2EntityType = "ImplementationSnippet"; + final String end2AttributeName = "implementationSnippetsForElement"; + final String end2AttributeDescription = "Template implementation of the element."; final String end2AttributeDescriptionGUID = null; final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; @@ -1519,29 +429,59 @@ private RelationshipDef getInformationSupplyChainLinkRelationship() end2Cardinality); relationshipDef.setEndDef2(relationshipEndDef); + return relationshipDef; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0710DigitalServices() + { + this.archiveBuilder.addTypeDefPatch(updateDigitalProductClassification()); + } + + + private TypeDefPatch updateDigitalProductClassification() + { /* - * Build the attributes + * Create the Patch */ - List properties = new ArrayList<>(); - TypeDefAttribute property; + final String typeName = "DigitalProduct"; - final String attribute1Name = "description"; - final String attribute1Description = "Description of the relationship."; - final String attribute1DescriptionGUID = null; + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); - relationshipDef.setPropertiesDefinition(properties); - return relationshipDef; + /* + * Update the valid instance statuses + */ + ArrayList validInstanceStatusList = new ArrayList<>(); + + validInstanceStatusList.add(InstanceStatus.DRAFT); + validInstanceStatusList.add(InstanceStatus.PREPARED); + validInstanceStatusList.add(InstanceStatus.PROPOSED); + validInstanceStatusList.add(InstanceStatus.APPROVED); + validInstanceStatusList.add(InstanceStatus.REJECTED); + validInstanceStatusList.add(InstanceStatus.APPROVED_CONCEPT); + validInstanceStatusList.add(InstanceStatus.UNDER_DEVELOPMENT); + validInstanceStatusList.add(InstanceStatus.DEVELOPMENT_COMPLETE); + validInstanceStatusList.add(InstanceStatus.APPROVED_FOR_DEPLOYMENT); + validInstanceStatusList.add(InstanceStatus.ACTIVE); + validInstanceStatusList.add(InstanceStatus.DISABLED); + validInstanceStatusList.add(InstanceStatus.DEPRECATED); + validInstanceStatusList.add(InstanceStatus.OTHER); + validInstanceStatusList.add(InstanceStatus.DELETED); + + typeDefPatch.setValidInstanceStatusList(validInstanceStatusList); + + return typeDefPatch; } /* * ------------------------------------------------------------------------------------------------------- */ - } diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive4_0.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive4_0.java new file mode 100644 index 00000000000..1c024b4e7dd --- /dev/null +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive4_0.java @@ -0,0 +1,1547 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.opentypes; + + +import org.odpi.openmetadata.repositoryservices.archiveutilities.OMRSArchiveBuilder; +import org.odpi.openmetadata.repositoryservices.archiveutilities.OMRSArchiveHelper; +import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchive; +import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchiveType; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationPropagationRule; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EntityDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EnumDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EnumElementDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndCardinality; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefPatch; +import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.OMRSLogicErrorException; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * OpenMetadataTypesArchive builds an open metadata archive containing all the standard open metadata types. + * These types have hardcoded dates and guids so that however many times this archive is rebuilt, it will + * produce the same content. + *

+ * Details of the open metadata types are documented on the wiki: + * The Open Metadata Type System + *

+ *

+ * There are 8 areas, each covering a different topic area of metadata. The module breaks down the process of creating + * the models into the areas and then the individual models to simplify the maintenance of this class + *

+ */ +public class OpenMetadataTypesArchive4_0 +{ + /* + * This is the header information for the archive. + */ + private static final String archiveGUID = "bce3b0a0-662a-4f87-b8dc-844078a11a6e"; + private static final String archiveName = "Open Metadata Types"; + private static final String archiveDescription = "Standard types for open metadata repositories."; + private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; + private static final String archiveVersion = "4.0"; + private static final String originatorName = "Egeria"; + private static final String originatorLicense = "Apache-2.0"; + private static final Date creationDate = new Date(1588261366992L); + + /* + * Specific values for initializing TypeDefs + */ + private static final long versionNumber = 1L; + private static final String versionName = "1.0"; + + + private final OMRSArchiveBuilder archiveBuilder; + private final OMRSArchiveHelper archiveHelper; + + /** + * Default constructor sets up the archive builder. This in turn sets up the header for the archive. + */ + public OpenMetadataTypesArchive4_0() + { + this.archiveBuilder = new OMRSArchiveBuilder(archiveGUID, + archiveName, + archiveDescription, + archiveType, + archiveVersion, + originatorName, + originatorLicense, + creationDate, + null); + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); + } + + + /** + * Chained constructor sets up the archive builder. This in turn sets up the header for the archive. + * + * @param archiveBuilder accumulator for types + */ + public OpenMetadataTypesArchive4_0(OMRSArchiveBuilder archiveBuilder) + { + this.archiveBuilder = archiveBuilder; + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); + } + + + /** + * Return the unique identifier for this archive. + * + * @return String guid + */ + public String getArchiveGUID() + { + return archiveGUID; + } + + + /** + * Returns the open metadata type archive containing all the standard open metadata types. + * + * @return populated open metadata archive object + */ + public OpenMetadataArchive getOpenMetadataArchive() + { + final String methodName = "getOpenMetadataArchive"; + + if (this.archiveBuilder != null) + { + /* + * Build the type archive. + */ + this.getOriginalTypes(); + + /* + * The completed archive is ready to be packaged up and returned + */ + return this.archiveBuilder.getOpenMetadataArchive(); + } + else + { + /* + * This is a logic error since it means the creation of the archive builder threw an exception + * in the constructor and so this object should not be used. + */ + throw new OMRSLogicErrorException(OMRSErrorCode.ARCHIVE_UNAVAILABLE.getMessageDefinition(), + this.getClass().getName(), + methodName); + } + } + + + /** + * Add the types from this archive to the archive builder supplied in the + * constructor. + */ + public void getOriginalTypes() + { + OpenMetadataTypesArchive3_15 previousTypes = new OpenMetadataTypesArchive3_15(archiveBuilder); + + /* + * Pull the types from previous releases. + */ + previousTypes.getOriginalTypes(); + + /* + * Add the type updates + */ + update0021Collections(); + update0137ToDos(); + add0220DataFileCollectionDataSet(); + add0224TableDataSet(); + add0239DeployedReportType(); + update0385ControlledGlossaries(); + update0462GovernanceActionType(); + create0464DynamicIntegrationGroups(); + update0470IncidentClassifierSet(); + update0484AgreementActor(); + update0545ReferenceData(); + update0720InformationSupplyChains(); + addFormulaTypeAttribute(); + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0385ControlledGlossaries() + { + this.archiveBuilder.addTypeDefPatch(updateControlledGlossaryTermEntity()); + this.archiveBuilder.addRelationshipDef(addGlossaryTermEvolutionRelationship()); + } + + + private TypeDefPatch updateControlledGlossaryTermEntity() + { + /* + * Create the Patch + */ + final String typeName = "ControlledGlossaryTerm"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "userDefinedStatus"; + final String attribute1Description = "Extend or replace the valid instance statuses with additional statuses controlled through valid metadata values."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + /* + * Update the valid instance statuses + */ + ArrayList validInstanceStatusList = new ArrayList<>(); + + validInstanceStatusList.add(InstanceStatus.DRAFT); + validInstanceStatusList.add(InstanceStatus.PREPARED); + validInstanceStatusList.add(InstanceStatus.PROPOSED); + validInstanceStatusList.add(InstanceStatus.APPROVED); + validInstanceStatusList.add(InstanceStatus.REJECTED); + validInstanceStatusList.add(InstanceStatus.ACTIVE); + validInstanceStatusList.add(InstanceStatus.DEPRECATED); + validInstanceStatusList.add(InstanceStatus.OTHER); + validInstanceStatusList.add(InstanceStatus.DELETED); + + typeDefPatch.setValidInstanceStatusList(validInstanceStatusList); + + return typeDefPatch; + } + + + private RelationshipDef addGlossaryTermEvolutionRelationship() + { + final String guid = "b323c9cf-f254-49c7-a391-11222e9da70f"; + final String name = "GlossaryTermEvolution"; + final String description = "Links a live glossary term with a future version of the term."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "ControlledGlossaryTerm"; + final String end1AttributeName = "glossaryTermUpdates"; + final String end1AttributeDescription = "A glossary term that contains proposed updates to the live glossary term."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "GlossaryTerm"; + final String end2AttributeName = "liveGlossaryTerm"; + final String end2AttributeDescription = "The approved term that is in use."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.AT_MOST_ONE; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "description"; + final String attribute1Description = "Short description of the update."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0021Collections() + { + this.archiveBuilder.addEnumDef(getMembershipStatusEnum()); + this.archiveBuilder.addTypeDefPatch(updateCollectionMembershipRelationship()); + } + + private EnumDef getMembershipStatusEnum() + { + final String guid = "a3bdb2ac-c28e-4e5a-8ab7-76aa01038832"; + final String name = "MembershipStatus"; + final String description = "Defines the provenance and confidence that a member belongs in a collection."; + final String descriptionGUID = null; + + EnumDef enumDef = archiveHelper.getEmptyEnumDef(guid, name, description, descriptionGUID); + + ArrayList elementDefs = new ArrayList<>(); + EnumElementDef elementDef; + + final int element0Ordinal = 0; + final String element0Value = "Unknown"; + final String element0Description = "The membership origin is unknown."; + final String element0DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element0Ordinal, + element0Value, + element0Description, + element0DescriptionGUID); + elementDefs.add(elementDef); + enumDef.setDefaultValue(elementDef); + + final int element1Ordinal = 1; + final String element1Value = "Discovered"; + final String element1Description = "The membership was discovered by an automated process."; + final String element1DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element1Ordinal, + element1Value, + element1Description, + element1DescriptionGUID); + elementDefs.add(elementDef); + + final int element2Ordinal = 2; + final String element2Value = "Assigned"; + final String element2Description = "The membership was proposed by an expert curator."; + final String element2DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element2Ordinal, + element2Value, + element2Description, + element2DescriptionGUID); + elementDefs.add(elementDef); + + final int element3Ordinal = 3; + final String element3Value = "Imported"; + final String element3Description = "The membership was imported from another metadata system."; + final String element3DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element3Ordinal, + element3Value, + element3Description, + element3DescriptionGUID); + elementDefs.add(elementDef); + + final int element4Ordinal = 4; + final String element4Value = "Validated"; + final String element4Description = "The membership created by an automated process has been validated and approved by an expert curator."; + final String element4DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element4Ordinal, + element4Value, + element4Description, + element4DescriptionGUID); + elementDefs.add(elementDef); + + final int element5Ordinal = 5; + final String element5Value = "Deprecated"; + final String element5Description = "The membership should no longer be used."; + final String element5DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element5Ordinal, + element5Value, + element5Description, + element5DescriptionGUID); + elementDefs.add(elementDef); + + final int element6Ordinal = 6; + final String element6Value = "Obsolete"; + final String element6Description = "The membership must no longer be used."; + final String element6DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element6Ordinal, + element6Value, + element6Description, + element6DescriptionGUID); + elementDefs.add(elementDef); + + final int element99Ordinal = 99; + final String element99Value = "Other"; + final String element99Description = "Another membership status."; + final String element99DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element99Ordinal, + element99Value, + element99Description, + element99DescriptionGUID); + elementDefs.add(elementDef); + + enumDef.setElementDefs(elementDefs); + return enumDef; + } + + private TypeDefPatch updateCollectionMembershipRelationship() + { + /* + * Create the Patch + */ + final String typeName = "CollectionMembership"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "membershipRationale"; + final String attribute1Description = "Description of how the member is used, or why it is useful in this collection."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "expression"; + final String attribute2Description = "Expression describing the membership relationship."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "status"; + final String attribute3Description = "The status of the membership relationship."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "confidence"; + final String attribute4Description = "Level of confidence in the correctness of the membership relationship."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "steward"; + final String attribute5Description = "Person responsible for the membership relationship."; + final String attribute5DescriptionGUID = null; + final String attribute6Name = "source"; + final String attribute6Description = "Person, organization or automated process that created the membership relationship."; + final String attribute6DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getEnumTypeDefAttribute("MembershipStatus", + attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getIntTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute6Name, + attribute6Description, + attribute6DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0137ToDos() + { + this.archiveBuilder.addTypeDefPatch(updateActionTargetRelationship()); + } + + private TypeDefPatch updateActionTargetRelationship() + { + /* + * Create the Patch + */ + final String typeName = "ActionTarget"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "status"; + final String attribute1Description = "The status of the work on this element."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "startDate"; + final String attribute2Description = "Date/time that work started on this element."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "completionDate"; + final String attribute3Description = "Date/time that work stopped on this element."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "actionTargetName"; + final String attribute4Description = "The name to identify the action target to the actor that processes it."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "completionMessage"; + final String attribute5Description = "Message to provide additional information on the results of acting on the target by the actor or the reasons for any failures."; + final String attribute5DescriptionGUID = null; + + property = archiveHelper.getEnumTypeDefAttribute("ToDoStatus", + attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void add0220DataFileCollectionDataSet() + { + this.archiveBuilder.addEntityDef(getDataFileCollectionDataSetEntity()); + + } + + private EntityDef getDataFileCollectionDataSetEntity() + { + final String guid = "962de053-ab51-40eb-b843-85b98013f5ca"; + final String name = "DataFileCollection"; + final String description = "A data set that consists of a collection files (do not need to be co-located)."; + final String descriptionGUID = null; + + final String superTypeName = "DataSet"; + + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void add0224TableDataSet() + { + this.archiveBuilder.addEntityDef(getTableDataSetEntity()); + + } + + private EntityDef getTableDataSetEntity() + { + final String guid = "20c45531-5d2e-4eb6-9a47-035cb1067b82"; + final String name = "TableDataSet"; + final String description = "A tabular data source (typically a database table) that is an asset in its own right."; + final String descriptionGUID = null; + + final String superTypeName = "DataSet"; + + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void add0239DeployedReportType() + { + this.archiveBuilder.addEntityDef(getDeployedReportTypeEntity()); + + } + + private EntityDef getDeployedReportTypeEntity() + { + final String guid = "ed53a480-e6d4-44f1-aac7-3fac60bbb00e"; + final String name = "DeployedReportType"; + final String description = "A template for generating report."; + final String descriptionGUID = null; + + final String superTypeName = "Asset"; + + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "id"; + final String attribute1Description = "Id of report."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "author"; + final String attribute2Description = "Author of the report."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "url"; + final String attribute3Description = "url of the report."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "createdTime"; + final String attribute4Description = "Report create time."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "lastModifiedTime"; + final String attribute5Description = "Report last modified time."; + final String attribute5DescriptionGUID = null; + final String attribute6Name = "lastModifier"; + final String attribute6Description = "Report last modifier."; + final String attribute6DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute6Name, + attribute6Description, + attribute6DescriptionGUID); + properties.add(property); + + entityDef.setPropertiesDefinition(properties); + + return entityDef; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + + private void update0462GovernanceActionType() + { + this.archiveBuilder.addTypeDefPatch(update0462GovernanceActionTypeExecutorRelationship()); + } + + private TypeDefPatch update0462GovernanceActionTypeExecutorRelationship() + { + /* + * Create the Patch + */ + final String typeName = "GovernanceActionTypeExecutor"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "requestParameterFilter"; + final String attribute1Description = "Which requestParameters to remove before calling governance action."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "requestParameterMap"; + final String attribute2Description = "The request parameters to rename before calling the governance action. Map is from old name to new name."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "actionTargetFilter"; + final String attribute3Description = "Which actionTargets to remove before calling governance action."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "actionTargetMap"; + final String attribute4Description = "The action target to rename before calling the governance action. Map is from old name to new name."; + final String attribute4DescriptionGUID = null; + + property = archiveHelper.getArrayStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getMapStringStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getArrayStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getMapStringStringTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void create0464DynamicIntegrationGroups() + { + this.archiveBuilder.addEntityDef(addIntegrationGroupEntity()); + this.archiveBuilder.addEntityDef(addIntegrationConnectorEntity()); + this.archiveBuilder.addEntityDef(addIntegrationReportEntity()); + this.archiveBuilder.addRelationshipDef(addRegisteredIntegrationConnectorRelationship()); + this.archiveBuilder.addRelationshipDef(addCatalogTargetRelationship()); + this.archiveBuilder.addRelationshipDef(addRelatedIntegrationReportRelationship()); + } + + + private EntityDef addIntegrationGroupEntity() + { + final String guid = "4d7c43ec-983b-40e4-af78-6fb66c4f5136"; + final String name = "IntegrationGroup"; + final String description = "A collection of integration connectors to run together."; + final String descriptionGUID = null; + + final String superTypeName = "SoftwareServerCapability"; + + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + } + + private EntityDef addIntegrationConnectorEntity() + { + final String guid = "759da11b-ebb6-4382-bdc9-72adc7c922db"; + final String name = "IntegrationConnector"; + final String description = "A definition to control the execution of an integration connector."; + final String descriptionGUID = null; + + final String superTypeName = "DeployedConnector"; + + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "usesBlockingCalls"; + final String attribute1Description = "The integration connector needs to use blocking calls to a third party technology and so needs to" + + " run in its own thread."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getBooleanTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + entityDef.setPropertiesDefinition(properties); + + return entityDef; + } + + private EntityDef addIntegrationReportEntity() + { + final String guid = "b8703d3f-8668-4e6a-bf26-27db1607220d"; + final String name = "IntegrationReport"; + final String description = "Details of the metadata changes made by the execution of the refresh() method by an integration connector."; + final String descriptionGUID = null; + + final String superTypeName = "OpenMetadataRoot"; + + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "connectorName"; + final String attribute1Description = "Name of the integration connector for logging purposes."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "connectorId"; + final String attribute2Description = "Unique identifier of the integration connector deployment."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "serverName"; + final String attribute3Description = "Name of the integration daemon where the integration connector is/was running."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "refreshStartDate"; + final String attribute4Description = "Date/time when the refresh() call was made."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "refreshCompletionDate"; + final String attribute5Description = "Date/time when the integration connector returned from the refresh() call."; + final String attribute5DescriptionGUID = null; + final String attribute6Name = "createdElements"; + final String attribute6Description = "List of elements that were created."; + final String attribute6DescriptionGUID = null; + final String attribute7Name = "updatedElements"; + final String attribute7Description = "List of elements that were updated."; + final String attribute7DescriptionGUID = null; + final String attribute8Name = "deletedElements"; + final String attribute8Description = "List of elements that were deleted."; + final String attribute8DescriptionGUID = null; + final String attribute9Name = "additionalProperties"; + final String attribute9Description = "Additional properties of importance to the integration connector."; + final String attribute9DescriptionGUID = null; + + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + property = archiveHelper.getArrayStringTypeDefAttribute(attribute6Name, + attribute6Description, + attribute6DescriptionGUID); + properties.add(property); + property = archiveHelper.getArrayStringTypeDefAttribute(attribute7Name, + attribute7Description, + attribute7DescriptionGUID); + properties.add(property); + property = archiveHelper.getArrayStringTypeDefAttribute(attribute8Name, + attribute8Description, + attribute8DescriptionGUID); + properties.add(property); + property = archiveHelper.getMapStringStringTypeDefAttribute(attribute9Name, + attribute9Description, + attribute9DescriptionGUID); + properties.add(property); + + entityDef.setPropertiesDefinition(properties); + + return entityDef; + } + + private RelationshipDef addRegisteredIntegrationConnectorRelationship() + { + final String guid = "7528bcd4-ae4c-47d0-a33f-4aeebbaa92c2"; + final String name = "RegisteredIntegrationConnector"; + final String description = "A link between an integration group and an integration connector that is part of the group."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "IntegrationGroup"; + final String end1AttributeName = "includedInIntegrationGroups"; + final String end1AttributeDescription = "An integration group that this integration connector is a member of."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "IntegrationConnector"; + final String end2AttributeName = "registeredIntegrationConnectors"; + final String end2AttributeDescription = "An integration connector that should run as part of the integration group."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "connectorName"; + final String attribute1Description = "Name of the connector for logging purposes."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "connectorUserId"; + final String attribute2Description = "UserId for the integration connector to use when working with open metadata. The default userId " + + "comes from the hosting server if this value is blank."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "metadataSourceQualifiedName"; + final String attribute3Description = "Qualified name of a software server capability that is the owner/home of the metadata catalogued " + + "by the integration connector."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "startDate"; + final String attribute4Description = "Earliest time that the connector can run."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "stopTime"; + final String attribute5Description = "Latest time that the connector can run."; + final String attribute5DescriptionGUID = null; + final String attribute6Name = "refreshTimeInterval"; + final String attribute6Description = "Describes how frequently the integration connector should run - in minutes."; + final String attribute6DescriptionGUID = null; + final String attribute7Name = "permittedSynchronization"; + final String attribute7Description = "Defines the permitted directions of flow of metadata updates between open metadata and a third party technology."; + final String attribute7DescriptionGUID = null; + final String attribute8Name = "generateIntegrationReport"; + final String attribute8Description = "Should the integration daemon create integration reports based on the integration connector's " + + "activity? (Default is true.)"; + final String attribute8DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + property = archiveHelper.getLongTypeDefAttribute(attribute6Name, + attribute6Description, + attribute6DescriptionGUID); + properties.add(property); + property = archiveHelper.getEnumTypeDefAttribute("PermittedSynchronization", + attribute7Name, + attribute7Description, + attribute7DescriptionGUID); + properties.add(property); + property = archiveHelper.getBooleanTypeDefAttribute(attribute8Name, + attribute8Description, + attribute8DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + private RelationshipDef addCatalogTargetRelationship() + { + final String guid = "bc5a5eb1-881b-4055-aa2c-78f314282ac2"; + final String name = "CatalogTarget"; + final String description = "Identifies an element that an integration connector is to work with."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "IntegrationConnector"; + final String end1AttributeName = "cataloguedByConnectors"; + final String end1AttributeDescription = "An integration connector managing metadata synchronization."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "OpenMetadataRoot"; + final String end2AttributeName = "catalogTargets"; + final String end2AttributeDescription = "An open metadata element that the integration connector is working on."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "catalogTargetName"; + final String attribute1Description = "Symbolic name of the catalog target to help the integration connector to choose when to use it."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + + private RelationshipDef addRelatedIntegrationReportRelationship() + { + final String guid = "83d12156-f8f3-4b4b-b31b-18c140df9aa3"; + final String name = "RelatedIntegrationReport"; + final String description = "Links an integration report to the anchor entity it describes."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "OpenMetadataRoot"; + final String end1AttributeName = "anchorSubject"; + final String end1AttributeDescription = "The anchor entity that the integration report describes."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.AT_MOST_ONE; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "IntegrationReport"; + final String end2AttributeName = "integrationReports"; + final String end2AttributeDescription = "A description of the changes made to the anchor entity by an integration " + + "report."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + return relationshipDef; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0545ReferenceData() + { + this.archiveBuilder.addTypeDefPatch(updateReferenceValueAssignment()); + } + + + private TypeDefPatch updateReferenceValueAssignment() + { + /* + * Create the Patch + */ + final String typeName = "ReferenceValueAssignment"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "attributeName"; + final String attribute1Description = "The name of the attribute that the reference data assignment represents."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void addFormulaTypeAttribute() + { + this.archiveBuilder.addTypeDefPatch(updateDataSet()); + this.archiveBuilder.addTypeDefPatch(updateProcess()); + this.archiveBuilder.addTypeDefPatch(updateCalculatedValue()); + this.archiveBuilder.addTypeDefPatch(updateProcessCall()); + this.archiveBuilder.addTypeDefPatch(updateDataFlow()); + } + + + private TypeDefPatch updateDataSet() + { + /* + * Create the Patch + */ + final String typeName = "DataSet"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "formulaType"; + final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + private TypeDefPatch updateProcess() + { + /* + * Create the Patch + */ + final String typeName = "Process"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "formulaType"; + final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + private TypeDefPatch updateCalculatedValue() + { + /* + * Create the Patch + */ + final String typeName = "CalculatedValue"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "formulaType"; + final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + private TypeDefPatch updateProcessCall() + { + /* + * Create the Patch + */ + final String typeName = "ProcessCall"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "formulaType"; + final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + private TypeDefPatch updateDataFlow() + { + /* + * Create the Patch + */ + final String typeName = "DataFlow"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "formulaType"; + final String attribute1Description = "Format of the expression provided in the formula attribute."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0470IncidentClassifierSet() + { + this.archiveBuilder.addTypeDefPatch(updateIncidentClassifierSetClassification()); + } + + private TypeDefPatch updateIncidentClassifierSetClassification() + { + /* + * Create the Patch + */ + final String typeName = "IncidentClassifierSet"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "incidentClassifierCategory"; + final String attribute1Description = "The category of classifiers used to set the incidentClassifiers in IncidentReport."; + final String attribute1DescriptionGUID = null; + + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0484AgreementActor() + { + this.archiveBuilder.addTypeDefPatch(updateAgreementActorRelationship()); + } + + private TypeDefPatch updateAgreementActorRelationship() + { + /* + * Create the Patch + */ + final String typeName = "AgreementActor"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); + + return typeDefPatch; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0720InformationSupplyChains() + { + this.archiveBuilder.addRelationshipDef(getInformationSupplyChainLinkRelationship()); + } + + private RelationshipDef getInformationSupplyChainLinkRelationship() + { + final String guid = "207e5130-ab7c-4048-9249-a63a43c13d60"; + final String name = "InformationSupplyChainLink"; + final String description = "A link between two related information supply chain segments -or to their source or destination."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "supplyFrom"; + final String end1AttributeDescription = "Logical source of the information supply chain."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "Referenceable"; + final String end2AttributeName = "supplyTo"; + final String end2AttributeDescription = "Logical destination of an information supply chain."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "description"; + final String attribute1Description = "Description of the relationship."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + +} + diff --git a/open-metadata-resources/open-metadata-samples/open-metadata-security-samples/src/main/java/org/odpi/openmetadata/metadatasecurity/samples/CocoPharmaServerSecurityConnector.java b/open-metadata-resources/open-metadata-samples/open-metadata-security-samples/src/main/java/org/odpi/openmetadata/metadatasecurity/samples/CocoPharmaServerSecurityConnector.java index 94bdc5d455e..b5dc094f9d8 100644 --- a/open-metadata-resources/open-metadata-samples/open-metadata-security-samples/src/main/java/org/odpi/openmetadata/metadatasecurity/samples/CocoPharmaServerSecurityConnector.java +++ b/open-metadata-resources/open-metadata-samples/open-metadata-security-samples/src/main/java/org/odpi/openmetadata/metadatasecurity/samples/CocoPharmaServerSecurityConnector.java @@ -8,12 +8,15 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.OpenMetadataAssetSecurity; import org.odpi.openmetadata.metadatasecurity.OpenMetadataConnectionSecurity; +import org.odpi.openmetadata.metadatasecurity.OpenMetadataGlossarySecurity; import org.odpi.openmetadata.metadatasecurity.OpenMetadataServerSecurity; import org.odpi.openmetadata.metadatasecurity.OpenMetadataServiceSecurity; import org.odpi.openmetadata.metadatasecurity.connectors.OpenMetadataServerSecurityConnector; import org.odpi.openmetadata.metadatasecurity.properties.Asset; import org.odpi.openmetadata.metadatasecurity.properties.Connection; import org.odpi.openmetadata.metadatasecurity.properties.AssetAuditHeader; +import org.odpi.openmetadata.metadatasecurity.properties.Glossary; +import org.odpi.openmetadata.metadatasecurity.properties.Referenceable; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OpenMetadataRepositorySecurity; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.AttributeTypeDef; @@ -36,29 +39,30 @@ public class CocoPharmaServerSecurityConnector extends OpenMetadataServerSecurit OpenMetadataServerSecurity, OpenMetadataServiceSecurity, OpenMetadataConnectionSecurity, - OpenMetadataAssetSecurity + OpenMetadataAssetSecurity, + OpenMetadataGlossarySecurity { /* * These variables represent the different groups of user. Typically these would be * implemented as a look up to a user directory such as LDAP rather than in memory lists. * The lists are used here to make the demo easier to set up. */ - private List allUsers = new ArrayList<>(); + private final List allUsers = new ArrayList<>(); - private List assetOnboardingExit = new ArrayList<>(); - private List serverAdmins = new ArrayList<>(); - private List serverOperators = new ArrayList<>(); - private List serverInvestigators = new ArrayList<>(); - private List metadataArchitects = new ArrayList<>(); - private List npaAccounts = new ArrayList<>(); - private List externalUsers = new ArrayList<>(); + private final List assetOnboardingExit = new ArrayList<>(); + private final List serverAdmins = new ArrayList<>(); + private final List serverOperators = new ArrayList<>(); + private final List serverInvestigators = new ArrayList<>(); + private final List metadataArchitects = new ArrayList<>(); + private final List npaAccounts = new ArrayList<>(); + private final List externalUsers = new ArrayList<>(); - private List defaultZoneMembership = new ArrayList<>(); - private List zonesForExternals = new ArrayList<>(); + private final List defaultZoneMembership = new ArrayList<>(); + private final List zonesForExternals = new ArrayList<>(); - private Map> zoneAccess = new HashMap<>(); - private Map ownerZones = new HashMap<>(); + private final Map> zoneAccess = new HashMap<>(); + private final Map ownerZones = new HashMap<>(); /* * Zones requiring special processing @@ -1218,6 +1222,160 @@ public void validateUserForAssetDelete(String userId, super.validateUserForAssetDelete(userId, asset); } + /* + * OpenMetadataGlossarySecurity assures the access to glossary content. + * Glossary categories and terms are anchored to a single glossary. + * Glossary terms may be linked to multiple categories, some in different glossaries. + */ + + /** + * Tests for whether a specific user should have the right to create a glossary. + * + * @param userId identifier of user + * @param glossary new glossary details + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + @Override + public void validateUserForGlossaryCreate(String userId, + Glossary glossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryCreate"; + + validateGlossaryAccess(glossary, userId, "glossaryCreate", methodName); + } + + + /** + * Tests for whether a specific user should have read access to a specific glossary and its contents. + * + * @param userId identifier of user + * @param glossary glossary details + * @throws UserNotAuthorizedException the user is not authorized to access this glossary + */ + @Override + public void validateUserForGlossaryRead(String userId, + Glossary glossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryRead"; + + validateGlossaryAccess(glossary, userId, "glossaryRead", methodName); + } + + + /** + * Tests for whether a specific user should have the right to update the properties/classifications of a glossary. + * + * @param userId identifier of user + * @param originalGlossary original glossary details + * @param newGlossary new glossary details + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + @Override + public void validateUserForGlossaryDetailUpdate(String userId, + Glossary originalGlossary, + Glossary newGlossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryDetailUpdate"; + + validateGlossaryAccess(newGlossary, userId, "glossaryDetailUpdate", methodName); + } + + + /** + * Tests for whether a specific user should have the right to update elements attached directly + * to a glossary such as glossary terms and categories. These updates could be to their properties, + * classifications and relationships. It also includes attaching valid values but not semantic assignments + * since they are considered updates to the associated asset. + * + * @param userId identifier of user + * @param glossary glossary details + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + @Override + public void validateUserForGlossaryMemberUpdate(String userId, + Glossary glossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryMemberUpdate"; + + validateGlossaryAccess(glossary, userId, "glossaryMemberUpdate", methodName); + } + + + /** + * Tests for whether a specific user should have the right to update the instance status of a term + * anchored in a glossary. + * + * @param userId identifier of user + * @param glossary glossary details + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + @Override + public void validateUserForGlossaryMemberStatusUpdate(String userId, + Glossary glossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryMemberStatusUpdate"; + + validateGlossaryAccess(glossary, userId, "glossaryMemberStatusUpdate", methodName); + } + + + /** + * Tests for whether a specific user should have the right to attach feedback - such as comments, + * ratings, tags and likes, to the glossary. + * + * @param userId identifier of user + * @param glossary original glossary details + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + @Override + public void validateUserForGlossaryFeedback(String userId, + Glossary glossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryFeedback"; + + validateGlossaryAccess(glossary, userId, "glossaryFeedback", methodName); + } + + + /** + * Tests for whether a specific user should have the right to delete a glossary and all of its contents. + * + * @param userId identifier of user + * @param glossary original glossary details + * @throws UserNotAuthorizedException the user is not authorized to change this glossary + */ + @Override + public void validateUserForGlossaryDelete(String userId, + Glossary glossary) throws UserNotAuthorizedException + { + final String methodName = "validateUserForGlossaryDelete"; + + validateGlossaryAccess(glossary, userId, "glossaryDelete", methodName); + } + + + private void validateGlossaryAccess(Glossary glossary, + String userId, + String operationName, + String methodName) throws UserNotAuthorizedException + { + if (glossary == null) + { + super.throwMissingGlossary(userId, operationName, methodName); + } + else if (glossary.getAccessGroups() != null) + { + List validUsers = glossary.getAccessGroups().get(operationName); + + if (validUsers != null) + { + if (! validUsers.contains(userId)) + { + throwUnauthorizedGlossaryAccess(userId, operationName, glossary, methodName); + } + } + } + } /* * ========================================================================================================= diff --git a/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/fvt/glossaries/CreateGlossaryTest.java b/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/fvt/glossaries/CreateGlossaryTest.java index 27bcea6cc94..ce804354e6b 100644 --- a/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/fvt/glossaries/CreateGlossaryTest.java +++ b/open-metadata-test/open-metadata-fvt/access-services-fvt/asset-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/fvt/glossaries/CreateGlossaryTest.java @@ -351,7 +351,7 @@ private String getGlossaryCategory(GlossaryExchangeClient client, } - List glossaryCategoryList = client.getGlossaryCategoriesByName(userId, assetManagerGUID, assetManagerName, glossaryCategoryName, 0, maxPageSize, null, false, false); + List glossaryCategoryList = client.getGlossaryCategoriesByName(userId, assetManagerGUID, assetManagerName, null, glossaryCategoryName, 0, maxPageSize, null, false, false); if (glossaryCategoryList == null) { @@ -755,7 +755,7 @@ private void validateGlossaryTerm(GlossaryExchangeClient client, extendedProperties, status); - List glossaryTermList = client.getGlossaryTermsByName(userId, assetManagerGUID, assetManagerName, qualifiedName, 0, maxPageSize, null, false, false); + List glossaryTermList = client.getGlossaryTermsByName(userId, assetManagerGUID, assetManagerName, null, qualifiedName, null,0, maxPageSize, null, false, false); validateGlossaryTermElements(activityName, "RetrieveByQualifiedName", @@ -768,7 +768,7 @@ private void validateGlossaryTerm(GlossaryExchangeClient client, extendedProperties, status); - glossaryTermList = client.getGlossaryTermsByName(userId, assetManagerGUID, assetManagerName, displayName, 0, 0, null, false, false); + glossaryTermList = client.getGlossaryTermsByName(userId, assetManagerGUID, assetManagerName, null, displayName, null, 0, 0, null, false, false); validateGlossaryTermElements(activityName, "RetrieveTermsByGlossary",