From 5eccc598a38fe322905554a876ca4d481089d966 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Fri, 24 Feb 2023 09:53:53 +0000 Subject: [PATCH] Add certification and license support to Asset Owner Signed-off-by: Mandy Chessell --- .../api/AssetCertificationInterface.java | 206 +++ .../assetowner/api/AssetLicenseInterface.java | 209 +++ .../api/ExternalReferencesInterface.java | 219 ++++ .../RelatedElementsManagementInterface.java | 258 ++++ .../CertificationElement.java | 201 +++ .../CertificationTypeElement.java | 178 +++ .../ExternalReferenceElement.java | 146 +++ .../metadataelements/LicenseElement.java | 201 +++ .../metadataelements/LicenseTypeElement.java | 178 +++ .../metadataelements/RelatedElement.java | 175 +++ .../properties/CertificationProperties.java | 465 +++++++ .../CertificationTypeProperties.java | 139 ++ .../properties/ClassificationProperties.java | 190 +++ .../ExternalReferenceLinkProperties.java | 177 +++ .../ExternalReferenceProperties.java | 271 ++++ .../GovernanceDefinitionProperties.java | 523 ++++++++ .../GovernanceDefinitionStatus.java | 93 ++ .../properties/LicenseProperties.java | 547 ++++++++ .../properties/LicenseTypeProperties.java | 138 ++ .../properties/RelationshipProperties.java | 200 +++ .../properties/ResourceListProperties.java | 150 +++ .../properties/StakeholderProperties.java | 127 ++ .../rest/CertificateIdRequestBody.java | 124 ++ .../rest/CertificationListResponse.java | 151 +++ .../rest/CertificationTypeListResponse.java | 151 +++ .../rest/CertificationTypeRequestBody.java | 147 +++ .../rest/CertificationTypeResponse.java | 138 ++ .../rest/ClassificationRequestBody.java | 129 ++ .../rest/ElementStubListResponse.java | 151 +++ .../rest/ExternalReferenceIdRequestBody.java | 124 ++ .../rest/ExternalReferenceListResponse.java | 151 +++ .../rest/ExternalReferenceRequestBody.java | 150 +++ .../rest/ExternalReferenceResponse.java | 138 ++ .../rest/ExternalSourceRequestBody.java | 145 ++ .../assetowner/rest/LicenseIdRequestBody.java | 124 ++ .../assetowner/rest/LicenseListResponse.java | 151 +++ .../rest/LicenseTypeListResponse.java | 151 +++ .../rest/LicenseTypeRequestBody.java | 147 +++ .../assetowner/rest/LicenseTypeResponse.java | 138 ++ .../rest/ReferenceableRequestBody.java | 203 +-- .../rest/RelatedElementListResponse.java | 148 +++ .../rest/RelationshipRequestBody.java | 154 +++ .../rest/ValidValuesRequestBody.java | 222 +++- .../client/AssetCertificationManager.java | 469 +++++++ .../client/AssetLicenseManager.java | 471 +++++++ .../client/AssetOwnerBaseClient.java | 1162 +++++++++++++++++ .../client/ExternalReferenceManager.java | 469 +++++++ .../client/rest/AssetOwnerRESTClient.java | 310 +++++ .../converters/AssetOwnerOMASConverter.java | 113 ++ .../CertificationTypeConverter.java | 141 ++ .../ExternalReferenceConverter.java | 136 ++ .../converters/LicenseTypeConverter.java | 141 ++ .../converters/RelatedElementConverter.java | 64 + .../server/AssetOwnerInstanceHandler.java | 125 +- .../server/AssetOwnerServicesInstance.java | 131 +- .../server/CertificationRESTServices.java | 643 +++++++++ .../server/ExternalReferenceRESTServices.java | 765 +++++++++++ .../server/LicenseRESTServices.java | 642 +++++++++ .../server/RelatedElementRESTServices.java | 876 +++++++++++++ .../spring/AssetCertificationsResource.java | 279 ++++ .../AssetExternalReferenceResource.java | 300 +++++ .../server/spring/AssetLicensesResource.java | 279 ++++ .../spring/AssetRelationshipsResource.java | 357 +++++ .../api/CertificationManagementInterface.java | 2 +- .../api/RightsManagementInterface.java | 2 +- .../client/CertificationManager.java | 4 +- .../client/RightsManager.java | 2 +- .../GovernanceProgramInstanceHandler.java | 10 +- .../GovernanceProgramServicesInstance.java | 2 +- .../server/LicenseRESTServices.java | 866 ++++++++++++ .../GovernanceCertificationsResource.java | 2 +- .../spring/GovernanceLicensesResource.java | 355 +++++ .../generichandlers/CertificationHandler.java | 1 - .../generichandlers/LicenseHandler.java | 375 +++++- 74 files changed, 17419 insertions(+), 203 deletions(-) create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetCertificationInterface.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetLicenseInterface.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/ExternalReferencesInterface.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/RelatedElementsManagementInterface.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationElement.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationTypeElement.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/ExternalReferenceElement.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseElement.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseTypeElement.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/RelatedElement.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationTypeProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ClassificationProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceLinkProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionStatus.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseTypeProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/RelationshipProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ResourceListProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/StakeholderProperties.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificateIdRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ClassificationRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ElementStubListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceIdRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalSourceRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseIdRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelatedElementListResponse.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelationshipRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetCertificationManager.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetLicenseManager.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwnerBaseClient.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/ExternalReferenceManager.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/CertificationTypeConverter.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/ExternalReferenceConverter.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/LicenseTypeConverter.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/RelatedElementConverter.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/CertificationRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ExternalReferenceRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/LicenseRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/RelatedElementRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetCertificationsResource.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetExternalReferenceResource.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetLicensesResource.java create mode 100644 open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetRelationshipsResource.java create mode 100644 open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/LicenseRESTServices.java create mode 100644 open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceLicensesResource.java diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetCertificationInterface.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetCertificationInterface.java new file mode 100644 index 00000000000..88b8147709a --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetCertificationInterface.java @@ -0,0 +1,206 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.api; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationProperties; +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; + +/** + * The AssetCertificationInterface provides the ability to manage the certification types that can be associated with elements. + */ +public interface AssetCertificationInterface +{ + /* ======================================== + * Certification Types + */ + + /** + * Retrieve the certification type by the unique identifier assigned by this service when it was created. + * + * @param userId calling user + * @param certificationTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the certification type + * + * @throws InvalidParameterException guid or userId is null; guid is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + CertificationTypeElement getCertificationTypeByGUID(String userId, + String certificationTypeGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the certification type by its assigned unique document identifier. + * + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching certification type + * + * @throws InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + CertificationTypeElement getCertificationTypeByDocId(String userId, + String documentIdentifier) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve all the certification types for a particular title. The title can include regEx wildcards. + * + * @param userId calling user + * @param title identifier of certification + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching certification types (null if no matching elements) + * + * @throws InvalidParameterException title or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getCertificationTypesByTitle(String userId, + String title, + int startFrom, + int pageSize) throws UserNotAuthorizedException, + InvalidParameterException, + PropertyServerException; + + + /** + * Retrieve all the certification type definitions for a specific governance domain. + * + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching certification type definitions + * + * @throws InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getCertificationTypeByDomainId(String userId, + int domainIdentifier, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + /* ======================================= + * Certifications + */ + + /** + * Link an element to a certification type and include details of the certification in the relationship properties. + * + * @param userId calling user + * @param elementGUID unique identifier of the element being certified + * @param certificationTypeGUID unique identifier for the certification type + * @param properties the properties of the certification + * + * @return unique identifier of the new relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + String certifyElement(String userId, + String elementGUID, + String certificationTypeGUID, + CertificationProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Update the properties of a certification. + * + * @param userId calling user + * @param certificationGUID unique identifier of the certification relationship being updated + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param properties the properties of the certification + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void updateCertification(String userId, + String certificationGUID, + boolean isMergeUpdate, + CertificationProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove the certification for an element. + * + * @param userId calling user + * @param certificationGUID unique identifier of the certification relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void decertifyElement(String userId, + String certificationGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Return information about the elements linked to a certification. + * + * @param userId calling user + * @param certificationTypeGUID unique identifier for the certification type + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getCertifiedElements(String userId, + String certificationTypeGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Return information about the certifications linked to an element. + * + * @param userId calling user + * @param elementGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getCertifications(String userId, + String elementGUID, + int startFrom, + int pageSize) 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/api/AssetLicenseInterface.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetLicenseInterface.java new file mode 100644 index 00000000000..9f86d1bd3a3 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/AssetLicenseInterface.java @@ -0,0 +1,209 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.api; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseProperties; +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; + +/** + * The AssetLicenseInterface supports the management of the types of licenses (terms and conditions) associated with elements. + */ +public interface AssetLicenseInterface +{ + /* ======================================================== + * Management of the different types of licenses + */ + + /** + * Retrieve the license type by the unique identifier assigned by this service when it was created. + * + * @param userId calling user + * @param licenseGUID identifier of the governance definition to retrieve + * + * @return properties of the license type + * + * @throws InvalidParameterException guid or userId is null; guid is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + LicenseTypeElement getLicenseTypeByGUID(String userId, + String licenseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the license type by its assigned unique document identifier. + * + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching license type + * + * @throws InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + LicenseTypeElement getLicenseTypeByDocId(String userId, + String documentIdentifier) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve all the license types for a particular title. The title can include regEx wildcards. + * + * @param userId calling user + * @param title identifier of license + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching roles (null if no matching elements) + * + * @throws InvalidParameterException title or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getLicenseTypesByTitle(String userId, + String title, + int startFrom, + int pageSize) throws UserNotAuthorizedException, + InvalidParameterException, + PropertyServerException; + + + /** + * Retrieve all the license type definitions for a specific governance domain. + * + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching license type definitions + * + * @throws InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getLicenseTypeByDomainId(String userId, + int domainIdentifier, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /* ======================================= + * Licensing + */ + + /** + * Link an element to a license type and include details of the license in the relationship properties. + * + * @param userId calling user + * @param elementGUID unique identifier of the element being licensed + * @param licenseTypeGUID unique identifier for the license type + * @param properties the properties of the license + * + * @return unique identifier of the new relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + String licenseElement(String userId, + String elementGUID, + String licenseTypeGUID, + LicenseProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Update the properties of a license. + * + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param properties the properties of the license + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void updateLicense(String userId, + String licenseGUID, + boolean isMergeUpdate, + LicenseProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove the license for an element. + * + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void unlicenseElement(String userId, + String licenseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + + /** + * Return information about the elements linked to a license. + * + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the subject area + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getLicensedElements(String userId, + String licenseGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Return information about the licenses linked to an element. + * + * @param userId calling user + * @param elementGUID unique identifier for the license relationship + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the subject area + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getLicenses(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/ExternalReferencesInterface.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/ExternalReferencesInterface.java new file mode 100644 index 00000000000..371b4fd992b --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/ExternalReferencesInterface.java @@ -0,0 +1,219 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.api; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.ExternalReferenceElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceLinkProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceProperties; +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; + + +/** + * The ExternalReferencesInterface is used by the governance team to define external references to elements within the governance program. + */ +public interface ExternalReferencesInterface +{ + /** + * Create a definition of an external reference. + * + * @param userId calling user + * @param anchorGUID optional element to link the external reference to that will act as an anchor - that is, this external reference + * will be deleted when the element is deleted (once the external reference is linked to the anchor). + * @param properties properties for a external reference + * + * @return unique identifier of the external reference + * + * @throws InvalidParameterException qualifiedName or userId is null; qualifiedName is not unique + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + String createExternalReference(String userId, + String anchorGUID, + ExternalReferenceProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Update the definition of an external reference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param properties properties to change + * + * @throws InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void updateExternalReference(String userId, + String externalReferenceGUID, + boolean isMergeUpdate, + ExternalReferenceProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove the definition of an external reference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * + * @throws InvalidParameterException guid or userId is null; guid is not known + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + void deleteExternalReference(String userId, + String externalReferenceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Link an external reference to an object. + * + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to. + * @param externalReferenceGUID unique identifier (guid) of the external reference details. + * + * @throws InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + void linkExternalReferenceToElement(String userId, + String attachedToGUID, + String externalReferenceGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Remove the link between an external reference and an element. If the element is its anchor, the external reference is removed. + * + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID identifier of the external reference. + * + * @throws InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + void unlinkExternalReferenceFromElement(String userId, + String attachedToGUID, + String externalReferenceGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return information about a specific external reference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier for the external reference + * + * @return properties of the external reference + * + * @throws InvalidParameterException externalReferenceGUID or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + ExternalReferenceElement getExternalReferenceByGUID(String userId, + String externalReferenceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + /** + * Retrieve the list of external references for this resourceId. + * + * @param userId the name of the calling user. + * @param resourceId unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information. + * + * @throws InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + List findExternalReferencesById(String userId, + String resourceId, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + /** + * Retrieve the list of external references for this URL. + * + * @param userId the name of the calling user. + * @param url URL of the external resource. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information. + * + * @throws InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + List getExternalReferencesByURL(String userId, + String url, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Retrieve the list of external references attached to the supplied object. + * + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external reference. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information. + * + * @throws InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + List retrieveAttachedExternalReferences(String userId, + String attachedToGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Return information about the elements linked to a externalReference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier for the externalReference + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the related elements + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + List getElementsForExternalReference(String userId, + String externalReferenceGUID, + int startFrom, + int pageSize) 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/api/RelatedElementsManagementInterface.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/RelatedElementsManagementInterface.java new file mode 100644 index 00000000000..b4a2fbee115 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/api/RelatedElementsManagementInterface.java @@ -0,0 +1,258 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.api; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.ResourceListProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.StakeholderProperties; +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; + +/** + * Defines the interface that is common to multiple element types + */ +public interface RelatedElementsManagementInterface +{ + /** + * Create a "MoreInformation" relationship between an element that is descriptive and one that is providing the detail. + * + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param properties properties of the relationship + * @param detailGUID unique identifier of the element that provides the detail + * + * @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 setupMoreInformation(String userId, + String elementGUID, + RelationshipProperties properties, + String detailGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove a "MoreInformation" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param detailGUID unique identifier of the element that provides the detail + * + * @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 clearMoreInformation(String userId, + String elementGUID, + String detailGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the detail elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + List getMoreInformation(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the descriptive elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param userId calling user + * @param detailGUID unique identifier of the element that provides the detail + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + List getDescriptiveElements(String userId, + String detailGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Create a "Stakeholder" relationship between an element and its stakeholder. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param properties properties of the relationship + * @param stakeholderGUID unique identifier of the stakeholder + * + * @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 setupStakeholder(String userId, + String elementGUID, + StakeholderProperties properties, + String stakeholderGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove a "Stakeholder" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param stakeholderGUID unique identifier of the stakeholder + * + * @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 clearStakeholder(String userId, + String elementGUID, + String stakeholderGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the stakeholder elements linked via the "Stakeholder" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + List getStakeholders(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the elements commissioned by a stakeholder, linked via the "Stakeholder" relationship between two referenceables. + * + * @param userId calling user + * @param stakeholderGUID unique identifier of the stakeholder + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + List getStakeholderCommissionedElements(String userId, + String stakeholderGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Create a "ResourceList" relationship between a consuming element and an element that represents resources. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param properties properties of the relationship + * @param resourceGUID unique identifier of the resource + * + * @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 setupResource(String userId, + String elementGUID, + ResourceListProperties properties, + String resourceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Remove a "ResourceList" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param resourceGUID unique identifier of the resource + * + * @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 clearResource(String userId, + String elementGUID, + String resourceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the list of resources assigned to an element via the "ResourceList" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + List getResourceList(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + + + /** + * Retrieve the list of elements assigned to a resource via the "ResourceList" relationship between two referenceables. + * + * @param userId calling user + * @param resourceGUID unique identifier of the resource + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + List getSupportedByResource(String userId, + String resourceGUID, + int startFrom, + int pageSize) 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/metadataelements/CertificationElement.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationElement.java new file mode 100644 index 00000000000..28bf6010140 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationElement.java @@ -0,0 +1,201 @@ +/* SPDX-Certification-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +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; + +/** + * CertificationElement contains the properties and header for a certification for an element. + * It includes the details of the specific element's certification and details of the certification type. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationElement implements Serializable +{ + private static final long serialVersionUID = 1L; + + private ElementHeader certificationHeader = null; + private RelationshipProperties certificationProperties = null; + private ElementHeader certificationTypeHeader = null; + private CertificationProperties certificationTypeProperties = null; + + /** + * Default constructor + */ + public CertificationElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificationElement(CertificationElement template) + { + if (template != null) + { + certificationHeader = template.getCertificationHeader(); + certificationProperties = template.getCertificationProperties(); + certificationTypeHeader = template.getCertificationTypeHeader(); + certificationTypeProperties = template.getCertificationTypeProperties(); + } + } + + + /** + * Return the element header associated with the relationship. + * + * @return element header object + */ + public ElementHeader getCertificationHeader() + { + return certificationHeader; + } + + + /** + * Set up the element header associated with the relationship. + * + * @param certificationHeader element header object + */ + public void setCertificationHeader(ElementHeader certificationHeader) + { + this.certificationHeader = certificationHeader; + } + + + /** + * Return details of the relationship + * + * @return relationship properties + */ + public RelationshipProperties getCertificationProperties() + { + return certificationProperties; + } + + + /** + * Set up relationship properties + * + * @param certificationProperties relationship properties + */ + public void setCertificationProperties(RelationshipProperties certificationProperties) + { + this.certificationProperties = certificationProperties; + } + + + /** + * Return the element header associated with end 2 of the relationship (certification type). + * + * @return element stub object + */ + public ElementHeader getCertificationTypeHeader() + { + return certificationTypeHeader; + } + + + /** + * Set up the element header associated with end 2 of the relationship (certification type). + * + * @param certificationTypeHeader element stub object + */ + public void setCertificationTypeHeader(ElementHeader certificationTypeHeader) + { + this.certificationTypeHeader = certificationTypeHeader; + } + + + /** + * Return the properties of the certification type. + * + * @return properties + */ + public CertificationProperties getCertificationTypeProperties() + { + return certificationTypeProperties; + } + + + /** + * Set up the properties of the certification type. + * + * @param certificationTypeProperties properties + */ + public void setCertificationTypeProperties(CertificationProperties certificationTypeProperties) + { + this.certificationTypeProperties = certificationTypeProperties; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CertificationElement{" + + "certificationHeader=" + certificationHeader + + ", relationshipProperties=" + certificationProperties + + ", certificationTypeHeader=" + certificationTypeHeader + + ", certificationTypeProperties=" + certificationTypeProperties + + '}'; + } + + + /** + * 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 CertificationElement)) + { + return false; + } + CertificationElement that = (CertificationElement) objectToCompare; + return Objects.equals(certificationHeader, that.certificationHeader) && + Objects.equals(certificationProperties, that.certificationProperties) && + Objects.equals(certificationTypeHeader, that.certificationTypeHeader) && + Objects.equals(certificationTypeProperties, that.certificationTypeProperties); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), certificationHeader, certificationProperties, certificationTypeHeader, certificationTypeProperties); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationTypeElement.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationTypeElement.java new file mode 100644 index 00000000000..4279f78f7cc --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/CertificationTypeElement.java @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationTypeProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +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; + +/** + * CertificationTypeElement contains the properties and header for a certification type retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationTypeElement implements MetadataElement, Serializable +{ + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private CertificationTypeProperties properties = null; + private RelatedElement relatedElement = null; + + + /** + * Default constructor + */ + public CertificationTypeElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificationTypeElement(CertificationTypeElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + properties = template.getProperties(); + relatedElement = template.getRelatedElement(); + } + } + + + /** + * 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 properties of the certification type. + * + * @return properties + */ + public CertificationTypeProperties getProperties() + { + return properties; + } + + + /** + * Set up the certification type properties. + * + * @param properties properties + */ + public void setProperties(CertificationTypeProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship used to retrieve this element. + * Will be null if the element was retrieved directly rather than via a relationship. + * + * @return list of element stubs + */ + public RelatedElement getRelatedElement() + { + return relatedElement; + } + + + /** + * Set up details of the relationship used to retrieve this element. + * Will be null if the element was retrieved directly rather than via a relationship. + * + * @param relatedElement relationship details + */ + public void setRelatedElement(RelatedElement relatedElement) + { + this.relatedElement = relatedElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CertificationTypeElement{" + + "elementHeader=" + elementHeader + + ", properties=" + properties + + ", relatedElement=" + relatedElement + + '}'; + } + + + /** + * 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; + } + CertificationTypeElement that = (CertificationTypeElement) objectToCompare; + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(properties, that.properties) && + Objects.equals(relatedElement, that.relatedElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), elementHeader, properties, relatedElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/ExternalReferenceElement.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/ExternalReferenceElement.java new file mode 100644 index 00000000000..bcdc6186f7d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/ExternalReferenceElement.java @@ -0,0 +1,146 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +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; + + +/** + * ExternalReferenceElement stores information about a link to an external resource that is relevant to this element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceElement implements MetadataElement, Serializable +{ + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private ExternalReferenceProperties properties = null; + + /** + * Default Constructor + */ + public ExternalReferenceElement() + { + } + + + /** + * Copy/clone Constructor - the resulting object. + * + * @param template object being copied + */ + public ExternalReferenceElement(ExternalReferenceElement template) + { + if (template != null) + { + this.elementHeader = template.getElementHeader(); + this.properties = template.getProperties(); + } + } + + + /** + * Return the element header associated with the properties. + * + * @return element header object + */ + public ElementHeader getElementHeader() + { + return elementHeader; + } + + + /** + * Set up the element header associated with the properties. + * + * @param elementHeader element header object + */ + public void setElementHeader(ElementHeader elementHeader) + { + this.elementHeader = elementHeader; + } + + + /** + * Return the link to external documentation that are relevant to this element. + * + * @return list of external references + */ + public ExternalReferenceProperties getProperties() + { + return properties; + } + + + /** + * Set up the list of links to external documentation that are relevant to this element. + * + * @param properties of external references + */ + public void setProperties(ExternalReferenceProperties properties) + { + this.properties = properties; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "ExternalReferenceElement{" + + "elementHeader=" + elementHeader + + ", properties=" + properties + + '}'; + } + + + /** + * 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; + } + ExternalReferenceElement that = (ExternalReferenceElement) objectToCompare; + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(properties, that.properties); + } + + + /** + * Hash of properties + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), properties, elementHeader); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseElement.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseElement.java new file mode 100644 index 00000000000..b4bc77980fa --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseElement.java @@ -0,0 +1,201 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +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; + +/** + * LicenseElement contains the properties and header for a license for an element. + * It includes the details of the specific element's license and details of the license type. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseElement implements Serializable +{ + private static final long serialVersionUID = 1L; + + private ElementHeader licenseHeader = null; + private RelationshipProperties licenseProperties = null; + private ElementHeader licenseTypeHeader = null; + private LicenseProperties licenseTypeProperties = null; + + /** + * Default constructor + */ + public LicenseElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseElement(LicenseElement template) + { + if (template != null) + { + licenseHeader = template.getLicenseHeader(); + licenseProperties = template.getLicenseProperties(); + licenseTypeHeader = template.getLicenseTypeHeader(); + licenseTypeProperties = template.getLicenseTypeProperties(); + } + } + + + /** + * Return the element header associated with the relationship. + * + * @return element header object + */ + public ElementHeader getLicenseHeader() + { + return licenseHeader; + } + + + /** + * Set up the element header associated with the relationship. + * + * @param licenseHeader element header object + */ + public void setLicenseHeader(ElementHeader licenseHeader) + { + this.licenseHeader = licenseHeader; + } + + + /** + * Return details of the relationship + * + * @return relationship properties + */ + public RelationshipProperties getLicenseProperties() + { + return licenseProperties; + } + + + /** + * Set up relationship properties + * + * @param licenseProperties relationship properties + */ + public void setLicenseProperties(RelationshipProperties licenseProperties) + { + this.licenseProperties = licenseProperties; + } + + + /** + * Return the element header associated with end 2 of the relationship (license type). + * + * @return element stub object + */ + public ElementHeader getLicenseTypeHeader() + { + return licenseTypeHeader; + } + + + /** + * Set up the element header associated with end 2 of the relationship (license type). + * + * @param licenseTypeHeader element stub object + */ + public void setLicenseTypeHeader(ElementHeader licenseTypeHeader) + { + this.licenseTypeHeader = licenseTypeHeader; + } + + + /** + * Return the properties of the license type. + * + * @return properties + */ + public LicenseProperties getLicenseTypeProperties() + { + return licenseTypeProperties; + } + + + /** + * Set up the properties of the license type. + * + * @param licenseTypeProperties properties + */ + public void setLicenseTypeProperties(LicenseProperties licenseTypeProperties) + { + this.licenseTypeProperties = licenseTypeProperties; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LicenseElement{" + + "licenseHeader=" + licenseHeader + + ", relationshipProperties=" + licenseProperties + + ", licenseTypeHeader=" + licenseTypeHeader + + ", licenseTypeProperties=" + licenseTypeProperties + + '}'; + } + + + /** + * 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 LicenseElement)) + { + return false; + } + LicenseElement that = (LicenseElement) objectToCompare; + return Objects.equals(licenseHeader, that.licenseHeader) && + Objects.equals(licenseProperties, that.licenseProperties) && + Objects.equals(licenseTypeHeader, that.licenseTypeHeader) && + Objects.equals(licenseTypeProperties, that.licenseTypeProperties); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), licenseHeader, licenseProperties, licenseTypeHeader, licenseTypeProperties); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseTypeElement.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseTypeElement.java new file mode 100644 index 00000000000..b7669fcdd5d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/LicenseTypeElement.java @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseTypeProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; + +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; + +/** + * LicenseTypeElement contains the properties and header for a licence type retrieved from the metadata repository. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseTypeElement implements MetadataElement, Serializable +{ + private static final long serialVersionUID = 1L; + + private ElementHeader elementHeader = null; + private LicenseTypeProperties properties = null; + private RelatedElement relatedElement = null; + + + /** + * Default constructor + */ + public LicenseTypeElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseTypeElement(LicenseTypeElement template) + { + if (template != null) + { + elementHeader = template.getElementHeader(); + properties = template.getProperties(); + relatedElement = template.getRelatedElement(); + } + } + + + /** + * 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 properties of the license type. + * + * @return properties + */ + public LicenseTypeProperties getProperties() + { + return properties; + } + + + /** + * Set up the license type properties. + * + * @param properties properties + */ + public void setProperties(LicenseTypeProperties properties) + { + this.properties = properties; + } + + + /** + * Return details of the relationship used to retrieve this element. + * Will be null if the element was retrieved directly rather than via a relationship. + * + * @return list of element stubs + */ + public RelatedElement getRelatedElement() + { + return relatedElement; + } + + + /** + * Set up details of the relationship used to retrieve this element. + * Will be null if the element was retrieved directly rather than via a relationship. + * + * @param relatedElement relationship details + */ + public void setRelatedElement(RelatedElement relatedElement) + { + this.relatedElement = relatedElement; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LicenseTypeElement{" + + "elementHeader=" + elementHeader + + ", properties=" + properties + + ", relatedElement=" + relatedElement + + '}'; + } + + + /** + * 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; + } + LicenseTypeElement that = (LicenseTypeElement) objectToCompare; + return Objects.equals(elementHeader, that.elementHeader) && + Objects.equals(properties, that.properties) && + Objects.equals(relatedElement, that.relatedElement); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), elementHeader, properties, relatedElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/RelatedElement.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/RelatedElement.java new file mode 100644 index 00000000000..b20f2f1cc13 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/metadataelements/RelatedElement.java @@ -0,0 +1,175 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.metadataelements; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementStub; + +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; + +/** + * RelatedElement 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 RelatedElement implements Serializable +{ + private static final long serialVersionUID = 1L; + + private ElementHeader relationshipHeader = null; + private RelationshipProperties relationshipProperties = null; + private ElementStub relatedElement = null; + + /** + * Default constructor + */ + public RelatedElement() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public RelatedElement(RelatedElement template) + { + if (template != null) + { + relationshipHeader = template.getRelationshipHeader(); + relationshipProperties = template.getRelationshipProperties(); + relatedElement = template.getRelatedElement(); + } + } + + + /** + * 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 details of the relationship + * + * @return relationship properties + */ + public RelationshipProperties getRelationshipProperties() + { + return relationshipProperties; + } + + + /** + * Set up relationship properties + * + * @param relationshipProperties relationship properties + */ + public void setRelationshipProperties(RelationshipProperties relationshipProperties) + { + this.relationshipProperties = relationshipProperties; + } + + + /** + * 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 "RelatedElement{" + + "relationshipHeader=" + relationshipHeader + + ", relationshipProperties=" + relationshipProperties + + ", relatedElement=" + relatedElement + + '}'; + } + + + /** + * 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; + } + RelatedElement that = (RelatedElement) objectToCompare; + return Objects.equals(getRelationshipHeader(), that.getRelationshipHeader()) && + Objects.equals(getRelationshipProperties(), that.getRelationshipProperties()) && + Objects.equals(getRelatedElement(), that.getRelatedElement()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), relationshipHeader, relationshipProperties, relatedElement); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationProperties.java new file mode 100644 index 00000000000..02b931d6cc8 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationProperties.java @@ -0,0 +1,465 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +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; + +/** + * CertificationProperties describe the details of a certificate that shows that an element is certified with a particular certification type. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + private String certificateId = null; + private Date startDate = null; + private Date endDate = null; + private String conditions = null; + private String certifiedBy = null; + private String certifiedByTypeName = null; + private String certifiedByPropertyName = null; + private String custodian = null; + private String custodianTypeName = null; + private String custodianPropertyName = null; + private String recipient = null; + private String recipientTypeName = null; + private String recipientPropertyName = null; + private String notes = null; + + + /** + * Default Constructor + */ + public CertificationProperties() + { + } + + + /** + * Copy/clone Constructor - the resulting object. + * + * @param template object being copied + */ + public CertificationProperties(CertificationProperties template) + { + super(template); + + if (template != null) + { + this.certificateId = template.getCertificateId(); + this.startDate = template.getStartDate(); + this.endDate = template.getEndDate(); + this.conditions = template.getConditions(); + this.certifiedBy = template.getCertifiedBy(); + this.certifiedByTypeName = template.getCertifiedByTypeName(); + this.certifiedByPropertyName = template.getCertifiedByPropertyName(); + this.custodian = template.getCustodian(); + this.custodianTypeName = template.getCustodianTypeName(); + this.custodianPropertyName = template.getCustodianPropertyName(); + this.recipient = template.getRecipient(); + this.recipientTypeName = template.getRecipientTypeName(); + this.recipientPropertyName = template.getRecipientPropertyName(); + this.notes = template.getNotes(); + } + } + + + /** + * Return the unique identifier of the certificate. This value comes from the certificate authority. + * + * @return string + */ + public String getCertificateId() + { + return certificateId; + } + + + /** + * Set up the unique identifier of the certificate. This value comes from the certificate authority. + * + * @param certificateId string + */ + public void setCertificateId(String certificateId) + { + this.certificateId = certificateId; + } + + + /** + * Return the date/time that this certificate is valid from. + * + * @return date/time + */ + public Date getStartDate() + { + return startDate; + } + + + /** + * Set up the date/time that this certificate is valid from. + * + * @param startDate date/time + */ + public void setStartDate(Date startDate) + { + this.startDate = startDate; + } + + + /** + * Return the date/time that this certificate is no longer valid. + * + * @return date/time + */ + public Date getEndDate() + { + return endDate; + } + + + /** + * Set up the date/time that this certificate is no longer valid. + * + * @param endDate date/time + */ + public void setEndDate(Date endDate) + { + this.endDate = endDate; + } + + + /** + * Return any conditions or endorsements to this certificate. + * + * @return string text + */ + public String getConditions() + { + return conditions; + } + + + /** + * Set up any conditions or endorsements to this certificate. + * + * @param conditions string text + */ + public void setConditions(String conditions) + { + this.conditions = conditions; + } + + + /** + * Return the name of the person in the certification authority that granted this certificate. + * + * @return string name/id + */ + public String getCertifiedBy() + { + return certifiedBy; + } + + + /** + * Set up the name of the person in the certification authority that granted this certificate. + * + * @param certifiedBy string name/id + */ + public void setCertifiedBy(String certifiedBy) + { + this.certifiedBy = certifiedBy; + } + + + /** + * Return the name of the type of the element supplying the certifiedBy property. + * + * @return string type name + */ + public String getCertifiedByTypeName() + { + return certifiedByTypeName; + } + + + /** + * Set up the name of the type of the element supplying the certifiedBy property. + * + * @param certifiedByTypeName string type name + */ + public void setCertifiedByTypeName(String certifiedByTypeName) + { + this.certifiedByTypeName = certifiedByTypeName; + } + + + /** + * Return the name of the property from the element supplying the certifiedBy property. + * + * @return string property name + */ + public String getCertifiedByPropertyName() + { + return certifiedByPropertyName; + } + + + /** + * Set up the name of the property from the element supplying the certifiedBy property. + * + * @param certifiedByPropertyName string property name + */ + public void setCertifiedByPropertyName(String certifiedByPropertyName) + { + this.certifiedByPropertyName = certifiedByPropertyName; + } + + + + /** + * Return the person/team responsible for ensuring that the certificate conditions are adhered to. + * + * @return string name/id + */ + public String getCustodian() + { + return custodian; + } + + + /** + * Set up the person/team responsible for ensuring that the certificate conditions are adhered to. + * + * @param custodian string name/id + */ + public void setCustodian(String custodian) + { + this.custodian = custodian; + } + + + /** + * Return the name of the type of the element supplying the custodian property. + * + * @return string type name + */ + public String getCustodianTypeName() + { + return custodianTypeName; + } + + + /** + * Set up the name of the type of the element supplying the custodian property. + * + * @param custodianTypeName string type name + */ + public void setCustodianTypeName(String custodianTypeName) + { + this.custodianTypeName = custodianTypeName; + } + + + /** + * Return the name of the property from the element supplying the custodian property. + * + * @return string property name + */ + public String getCustodianPropertyName() + { + return custodianPropertyName; + } + + + /** + * Set up the name of the property from the element supplying the custodian property. + * + * @param custodianPropertyName string property name + */ + public void setCustodianPropertyName(String custodianPropertyName) + { + this.custodianPropertyName = custodianPropertyName; + } + + + /** + * Return the person/team that received the certification. + * + * @return string name/id + */ + public String getRecipient() + { + return recipient; + } + + + /** + * Set up the person/team that received the certification. + * + * @param recipient string name/id + */ + public void setRecipient(String recipient) + { + this.recipient = recipient; + } + + + /** + * Return the name of the type of the element supplying the recipient property. + * + * @return string type name + */ + public String getRecipientTypeName() + { + return recipientTypeName; + } + + + /** + * Set up the name of the type of the element supplying the recipient property. + * + * @param recipientTypeName string type name + */ + public void setRecipientTypeName(String recipientTypeName) + { + this.recipientTypeName = recipientTypeName; + } + + + /** + * Return the name of the property from the element supplying the recipient property. + * + * @return string property name + */ + public String getRecipientPropertyName() + { + return recipientPropertyName; + } + + + /** + * Set up the name of the property from the element supplying the recipient property. + * + * @param recipientPropertyName string property name + */ + public void setRecipientPropertyName(String recipientPropertyName) + { + this.recipientPropertyName = recipientPropertyName; + } + + + /** + * Return any notes associated with the certificate. + * + * @return string text + */ + public String getNotes() + { + return notes; + } + + + /** + * Set up any notes associated with the certificate. + * + * @param notes string text + */ + public void setNotes(String notes) + { + this.notes = notes; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "CertificationProperties{" + + "certificateId='" + certificateId + '\'' + + ", startDate=" + startDate + + ", endDate=" + endDate + + ", conditions='" + conditions + '\'' + + ", certifiedBy='" + certifiedBy + '\'' + + ", certifiedByTypeName='" + certifiedByTypeName + '\'' + + ", certifiedByPropertyName='" + certifiedByPropertyName + '\'' + + ", custodian='" + custodian + '\'' + + ", custodianTypeName='" + custodianTypeName + '\'' + + ", custodianPropertyName='" + custodianPropertyName + '\'' + + ", recipient='" + recipient + '\'' + + ", recipientTypeName='" + recipientTypeName + '\'' + + ", recipientPropertyName='" + recipientPropertyName + '\'' + + ", notes='" + notes + '\'' + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", extendedProperties=" + getExtendedProperties() + + '}'; + } + + + /** + * 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 CertificationProperties)) + { + return false; + } + if (! super.equals(objectToCompare)) + { + return false; + } + CertificationProperties that = (CertificationProperties) objectToCompare; + return Objects.equals(certificateId, that.certificateId) && Objects.equals(startDate, + that.startDate) && Objects.equals( + endDate, that.endDate) && Objects.equals(conditions, that.conditions) && Objects.equals(certifiedBy, + that.certifiedBy) && Objects.equals( + certifiedByTypeName, that.certifiedByTypeName) && Objects.equals(certifiedByPropertyName, + that.certifiedByPropertyName) && Objects.equals( + custodian, that.custodian) && Objects.equals(custodianTypeName, that.custodianTypeName) && Objects.equals( + custodianPropertyName, that.custodianPropertyName) && Objects.equals(recipient, that.recipient) && Objects.equals( + recipientTypeName, that.recipientTypeName) && Objects.equals(recipientPropertyName, + that.recipientPropertyName) && Objects.equals(notes, + that.notes); + } + + + /** + * Just use the GUID for the hash code as it should be unique. + * + * @return int code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), certificateId, startDate, endDate, conditions, certifiedBy, certifiedByTypeName, + certifiedByPropertyName, + custodian, custodianTypeName, custodianPropertyName, recipient, recipientTypeName, recipientPropertyName, notes); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationTypeProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationTypeProperties.java new file mode 100644 index 00000000000..c8f74f5beb1 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/CertificationTypeProperties.java @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Many regulations and industry bodies define certifications that can confirm a level of support, capability + * or competence in an aspect of a digital organization's operation. Having certifications may be + * necessary to operating legally or may be a business advantage. The certifications awarded can be captured + * in the metadata repository to enable both use and management of the certification process. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationTypeProperties extends GovernanceDefinitionProperties +{ + private static final long serialVersionUID = 1L; + + private String details = null; + + + /** + * Default Constructor + */ + public CertificationTypeProperties() + { + } + + + /** + * Copy/Clone Constructor + * + * @param template object to copy + */ + public CertificationTypeProperties(CertificationTypeProperties template) + { + super(template); + + if (template != null) + { + this.details = template.getDetails(); + } + } + + + /** + * Return the specific details of the certification. + * + * @return string description + */ + public String getDetails() + { + return details; + } + + + /** + * Set up the specific details of the certification. + * + * @param details string description + */ + public void setDetails(String details) + { + this.details = details; + } + + + /** + * JSON-style toString + * + * @return string containing the properties and their values + */ + @Override + public String toString() + { + return "CertificationTypeProperties{" + + "details='" + details + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", documentIdentifier='" + getDocumentIdentifier() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", extendedProperties=" + getExtendedProperties() + + ", title='" + getTitle() + '\'' + + ", summary='" + getSummary() + '\'' + + ", description='" + getDescription() + '\'' + + ", scope='" + getScope() + '\'' + + ", domainIdentifier=" + getDomainIdentifier() + + ", priority='" + getPriority() + '\'' + + ", implications=" + getImplications() + + ", outcomes=" + getOutcomes() + + ", results=" + getResults() + + '}'; + } + + + /** + * 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; + } + CertificationTypeProperties that = (CertificationTypeProperties) objectToCompare; + return Objects.equals(details, that.details); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), details); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ClassificationProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ClassificationProperties.java new file mode 100644 index 00000000000..514cc54b919 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ClassificationProperties.java @@ -0,0 +1,190 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +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; + +/** + * RelationshipProperties provides the base class for relationships items. This provides extended properties with the ability to + * set effectivity dates. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) + +public class ClassificationProperties implements Serializable +{ + private static final long serialVersionUID = 1L; + + private Date effectiveFrom = null; + private Date effectiveTo = null; + private Map extendedProperties = null; + + + /** + * Default constructor + */ + public ClassificationProperties() + { + super(); + } + + + /** + * Copy/clone constructor. Retrieve values from the supplied template + * + * @param template element to copy + */ + public ClassificationProperties(ClassificationProperties template) + { + if (template != null) + { + effectiveFrom = template.getEffectiveFrom(); + effectiveTo = template.getEffectiveTo(); + extendedProperties = template.getExtendedProperties(); + } + } + + + /** + * Return the date/time that this element is effective from (null means effective from the epoch). + * + * @return date object + */ + public Date getEffectiveFrom() + { + return effectiveFrom; + } + + + /** + * Set up the date/time that this element is effective from (null means effective from the epoch). + * + * @param effectiveFrom date object + */ + public void setEffectiveFrom(Date effectiveFrom) + { + this.effectiveFrom = effectiveFrom; + } + + + /** + * Return the date/time that element is effective to (null means that it is effective indefinitely into the future). + * + * @return date object + */ + public Date getEffectiveTo() + { + return effectiveTo; + } + + + /** + * Set the date/time that element is effective to (null means that it is effective indefinitely into the future). + * + * @param effectiveTo date object + */ + public void setEffectiveTo(Date effectiveTo) + { + this.effectiveTo = effectiveTo; + } + + + /** + * Return the properties that have been defined for a subtype of this object that are not supported explicitly + * by this bean. + * + * @return property map + */ + public Map getExtendedProperties() + { + if (extendedProperties == null) + { + return null; + } + else if (extendedProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(extendedProperties); + } + } + + + /** + * Set up the properties that have been defined for a subtype of this object that are not supported explicitly + * by this bean. + * + * @param extendedProperties property map + */ + public void setExtendedProperties(Map extendedProperties) + { + this.extendedProperties = extendedProperties; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "RelationshipProperties{" + + "effectiveFrom=" + effectiveFrom + + ", effectiveTo=" + effectiveTo + + ", extendedProperties=" + extendedProperties + + '}'; + } + + + /** + * 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; + } + ClassificationProperties that = (ClassificationProperties) objectToCompare; + return Objects.equals(effectiveFrom, that.effectiveFrom) && + Objects.equals(effectiveTo, that.effectiveTo); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(effectiveFrom, effectiveTo); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceLinkProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceLinkProperties.java new file mode 100644 index 00000000000..a9731a83276 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceLinkProperties.java @@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ExternalReferenceLinkProperties provides a structure for the properties that link an external reference to an object. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceLinkProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + private String linkId = null; + private String linkDescription = null; + private String pages = null; + + + /** + * Default constructor + */ + public ExternalReferenceLinkProperties() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ExternalReferenceLinkProperties(ExternalReferenceLinkProperties template) + { + super (template); + + if (template != null) + { + this.linkId = template.getLinkId(); + this.linkDescription = template.getLinkDescription(); + this.pages = template.getPages(); + } + } + + + /** + * Return the identifier that this reference is to be known as with respect to the linked object. + * + * @return String identifier + */ + public String getLinkId() + { + return linkId; + } + + + /** + * Set up the identifier that this reference is to be known as with respect to the linked object. + * + * @param linkId String identifier + */ + public void setLinkId(String linkId) + { + this.linkId = linkId; + } + + + /** + * Return the description of the external reference with respect to the linked object. + * + * @return string + */ + public String getLinkDescription() + { + return linkDescription; + } + + + /** + * Set up the description of the external reference with respect to the linked object. + * + * @param linkDescription string + */ + public void setLinkDescription(String linkDescription) + { + this.linkDescription = linkDescription; + } + + + /** + * Return the page range for the reference. + * + * @return string + */ + public String getPages() + { + return pages; + } + + + /** + * Set up the page range for the reference. + * + * @param pages string + */ + public void setPages(String pages) + { + this.pages = pages; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "ExternalReferenceLinkProperties{" + + "linkId='" + linkId + '\'' + + ", linkDescription='" + linkDescription + '\'' + + ", pages='" + pages + '\'' + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", extendedProperties=" + getExtendedProperties() + + '}'; + } + + + /** + * 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 ExternalReferenceLinkProperties)) + { + return false; + } + if (! super.equals(objectToCompare)) + { + return false; + } + ExternalReferenceLinkProperties that = (ExternalReferenceLinkProperties) objectToCompare; + return Objects.equals(linkId, that.linkId) && Objects.equals(linkDescription, that.linkDescription) + && Objects.equals(pages, that.pages); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), linkId, linkDescription, pages); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceProperties.java new file mode 100644 index 00000000000..ecc9e5adb42 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ExternalReferenceProperties.java @@ -0,0 +1,271 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ExternalReferenceProperties stores information about an link to an external resource that is relevant to this element. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceProperties extends ReferenceableProperties +{ + private static final long serialVersionUID = 1L; + + private String localReferenceId = null; + private String displayName = null; + private String linkDescription = null; + private String resourceDescription = null; + private String uri = null; + private String version = null; + private String organization = null; + + + /** + * Default constructor + */ + public ExternalReferenceProperties() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template element to copy + */ + public ExternalReferenceProperties(ExternalReferenceProperties template) + { + super(template); + + if (template != null) + { + /* + * Copy the values from the supplied template. + */ + localReferenceId = template.getLocalReferenceId(); + linkDescription = template.getLinkDescription(); + displayName = template.getDisplayName(); + uri = template.getURI(); + resourceDescription = template.getResourceDescription(); + version = template.getVersion(); + organization = template.getOrganization(); + } + } + + + /** + * Return the identifier given to this reference (with respect to this governance definition). + * + * @return localReferenceId + */ + public String getLocalReferenceId() + { + return localReferenceId; + } + + + /** + * Set up the identifier given to this reference (with respect to this governance definition). + * + * @param localReferenceId String name + */ + public void setLocalReferenceId(String localReferenceId) + { + this.localReferenceId = localReferenceId; + } + + + /** + * Return the display name of this external reference. + * + * @return String display name. + */ + public String getDisplayName() { return displayName; } + + + /** + * Set up the display name of this external reference. + * + * @param displayName - string name + */ + public void setDisplayName(String displayName) + { + this.displayName = displayName; + } + + + /** + * Return the description of the reference (with respect to this governance definition). + * + * @return String link description. + */ + public String getLinkDescription() { return linkDescription; } + + + /** + * Set up the description of the reference (with respect to the governance definition this reference is linked to). + * + * @param linkDescription String description + */ + public void setLinkDescription(String linkDescription) + { + this.linkDescription = linkDescription; + } + + + /** + * Return the description of the resource that this external reference represents. + * + * @return String description + */ + public String getResourceDescription() { return resourceDescription; } + + + /** + * Set up the description of the resource that this external reference represents. + * + * @param resourceDescription String description + */ + public void setResourceDescription(String resourceDescription) + { + this.resourceDescription = resourceDescription; + } + + + /** + * Return the URI used to retrieve the resource that this external reference represents. + * + * @return String URI + */ + public String getURI() { return uri; } + + + /** + * Set up the URI used to retrieve the resource that this external reference represents. + * + * @param uri String URI + */ + public void setURI(String uri) + { + this.uri = uri; + } + + + + /** + * Return the version of the resource that this external reference represents. + * + * @return String version identifier + */ + public String getVersion() { return version; } + + + /** + * Set up the version of the resource that this external reference represents. + * + * @param version String identifier + */ + public void setVersion(String version) + { + this.version = version; + } + + + /** + * Return the name of the organization that owns the resource that this external reference represents. + * + * @return String organization name + */ + public String getOrganization() { return organization; } + + + /** + * Set up the name of the organization that owns the resource that this external reference represents. + * + * @param organization String name + */ + public void setOrganization(String organization) + { + this.organization = organization; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "ExternalReferenceProperties{" + + "localReferenceId='" + localReferenceId + '\'' + + ", displayName='" + displayName + '\'' + + ", linkDescription='" + linkDescription + '\'' + + ", resourceDescription='" + resourceDescription + '\'' + + ", uri='" + uri + '\'' + + ", version='" + version + '\'' + + ", organization='" + organization + '\'' + + ", URI='" + getURI() + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", qualifiedName='" + getQualifiedName() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", 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; + } + ExternalReferenceProperties that = (ExternalReferenceProperties) objectToCompare; + return Objects.equals(localReferenceId, that.localReferenceId) && + Objects.equals(displayName, that.displayName) && + Objects.equals(linkDescription, that.linkDescription) && + Objects.equals(resourceDescription, that.resourceDescription) && + Objects.equals(uri, that.uri) && + Objects.equals(version, that.version) && + Objects.equals(organization, that.organization); + } + + + /** + * Uses the guid to create a hashcode. + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(localReferenceId, displayName, linkDescription, resourceDescription, uri, version, organization); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionProperties.java new file mode 100644 index 00000000000..5e2909ba386 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionProperties.java @@ -0,0 +1,523 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +import java.io.Serializable; +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; + + +/** + * GovernanceDefinitionProperties provides the base class for many of the definitions that define the data strategy + * and governance program. It includes many of the common fields: + * + *
    + *
  • Document Id
  • + *
  • Title
  • + *
  • Summary
  • + *
  • Description
  • + *
  • Scope
  • + *
  • Domain Identifier
  • + *
  • Status
  • + *
  • Priority
  • + *
  • Implications
  • + *
  • Outcomes
  • + *
  • Results
  • + *
  • AdditionalProperties
  • + *
+ */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "class") +@JsonSubTypes( + { + @JsonSubTypes.Type(value = LicenseTypeProperties.class, name = "LicenseTypeProperties"), + @JsonSubTypes.Type(value = CertificationTypeProperties.class, name = "CertificationTypeProperties"), + }) +public class GovernanceDefinitionProperties implements Serializable +{ + private static final long serialVersionUID = 1L; + + private String documentIdentifier = null; + private Map additionalProperties = null; + + private String title = null; + private String summary = null; + private String description = null; + private String scope = null; + private int domainIdentifier = 0; + private String priority = null; + private List implications = null; + private List outcomes = null; + private List results = null; + + private String typeName = null; + private Map extendedProperties = null; + + + /** + * Default Constructor + */ + public GovernanceDefinitionProperties() + { + super(); + } + + + /** + * Copy/clone Constructor + * + * @param template object being copied + */ + public GovernanceDefinitionProperties(GovernanceDefinitionProperties template) + { + if (template != null) + { + this.documentIdentifier = template.getDocumentIdentifier(); + this.additionalProperties = template.getAdditionalProperties(); + this.title = template.getTitle(); + this.summary = template.getSummary(); + this.description = template.getDescription(); + this.scope = template.getScope(); + this.domainIdentifier = template.getDomainIdentifier(); + this.priority = template.getPriority(); + this.implications = template.getImplications(); + this.outcomes = template.getOutcomes(); + this.results = template.getResults(); + this.typeName = template.getTypeName(); + this.extendedProperties = template.getExtendedProperties(); + } + } + + + /** + * Return the open metadata type name of this object - this is used to create a subtype of + * the referenceable. Any properties associated with this subtype are passed as extended properties. + * + * @return string type name + */ + public String getTypeName() + { + return typeName; + } + + + /** + * Set up the open metadata type name of this object - this is used to create a subtype of + * the referenceable. Any properties associated with this subtype are passed as extended properties. + * + * @param typeName string type name + */ + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + + /** + * Returns the stored qualified name property for the metadata entity. + * If no qualified name is available then the empty string is returned. + * + * @return documentIdentifier + */ + public String getDocumentIdentifier() + { + return documentIdentifier; + } + + + /** + * Set up the fully qualified name. + * + * @param documentIdentifier String name + */ + public void setDocumentIdentifier(String documentIdentifier) + { + this.documentIdentifier = documentIdentifier; + } + + + /** + * Return a copy of the additional properties. Null means no additional properties are available. + * + * @return AdditionalProperties + */ + public Map getAdditionalProperties() + { + if (additionalProperties == null) + { + return null; + } + else if (additionalProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(additionalProperties); + } + } + + + /** + * Set up additional properties. + * + * @param additionalProperties Additional properties object + */ + public void setAdditionalProperties(Map additionalProperties) + { + this.additionalProperties = additionalProperties; + } + + + /** + * Return the properties that are defined for a subtype of referenceable but are not explicitly + * supported by the bean. + * + * @return map of properties + */ + public Map getExtendedProperties() + { + if (extendedProperties == null) + { + return null; + } + else if (extendedProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(extendedProperties); + } + } + + + /** + * Set up the properties that are defined for a subtype of referenceable but are not explicitly + * supported by the bean. + * + * @param extendedProperties map of properties + */ + public void setExtendedProperties(Map extendedProperties) + { + this.extendedProperties = extendedProperties; + } + + + + /** + * Return the title associated with this governance definition. + * + * @return String title + */ + public String getTitle() + { + return title; + } + + + /** + * Set up the title associated with this governance definition. + * + * @param title String title + */ + public void setTitle(String title) + { + this.title = title; + } + + + + /** + * Return the summary for this governance definition. This should cover its essence. Think of it as + * the executive summary. + * + * @return String short description + */ + public String getSummary() + { + return summary; + } + + + /** + * Set up the summary of the governance definition. This should cover its essence. Think of it as + * the executive summary. + * + * @param summary String description + */ + public void setSummary(String summary) + { + this.summary = summary; + } + + + /** + * Return the full description of the governance definition. + * + * @return String description + */ + public String getDescription() + { + return description; + } + + + /** + * Set up the full description of the governance definition. + * + * @param description String description + */ + public void setDescription(String description) + { + this.description = description; + } + + + /** + * Return the organizational scope that this governance definition applies to. + * + * @return String organization, department or team name + */ + public String getScope() + { + return scope; + } + + + /** + * Set up the organizational scope that this governance definition applies to. + * + * @param scope String organization, department or team name + */ + public void setScope(String scope) + { + this.scope = scope; + } + + + /** + * Return the identifier of the governance domain that this definition belongs to (0=all). + * + * @return int + */ + public int getDomainIdentifier() + { + return domainIdentifier; + } + + + /** + * Set up the identifier of the governance domain that this definition belongs to (0=all). + * + * @param domainIdentifier int + */ + public void setDomainIdentifier(int domainIdentifier) + { + this.domainIdentifier = domainIdentifier; + } + + + /** + * Return the priority of the governance definition. This may be something like high, medium or low, + * or maybe a time frame or more detailed explanation. + * + * @return String priority + */ + public String getPriority() + { + return priority; + } + + + /** + * Set up the priority of this governance definition. This may be something like high, medium or low, + * or maybe a time frame or more detailed explanation. + * + * @param priority String priority + */ + public void setPriority(String priority) + { + this.priority = priority; + } + + + /** + * Return the list of implications for the organization that this governance definition brings. + * This is often the first enumeration of the changes that that need to be implemented to bring + * the governance definition into effect. + * + * @return list of descriptions + */ + public List getImplications() + { + return implications; + } + + + /** + * Set up the list of implications for the organization that this governance definition brings. + * This is often the first enumeration of the changes that that need to be implemented to bring + * the governance definition into effect. + * + * @param implications list of descriptions + */ + public void setImplications(List implications) + { + this.implications = implications; + } + + + /** + * Return the list of expected outcomes from implementing this governance definition. + * + * @return list of outcome descriptions + */ + public List getOutcomes() + { + if (outcomes == null) + { + return null; + } + else if (outcomes.isEmpty()) + { + return null; + } + else + { + return outcomes; + } + } + + + /** + * Set up the list of expected outcomes from implementing this governance definition. + * + * @param outcomes list of descriptions of outcomes + */ + public void setOutcomes(List outcomes) + { + this.outcomes = outcomes; + } + + + /** + * Return the list of actual results from implementing this governance definition. + * + * @return list of result descriptions + */ + public List getResults() + { + if (outcomes == null) + { + return null; + } + else if (outcomes.isEmpty()) + { + return null; + } + else + { + return outcomes; + } + } + + + /** + * Set up the list of actual results from implementing this governance definition. + * + * @param results list of description of results + */ + public void setResults(List results) + { + this.results = results; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "GovernanceDefinitionProperties{" + + "documentIdentifier='" + documentIdentifier + '\'' + + ", additionalProperties=" + additionalProperties + + ", title='" + title + '\'' + + ", summary='" + summary + '\'' + + ", description='" + description + '\'' + + ", scope='" + scope + '\'' + + ", domainIdentifier=" + domainIdentifier + + ", priority='" + priority + '\'' + + ", implications=" + implications + + ", outcomes=" + outcomes + + ", results=" + results + + ", typeName='" + typeName + '\'' + + ", extendedProperties=" + extendedProperties + + '}'; + } + + + /** + * 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; + } + GovernanceDefinitionProperties that = (GovernanceDefinitionProperties) objectToCompare; + return domainIdentifier == that.domainIdentifier && + Objects.equals(documentIdentifier, that.documentIdentifier) && + Objects.equals(additionalProperties, that.additionalProperties) && + Objects.equals(title, that.title) && + Objects.equals(summary, that.summary) && + Objects.equals(description, that.description) && + Objects.equals(scope, that.scope) && + Objects.equals(priority, that.priority) && + Objects.equals(implications, that.implications) && + Objects.equals(outcomes, that.outcomes) && + Objects.equals(results, that.results) && + Objects.equals(typeName, that.typeName) && + Objects.equals(extendedProperties, that.extendedProperties); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(documentIdentifier, additionalProperties, title, summary, description, scope, domainIdentifier, priority, + implications, outcomes, results, typeName, extendedProperties); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionStatus.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionStatus.java new file mode 100644 index 00000000000..4d4a1776c28 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/GovernanceDefinitionStatus.java @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.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; + +/** + * GovernanceDefinitionStatus indicates whether the definition is complete and operational or in a state that means + * it is either under development or obsolete. + *
    + *
  • DRAFT - The governance definition is still in development.
  • + *
  • PROPOSED - The governance definition is in review and not yet active.
  • + *
  • ACTIVE - The governance definition is approved and in use.
  • + *
  • DEPRECATED - The governance definition has been superseded.
  • + *
  • OTHER - The governance definition in a locally defined state.
  • + *
+ */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum GovernanceDefinitionStatus implements Serializable +{ + DRAFT (0, "Draft", "The governance definition is still in development."), + PROPOSED (1, "Proposed", "The governance definition is in review and not yet active."), + ACTIVE (2, "Active", "The governance definition is approved and in use."), + DEPRECATED (3, "Deprecated", "The governance definition has been superseded."), + OTHER (99, "Other", "The governance definition in a locally defined state."); + + private static final long serialVersionUID = 1L; + + private final int ordinal; + private final String name; + private final String description; + + + /** + * Default constructor for the enumeration. + * + * @param ordinal numerical representation of the enumeration + * @param name default string name of the instance provenance type + * @param description default string description of the instance provenance type + */ + GovernanceDefinitionStatus(int ordinal, String name, String description) + { + this.ordinal = ordinal; + this.name = name; + this.description = description; + } + + + /** + * Return the numeric representation of the instance provenance type. + * + * @return int ordinal + */ + public int getOrdinal() { return ordinal; } + + + /** + * Return the default name of the instance provenance type. + * + * @return String name + */ + public String getName() { return name; } + + + /** + * Return the default description of the instance provenance type. + * + * @return String description + */ + public String getDescription() { return description; } + + + /** + * toString() JSON-style + * + * @return string description + */ + @Override + public String toString() + { + return "GovernanceDefinitionStatus : " + name; + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseProperties.java new file mode 100644 index 00000000000..b36240eb752 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseProperties.java @@ -0,0 +1,547 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Date; +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; + +/** + * LicenseProperties describe the details of a license that shows that an element is licensed with a particular license type. + */ +@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class LicenseProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + private String licenseId = null; + private Date startDate = null; + private Date endDate = null; + private String conditions = null; + private String licensedBy = null; + private String licensedByTypeName = null; + private String licensedByPropertyName = null; + private String custodian = null; + private String custodianTypeName = null; + private String custodianPropertyName = null; + private String licensee = null; + private String licenseeTypeName = null; + private String licenseePropertyName = null; + private Map entitlements = null; + private Map restrictions = null; + private Map obligations = null; + private String notes = null; + + + /** + * Default Constructor + */ + public LicenseProperties() + { + } + + + /** + * Copy/clone Constructor - the resulting object. + * + * @param template object being copied + */ + public LicenseProperties(LicenseProperties template) + { + super(template); + + if (template != null) + { + this.licenseId = template.getLicenseId(); + this.startDate = template.getStartDate(); + this.endDate = template.getEndDate(); + this.conditions = template.getConditions(); + this.licensedBy = template.getLicensedBy(); + this.licensedByTypeName = template.getLicensedByTypeName(); + this.licensedByPropertyName = template.getLicensedByPropertyName(); + this.custodian = template.getCustodian(); + this.custodianTypeName = template.getCustodianTypeName(); + this.custodianPropertyName = template.getCustodianPropertyName(); + this.licensee = template.getLicensee(); + this.licenseeTypeName = template.getLicenseeTypeName(); + this.licenseePropertyName = template.getLicenseePropertyName(); + this.entitlements = template.getEntitlements(); + this.restrictions = template.getRestrictions(); + this.obligations = template.getObligations(); + this.notes = template.getNotes(); + } + } + + + /** + * Return the unique identifier of the license. This value comes from the license authority. + * + * @return string + */ + public String getLicenseId() + { + return licenseId; + } + + + /** + * Set up the unique identifier of the license. This value comes from the license authority. + * + * @param licenseId string + */ + public void setLicenseId(String licenseId) + { + this.licenseId = licenseId; + } + + + /** + * Return the date/time that this license is valid from. + * + * @return date/time + */ + public Date getStartDate() + { + return startDate; + } + + + /** + * Set up the date/time that this license is valid from. + * + * @param startDate date/time + */ + public void setStartDate(Date startDate) + { + this.startDate = startDate; + } + + + /** + * Return the date/time that this license is no longer valid. + * + * @return date/time + */ + public Date getEndDate() + { + return endDate; + } + + + /** + * Set up the date/time that this license is no longer valid. + * + * @param endDate date/time + */ + public void setEndDate(Date endDate) + { + this.endDate = endDate; + } + + + /** + * Return any conditions or endorsements to this license. + * + * @return string text + */ + public String getConditions() + { + return conditions; + } + + + /** + * Set up any conditions or endorsements to this license. + * + * @param conditions string text + */ + public void setConditions(String conditions) + { + this.conditions = conditions; + } + + + /** + * Return the name of the person in the license authority that granted this license. + * + * @return string name/id + */ + public String getLicensedBy() + { + return licensedBy; + } + + + /** + * Set up the name of the person in the license authority that granted this license. + * + * @param licensedBy string name/id + */ + public void setLicensedBy(String licensedBy) + { + this.licensedBy = licensedBy; + } + + + /** + * Return the name of the type of the element supplying the licensedBy property. + * + * @return string type name + */ + public String getLicensedByTypeName() + { + return licensedByTypeName; + } + + + /** + * Set up the name of the type of the element supplying the licensedBy property. + * + * @param licensedByTypeName string type name + */ + public void setLicensedByTypeName(String licensedByTypeName) + { + this.licensedByTypeName = licensedByTypeName; + } + + + /** + * Return the name of the property from the element supplying the licensedBy property. + * + * @return string property name + */ + public String getLicensedByPropertyName() + { + return licensedByPropertyName; + } + + + /** + * Set up the name of the property from the element supplying the licensedBy property. + * + * @param licensedByPropertyName string property name + */ + public void setLicensedByPropertyName(String licensedByPropertyName) + { + this.licensedByPropertyName = licensedByPropertyName; + } + + + /** + * Return the person/team responsible for ensuring that the license conditions are adhered to. + * + * @return string name/id + */ + public String getCustodian() + { + return custodian; + } + + + /** + * Set up the person/team responsible for ensuring that the license conditions are adhered to. + * + * @param custodian string name/id + */ + public void setCustodian(String custodian) + { + this.custodian = custodian; + } + + + /** + * Return the name of the type of the element supplying the custodian property. + * + * @return string type name + */ + public String getCustodianTypeName() + { + return custodianTypeName; + } + + + /** + * Set up the name of the type of the element supplying the custodian property. + * + * @param custodianTypeName string type name + */ + public void setCustodianTypeName(String custodianTypeName) + { + this.custodianTypeName = custodianTypeName; + } + + + /** + * Return the name of the property from the element supplying the custodian property. + * + * @return string property name + */ + public String getCustodianPropertyName() + { + return custodianPropertyName; + } + + + /** + * Set up the name of the property from the element supplying the custodian property. + * + * @param custodianPropertyName string property name + */ + public void setCustodianPropertyName(String custodianPropertyName) + { + this.custodianPropertyName = custodianPropertyName; + } + + + /** + * Return the person/team that received the license. + * + * @return string name/id + */ + public String getLicensee() + { + return licensee; + } + + + /** + * Set up the person/team that received the license. + * + * @param licensee string name/id + */ + public void setLicensee(String licensee) + { + this.licensee = licensee; + } + + + /** + * Return the name of the type of the element supplying the licensee property. + * + * @return string type name + */ + public String getLicenseeTypeName() + { + return licenseeTypeName; + } + + + /** + * Set up the name of the type of the element supplying the licensee property. + * + * @param licenseeTypeName string type name + */ + public void setLicenseeTypeName(String licenseeTypeName) + { + this.licenseeTypeName = licenseeTypeName; + } + + + /** + * Return the name of the property from the element supplying the licensee property. + * + * @return string property name + */ + public String getLicenseePropertyName() + { + return licenseePropertyName; + } + + + /** + * Set up the name of the property from the element supplying the licensee property. + * + * @param licenseePropertyName string property name + */ + public void setLicenseePropertyName(String licenseePropertyName) + { + this.licenseePropertyName = licenseePropertyName; + } + + + /** + * Return the entitlements granted by the license. + * + * @return name value pairs + */ + public Map getEntitlements() + { + return entitlements; + } + + + /** + * Set up the entitlements granted by the license. + * + * @param entitlements name value pairs + */ + public void setEntitlements(Map entitlements) + { + this.entitlements = entitlements; + } + + + /** + * Return the restrictions imposed by the license. + * + * @return name value pairs + */ + public Map getRestrictions() + { + return restrictions; + } + + + /** + * Set up the restrictions imposed by the license. + * + * @param restrictions name value pairs + */ + public void setRestrictions(Map restrictions) + { + this.restrictions = restrictions; + } + + + /** + * Return the obligations stipulated by the license. + * + * @return name value pairs + */ + public Map getObligations() + { + return obligations; + } + + + /** + * Set up the obligations stipulated by the license. + * + * @param obligations name value pairs + */ + public void setObligations(Map obligations) + { + this.obligations = obligations; + } + + + /** + * Return any notes associated with the license. + * + * @return string text + */ + public String getNotes() + { + return notes; + } + + + /** + * Set up any notes associated with the license. + * + * @param notes string text + */ + public void setNotes(String notes) + { + this.notes = notes; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "LicenseProperties{" + + "licenseId='" + licenseId + '\'' + + ", startDate=" + startDate + + ", endDate=" + endDate + + ", conditions='" + conditions + '\'' + + ", licensedBy='" + licensedBy + '\'' + + ", licensedByTypeName='" + licensedByTypeName + '\'' + + ", licensedByPropertyName='" + licensedByPropertyName + '\'' + + ", custodian='" + custodian + '\'' + + ", custodianTypeName='" + custodianTypeName + '\'' + + ", custodianPropertyName='" + custodianPropertyName + '\'' + + ", licensee='" + licensee + '\'' + + ", licenseeTypeName='" + licenseeTypeName + '\'' + + ", licenseePropertyName='" + licenseePropertyName + '\'' + + ", entitlements=" + entitlements + + ", restrictions=" + restrictions + + ", obligations=" + obligations + + ", notes='" + notes + '\'' + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", extendedProperties=" + getExtendedProperties() + + '}'; + } + + + /** + * 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 LicenseProperties)) + { + return false; + } + if (! super.equals(objectToCompare)) + { + return false; + } + LicenseProperties that = (LicenseProperties) objectToCompare; + return Objects.equals(licenseId, that.licenseId) && + Objects.equals(startDate, that.startDate) && + Objects.equals(endDate, that.endDate) && + Objects.equals(conditions, that.conditions) && + Objects.equals(licensedBy, that.licensedBy) && + Objects.equals(licensedByTypeName, that.licensedByTypeName) && + Objects.equals(licensedByPropertyName, that.licensedByPropertyName) && + Objects.equals(custodian, that.custodian) && + Objects.equals(custodianTypeName, that.custodianTypeName) && + Objects.equals(custodianPropertyName, that.custodianPropertyName) && + Objects.equals(licensee, that.licensee) && + Objects.equals(licenseeTypeName, that.licenseeTypeName) && + Objects.equals(licenseePropertyName, that.licenseePropertyName) && + Objects.equals(entitlements, that.entitlements) && + Objects.equals(restrictions, that.restrictions) && + Objects.equals(obligations, that.obligations) && + Objects.equals(notes, that.notes); + } + + + /** + * Just use the GUID for the hash code as it should be unique. + * + * @return int code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), licenseId, startDate, endDate, conditions, licensedBy, licensedByTypeName, licensedByPropertyName, + custodian, custodianTypeName, custodianPropertyName, licensee, licenseeTypeName, licenseePropertyName, + obligations, restrictions, entitlements, notes); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseTypeProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseTypeProperties.java new file mode 100644 index 00000000000..fdb61ac0a43 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/LicenseTypeProperties.java @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * LicenseTypeProperties defines a license that the organization recognizes and has governance + * definitions to support it. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseTypeProperties extends GovernanceDefinitionProperties +{ + private static final long serialVersionUID = 1L; + + private String details = null; + + + /** + * Default Constructor + */ + public LicenseTypeProperties() + { + } + + + /** + * Copy/Clone Constructor + * + * @param template object to copy + */ + public LicenseTypeProperties(LicenseTypeProperties template) + { + super(template); + + if (template != null) + { + this.details = template.getDetails(); + } + } + + + /** + * Return the specific details of the license. + * + * @return string description + */ + public String getDetails() + { + return details; + } + + + /** + * Set up the specific details of the license. + * + * @param details string description + */ + public void setDetails(String details) + { + this.details = details; + } + + + /** + * JSON-style toString + * + * @return string containing the properties and their values + */ + @Override + public String toString() + { + return "LicenseTypeProperties{" + + "details='" + details + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", documentIdentifier='" + getDocumentIdentifier() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", extendedProperties=" + getExtendedProperties() + + ", title='" + getTitle() + '\'' + + ", summary='" + getSummary() + '\'' + + ", description='" + getDescription() + '\'' + + ", scope='" + getScope() + '\'' + + ", domainIdentifier=" + getDomainIdentifier() + + ", priority='" + getPriority() + '\'' + + ", implications=" + getImplications() + + ", outcomes=" + getOutcomes() + + ", results=" + getResults() + + '}'; + } + + + /** + * 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; + } + LicenseTypeProperties that = (LicenseTypeProperties) objectToCompare; + return Objects.equals(details, that.details); + } + + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), details); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/RelationshipProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/RelationshipProperties.java new file mode 100644 index 00000000000..058e969c7e1 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/RelationshipProperties.java @@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +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; + +/** + * RelationshipProperties provides the base class for relationships items. This provides extended properties with the ability to + * set effectivity dates. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "class") +@JsonSubTypes( + { + @JsonSubTypes.Type(value = ResourceListProperties.class, name = "ResourceListProperties"), + @JsonSubTypes.Type(value = LicenseProperties.class, name = "LicenseProperties"), + @JsonSubTypes.Type(value = CertificationProperties.class, name = "CertificationProperties"), + @JsonSubTypes.Type(value = ExternalReferenceLinkProperties.class, name = "ExternalReferenceLinkProperties"), + }) +public class RelationshipProperties implements Serializable +{ + private static final long serialVersionUID = 1L; + + private Date effectiveFrom = null; + private Date effectiveTo = null; + + private Map extendedProperties = null; + + + /** + * Default constructor + */ + public RelationshipProperties() + { + super(); + } + + + /** + * Copy/clone constructor. Retrieve values from the supplied template + * + * @param template element to copy + */ + public RelationshipProperties(RelationshipProperties template) + { + if (template != null) + { + effectiveFrom = template.getEffectiveFrom(); + effectiveTo = template.getEffectiveTo(); + extendedProperties = template.getExtendedProperties(); + } + } + + + /** + * Return the date/time that this element is effective from (null means effective from the epoch). + * + * @return date object + */ + public Date getEffectiveFrom() + { + return effectiveFrom; + } + + + /** + * Set up the date/time that this element is effective from (null means effective from the epoch). + * + * @param effectiveFrom date object + */ + public void setEffectiveFrom(Date effectiveFrom) + { + this.effectiveFrom = effectiveFrom; + } + + + /** + * Return the date/time that element is effective to (null means that it is effective indefinitely into the future). + * + * @return date object + */ + public Date getEffectiveTo() + { + return effectiveTo; + } + + + /** + * Set the date/time that element is effective to (null means that it is effective indefinitely into the future). + * + * @param effectiveTo date object + */ + public void setEffectiveTo(Date effectiveTo) + { + this.effectiveTo = effectiveTo; + } + + + /** + * Return the properties that have been defined for a subtype of this object that are not supported explicitly + * by this bean. + * + * @return property map + */ + public Map getExtendedProperties() + { + if (extendedProperties == null) + { + return null; + } + else if (extendedProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(extendedProperties); + } + } + + + /** + * Set up the properties that have been defined for a subtype of this object that are not supported explicitly + * by this bean. + * + * @param extendedProperties property map + */ + public void setExtendedProperties(Map extendedProperties) + { + this.extendedProperties = extendedProperties; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "RelationshipProperties{" + + "effectiveFrom=" + effectiveFrom + + ", effectiveTo=" + effectiveTo + + ", extendedProperties=" + extendedProperties + + '}'; + } + + + /** + * 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; + } + RelationshipProperties that = (RelationshipProperties) objectToCompare; + return Objects.equals(effectiveFrom, that.effectiveFrom) && + Objects.equals(effectiveTo, that.effectiveTo); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(effectiveFrom, effectiveTo); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ResourceListProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ResourceListProperties.java new file mode 100644 index 00000000000..c6fa9c9aee1 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/ResourceListProperties.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ResourceListProperties provides a details of why an element providing resources (such as a community) has been attached to an initiative + * such as a governance domain. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ResourceListProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + String resourceUse = null; + boolean watchResource = false; + + /** + * Default constructor + */ + public ResourceListProperties() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ResourceListProperties(ResourceListProperties template) + { + super(template); + + if (template != null) + { + this.resourceUse = template.getResourceUse(); + this.watchResource = template.getWatchResource(); + } + } + + + /** + * Return the reason why the resource has been attached to the initiative. + * + * @return description + */ + public String getResourceUse() + { + return resourceUse; + } + + + /** + * Set up the reason why the resource has been attached to the initiative. + * + * @param resourceUse description + */ + public void setResourceUse(String resourceUse) + { + this.resourceUse = resourceUse; + } + + + /** + * Return whether changes to the resource result in notifications to the initiative. + * + * @return flag + */ + public boolean getWatchResource() + { + return watchResource; + } + + + /** + * Set up whether changes to the resource result in notifications to the initiative. + * + * @param watchResource flag + */ + public void setWatchResource(boolean watchResource) + { + this.watchResource = watchResource; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ResourceListProperties{" + + "resourceUse='" + resourceUse + '\'' + + ", watchResource=" + watchResource + + '}'; + } + + + /** + * 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; + } + ResourceListProperties that = (ResourceListProperties) objectToCompare; + return watchResource == that.watchResource && Objects.equals(resourceUse, that.resourceUse); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), resourceUse, watchResource); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/StakeholderProperties.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/StakeholderProperties.java new file mode 100644 index 00000000000..bcce64b774e --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/properties/StakeholderProperties.java @@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * StakeholderProperties provides a details of a stakeholder for an initiative. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class StakeholderProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + String stakeholderRole = null; + + /** + * Default constructor + */ + public StakeholderProperties() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public StakeholderProperties(StakeholderProperties template) + { + super(template); + + if (template != null) + { + this.stakeholderRole = template.getStakeholderRole(); + } + } + + + /** + * Return the role of the stakeholder to the initiative. + * + * @return role type + */ + public String getStakeholderRole() + { + return stakeholderRole; + } + + + /** + * Set up the role of the stakeholder to the initiative. + * + * @param stakeholderRole role type + */ + public void setStakeholderRole(String stakeholderRole) + { + this.stakeholderRole = stakeholderRole; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "StakeholderProperties{" + + "effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", extendedProperties=" + getExtendedProperties() + + ", stakeholderRole='" + stakeholderRole + '\'' + + '}'; + } + + + /** + * 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; + } + StakeholderProperties that = (StakeholderProperties) objectToCompare; + return Objects.equals(stakeholderRole, that.stakeholderRole); + } + + + /** + * Return hash code based on properties. + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), stakeholderRole); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificateIdRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificateIdRequestBody.java new file mode 100644 index 00000000000..0c30bc8d213 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificateIdRequestBody.java @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * CertificateIdRequestBody provides a structure for the unique certificate identifier. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificateIdRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private String certificateId = null; + + + /** + * Default constructor + */ + public CertificateIdRequestBody() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificateIdRequestBody(CertificateIdRequestBody template) + { + super(template); + + if (template != null) + { + this.certificateId = template.getCertificateId(); + } + } + + + /** + * Return the unique identifier for the certificate from the certificate authority. + * + * @return String identifier + */ + public String getCertificateId() + { + return certificateId; + } + + + /** + * Set up the unique identifier for the certificate from the certificate authority. + * + * @param certificateId String identifier + */ + public void setCertificateId(String certificateId) + { + this.certificateId = certificateId; + } + + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "CertificateIdRequestBody{" + + "certificateId='" + certificateId + '\'' + + '}'; + } + + + /** + * 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; + } + if (!super.equals(objectToCompare)) + { + return false; + } + CertificateIdRequestBody that = (CertificateIdRequestBody) objectToCompare; + return Objects.equals(certificateId, that.certificateId); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(certificateId); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationListResponse.java new file mode 100644 index 00000000000..a93a3d43f54 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationListResponse.java @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationElement; + +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; + + +/** + * CertificationTypeListResponse is the response structure used on the OMAS REST API calls that return a + * list of certifications as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elements = null; + + + /** + * Default constructor + */ + public CertificationListResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificationListResponse(CertificationListResponse template) + { + super(template); + + if (template != null) + { + this.elements = template.getElements(); + } + } + + + /** + * Return the list of certification types. + * + * @return list of objects or null + */ + public List getElements() + { + if (elements == null) + { + return null; + } + else if (elements.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elements); + } + } + + + /** + * Set up the list of certification types. + * + * @param elements - list of objects or null + */ + public void setElements(List elements) + { + this.elements = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CertificationListResponse{" + + "elements=" + elements + + ", 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 CertificationListResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + CertificationListResponse that = (CertificationListResponse) objectToCompare; + return Objects.equals(this.getElements(), that.getElements()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elements, super.hashCode()); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeListResponse.java new file mode 100644 index 00000000000..fc630fdf703 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeListResponse.java @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationTypeElement; + +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; + + +/** + * CertificationTypeListResponse is the response structure used on the OMAS REST API calls that return a + * list of certification types as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationTypeListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elements = null; + + + /** + * Default constructor + */ + public CertificationTypeListResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificationTypeListResponse(CertificationTypeListResponse template) + { + super(template); + + if (template != null) + { + this.elements = template.getElements(); + } + } + + + /** + * Return the list of certification types. + * + * @return list of objects or null + */ + public List getElements() + { + if (elements == null) + { + return null; + } + else if (elements.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elements); + } + } + + + /** + * Set up the list of certification types. + * + * @param elements - list of objects or null + */ + public void setElements(List elements) + { + this.elements = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CertificationTypeListResponse{" + + "elements=" + elements + + ", 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 CertificationTypeListResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + CertificationTypeListResponse that = (CertificationTypeListResponse) objectToCompare; + return Objects.equals(this.getElements(), that.getElements()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elements, super.hashCode()); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeRequestBody.java new file mode 100644 index 00000000000..3efdabc01c6 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeRequestBody.java @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationTypeProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.GovernanceDefinitionStatus; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * CertificationTypeRequestBody provides a structure used when creating certification types. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationTypeRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private CertificationTypeProperties properties = null; + private GovernanceDefinitionStatus initialStatus = null; + + + /** + * Default constructor + */ + public CertificationTypeRequestBody() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificationTypeRequestBody(CertificationTypeRequestBody template) + { + super(template); + + if (template != null) + { + this.properties = template.getProperties(); + this.initialStatus = template.getInitialStatus(); + } + } + + + /** + * Return the properties of the certification type. + * + * @return properties + */ + public CertificationTypeProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the certification type. + * + * @param properties properties + */ + public void setProperties(CertificationTypeProperties properties) + { + this.properties = properties; + } + + + /** + * Return the initial status of the certification type. + * + * @return instance status + */ + public GovernanceDefinitionStatus getInitialStatus() + { + return initialStatus; + } + + + /** + * Set up the initial status of the certification type. + * + * @param initialStatus instance status + */ + public void setInitialStatus(GovernanceDefinitionStatus initialStatus) + { + this.initialStatus = initialStatus; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "CertificationTypeRequestBody{" + + "properties=" + properties + + ", initialStatus=" + initialStatus + + '}'; + } + + + /** + * 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; + } + CertificationTypeRequestBody that = (CertificationTypeRequestBody) objectToCompare; + return Objects.equals(properties, that.properties) && + initialStatus == that.initialStatus; + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(properties, initialStatus); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeResponse.java new file mode 100644 index 00000000000..3adee785a47 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/CertificationTypeResponse.java @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationTypeElement; + +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; + + +/** + * CertificationTypeResponse is the response structure used on the OMAS REST API calls that returns a + * certification type object as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CertificationTypeResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private CertificationTypeElement element = null; + + + /** + * Default constructor + */ + public CertificationTypeResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CertificationTypeResponse(CertificationTypeResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return CertificationTypeProperties object + */ + public CertificationTypeElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element CertificationTypeProperties object + */ + public void setElement(CertificationTypeElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "CertificationTypeResponse{" + + "element='" + getElement() + '\'' + + ", 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 CertificationTypeResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + CertificationTypeResponse that = (CertificationTypeResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), element); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ClassificationRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ClassificationRequestBody.java new file mode 100644 index 00000000000..729cf4f3118 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ClassificationRequestBody.java @@ -0,0 +1,129 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.ClassificationProperties; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * ClassificationRequestBody describes the request body used when attaching classification to elements. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ClassificationRequestBody extends ExternalSourceRequestBody +{ + private static final long serialVersionUID = 1L; + + private ClassificationProperties properties = null; + + + /** + * Default constructor + */ + public ClassificationRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template object to copy + */ + public ClassificationRequestBody(ClassificationRequestBody template) + { + super(template); + + if (template != null) + { + properties = template.getProperties(); + } + } + + + /** + * Return the properties for the classification. + * + * @return properties object + */ + public ClassificationProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties for the classification. + * + * @param properties properties object + */ + public void setProperties(ClassificationProperties properties) + { + this.properties = properties; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ClassificationRequestBody{" + + "externalSourceGUID='" + getExternalSourceGUID() + '\'' + + ", externalSourceName='" + getExternalSourceName() + '\'' + + ", properties=" + properties + + '}'; + } + + + /** + * 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; + } + ClassificationRequestBody that = (ClassificationRequestBody) objectToCompare; + return Objects.equals(getProperties(), that.getProperties()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), properties); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ElementStubListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ElementStubListResponse.java new file mode 100644 index 00000000000..9ae1c7b0c8f --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ElementStubListResponse.java @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +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.ElementStub; + +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; + + +/** + * ElementStubListResponse is the response structure used on the OMAS REST API calls that return a + * list of element identifiers as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ElementStubListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elements = null; + + + /** + * Default constructor + */ + public ElementStubListResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ElementStubListResponse(ElementStubListResponse template) + { + super(template); + + if (template != null) + { + this.elements = template.getElements(); + } + } + + + /** + * Return the list of element identifiers. + * + * @return list of objects or null + */ + public List getElements() + { + if (elements == null) + { + return null; + } + else if (elements.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elements); + } + } + + + /** + * Set up the list of element identifiers. + * + * @param elements - list of objects or null + */ + public void setElements(List elements) + { + this.elements = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ElementStubListResponse{" + + "elements=" + elements + + ", 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 ElementStubListResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + ElementStubListResponse that = (ElementStubListResponse) objectToCompare; + return Objects.equals(this.getElements(), that.getElements()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elements, super.hashCode()); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceIdRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceIdRequestBody.java new file mode 100644 index 00000000000..51655964a37 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceIdRequestBody.java @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ExternalReferenceIdRequestBody provides a structure for the unique external reference identifier. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceIdRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private String referenceId = null; + + + /** + * Default constructor + */ + public ExternalReferenceIdRequestBody() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ExternalReferenceIdRequestBody(ExternalReferenceIdRequestBody template) + { + super(template); + + if (template != null) + { + this.referenceId = template.getReferenceId(); + } + } + + + /** + * Return the unique identifier for the certificate from the certificate authority. + * + * @return String identifier + */ + public String getReferenceId() + { + return referenceId; + } + + + /** + * Set up the unique identifier for the certificate from the certificate authority. + * + * @param referenceId String identifier + */ + public void setReferenceId(String referenceId) + { + this.referenceId = referenceId; + } + + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "CertificateIdRequestBody{" + + "referenceId='" + referenceId + '\'' + + '}'; + } + + + /** + * 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; + } + if (!super.equals(objectToCompare)) + { + return false; + } + ExternalReferenceIdRequestBody that = (ExternalReferenceIdRequestBody) objectToCompare; + return Objects.equals(referenceId, that.referenceId); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(referenceId); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceListResponse.java new file mode 100644 index 00000000000..307a53d680b --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceListResponse.java @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.ExternalReferenceElement; + +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; + + +/** + * ExternalReferenceListResponse is the response structure used on the OMAS REST API calls that return a + * list of external references as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elements = null; + + + /** + * Default constructor + */ + public ExternalReferenceListResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ExternalReferenceListResponse(ExternalReferenceListResponse template) + { + super(template); + + if (template != null) + { + this.elements = template.getElements(); + } + } + + + /** + * Return the list of external references. + * + * @return list of objects or null + */ + public List getElements() + { + if (elements == null) + { + return null; + } + else if (elements.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elements); + } + } + + + /** + * Set up the list of external references. + * + * @param elements - list of objects or null + */ + public void setElements(List elements) + { + this.elements = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ExternalReferenceListResponse{" + + "elements=" + elements + + ", 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 ExternalReferenceListResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + ExternalReferenceListResponse that = (ExternalReferenceListResponse) objectToCompare; + return Objects.equals(this.getElements(), that.getElements()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elements, super.hashCode()); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceRequestBody.java new file mode 100644 index 00000000000..98b08a0ed07 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceRequestBody.java @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceProperties; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ExternalReferenceRequestBody provides a structure for a new ExternalReference. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private String anchorGUID = null; + private ExternalReferenceProperties properties = null; + + + /** + * Default constructor + */ + public ExternalReferenceRequestBody() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ExternalReferenceRequestBody(ExternalReferenceRequestBody template) + { + super(template); + + if (template != null) + { + this.anchorGUID = template.getAnchorGUID(); + this.properties = template.getProperties(); + } + } + + + /** + * Return the optional anchor unique identifier. + * + * @return String guid + */ + public String getAnchorGUID() + { + return anchorGUID; + } + + + /** + * Set up the optional anchor unique identifier. + * + * @param guid String guid + */ + public void setAnchorGUID(String guid) + { + this.anchorGUID = guid; + } + + + /** + * Return the properties for this external reference. + * + * @return date + */ + public ExternalReferenceProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties for this external reference. + * + * @param properties date + */ + public void setProperties(ExternalReferenceProperties properties) + { + this.properties = properties; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "ExternalReferenceRequestBody{" + + "anchorGUID='" + anchorGUID + '\'' + + ", properties=" + properties + + '}'; + } + + + /** + * 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; + } + if (!super.equals(objectToCompare)) + { + return false; + } + ExternalReferenceRequestBody that = (ExternalReferenceRequestBody) objectToCompare; + return Objects.equals(anchorGUID, that.anchorGUID) && + Objects.equals(properties, that.properties); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(anchorGUID, properties); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceResponse.java new file mode 100644 index 00000000000..025e7f8f473 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalReferenceResponse.java @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.ExternalReferenceElement; + +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; + + +/** + * ExternalReferenceResponse is the response structure used on the OMAS REST API calls that returns a + * external reference object as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private ExternalReferenceElement element = null; + + + /** + * Default constructor + */ + public ExternalReferenceResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ExternalReferenceResponse(ExternalReferenceResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return external reference object + */ + public ExternalReferenceElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element external reference object + */ + public void setElement(ExternalReferenceElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ExternalReferenceResponse{" + + "element='" + getElement() + '\'' + + ", 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 ExternalReferenceResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + ExternalReferenceResponse that = (ExternalReferenceResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), element); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalSourceRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalSourceRequestBody.java new file mode 100644 index 00000000000..7ac259f7baf --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ExternalSourceRequestBody.java @@ -0,0 +1,145 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ExternalSourceRequestBody carries the parameters for marking an asset or schema as external. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalSourceRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private String externalSourceGUID = null; + private String externalSourceName = null; + + + /** + * Default constructor + */ + public ExternalSourceRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ExternalSourceRequestBody(ExternalSourceRequestBody template) + { + super(template); + + if (template != null) + { + externalSourceGUID = template.getExternalSourceGUID(); + externalSourceName = template.getExternalSourceName(); + } + } + + + /** + * Return the unique identifier of the software server capability entity that represented the external source - null for local. + * + * @return string guid + */ + public String getExternalSourceGUID() + { + return externalSourceGUID; + } + + + /** + * Set up the unique identifier of the software server capability entity that represented the external source - null for local. + * + * @param externalSourceGUID string guid + */ + public void setExternalSourceGUID(String externalSourceGUID) + { + this.externalSourceGUID = externalSourceGUID; + } + + + /** + * Return the unique name of the software server capability entity that represented the external source. + * + * @return string name + */ + public String getExternalSourceName() + { + return externalSourceName; + } + + + /** + * Set up the unique name of the software server capability entity that represented the external source. + * + * @param externalSourceName string name + */ + public void setExternalSourceName(String externalSourceName) + { + this.externalSourceName = externalSourceName; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ExternalSourceRequestBody{" + + "externalSourceGUID='" + externalSourceGUID + '\'' + + ", externalSourceName='" + externalSourceName + '\'' + + '}'; + } + + /** + * 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; + } + ExternalSourceRequestBody that = (ExternalSourceRequestBody) objectToCompare; + return Objects.equals(externalSourceGUID, that.externalSourceGUID) && + Objects.equals(externalSourceName, that.externalSourceName); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), externalSourceGUID, externalSourceName); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseIdRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseIdRequestBody.java new file mode 100644 index 00000000000..20cf234a760 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseIdRequestBody.java @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * LicenseIdRequestBody provides a structure for the unique certificate identifier. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseIdRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private String licenseId = null; + + + /** + * Default constructor + */ + public LicenseIdRequestBody() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseIdRequestBody(LicenseIdRequestBody template) + { + super(template); + + if (template != null) + { + this.licenseId = template.getLicenseId(); + } + } + + + /** + * Return the unique identifier for the license. + * + * @return String identifier + */ + public String getLicenseId() + { + return licenseId; + } + + + /** + * Set up the unique identifier for the license. + * + * @param licenseId String identifier + */ + public void setLicenseId(String licenseId) + { + this.licenseId = licenseId; + } + + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "LicenseIdRequestBody{" + + "licenseId='" + licenseId + '\'' + + '}'; + } + + + /** + * 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; + } + if (!super.equals(objectToCompare)) + { + return false; + } + LicenseIdRequestBody that = (LicenseIdRequestBody) objectToCompare; + return Objects.equals(licenseId, that.licenseId); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(licenseId); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseListResponse.java new file mode 100644 index 00000000000..73082ef2fda --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseListResponse.java @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseElement; + +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; + + +/** + * LicenseListResponse is the response structure used on the OMAS REST API calls that return a + * list of licenses as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elements = null; + + + /** + * Default constructor + */ + public LicenseListResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseListResponse(LicenseListResponse template) + { + super(template); + + if (template != null) + { + this.elements = template.getElements(); + } + } + + + /** + * Return the list of license types. + * + * @return list of objects or null + */ + public List getElements() + { + if (elements == null) + { + return null; + } + else if (elements.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elements); + } + } + + + /** + * Set up the list of license types. + * + * @param elements - list of objects or null + */ + public void setElements(List elements) + { + this.elements = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LicenseListResponse{" + + "elements=" + elements + + ", 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 LicenseListResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + LicenseListResponse that = (LicenseListResponse) objectToCompare; + return Objects.equals(this.getElements(), that.getElements()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elements, super.hashCode()); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeListResponse.java new file mode 100644 index 00000000000..d3fec914db4 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeListResponse.java @@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseTypeElement; + +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; + + +/** + * LicenseTypeListResponse is the response structure used on the OMAS REST API calls that return a + * list of license types as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseTypeListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elements = null; + + + /** + * Default constructor + */ + public LicenseTypeListResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseTypeListResponse(LicenseTypeListResponse template) + { + super(template); + + if (template != null) + { + this.elements = template.getElements(); + } + } + + + /** + * Return the list of license types. + * + * @return list of objects or null + */ + public List getElements() + { + if (elements == null) + { + return null; + } + else if (elements.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(elements); + } + } + + + /** + * Set up the list of license types. + * + * @param elements - list of objects or null + */ + public void setElements(List elements) + { + this.elements = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LicenseTypeListResponse{" + + "elements=" + elements + + ", 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 LicenseTypeListResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + LicenseTypeListResponse that = (LicenseTypeListResponse) objectToCompare; + return Objects.equals(this.getElements(), that.getElements()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(elements, super.hashCode()); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeRequestBody.java new file mode 100644 index 00000000000..497a266ad3a --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeRequestBody.java @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.GovernanceDefinitionStatus; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseTypeProperties; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * LicenseTypeRequestBody provides a structure used when creating license types. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseTypeRequestBody extends AssetOwnerOMASAPIRequestBody +{ + private static final long serialVersionUID = 1L; + + private LicenseTypeProperties properties = null; + private GovernanceDefinitionStatus initialStatus = null; + + + /** + * Default constructor + */ + public LicenseTypeRequestBody() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseTypeRequestBody(LicenseTypeRequestBody template) + { + super(template); + + if (template != null) + { + this.properties = template.getProperties(); + this.initialStatus = template.getInitialStatus(); + } + } + + + /** + * Return the properties of the license type. + * + * @return properties + */ + public LicenseTypeProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties of the license type. + * + * @param properties properties + */ + public void setProperties(LicenseTypeProperties properties) + { + this.properties = properties; + } + + + /** + * Return the initial status of the license type. + * + * @return instance status + */ + public GovernanceDefinitionStatus getInitialStatus() + { + return initialStatus; + } + + + /** + * Set up the initial status of the license type. + * + * @param initialStatus instance status + */ + public void setInitialStatus(GovernanceDefinitionStatus initialStatus) + { + this.initialStatus = initialStatus; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "LicenseTypeRequestBody{" + + "properties=" + properties + + ", initialStatus=" + initialStatus + + '}'; + } + + + /** + * 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; + } + LicenseTypeRequestBody that = (LicenseTypeRequestBody) objectToCompare; + return Objects.equals(properties, that.properties) && + initialStatus == that.initialStatus; + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(properties, initialStatus); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeResponse.java new file mode 100644 index 00000000000..04f88a30a67 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/LicenseTypeResponse.java @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseTypeElement; + +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; + + +/** + * LicenseTypeResponse is the response structure used on the OMAS REST API calls that returns a + * license type object as a response. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class LicenseTypeResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private LicenseTypeElement element = null; + + + /** + * Default constructor + */ + public LicenseTypeResponse() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public LicenseTypeResponse(LicenseTypeResponse template) + { + super(template); + + if (template != null) + { + this.element = template.getElement(); + } + } + + + /** + * Return the element result. + * + * @return LicenseTypeProperties object + */ + public LicenseTypeElement getElement() + { + return element; + } + + + /** + * Set up the element result. + * + * @param element LicenseTypeProperties object + */ + public void setElement(LicenseTypeElement element) + { + this.element = element; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "LicenseTypeResponse{" + + "element='" + getElement() + '\'' + + ", 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 LicenseTypeResponse)) + { + return false; + } + if (!super.equals(objectToCompare)) + { + return false; + } + LicenseTypeResponse that = (LicenseTypeResponse) objectToCompare; + return Objects.equals(element, that.element); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), element); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ReferenceableRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ReferenceableRequestBody.java index 8c5d5d81bdf..2f73fd51705 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ReferenceableRequestBody.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ReferenceableRequestBody.java @@ -4,8 +4,7 @@ package org.odpi.openmetadata.accessservices.assetowner.rest; import com.fasterxml.jackson.annotation.*; -import org.odpi.openmetadata.accessservices.assetowner.properties.MeaningProperties; -import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementClassification; +import org.odpi.openmetadata.accessservices.assetowner.properties.ReferenceableProperties; import java.util.*; @@ -29,12 +28,9 @@ public class ReferenceableRequestBody extends AssetOwnerOMASAPIRequestBody { private static final long serialVersionUID = 1L; - private String typeName = null; - private List classifications = null; - private String qualifiedName = null; - private List meanings = null; - private Map additionalProperties = null; - private Map extendedProperties = null; + private String anchorGUID = null; + private ReferenceableProperties properties = null; + /** @@ -56,183 +52,54 @@ public ReferenceableRequestBody(ReferenceableRequestBody template) if (template != null) { - this.typeName = template.getTypeName(); - this.classifications = template.getClassifications(); - this.qualifiedName = template.getQualifiedName(); - this.meanings = template.getMeanings(); - this.additionalProperties = template.getAdditionalProperties(); - this.extendedProperties = template.getExtendedProperties(); + anchorGUID = template.getAnchorGUID(); + properties = template.getProperties(); } } - /** - * Return the open metadata type name of this object - this is used to create a subtype of - * the referenceable. Any properties associated with this subtype are passed as extended properties. - * - * @return string type name - */ - public String getTypeName() - { - return typeName; - } - - - /** - * Set up the open metadata type name of this object - this is used to create a subtype of - * the referenceable. Any properties associated with this subtype are passed as extended properties. - * - * @param typeName string type name - */ - public void setTypeName(String typeName) - { - this.typeName = typeName; - } - /** - * Return the classifications associated with this referenceable. + * Return the properties for the relationship. * - * @return list of classifications with their properties + * @return properties object */ - public List getClassifications() + public ReferenceableProperties getProperties() { - return classifications; + return properties; } /** - * Set up the list of classifications associated with this referenceable. + * Set up the properties for the relationship. * - * @param classifications list of classifications with their properties + * @param properties properties object */ - public void setClassifications(List classifications) + public void setProperties(ReferenceableProperties properties) { - this.classifications = classifications; + this.properties = properties; } /** - * Returns the stored qualified name property for the metadata entity. - * If no qualified name is available then the empty string is returned. + * Return an optional anchor GUID to attach the new element to. * - * @return qualifiedName + * @return guid */ - public String getQualifiedName() + public String getAnchorGUID() { - return qualifiedName; + return anchorGUID; } /** - * Set up the fully qualified name. + * Set up an optional anchor GUID to attach the new element to. * - * @param qualifiedName String name + * @param anchorGUID guid */ - public void setQualifiedName(String qualifiedName) + public void setAnchorGUID(String anchorGUID) { - this.qualifiedName = qualifiedName; - } - - - /** - * Return a copy of the additional properties. Null means no additional properties are available. - * - * @return AdditionalProperties - */ - public Map getAdditionalProperties() - { - if (additionalProperties == null) - { - return null; - } - else if (additionalProperties.isEmpty()) - { - return null; - } - else - { - return new HashMap<>(additionalProperties); - } - } - - - /** - * Set up additional properties. - * - * @param additionalProperties Additional properties object - */ - public void setAdditionalProperties(Map additionalProperties) - { - this.additionalProperties = additionalProperties; - } - - - /** - * Return the assigned meanings for this metadata entity. - * - * @return list of meanings - */ - public List getMeanings() - { - if (meanings == null) - { - return null; - } - else if (meanings.isEmpty()) - { - return null; - } - else - { - return new ArrayList<>(meanings); - } - } - - - /** - * Set up the assigned meanings for this metadata entity. - * - * @param meanings list of meanings - */ - public void setMeanings(List meanings) - { - this.meanings = meanings; - } - - - /** - * Return the properties that are defined for a subtype of referenceable but are not explicitly - * supported by the bean. - * - * @return map of properties - */ - public Map getExtendedProperties() - { - if (extendedProperties == null) - { - return null; - } - else if (extendedProperties.isEmpty()) - { - return null; - } - else - { - return new HashMap<>(extendedProperties); - } - } - - - /** - * Set up the properties that are defined for a subtype of referenceable but are not explicitly - * supported by the bean. - * - * @param extendedProperties map of properties - */ - public void setExtendedProperties(Map extendedProperties) - { - this.extendedProperties = extendedProperties; + this.anchorGUID = anchorGUID; } @@ -245,13 +112,9 @@ public void setExtendedProperties(Map extendedProperties) public String toString() { return "ReferenceableRequestBody{" + - "typeName='" + typeName + '\'' + - ", classifications=" + classifications + - ", qualifiedName='" + qualifiedName + '\'' + - ", meanings=" + meanings + - ", additionalProperties=" + additionalProperties + - ", extendedProperties=" + extendedProperties + - '}'; + "anchorGUID='" + anchorGUID + '\'' + + ", properties=" + properties + + '}'; } @@ -268,17 +131,16 @@ public boolean equals(Object objectToCompare) { return true; } - if (objectToCompare == null || getClass() != objectToCompare.getClass()) + if (! (objectToCompare instanceof ReferenceableRequestBody)) + { + return false; + } + if (! super.equals(objectToCompare)) { return false; } ReferenceableRequestBody that = (ReferenceableRequestBody) objectToCompare; - return Objects.equals(getTypeName(), that.getTypeName()) && - Objects.equals(getClassifications(), that.getClassifications()) && - Objects.equals(getQualifiedName(), that.getQualifiedName()) && - Objects.equals(getMeanings(), that.getMeanings()) && - Objects.equals(getAdditionalProperties(), that.getAdditionalProperties()) && - Objects.equals(getExtendedProperties(), that.getExtendedProperties()); + return Objects.equals(anchorGUID, that.anchorGUID) && Objects.equals(properties, that.properties); } @@ -291,7 +153,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(getTypeName(), getClassifications(), getQualifiedName(), getMeanings(), - getAdditionalProperties(), getExtendedProperties()); + return Objects.hash(super.hashCode(), anchorGUID, properties); } } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelatedElementListResponse.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelatedElementListResponse.java new file mode 100644 index 00000000000..ef4610c525f --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelatedElementListResponse.java @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; + +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; + +/** + * RelatedElementListResponse is a response object for passing back a list of relatedElement objects. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class RelatedElementListResponse extends AssetOwnerOMASAPIResponse +{ + private static final long serialVersionUID = 1L; + + private List elementList = null; + + + /** + * Default constructor + */ + public RelatedElementListResponse() + { + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public RelatedElementListResponse(RelatedElementListResponse 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 elementList; + } + } + + + /** + * Set up the list of metadata elements to return. + * + * @param elements result object + */ + public void setElementList(List elements) + { + this.elementList = elements; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "RelatedElementListResponse{" + + "element=" + 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; + } + RelatedElementListResponse that = (RelatedElementListResponse) 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-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelationshipRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelationshipRequestBody.java new file mode 100644 index 00000000000..0436b99cd5d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/RelationshipRequestBody.java @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.rest; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * RelationshipRequestBody describes the request body used when linking elements together. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class RelationshipRequestBody extends ExternalSourceRequestBody +{ + private static final long serialVersionUID = 1L; + + private String relationshipName = null; + private RelationshipProperties properties = null; + + + /** + * Default constructor + */ + public RelationshipRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template object to copy + */ + public RelationshipRequestBody(RelationshipRequestBody template) + { + super(template); + + if (template != null) + { + relationshipName = template.getRelationshipName(); + properties = template.getProperties(); + } + } + + + /** + * Return the name of the relationship type. + * + * @return type name + */ + public String getRelationshipName() + { + return relationshipName; + } + + + /** + * Set up the name of the relationship type. + * + * @param relationshipName type name + */ + public void setRelationshipName(String relationshipName) + { + this.relationshipName = relationshipName; + } + + + /** + * Return the properties for the relationship. + * + * @return properties object + */ + public RelationshipProperties getProperties() + { + return properties; + } + + + /** + * Set up the properties for the relationship. + * + * @param properties properties object + */ + public void setProperties(RelationshipProperties properties) + { + this.properties = properties; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "RelationshipRequestBody{" + + "externalSourceGUID='" + getExternalSourceGUID() + '\'' + + ", externalSourceName='" + getExternalSourceName() + '\'' + + ", relationshipTypeName=" + relationshipName + + ", properties=" + properties + + '}'; + } + + + /** + * 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; + } + RelationshipRequestBody that = (RelationshipRequestBody) objectToCompare; + return Objects.equals(getProperties(), that.getProperties()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), relationshipName, properties); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ValidValuesRequestBody.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ValidValuesRequestBody.java index 71afb2ce92c..8a6e664f012 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ValidValuesRequestBody.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-api/src/main/java/org/odpi/openmetadata/accessservices/assetowner/rest/ValidValuesRequestBody.java @@ -5,7 +5,13 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetowner.properties.MeaningProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementClassification; +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; @@ -17,16 +23,22 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class ValidValuesRequestBody extends ReferenceableRequestBody +public class ValidValuesRequestBody extends AssetOwnerOMASAPIRequestBody { private static final long serialVersionUID = 1L; - private String displayName = null; - private String description = null; - private String usage = null; - private String scope = null; - private String preferredValue = null; - private boolean isDeprecated = false; + private String typeName = null; + private List classifications = null; + private String qualifiedName = null; + private List meanings = null; + private Map additionalProperties = null; + private Map extendedProperties = null; + private String displayName = null; + private String description = null; + private String usage = null; + private String scope = null; + private String preferredValue = null; + private boolean isDeprecated = false; /** @@ -49,6 +61,12 @@ public ValidValuesRequestBody(ValidValuesRequestBody template) if (template != null) { + this.typeName = template.getTypeName(); + this.classifications = template.getClassifications(); + this.qualifiedName = template.getQualifiedName(); + this.meanings = template.getMeanings(); + this.additionalProperties = template.getAdditionalProperties(); + this.extendedProperties = template.getExtendedProperties(); displayName = template.getDisplayName(); description = template.getDescription(); usage = template.getUsage(); @@ -59,6 +77,176 @@ public ValidValuesRequestBody(ValidValuesRequestBody template) } + /** + * Return the open metadata type name of this object - this is used to create a subtype of + * the referenceable. Any properties associated with this subtype are passed as extended properties. + * + * @return string type name + */ + public String getTypeName() + { + return typeName; + } + + + /** + * Set up the open metadata type name of this object - this is used to create a subtype of + * the referenceable. Any properties associated with this subtype are passed as extended properties. + * + * @param typeName string type name + */ + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + + /** + * Return the classifications associated with this referenceable. + * + * @return list of classifications with their properties + */ + public List getClassifications() + { + return classifications; + } + + + /** + * Set up the list of classifications associated with this referenceable. + * + * @param classifications list of classifications with their properties + */ + public void setClassifications(List classifications) + { + this.classifications = classifications; + } + + + /** + * Returns the stored qualified name property for the metadata entity. + * If no qualified name is available then the empty string is returned. + * + * @return qualifiedName + */ + public String getQualifiedName() + { + return qualifiedName; + } + + + /** + * Set up the fully qualified name. + * + * @param qualifiedName String name + */ + public void setQualifiedName(String qualifiedName) + { + this.qualifiedName = qualifiedName; + } + + + /** + * Return a copy of the additional properties. Null means no additional properties are available. + * + * @return AdditionalProperties + */ + public Map getAdditionalProperties() + { + if (additionalProperties == null) + { + return null; + } + else if (additionalProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(additionalProperties); + } + } + + + /** + * Set up additional properties. + * + * @param additionalProperties Additional properties object + */ + public void setAdditionalProperties(Map additionalProperties) + { + this.additionalProperties = additionalProperties; + } + + + /** + * Return the assigned meanings for this metadata entity. + * + * @return list of meanings + */ + public List getMeanings() + { + if (meanings == null) + { + return null; + } + else if (meanings.isEmpty()) + { + return null; + } + else + { + return new ArrayList<>(meanings); + } + } + + + /** + * Set up the assigned meanings for this metadata entity. + * + * @param meanings list of meanings + */ + public void setMeanings(List meanings) + { + this.meanings = meanings; + } + + + /** + * Return the properties that are defined for a subtype of referenceable but are not explicitly + * supported by the bean. + * + * @return map of properties + */ + public Map getExtendedProperties() + { + if (extendedProperties == null) + { + return null; + } + else if (extendedProperties.isEmpty()) + { + return null; + } + else + { + return new HashMap<>(extendedProperties); + } + } + + + /** + * Set up the properties that are defined for a subtype of referenceable but are not explicitly + * supported by the bean. + * + * @param extendedProperties map of properties + */ + public void setExtendedProperties(Map extendedProperties) + { + this.extendedProperties = extendedProperties; + } + + /** * Returns the stored display name property for the valid value. * If no display name is available then null is returned. @@ -202,7 +390,13 @@ public void setIsDeprecated(boolean deprecated) public String toString() { return "ValidValuesRequestBody{" + - "displayName='" + displayName + '\'' + + "typeName='" + typeName + '\'' + + ", classifications=" + classifications + + ", qualifiedName='" + qualifiedName + '\'' + + ", meanings=" + meanings + + ", additionalProperties=" + additionalProperties + + ", extendedProperties=" + extendedProperties + + ", displayName='" + displayName + '\'' + ", description='" + description + '\'' + ", usage='" + usage + '\'' + ", scope='" + scope + '\'' + @@ -240,7 +434,13 @@ public boolean equals(Object objectToCompare) return false; } ValidValuesRequestBody that = (ValidValuesRequestBody) objectToCompare; - return Objects.equals(displayName, that.displayName) && + return Objects.equals(getTypeName(), that.getTypeName()) && + Objects.equals(getClassifications(), that.getClassifications()) && + Objects.equals(getQualifiedName(), that.getQualifiedName()) && + Objects.equals(getMeanings(), that.getMeanings()) && + Objects.equals(getAdditionalProperties(), that.getAdditionalProperties()) && + Objects.equals(getExtendedProperties(), that.getExtendedProperties()) && + Objects.equals(displayName, that.displayName) && Objects.equals(description, that.description) && Objects.equals(usage, that.usage) && Objects.equals(scope, that.scope) && @@ -257,6 +457,8 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), displayName, description, usage, scope, isDeprecated, preferredValue); + return Objects.hash(super.hashCode(), getTypeName(), getClassifications(), getQualifiedName(), getMeanings(), + getAdditionalProperties(), getExtendedProperties(), + displayName, description, usage, scope, isDeprecated, preferredValue); } } \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetCertificationManager.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetCertificationManager.java new file mode 100644 index 00000000000..cf5ac041745 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetCertificationManager.java @@ -0,0 +1,469 @@ +/* SPDX-Certification-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.client; + +import org.odpi.openmetadata.accessservices.assetowner.api.AssetCertificationInterface; +import org.odpi.openmetadata.accessservices.assetowner.client.rest.AssetOwnerRESTClient; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.CertificationTypeListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.CertificationTypeResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +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; + +/** + * AssetCertificationManager is the java client for managing certification types and the certification of elements. + */ +public class AssetCertificationManager extends AssetOwnerBaseClient implements AssetCertificationInterface +{ + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * + * @throws InvalidParameterException bad input parameters + */ + public AssetCertificationManager(String serverName, + String serverPlatformURLRoot) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * + * @throws InvalidParameterException bad input parameters + */ + public AssetCertificationManager(String serverName, + String serverPlatformURLRoot, + String userId, + String password) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, userId, password); + } + + + + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException bad input parameters + */ + public AssetCertificationManager(String serverName, + String serverPlatformURLRoot, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, maxPageSize, auditLog); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException bad input parameters + */ + public AssetCertificationManager(String serverName, + String serverPlatformURLRoot, + String userId, + String password, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, userId, password, maxPageSize, auditLog); + } + + + /** + * Create a new client that uses the supplied rest client. This is typically used when called from another OMAG Server. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param restClient internal client for rest calls + * @param maxPageSize pre-initialized parameter limit + * + * @throws InvalidParameterException bad input parameters + */ + public AssetCertificationManager(String serverName, + String serverPlatformURLRoot, + AssetOwnerRESTClient restClient, + int maxPageSize) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, restClient, maxPageSize); + } + + /* ======================================== + * Certification Types + */ + + /** + * Retrieve the certification type by the unique identifier assigned by this service when it was created. + * + * @param userId calling user + * @param certificationTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the certification type + * + * @throws InvalidParameterException guid or userId is null; guid is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public CertificationTypeElement getCertificationTypeByGUID(String userId, + String certificationTypeGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getCertificationTypeByGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/certification-types/{2}"; + + final String guidParameterName = "certificationTypeGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(certificationTypeGUID, guidParameterName, methodName); + + CertificationTypeResponse restResult = restClient.callCertificationTypeGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + certificationTypeGUID); + + return restResult.getElement(); + } + + + /** + * Retrieve the certification type by its assigned unique document identifier. + * + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching certification type + * + * @throws InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public CertificationTypeElement getCertificationTypeByDocId(String userId, + String documentIdentifier) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getCertificationTypeByDocId"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/certification-types/by-document-id/{2}"; + + final String documentIdParameterName = "documentId"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(documentIdentifier, documentIdParameterName, methodName); + + CertificationTypeResponse restResult = restClient.callCertificationTypeGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + documentIdentifier); + + return restResult.getElement(); + } + + + /** + * Retrieve all the certification types for a particular title. The title can include regEx wildcards. + * + * @param userId calling user + * @param title short description of the certification + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching certification types (null if no matching elements) + * + * @throws InvalidParameterException title or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getCertificationTypesByTitle(String userId, + String title, + int startFrom, + int pageSize) throws UserNotAuthorizedException, + InvalidParameterException, + PropertyServerException + { + final String methodName = "getCertificationTypesByTitle"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/certification-types/by-title?startFrom={2}&pageSize={3}"; + final String titleParameterName = "title"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateSearchString(title, titleParameterName, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + SearchStringRequestBody requestBody = new SearchStringRequestBody(); + requestBody.setSearchString(title); + requestBody.setSearchStringParameterName(titleParameterName); + + CertificationTypeListResponse restResult = restClient.callCertificationTypeListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /** + * Retrieve all the certification type definitions for a specific governance domain. + * + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching certification type definitions + * + * @throws InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getCertificationTypeByDomainId(String userId, + int domainIdentifier, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getCertificationTypeByDomainId"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/certification-types/by-domain/{2}?startFrom={3}&pageSize={4}"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + invalidParameterHandler.validateUserId(userId, methodName); + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + CertificationTypeListResponse restResult = restClient.callCertificationTypeListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + domainIdentifier, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /* ======================================= + * Certifications + */ + + /** + * Link an element to a certification type and include details of the certification in the relationship properties. + * + * @param userId calling user + * @param elementGUID unique identifier of the element being certified + * @param certificationTypeGUID unique identifier for the certification type + * @param properties the properties of the certification + * + * @return unique identifier of the new relationship + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public String certifyElement(String userId, + String elementGUID, + String certificationTypeGUID, + CertificationProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "certifyElement"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/certification-types/{3}/certify"; + + final String elementGUIDParameterName = "elementGUID"; + final String certificationTypeGUIDParameterName = "certificationTypeGUID"; + + return super.setupMultiLinkRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + properties, + certificationTypeGUID, + certificationTypeGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Update the properties of a certification. + * + * @param userId calling user + * @param certificationGUID unique identifier of the certification relationship being updated + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param properties the properties of the certification + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void updateCertification(String userId, + String certificationGUID, + boolean isMergeUpdate, + CertificationProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateCertification"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/certifications/{2}/update?isMergeUpdate={3}"; + + final String certificationGUIDParameterName = "certificationGUID"; + + super.updateRelationship(userId, + certificationGUID, + certificationGUIDParameterName, + isMergeUpdate, + null, + properties, + urlTemplate, + methodName); + } + + + /** + * Remove the certification for an element. + * + * @param userId calling user + * @param certificationGUID unique identifier of the certification relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void decertifyElement(String userId, + String certificationGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "decertifyElement"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/certifications/{2}/delete"; + + final String certificationGUIDParameterName = "certificationGUID"; + + super.clearRelationship(userId, + certificationGUID, + certificationGUIDParameterName, + null, + urlTemplate, + methodName); + } + + + + /** + * Return information about the elements linked to a certification. + * + * @param userId calling user + * @param certificationTypeGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getCertifiedElements(String userId, + String certificationTypeGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getCertifiedElements"; + final String guidParameter = "certificationTypeGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/certifications/{2}?&startFrom={3}&pageSize={4}"; + + return super.getRelatedElements(userId, certificationTypeGUID, guidParameter, urlTemplate, startFrom, pageSize, methodName); + } + + + /** + * Return information about the certifications linked to an element. + * + * @param userId calling user + * @param elementGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getCertifications(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getLicences"; + final String guidParameterName = "elementGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/certifications?&startFrom={3}&pageSize={4}"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameterName, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + RelatedElementListResponse restResult = restClient.callRelatedElementListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + elementGUID, + startFrom, + queryPageSize); + + return restResult.getElementList(); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetLicenseManager.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetLicenseManager.java new file mode 100644 index 00000000000..0f2a30a0911 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetLicenseManager.java @@ -0,0 +1,471 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.client; + +import org.odpi.openmetadata.accessservices.assetowner.api.AssetLicenseInterface; +import org.odpi.openmetadata.accessservices.assetowner.client.rest.AssetOwnerRESTClient; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseTypeListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseTypeResponse; +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; + +/** + * AssetLicenseManager is the java client for managing license types and the licensing of elements. + */ +public class AssetLicenseManager extends AssetOwnerBaseClient implements AssetLicenseInterface +{ + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * + * @throws InvalidParameterException bad input parameters + */ + public AssetLicenseManager(String serverName, + String serverPlatformURLRoot) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * + * @throws InvalidParameterException bad input parameters + */ + public AssetLicenseManager(String serverName, + String serverPlatformURLRoot, + String userId, + String password) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, userId, password); + } + + + + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException bad input parameters + */ + public AssetLicenseManager(String serverName, + String serverPlatformURLRoot, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, maxPageSize, auditLog); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException bad input parameters + */ + public AssetLicenseManager(String serverName, + String serverPlatformURLRoot, + String userId, + String password, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, userId, password, maxPageSize, auditLog); + } + + + /** + * Create a new client that uses the supplied rest client. This is typically used when called from another OMAG Server. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param restClient internal client for rest calls + * @param maxPageSize pre-initialized parameter limit + * + * @throws InvalidParameterException bad input parameters + */ + public AssetLicenseManager(String serverName, + String serverPlatformURLRoot, + AssetOwnerRESTClient restClient, + int maxPageSize) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, restClient, maxPageSize); + } + + + /* ======================================== + * License Types + */ + + + /** + * Retrieve the license type by the unique identifier assigned by this service when it was created. + * + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the license type + * + * @throws InvalidParameterException guid or userId is null; guid is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public LicenseTypeElement getLicenseTypeByGUID(String userId, + String licenseTypeGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getLicenseTypeByGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/license-types/{2}"; + + final String guidParameterName = "licenseTypeGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(licenseTypeGUID, guidParameterName, methodName); + + LicenseTypeResponse restResult = restClient.callLicenseTypeGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + licenseTypeGUID); + + return restResult.getElement(); + } + + + /** + * Retrieve the license type by its assigned unique document identifier. + * + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching license type + * + * @throws InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public LicenseTypeElement getLicenseTypeByDocId(String userId, + String documentIdentifier) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getLicenseTypeByDocId"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/license-types/by-document-id/{2}"; + + final String documentIdParameterName = "documentId"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(documentIdentifier, documentIdParameterName, methodName); + + LicenseTypeResponse restResult = restClient.callLicenseTypeGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + documentIdentifier); + + return restResult.getElement(); + } + + + /** + * Retrieve all the license types for a particular title. The title can include regEx wildcards. + * + * @param userId calling user + * @param title short description of the license + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching roles (null if no matching elements) + * + * @throws InvalidParameterException title or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getLicenseTypesByTitle(String userId, + String title, + int startFrom, + int pageSize) throws UserNotAuthorizedException, + InvalidParameterException, + PropertyServerException + { + final String methodName = "getLicenseTypesByTitle"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/license-types/by-title?startFrom={2}&pageSize={3}"; + final String titleParameterName = "title"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateSearchString(title, titleParameterName, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + SearchStringRequestBody requestBody = new SearchStringRequestBody(); + requestBody.setSearchString(title); + requestBody.setSearchStringParameterName(titleParameterName); + + LicenseTypeListResponse restResult = restClient.callLicenseTypeListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /** + * Retrieve all the license type definitions for a specific governance domain. + * + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching license type definitions + * + * @throws InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getLicenseTypeByDomainId(String userId, + int domainIdentifier, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getLicenseTypeByDomainId"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/license-types/by-domain/{2}?startFrom={3}&pageSize={4}"; + + invalidParameterHandler.validateUserId(userId, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + LicenseTypeListResponse restResult = restClient.callLicenseTypeListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + domainIdentifier, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /* ======================================= + * Licenses + */ + + /** + * Link an element to a license type and include details of the license in the relationship properties. + * + * @param userId calling user + * @param elementGUID unique identifier of the element being certified + * @param licenseTypeGUID unique identifier for the license type + * @param properties the properties of the license + * + * @return unique identifier of the new relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public String licenseElement(String userId, + String elementGUID, + String licenseTypeGUID, + LicenseProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "licenseElement"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/license-types/{3}"; + + final String elementGUIDParameterName = "elementGUID"; + final String licenseTypeGUIDParameterName = "licenseTypeGUID"; + + return super.setupMultiLinkRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + properties, + licenseTypeGUID, + licenseTypeGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Update the properties of a license. + * + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param properties the properties of the license + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void updateLicense(String userId, + String licenseGUID, + boolean isMergeUpdate, + LicenseProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateLicense"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/licenses/{2}/update?isMergeUpdate={3}"; + + final String licenseGUIDParameterName = "licenseGUID"; + + super.updateRelationship(userId, + licenseGUID, + licenseGUIDParameterName, + isMergeUpdate, + null, + properties, + urlTemplate, + methodName); + } + + + /** + * Remove the license for an element. + * + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void unlicenseElement(String userId, + String licenseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "unlicenseElement"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/licenses/{2}/delete"; + + final String licenseGUIDParameterName = "licenseGUID"; + + super.clearRelationship(userId, + licenseGUID, + licenseGUIDParameterName, + null, + urlTemplate, + methodName); + } + + + /** + * Return information about the elements linked to a license. + * + * @param userId calling user + * @param licenseGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the subject area + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getLicensedElements(String userId, + String licenseGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getLicencedElements"; + final String guidParameter = "licenseGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/licenses/{2}?&startFrom={3}&pageSize={4}"; + + return super.getRelatedElements(userId, licenseGUID, guidParameter, urlTemplate, startFrom, pageSize, methodName); + } + + + /** + * Return information about the licenses linked to an element. + * + * @param userId calling user + * @param elementGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the subject area + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getLicenses(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getLicences"; + final String guidParameterName = "elementGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/licenses?&startFrom={3}&pageSize={4}"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, guidParameterName, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + LicenseListResponse restResult = restClient.callLicenseListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + elementGUID, + startFrom, + queryPageSize); + + return restResult.getElements(); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwnerBaseClient.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwnerBaseClient.java new file mode 100644 index 00000000000..55b6c85158e --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/AssetOwnerBaseClient.java @@ -0,0 +1,1162 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.client; + + +import org.odpi.openmetadata.accessservices.assetowner.api.RelatedElementsManagementInterface; +import org.odpi.openmetadata.accessservices.assetowner.client.rest.AssetOwnerRESTClient; +import org.odpi.openmetadata.accessservices.assetowner.properties.ClassificationProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.StakeholderProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.ElementStubListResponse; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.ReferenceableProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.ResourceListProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.ClassificationRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.ReferenceableRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NullRequestBody; +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.frameworks.connectors.properties.beans.ElementStub; + +import java.util.List; + +/** + * AssetOwnerBaseClient supports the common properties and functions for the Community Profile OMAS. + */ +public class AssetOwnerBaseClient implements RelatedElementsManagementInterface +{ + final String serverName; /* Initialized in constructor */ + final String serverPlatformURLRoot; /* Initialized in constructor */ + + final InvalidParameterHandler invalidParameterHandler = new InvalidParameterHandler(); + final AssetOwnerRESTClient restClient; /* Initialized in constructor */ + + private static final String elementsURLTemplatePrefix = "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/related-elements"; + + protected NullRequestBody nullRequestBody = new NullRequestBody(); + + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException there is a problem creating the client-side components to issue any + * REST API calls. + */ + public AssetOwnerBaseClient(String serverName, + String serverPlatformURLRoot, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + final String methodName = "Client Constructor"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + + this.serverName = serverName; + this.serverPlatformURLRoot = serverPlatformURLRoot; + + invalidParameterHandler.setMaxPagingSize(maxPageSize); + + this.restClient = new AssetOwnerRESTClient(serverName, serverPlatformURLRoot, auditLog); + } + + + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * + * @throws InvalidParameterException there is a problem creating the client-side components to issue any + * REST API calls. + */ + public AssetOwnerBaseClient(String serverName, + String serverPlatformURLRoot) throws InvalidParameterException + { + final String methodName = "Client Constructor"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + + this.serverName = serverName; + this.serverPlatformURLRoot = serverPlatformURLRoot; + + this.restClient = new AssetOwnerRESTClient(serverName, serverPlatformURLRoot); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * + * @throws InvalidParameterException there is a problem creating the client-side components to issue any + * REST API calls. + */ + public AssetOwnerBaseClient(String serverName, + String serverPlatformURLRoot, + String userId, + String password) throws InvalidParameterException + { + final String methodName = "Client Constructor"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + + this.serverName = serverName; + this.serverPlatformURLRoot = serverPlatformURLRoot; + + this.restClient = new AssetOwnerRESTClient(serverName, serverPlatformURLRoot, userId, password); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException there is a problem creating the client-side components to issue any + * REST API calls. + */ + public AssetOwnerBaseClient(String serverName, + String serverPlatformURLRoot, + String userId, + String password, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + final String methodName = "Client Constructor"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + + this.serverName = serverName; + this.serverPlatformURLRoot = serverPlatformURLRoot; + + invalidParameterHandler.setMaxPagingSize(maxPageSize); + + this.restClient = new AssetOwnerRESTClient(serverName, serverPlatformURLRoot, userId, password, auditLog); + } + + + /** + * Create a new client that is going to be used in an OMAG Server. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param restClient client that issues the REST API calls + * @param maxPageSize maximum number of results supported by this server + * + * @throws InvalidParameterException there is a problem creating the client-side components to issue any + * REST API calls. + */ + public AssetOwnerBaseClient(String serverName, + String serverPlatformURLRoot, + AssetOwnerRESTClient restClient, + int maxPageSize) throws InvalidParameterException + { + final String methodName = "Client Constructor"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + + this.serverName = serverName; + this.serverPlatformURLRoot = serverPlatformURLRoot; + + invalidParameterHandler.setMaxPagingSize(maxPageSize); + + this.restClient = restClient; + } + + + /* ===================================================================================================================== + * Basic client methods + */ + + + /** + * Create a new metadata element. + * + * @param userId calling user + * @param properties properties about the element to store + * @param propertiesParameterName name of parameter passing the properties + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @return unique identifier of the new element + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + String createReferenceable(String userId, + ReferenceableProperties properties, + String propertiesParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String qualifiedNameParameterName = "qualifiedName"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateObject(properties, propertiesParameterName, methodName); + invalidParameterHandler.validateName(properties.getQualifiedName(), qualifiedNameParameterName, methodName); + + ReferenceableRequestBody requestBody = new ReferenceableRequestBody(); + + requestBody.setProperties(properties); + + GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId); + + return restResult.getGUID(); + } + + + /** + * Create a new metadata element. + * + * @param userId calling user + * @param properties properties about the element to store + * @param propertiesParameterName name of parameter passing the properties + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @return unique identifier of the new element + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + String createReferenceableWithAnchor(String userId, + String anchorGUID, + String anchorGUIDParameterName, + ReferenceableProperties properties, + String propertiesParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String qualifiedNameParameterName = "qualifiedName"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(anchorGUID, anchorGUIDParameterName, methodName); + invalidParameterHandler.validateObject(properties, propertiesParameterName, methodName); + invalidParameterHandler.validateName(properties.getQualifiedName(), qualifiedNameParameterName, methodName); + + ReferenceableRequestBody requestBody = new ReferenceableRequestBody(); + + requestBody.setAnchorGUID(anchorGUID); + requestBody.setProperties(properties); + + GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId); + + return restResult.getGUID(); + } + + + + /** + * Update the metadata element. It is possible to use the subtype property classes or + * set up specialized properties in extended properties. + * + * @param userId calling user + * @param elementGUID unique identifier of the metadata element to update + * @param elementGUIDParameterName name of parameter passing the elementGUID + * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? + * @param properties new properties for the metadata element + * @param propertiesParameterName name of parameter passing the properties + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @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 updateReferenceable(String userId, + String elementGUID, + String elementGUIDParameterName, + boolean isMergeUpdate, + ReferenceableProperties properties, + String propertiesParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String qualifiedNameParameterName = "qualifiedName"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameterName, methodName); + invalidParameterHandler.validateObject(properties, propertiesParameterName, methodName); + + if (! isMergeUpdate) + { + invalidParameterHandler.validateName(properties.getQualifiedName(), qualifiedNameParameterName, methodName); + } + + ReferenceableRequestBody requestBody = new ReferenceableRequestBody(); + + requestBody.setProperties(properties); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + elementGUID, + isMergeUpdate); + } + + + /** + * Add or update classification on referenceable. + * + * @param userId calling user + * @param elementGUID unique identifier of the metadata element to classify + * @param elementGUIDParameter parameter name for elementGUID + * @param properties properties of security at the site + * @param urlTemplate URL to call with placeholder for guid + * @param methodName calling method + * + * @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 setReferenceableClassification(String userId, + String elementGUID, + String elementGUIDParameter, + ClassificationProperties properties, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameter, methodName); + + ClassificationRequestBody requestBody = new ClassificationRequestBody(); + + requestBody.setProperties(properties); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + elementGUID); + } + + + /** + * Remove classification from the referenceable. + * + * @param userId calling user + * @param elementGUID unique identifier of the metadata element to classify + * @param elementGUIDParameter parameter name for elementGUID + * @param urlTemplate URL to call with placeholder for guid + * @param methodName calling method + * + * @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 removeReferenceableClassification(String userId, + String elementGUID, + String elementGUIDParameter, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameter, methodName); + + ExternalSourceRequestBody requestBody = new ExternalSourceRequestBody(); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + elementGUID); + } + + + /** + * Create a relationship between a primary element and a secondary element. + * + * @param userId calling user + * @param primaryElementGUID unique identifier of the primary element + * @param primaryElementGUIDParameterName name of parameter passing the primaryElementGUID + * @param relationshipName type name of relationship + * @param properties describes the properties for the relationship + * @param secondaryElementGUID unique identifier of the element to connect it to + * @param secondaryElementGUIDParameterName name of parameter passing the secondaryElementGUID + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @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 setupRelationship(String userId, + String primaryElementGUID, + String primaryElementGUIDParameterName, + String relationshipName, + RelationshipProperties properties, + String secondaryElementGUID, + String secondaryElementGUIDParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(primaryElementGUID, primaryElementGUIDParameterName, methodName); + invalidParameterHandler.validateGUID(secondaryElementGUID, secondaryElementGUIDParameterName, methodName); + + RelationshipRequestBody requestBody = new RelationshipRequestBody(); + + requestBody.setRelationshipName(relationshipName); + requestBody.setProperties(properties); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + primaryElementGUID, + secondaryElementGUID); + } + + + /** + * Create a relationship between a primary element and a secondary element. + * + * @param userId calling user + * @param primaryElementGUID unique identifier of the primary element + * @param primaryElementGUIDParameterName name of parameter passing the primaryElementGUID + * @param relationshipName type name of relationship + * @param properties describes the properties for the relationship + * @param secondaryElementGUID unique identifier of the element to connect it to + * @param secondaryElementGUIDParameterName name of parameter passing the secondaryElementGUID + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @return unique identifier of the new relationship + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + String setupMultiLinkRelationship(String userId, + String primaryElementGUID, + String primaryElementGUIDParameterName, + String relationshipName, + RelationshipProperties properties, + String secondaryElementGUID, + String secondaryElementGUIDParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(primaryElementGUID, primaryElementGUIDParameterName, methodName); + invalidParameterHandler.validateGUID(secondaryElementGUID, secondaryElementGUIDParameterName, methodName); + + RelationshipRequestBody requestBody = new RelationshipRequestBody(); + + requestBody.setRelationshipName(relationshipName); + requestBody.setProperties(properties); + + GUIDResponse response = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + primaryElementGUID, + secondaryElementGUID); + + return response.getGUID(); + } + + + /** + * Update the properties of a multi-link relationship. + * + * @param userId calling user + * @param relationshipGUID unique identifier of the primary element + * @param relationshipGUIDParameterName name of parameter passing the relationshipGUID + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param relationshipName type name of relationship + * @param properties describes the properties for the relationship + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @throws InvalidParameterException one of the properties is invalid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void updateRelationship(String userId, + String relationshipGUID, + String relationshipGUIDParameterName, + boolean isMergeUpdate, + String relationshipName, + RelationshipProperties properties, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(relationshipGUID, relationshipGUIDParameterName, methodName); + + RelationshipRequestBody requestBody = new RelationshipRequestBody(); + + requestBody.setRelationshipName(relationshipName); + requestBody.setProperties(properties); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + relationshipGUID, + isMergeUpdate); + } + + + + /** + * Remove a relationship multi-link. + * + * @param userId calling user + * @param relationshipGUID unique identifier of the relationship + * @param relationshipGUIDParameterName name of parameter passing the relationshipGUID + * @param relationshipName type name of relationship + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @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 clearRelationship(String userId, + String relationshipGUID, + String relationshipGUIDParameterName, + String relationshipName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(relationshipGUID, relationshipGUIDParameterName, methodName); + + RelationshipRequestBody requestBody = new RelationshipRequestBody(); + + requestBody.setRelationshipName(relationshipName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + relationshipGUID); + } + + + /** + * Remove a relationship uni-link. + * + * @param userId calling user + * @param primaryElementGUID unique identifier of the primary element + * @param primaryElementGUIDParameterName name of parameter passing the primaryElementGUID + * @param relationshipName type name of relationship + * @param secondaryElementGUID unique identifier of the element to connect it to + * @param secondaryElementGUIDParameterName name of parameter passing the secondaryElementGUID + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @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 clearRelationship(String userId, + String primaryElementGUID, + String primaryElementGUIDParameterName, + String relationshipName, + String secondaryElementGUID, + String secondaryElementGUIDParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(primaryElementGUID, primaryElementGUIDParameterName, methodName); + invalidParameterHandler.validateGUID(secondaryElementGUID, secondaryElementGUIDParameterName, methodName); + + RelationshipRequestBody requestBody = new RelationshipRequestBody(); + + requestBody.setRelationshipName(relationshipName); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + primaryElementGUID, + secondaryElementGUID); + } + + + /** + * Retrieve a relationship. + * + * @param userId calling user + * @param startingElementGUID unique identifier of the primary element + * @param startingElementGUIDParameterName name of parameter passing the startingElementGUID + * @param urlTemplate URL to call (no expected placeholders) + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param methodName calling method + * + * @return list of related 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) + */ + List getRelatedElements(String userId, + String startingElementGUID, + String startingElementGUIDParameterName, + String urlTemplate, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(startingElementGUID, startingElementGUIDParameterName, methodName); + + RelatedElementListResponse restResult = restClient.callRelatedElementListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + startingElementGUID, + Integer.toString(startFrom), + Integer.toString(pageSize)); + + return restResult.getElementList(); + } + + + /** + * Retrieve an element stub via a name. + * + * @param userId calling user + * @param name unique identifier of the primary element + * @param nameParameterName name of parameter passing the name + * @param urlTemplate URL to call (no expected placeholders) + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param methodName calling method + * + * @return list of related 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) + */ + List getElementStubsByName(String userId, + String name, + String nameParameterName, + String urlTemplate, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(name, nameParameterName, methodName); + + ElementStubListResponse restResult = restClient.callElementStubListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + name, + Integer.toString(startFrom), + Integer.toString(pageSize)); + + return restResult.getElements(); + } + + + + /** + * Remove the metadata element. + * + * @param userId calling user + * @param elementGUID unique identifier of the metadata element to remove + * @param elementGUIDParameterName name of parameter passing the elementGUID + * @param urlTemplate URL to call (no expected placeholders) + * @param methodName calling method + * + * @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 void removeReferenceable(String userId, + String elementGUID, + String elementGUIDParameterName, + String urlTemplate, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(elementGUID, elementGUIDParameterName, methodName); + + ExternalSourceRequestBody requestBody = new ExternalSourceRequestBody(); + + restClient.callVoidPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + elementGUID); + } + + + /** + * Create a "MoreInformation" relationship between an element that is descriptive and one that is providing the detail. + * + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param properties properties of the relationship + * @param detailGUID unique identifier of the element that provides the detail + * + * @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 setupMoreInformation(String userId, + String elementGUID, + RelationshipProperties properties, + String detailGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setupMoreInformation"; + final String elementGUIDParameterName = "elementGUID"; + final String detailGUIDParameterName = "detailGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/{2}/more-information/{3}"; + + this.setupRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + properties, + detailGUID, + detailGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Remove a "MoreInformation" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param detailGUID unique identifier of the element that provides the detail + * + * @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 clearMoreInformation(String userId, + String elementGUID, + String detailGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearMoreInformation"; + final String elementGUIDParameterName = "elementGUID"; + final String detailGUIDParameterName = "detailGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/{2}/more-information/{3}/delete"; + + this.clearRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + detailGUID, + detailGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Retrieve the detail elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + @Override + public List getMoreInformation(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getMoreInformation"; + final String guidPropertyName = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/more-information/by-descriptive-element/{2}?startFrom={3}&pageSize={4}"; + + return this.getRelatedElements(userId, elementGUID, guidPropertyName, urlTemplate, startFrom, pageSize, methodName); + } + + + /** + * Retrieve the descriptive elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param userId calling user + * @param detailGUID unique identifier of the element that provides the detail + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + @Override + public List getDescriptiveElements(String userId, + String detailGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getDescriptiveElements"; + final String guidPropertyName = "detailGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/more-information/by-detail-element/{2}?startFrom={3}&pageSize={4}"; + + return this.getRelatedElements(userId, detailGUID, guidPropertyName, urlTemplate, startFrom, pageSize, methodName); + } + + + + + /** + * Create a "Stakeholder" relationship between an element and its stakeholder. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param properties properties of the relationship + * @param stakeholderGUID unique identifier of the stakeholder + * + * @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 setupStakeholder(String userId, + String elementGUID, + StakeholderProperties properties, + String stakeholderGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setupStakeholder"; + final String elementGUIDParameterName = "elementGUID"; + final String stakeholderGUIDParameterName = "stakeholderGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/{2}/stakeholders/{3}"; + + this.setupRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + properties, + stakeholderGUID, + stakeholderGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Remove a "Stakeholder" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param stakeholderGUID unique identifier of the stakeholder + * + * @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 clearStakeholder(String userId, + String elementGUID, + String stakeholderGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearStakeholder"; + final String elementGUIDParameterName = "elementGUID"; + final String stakeholderGUIDParameterName = "stakeholderGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/{2}/stakeholders/{3}/delete"; + + this.clearRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + stakeholderGUID, + stakeholderGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Retrieve the stakeholder elements linked via the "Stakeholder" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + @Override + public List getStakeholders(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getStakeholders"; + final String guidPropertyName = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/stakeholders/by-commissioned-element/{2}?startFrom={3}&pageSize={4}"; + + return this.getRelatedElements(userId, elementGUID, guidPropertyName, urlTemplate, startFrom, pageSize, methodName); + } + + + /** + * Retrieve the elements commissioned by a stakeholder, linked via the "Stakeholder" relationship between two referenceables. + * + * @param userId calling user + * @param stakeholderGUID unique identifier of the stakeholder + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + @Override + public List getStakeholderCommissionedElements(String userId, + String stakeholderGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getStakeholderCommissionedElements"; + final String guidPropertyName = "stakeholderGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/stakeholders/by-stakeholder/{2}?startFrom={3}&pageSize={4}"; + + return this.getRelatedElements(userId, stakeholderGUID, guidPropertyName, urlTemplate, startFrom, pageSize, methodName); + } + + + /** + * Create a "ResourceList" relationship between a consuming element and an element that represents resources. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param properties properties of the relationship + * @param resourceGUID unique identifier of the resource + * + * @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 setupResource(String userId, + String elementGUID, + ResourceListProperties properties, + String resourceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setupResource"; + final String elementGUIDParameterName = "elementGUID"; + final String resourceGUIDParameterName = "resourceGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/{2}/resource-list/{3}"; + + this.setupRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + properties, + resourceGUID, + resourceGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Remove a "ResourceList" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param resourceGUID unique identifier of the resource + * + * @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 clearResource(String userId, + String elementGUID, + String resourceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearResource"; + final String elementGUIDParameterName = "elementGUID"; + final String resourceGUIDParameterName = "resourceGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/{2}/resource-list/{3}/delete"; + + this.clearRelationship(userId, + elementGUID, + elementGUIDParameterName, + null, + resourceGUID, + resourceGUIDParameterName, + urlTemplate, + methodName); + } + + + /** + * Retrieve the list of resources assigned to an element via the "ResourceList" relationship between two referenceables. + * + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + @Override + public List getResourceList(String userId, + String elementGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getResourceList"; + final String guidPropertyName = "elementGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/resource-list/by-assignee/{2}?startFrom={3}&pageSize={4}"; + + return this.getRelatedElements(userId, elementGUID, guidPropertyName, urlTemplate, startFrom, pageSize, methodName); + } + + + /** + * Retrieve the list of elements assigned to a resource via the "ResourceList" relationship between two referenceables. + * + * @param userId calling user + * @param resourceGUID unique identifier of the resource + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return list of related 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) + */ + @Override + public List getSupportedByResource(String userId, + String resourceGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getSupportedByResource"; + final String guidPropertyName = "resourceGUID"; + + final String urlTemplate = serverPlatformURLRoot + elementsURLTemplatePrefix + "/resource-list/by-resource/{2}?startFrom={3}&pageSize={4}"; + + return this.getRelatedElements(userId, resourceGUID, guidPropertyName, urlTemplate, startFrom, pageSize, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/ExternalReferenceManager.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/ExternalReferenceManager.java new file mode 100644 index 00000000000..a59d7762b16 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/ExternalReferenceManager.java @@ -0,0 +1,469 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.client; + +import org.odpi.openmetadata.accessservices.assetowner.api.ExternalReferencesInterface; +import org.odpi.openmetadata.accessservices.assetowner.client.rest.AssetOwnerRESTClient; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.ExternalReferenceElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceLinkProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalReferenceListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalReferenceResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; +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; + +/** + * ExternalReferenceManager is the java client for managing external references and their links to all types of governance definitions. + */ +public class ExternalReferenceManager extends AssetOwnerBaseClient implements ExternalReferencesInterface +{ + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * + * @throws InvalidParameterException bad input parameters + */ + public ExternalReferenceManager(String serverName, + String serverPlatformURLRoot) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * + * @throws InvalidParameterException bad input parameters + */ + public ExternalReferenceManager(String serverName, + String serverPlatformURLRoot, + String userId, + String password) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, userId, password); + } + + + /** + * Create a new client with no authentication embedded in the HTTP request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException bad input parameters + */ + public ExternalReferenceManager(String serverName, + String serverPlatformURLRoot, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, maxPageSize, auditLog); + } + + + /** + * Create a new client that passes userId and password in each HTTP request. This is the + * userId/password of the calling server. The end user's userId is sent on each request. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param userId caller's userId embedded in all HTTP requests + * @param password caller's userId embedded in all HTTP requests + * @param maxPageSize pre-initialized parameter limit + * @param auditLog logging destination + * + * @throws InvalidParameterException bad input parameters + */ + public ExternalReferenceManager(String serverName, + String serverPlatformURLRoot, + String userId, + String password, + int maxPageSize, + AuditLog auditLog) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, userId, password, maxPageSize, auditLog); + } + + + /** + * Create a new client that uses the supplied rest client. This is typically used when called from another OMAG Server. + * + * @param serverName name of the server to connect to + * @param serverPlatformURLRoot the network address of the server running the OMAS REST servers + * @param restClient internal client for rest calls + * @param maxPageSize pre-initialized parameter limit + * + * @throws InvalidParameterException bad input parameters + */ + public ExternalReferenceManager(String serverName, + String serverPlatformURLRoot, + AssetOwnerRESTClient restClient, + int maxPageSize) throws InvalidParameterException + { + super(serverName, serverPlatformURLRoot, restClient, maxPageSize); + } + + + /** + * Create a definition of an external reference. + * + * @param userId calling user + * @param anchorGUID optional element to link the external reference to that will act as an anchor - that is, this external reference + * will be deleted when the element is deleted (once the external reference is linked to the anchor). + * @param properties properties for a external reference + * + * @return unique identifier of the external reference + * + * @throws InvalidParameterException qualifiedName or userId is null; qualifiedName is not unique + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public String createExternalReference(String userId, + String anchorGUID, + ExternalReferenceProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createExternalReference"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/external-references"; + final String propertiesParameterName = "properties"; + + return super.createReferenceable(userId, properties, propertiesParameterName, urlTemplate, methodName); + } + + + /** + * Update the definition of an external reference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param properties properties to change + * + * @throws InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void updateExternalReference(String userId, + String externalReferenceGUID, + boolean isMergeUpdate, + ExternalReferenceProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateExternalReference"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/external-references/{2}/update?isMergeUpdate={4}"; + final String guidParameterName = "externalReferenceGUID"; + final String propertiesParameterName = "properties"; + + super.updateReferenceable(userId, externalReferenceGUID, guidParameterName, isMergeUpdate, properties, propertiesParameterName, urlTemplate, methodName); + } + + + /** + * Remove the definition of an external reference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * + * @throws InvalidParameterException guid or userId is null; guid is not known + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public void deleteExternalReference(String userId, + String externalReferenceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "deleteExternalReference"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/external-references/{2}/delete"; + final String guidParameterName = "externalReferenceGUID"; + + super.removeReferenceable(userId, externalReferenceGUID, guidParameterName, urlTemplate, methodName); + } + + + /** + * Link an external reference to an object. + * + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID unique identifier (guid) of the external reference details. + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to. + * + * @throws InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @Override + public void linkExternalReferenceToElement(String userId, + String attachedToGUID, + String externalReferenceGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "linkExternalReferenceToElement"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/external-references/{3}/link"; + + final String elementGUIDParameterName = "attachedToGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + super.setupRelationship(userId, attachedToGUID, elementGUIDParameterName, null, linkProperties, externalReferenceGUID, externalReferenceGUIDParameterName, urlTemplate, methodName); + } + + + + /** + * Remove the link between an external reference and an element. If the element is its anchor, the external reference is removed. + * + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID identifier of the external reference. + * + * @throws InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @Override + public void unlinkExternalReferenceFromElement(String userId, + String attachedToGUID, + String externalReferenceGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "unlinkExternalReferenceToElement"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/external-references/{3}/unlink"; + + final String elementGUIDParameterName = "attachedToGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + super.clearRelationship(userId, attachedToGUID, elementGUIDParameterName, null, externalReferenceGUID, externalReferenceGUIDParameterName, urlTemplate, methodName); + } + + + /** + * Return information about a specific external reference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier for the external reference + * + * @return properties of the external reference + * + * @throws InvalidParameterException externalReferenceGUID or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public ExternalReferenceElement getExternalReferenceByGUID(String userId, + String externalReferenceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + + { + final String methodName = "getExternalReferenceByGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/external-references/{2}"; + + final String guidParameterName = "externalReferenceGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceGUID, guidParameterName, methodName); + + ExternalReferenceResponse restResult = restClient.callExternalReferenceGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + externalReferenceGUID); + + return restResult.getElement(); + } + + + /** + * Retrieve the list of external references for this resourceId. + * + * @param userId the name of the calling user. + * @param resourceId unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information. + * + * @throws InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @Override + public List findExternalReferencesById(String userId, + String resourceId, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "findExternalReferencesById"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/external-references/by-resource-id?startFrom={2}&pageSize={3}"; + final String resourceIdParameterName = "resourceId"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateSearchString(resourceId, resourceIdParameterName, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + SearchStringRequestBody requestBody = new SearchStringRequestBody(); + requestBody.setSearchString(resourceId); + requestBody.setSearchStringParameterName(resourceIdParameterName); + + ExternalReferenceListResponse restResult = restClient.callExternalReferenceListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /** + * Retrieve the list of external references for this URL. + * + * @param userId the name of the calling user. + * @param url URL of the external resource. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information. + * + * @throws InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @Override + public List getExternalReferencesByURL(String userId, + String url, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getExternalReferencesByURL"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/external-references/by-url?startFrom={2}&pageSize={3}"; + final String urlParameterName = "resourceId"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + invalidParameterHandler.validateUserId(userId, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + NameRequestBody requestBody = new NameRequestBody(); + requestBody.setName(url); + requestBody.setNameParameterName(urlParameterName); + + ExternalReferenceListResponse restResult = restClient.callExternalReferenceListPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /** + * Retrieve the list of external references attached to the supplied object. + * + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external reference. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information. + * + * @throws InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * @throws PropertyServerException the server is not available. + * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @Override + public List retrieveAttachedExternalReferences(String userId, + String attachedToGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "retrieveAttachedExternalReferences"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/{2}/external-references?startFrom={3}&pageSize={4}"; + final String guidParameterName = "attachedToGUID"; + + invalidParameterHandler.validateOMAGServerPlatformURL(serverPlatformURLRoot, serverName, methodName); + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(attachedToGUID, guidParameterName, methodName); + + int queryPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + ExternalReferenceListResponse restResult = restClient.callExternalReferenceListGetRESTCall(methodName, + urlTemplate, + serverName, + userId, + attachedToGUID, + startFrom, + queryPageSize); + + return restResult.getElements(); + } + + + /** + * Return information about the elements linked to a externalReference. + * + * @param userId calling user + * @param externalReferenceGUID unique identifier for the externalReference + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the related elements + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + @Override + public List getElementsForExternalReference(String userId, + String externalReferenceGUID, + int startFrom, + int pageSize) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getElementsForExternalReference"; + final String guidParameter = "externalReferenceGUID"; + final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/access-services/asset-owner/users/{1}/elements/external-references/{2}?&startFrom={3}&pageSize={4}"; + + return super.getRelatedElements(userId, externalReferenceGUID, guidParameter, urlTemplate, startFrom, pageSize, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/rest/AssetOwnerRESTClient.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/rest/AssetOwnerRESTClient.java index 71803c2dfdd..533476e68dc 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/rest/AssetOwnerRESTClient.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-client/src/main/java/org/odpi/openmetadata/accessservices/assetowner/client/rest/AssetOwnerRESTClient.java @@ -658,4 +658,314 @@ public AnnotationResponse callAnnotationPostRESTCall(String methodName, return restResult; } + + + /** + * Issue a GET REST call that returns a CertificationTypeResponse object. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return CertificationTypeResponse + * @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 CertificationTypeResponse callCertificationTypeGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + CertificationTypeResponse restResult = this.callGetRESTCall(methodName, CertificationTypeResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a list of CertificationTypeElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return CertificationTypeListResponse + * @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 CertificationTypeListResponse callCertificationTypeListGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + CertificationTypeListResponse restResult = this.callGetRESTCall(methodName, CertificationTypeListResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a list of CertificationTypeElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param requestBody request body for the REST call - contains most of the parameters + * @param params a list of parameters that are slotted into the url template + * @return CertificationTypeListResponse + * @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 CertificationTypeListResponse callCertificationTypeListPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + CertificationTypeListResponse restResult = this.callPostRESTCall(methodName, CertificationTypeListResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a ElementStubListResponse object. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return ElementStubListResponse + * @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 ElementStubListResponse callElementStubListGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + ElementStubListResponse restResult = this.callGetRESTCall(methodName, ElementStubListResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a ExternalReferenceResponse object. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return ExternalReferenceResponse + * @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 ExternalReferenceResponse callExternalReferenceGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + ExternalReferenceResponse restResult = this.callGetRESTCall(methodName, ExternalReferenceResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a list of ExternalReferenceElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return ExternalReferenceListResponse + * @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 ExternalReferenceListResponse callExternalReferenceListGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + ExternalReferenceListResponse restResult = this.callGetRESTCall(methodName, ExternalReferenceListResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a list of ExternalReferenceElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param requestBody request body for the REST call - contains most of the parameters + * @param params a list of parameters that are slotted into the url template + * @return ExternalReferenceListResponse + * @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 ExternalReferenceListResponse callExternalReferenceListPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + ExternalReferenceListResponse restResult = this.callPostRESTCall(methodName, ExternalReferenceListResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a RelatedElementListResponse object. + * + * @param methodName name of the method being called. + * @param urlTemplate REST API call URL template 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 RelatedElementListResponse callRelatedElementListGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + RelatedElementListResponse restResult = this.callGetRESTCall(methodName, RelatedElementListResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a LicenseTypeResponse object. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return LicenseTypeResponse + * @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 LicenseTypeResponse callLicenseTypeGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + LicenseTypeResponse restResult = this.callGetRESTCall(methodName, LicenseTypeResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a GET REST call that returns a list of LicenseTypeElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return LicenseTypeListResponse + * @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 LicenseTypeListResponse callLicenseTypeListGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + LicenseTypeListResponse restResult = this.callGetRESTCall(methodName, LicenseTypeListResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + + /** + * Issue a GET REST call that returns a list of LicenseElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param params a list of parameters that are slotted into the url template + * @return LicenseListResponse + * @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 LicenseListResponse callLicenseListGetRESTCall(String methodName, + String urlTemplate, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + LicenseListResponse restResult = this.callGetRESTCall(methodName, LicenseListResponse.class, urlTemplate, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + + /** + * Issue a POST REST call that returns a list of LicenseTypeElement objects. + * + * @param methodName name of the method being called + * @param urlTemplate template of the URL with place-holders for the parameters + * @param requestBody request body for the REST call - contains most of the parameters + * @param params a list of parameters that are slotted into the url template + * @return LicenseTypeListResponse + * @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 LicenseTypeListResponse callLicenseTypeListPostRESTCall(String methodName, + String urlTemplate, + Object requestBody, + Object... params) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + LicenseTypeListResponse restResult = this.callPostRESTCall(methodName, LicenseTypeListResponse.class, urlTemplate, requestBody, params); + + exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult); + + return restResult; + } + + } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/AssetOwnerOMASConverter.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/AssetOwnerOMASConverter.java index e9a39a3eeba..70b959ec274 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/AssetOwnerOMASConverter.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/AssetOwnerOMASConverter.java @@ -2,10 +2,15 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.accessservices.assetowner.converters; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; import org.odpi.openmetadata.accessservices.assetowner.properties.OwnerType; +import org.odpi.openmetadata.accessservices.assetowner.properties.RelationshipProperties; import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericConverter; import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementStub; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; import java.util.Map; @@ -103,4 +108,112 @@ OwnerType getOwnerTypeFromProperties(InstanceProperties properties) return ownerType; } + + + /** + * Using the supplied instances, return a new instance of a relatedElement 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 + */ + public RelatedElement getRelatedElement(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + RelatedElement relatedElement = new RelatedElement(); + + relatedElement.setRelationshipHeader(this.getMetadataElementHeader(beanClass, relationship, null, methodName)); + + if (relationship != null) + { + InstanceProperties instanceProperties = new InstanceProperties(relationship.getProperties()); + + RelationshipProperties relationshipProperties = new RelationshipProperties(); + + relationshipProperties.setEffectiveFrom(instanceProperties.getEffectiveFromTime()); + relationshipProperties.setEffectiveTo(instanceProperties.getEffectiveToTime()); + relationshipProperties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + + relatedElement.setRelationshipProperties(relationshipProperties); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.RELATIONSHIP_DEF, methodName); + } + + + if (entity != null) + { + ElementStub elementStub = this.getElementStub(beanClass, entity, methodName); + + relatedElement.setRelatedElement(elementStub); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + return relatedElement; + } + + + + /** + * Using the supplied instances, return a new instance of a relatedElement bean. This is used for beans that + * contain a combination of the properties from an entityProxy and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entityProxy entityProxy 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 + */ + public RelatedElement getRelatedElement(Class beanClass, + Relationship relationship, + EntityProxy entityProxy, + String methodName) throws PropertyServerException + { + RelatedElement relatedElement = new RelatedElement(); + + relatedElement.setRelationshipHeader(this.getMetadataElementHeader(beanClass, relationship, null, methodName)); + + if (relationship != null) + { + InstanceProperties instanceProperties = new InstanceProperties(relationship.getProperties()); + + RelationshipProperties relationshipProperties = new RelationshipProperties(); + + relationshipProperties.setEffectiveFrom(instanceProperties.getEffectiveFromTime()); + relationshipProperties.setEffectiveTo(instanceProperties.getEffectiveToTime()); + relationshipProperties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + + relatedElement.setRelationshipProperties(relationshipProperties); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.RELATIONSHIP_DEF, methodName); + } + + + if (entityProxy != null) + { + ElementStub elementStub = this.getElementStub(beanClass, entityProxy, methodName); + + relatedElement.setRelatedElement(elementStub); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + return relatedElement; + } + } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/CertificationTypeConverter.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/CertificationTypeConverter.java new file mode 100644 index 00000000000..a3e8ff1097b --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/CertificationTypeConverter.java @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.converters; + + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationTypeProperties; +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; + + +/** + * CertificationTypeConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into a bean that inherits from CertificationTypeElement. + */ +public class CertificationTypeConverter extends AssetOwnerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public CertificationTypeConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + + /** + * Using the supplied entity, return a new instance of the bean. This is used for most beans that have + * a one to one correspondence with the repository instances. + * + * @param beanClass name of the class to create + * @param primaryEntity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the entity supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + public B getNewBean(Class beanClass, + EntityDetail primaryEntity, + 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 CertificationTypeElement) + { + CertificationTypeElement bean = (CertificationTypeElement) returnBean; + + if (primaryEntity != null) + { + bean.setElementHeader(this.getMetadataElementHeader(beanClass, primaryEntity, primaryEntity.getClassifications(), methodName)); + + /* + * The initial set of values come from the entity. + */ + InstanceProperties instanceProperties = new InstanceProperties(primaryEntity.getProperties()); + + CertificationTypeProperties governanceDefinitionProperties = new CertificationTypeProperties(); + + governanceDefinitionProperties.setDocumentIdentifier(this.removeQualifiedName(instanceProperties)); + governanceDefinitionProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + governanceDefinitionProperties.setTitle(this.removeTitle(instanceProperties)); + governanceDefinitionProperties.setScope(this.removeScope(instanceProperties)); + governanceDefinitionProperties.setDomainIdentifier(this.removeDomainIdentifier(instanceProperties)); + governanceDefinitionProperties.setPriority(this.removePriority(instanceProperties)); + governanceDefinitionProperties.setOutcomes(this.removeOutcomes(instanceProperties)); + governanceDefinitionProperties.setResults(this.removeResults(instanceProperties)); + governanceDefinitionProperties.setDetails(this.removeDetails(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + governanceDefinitionProperties.setTypeName(bean.getElementHeader().getType().getTypeName()); + governanceDefinitionProperties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + + bean.setProperties(governanceDefinitionProperties); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + } + + 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 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 + */ + @SuppressWarnings(value = "unused") + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + final String thisMethodName = "getNewBean(entity, relationship)"; + B returnBean = this.getNewBean(beanClass, entity, methodName); + + if (returnBean instanceof CertificationTypeElement) + { + CertificationTypeElement bean = (CertificationTypeElement) returnBean; + + bean.setRelatedElement(super.getRelatedElement(beanClass, entity, relationship, methodName)); + } + + return returnBean; + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/ExternalReferenceConverter.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/ExternalReferenceConverter.java new file mode 100644 index 00000000000..f81304bf936 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/ExternalReferenceConverter.java @@ -0,0 +1,136 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.converters; + + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.ExternalReferenceElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceProperties; +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; + + +/** + * ExternalReferenceConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into a bean that inherits from ExternalReferenceElement. + */ +public class ExternalReferenceConverter extends AssetOwnerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public ExternalReferenceConverter(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 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); + } + + + /** + * 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 ExternalReferenceElement) + { + ExternalReferenceElement bean = (ExternalReferenceElement) returnBean; + + if (entity != null) + { + bean.setElementHeader(this.getMetadataElementHeader(beanClass, entity, entity.getClassifications(), methodName)); + ExternalReferenceProperties externalReferenceProperties = new ExternalReferenceProperties(); + + /* + * The initial set of values come from the entity. + */ + InstanceProperties instanceProperties = new InstanceProperties(entity.getProperties()); + + externalReferenceProperties.setQualifiedName(this.removeQualifiedName(instanceProperties)); + externalReferenceProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + externalReferenceProperties.setDisplayName(this.removeDisplayName(instanceProperties)); + externalReferenceProperties.setURI(this.removeURL(instanceProperties)); + externalReferenceProperties.setVersion(this.removeReferenceVersion(instanceProperties)); + externalReferenceProperties.setResourceDescription(this.removeDescription(instanceProperties)); + externalReferenceProperties.setOrganization(this.removeOrganization(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + externalReferenceProperties.setTypeName(bean.getElementHeader().getType().getTypeName()); + externalReferenceProperties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + + if (relationship != null) + { + instanceProperties = relationship.getProperties(); + + externalReferenceProperties.setLinkDescription(this.getDescription(instanceProperties)); + externalReferenceProperties.setLocalReferenceId(this.getReferenceId(instanceProperties)); + } + + bean.setProperties(externalReferenceProperties); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/LicenseTypeConverter.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/LicenseTypeConverter.java new file mode 100644 index 00000000000..2c60a851e2f --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/LicenseTypeConverter.java @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.converters; + + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseTypeProperties; +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; + + +/** + * LicenseTypeConverter provides common methods for transferring relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into a bean that inherits from LicenseTypeElement. + */ +public class LicenseTypeConverter extends AssetOwnerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public LicenseTypeConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + + /** + * Using the supplied entity, return a new instance of the bean. This is used for most beans that have + * a one to one correspondence with the repository instances. + * + * @param beanClass name of the class to create + * @param primaryEntity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the entity supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + public B getNewBean(Class beanClass, + EntityDetail primaryEntity, + 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 LicenseTypeElement) + { + LicenseTypeElement bean = (LicenseTypeElement) returnBean; + + if (primaryEntity != null) + { + bean.setElementHeader(this.getMetadataElementHeader(beanClass, primaryEntity, primaryEntity.getClassifications(), methodName)); + + /* + * The initial set of values come from the entity. + */ + InstanceProperties instanceProperties = new InstanceProperties(primaryEntity.getProperties()); + + LicenseTypeProperties licenseTypeProperties = new LicenseTypeProperties(); + + licenseTypeProperties.setDocumentIdentifier(this.removeQualifiedName(instanceProperties)); + licenseTypeProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + licenseTypeProperties.setTitle(this.removeTitle(instanceProperties)); + licenseTypeProperties.setScope(this.removeScope(instanceProperties)); + licenseTypeProperties.setDomainIdentifier(this.removeDomainIdentifier(instanceProperties)); + licenseTypeProperties.setPriority(this.removePriority(instanceProperties)); + licenseTypeProperties.setOutcomes(this.removeOutcomes(instanceProperties)); + licenseTypeProperties.setResults(this.removeResults(instanceProperties)); + licenseTypeProperties.setDetails(this.removeDetails(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + licenseTypeProperties.setTypeName(bean.getElementHeader().getType().getTypeName()); + licenseTypeProperties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + + bean.setProperties(licenseTypeProperties); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + } + + 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 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 + */ + @SuppressWarnings(value = "unused") + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + final String thisMethodName = "getNewBean(entity, relationship)"; + B returnBean = this.getNewBean(beanClass, entity, methodName); + + if (returnBean instanceof LicenseTypeElement) + { + LicenseTypeElement bean = (LicenseTypeElement) returnBean; + + bean.setRelatedElement(super.getRelatedElement(beanClass, entity, relationship, methodName)); + } + + return returnBean; + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/RelatedElementConverter.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/RelatedElementConverter.java new file mode 100644 index 00000000000..fecd0f332f9 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/converters/RelatedElementConverter.java @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.converters; + + +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.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + + +/** + * RelatedElementConverter generates a RelatedElement from a relationship and attached entity + */ +public class RelatedElementConverter extends AssetOwnerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public RelatedElementConverter(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 + @SuppressWarnings(value = "unchecked") + public B getNewBean(Class beanClass, + EntityDetail entity, + Relationship relationship, + String methodName) throws PropertyServerException + { + try + { + return (B)super.getRelatedElement(beanClass, entity, relationship, methodName); + } + catch (ClassCastException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerInstanceHandler.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerInstanceHandler.java index 35fec95dcbc..b42d00b0ff4 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerInstanceHandler.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerInstanceHandler.java @@ -351,9 +351,7 @@ public ConnectorTypeHandler getConnectorTypeHandler(String UserNotAuthorizedException, PropertyServerException { - AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance)super.getServerServiceInstance(userId, - serverName, - serviceOperationName); + AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance)super.getServerServiceInstance(userId, serverName, serviceOperationName); if (instance != null) { @@ -381,9 +379,7 @@ public EndpointHandler getEndpointHandler(String userId, UserNotAuthorizedException, PropertyServerException { - AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance)super.getServerServiceInstance(userId, - serverName, - serviceOperationName); + AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance)super.getServerServiceInstance(userId, serverName, serviceOperationName); if (instance != null) { @@ -392,4 +388,121 @@ public EndpointHandler getEndpointHandler(String userId, return null; } + + + + + /** + * Retrieve the specific converter 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 converter 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 the service name is not known - indicating a logic error + */ + ReferenceableHandler getRelatedElementHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance)super.getServerServiceInstance(userId, serverName, serviceOperationName); + + if (instance != null) + { + return instance.getRelatedElementHandler(); + } + + return null; + } + + + /** + * Retrieve a 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 the service name is not known - indicating a logic error + */ + ExternalReferenceHandler getExternalReferencesHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance) super.getServerServiceInstance(userId, serverName, serviceOperationName); + + if (instance != null) + { + return instance.getExternalReferencesHandler(); + } + + return null; + } + + + + /** + * Retrieve a 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 the service name is not known - indicating a logic error + */ + LicenseHandler getLicenseTypeHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance) super.getServerServiceInstance(userId, serverName, serviceOperationName); + + if (instance != null) + { + return instance.getLicenseTypeHandler(); + } + + return null; + } + + + /** + * Retrieve a 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 the service name is not known - indicating a logic error + */ + CertificationHandler getCertificationTypeHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetOwnerServicesInstance instance = (AssetOwnerServicesInstance) super.getServerServiceInstance(userId, serverName, serviceOperationName); + + if (instance != null) + { + return instance.getCertificationTypeHandler(); + } + + return null; + } + + } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerServicesInstance.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerServicesInstance.java index 89a563718a5..4031ec87e72 100644 --- a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerServicesInstance.java +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/AssetOwnerServicesInstance.java @@ -8,6 +8,9 @@ import org.odpi.openmetadata.accessservices.assetowner.metadataelements.*; import org.odpi.openmetadata.adminservices.configuration.registration.AccessServiceDescription; import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler; +import org.odpi.openmetadata.commonservices.generichandlers.CertificationHandler; +import org.odpi.openmetadata.commonservices.generichandlers.ExternalReferenceHandler; +import org.odpi.openmetadata.commonservices.generichandlers.LicenseHandler; import org.odpi.openmetadata.commonservices.generichandlers.ReferenceableHandler; import org.odpi.openmetadata.commonservices.generichandlers.SchemaAttributeHandler; import org.odpi.openmetadata.commonservices.generichandlers.SchemaTypeHandler; @@ -56,7 +59,11 @@ public class AssetOwnerServicesInstance extends OMASServiceInstance private final ConnectionHandler connectionHandler; private final ConnectorTypeHandler connectorTypeHandler; - private final EndpointHandler endpointHandler; + private final EndpointHandler endpointHandler; + private final ExternalReferenceHandler externalReferenceHandler; + private final CertificationHandler certificationTypeHandler; + private final LicenseHandler licenseTypeHandler; + private final ReferenceableHandler relatedElementHandler; /** * Set up the local repository connector that will service the REST Calls. @@ -199,6 +206,7 @@ public AssetOwnerServicesInstance(OMRSRepositoryConnector repositoryConnector, defaultZones, publishZones, auditLog); + this.annotationHandler = new AnnotationHandler<>(new AnnotationConverter<>(repositoryHelper, serviceName, serverName), Annotation.class, serviceName, @@ -212,6 +220,7 @@ public AssetOwnerServicesInstance(OMRSRepositoryConnector repositoryConnector, defaultZones, publishZones, auditLog); + this.discoveryAnalysisReportHandler = new DiscoveryAnalysisReportHandler<>(new DiscoveryAnalysisReportConverter<>(repositoryHelper, serviceName, serverName), @@ -269,6 +278,62 @@ public AssetOwnerServicesInstance(OMRSRepositoryConnector repositoryConnector, defaultZones, publishZones, auditLog); + + this.relatedElementHandler = new ReferenceableHandler<>(new RelatedElementConverter<>(repositoryHelper, serviceName,serverName), + RelatedElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + + this.externalReferenceHandler = new ExternalReferenceHandler<>(new ExternalReferenceConverter<>(repositoryHelper, serviceName, serverName), + ExternalReferenceElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + + this.certificationTypeHandler = new CertificationHandler<>(new CertificationTypeConverter<>(repositoryHelper, serviceName, serverName), + CertificationTypeElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + + this.licenseTypeHandler = new LicenseHandler<>(new LicenseTypeConverter<>(repositoryHelper, serviceName, serverName), + LicenseTypeElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); } @@ -463,4 +528,68 @@ EndpointHandler getEndpointHandler() throws PropertyServerExcep return endpointHandler; } + + /** + * Return the external references handler + * + * @return handler + * @throws PropertyServerException the instance has not been initialized successfully + */ + ExternalReferenceHandler getExternalReferencesHandler() throws PropertyServerException + { + final String methodName = "getExternalReferencesHandler"; + + validateActiveRepository(methodName); + + return externalReferenceHandler; + } + + + + /** + * Return the handler for governance definition requests. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + CertificationHandler getCertificationTypeHandler() throws PropertyServerException + { + final String methodName = "getCertificationTypeHandler"; + + validateActiveRepository(methodName); + + return certificationTypeHandler; + } + + + /** + * Return the handler for governance definition requests. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + LicenseHandler getLicenseTypeHandler() throws PropertyServerException + { + final String methodName = "getLicenseTypeHandler"; + + validateActiveRepository(methodName); + + return licenseTypeHandler; + } + + + /** + * Return the handler for related referenceables. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + public ReferenceableHandler getRelatedElementHandler() throws PropertyServerException + { + final String methodName = "getRelatedElementHandler"; + + validateActiveRepository(methodName); + + return relatedElementHandler; + } } diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/CertificationRESTServices.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/CertificationRESTServices.java new file mode 100644 index 00000000000..9029dcd5219 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/CertificationRESTServices.java @@ -0,0 +1,643 @@ +/* SPDX-Certification-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.server; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.CertificationTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.CertificationTypeProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.CertificationTypeListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.CertificationTypeResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +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.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.CertificationHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.ReferenceableHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.List; + +/** + * CertificationRESTServices is the java client for managing certification types and the certification of elements. + */ +public class CertificationRESTServices +{ + private static final AssetOwnerInstanceHandler instanceHandler = new AssetOwnerInstanceHandler(); + + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(CertificationRESTServices.class), + instanceHandler.getServiceName()); + + private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + + /** + * Default constructor + */ + public CertificationRESTServices() + { + } + + + /* ======================================== + * Certification Types + */ + + + /** + * Retrieve the certification type by the unique identifier assigned by this service when it was created. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the certification type or + * InvalidParameterException guid or userId is null; guid is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public CertificationTypeResponse getCertificationTypeByGUID(String serverName, + String userId, + String certificationTypeGUID) + { + final String methodName = "getCertificationTypeByGUID"; + final String guidParameterName = "certificationTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + CertificationTypeResponse response = new CertificationTypeResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + response.setElement(handler.getGovernanceDefinitionByGUID(userId, + certificationTypeGUID, + guidParameterName, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the certification type by its assigned unique document identifier. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching certification type or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public CertificationTypeResponse getCertificationTypeByDocId(String serverName, + String userId, + String documentIdentifier) + { + final String methodName = "getCertificationTypeByDocId"; + + final String documentIdParameterName = "documentId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + CertificationTypeResponse response = new CertificationTypeResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + List certificationTypeElements = handler.getGovernanceDefinitionsByName(userId, + OpenMetadataAPIMapper.CERTIFICATION_TYPE_TYPE_NAME, + documentIdentifier, + documentIdParameterName, + 0, + 0, + false, + false, + new Date(), + methodName); + + if ((certificationTypeElements != null) && (! certificationTypeElements.isEmpty())) + { + response.setElement(certificationTypeElements.get(0)); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve all the certification types for a particular title. The title can include regEx wildcards. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody short description of the certification + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching certification types (null if no matching elements) or + * InvalidParameterException title or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public CertificationTypeListResponse getCertificationTypesByTitle(String serverName, + String userId, + int startFrom, + int pageSize, + SearchStringRequestBody requestBody) + { + final String methodName = "getCertificationTypesByTitle"; + final String titleParameterName = "title"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + CertificationTypeListResponse response = new CertificationTypeListResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + response.setElements(handler.findGovernanceDefinitions(userId, + OpenMetadataAPIMapper.CERTIFICATION_TYPE_TYPE_NAME, + requestBody.getSearchString(), + titleParameterName, + 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; + } + + + /** + * Retrieve all the certification type definitions for a specific governance domain. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching certification type definitions or + * InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public CertificationTypeListResponse getCertificationTypeByDomainId(String serverName, + String userId, + int domainIdentifier, + int startFrom, + int pageSize) + { + final String methodName = "getCertificationTypeByDomainId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + CertificationTypeListResponse response = new CertificationTypeListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + response.setElements(handler.getGovernanceDefinitionsByDomain(userId, + OpenMetadataAPIMapper.CERTIFICATION_TYPE_TYPE_NAME, + domainIdentifier, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /* ======================================= + * Certifications + */ + + /** + * Link an element to a certification type and include details of the certification in the relationship properties. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of the element being certified + * @param certificationTypeGUID unique identifier for the certification type + * @param requestBody the properties of the certification + * + * @return guid or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public GUIDResponse certifyElement(String serverName, + String userId, + String elementGUID, + String certificationTypeGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "certifyElement"; + + final String elementGUIDParameterName = "elementGUID"; + final String certificationTypeGUIDParameterName = "certificationTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof CertificationProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + CertificationProperties properties = (CertificationProperties) requestBody.getProperties(); + + response.setGUID(handler.certifyElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + certificationTypeGUID, + certificationTypeGUIDParameterName, + OpenMetadataAPIMapper.CERTIFICATION_TYPE_TYPE_NAME, + properties.getCertificateId(), + properties.getStartDate(), + properties.getEndDate(), + properties.getConditions(), + properties.getCertifiedBy(), + properties.getCertifiedByTypeName(), + properties.getCertifiedByPropertyName(), + properties.getCustodian(), + properties.getCustodianTypeName(), + properties.getCustodianPropertyName(), + properties.getRecipient(), + properties.getRecipientTypeName(), + properties.getRecipientPropertyName(), + properties.getNotes(), + properties.getEffectiveFrom(), + properties.getEffectiveTo(), + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(CertificationTypeProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties of a certification. Remember to include the certificationId in the properties if the element has multiple + * certifications for the same certification type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationGUID unique identifier for the certification type + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param requestBody the properties of the certification + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse updateCertification(String serverName, + String userId, + String certificationGUID, + boolean isMergeUpdate, + RelationshipRequestBody requestBody) + { + final String methodName = "updateCertification"; + final String certificationGUIDParameterName = "certificationGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof CertificationProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + CertificationProperties properties = (CertificationProperties) requestBody.getProperties(); + + handler.updateCertification(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + certificationGUID, + certificationGUIDParameterName, + properties.getCertificateId(), + properties.getStartDate(), + properties.getEndDate(), + properties.getConditions(), + properties.getCertifiedBy(), + properties.getCertifiedByTypeName(), + properties.getCertifiedByPropertyName(), + properties.getCustodian(), + properties.getCustodianTypeName(), + properties.getCustodianPropertyName(), + properties.getRecipient(), + properties.getRecipientTypeName(), + properties.getRecipientPropertyName(), + properties.getNotes(), + isMergeUpdate, + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(CertificationProperties.class.getName(), 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 certification for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationGUID unique identifier for the certification type + * @param requestBody external source information. + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @SuppressWarnings(value="unused") + public VoidResponse decertifyElement(String serverName, + String userId, + String certificationGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "decertifyElement"; + final String certificationGUIDParameterName = "certificationGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + CertificationHandler handler = instanceHandler.getCertificationTypeHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.decertifyElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + certificationGUID, + certificationGUIDParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.decertifyElement(userId, + null, + null, + certificationGUID, + certificationGUIDParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + + /** + * Return information about the elements linked to a certification. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationTypeGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getCertifiedElements(String serverName, + String userId, + String certificationTypeGUID, + int startFrom, + int pageSize) + { + final String methodName = "getCertifiedElements"; + final String guidParameter = "certificationTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + certificationTypeGUID, + guidParameter, + OpenMetadataAPIMapper.CERTIFICATION_TYPE_TYPE_NAME, + OpenMetadataAPIMapper.CERTIFICATION_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.CERTIFICATION_OF_REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + null, + null, + 1, + false, + false, + startFrom, + pageSize, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return information about the certifications linked to an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getCertifications(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getLicences"; + final String guidParameterName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + elementGUID, + guidParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.CERTIFICATION_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.CERTIFICATION_OF_REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.CERTIFICATION_TYPE_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; + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ExternalReferenceRESTServices.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ExternalReferenceRESTServices.java new file mode 100644 index 00000000000..cfcc2fcfb33 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/ExternalReferenceRESTServices.java @@ -0,0 +1,765 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.server; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.ExternalReferenceElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceLinkProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.ExternalReferenceProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalReferenceListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalReferenceResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.ReferenceableRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +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.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.NameRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.ExternalReferenceHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.ReferenceableHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +/** + * ExternalReferenceRESTServices is the server-side for managing external references and their links to all types of governance definitions. + */ +public class ExternalReferenceRESTServices +{ + private static final AssetOwnerInstanceHandler instanceHandler = new AssetOwnerInstanceHandler(); + + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(ExternalReferenceRESTServices.class), + instanceHandler.getServiceName()); + + private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + + /** + * Default constructor + */ + public ExternalReferenceRESTServices() + { + } + + + /** + * Create a definition of an external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody properties for an external reference plus optional element to link the external reference to that will act as an anchor + * - that is, this external reference will be deleted when the element is deleted (once the external reference is linked to the anchor). + * + * @return unique identifier of the external reference or + * InvalidParameterException qualifiedName or userId is null; qualifiedName is not unique + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public GUIDResponse createExternalReference(String serverName, + String userId, + ReferenceableRequestBody requestBody) + { + final String methodName = "createExternalReference"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof ExternalReferenceProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + ExternalReferenceProperties properties = (ExternalReferenceProperties) requestBody.getProperties(); + + response.setGUID(handler.createExternalReference(userId, + null, + null, + requestBody.getAnchorGUID(), + properties.getQualifiedName(), + properties.getDisplayName(), + properties.getResourceDescription(), + properties.getURI(), + properties.getVersion(), + properties.getOrganization(), + properties.getAdditionalProperties(), + properties.getTypeName(), + properties.getExtendedProperties(), + null, + null, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(ExternalReferenceProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the definition of an external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param requestBody properties to change + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse updateExternalReference(String serverName, + String userId, + String externalReferenceGUID, + boolean isMergeUpdate, + ReferenceableRequestBody requestBody) + { + final String methodName = "updateExternalReference"; + final String guidParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof ExternalReferenceProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + ExternalReferenceProperties properties = (ExternalReferenceProperties) requestBody.getProperties(); + + handler.updateExternalReference(userId, + null, + null, + externalReferenceGUID, + guidParameterName, + properties.getQualifiedName(), + properties.getDisplayName(), + properties.getResourceDescription(), + properties.getURI(), + properties.getVersion(), + properties.getOrganization(), + properties.getAdditionalProperties(), + properties.getTypeName(), + properties.getExtendedProperties(), + null, + null, + isMergeUpdate, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(ExternalReferenceProperties.class.getName(), 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 definition of an external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param requestBody external source request body + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse deleteExternalReference(String serverName, + String userId, + String externalReferenceGUID, + ExternalSourceRequestBody requestBody) + { + final String methodName = "deleteExternalReference"; + final String guidParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.removeExternalReference(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + externalReferenceGUID, + guidParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.removeExternalReference(userId, + null, + null, + externalReferenceGUID, + guidParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Link an external reference to an object. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID unique identifier (guid) of the external reference details. + * @param requestBody description for the reference from the perspective of the object that the reference is being attached to. + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse linkExternalReferenceToElement(String serverName, + String userId, + String attachedToGUID, + String externalReferenceGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "linkExternalReferenceToElement"; + + final String elementGUIDParameterName = "attachedToGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + if (requestBody != null) + { + if (requestBody.getProperties() instanceof ExternalReferenceLinkProperties) + { + OMRSRepositoryHelper repositoryHelper = instanceHandler.getRepositoryHelper(userId, serverName, methodName); + String serviceName = instanceHandler.getServiceName(); + ExternalReferenceLinkProperties properties = (ExternalReferenceLinkProperties)requestBody.getProperties(); + + InstanceProperties relationshipProperties = repositoryHelper.addStringPropertyToInstance(serviceName, + null, + OpenMetadataAPIMapper.REFERENCE_ID_PROPERTY_NAME, + properties.getLinkId(), + methodName); + + relationshipProperties = repositoryHelper.addStringPropertyToInstance(serviceName, + relationshipProperties, + OpenMetadataAPIMapper.DESCRIPTION_PROPERTY_NAME, + properties.getLinkDescription(), + methodName); + + relationshipProperties = repositoryHelper.addStringPropertyToInstance(serviceName, + relationshipProperties, + OpenMetadataAPIMapper.PAGES_PROPERTY_NAME, + properties.getPages(), + methodName); + + handler.linkElementToElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + attachedToGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + relationshipProperties, + properties.getEffectiveFrom(), + properties.getEffectiveTo(), + new Date(), + methodName); + } + else if (requestBody.getProperties() == null) + { + handler.linkElementToElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + attachedToGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + null, + null, + (Date)null, + new Date(), + methodName); + } + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(ExternalReferenceLinkProperties.class.getName(), methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + + /** + * Remove the link between an external reference and an element. If the element is its anchor, the external reference is removed. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID identifier of the external reference. + * @param requestBody external source request body + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse unlinkExternalReferenceFromElement(String serverName, + String userId, + String attachedToGUID, + String externalReferenceGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "unlinkExternalReferenceToElement"; + final String elementGUIDParameterName = "attachedToGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.unlinkElementFromElement(userId, + false, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + attachedToGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + new Date(), + methodName); + } + else + { + handler.unlinkElementFromElement(userId, + false, + null, + null, + attachedToGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return information about a specific external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier for the external reference + * + * @return properties of the external reference or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public ExternalReferenceResponse getExternalReferenceByGUID(String serverName, + String userId, + String externalReferenceGUID) + + { + final String methodName = "getExternalReferenceByGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceResponse response = new ExternalReferenceResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + response.setElement(handler.getBeanFromRepository(userId, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the list of external references for this resourceId. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param requestBody unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public ExternalReferenceListResponse findExternalReferencesById(String serverName, + String userId, + int startFrom, + int pageSize, + SearchStringRequestBody requestBody) + { + final String methodName = "findExternalReferencesById"; + final String resourceIdParameterName = "resourceId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceListResponse response = new ExternalReferenceListResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + response.setElements(handler.findBeans(userId, + requestBody.getSearchString(), + resourceIdParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_IDENTIFIER_TYPE_NAME, + null, + 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; + } + + + /** + * Retrieve the list of external references for this URL. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param requestBody URL of the external resource. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public ExternalReferenceListResponse getExternalReferencesByURL(String serverName, + String userId, + int startFrom, + int pageSize, + NameRequestBody requestBody) + { + final String methodName = "getExternalReferencesByURL"; + final String urlParameterName = "resourceId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceListResponse response = new ExternalReferenceListResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + response.setElements(handler.getExternalReferencesByURL(userId, + requestBody.getName(), + urlParameterName, + 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; + } + + + /** + * Retrieve the list of external references attached to the supplied object. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external reference. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public ExternalReferenceListResponse retrieveAttachedExternalReferences(String serverName, + String userId, + String attachedToGUID, + int startFrom, + int pageSize) + { + final String methodName = "retrieveAttachedExternalReferences"; + final String guidParameterName = "attachedToGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceListResponse response = new ExternalReferenceListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ExternalReferenceHandler handler = instanceHandler.getExternalReferencesHandler(userId, serverName, methodName); + + response.setElements(handler.getAttachedElements(userId, + attachedToGUID, + guidParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_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; + } + + + /** + * Return information about the elements linked to a externalReference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier for the externalReference + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the external reference + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getElementsForExternalReference(String serverName, + String userId, + String externalReferenceGUID, + int startFrom, + int pageSize) + { + final String methodName = "getElementsForExternalReference"; + final String guidParameter = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + externalReferenceGUID, + guidParameter, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + null, + null, + 1, + false, + false, + startFrom, + pageSize, + 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-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/LicenseRESTServices.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/LicenseRESTServices.java new file mode 100644 index 00000000000..bac8691e1e5 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/LicenseRESTServices.java @@ -0,0 +1,642 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.server; + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.LicenseTypeElement; +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.LicenseTypeProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseTypeListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseTypeResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +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.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.LicenseHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.ReferenceableHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.List; + +/** + * LicenseRESTServices is the java client for managing license types and the license of elements. + */ +public class LicenseRESTServices +{ + private static final AssetOwnerInstanceHandler instanceHandler = new AssetOwnerInstanceHandler(); + + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(LicenseRESTServices.class), + instanceHandler.getServiceName()); + + private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + + /** + * Default constructor + */ + public LicenseRESTServices() + { + } + + + /* ======================================== + * License Types + */ + + /** + * Retrieve the license type by the unique identifier assigned by this service when it was created. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the license type or + * InvalidParameterException guid or userId is null; guid is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeResponse getLicenseTypeByGUID(String serverName, + String userId, + String licenseTypeGUID) + { + final String methodName = "getLicenseTypeByGUID"; + final String guidParameterName = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeResponse response = new LicenseTypeResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + response.setElement(handler.getGovernanceDefinitionByGUID(userId, + licenseTypeGUID, + guidParameterName, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the license type by its assigned unique document identifier. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching license type or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeResponse getLicenseTypeByDocId(String serverName, + String userId, + String documentIdentifier) + { + final String methodName = "getLicenseTypeByDocId"; + + final String documentIdParameterName = "documentId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeResponse response = new LicenseTypeResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + List licenseTypeElements = handler.getGovernanceDefinitionsByName(userId, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + documentIdentifier, + documentIdParameterName, + 0, + 0, + false, + false, + new Date(), + methodName); + + if ((licenseTypeElements != null) && (! licenseTypeElements.isEmpty())) + { + response.setElement(licenseTypeElements.get(0)); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve all the license types for a particular title. The title can include regEx wildcards. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody short description of the license + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching license types (null if no matching elements) or + * InvalidParameterException title or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeListResponse getLicenseTypesByTitle(String serverName, + String userId, + int startFrom, + int pageSize, + SearchStringRequestBody requestBody) + { + final String methodName = "getLicenseTypesByTitle"; + final String titleParameterName = "title"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeListResponse response = new LicenseTypeListResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + response.setElements(handler.findGovernanceDefinitions(userId, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + requestBody.getSearchString(), + titleParameterName, + 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; + } + + + /** + * Retrieve all the license type definitions for a specific governance domain. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching license type definitions or + * InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeListResponse getLicenseTypeByDomainId(String serverName, + String userId, + int domainIdentifier, + int startFrom, + int pageSize) + { + final String methodName = "getLicenseTypeByDomainId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeListResponse response = new LicenseTypeListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + response.setElements(handler.getGovernanceDefinitionsByDomain(userId, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + domainIdentifier, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /* ======================================= + * Licenses + */ + + /** + * Link an element to a license type and include details of the license in the relationship properties. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of the element being licensed + * @param licenseTypeGUID unique identifier for the license type + * @param requestBody the properties of the license + * + * @return guid or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public GUIDResponse licenseElement(String serverName, + String userId, + String elementGUID, + String licenseTypeGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "licenseElement"; + + final String elementGUIDParameterName = "elementGUID"; + final String licenseTypeGUIDParameterName = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof LicenseProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + LicenseProperties properties = (LicenseProperties) requestBody.getProperties(); + + response.setGUID(handler.licenseElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + licenseTypeGUID, + licenseTypeGUIDParameterName, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + properties.getLicenseId(), + properties.getStartDate(), + properties.getEndDate(), + properties.getConditions(), + properties.getLicensedBy(), + properties.getLicensedByTypeName(), + properties.getLicensedByPropertyName(), + properties.getCustodian(), + properties.getCustodianTypeName(), + properties.getCustodianPropertyName(), + properties.getLicensee(), + properties.getLicenseeTypeName(), + properties.getLicenseePropertyName(), + properties.getNotes(), + properties.getEffectiveFrom(), + properties.getEffectiveTo(), + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(LicenseTypeProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties of a license. Remember to include the licenseId in the properties if the element has multiple + * licenses for the same license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license type + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param requestBody the properties of the license + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse updateLicense(String serverName, + String userId, + String licenseGUID, + boolean isMergeUpdate, + RelationshipRequestBody requestBody) + { + final String methodName = "updateLicense"; + final String licenseGUIDParameterName = "licenseGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof LicenseProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + LicenseProperties properties = (LicenseProperties) requestBody.getProperties(); + + handler.updateLicense(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + licenseGUID, + licenseGUIDParameterName, + properties.getLicenseId(), + properties.getStartDate(), + properties.getEndDate(), + properties.getConditions(), + properties.getLicensedBy(), + properties.getLicensedByTypeName(), + properties.getLicensedByPropertyName(), + properties.getCustodian(), + properties.getCustodianTypeName(), + properties.getCustodianPropertyName(), + properties.getLicensee(), + properties.getLicenseeTypeName(), + properties.getLicenseePropertyName(), + properties.getNotes(), + isMergeUpdate, + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(LicenseProperties.class.getName(), 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 license for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license type + * @param requestBody external source information. + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @SuppressWarnings(value="unused") + public VoidResponse unlicenseElement(String serverName, + String userId, + String licenseGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "unlicenseElement"; + final String licenseGUIDParameterName = "licenseGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.unlicenseElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + licenseGUID, + licenseGUIDParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.unlicenseElement(userId, + null, + null, + licenseGUID, + licenseGUIDParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + + /** + * Return information about the elements linked to a license. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getLicensedElements(String serverName, + String userId, + String licenseTypeGUID, + int startFrom, + int pageSize) + { + final String methodName = "getLicensedElements"; + final String guidParameter = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + licenseTypeGUID, + guidParameter, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + null, + null, + 1, + false, + false, + startFrom, + pageSize, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return information about the licenses linked to an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getLicenses(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getLicences"; + final String guidParameterName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + elementGUID, + guidParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.LICENSE_TYPE_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; + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/RelatedElementRESTServices.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/RelatedElementRESTServices.java new file mode 100644 index 00000000000..7edfbc010b9 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-server/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/RelatedElementRESTServices.java @@ -0,0 +1,876 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.server; + + +import org.odpi.openmetadata.accessservices.assetowner.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetowner.properties.ResourceListProperties; +import org.odpi.openmetadata.accessservices.assetowner.properties.StakeholderProperties; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +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.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.ReferenceableHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + +import java.util.Date; + +/** + * RelatedElementRESTServices support requests about common Referenceable relationships. + * It is the server side for the RelatedElementsManagementInterface. + */ +public class RelatedElementRESTServices +{ + private static final AssetOwnerInstanceHandler instanceHandler = new AssetOwnerInstanceHandler(); + + private static final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(RelatedElementRESTServices.class), + instanceHandler.getServiceName()); + + + /** + * Create a "MoreInformation" relationship between an element that is descriptive and one that is providing the detail. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param detailGUID unique identifier of the element that provides the detail + * @param requestBody relationship properties + * + * @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 setupMoreInformation(String serverName, + String userId, + String elementGUID, + String detailGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "setupMoreInformation"; + final String elementGUIDParameterName = "elementGUID"; + final String detailGUIDParameterName = "detailGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + if (requestBody != null) + { + if (requestBody.getProperties() != null) + { + handler.addMoreInformation(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + detailGUID, + detailGUIDParameterName, + requestBody.getProperties().getEffectiveFrom(), + requestBody.getProperties().getEffectiveTo(), + false, + false, + new Date(), + methodName); + } + else + { + handler.addMoreInformation(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + detailGUID, + detailGUIDParameterName, + 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; + } + + + /** + * Remove a "MoreInformation" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param detailGUID unique identifier of the element that provides the detail + * @param requestBody external source identifiers + * + * @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 clearMoreInformation(String serverName, + String userId, + String elementGUID, + String detailGUID, + ExternalSourceRequestBody requestBody) + { + final String methodName = "clearMoreInformation"; + final String elementGUIDParameterName = "elementGUID"; + final String detailGUIDParameterName = "detailGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.removeMoreInformation(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + detailGUID, + detailGUIDParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.removeMoreInformation(userId, + null, + null, + elementGUID, + elementGUIDParameterName, + detailGUID, + detailGUIDParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Retrieve the detail elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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 RelatedElementListResponse getMoreInformation(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getMoreInformation"; + final String guidPropertyName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getMoreInformation(userId, + elementGUID, + guidPropertyName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Retrieve the descriptive elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param detailGUID unique identifier of the element that provides the detail + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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 RelatedElementListResponse getDescriptiveElements(String serverName, + String userId, + String detailGUID, + int startFrom, + int pageSize) + { + final String methodName = "getDescriptiveElements"; + final String guidPropertyName = "detailGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getDescriptiveElements(userId, + detailGUID, + guidPropertyName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Create a "Stakeholder" relationship between an element and its stakeholder. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param stakeholderGUID unique identifier of the stakeholder + * @param requestBody relationship properties + * + * @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 setupStakeholder(String serverName, + String userId, + String elementGUID, + String stakeholderGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "setupStakeholder"; + final String elementGUIDParameterName = "elementGUID"; + final String stakeholderGUIDParameterName = "stakeholderGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + if (requestBody != null) + { + if (requestBody.getProperties() instanceof StakeholderProperties) + { + StakeholderProperties properties = (StakeholderProperties) requestBody.getProperties(); + + handler.addStakeholder(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + stakeholderGUID, + stakeholderGUIDParameterName, + properties.getStakeholderRole(), + properties.getEffectiveFrom(), + properties.getEffectiveTo(), + false, + false, + new Date(), + methodName); + } + else if (requestBody.getProperties() == null) + { + handler.addStakeholder(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + stakeholderGUID, + stakeholderGUIDParameterName, + null, + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(StakeholderProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Remove a "Stakeholder" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param stakeholderGUID unique identifier of the stakeholder + * @param requestBody external source identifiers + * + * @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 clearStakeholder(String serverName, + String userId, + String elementGUID, + String stakeholderGUID, + ExternalSourceRequestBody requestBody) + { + final String methodName = "clearStakeholder"; + final String elementGUIDParameterName = "elementGUID"; + final String stakeholderGUIDParameterName = "stakeholderGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.removeStakeholder(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + stakeholderGUID, + stakeholderGUIDParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.removeStakeholder(userId, + null, + null, + elementGUID, + elementGUIDParameterName, + stakeholderGUID, + stakeholderGUIDParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Retrieve the stakeholder elements linked via the "Stakeholder" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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 RelatedElementListResponse getStakeholders(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getStakeholders"; + final String guidPropertyName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getStakeholders(userId, + elementGUID, + guidPropertyName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Retrieve the elements commissioned by a stakeholder, linked via the "Stakeholder" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param stakeholderGUID unique identifier of the stakeholder + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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 RelatedElementListResponse getStakeholderCommissionedElements(String serverName, + String userId, + String stakeholderGUID, + int startFrom, + int pageSize) + { + final String methodName = "getStakeholderCommissionedElements"; + final String guidPropertyName = "stakeholderGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getCommissionedByStakeholder(userId, + stakeholderGUID, + guidPropertyName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Create a "ResourceList" relationship between a consuming element and an element that represents resources. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param resourceGUID unique identifier of the resource + * @param requestBody relationship properties + * + * @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 setupResource(String serverName, + String userId, + String elementGUID, + String resourceGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "setupResource"; + final String elementGUIDParameterName = "elementGUID"; + final String resourceGUIDParameterName = "resourceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + if (requestBody != null) + { + if (requestBody.getProperties() instanceof ResourceListProperties) + { + ResourceListProperties properties = (ResourceListProperties) requestBody.getProperties(); + + handler.saveResourceListMember(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + resourceGUID, + resourceGUIDParameterName, + properties.getResourceUse(), + properties.getWatchResource(), + properties.getEffectiveFrom(), + properties.getEffectiveTo(), + false, + false, + new Date(), + methodName); + } + else if (requestBody.getProperties() == null) + { + handler.saveResourceListMember(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + resourceGUID, + resourceGUIDParameterName, + null, + false, + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(ResourceListProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Remove a "ResourceList" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param resourceGUID unique identifier of the resource + * @param requestBody external source identifiers + * + * @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 clearResource(String serverName, + String userId, + String elementGUID, + String resourceGUID, + ExternalSourceRequestBody requestBody) + { + final String methodName = "clearResource"; + final String elementGUIDParameterName = "elementGUID"; + final String resourceGUIDParameterName = "resourceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.removeResourceListMember(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + resourceGUID, + resourceGUIDParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.removeResourceListMember(userId, + null, + null, + elementGUID, + elementGUIDParameterName, + resourceGUID, + resourceGUIDParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Retrieve the list of resources assigned to an element via the "ResourceList" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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 RelatedElementListResponse getResourceList(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getResourceList"; + final String guidPropertyName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getResourceList(userId, + elementGUID, + guidPropertyName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Retrieve the list of elements assigned to a resource via the "ResourceList" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param resourceGUID unique identifier of the resource + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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 RelatedElementListResponse getSupportedByResource(String serverName, + String userId, + String resourceGUID, + int startFrom, + int pageSize) + { + final String methodName = "getSupportedByResource"; + final String guidPropertyName = "resourceGUID"; + + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getSupportedByResource(userId, + resourceGUID, + guidPropertyName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + startFrom, + pageSize, + 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-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetCertificationsResource.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetCertificationsResource.java new file mode 100644 index 00000000000..138d52f2434 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetCertificationsResource.java @@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.assetowner.rest.CertificationTypeListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.CertificationTypeResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.server.CertificationRESTServices; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +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; + + +/** + * AssetCertificationsResource sets up the certification types that are part of an organization governance. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-owner/users/{userId}") + +@Tag(name="Asset Owner OMAS", description="The Asset Owner OMAS provides APIs and notifications for tools and applications supporting the work of Asset Owners in protecting and enhancing their assets.\n" + + "\n", externalDocs=@ExternalDocumentation(description="Asset Owner Open Metadata Access Service (OMAS)",url="https://egeria-project.org/services/omas/asset-owner/overview/")) + +public class AssetCertificationsResource +{ + private final CertificationRESTServices restAPI = new CertificationRESTServices(); + + /** + * Default constructor + */ + public AssetCertificationsResource() + { + } + + + + /* ======================================== + * Certification Types + */ + + /** + * Retrieve the certification type by the unique identifier assigned by this service when it was created. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the certification type or + * InvalidParameterException guid or userId is null; guid is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/certification-types/{certificationTypeGUID}") + + public CertificationTypeResponse getCertificationTypeByGUID(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String certificationTypeGUID) + { + return restAPI.getCertificationTypeByGUID(serverName, userId, certificationTypeGUID); + } + + + /** + * Retrieve the certification type by its assigned unique document identifier. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching certification type or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/certification-types/by-document-id/{documentIdentifier}") + + public CertificationTypeResponse getCertificationTypeByDocId(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String documentIdentifier) + { + return restAPI.getCertificationTypeByDocId(serverName, userId, documentIdentifier); + } + + + /** + * Retrieve all the certification types for a particular title. The title can include regEx wildcards. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody short description of the certification + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching certification types (null if no matching elements) or + * InvalidParameterException title or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/certification-types/by-title") + + public CertificationTypeListResponse getCertificationTypesByTitle(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.getCertificationTypesByTitle(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve all the certification type definitions for a specific governance domain. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching certification type definitions or + * InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/certification-types/by-domain/{domainIdentifier}") + + public CertificationTypeListResponse getCertificationTypeByDomainId(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable int domainIdentifier, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getCertificationTypeByDomainId(serverName, userId, domainIdentifier, startFrom, pageSize); + } + + + /* ======================================= + * Certifications + */ + + /** + * Link an element to a certification type and include details of the certification in the relationship properties. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of the element being certified + * @param certificationTypeGUID unique identifier for the certification type + * @param requestBody the properties of the certification + * + * @return guid or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/elements/{elementGUID}/certification-types/{certificationTypeGUID}/certify") + + public GUIDResponse certifyElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String certificationTypeGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.certifyElement(serverName, userId, elementGUID, certificationTypeGUID, requestBody); + } + + + /** + * Update the properties of a certification. Remember to include the certificationId in the properties if the element has multiple + * certifications for the same certification type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationGUID unique identifier for the certification relationship + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param requestBody the properties of the certification + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/certifications/{certificationGUID}/update") + + public VoidResponse updateCertification(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String certificationGUID, + @RequestParam boolean isMergeUpdate, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.updateCertification(serverName, userId, certificationGUID, isMergeUpdate, requestBody); + } + + + /** + * Remove the certification for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationGUID unique identifier for the certification relationship + * @param requestBody external source information. + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/certifications/{certificationGUID}/delete") + + public VoidResponse decertifyElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String certificationGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.decertifyElement(serverName, userId, certificationGUID, requestBody); + } + + + + /** + * Return information about the elements linked to a certification. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param certificationGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/elements/certifications/{certificationGUID}") + + public RelatedElementListResponse getCertifiedElements(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String certificationGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getCertifiedElements(serverName, userId, certificationGUID, startFrom, pageSize); + } + + + /** + * Return information about the certifications linked to an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier for the certification + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the certification or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/elements/{elementGUID}/certifications") + + public RelatedElementListResponse getCertifications(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getCertifications(serverName, userId, elementGUID, startFrom, pageSize); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetExternalReferenceResource.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetExternalReferenceResource.java new file mode 100644 index 00000000000..2c333853096 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetExternalReferenceResource.java @@ -0,0 +1,300 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalReferenceListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalReferenceResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.ReferenceableRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.server.ExternalReferenceRESTServices; +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.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; + + +/** + * AssetExternalReferenceResource sets up the external references that are part of an organization governance. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-owner/users/{userId}") + +@Tag(name="Asset Owner OMAS", description="The Asset Owner OMAS provides APIs and notifications for tools and applications supporting the work of Asset Owners in protecting and enhancing their assets.\n" + + "\n", externalDocs=@ExternalDocumentation(description="Asset Owner Open Metadata Access Service (OMAS)",url="https://egeria-project.org/services/omas/asset-owner/overview/")) + +public class AssetExternalReferenceResource +{ + private final ExternalReferenceRESTServices restAPI = new ExternalReferenceRESTServices(); + + /** + * Default constructor + */ + public AssetExternalReferenceResource() + { + } + + + /** + * Create a definition of an external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody properties for an external reference plus optional element to link the external reference to that will act as an anchor + * - that is, this external reference will be deleted when the element is deleted (once the external reference is linked to the anchor). + * + * @return unique identifier of the external reference or + * InvalidParameterException qualifiedName or userId is null; qualifiedName is not unique + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references") + + public GUIDResponse createExternalReference(@PathVariable String serverName, + @PathVariable String userId, + @RequestBody ReferenceableRequestBody requestBody) + { + return restAPI.createExternalReference(serverName, userId, requestBody); + } + + + /** + * Update the definition of an external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param requestBody properties to change + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references/{externalReferenceGUID}/update") + + public VoidResponse updateExternalReference(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID, + @RequestParam boolean isMergeUpdate, + @RequestBody ReferenceableRequestBody requestBody) + { + return restAPI.updateExternalReference(serverName, userId, externalReferenceGUID, isMergeUpdate, requestBody); + } + + + /** + * Remove the definition of an external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param requestBody external source request body + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references/{externalReferenceGUID}/delete") + + public VoidResponse deleteExternalReference(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID, + @RequestBody ExternalSourceRequestBody requestBody) + { + return restAPI.deleteExternalReference(serverName, userId, externalReferenceGUID, requestBody); + } + + + /** + * Link an external reference to an object. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID unique identifier (guid) of the external reference details. + * @param requestBody description for the reference from the perspective of the object that the reference is being attached to. + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/elements/{attachedToGUID}/external-references/{externalReferenceGUID}/link") + + public VoidResponse linkExternalReferenceToElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String attachedToGUID, + @PathVariable String externalReferenceGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.linkExternalReferenceToElement(serverName, userId, attachedToGUID, externalReferenceGUID, requestBody); + } + + + + /** + * Remove the link between an external reference and an element. If the element is its anchor, the external reference is removed. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external references. + * @param externalReferenceGUID identifier of the external reference. + * @param requestBody external source request body + * + * @return void or + * InvalidParameterException guid, qualifiedName or userId is null; qualifiedName is not unique; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/elements/{attachedToGUID}/external-references/{externalReferenceGUID}/unlink") + + public VoidResponse unlinkExternalReferenceFromElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String attachedToGUID, + @PathVariable String externalReferenceGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.unlinkExternalReferenceFromElement(serverName, userId, attachedToGUID, externalReferenceGUID, requestBody); + } + + + /** + * Return information about a specific external reference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier for the external reference + * + * @return properties of the external reference or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping(path = "/external-references/{externalReferenceGUID}") + + public ExternalReferenceResponse getExternalReferenceByGUID(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID) + + { + return restAPI.getExternalReferenceByGUID(serverName, userId, externalReferenceGUID); + } + + + /** + * Retrieve the list of external references for this resourceId. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param requestBody unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references/by-resource-id") + + public ExternalReferenceListResponse findExternalReferencesById(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.findExternalReferencesById(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve the list of external references for this URL. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param requestBody URL of the external resource. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references/by-url") + + public ExternalReferenceListResponse getExternalReferencesByURL(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody NameRequestBody requestBody) + { + return restAPI.getExternalReferencesByURL(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve the list of external references attached to the supplied object. + * + * @param serverName name of the server instance to connect to + * @param userId the name of the calling user. + * @param attachedToGUID object linked to external reference. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @return links to addition information or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping(path = "/elements/{attachedToGUID}/external-references") + + public ExternalReferenceListResponse retrieveAttachedExternalReferences(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String attachedToGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.retrieveAttachedExternalReferences(serverName, userId, attachedToGUID, startFrom, pageSize); + } + + + /** + * Return information about the elements linked to a externalReference. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param externalReferenceGUID unique identifier for the externalReference + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the external reference + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping(path = "/elements/external-references/{externalReferenceGUID}") + + public RelatedElementListResponse getElementsForExternalReference(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getElementsForExternalReference(serverName, userId, externalReferenceGUID, startFrom, pageSize); + } +} diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetLicensesResource.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetLicensesResource.java new file mode 100644 index 00000000000..102da59ff47 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetLicensesResource.java @@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetowner.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseTypeListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.LicenseTypeResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.server.LicenseRESTServices; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +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; + + +/** + * AssetLicensesResource sets up the license types that are part of an organization governance. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-owner/users/{userId}") + +@Tag(name="Asset Owner OMAS", description="The Asset Owner OMAS provides APIs and notifications for tools and applications supporting the work of Asset Owners in protecting and enhancing their assets.\n" + + "\n", externalDocs=@ExternalDocumentation(description="Asset Owner Open Metadata Access Service (OMAS)",url="https://egeria-project.org/services/omas/asset-owner/overview/")) + +public class AssetLicensesResource +{ + private final LicenseRESTServices restAPI = new LicenseRESTServices(); + + /** + * Default constructor + */ + public AssetLicensesResource() + { + } + + + /* ======================================== + * License Types + */ + + + /** + * Retrieve the license type by the unique identifier assigned by this service when it was created. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the license type or + * InvalidParameterException guid or userId is null; guid is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/license-types/{licenseTypeGUID}") + + public LicenseTypeResponse getLicenseTypeByGUID(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseTypeGUID) + { + return restAPI.getLicenseTypeByGUID(serverName, userId, licenseTypeGUID); + } + + + /** + * Retrieve the license type by its assigned unique document identifier. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching license type or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/license-types/by-document-id/{documentIdentifier}") + + public LicenseTypeResponse getLicenseTypeByDocId(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String documentIdentifier) + { + return restAPI.getLicenseTypeByDocId(serverName, userId, documentIdentifier); + } + + + /** + * Retrieve all the license types for a particular title. The title can include regEx wildcards. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody short description of the license + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching license types (null if no matching elements) or + * InvalidParameterException title or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/license-types/by-title") + + public LicenseTypeListResponse getLicenseTypesByTitle(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.getLicenseTypesByTitle(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve all the license type definitions for a specific governance domain. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching license type definitions or + * InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/license-types/by-domain/{domainIdentifier}") + + public LicenseTypeListResponse getLicenseTypeByDomainId(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable int domainIdentifier, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getLicenseTypeByDomainId(serverName, userId, domainIdentifier, startFrom, pageSize); + } + + + /* ======================================= + * Licenses + */ + + /** + * Link an element to a license type and include details of the license in the relationship properties. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of the element being licensed + * @param licenseTypeGUID unique identifier for the license type + * @param requestBody the properties of the license + * + * @return guid or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/elements/{elementGUID}/license-types/{licenseTypeGUID}/license") + + public GUIDResponse licenseElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String licenseTypeGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.licenseElement(serverName, userId, elementGUID, licenseTypeGUID, requestBody); + } + + + /** + * Update the properties of a license. Remember to include the licenseId in the properties if the element has multiple + * licenses for the same license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param requestBody the properties of the license + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/licenses/{licenseGUID}/update") + + public VoidResponse updateLicense(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseGUID, + @RequestParam boolean isMergeUpdate, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.updateLicense(serverName, userId, licenseGUID, isMergeUpdate, requestBody); + } + + + /** + * Remove the license for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param requestBody external source information. + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/licenses/{licenseGUID}/delete") + + public VoidResponse unlicenseElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.unlicenseElement(serverName, userId, licenseGUID, requestBody); + } + + + + /** + * Return information about the elements linked to a license. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/elements/licenses/{licenseGUID}") + + public RelatedElementListResponse getCertifiedElements(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getLicensedElements(serverName, userId, licenseGUID, startFrom, pageSize); + } + + + /** + * Return information about the licenses linked to an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/elements/{elementGUID}/licenses") + + public RelatedElementListResponse getLicenses(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getLicenses(serverName, userId, elementGUID, startFrom, pageSize); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetRelationshipsResource.java b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetRelationshipsResource.java new file mode 100644 index 00000000000..0197448ddf7 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-owner/asset-owner-spring/src/main/java/org/odpi/openmetadata/accessservices/assetowner/server/spring/AssetRelationshipsResource.java @@ -0,0 +1,357 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetowner.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.assetowner.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.assetowner.rest.RelationshipRequestBody; +import org.odpi.openmetadata.accessservices.assetowner.server.RelatedElementRESTServices; +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 AssetRelationshipsResource provides a Spring based server-side REST API + * that supports the RelatedElementsManagementInterface. It delegates each request to the + * RelatedElementRESTServices. This provides the server-side implementation of the Community Profile Open Metadata + * Assess Service (OMAS) which is used to manage information about people, roles and organizations. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-owner/users/{userId}") + +@Tag(name="Governance Program OMAS", + description="The Governance Program OMAS provides APIs and events for tools and applications focused on defining a data strategy, planning support for a regulation and/or developing a governance program for the data landscape.", + externalDocs=@ExternalDocumentation(description="Governance Program Open Metadata Access Service (OMAS)", + url="https://egeria-project.org/services/omas/asset-owner/overview/")) + +public class AssetRelationshipsResource +{ + private final RelatedElementRESTServices restAPI = new RelatedElementRESTServices(); + + /** + * Default constructor + */ + public AssetRelationshipsResource() + { + } + + + /** + * Create a "MoreInformation" relationship between an element that is descriptive and one that is providing the detail. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param detailGUID unique identifier of the element that provides the detail + * @param requestBody relationship properties + * + * @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 = "/related-elements/{elementGUID}/more-information/{detailGUID}") + + public VoidResponse setupMoreInformation(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String detailGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.setupMoreInformation(serverName, userId, elementGUID, detailGUID, requestBody); + } + + + /** + * Remove a "MoreInformation" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param detailGUID unique identifier of the element that provides the detail + * @param requestBody external source identifiers + * + * @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 = "/related-elements/{elementGUID}/more-information/{detailGUID}/delete") + + public VoidResponse clearMoreInformation(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String detailGUID, + @RequestBody ExternalSourceRequestBody requestBody) + { + return restAPI.clearMoreInformation(serverName, userId, elementGUID, detailGUID, requestBody); + } + + + /** + * Retrieve the detail elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element that is descriptive + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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) + */ + @GetMapping(path = "/related-elements/more-information/by-descriptive-element/{elementGUID}") + + public RelatedElementListResponse getMoreInformation(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getMoreInformation(serverName, userId, elementGUID, startFrom, pageSize); + } + + + /** + * Retrieve the descriptive elements linked via a "MoreInformation" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param detailGUID unique identifier of the element that provides the detail + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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) + */ + @GetMapping(path = "/related-elements/more-information/by-detail-element/{detailGUID}") + + public RelatedElementListResponse getDescriptiveElements(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String detailGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getDescriptiveElements(serverName, userId, detailGUID, startFrom, pageSize); + } + + + /** + * Create a "Stakeholder" relationship between an element and its stakeholder. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param stakeholderGUID unique identifier of the stakeholder + * @param requestBody relationship properties + * + * @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 = "/related-elements/{elementGUID}/stakeholders/{stakeholderGUID}") + + public VoidResponse setupStakeholder(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String stakeholderGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.setupStakeholder(serverName, userId, elementGUID, stakeholderGUID, requestBody); + } + + + /** + * Remove a "Stakeholder" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param stakeholderGUID unique identifier of the stakeholder + * @param requestBody external source identifiers + * + * @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 = "/related-elements/{elementGUID}/stakeholders/{stakeholderGUID}/delete") + + public VoidResponse clearStakeholder(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String stakeholderGUID, + @RequestBody ExternalSourceRequestBody requestBody) + { + return restAPI.clearStakeholder(serverName, userId, elementGUID, stakeholderGUID, requestBody); + } + + + /** + * Retrieve the stakeholder elements linked via the "Stakeholder" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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) + */ + @GetMapping(path = "/related-elements/stakeholders/by-commissioned-element/{elementGUID}") + + public RelatedElementListResponse getStakeholders(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getStakeholders(serverName, userId, elementGUID, startFrom, pageSize); + } + + + /** + * Retrieve the elements commissioned by a stakeholder, linked via the "Stakeholder" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param stakeholderGUID unique identifier of the stakeholder + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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) + */ + @GetMapping(path = "/related-elements/stakeholders/by-stakeholder/{stakeholderGUID}") + + public RelatedElementListResponse getStakeholderCommissionedElements(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String stakeholderGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getStakeholderCommissionedElements(serverName, userId, stakeholderGUID, startFrom, pageSize); + } + + + /** + * Create a "ResourceList" relationship between a consuming element and an element that represents resources. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param resourceGUID unique identifier of the resource + * @param requestBody relationship properties + * + * @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 = "/related-elements/{elementGUID}/resource-list/{resourceGUID}") + + public VoidResponse setupResource(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String resourceGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.setupResource(serverName, userId, elementGUID, resourceGUID, requestBody); + } + + + /** + * Remove a "ResourceList" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param resourceGUID unique identifier of the resource + * @param requestBody external source identifiers + * + * @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 = "/related-elements/{elementGUID}/resource-list/{resourceGUID}/delete") + + public VoidResponse clearResource(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String resourceGUID, + @RequestBody ExternalSourceRequestBody requestBody) + { + return restAPI.clearResource(serverName, userId, elementGUID, resourceGUID, requestBody); + } + + + /** + * Retrieve the list of resources assigned to an element via the "ResourceList" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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) + */ + @GetMapping(path = "/related-elements/resource-list/by-assignee/{elementGUID}") + + public RelatedElementListResponse getResourceList(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getResourceList(serverName, userId, elementGUID, startFrom, pageSize); + } + + + /** + * Retrieve the list of elements assigned to a resource via the "ResourceList" relationship between two referenceables. + * + * @param serverName name of the service to route the request to. + * @param userId calling user + * @param resourceGUID unique identifier of the resource + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * + * @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) + */ + @GetMapping(path = "/related-elements/resource-list/by-resource/{resourceGUID}") + + public RelatedElementListResponse getSupportedByResource(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String resourceGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getSupportedByResource(serverName, userId, resourceGUID, startFrom, pageSize); + } +} diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/CertificationManagementInterface.java b/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/CertificationManagementInterface.java index 840414ee187..13de7c5e1d7 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/CertificationManagementInterface.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/CertificationManagementInterface.java @@ -118,7 +118,7 @@ CertificationTypeElement getCertificationTypeByDocId(String userId, * Retrieve all the certification types for a particular title. The title can include regEx wildcards. * * @param userId calling user - * @param title identifier of role + * @param title identifier of certification * @param startFrom where to start from in the list of definitions * @param pageSize max number of results to return in one call * diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/RightsManagementInterface.java b/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/RightsManagementInterface.java index 0fcb6042f35..1aa0e52c0e7 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/RightsManagementInterface.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-api/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/api/RightsManagementInterface.java @@ -137,7 +137,7 @@ LicenseTypeElement getLicenseTypeByDocId(String userId, * Retrieve all the license types for a particular title. The title can include regEx wildcards. * * @param userId calling user - * @param title identifier of role + * @param title identifier of license * @param startFrom where to start from in the list of definitions * @param pageSize max number of results to return in one call * diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/CertificationManager.java b/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/CertificationManager.java index 78723583778..b6e7b2c30c7 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/CertificationManager.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/CertificationManager.java @@ -5,13 +5,11 @@ import org.odpi.openmetadata.accessservices.governanceprogram.api.CertificationManagementInterface; import org.odpi.openmetadata.accessservices.governanceprogram.client.rest.GovernanceProgramRESTClient; import org.odpi.openmetadata.accessservices.governanceprogram.metadataelements.CertificationTypeElement; -import org.odpi.openmetadata.accessservices.governanceprogram.metadataelements.CertificationElement; import org.odpi.openmetadata.accessservices.governanceprogram.metadataelements.RelatedElement; import org.odpi.openmetadata.accessservices.governanceprogram.properties.CertificationProperties; import org.odpi.openmetadata.accessservices.governanceprogram.properties.CertificationTypeProperties; import org.odpi.openmetadata.accessservices.governanceprogram.properties.GovernanceDefinitionStatus; import org.odpi.openmetadata.accessservices.governanceprogram.rest.*; -import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; @@ -291,7 +289,7 @@ public CertificationTypeElement getCertificationTypeByDocId(String userId, * Retrieve all the certification types for a particular title. The title can include regEx wildcards. * * @param userId calling user - * @param title short description of the role + * @param title short description of the certification * @param startFrom where to start from in the list of definitions * @param pageSize max number of results to return in one call * diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/RightsManager.java b/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/RightsManager.java index 4e2084c31f1..2d7129ffc4a 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/RightsManager.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-client/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/client/RightsManager.java @@ -317,7 +317,7 @@ public LicenseTypeElement getLicenseTypeByDocId(String userId, * Retrieve all the license types for a particular title. The title can include regEx wildcards. * * @param userId calling user - * @param title short description of the role + * @param title short description of the license * @param startFrom where to start from in the list of definitions * @param pageSize max number of results to return in one call * diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramInstanceHandler.java b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramInstanceHandler.java index fd193886b99..895595f7272 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramInstanceHandler.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramInstanceHandler.java @@ -308,11 +308,11 @@ GovernanceDefinitionHandler getGovernanceDefinitionGr * @throws UserNotAuthorizedException user does not have access to the requested server * @throws PropertyServerException the service name is not known - indicating a logic error */ - GovernanceDefinitionHandler getLicenseTypeHandler(String userId, - String serverName, - String serviceOperationName) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + LicenseHandler getLicenseTypeHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { GovernanceProgramServicesInstance instance = (GovernanceProgramServicesInstance) super.getServerServiceInstance(userId, serverName, serviceOperationName); diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramServicesInstance.java b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramServicesInstance.java index a83f25cfd5c..312ae36e04c 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramServicesInstance.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/GovernanceProgramServicesInstance.java @@ -442,7 +442,7 @@ CertificationHandler getCertificationTypeHandler() * * @return handler object */ - GovernanceDefinitionHandler getLicenseTypeHandler() + LicenseHandler getLicenseTypeHandler() { return licenseTypeHandler; } diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/LicenseRESTServices.java b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/LicenseRESTServices.java new file mode 100644 index 00000000000..581eeef2068 --- /dev/null +++ b/open-metadata-implementation/access-services/governance-program/governance-program-server/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/LicenseRESTServices.java @@ -0,0 +1,866 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.governanceprogram.server; + +import org.odpi.openmetadata.accessservices.governanceprogram.metadataelements.LicenseTypeElement; +import org.odpi.openmetadata.accessservices.governanceprogram.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.governanceprogram.properties.LicenseProperties; +import org.odpi.openmetadata.accessservices.governanceprogram.properties.LicenseTypeProperties; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.LicenseTypeListResponse; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.LicenseTypeResponse; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.GovernanceDefinitionRequestBody; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.RelationshipRequestBody; +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.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.SearchStringRequestBody; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.generichandlers.LicenseHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.generichandlers.ReferenceableHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.List; + +/** + * LicenseRESTServices is the java client for managing license types and the license of elements. + */ +public class LicenseRESTServices +{ + private static final GovernanceProgramInstanceHandler instanceHandler = new GovernanceProgramInstanceHandler(); + + private static final RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(LicenseRESTServices.class), + instanceHandler.getServiceName()); + + private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + + /** + * Default constructor + */ + public LicenseRESTServices() + { + } + + + /* ======================================== + * License Types + */ + + /** + * Create a description of the license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody license properties and initial status + * + * @return unique identifier of new definition or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not unique + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public GUIDResponse createLicenseType(String serverName, + String userId, + GovernanceDefinitionRequestBody requestBody) + { + final String methodName = "createLicenseType"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof LicenseTypeProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + LicenseTypeProperties properties = (LicenseTypeProperties) requestBody.getProperties(); + + String setGUID = handler.createGovernanceDefinition(userId, + properties.getDocumentIdentifier(), + properties.getTitle(), + properties.getSummary(), + properties.getDescription(), + properties.getScope(), + properties.getDomainIdentifier(), + properties.getPriority(), + properties.getImplications(), + properties.getOutcomes(), + properties.getResults(), + null, + null, + null, + null, + properties.getDetails(), + null, + properties.getAdditionalProperties(), + properties.getTypeName(), + properties.getExtendedProperties(), + null, + null, + new Date(), + methodName); + + response.setGUID(setGUID); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(LicenseTypeProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties of the license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to change + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param requestBody license properties + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse updateLicenseType(String serverName, + String userId, + String licenseTypeGUID, + boolean isMergeUpdate, + GovernanceDefinitionRequestBody requestBody) + { + final String methodName = "updateLicenseType"; + final String guidParameterName = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof LicenseTypeProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + LicenseTypeProperties properties = (LicenseTypeProperties) requestBody.getProperties(); + + handler.updateGovernanceDefinition(userId, + licenseTypeGUID, + guidParameterName, + properties.getDocumentIdentifier(), + properties.getTitle(), + properties.getSummary(), + properties.getDescription(), + properties.getScope(), + properties.getDomainIdentifier(), + properties.getPriority(), + properties.getImplications(), + properties.getOutcomes(), + properties.getResults(), + null, + null, + null, + null, + properties.getDetails(), + null, + properties.getAdditionalProperties(), + properties.getTypeName(), + properties.getExtendedProperties(), + isMergeUpdate, + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(LicenseTypeProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Delete the properties of the license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to delete + * @param requestBody external source request body + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @SuppressWarnings(value = "unused") + public VoidResponse deleteLicenseType(String serverName, + String userId, + String licenseTypeGUID, + ExternalSourceRequestBody requestBody) + { + final String methodName = "deleteLicenseType"; + final String guidParameterName = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + handler.removeGovernanceDefinition(userId, + licenseTypeGUID, + guidParameterName, + false, + false, + new Date(), + methodName); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the license type by the unique identifier assigned by this service when it was created. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the license type or + * InvalidParameterException guid or userId is null; guid is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeResponse getLicenseTypeByGUID(String serverName, + String userId, + String licenseTypeGUID) + { + final String methodName = "getLicenseTypeByGUID"; + final String guidParameterName = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeResponse response = new LicenseTypeResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + response.setElement(handler.getGovernanceDefinitionByGUID(userId, + licenseTypeGUID, + guidParameterName, + false, + false, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve the license type by its assigned unique document identifier. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching license type or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeResponse getLicenseTypeByDocId(String serverName, + String userId, + String documentIdentifier) + { + final String methodName = "getLicenseTypeByDocId"; + + final String documentIdParameterName = "documentId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeResponse response = new LicenseTypeResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + List licenseTypeElements = handler.getGovernanceDefinitionsByName(userId, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + documentIdentifier, + documentIdParameterName, + 0, + 0, + false, + false, + new Date(), + methodName); + + if ((licenseTypeElements != null) && (! licenseTypeElements.isEmpty())) + { + response.setElement(licenseTypeElements.get(0)); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Retrieve all the license types for a particular title. The title can include regEx wildcards. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody short description of the license + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching license types (null if no matching elements) or + * InvalidParameterException title or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeListResponse getLicenseTypesByTitle(String serverName, + String userId, + int startFrom, + int pageSize, + SearchStringRequestBody requestBody) + { + final String methodName = "getLicenseTypesByTitle"; + final String titleParameterName = "title"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeListResponse response = new LicenseTypeListResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + response.setElements(handler.findGovernanceDefinitions(userId, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + requestBody.getSearchString(), + titleParameterName, + 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; + } + + + /** + * Retrieve all the license type definitions for a specific governance domain. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching license type definitions or + * InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public LicenseTypeListResponse getLicenseTypeByDomainId(String serverName, + String userId, + int domainIdentifier, + int startFrom, + int pageSize) + { + final String methodName = "getLicenseTypeByDomainId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + LicenseTypeListResponse response = new LicenseTypeListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + response.setElements(handler.getGovernanceDefinitionsByDomain(userId, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + domainIdentifier, + startFrom, + pageSize, + false, + false, + new Date(), + methodName)); + + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /* ======================================= + * Licenses + */ + + /** + * Link an element to a license type and include details of the license in the relationship properties. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of the element being licensed + * @param licenseTypeGUID unique identifier for the license type + * @param requestBody the properties of the license + * + * @return guid or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public GUIDResponse licenseElement(String serverName, + String userId, + String elementGUID, + String licenseTypeGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "licenseElement"; + + final String elementGUIDParameterName = "elementGUID"; + final String licenseTypeGUIDParameterName = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof LicenseProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + LicenseProperties properties = (LicenseProperties) requestBody.getProperties(); + + response.setGUID(handler.licenseElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + elementGUID, + elementGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + licenseTypeGUID, + licenseTypeGUIDParameterName, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + properties.getLicenseId(), + properties.getStartDate(), + properties.getEndDate(), + properties.getConditions(), + properties.getLicensedBy(), + properties.getLicensedByTypeName(), + properties.getLicensedByPropertyName(), + properties.getCustodian(), + properties.getCustodianTypeName(), + properties.getCustodianPropertyName(), + properties.getLicensee(), + properties.getLicenseeTypeName(), + properties.getLicenseePropertyName(), + properties.getNotes(), + properties.getEffectiveFrom(), + properties.getEffectiveTo(), + false, + false, + new Date(), + methodName)); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(LicenseTypeProperties.class.getName(), methodName); + } + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Update the properties of a license. Remember to include the licenseId in the properties if the element has multiple + * licenses for the same license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license type + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param requestBody the properties of the license + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse updateLicense(String serverName, + String userId, + String licenseGUID, + boolean isMergeUpdate, + RelationshipRequestBody requestBody) + { + final String methodName = "updateLicense"; + final String licenseGUIDParameterName = "licenseGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + if (requestBody != null) + { + if (requestBody.getProperties() instanceof LicenseProperties) + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + LicenseProperties properties = (LicenseProperties) requestBody.getProperties(); + + handler.updateLicense(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + licenseGUID, + licenseGUIDParameterName, + properties.getLicenseId(), + properties.getStartDate(), + properties.getEndDate(), + properties.getConditions(), + properties.getLicensedBy(), + properties.getLicensedByTypeName(), + properties.getLicensedByPropertyName(), + properties.getCustodian(), + properties.getCustodianTypeName(), + properties.getCustodianPropertyName(), + properties.getLicensee(), + properties.getLicenseeTypeName(), + properties.getLicenseePropertyName(), + properties.getNotes(), + isMergeUpdate, + null, + null, + false, + false, + new Date(), + methodName); + } + else + { + restExceptionHandler.handleInvalidPropertiesObject(LicenseProperties.class.getName(), 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 license for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license type + * @param requestBody external source information. + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @SuppressWarnings(value="unused") + public VoidResponse unlicenseElement(String serverName, + String userId, + String licenseGUID, + RelationshipRequestBody requestBody) + { + final String methodName = "unlicenseElement"; + final String licenseGUIDParameterName = "licenseGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + LicenseHandler handler = instanceHandler.getLicenseTypeHandler(userId, serverName, methodName); + + if (requestBody != null) + { + handler.unlicenseElement(userId, + requestBody.getExternalSourceGUID(), + requestBody.getExternalSourceName(), + licenseGUID, + licenseGUIDParameterName, + false, + false, + new Date(), + methodName); + } + else + { + handler.unlicenseElement(userId, + null, + null, + licenseGUID, + licenseGUIDParameterName, + false, + false, + new Date(), + methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + + /** + * Return information about the elements linked to a license. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getLicensedElements(String serverName, + String userId, + String licenseTypeGUID, + int startFrom, + int pageSize) + { + final String methodName = "getLicensedElements"; + final String guidParameter = "licenseTypeGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + licenseTypeGUID, + guidParameter, + OpenMetadataAPIMapper.LICENSE_TYPE_TYPE_NAME, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + null, + null, + 1, + false, + false, + startFrom, + pageSize, + new Date(), + methodName)); + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Return information about the licenses linked to an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public RelatedElementListResponse getLicenses(String serverName, + String userId, + String elementGUID, + int startFrom, + int pageSize) + { + final String methodName = "getLicences"; + final String guidParameterName = "elementGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + RelatedElementListResponse response = new RelatedElementListResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + ReferenceableHandler handler = instanceHandler.getRelatedElementHandler(userId, serverName, methodName); + + response.setElementList(handler.getAttachedElements(userId, + elementGUID, + guidParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.LICENSE_TYPE_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; + } +} diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceCertificationsResource.java b/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceCertificationsResource.java index 85f75445e92..c4c1676cc1c 100644 --- a/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceCertificationsResource.java +++ b/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceCertificationsResource.java @@ -173,7 +173,7 @@ public CertificationTypeResponse getCertificationTypeByDocId(@PathVariable Strin * * @param serverName name of the server instance to connect to * @param userId calling user - * @param requestBody short description of the role + * @param requestBody short description of the certification * @param startFrom where to start from in the list of definitions * @param pageSize max number of results to return in one call * diff --git a/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceLicensesResource.java b/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceLicensesResource.java new file mode 100644 index 00000000000..01edc32cc37 --- /dev/null +++ b/open-metadata-implementation/access-services/governance-program/governance-program-spring/src/main/java/org/odpi/openmetadata/accessservices/governanceprogram/server/spring/GovernanceLicensesResource.java @@ -0,0 +1,355 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.governanceprogram.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.LicenseTypeListResponse; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.LicenseTypeResponse; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.ExternalSourceRequestBody; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.GovernanceDefinitionRequestBody; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.RelatedElementListResponse; +import org.odpi.openmetadata.accessservices.governanceprogram.rest.RelationshipRequestBody; +import org.odpi.openmetadata.accessservices.governanceprogram.server.LicenseRESTServices; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +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; + + +/** + * GovernanceLicensesResource sets up the license types that are part of an organization governance. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/governance-program/users/{userId}") + +@Tag(name="Governance Program OMAS", + description="The Governance Program OMAS provides APIs and events for tools and applications focused on defining a data strategy, planning support for a regulation and/or developing a governance program for the data landscape.", + externalDocs=@ExternalDocumentation(description="Governance Program Open Metadata Access Service (OMAS)", + url="https://egeria-project.org/services/omas/governance-program/overview/")) + +public class GovernanceLicensesResource +{ + private final LicenseRESTServices restAPI = new LicenseRESTServices(); + + /** + * Default constructor + */ + public GovernanceLicensesResource() + { + } + + + + /* ======================================== + * License Types + */ + + /** + * Create a description of the license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody license properties and initial status + * + * @return unique identifier of new definition or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not unique + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/license-types") + + public GUIDResponse createLicenseType(@PathVariable String serverName, + @PathVariable String userId, + @RequestBody GovernanceDefinitionRequestBody requestBody) + { + return restAPI.createLicenseType(serverName, userId, requestBody); + } + + + /** + * Update the properties of the license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to change + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param requestBody license properties + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/license-types/{licenseTypeGUID}/update") + + public VoidResponse updateLicenseType(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseTypeGUID, + @RequestParam boolean isMergeUpdate, + @RequestBody GovernanceDefinitionRequestBody requestBody) + { + return restAPI.updateLicenseType(serverName, userId, licenseTypeGUID, isMergeUpdate, requestBody); + } + + + /** + * Delete the properties of the license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to delete + * @param requestBody external source request body + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/license-types/{licenseTypeGUID}/delete") + + public VoidResponse deleteLicenseType(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseTypeGUID, + @RequestBody ExternalSourceRequestBody requestBody) + { + return restAPI.deleteLicenseType(serverName, userId, licenseTypeGUID, requestBody); + } + + + /** + * Retrieve the license type by the unique identifier assigned by this service when it was created. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseTypeGUID identifier of the governance definition to retrieve + * + * @return properties of the license type or + * InvalidParameterException guid or userId is null; guid is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/license-types/{licenseTypeGUID}") + + public LicenseTypeResponse getLicenseTypeByGUID(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseTypeGUID) + { + return restAPI.getLicenseTypeByGUID(serverName, userId, licenseTypeGUID); + } + + + /** + * Retrieve the license type by its assigned unique document identifier. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param documentIdentifier identifier to search for + * + * @return properties of the matching license type or + * InvalidParameterException documentIdentifier or userId is null; documentIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/license-types/by-document-id/{documentIdentifier}") + + public LicenseTypeResponse getLicenseTypeByDocId(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String documentIdentifier) + { + return restAPI.getLicenseTypeByDocId(serverName, userId, documentIdentifier); + } + + + /** + * Retrieve all the license types for a particular title. The title can include regEx wildcards. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param requestBody short description of the license + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return list of matching license types (null if no matching elements) or + * InvalidParameterException title or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/license-types/by-title") + + public LicenseTypeListResponse getLicenseTypesByTitle(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.getLicenseTypesByTitle(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve all the license type definitions for a specific governance domain. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param domainIdentifier identifier to search for + * @param startFrom where to start from in the list of definitions + * @param pageSize max number of results to return in one call + * + * @return properties of the matching license type definitions or + * InvalidParameterException domainIdentifier or userId is null; domainIdentifier is not recognized + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/license-types/by-domain/{domainIdentifier}") + + public LicenseTypeListResponse getLicenseTypeByDomainId(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable int domainIdentifier, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getLicenseTypeByDomainId(serverName, userId, domainIdentifier, startFrom, pageSize); + } + + + /* ======================================= + * Licenses + */ + + /** + * Link an element to a license type and include details of the license in the relationship properties. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier of the element being licensed + * @param licenseTypeGUID unique identifier for the license type + * @param requestBody the properties of the license + * + * @return guid or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/elements/{elementGUID}/license-types/{licenseTypeGUID}/license") + + public GUIDResponse licenseElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @PathVariable String licenseTypeGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.licenseElement(serverName, userId, elementGUID, licenseTypeGUID, requestBody); + } + + + /** + * Update the properties of a license. Remember to include the licenseId in the properties if the element has multiple + * licenses for the same license type. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param isMergeUpdate should the supplied properties overlay the existing properties or replace them + * @param requestBody the properties of the license + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/licenses/{licenseGUID}/update") + + public VoidResponse updateLicense(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseGUID, + @RequestParam boolean isMergeUpdate, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.updateLicense(serverName, userId, licenseGUID, isMergeUpdate, requestBody); + } + + + /** + * Remove the license for an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license relationship + * @param requestBody external source information. + * + * @return void or + * InvalidParameterException one of the properties is invalid + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping (path = "/licenses/{licenseGUID}/delete") + + public VoidResponse unlicenseElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseGUID, + @RequestBody RelationshipRequestBody requestBody) + { + return restAPI.unlicenseElement(serverName, userId, licenseGUID, requestBody); + } + + + + /** + * Return information about the elements linked to a license. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param licenseGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/elements/licenses/{licenseGUID}") + + public RelatedElementListResponse getCertifiedElements(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String licenseGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getLicensedElements(serverName, userId, licenseGUID, startFrom, pageSize); + } + + + /** + * Return information about the licenses linked to an element. + * + * @param serverName name of the server instance to connect to + * @param userId calling user + * @param elementGUID unique identifier for the license + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * + * @return properties of the license or + * InvalidParameterException qualifiedName or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @GetMapping (path = "/elements/{elementGUID}/licenses") + + public RelatedElementListResponse getLicenses(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String elementGUID, + @RequestParam int startFrom, + @RequestParam int pageSize) + { + return restAPI.getLicenses(serverName, userId, elementGUID, startFrom, pageSize); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/CertificationHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/CertificationHandler.java index 1acbff592ec..dc96e03fbe8 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/CertificationHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/CertificationHandler.java @@ -150,7 +150,6 @@ public List getCertifications(String userId, } - /** * Return the Certifications attached to a referenceable entity. * diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/LicenseHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/LicenseHandler.java index 10296c19de8..b53dc3c81e2 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/LicenseHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/LicenseHandler.java @@ -11,6 +11,7 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy; +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.repositoryconnector.OMRSRepositoryHelper; @@ -150,6 +151,7 @@ public List getLicenses(String userId, methodName); } + /** * Return the Licenses attached to an element. * @@ -244,4 +246,375 @@ public List getLicenses(String userId, return null; } -} + + + /** + * Create a link between a license type and an element that has achieved the license. + * + * @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 elementGUID unique identifier of the element + * @param elementGUIDParameterName parameter supplying the elementGUID + * @param elementTypeName typename of super-definition + * @param licenseTypeGUID unique identifier of the license type + * @param licenseTypeGUIDParameterName parameter supplying licenseTypeGUID + * @param licenseTypeGUIDTypeName type name of the licenseTypeGUID + * @param licenseGUID unique identifier of the license (maybe from an external system) + * @param start when did the license start + * @param end when will the license end + * @param conditions any conditions added to the license + * @param licensedBy unique name/identifier of the element for the person/organization licensing the element + * @param licensedByTypeName type of the licensedBy element + * @param licensedByPropertyName property name for the unique identifier from the licensedBy element + * @param custodian unique name/identifier of the element for the person/organization responsible for maintaining the license status + * @param custodianTypeName type of the custodian element + * @param custodianPropertyName property name for the unique identifier from the custodian element + * @param licensee unique name/identifier of the element for the person/organization receiving the license + * @param licenseeTypeName type of the licensee element + * @param licenseePropertyName property name for the unique identifier from the licensee element + * @param notes additional information, endorsements etc + * @param effectiveFrom starting time for this relationship (null for all time) + * @param effectiveTo ending time for this relationship (null for all time) + * @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 guid of license relationship + * @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 String licenseElement(String userId, + String externalSourceGUID, + String externalSourceName, + String elementGUID, + String elementGUIDParameterName, + String elementTypeName, + String licenseTypeGUID, + String licenseTypeGUIDParameterName, + String licenseTypeGUIDTypeName, + String licenseGUID, + Date start, + Date end, + String conditions, + String licensedBy, + String licensedByTypeName, + String licensedByPropertyName, + String custodian, + String custodianTypeName, + String custodianPropertyName, + String licensee, + String licenseeTypeName, + String licenseePropertyName, + String notes, + Date effectiveFrom, + Date effectiveTo, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return this.multiLinkElementToElement(userId, + externalSourceGUID, + externalSourceName, + elementGUID, + elementGUIDParameterName, + elementTypeName, + licenseTypeGUID, + licenseTypeGUIDParameterName, + licenseTypeGUIDTypeName, + forLineage, + forDuplicateProcessing, + supportedZones, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_GUID, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + getLicenseProperties(licenseGUID, + start, + end, + conditions, + licensedBy, + licensedByTypeName, + licensedByPropertyName, + custodian, + custodianTypeName, + custodianPropertyName, + licensee, + licenseeTypeName, + licenseePropertyName, + notes, + effectiveFrom, + effectiveTo, + methodName), + effectiveTime, + methodName); + } + + + /** + * Update the license relationship. + * + * @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 licenseGUID unique identifier for the relationship + * @param licenseGUIDParameterName parameter + * @param licenseId unique identifier of the license (maybe from an external system) + * @param start when did the license start + * @param end when will the license end + * @param conditions any conditions added to the license + * @param licensedBy unique name/identifier of the element for the person/organization licensing the element + * @param licensedByTypeName type of the licensedBy element + * @param licensedByPropertyName property name for the unique identifier from the licensedBy element + * @param custodian unique name/identifier of the element for the person/organization responsible for maintaining the license status + * @param custodianTypeName type of the custodian element + * @param custodianPropertyName property name for the unique identifier from the custodian element + * @param licensee unique name/identifier of the element for the person/organization receiving the license + * @param licenseeTypeName type of the licensee element + * @param licenseePropertyName property name for the unique identifier from the licensee element + * @param notes additional information, endorsements etc + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param effectiveFrom starting time for this relationship (null for all time) + * @param effectiveTo ending time for this relationship (null for all time) + * @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 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 void updateLicense(String userId, + String externalSourceGUID, + String externalSourceName, + String licenseGUID, + String licenseGUIDParameterName, + String licenseId, + Date start, + Date end, + String conditions, + String licensedBy, + String licensedByTypeName, + String licensedByPropertyName, + String custodian, + String custodianTypeName, + String custodianPropertyName, + String licensee, + String licenseeTypeName, + String licenseePropertyName, + String notes, + boolean isMergeUpdate, + Date effectiveFrom, + Date effectiveTo, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + this.updateRelationshipProperties(userId, + externalSourceGUID, + externalSourceName, + licenseGUID, + licenseGUIDParameterName, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + isMergeUpdate, + getLicenseProperties(licenseId, + start, + end, + conditions, + licensedBy, + licensedByTypeName, + licensedByPropertyName, + custodian, + custodianTypeName, + custodianPropertyName, + licensee, + licenseeTypeName, + licenseePropertyName, + notes, + effectiveFrom, + effectiveTo, + methodName), + forLineage, + forDuplicateProcessing, + supportedZones, + effectiveTime, + methodName); + } + + + /** + * Set up the properties for a license. + * + * @param licenseId unique identifier of the license (maybe from an external system) + * @param start when did the license start + * @param end when will the license end + * @param conditions any conditions added to the license + * @param licensedBy unique name/identifier of the element for the person/organization licensing the element + * @param licensedByTypeName type of the licensedBy element + * @param licensedByPropertyName property name for the unique identifier from the licensedBy element + * @param custodian unique name/identifier of the element for the person/organization responsible for maintaining the license status + * @param custodianTypeName type of the custodian element + * @param custodianPropertyName property name for the unique identifier from the custodian element + * @param licensee unique name/identifier of the element for the person/organization receiving the license + * @param licenseeTypeName type of the licensee element + * @param licenseePropertyName property name for the unique identifier from the licensee element + * @param notes additional information, endorsements etc + * @param effectiveFrom starting time for this relationship (null for all time) + * @param effectiveTo ending time for this relationship (null for all time) + * @param methodName calling method + * @return instance properties + */ + private InstanceProperties getLicenseProperties(String licenseId, + Date start, + Date end, + String conditions, + String licensedBy, + String licensedByTypeName, + String licensedByPropertyName, + String custodian, + String custodianTypeName, + String custodianPropertyName, + String licensee, + String licenseeTypeName, + String licenseePropertyName, + String notes, + Date effectiveFrom, + Date effectiveTo, + String methodName) + { + InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, + null, + OpenMetadataAPIMapper.LICENSE_GUID_PROPERTY_NAME, + licenseId, + methodName); + + properties = repositoryHelper.addDatePropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.START_PROPERTY_NAME, + start, + methodName); + + properties = repositoryHelper.addDatePropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.END_PROPERTY_NAME, + end, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.CONDITIONS_PROPERTY_NAME, + conditions, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.LICENSED_BY_PROPERTY_NAME, + licensedBy, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.LICENSED_BY_TYPE_NAME_PROPERTY_NAME, + licensedByTypeName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.LICENSED_BY_PROPERTY_NAME_PROPERTY_NAME, + licensedByPropertyName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.CUSTODIAN_PROPERTY_NAME, + custodian, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.CUSTODIAN_TYPE_NAME_PROPERTY_NAME, + custodianTypeName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.CUSTODIAN_PROPERTY_NAME_PROPERTY_NAME, + custodianPropertyName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.LICENSEE_PROPERTY_NAME, + licensee, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.LICENSEE_TYPE_NAME_PROPERTY_NAME, + licenseeTypeName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.LICENSEE_PROPERTY_NAME_PROPERTY_NAME, + licenseePropertyName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.NOTES_PROPERTY_NAME, + notes, + methodName); + + return this.setUpEffectiveDates(properties, effectiveFrom, effectiveTo); + } + + + /** + * Remove a relationship between two definitions. + * + * @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 userId calling user + * @param licenseGUID unique identifier of the license relationship + * @param licenseGUIDParameterName parameter supplying licenseGUID + * @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 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 void unlicenseElement(String userId, + String externalSourceGUID, + String externalSourceName, + String licenseGUID, + String licenseGUIDParameterName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + this.deleteRelationship(userId, + externalSourceGUID, + externalSourceName, + licenseGUID, + licenseGUIDParameterName, + OpenMetadataAPIMapper.LICENSE_OF_REFERENCEABLE_TYPE_NAME, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + } +} \ No newline at end of file