From 514cd27b1378d00b7504fdbd01d2efd12eeeda7d Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 28 Mar 2022 12:10:14 +0100 Subject: [PATCH 01/16] Prepare types for 3.8 Signed-off-by: Mandy Chessell --- .../opentypes/OpenMetadataTypesArchive.java | 505 ++++++-------- .../OpenMetadataTypesArchive3_7.java | 636 ++++++++++++++++++ 2 files changed, 845 insertions(+), 296 deletions(-) create mode 100644 open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive3_7.java diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java index 8414f42d5b1..3bc763d2c4d 100644 --- a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java @@ -8,6 +8,7 @@ import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchive; import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchiveType; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationPropagationRule; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EntityDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndCardinality; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndDef; @@ -43,7 +44,7 @@ public class OpenMetadataTypesArchive private static final String archiveName = "Open Metadata Types"; private static final String archiveDescription = "Standard types for open metadata repositories."; private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; - private static final String archiveVersion = "3.7"; + private static final String archiveVersion = "3.8"; private static final String originatorName = "Egeria"; private static final String originatorLicense = "Apache 2.0"; private static final Date creationDate = new Date(1588261366992L); @@ -151,7 +152,7 @@ public OpenMetadataArchive getOpenMetadataArchive() */ public void getOriginalTypes() { - OpenMetadataTypesArchive3_5 previousTypes = new OpenMetadataTypesArchive3_5(archiveBuilder); + OpenMetadataTypesArchive3_7 previousTypes = new OpenMetadataTypesArchive3_7(archiveBuilder); /* * Pull the types from previous releases. @@ -161,9 +162,11 @@ public void getOriginalTypes() /* * Calls for new and changed types go here */ - update003040ITAssetDeployments(); - update0233EventsAndLogs(); - updateArea7LineageRelationships(); + update0011ManagingReferenceables(); + update0015LinkedMediaTypes(); + update0030OperatingPlatforms(); + update0057SoftwareServices(); + update0070NetworksAndGateways(); } @@ -172,144 +175,33 @@ public void getOriginalTypes() */ /** - * Allow software capabilities to be supported by any type of IT Infrastructure - not just SoftwareServers + * SourcedFrom relationship has its cardinality the wrong way around */ - private void update003040ITAssetDeployments() + private void update0011ManagingReferenceables() { - this.archiveBuilder.addRelationshipDef(getDeployedOnRelationship()); - this.archiveBuilder.addRelationshipDef(getOperatingPlatformUseRelationship()); - this.archiveBuilder.addTypeDefPatch(deprecateSoftwareServerPlatformDeploymentRelationship()); - this.archiveBuilder.addTypeDefPatch(deprecateSoftwareServerDeploymentRelationship()); - this.archiveBuilder.addTypeDefPatch(deprecateHostOperatingPlatformRelationship()); + this.archiveBuilder.addTypeDefPatch(updateSourcedFromRelationship()); } - - private RelationshipDef getDeployedOnRelationship() + private TypeDefPatch updateSourcedFromRelationship() { - final String guid = "6932ba75-9522-4a06-a4a4-ee60a4df6aab"; - final String name = "DeployedOn"; - final String description = "Identifies an IT Infrastructure asset that is deployed to a specific destination."; - final String descriptionGUID = null; - - final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - - RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - classificationPropagationRule); - - RelationshipEndDef relationshipEndDef; - - /* - * Set up end 1. - */ - final String end1EntityType = "ITInfrastructure"; - final String end1AttributeName = "deployedElement"; - final String end1AttributeDescription = "IT infrastructure deployed to this asset."; - final String end1AttributeDescriptionGUID = null; - final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); - relationshipDef.setEndDef1(relationshipEndDef); - - /* - * Set up end 2. - */ - final String end2EntityType = "Asset"; - final String end2AttributeName = "deployedTo"; - final String end2AttributeDescription = "Deployment destination."; - final String end2AttributeDescriptionGUID = null; - final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; - - relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); - relationshipDef.setEndDef2(relationshipEndDef); - - /* - * Build the attributes + * Create the Patch */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "deploymentTime"; - final String attribute1Description = "Time that the IT Infrastructure was deployed."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "deployer"; - final String attribute2Description = "Person, organization or engine that deployed the IT Infrastructure."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "deployerTypeName"; - final String attribute3Description = "Type name of deployer."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "deployerPropertyName"; - final String attribute4Description = "Identifying property name of deployer."; - final String attribute4DescriptionGUID = null; - final String attribute5Name = "deploymentStatus"; - final String attribute5Description = "The operational status of the the IT Infrastructure on the specific destination."; - final String attribute5DescriptionGUID = null; + final String typeName = "SourcedFrom"; - property = archiveHelper.getDateTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - property = archiveHelper.getEnumTypeDefAttribute("OperationalStatus", - attribute5Name, - attribute5Description, - attribute5DescriptionGUID); - properties.add(property); - - relationshipDef.setPropertiesDefinition(properties); - - return relationshipDef; - } - - - - private RelationshipDef getOperatingPlatformUseRelationship() - { - final String guid = "0943e0ba-73ac-476b-8ebe-2ef30ba44976"; - final String name = "OperatingPlatformUse"; - final String description = "Identifies the operating platform installed on the IT Infrastructure asset."; - final String descriptionGUID = null; - - final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - classificationPropagationRule); + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); RelationshipEndDef relationshipEndDef; /* * Set up end 1. */ - final String end1EntityType = "OperatingPlatform"; - final String end1AttributeName = "operatingPlatforms"; - final String end1AttributeDescription = "Software installed."; + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "resultingElement"; + final String end1AttributeDescription = "Element created from the template."; final String end1AttributeDescriptionGUID = null; final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; @@ -318,266 +210,214 @@ private RelationshipDef getOperatingPlatformUseRelationship() end1AttributeDescription, end1AttributeDescriptionGUID, end1Cardinality); - relationshipDef.setEndDef1(relationshipEndDef); + typeDefPatch.setEndDef1(relationshipEndDef); /* * Set up end 2. */ - final String end2EntityType = "ITInfrastructure"; - final String end2AttributeName = "installedOn"; - final String end2AttributeDescription = "Where the operating platform is running."; + final String end2EntityType = "Referenceable"; + final String end2AttributeName = "templateElement"; + final String end2AttributeDescription = "Template element providing information."; final String end2AttributeDescriptionGUID = null; - final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.AT_MOST_ONE; relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), end2AttributeName, end2AttributeDescription, end2AttributeDescriptionGUID, end2Cardinality); - relationshipDef.setEndDef2(relationshipEndDef); - - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "installTime"; - final String attribute1Description = "Time that the software was installed on the IT Infrastructure."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "deployer"; - final String attribute2Description = "Person, organization or engine that installed the software."; - final String attribute2DescriptionGUID = null; - final String attribute3Name = "deployerTypeName"; - final String attribute3Description = "Type name of deployer."; - final String attribute3DescriptionGUID = null; - final String attribute4Name = "deployerPropertyName"; - final String attribute4Description = "Identifying property name of deployer."; - final String attribute4DescriptionGUID = null; + typeDefPatch.setEndDef2(relationshipEndDef); - property = archiveHelper.getDateTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute3Name, - attribute3Description, - attribute3DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute4Name, - attribute4Description, - attribute4DescriptionGUID); - properties.add(property); - - relationshipDef.setPropertiesDefinition(properties); - - return relationshipDef; + return typeDefPatch; } - private TypeDefPatch deprecateSoftwareServerPlatformDeploymentRelationship() - { - /* - * Create the Patch - */ - final String typeName = "SoftwareServerPlatformDeployment"; - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + /* + * ------------------------------------------------------------------------------------------------------- + */ - return typeDefPatch; + /** + * Add multi-link flags + */ + private void update0015LinkedMediaTypes() + { + this.archiveBuilder.addTypeDefPatch(updateExternalReferenceLinkRelationship()); + this.archiveBuilder.addTypeDefPatch(updateMediaReferenceRelationship()); } - - private TypeDefPatch deprecateSoftwareServerDeploymentRelationship() + private TypeDefPatch updateExternalReferenceLinkRelationship() { /* * Create the Patch */ - final String typeName = "SoftwareServerDeployment"; + final String typeName = "ExternalReferenceLink"; TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); typeDefPatch.setUpdatedBy(originatorName); typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); return typeDefPatch; } - private TypeDefPatch deprecateHostOperatingPlatformRelationship() + private TypeDefPatch updateMediaReferenceRelationship() { /* * Create the Patch */ - final String typeName = "HostOperatingPlatform"; + final String typeName = "MediaReference"; TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); typeDefPatch.setUpdatedBy(originatorName); typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); return typeDefPatch; } - /* * ------------------------------------------------------------------------------------------------------- */ /** - * Change the lineage relationships to allow multiLink and add missing properties. + * Add new software services */ - private void updateArea7LineageRelationships() + private void update0057SoftwareServices() { - this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnLineageMappingRelationship()); - this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnDataFlowRelationship()); - this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnControlFlowRelationship()); - this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnProcessCallRelationship()); + this.archiveBuilder.addEntityDef(addMetadataRepositoryServiceEntity()); + this.archiveBuilder.addEntityDef(addSecurityServiceEntity()); } - - private TypeDefPatch enableMultiLinkOnLineageMappingRelationship() + private EntityDef addMetadataRepositoryServiceEntity() { - /* - * Create the Patch - */ - final String typeName = "LineageMapping"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setUpdateMultiLink(true); - typeDefPatch.setMultiLink(true); + final String guid = "27891e52-1255-4a33-98a2-377717a25334"; + final String name = "MetadataRepositoryService"; + final String description = "Provides access to a metadata repository - either local or remote."; + final String descriptionGUID = null; - /* - * Build the attributes - */ - List properties = new ArrayList<>(); - TypeDefAttribute property; + final String superTypeName = "SoftwareService"; - final String attribute1Name = "qualifiedName"; - final String attribute1Description = "Unique name of the lineage flow."; - final String attribute1DescriptionGUID = null; - final String attribute2Name = "description"; - final String attribute2Description = "Description and purpose of the lineage flow."; - final String attribute2DescriptionGUID = null; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + } - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - properties.add(property); + private EntityDef addSecurityServiceEntity() + { + final String guid = "2df2069f-6475-400c-bf8c-6d2072a55d47"; + final String name = "SecurityService"; + final String description = "Provides security services - classifications identify specific capabilities."; + final String descriptionGUID = null; - typeDefPatch.setPropertyDefinitions(properties); + final String superTypeName = "SoftwareService"; - return typeDefPatch; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); } - private TypeDefPatch enableMultiLinkOnDataFlowRelationship() - { - /* - * Create the Patch - */ - final String typeName = "DataFlow"; - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); - - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setUpdateMultiLink(true); - typeDefPatch.setMultiLink(true); + /* + * ------------------------------------------------------------------------------------------------------- + */ - return typeDefPatch; + /** + * Add software package dependency relationship + */ + private void update0030OperatingPlatforms() + { + this.archiveBuilder.addRelationshipDef(addSoftwarePackageDependencyRelationship()); } - - private TypeDefPatch enableMultiLinkOnControlFlowRelationship() + private RelationshipDef addSoftwarePackageDependencyRelationship() { - /* - * Create the Patch - */ - final String typeName = "ControlFlow"; - - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + final String guid = "2c05beaf-e313-47f8-ac18-2298140b2ad9"; + final String name = "SoftwarePackageDependency"; + final String description = "Shows the software packages being used within an asset."; + final String descriptionGUID = null; - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setUpdateMultiLink(true); - typeDefPatch.setMultiLink(true); + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - return typeDefPatch; - } + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + RelationshipEndDef relationshipEndDef; - private TypeDefPatch enableMultiLinkOnProcessCallRelationship() - { /* - * Create the Patch + * Set up end 1. */ - final String typeName = "ProcessCall"; + final String end1EntityType = "Asset"; + final String end1AttributeName = "runningWithAsset"; + final String end1AttributeDescription = "Assets making use of software package."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; - TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); - typeDefPatch.setUpdatedBy(originatorName); - typeDefPatch.setUpdateTime(creationDate); - typeDefPatch.setUpdateMultiLink(true); - typeDefPatch.setMultiLink(true); /* - * Build the attributes + * Set up end 2. */ - List properties = new ArrayList<>(); - TypeDefAttribute property; - - final String attribute1Name = "lineNumber"; - final String attribute1Description = "Location of the call in the implementation."; - final String attribute1DescriptionGUID = null; - - - property = archiveHelper.getStringTypeDefAttribute(attribute1Name, - attribute1Description, - attribute1DescriptionGUID); - properties.add(property); + final String end2EntityType = "Collection"; + final String end2AttributeName = "dependsOnSoftwarePackages"; + final String end2AttributeDescription = "Collection of software packages."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; - typeDefPatch.setPropertyDefinitions(properties); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); - return typeDefPatch; + return relationshipDef; } + /* * ------------------------------------------------------------------------------------------------------- */ /** - * Add associated log relationship + * Simplify modelling networks */ - private void update0233EventsAndLogs() + private void update0070NetworksAndGateways() { - this.archiveBuilder.addRelationshipDef(addAssociatedLogRelationship()); + this.archiveBuilder.addRelationshipDef(getVisibleEndpointRelationship()); + this.archiveBuilder.addTypeDefPatch(deprecateHostNetworkRelationship()); + this.archiveBuilder.addTypeDefPatch(updateNetworkGatewayLinkRelationship()); } - private RelationshipDef addAssociatedLogRelationship() + private RelationshipDef getVisibleEndpointRelationship() { - final String guid = "0999e2b9-45d6-42c4-9767-4b74b0b48b89"; - final String name = "AssociatedLog"; - final String description = "Defines destination information for the log of activity associated with an element."; + final String guid = "5e1722c7-0167-49a0-bd77-fbf9dc5eb5bb"; + final String name = "VisibleEndpoint"; + final String description = "Shows that network that an endpoint is visible through."; final String descriptionGUID = null; final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; @@ -594,9 +434,9 @@ private RelationshipDef addAssociatedLogRelationship() /* * Set up end 1. */ - final String end1EntityType = "Referenceable"; - final String end1AttributeName = "logSubjects"; - final String end1AttributeDescription = "Elements that the log records describe."; + final String end1EntityType = "Endpoint"; + final String end1AttributeName = "visibleEndpoints"; + final String end1AttributeDescription = "Endpoint callable through network."; final String end1AttributeDescriptionGUID = null; final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; @@ -611,9 +451,9 @@ private RelationshipDef addAssociatedLogRelationship() /* * Set up end 2. */ - final String end2EntityType = "Asset"; - final String end2AttributeName = "associatedLogs"; - final String end2AttributeDescription = "Destinations for log records."; + final String end2EntityType = "Network"; + final String end2AttributeName = "visibleInNetwork"; + final String end2AttributeDescription = "Networks from which the endpoint can be called."; final String end2AttributeDescriptionGUID = null; final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; @@ -627,6 +467,79 @@ private RelationshipDef addAssociatedLogRelationship() return relationshipDef; } + private TypeDefPatch deprecateHostNetworkRelationship() + { + /* + * Create the Patch + */ + final String typeName = "HostNetwork"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + + return typeDefPatch; + } + + + private TypeDefPatch updateNetworkGatewayLinkRelationship() + { + /* + * Create the Patch + */ + final String typeName = "NetworkGatewayLink"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "name"; + final String attribute1Description = "Name for the network mapping."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "description"; + final String attribute2Description = "Description and purpose of the network mapping."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "externalEndpointAddress"; + final String attribute3Description = "Network address used by callers to the network gateway."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "externalEndpointAddress"; + final String attribute4Description = "Network address that the network gateway maps the request to."; + final String attribute4DescriptionGUID = null; + + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + /* * ------------------------------------------------------------------------------------------------------- diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive3_7.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive3_7.java new file mode 100644 index 00000000000..18ca6ed6ae8 --- /dev/null +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive3_7.java @@ -0,0 +1,636 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.opentypes; + + +import org.odpi.openmetadata.repositoryservices.archiveutilities.OMRSArchiveBuilder; +import org.odpi.openmetadata.repositoryservices.archiveutilities.OMRSArchiveHelper; +import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchive; +import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchiveType; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationPropagationRule; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndCardinality; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.RelationshipEndDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefPatch; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefStatus; +import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.OMRSLogicErrorException; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * OpenMetadataTypesArchive builds an open metadata archive containing all of the standard open metadata types. + * These types have hardcoded dates and guids so that however many times this archive is rebuilt, it will + * produce the same content. + *

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

+ *

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

+ */ +public class OpenMetadataTypesArchive3_7 +{ + /* + * This is the header information for the archive. + */ + private static final String archiveGUID = "bce3b0a0-662a-4f87-b8dc-844078a11a6e"; + private static final String archiveName = "Open Metadata Types"; + private static final String archiveDescription = "Standard types for open metadata repositories."; + private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; + private static final String archiveVersion = "3.7"; + private static final String originatorName = "Egeria"; + private static final String originatorLicense = "Apache 2.0"; + private static final Date creationDate = new Date(1588261366992L); + + /* + * Specific values for initializing TypeDefs + */ + private static final long versionNumber = 1L; + private static final String versionName = "1.0"; + + + private OMRSArchiveBuilder archiveBuilder; + private OMRSArchiveHelper archiveHelper; + + /** + * Default constructor sets up the archive builder. This in turn sets up the header for the archive. + */ + public OpenMetadataTypesArchive3_7() + { + this.archiveBuilder = new OMRSArchiveBuilder(archiveGUID, + archiveName, + archiveDescription, + archiveType, + archiveVersion, + originatorName, + originatorLicense, + creationDate, + null); + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); + } + + + /** + * Chained constructor sets up the archive builder. This in turn sets up the header for the archive. + * + * @param archiveBuilder accumulator for types + */ + public OpenMetadataTypesArchive3_7(OMRSArchiveBuilder archiveBuilder) + { + this.archiveBuilder = archiveBuilder; + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); + } + + + /** + * Return the unique identifier for this archive. + * + * @return String guid + */ + public String getArchiveGUID() + { + return archiveGUID; + } + + + /** + * Returns the open metadata type archive containing all of the standard open metadata types. + * + * @return populated open metadata archive object + */ + public OpenMetadataArchive getOpenMetadataArchive() + { + final String methodName = "getOpenMetadataArchive"; + + if (this.archiveBuilder != null) + { + /* + * Build the type archive. + */ + this.getOriginalTypes(); + + /* + * The completed archive is ready to be packaged up and returned + */ + return this.archiveBuilder.getOpenMetadataArchive(); + } + else + { + /* + * This is a logic error since it means the creation of the archive builder threw an exception + * in the constructor and so this object should not be used. + */ + throw new OMRSLogicErrorException(OMRSErrorCode.ARCHIVE_UNAVAILABLE.getMessageDefinition(), + this.getClass().getName(), + methodName); + } + } + + + /** + * Add the types from this archive to the archive builder supplied in the + * constructor. + */ + public void getOriginalTypes() + { + OpenMetadataTypesArchive3_5 previousTypes = new OpenMetadataTypesArchive3_5(archiveBuilder); + + /* + * Pull the types from previous releases. + */ + previousTypes.getOriginalTypes(); + + /* + * Calls for new and changed types go here + */ + update003040ITAssetDeployments(); + update0233EventsAndLogs(); + updateArea7LineageRelationships(); + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + /** + * Allow software capabilities to be supported by any type of IT Infrastructure - not just SoftwareServers + */ + private void update003040ITAssetDeployments() + { + this.archiveBuilder.addRelationshipDef(getDeployedOnRelationship()); + this.archiveBuilder.addRelationshipDef(getOperatingPlatformUseRelationship()); + this.archiveBuilder.addTypeDefPatch(deprecateSoftwareServerPlatformDeploymentRelationship()); + this.archiveBuilder.addTypeDefPatch(deprecateSoftwareServerDeploymentRelationship()); + this.archiveBuilder.addTypeDefPatch(deprecateHostOperatingPlatformRelationship()); + } + + + private RelationshipDef getDeployedOnRelationship() + { + final String guid = "6932ba75-9522-4a06-a4a4-ee60a4df6aab"; + final String name = "DeployedOn"; + final String description = "Identifies an IT Infrastructure asset that is deployed to a specific destination."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "ITInfrastructure"; + final String end1AttributeName = "deployedElement"; + final String end1AttributeDescription = "IT infrastructure deployed to this asset."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "Asset"; + final String end2AttributeName = "deployedTo"; + final String end2AttributeDescription = "Deployment destination."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "deploymentTime"; + final String attribute1Description = "Time that the IT Infrastructure was deployed."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "deployer"; + final String attribute2Description = "Person, organization or engine that deployed the IT Infrastructure."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "deployerTypeName"; + final String attribute3Description = "Type name of deployer."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "deployerPropertyName"; + final String attribute4Description = "Identifying property name of deployer."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "deploymentStatus"; + final String attribute5Description = "The operational status of the the IT Infrastructure on the specific destination."; + final String attribute5DescriptionGUID = null; + + property = archiveHelper.getDateTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getEnumTypeDefAttribute("OperationalStatus", + attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + + + private RelationshipDef getOperatingPlatformUseRelationship() + { + final String guid = "0943e0ba-73ac-476b-8ebe-2ef30ba44976"; + final String name = "OperatingPlatformUse"; + final String description = "Identifies the operating platform installed on the IT Infrastructure asset."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "OperatingPlatform"; + final String end1AttributeName = "operatingPlatforms"; + final String end1AttributeDescription = "Software installed."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "ITInfrastructure"; + final String end2AttributeName = "installedOn"; + final String end2AttributeDescription = "Where the operating platform is running."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "installTime"; + final String attribute1Description = "Time that the software was installed on the IT Infrastructure."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "deployer"; + final String attribute2Description = "Person, organization or engine that installed the software."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "deployerTypeName"; + final String attribute3Description = "Type name of deployer."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "deployerPropertyName"; + final String attribute4Description = "Identifying property name of deployer."; + final String attribute4DescriptionGUID = null; + + property = archiveHelper.getDateTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + private TypeDefPatch deprecateSoftwareServerPlatformDeploymentRelationship() + { + /* + * Create the Patch + */ + final String typeName = "SoftwareServerPlatformDeployment"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + + return typeDefPatch; + } + + + private TypeDefPatch deprecateSoftwareServerDeploymentRelationship() + { + /* + * Create the Patch + */ + final String typeName = "SoftwareServerDeployment"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + + return typeDefPatch; + } + + + private TypeDefPatch deprecateHostOperatingPlatformRelationship() + { + /* + * Create the Patch + */ + final String typeName = "HostOperatingPlatform"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setTypeDefStatus(TypeDefStatus.DEPRECATED_TYPEDEF); + + return typeDefPatch; + } + + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + /** + * Change the lineage relationships to allow multiLink and add missing properties. + */ + private void updateArea7LineageRelationships() + { + this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnLineageMappingRelationship()); + this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnDataFlowRelationship()); + this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnControlFlowRelationship()); + this.archiveBuilder.addTypeDefPatch(enableMultiLinkOnProcessCallRelationship()); + } + + + private TypeDefPatch enableMultiLinkOnLineageMappingRelationship() + { + /* + * Create the Patch + */ + final String typeName = "LineageMapping"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "qualifiedName"; + final String attribute1Description = "Unique name of the lineage flow."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "description"; + final String attribute2Description = "Description and purpose of the lineage flow."; + final String attribute2DescriptionGUID = null; + + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + private TypeDefPatch enableMultiLinkOnDataFlowRelationship() + { + /* + * Create the Patch + */ + final String typeName = "DataFlow"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); + + return typeDefPatch; + } + + + private TypeDefPatch enableMultiLinkOnControlFlowRelationship() + { + /* + * Create the Patch + */ + final String typeName = "ControlFlow"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); + + return typeDefPatch; + } + + + private TypeDefPatch enableMultiLinkOnProcessCallRelationship() + { + /* + * Create the Patch + */ + final String typeName = "ProcessCall"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + typeDefPatch.setUpdateMultiLink(true); + typeDefPatch.setMultiLink(true); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "lineNumber"; + final String attribute1Description = "Location of the call in the implementation."; + final String attribute1DescriptionGUID = null; + + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + /** + * Add associated log relationship + */ + private void update0233EventsAndLogs() + { + this.archiveBuilder.addRelationshipDef(addAssociatedLogRelationship()); + } + + private RelationshipDef addAssociatedLogRelationship() + { + final String guid = "0999e2b9-45d6-42c4-9767-4b74b0b48b89"; + final String name = "AssociatedLog"; + final String description = "Defines destination information for the log of activity associated with an element."; + final String descriptionGUID = null; + + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "logSubjects"; + final String end1AttributeDescription = "Elements that the log records describe."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "Asset"; + final String end2AttributeName = "associatedLogs"; + final String end2AttributeDescription = "Destinations for log records."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + return relationshipDef; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + +} + From c051acef2745791e449d799d07baa118b5c07ec7 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Tue, 29 Mar 2022 22:56:48 +0100 Subject: [PATCH 02/16] Add external reference support Signed-off-by: Mandy Chessell --- .../api/ExternalReferencesInterface.java | 149 ++- .../properties/AssetManagerProperties.java | 2 + .../properties/AssetProperties.java | 4 +- .../CapabilityDeploymentProperties.java | 285 +++++ .../ComplexSchemaTypeProperties.java | 37 +- .../properties/ConnectionProperties.java | 2 + .../properties/ConnectorTypeProperties.java | 2 + .../properties/ControlFlowProperties.java | 18 +- .../properties/DataAssetProperties.java | 2 + .../properties/DataFlowProperties.java | 18 +- .../properties/DataSetProperties.java | 23 +- .../properties/DataStoreProperties.java | 4 +- .../properties/DeploymentProperties.java | 319 ++++++ .../properties/EndpointProperties.java | 2 + .../properties/EnumSchemaTypeProperties.java | 2 + ...ExternalGlossaryElementLinkProperties.java | 4 +- .../ExternalReferenceLinkProperties.java | 10 +- .../properties/OperationalStatus.java | 118 +++ .../properties/ReferenceableProperties.java | 62 +- .../properties/RelationshipProperties.java | 162 +++ .../properties/ServerAssetUseProperties.java | 257 +++++ .../rest/EffectiveTimeQueryRequestBody.java | 124 +++ .../ExternalReferenceLinkRequestBody.java | 122 +++ .../rest/ExternalReferenceRequestBody.java | 34 +- .../assetmanager/rest/NameRequestBody.java | 3 +- .../rest/SearchStringRequestBody.java | 3 +- .../client/ExchangeClientBase.java | 28 + .../ExternalReferenceExchangeClient.java | 332 ++++-- .../ExternalReferenceConverter.java | 121 +++ .../ExternalReferenceLinkConverter.java | 131 +++ .../handlers/DataAssetExchangeHandler.java | 1 - .../ExternalReferenceExchangeHandler.java | 991 ++++++++++++++++++ .../server/AssetManagerInstanceHandler.java | 28 + .../server/AssetManagerServicesInstance.java | 51 +- ...ExternalReferenceExchangeRESTServices.java | 879 ++++++++++++++++ .../ExternalReferenceExchangeResource.java | 412 ++++++++ .../ExternalIdentifierHandler.java | 28 + .../ExternalReferenceBuilder.java | 238 +++++ .../ExternalReferenceHandler.java | 545 ++++++++-- .../ExternalReferenceLinkHandler.java | 406 +++++++ .../OpenMetadataAPIGenericConverter.java | 22 + .../OpenMetadataAPIGenericHandler.java | 16 +- .../OpenMetadataAPIMapper.java | 2 +- .../OperatingPlatformHandler.java | 4 +- .../ffdc/GenericHandlersAuditCode.java | 11 +- .../server/OCFMetadataInstanceHandler.java | 10 +- .../server/OCFMetadataRESTServices.java | 7 +- .../server/OCFMetadataServicesInstance.java | 32 +- 48 files changed, 5815 insertions(+), 248 deletions(-) create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CapabilityDeploymentProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DeploymentProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/OperationalStatus.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RelationshipProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ServerAssetUseProperties.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceLinkRequestBody.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceLinkConverter.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExternalReferenceExchangeHandler.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/ExternalReferenceExchangeRESTServices.java create mode 100644 open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/ExternalReferenceExchangeResource.java create mode 100644 open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceBuilder.java create mode 100644 open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/ExternalReferencesInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/ExternalReferencesInterface.java index 85db9147ee1..c5cdea354b0 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/ExternalReferencesInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/ExternalReferencesInterface.java @@ -12,6 +12,7 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import java.util.Date; import java.util.List; import java.util.Map; @@ -114,22 +115,48 @@ void deleteExternalReference(String userId, * @param userId the name of the calling user. * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerIsHome ensure that only the asset manager can update this asset * @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. * + * @return Unique identifier for new relationship + * + * @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. + */ + String linkExternalReferenceToElement(String userId, + String assetManagerGUID, + String assetManagerName, + boolean assetManagerIsHome, + String attachedToGUID, + String externalReferenceGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + + /** + * Update the link between an external reference to an object. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to. + * @param externalReferenceLinkGUID 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 assetManagerGUID, - String assetManagerName, - String attachedToGUID, - String externalReferenceGUID, - ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException; + void updateExternalReferenceToElementLink(String userId, + String assetManagerGUID, + String assetManagerName, + String externalReferenceLinkGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; /** @@ -138,8 +165,7 @@ void linkExternalReferenceToElement(String userId, * @param userId the name of the calling user. * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller - * @param attachedToGUID object linked to external references. - * @param externalReferenceGUID identifier of the external reference. + * @param externalReferenceLinkGUID identifier of the external reference relationship. * * @throws InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. * @throws PropertyServerException the server is not available. @@ -148,32 +174,36 @@ void linkExternalReferenceToElement(String userId, void unlinkExternalReferenceFromElement(String userId, String assetManagerGUID, String assetManagerName, - String attachedToGUID, - String externalReferenceGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException; + String externalReferenceLinkGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; /** - * Return information about a specific external reference. + * Retrieve the list of external references sorted in open metadata. * - * @param userId calling user + * @param userId the name of the calling user. * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller - * @param externalReferenceGUID unique identifier for the external reference + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. * - * @return properties of the external reference + * @return links to addition information. * - * @throws InvalidParameterException externalReferenceGUID or userId is null - * @throws PropertyServerException problem accessing property server - * @throws UserNotAuthorizedException security access problem + * @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. */ - ExternalReferenceElement getExternalReferenceByGUID(String userId, - String assetManagerGUID, - String assetManagerName, - String externalReferenceGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException; + List getExternalReferences(String userId, + String assetManagerGUID, + String assetManagerName, + Date effectiveTime, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + /** * Retrieve the list of external references for this resourceId. @@ -182,6 +212,7 @@ ExternalReferenceElement getExternalReferenceByGUID(String userId, * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param resourceId unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -195,6 +226,7 @@ List getExternalReferencesById(String userId, String assetManagerGUID, String assetManagerName, String resourceId, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, @@ -207,6 +239,7 @@ List getExternalReferencesById(String userId, * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param url URL of the external resource. + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -220,18 +253,49 @@ List getExternalReferencesByURL(String userId, String assetManagerGUID, String assetManagerName, String url, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException; + + /** + * Retrieve the list of external references for this name. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param name qualifiedName or displayNAme of the external resource + * @param effectiveTime the time that the retrieved elements must be effective for + * @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 getExternalReferencesByName(String userId, + String assetManagerGUID, + String assetManagerName, + String name, + Date effectiveTime, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; + + /** * Retrieve the list of external reference created on behalf of the named asset manager. * * @param userId calling user * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom paging start point * @param pageSize maximum results that can be returned * @@ -244,6 +308,7 @@ List getExternalReferencesByURL(String userId, List getExternalReferencesForAssetManager(String userId, String assetManagerGUID, String assetManagerName, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, UserNotAuthorizedException, @@ -257,6 +322,7 @@ List getExternalReferencesForAssetManager(String userI * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param searchString regular expression (RegEx) to search for + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -270,6 +336,7 @@ List findExternalReferences(String userId, String assetManagerGUID, String assetManagerName, String searchString, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, @@ -283,6 +350,7 @@ List findExternalReferences(String userId, * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param attachedToGUID object linked to external reference. + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -296,8 +364,35 @@ List retrieveAttachedExternalReferences(String use String assetManagerGUID, String assetManagerName, String attachedToGUID, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException; + + + + /** + * Return information about a specific external reference. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param externalReferenceGUID unique identifier for the external reference + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 assetManagerGUID, + String assetManagerName, + String externalReferenceGUID, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetManagerProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetManagerProperties.java index 254e9906df0..f8eb9daa522 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetManagerProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetManagerProperties.java @@ -61,6 +61,8 @@ public String toString() ", usage='" + getUsage() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetProperties.java index 3625da740d8..1b342b90123 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/AssetProperties.java @@ -112,7 +112,7 @@ public void setTechnicalDescription(String description) @Override public String toString() { - return "DataAssetProperties{" + + return "AssetProperties{" + "technicalName='" + technicalName + '\'' + ", technicalDescription='" + technicalDescription + '\'' + ", displayName='" + getDisplayName() + '\'' + @@ -122,6 +122,8 @@ public String toString() ", usage='" + getUsage() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CapabilityDeploymentProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CapabilityDeploymentProperties.java new file mode 100644 index 00000000000..b7ae3f5d70a --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/CapabilityDeploymentProperties.java @@ -0,0 +1,285 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.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; + +/** + * CapabilityDeploymentProperties describes the properties for the SupportedSoftwareCapability relationship between a ITInfrastructure asset + * and a Software Capability. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class CapabilityDeploymentProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + private static final String deploymentTimeProperty = "deploymentTime"; + private static final String deployerProperty = "deployer"; + private static final String deployerTypeNameProperty = "deployerTypeName"; + private static final String deployerPropertyNameProperty = "deployerPropertyName"; + private static final String deploymentStatusProperty = "serverCapabilityStatus"; + + + private Date deploymentTime = null; + private String deployer = null; + private String deployerTypeName = null; + private String deployerPropertyName = null; + private OperationalStatus softwareCapabilityStatus = null; + + + /** + * Default constructor + */ + public CapabilityDeploymentProperties() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public CapabilityDeploymentProperties(CapabilityDeploymentProperties template) + { + super(template); + + if (template != null) + { + deploymentTime = template.getDeploymentTime(); + deployer = template.getDeployer(); + deployerTypeName = template.getDeployerTypeName(); + deployerPropertyName = template.getDeployerPropertyName(); + softwareCapabilityStatus = template.getSoftwareCapabilityStatus(); + } + } + + + /** + * Turn the properties into a property map. + * + * @return property map. + */ + public Map cloneToMap() + { + Map propertyMap = new HashMap<>(); + + if (deploymentTime != null) + { + propertyMap.put(deploymentTimeProperty, deploymentTime); + } + + if (deployer != null) + { + propertyMap.put(deployerProperty, deployer); + } + + if (deployerTypeName != null) + { + propertyMap.put(deployerTypeNameProperty, deployerTypeName); + } + + if (deployerPropertyName != null) + { + propertyMap.put(deployerPropertyNameProperty, deployerPropertyName); + } + + if (softwareCapabilityStatus != null) + { + propertyMap.put(deploymentStatusProperty, softwareCapabilityStatus.getOpenTypeOrdinal()); + } + + if (! propertyMap.isEmpty()) + { + propertyMap = null; + } + + return propertyMap; + } + + + + /** + * Return the time that the capability was deployed into the server. + * + * @return date/time + */ + public Date getDeploymentTime() + { + return deploymentTime; + } + + + /** + * Set up the time that the capability was deployed into the server. + * + * @param deploymentTime date/time + */ + public void setDeploymentTime(Date deploymentTime) + { + this.deploymentTime = deploymentTime; + } + + + /** + * Return the userId of the deployer. + * + * @return name + */ + public String getDeployer() + { + return deployer; + } + + + /** + * Set up the userId of the deployer. + * + * @param deployer name + */ + public void setDeployer(String deployer) + { + this.deployer = deployer; + } + + + /** + * Return the type name of the element used to represent the deployer. + * + * @return string name + */ + public String getDeployerTypeName() + { + return deployerTypeName; + } + + + /** + * Set up the type name of the element used to represent the deployer. + * + * @param deployerTypeName string name + */ + public void setDeployerTypeName(String deployerTypeName) + { + this.deployerTypeName = deployerTypeName; + } + + + /** + * Return the property name from the element used to represent the deployer. + * + * @return string name + */ + public String getDeployerPropertyName() + { + return deployerPropertyName; + } + + + /** + * Set up the property name from the element used to represent the deployer. + * + * @param deployerPropertyName string name + */ + public void setDeployerPropertyName(String deployerPropertyName) + { + this.deployerPropertyName = deployerPropertyName; + } + + + /** + * Return whether the capability is ready to use. + * + * @return operational status enum + */ + public OperationalStatus getSoftwareCapabilityStatus() + { + return softwareCapabilityStatus; + } + + + /** + * Set up whether the capability is ready to use. + * + * @param softwareCapabilityStatus operational status enum + */ + public void setSoftwareCapabilityStatus(OperationalStatus softwareCapabilityStatus) + { + this.softwareCapabilityStatus = softwareCapabilityStatus; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "CapabilityDeploymentProperties{" + + "deploymentTime=" + deploymentTime + + ", deployer='" + deployer + '\'' + + ", deployerTypeName='" + deployerTypeName + '\'' + + ", deployerPropertyName='" + deployerPropertyName + '\'' + + ", softwareCapabilityStatus=" + softwareCapabilityStatus + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + '}'; + } + + + /** + * 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; + } + CapabilityDeploymentProperties that = (CapabilityDeploymentProperties) objectToCompare; + return Objects.equals(deploymentTime, that.deploymentTime) && + Objects.equals(deployer, that.deployer) && + Objects.equals(deployerTypeName, that.deployerTypeName) && + Objects.equals(deployerPropertyName, that.deployerPropertyName) && + softwareCapabilityStatus == that.softwareCapabilityStatus; + } + + + /** + * Hash code for this object + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), deploymentTime, deployer, deployerTypeName, deployerPropertyName, softwareCapabilityStatus); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ComplexSchemaTypeProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ComplexSchemaTypeProperties.java index 0df0be60b80..5bde16e62f1 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ComplexSchemaTypeProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ComplexSchemaTypeProperties.java @@ -77,19 +77,34 @@ public void setAttributeCount(int attributeCount) @Override public String toString() { - return "ComplexSchemaType{" + - "attributeCount='" + attributeCount + '\'' + - ", displayName='" + getDisplayName() + '\'' + - ", versionNumber='" + getVersionNumber() + '\'' + - ", author='" + getAuthor() + '\'' + - ", usage='" + getUsage() + '\'' + - ", encodingStandard='" + getEncodingStandard() + '\'' + - ", qualifiedName='" + getQualifiedName() + '\'' + - ", additionalProperties=" + getAdditionalProperties() + - ", extendedProperties=" + getExtendedProperties() + - '}'; + return "ComplexSchemaTypeProperties{" + + "attributeCount=" + attributeCount + + ", versionNumber='" + getVersionNumber() + '\'' + + ", author='" + getAuthor() + '\'' + + ", usage='" + getUsage() + '\'' + + ", encodingStandard='" + getEncodingStandard() + '\'' + + ", namespace='" + getNamespace() + '\'' + + ", formula='" + getFormula() + '\'' + + ", queries=" + getQueries() + + ", isDeprecated=" + getIsDeprecated() + + ", technicalName='" + getTechnicalName() + '\'' + + ", technicalDescription='" + getTechnicalDescription() + '\'' + + ", displayName='" + getDisplayName() + '\'' + + ", summary='" + getSummary() + '\'' + + ", description='" + getDescription() + '\'' + + ", abbreviation='" + getAbbreviation() + '\'' + + ", usage='" + getUsage() + '\'' + + ", qualifiedName='" + getQualifiedName() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", vendorProperties=" + getVendorProperties() + + ", typeName='" + getTypeName() + '\'' + + ", extendedProperties=" + getExtendedProperties() + + '}'; } + /** * Compare the values of the supplied object with those stored in the current object. * diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectionProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectionProperties.java index b5730f7798d..f8c94e16335 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectionProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectionProperties.java @@ -324,6 +324,8 @@ public String toString() ", securedProperties=" + securedProperties + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectorTypeProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectorTypeProperties.java index 58e51d13b80..41dbdbc2ca5 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectorTypeProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ConnectorTypeProperties.java @@ -334,6 +334,8 @@ public String toString() ", recognizedSecuredProperties=" + recognizedSecuredProperties + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ControlFlowProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ControlFlowProperties.java index ea669a8a357..2fe6b772287 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ControlFlowProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ControlFlowProperties.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import java.io.Serializable; +import java.util.Date; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -18,7 +19,7 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class ControlFlowProperties implements Serializable +public class ControlFlowProperties extends RelationshipProperties { private static final long serialVersionUID = 1L; @@ -43,6 +44,7 @@ public ControlFlowProperties() */ public ControlFlowProperties(ControlFlowProperties template) { + super(template); if (template != null) { qualifiedName = template.getQualifiedName(); @@ -131,6 +133,8 @@ public String toString() "qualifiedName='" + qualifiedName + '\'' + ", description='" + description + '\'' + ", guard='" + guard + '\'' + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + '}'; } @@ -152,10 +156,14 @@ public boolean equals(Object objectToCompare) { return false; } + if (! super.equals(objectToCompare)) + { + return false; + } ControlFlowProperties that = (ControlFlowProperties) objectToCompare; - return Objects.equals(getQualifiedName(), that.getQualifiedName()) && - Objects.equals(getDescription(), that.getDescription()) && - Objects.equals(getGuard(), that.getGuard()); + return Objects.equals(qualifiedName, that.qualifiedName) && + Objects.equals(description, that.description) && + Objects.equals(guard, that.guard); } @@ -167,6 +175,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(qualifiedName, description, guard); + return Objects.hash(super.hashCode(), qualifiedName, description, guard); } } \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataAssetProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataAssetProperties.java index 07421bf76af..8f393591ffa 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataAssetProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataAssetProperties.java @@ -97,6 +97,8 @@ public String toString() ", usage='" + getUsage() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataFlowProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataFlowProperties.java index 9e79b201f9a..3d79d8ac4f4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataFlowProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataFlowProperties.java @@ -16,7 +16,7 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class DataFlowProperties implements Serializable +public class DataFlowProperties extends RelationshipProperties { private static final long serialVersionUID = 1L; @@ -41,6 +41,8 @@ public DataFlowProperties() */ public DataFlowProperties(DataFlowProperties template) { + super(template); + if (template != null) { qualifiedName = template.getQualifiedName(); @@ -129,6 +131,8 @@ public String toString() "qualifiedName='" + qualifiedName + '\'' + ", description='" + description + '\'' + ", formula='" + formula + '\'' + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + '}'; } @@ -150,10 +154,14 @@ public boolean equals(Object objectToCompare) { return false; } + if (! super.equals(objectToCompare)) + { + return false; + } DataFlowProperties that = (DataFlowProperties) objectToCompare; - return Objects.equals(getQualifiedName(), that.getQualifiedName()) && - Objects.equals(getDescription(), that.getDescription()) && - Objects.equals(getFormula(), that.getFormula()); + return Objects.equals(qualifiedName, that.qualifiedName) && + Objects.equals(description, that.description) && + Objects.equals(formula, that.formula); } @@ -165,6 +173,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(qualifiedName, description, formula); + return Objects.hash(super.hashCode(), qualifiedName, description, formula); } } \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataSetProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataSetProperties.java index 59e91aab29f..747cae1d42f 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataSetProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataSetProperties.java @@ -48,12 +48,21 @@ public DataSetProperties(DataSetProperties template) public String toString() { return "DataSetProperties{" + - "displayName='" + getDisplayName() + '\'' + - ", description='" + getDescription() + '\'' + - ", qualifiedName='" + getQualifiedName() + '\'' + - ", additionalProperties=" + getAdditionalProperties() + - ", typeName='" + getTypeName() + '\'' + - ", extendedProperties=" + getExtendedProperties() + - '}'; + "isReferenceAsset=" + getIsReferenceAsset() + + ", technicalName='" + getTechnicalName() + '\'' + + ", technicalDescription='" + getTechnicalDescription() + '\'' + + ", displayName='" + getDisplayName() + '\'' + + ", summary='" + getSummary() + '\'' + + ", description='" + getDescription() + '\'' + + ", abbreviation='" + getAbbreviation() + '\'' + + ", usage='" + getUsage() + '\'' + + ", qualifiedName='" + getQualifiedName() + '\'' + + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + ", vendorProperties=" + getVendorProperties() + + ", typeName='" + getTypeName() + '\'' + + ", extendedProperties=" + getExtendedProperties() + + '}'; } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataStoreProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataStoreProperties.java index 83152d94967..6eacb90c3fd 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataStoreProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DataStoreProperties.java @@ -253,9 +253,9 @@ public String toString() ", encodingLanguage='" + encodingLanguage + '\'' + ", encodingDescription='" + encodingDescription + '\'' + ", encodingProperties=" + encodingProperties + + ", isReferenceAsset=" + getIsReferenceAsset() + ", technicalName='" + getTechnicalName() + '\'' + ", technicalDescription='" + getTechnicalDescription() + '\'' + - ", isReferenceAsset=" + getIsReferenceAsset() + ", displayName='" + getDisplayName() + '\'' + ", summary='" + getSummary() + '\'' + ", description='" + getDescription() + '\'' + @@ -263,6 +263,8 @@ public String toString() ", usage='" + getUsage() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DeploymentProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DeploymentProperties.java new file mode 100644 index 00000000000..15ea9e3674d --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/DeploymentProperties.java @@ -0,0 +1,319 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.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; + +/** + * DeploymentProperties describes the properties for the DeployedOn relationship between an IT Infrastructure asset + * and a destination asset. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class DeploymentProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + private static final String deploymentTimeProperty = "deploymentTime"; + private static final String deployerProperty = "deployer"; + private static final String deployerTypeNameProperty = "deployerTypeName"; + private static final String deployerPropertyNameProperty = "deployerPropertyName"; + private static final String deploymentStatusProperty = "deploymentStatus"; + + + private Date deploymentTime = null; + private String deployer = null; + private String deployerTypeName = null; + private String deployerPropertyName = null; + private OperationalStatus deploymentStatus = null; + + + /** + * Default constructor + */ + public DeploymentProperties() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public DeploymentProperties(DeploymentProperties template) + { + super(template); + + if (template != null) + { + deploymentTime = template.getDeploymentTime(); + deployer = template.getDeployer(); + deployerTypeName = template.getDeployerTypeName(); + deployerPropertyName = template.getDeployerPropertyName(); + deploymentStatus = template.getDeploymentStatus(); } + } + + + /** + * Copy/clone constructor + * + * @param properties property map + * @param effectiveFrom effective from + * @param effectiveTo effective to + */ + public DeploymentProperties(Map properties, + Date effectiveFrom, + Date effectiveTo) + { + super(); + + super.setEffectiveFrom(effectiveFrom); + super.setEffectiveTo(effectiveTo); + + if (properties != null) + { + deploymentTime = (Date)properties.get(deploymentTimeProperty); + deployer = properties.get(deployerProperty).toString(); + deployerTypeName = properties.get(deployerTypeNameProperty).toString(); + deployerPropertyName = properties.get(deployerPropertyNameProperty).toString(); + + deploymentStatus = OperationalStatus.DISABLED; + int operationalStatus = (Integer)properties.get(deploymentStatusProperty); + + if (operationalStatus == 1) + { + deploymentStatus = OperationalStatus.ENABLED; + } + } + } + + + /** + * Turn the properties into a property map. + * + * @return property map. + */ + public Map cloneToMap() + { + Map propertyMap = new HashMap<>(); + + if (deploymentTime != null) + { + propertyMap.put(deploymentTimeProperty, deploymentTime); + } + + if (deployer != null) + { + propertyMap.put(deployerProperty, deployer); + } + + if (deployerTypeName != null) + { + propertyMap.put(deployerTypeNameProperty, deployerTypeName); + } + + if (deployerPropertyName != null) + { + propertyMap.put(deployerPropertyNameProperty, deployerPropertyName); + } + + if (deploymentStatus != null) + { + propertyMap.put(deploymentStatusProperty, deploymentStatus.getOpenTypeOrdinal()); + } + + if (! propertyMap.isEmpty()) + { + propertyMap = null; + } + + return propertyMap; + } + + + + /** + * Return the time that the capability was deployed into the server. + * + * @return date/time + */ + public Date getDeploymentTime() + { + return deploymentTime; + } + + + /** + * Set up the time that the capability was deployed into the server. + * + * @param deploymentTime date/time + */ + public void setDeploymentTime(Date deploymentTime) + { + this.deploymentTime = deploymentTime; + } + + + /** + * Return the userId of the deployer. + * + * @return name + */ + public String getDeployer() + { + return deployer; + } + + + /** + * Set up the userId of the deployer. + * + * @param deployer name + */ + public void setDeployer(String deployer) + { + this.deployer = deployer; + } + + + /** + * Return the type name of the element used to represent the deployer. + * + * @return string name + */ + public String getDeployerTypeName() + { + return deployerTypeName; + } + + + /** + * Set up the type name of the element used to represent the deployer. + * + * @param deployerTypeName string name + */ + public void setDeployerTypeName(String deployerTypeName) + { + this.deployerTypeName = deployerTypeName; + } + + + /** + * Return the property name from the element used to represent the deployer. + * + * @return string name + */ + public String getDeployerPropertyName() + { + return deployerPropertyName; + } + + + /** + * Set up the property name from the element used to represent the deployer. + * + * @param deployerPropertyName string name + */ + public void setDeployerPropertyName(String deployerPropertyName) + { + this.deployerPropertyName = deployerPropertyName; + } + + + /** + * Return whether the capability is ready to use. + * + * @return operational status enum + */ + public OperationalStatus getDeploymentStatus() + { + return deploymentStatus; + } + + + /** + * Set up whether the capability is ready to use. + * + * @param deploymentStatus operational status enum + */ + public void setDeploymentStatus(OperationalStatus deploymentStatus) + { + this.deploymentStatus = deploymentStatus; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "DeploymentProperties{" + + "deploymentTime=" + deploymentTime + + ", deployer='" + deployer + '\'' + + ", deployerTypeName='" + deployerTypeName + '\'' + + ", deployerPropertyName='" + deployerPropertyName + '\'' + + ", deploymentStatus=" + deploymentStatus + + ", cloneToMap=" + cloneToMap() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + '}'; + } + + + /** + * 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; + } + DeploymentProperties that = (DeploymentProperties) objectToCompare; + return Objects.equals(deploymentTime, that.deploymentTime) && + Objects.equals(deployer, that.deployer) && + Objects.equals(deployerTypeName, that.deployerTypeName) && + Objects.equals(deployerPropertyName, that.deployerPropertyName) && + deploymentStatus == that.deploymentStatus; + } + + + /** + * Hash code for this object + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), deploymentTime, deployer, deployerTypeName, deployerPropertyName, deploymentStatus); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EndpointProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EndpointProperties.java index 9191b41419f..c91272e8166 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EndpointProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EndpointProperties.java @@ -198,6 +198,8 @@ public String toString() ", usage='" + getUsage() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EnumSchemaTypeProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EnumSchemaTypeProperties.java index 4f07eb3616c..dbc8dd74bec 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EnumSchemaTypeProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/EnumSchemaTypeProperties.java @@ -95,6 +95,8 @@ public String toString() ", usage='" + getUsage() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + ", vendorProperties=" + getVendorProperties() + ", typeName='" + getTypeName() + '\'' + ", extendedProperties=" + getExtendedProperties() + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalGlossaryElementLinkProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalGlossaryElementLinkProperties.java index c0b92173cd0..848a4e1bcc6 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalGlossaryElementLinkProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalGlossaryElementLinkProperties.java @@ -20,7 +20,7 @@ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ExternalGlossaryElementLinkProperties implements Serializable +public class ExternalGlossaryElementLinkProperties extends RelationshipProperties { private static final long serialVersionUID = 1L; @@ -45,6 +45,8 @@ public ExternalGlossaryElementLinkProperties() */ public ExternalGlossaryElementLinkProperties(ExternalGlossaryElementLinkProperties template) { + super(template); + if (template != null) { elementIdentifier = template.getElementIdentifier(); diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalReferenceLinkProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalReferenceLinkProperties.java index 9a4d91969d6..f4766700e78 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalReferenceLinkProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalReferenceLinkProperties.java @@ -18,7 +18,7 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class ExternalReferenceLinkProperties implements Serializable +public class ExternalReferenceLinkProperties extends RelationshipProperties { private static final long serialVersionUID = 1L; @@ -104,6 +104,8 @@ public String toString() return "ExternalReferenceLinkProperties{" + "linkId='" + linkId + '\'' + ", linkDescription='" + linkDescription + '\'' + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + '}'; } @@ -125,6 +127,10 @@ public boolean equals(Object objectToCompare) { return false; } + if (! super.equals(objectToCompare)) + { + return false; + } ExternalReferenceLinkProperties that = (ExternalReferenceLinkProperties) objectToCompare; return Objects.equals(linkId, that.linkId) && Objects.equals(linkDescription, that.linkDescription); @@ -139,6 +145,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(linkId, linkDescription); + return Objects.hash(super.hashCode(), linkId, linkDescription); } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/OperationalStatus.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/OperationalStatus.java new file mode 100644 index 00000000000..13564ad9c51 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/OperationalStatus.java @@ -0,0 +1,118 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * OperationalStatus defines whether a component is usable. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum OperationalStatus implements Serializable +{ + DISABLED (0, 0, "Disabled", "The component is deployed but not operational."), + ENABLED (1, 1, "Enabled", "The component is operational."); + + public static final String ENUM_TYPE_GUID = "24e1e33e-9250-4a6c-8b07-05c7adec3a1d"; + public static final String ENUM_TYPE_NAME = "OperationalStatus"; + + private final int openTypeOrdinal; + + private final int ordinal; + private final String name; + private final String description; + + private static final long serialVersionUID = 1L; + + + /** + * Constructor to set up the instance of this enum. + * + * @param ordinal code number + * @param openTypeOrdinal code number from the equivalent Enum Type + * @param name default name + * @param description default description + */ + OperationalStatus(int ordinal, + int openTypeOrdinal, + String name, + String description) + { + this.ordinal = ordinal; + this.openTypeOrdinal = openTypeOrdinal; + this.name = name; + this.description = description; + } + + + /** + * Return the numeric representation of the enumeration. + * + * @return int ordinal + */ + public int getOrdinal() { return ordinal; } + + + /** + * Return the default name of the enumeration. + * + * @return String name + */ + public String getName() { return name; } + + + /** + * Return the default description of the enumeration. + * + * @return String description + */ + public String getDescription() { return description; } + + + /** + * Return the code for this enum that comes from the Open Metadata Type that this enum represents. + * + * @return int code number + */ + public int getOpenTypeOrdinal() + { + return openTypeOrdinal; + } + + + /** + * Return the unique identifier for the open metadata enum type that this enum class represents. + * + * @return string guid + */ + public String getOpenTypeGUID() { return ENUM_TYPE_GUID; } + + + /** + * Return the unique name for the open metadata enum type that this enum class represents. + * + * @return string name + */ + public String getOpenTypeName() { return ENUM_TYPE_NAME; } + + + /** + * toString() JSON-style + * + * @return string description + */ + @Override + public String toString() + { + return "OperationalStatus : " + name; + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ReferenceableProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ReferenceableProperties.java index cb8880ea5cf..e9488f56a66 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ReferenceableProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ReferenceableProperties.java @@ -39,6 +39,9 @@ public class ReferenceableProperties implements Serializable private String qualifiedName = null; private Map additionalProperties = null; + private Date effectiveFrom = null; + private Date effectiveTo = null; + private Map vendorProperties = null; private String typeName = null; @@ -65,6 +68,9 @@ public ReferenceableProperties(ReferenceableProperties template) qualifiedName = template.getQualifiedName(); additionalProperties = template.getAdditionalProperties(); + effectiveFrom = template.getEffectiveFrom(); + effectiveTo = template.getEffectiveTo(); + vendorProperties = template.getVendorProperties(); typeName = template.getTypeName(); @@ -129,6 +135,50 @@ else if (additionalProperties.isEmpty()) } + /** + * 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 specific properties for the specific technology vendor. * @@ -256,10 +306,12 @@ public boolean equals(Object objectToCompare) } ReferenceableProperties that = (ReferenceableProperties) objectToCompare; return Objects.equals(qualifiedName, that.qualifiedName) && - Objects.equals(additionalProperties, that.additionalProperties) && - Objects.equals(vendorProperties, that.vendorProperties) && - Objects.equals(typeName, that.typeName) && - Objects.equals(extendedProperties, that.extendedProperties); + Objects.equals(additionalProperties, that.additionalProperties) && + Objects.equals(effectiveFrom, that.effectiveFrom) && + Objects.equals(effectiveTo, that.effectiveTo) && + Objects.equals(vendorProperties, that.vendorProperties) && + Objects.equals(typeName, that.typeName) && + Objects.equals(extendedProperties, that.extendedProperties); } @@ -271,6 +323,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(qualifiedName, additionalProperties, vendorProperties, typeName, extendedProperties); + return Objects.hash(qualifiedName, additionalProperties, effectiveFrom, effectiveTo, vendorProperties, typeName, extendedProperties); } } \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RelationshipProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RelationshipProperties.java new file mode 100644 index 00000000000..0ae044ac094 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/RelationshipProperties.java @@ -0,0 +1,162 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +import java.io.Serializable; +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; + +/** + * ConfigurationItemProperties provides the base class for infrastructure items. This extends referenceable 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 = ServerAssetUseProperties.class, name = "ServerAssetUseProperties"), + @JsonSubTypes.Type(value = ExternalGlossaryElementLinkProperties.class, name = "ExternalGlossaryElementLinkProperties"), + @JsonSubTypes.Type(value = CapabilityDeploymentProperties.class, name = "CapabilityDeploymentProperties"), + @JsonSubTypes.Type(value = DeploymentProperties.class, name = "DeploymentProperties"), + @JsonSubTypes.Type(value = ControlFlowProperties.class, name = "ControlFlowProperties"), + @JsonSubTypes.Type(value = DataFlowProperties.class, name = "DataFlowProperties"), + @JsonSubTypes.Type(value = ProcessCallProperties.class, name = "ProcessCallProperties"), + }) +public class RelationshipProperties implements Serializable +{ + private static final long serialVersionUID = 1L; + + private Date effectiveFrom = null; + private Date effectiveTo = null; + + + /** + * Default constructor + */ + public RelationshipProperties() + { + super(); + } + + + /** + * Copy/clone constructor. Retrieves values from the supplied template + * + * @param template element to copy + */ + public RelationshipProperties(RelationshipProperties template) + { + if (template != null) + { + effectiveFrom = template.getEffectiveFrom(); + effectiveTo = template.getEffectiveTo(); + } + } + + + /** + * 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; + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "ConfigurationItemRelationshipProperties{" + + "effectiveFrom=" + effectiveFrom + + ", effectiveTo=" + effectiveTo + + '}'; + } + + + /** + * 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 has 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-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ServerAssetUseProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ServerAssetUseProperties.java new file mode 100644 index 00000000000..fbedbd3efd8 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ServerAssetUseProperties.java @@ -0,0 +1,257 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * ServerAssetUseProperties describes the properties for the ServerAssetUse relationship between a software + * server capability and an asset. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ServerAssetUseProperties extends RelationshipProperties +{ + private static final long serialVersionUID = 1L; + + private ServerAssetUseType useType = null; + private String description = null; + private boolean minimumInstancesSet = false; + private int minimumInstances = 0; + private boolean maximumInstancesSet = false; + private int maximumInstances = 0; + + + /** + * Default constructor + */ + public ServerAssetUseProperties() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public ServerAssetUseProperties(ServerAssetUseProperties template) + { + super(template); + + if (template != null) + { + this.useType = template.getUseType(); + this.description = template.getDescription(); + this.minimumInstancesSet = template.getMinimumInstancesSet(); + this.minimumInstances = template.getMinimumInstances(); + this.maximumInstancesSet = template.getMaximumInstancesSet(); + this.maximumInstances = template.getMaximumInstances(); + } + } + + + /** + * Return the types of interactions that the software server capability may have with the asset. + * + * @return ServerAssetUseType enum + */ + public ServerAssetUseType getUseType() + { + return useType; + } + + + /** + * Set up the types of interactions that the software server capability may have with the asset. + * + * @param useType ServerAssetUseType enum + */ + public void setUseType(ServerAssetUseType useType) + { + this.useType = useType; + } + + + /** + * Return the description of the relationship between the software server capability and the asset. + * + * @return text + */ + public String getDescription() + { + return description; + } + + + /** + * Set up the description of the relationship between the software server capability and the asset. + * + * @param description text + */ + public void setDescription(String description) + { + this.description = description; + } + + + /** + * Return whether the minimum instances value is set up or just default. + * + * @return flag + */ + public boolean getMinimumInstancesSet() + { + return minimumInstancesSet; + } + + + /** + * Set up whether the minimum instances value is set up or just default. + * + * @param minimumInstancesSet flag + */ + public void setMinimumInstancesSet(boolean minimumInstancesSet) + { + this.minimumInstancesSet = minimumInstancesSet; + } + + + /** + * Return the minimum number of running asset instances controlled by the software server capability. + * + * @return integer + */ + public int getMinimumInstances() + { + return minimumInstances; + } + + + /** + * Set up the minimum number of running asset instances controlled by the software server capability. + * + * @param minimumInstances integer + */ + public void setMinimumInstances(int minimumInstances) + { + this.minimumInstances = minimumInstances; + } + + + /** + * Return whether the maximum instances value is set up or just default. + * + * @return flag + */ + public boolean getMaximumInstancesSet() + { + return maximumInstancesSet; + } + + + /** + * Set up whether the maximum instances value is set up or just default. + * + * @param maximumInstancesSet flag + */ + public void setMaximumInstancesSet(boolean maximumInstancesSet) + { + this.maximumInstancesSet = maximumInstancesSet; + } + + + /** + * Return the maximum number of running asset instances controlled by the software server capability. + * + * @return integer + */ + public int getMaximumInstances() + { + return maximumInstances; + } + + + /** + * Set up the maximum number of running asset instances controlled by the software server capability. + * + * @param maximumInstances integer + */ + public void setMaximumInstances(int maximumInstances) + { + this.maximumInstances = maximumInstances; + } + + + /** + * JSON-style toString. + * + * @return list of properties and their values. + */ + @Override + public String toString() + { + return "ServerAssetUseProperties{" + + "useType=" + useType + + ", description='" + description + '\'' + + ", minimumInstancesSet=" + minimumInstancesSet + + ", minimumInstances=" + minimumInstances + + ", maximumInstancesSet=" + maximumInstancesSet + + ", maximumInstances=" + maximumInstances + + ", effectiveFrom=" + getEffectiveFrom() + + ", effectiveTo=" + getEffectiveTo() + + '}'; + } + + + /** + * 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; + } + ServerAssetUseProperties that = (ServerAssetUseProperties) objectToCompare; + return minimumInstancesSet == that.minimumInstancesSet && + minimumInstances == that.minimumInstances && + maximumInstancesSet == that.maximumInstancesSet && + maximumInstances == that.maximumInstances && + useType == that.useType && + Objects.equals(description, that.description); + } + + + /** + * Hash code for this object + * + * @return int + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), useType, description, minimumInstancesSet, minimumInstances, maximumInstancesSet, maximumInstances); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java new file mode 100644 index 00000000000..eb5cb696552 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/EffectiveTimeQueryRequestBody.java @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.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; + +/** + * EffectiveTimeRequestBody carries the date/time for a query. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class EffectiveTimeQueryRequestBody extends AssetManagerIdentifiersRequestBody +{ + private static final long serialVersionUID = 1L; + + private Date effectiveTime = null; + + + /** + * Default constructor + */ + public EffectiveTimeQueryRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor + * + * @param template object to copy + */ + public EffectiveTimeQueryRequestBody(EffectiveTimeQueryRequestBody template) + { + if (template != null) + { + effectiveTime = template.getEffectiveTime(); + } + } + + + /** + * Return the date/time to use for the query. + * + * @return date object + */ + public Date getEffectiveTime() + { + return effectiveTime; + } + + + /** + * Set up the date/time to use for the query. + * + * @param effectiveTime date object + */ + public void setEffectiveTime(Date effectiveTime) + { + this.effectiveTime = effectiveTime; + } + + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "EffectiveTimeQueryRequestBody{" + + "effectiveTime=" + effectiveTime + + '}'; + } + + + /** + * 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; + } + EffectiveTimeQueryRequestBody that = (EffectiveTimeQueryRequestBody) objectToCompare; + return Objects.equals(effectiveTime, that.effectiveTime); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), effectiveTime); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceLinkRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceLinkRequestBody.java new file mode 100644 index 00000000000..17039cdfd98 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceLinkRequestBody.java @@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.rest; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalReferenceLinkProperties; + +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * ExternalGlossaryLinkRequestBody describes the request body used to create/update links to external glossary elements. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExternalReferenceLinkRequestBody extends AssetManagerIdentifiersRequestBody +{ + private static final long serialVersionUID = 1L; + + private ExternalReferenceLinkProperties elementProperties = null; + + + /** + * Default constructor + */ + public ExternalReferenceLinkRequestBody() + { + super(); + } + + + /** + * Copy/clone constructor. + * + * @param template object to copy + */ + public ExternalReferenceLinkRequestBody(ExternalReferenceLinkRequestBody template) + { + if (template != null) + { + elementProperties = template.getElementProperties(); + } + } + + /** + * Return the properties for the element. + * + * @return properties object + */ + public ExternalReferenceLinkProperties getElementProperties() + { + return elementProperties; + } + + + /** + * Set up the properties for the element. + * + * @param elementProperties properties object + */ + public void setElementProperties(ExternalReferenceLinkProperties elementProperties) + { + this.elementProperties = elementProperties; + } + + + /** + * JSON-style toString + * + * @return return string containing the property names and values + */ + @Override + public String toString() + { + return "ExternalReferenceLinkRequestBody{" + + "elementProperties=" + elementProperties + + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + + ", assetManagerName='" + getAssetManagerName() + '\'' + + '}'; + } + + + /** + * Return comparison result based on the content of the properties. + * + * @param objectToCompare test object + * @return result of comparison + */ + @Override + public boolean equals(Object objectToCompare) + { + if (this == objectToCompare) + { + return true; + } + if (objectToCompare == null || getClass() != objectToCompare.getClass()) + { + return false; + } + ExternalReferenceLinkRequestBody that = (ExternalReferenceLinkRequestBody) objectToCompare; + return Objects.equals(getElementProperties(), that.getElementProperties()); + } + + + /** + * Return hash code for this object + * + * @return int hash code + */ + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), elementProperties); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceRequestBody.java index 95c03b53ef1..96d252e19c4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/ExternalReferenceRequestBody.java @@ -28,6 +28,7 @@ public class ExternalReferenceRequestBody implements Serializable private MetadataCorrelationProperties metadataCorrelationProperties = null; private ExternalReferenceProperties elementProperties = null; + private String anchorGUID = null; /** @@ -50,6 +51,7 @@ public ExternalReferenceRequestBody(ExternalReferenceRequestBody template) { metadataCorrelationProperties = template.getMetadataCorrelationProperties(); elementProperties = template.getElementProperties(); + anchorGUID = template.getAnchorGUID(); } } @@ -98,6 +100,30 @@ public void setElementProperties(ExternalReferenceProperties elementProperties) } + /** + * Set up an optional anchor GUID for the new external reference. The assumption is that the external reference + * will be linked to this element. + * + * @return string guid + */ + public String getAnchorGUID() + { + return anchorGUID; + } + + + /** + * Set up an optional anchor GUID for the new external reference. The assumption is that the external reference + * will be linked to this element. + * + * @param anchorGUID string guid + */ + public void setAnchorGUID(String anchorGUID) + { + this.anchorGUID = anchorGUID; + } + + /** * JSON-style toString * @@ -109,6 +135,7 @@ public String toString() return "ExternalReferenceRequestBody{" + "metadataCorrelationProperties=" + metadataCorrelationProperties + ", elementProperties=" + elementProperties + + ", anchorGUID='" + anchorGUID + '\'' + '}'; } @@ -131,8 +158,9 @@ public boolean equals(Object objectToCompare) return false; } ExternalReferenceRequestBody that = (ExternalReferenceRequestBody) objectToCompare; - return Objects.equals(getMetadataCorrelationProperties(), that.getMetadataCorrelationProperties()) && - Objects.equals(getElementProperties(), that.getElementProperties()); + return Objects.equals(metadataCorrelationProperties, that.metadataCorrelationProperties) && + Objects.equals(elementProperties, that.elementProperties) && + Objects.equals(anchorGUID, that.anchorGUID); } @@ -144,6 +172,6 @@ public boolean equals(Object objectToCompare) @Override public int hashCode() { - return Objects.hash(super.hashCode(), metadataCorrelationProperties, elementProperties); + return Objects.hash(super.hashCode(), metadataCorrelationProperties, anchorGUID, elementProperties); } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java index 1477aaf2abc..7428328a1fa 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/NameRequestBody.java @@ -20,7 +20,7 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class NameRequestBody extends AssetManagerIdentifiersRequestBody +public class NameRequestBody extends EffectiveTimeQueryRequestBody { private static final long serialVersionUID = 1L; @@ -109,6 +109,7 @@ public String toString() return "NameRequestBody{" + "name='" + name + '\'' + ", nameParameterName='" + nameParameterName + '\'' + + ", effectiveTime=" + getEffectiveTime() + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + ", assetManagerName='" + getAssetManagerName() + '\'' + '}'; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java index 83d8e65c7e0..be130bfa6c4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/rest/SearchStringRequestBody.java @@ -20,7 +20,7 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class SearchStringRequestBody extends AssetManagerIdentifiersRequestBody +public class SearchStringRequestBody extends EffectiveTimeQueryRequestBody { private static final long serialVersionUID = 1L; @@ -108,6 +108,7 @@ public String toString() return "SearchStringRequestBody{" + "searchString='" + searchString + '\'' + ", searchStringParameterName='" + searchStringParameterName + '\'' + + ", effectiveTime=" + getEffectiveTime() + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + ", assetManagerName='" + getAssetManagerName() + '\'' + '}'; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java index 66e0fafbb68..8459d741ca8 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExchangeClientBase.java @@ -11,6 +11,7 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import java.util.Date; import java.util.Map; /** @@ -299,4 +300,31 @@ AssetManagerIdentifiersRequestBody getAssetManagerIdentifiersRequestBody(String return requestBody; } + + + + /** + * Return the asset manager identifiers packaged in an appropriate request body (or null is assetManagerGUID is null). + * + * @param assetManagerGUID unique identifier for the asset manager + * @param assetManagerName unique name for the asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * @return request body + */ + EffectiveTimeQueryRequestBody getEffectiveTimeQueryRequestBody(String assetManagerGUID, + String assetManagerName, + Date effectiveTime) + { + EffectiveTimeQueryRequestBody requestBody = new EffectiveTimeQueryRequestBody(); + + if (assetManagerGUID != null) + { + requestBody.setAssetManagerGUID(assetManagerGUID); + requestBody.setAssetManagerName(assetManagerName); + } + + requestBody.setEffectiveTime(effectiveTime); + + return requestBody; + } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExternalReferenceExchangeClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExternalReferenceExchangeClient.java index d2ab3c8b362..a335deadc54 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExternalReferenceExchangeClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/ExternalReferenceExchangeClient.java @@ -13,6 +13,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceElementResponse; import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceElementsResponse; import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceLinkElementsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceLinkRequestBody; import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceRequestBody; import org.odpi.openmetadata.accessservices.assetmanager.rest.NameRequestBody; import org.odpi.openmetadata.accessservices.assetmanager.rest.SearchStringRequestBody; @@ -22,6 +23,7 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import java.util.Date; import java.util.List; import java.util.Map; @@ -185,13 +187,14 @@ public String createExternalReference(String userId, mappingProperties, methodName)); - final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references"; + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references?assetManagerIsHome={2}"; GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, urlTemplate, requestBody, serverName, - userId); + userId, + assetManagerIsHome); return restResult.getGUID(); } @@ -231,7 +234,7 @@ public void updateExternalReference(String userId, invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); invalidParameterHandler.validateObject(properties, propertiesParameterName, methodName); - + if (!isMergeUpdate) { invalidParameterHandler.validateName(properties.getQualifiedName(), qualifiedNameParameterName, methodName); @@ -278,8 +281,8 @@ public void deleteExternalReference(String userId, UserNotAuthorizedException, PropertyServerException { - final String methodName = "deleteExternalReference"; - final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + final String methodName = "deleteExternalReference"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); @@ -304,23 +307,27 @@ public void deleteExternalReference(String userId, * @param userId the name of the calling user. * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param assetManagerIsHome ensure that only the asset manager can update this asset * @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. * + * @return Unique identifier for new relationship + * * @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 assetManagerGUID, - String assetManagerName, - String attachedToGUID, - String externalReferenceGUID, - ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public String linkExternalReferenceToElement(String userId, + String assetManagerGUID, + String assetManagerName, + boolean assetManagerIsHome, + String attachedToGUID, + String externalReferenceGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { final String methodName = "linkExternalReferenceToElement"; final String attachedToGUIDParameterName = "attachedToGUID"; @@ -330,16 +337,69 @@ public void linkExternalReferenceToElement(String userI invalidParameterHandler.validateGUID(attachedToGUID, attachedToGUIDParameterName, methodName); invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/{2}/links/{3}?assetManagerIsHome={4}"; + + ExternalReferenceLinkRequestBody requestBody = new ExternalReferenceLinkRequestBody(); + + requestBody.setAssetManagerGUID(assetManagerGUID); + requestBody.setAssetManagerName(assetManagerName); + requestBody.setElementProperties(linkProperties); + + GUIDResponse restResult = restClient.callGUIDPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + externalReferenceGUID, + attachedToGUID); + + return restResult.getGUID(); + } + + + + /** + * Update the link between an external reference to an object. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to. + * @param externalReferenceLinkGUID 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. + */ + @Override + public void updateExternalReferenceToElementLink(String userId, + String assetManagerGUID, + String assetManagerName, + String externalReferenceLinkGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "linkExternalReferenceToElement"; + final String externalReferenceGUIDParameterName = "externalReferenceLinkGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceLinkGUID, externalReferenceGUIDParameterName, methodName); - final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/{2}/link/{3}"; + ExternalReferenceLinkRequestBody requestBody = new ExternalReferenceLinkRequestBody(); + + requestBody.setAssetManagerGUID(assetManagerGUID); + requestBody.setAssetManagerName(assetManagerName); + requestBody.setElementProperties(linkProperties); + + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/links/{2}/update"; restClient.callVoidPostRESTCall(methodName, urlTemplate, - getAssetManagerIdentifiersRequestBody(assetManagerGUID, assetManagerName), + requestBody, serverName, userId, - externalReferenceGUID, - attachedToGUID); + externalReferenceLinkGUID); } @@ -349,8 +409,7 @@ public void linkExternalReferenceToElement(String userI * @param userId the name of the calling user. * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller - * @param attachedToGUID object linked to external references. - * @param externalReferenceGUID identifier of the external reference. + * @param externalReferenceLinkGUID identifier of the external reference relationship. * * @throws InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. * @throws PropertyServerException the server is not available. @@ -360,71 +419,72 @@ public void linkExternalReferenceToElement(String userI public void unlinkExternalReferenceFromElement(String userId, String assetManagerGUID, String assetManagerName, - String attachedToGUID, - String externalReferenceGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + String externalReferenceLinkGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { final String methodName = "linkExternalReferenceToElement"; - final String attachedToGUIDParameterName = "attachedToGUID"; - final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceLinkGUID"; invalidParameterHandler.validateUserId(userId, methodName); - invalidParameterHandler.validateGUID(attachedToGUID, attachedToGUIDParameterName, methodName); - invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); - + invalidParameterHandler.validateGUID(externalReferenceLinkGUID, externalReferenceGUIDParameterName, methodName); - final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/{2}/unlink/{3}"; + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/links/{2}/remove"; restClient.callVoidPostRESTCall(methodName, urlTemplate, getAssetManagerIdentifiersRequestBody(assetManagerGUID, assetManagerName), serverName, userId, - externalReferenceGUID, - attachedToGUID); + externalReferenceLinkGUID); } /** - * Return information about a specific external reference. + * Retrieve the list of external references sorted in open metadata. * - * @param userId calling user + * @param userId the name of the calling user. * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller - * @param externalReferenceGUID unique identifier for the external reference + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. * - * @return properties of the external reference + * @return links to addition information. * - * @throws InvalidParameterException externalReferenceGUID or userId is null - * @throws PropertyServerException problem accessing property server - * @throws UserNotAuthorizedException security access problem + * @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 ExternalReferenceElement getExternalReferenceByGUID(String userId, - String assetManagerGUID, - String assetManagerName, - String externalReferenceGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public List getExternalReferences(String userId, + String assetManagerGUID, + String assetManagerName, + Date effectiveTime, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { - final String methodName = "getExternalReferenceByGUID"; - final String guidParameterName = "externalReferenceGUID"; + final String methodName = "getExternalReferences"; invalidParameterHandler.validateUserId(userId, methodName); - invalidParameterHandler.validateGUID(externalReferenceGUID, guidParameterName, methodName); - final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/{2}/retrieve"; + int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); - ExternalReferenceElementResponse restResult = restClient.callExternalReferencePostRESTCall(methodName, - urlTemplate, - getAssetManagerIdentifiersRequestBody(assetManagerGUID, - assetManagerName), - serverName, - userId, - externalReferenceGUID); + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/by-type?startFrom={2}&pageSize={3}"; - return restResult.getElement(); + ExternalReferenceElementsResponse restResult = restClient.callExternalReferencesPostRESTCall(methodName, + urlTemplate, + getEffectiveTimeQueryRequestBody(assetManagerGUID, + assetManagerName, + effectiveTime), + serverName, + userId, + startFrom, + validatedPageSize); + + return restResult.getElementList(); } @@ -435,6 +495,7 @@ public ExternalReferenceElement getExternalReferenceByGUID(String userId, * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param resourceId unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -449,6 +510,7 @@ public List getExternalReferencesById(String userId, String assetManagerGUID, String assetManagerName, String resourceId, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, @@ -467,16 +529,17 @@ public List getExternalReferencesById(String userId, requestBody.setAssetManagerName(assetManagerName); requestBody.setName(resourceId); requestBody.setNameParameterName(nameParameterName); + requestBody.setEffectiveTime(effectiveTime); final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/by-resource-id?startFrom={2}&pageSize={3}"; ExternalReferenceElementsResponse restResult = restClient.callExternalReferencesPostRESTCall(methodName, - urlTemplate, - requestBody, - serverName, - userId, - startFrom, - validatedPageSize); + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + validatedPageSize); return restResult.getElementList(); } @@ -489,6 +552,7 @@ public List getExternalReferencesById(String userId, * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param url URL of the external resource. + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -503,6 +567,7 @@ public List getExternalReferencesByURL(String userId, String assetManagerGUID, String assetManagerName, String url, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, @@ -521,6 +586,7 @@ public List getExternalReferencesByURL(String userId, requestBody.setAssetManagerName(assetManagerName); requestBody.setName(url); requestBody.setNameParameterName(nameParameterName); + requestBody.setEffectiveTime(effectiveTime); final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/by-url?startFrom={2}&pageSize={3}"; @@ -536,12 +602,70 @@ public List getExternalReferencesByURL(String userId, } + /** + * Retrieve the list of external references for this name. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param name qualifiedName or displayName of the external resource. + * @param effectiveTime the time that the retrieved elements must be effective for + * @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 getExternalReferencesByName(String userId, + String assetManagerGUID, + String assetManagerName, + String name, + Date effectiveTime, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getExternalReferencesByName"; + final String nameParameterName = "name"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateName(name, nameParameterName, methodName); + + int validatedPageSize = invalidParameterHandler.validatePaging(startFrom, pageSize, methodName); + + NameRequestBody requestBody = new NameRequestBody(); + requestBody.setAssetManagerGUID(assetManagerGUID); + requestBody.setAssetManagerName(assetManagerName); + requestBody.setName(name); + requestBody.setNameParameterName(nameParameterName); + requestBody.setEffectiveTime(effectiveTime); + + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/by-name?startFrom={2}&pageSize={3}"; + + ExternalReferenceElementsResponse restResult = restClient.callExternalReferencesPostRESTCall(methodName, + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + validatedPageSize); + + return restResult.getElementList(); + } + + /** * Retrieve the list of external reference created on behalf of the named asset manager. * * @param userId calling user * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom paging start point * @param pageSize maximum results that can be returned * @@ -555,6 +679,7 @@ public List getExternalReferencesByURL(String userId, public List getExternalReferencesForAssetManager(String userId, String assetManagerGUID, String assetManagerName, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, UserNotAuthorizedException, @@ -568,13 +693,14 @@ public List getExternalReferencesForAssetManager(Strin final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/by-asset-manager?startFrom={2}&pageSize={3}"; ExternalReferenceElementsResponse restResult = restClient.callExternalReferencesPostRESTCall(methodName, - urlTemplate, - getAssetManagerIdentifiersRequestBody(assetManagerGUID, - assetManagerName), - serverName, - userId, - startFrom, - validatedPageSize); + urlTemplate, + getEffectiveTimeQueryRequestBody(assetManagerGUID, + assetManagerName, + effectiveTime), + serverName, + userId, + startFrom, + validatedPageSize); return restResult.getElementList(); } @@ -587,6 +713,7 @@ public List getExternalReferencesForAssetManager(Strin * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param searchString regular expression (RegEx) to search for + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -601,6 +728,7 @@ public List findExternalReferences(String userId, String assetManagerGUID, String assetManagerName, String searchString, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, @@ -618,16 +746,17 @@ public List findExternalReferences(String userId, requestBody.setAssetManagerName(assetManagerName); requestBody.setSearchString(searchString); requestBody.setSearchStringParameterName(searchStringParameterName); + requestBody.setEffectiveTime(effectiveTime); final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/by-search-string?startFrom={2}&pageSize={3}"; ExternalReferenceElementsResponse restResult = restClient.callExternalReferencesPostRESTCall(methodName, - urlTemplate, - requestBody, - serverName, - userId, - startFrom, - validatedPageSize); + urlTemplate, + requestBody, + serverName, + userId, + startFrom, + validatedPageSize); return restResult.getElementList(); } @@ -640,6 +769,7 @@ public List findExternalReferences(String userId, * @param assetManagerGUID unique identifier of software server capability representing the caller * @param assetManagerName unique name of software server capability representing the caller * @param attachedToGUID object linked to external reference. + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -654,6 +784,7 @@ public List retrieveAttachedExternalReferences(Str String assetManagerGUID, String assetManagerName, String attachedToGUID, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, @@ -670,8 +801,9 @@ public List retrieveAttachedExternalReferences(Str ExternalReferenceLinkElementsResponse restResult = restClient.callExternalReferenceLinksPostRESTCall(methodName, urlTemplate, - getAssetManagerIdentifiersRequestBody(assetManagerGUID, - assetManagerName), + getEffectiveTimeQueryRequestBody(assetManagerGUID, + assetManagerName, + effectiveTime), serverName, userId, attachedToGUID, @@ -680,4 +812,50 @@ public List retrieveAttachedExternalReferences(Str return restResult.getElementList(); } + + + /** + * Return information about a specific external reference. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param externalReferenceGUID unique identifier for the external reference + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 assetManagerGUID, + String assetManagerName, + String externalReferenceGUID, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "getExternalReferenceByGUID"; + final String guidParameterName = "externalReferenceGUID"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceGUID, guidParameterName, methodName); + + final String urlTemplate = serverPlatformURLRoot + urlTemplatePrefix + "/external-references/{2}/by-guid"; + + ExternalReferenceElementResponse restResult = restClient.callExternalReferencePostRESTCall(methodName, + urlTemplate, + getEffectiveTimeQueryRequestBody(assetManagerGUID, + assetManagerName, + effectiveTime), + serverName, + userId, + externalReferenceGUID); + + return restResult.getElement(); + } + } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceConverter.java new file mode 100644 index 00000000000..4219022c3d3 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceConverter.java @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.ExternalReferenceElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.ExternalReferenceLinkElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalReferenceProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalReferenceLinkProperties; +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 transfers the relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into a ExternalReferenceElement bean. + */ +public class ExternalReferenceConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity/relationship objects + * @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 have + * 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 + { + 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; + ExternalReferenceProperties externalReferenceProperties = new ExternalReferenceProperties(); + + if (entity != null) + { + bean.setElementHeader(this.getMetadataElementHeader(beanClass, entity, methodName)); + + /* + * 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.setDescription(this.removeDescription(instanceProperties)); + externalReferenceProperties.setUrl(this.removeURL(instanceProperties)); + externalReferenceProperties.setVersion(this.removeReferenceVersion(instanceProperties)); + externalReferenceProperties.setOrganization(this.removeOrganization(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; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that have + * 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 + { + return getNewBean(beanClass, entity, methodName); + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceLinkConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceLinkConverter.java new file mode 100644 index 00000000000..2a65c4fe891 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalReferenceLinkConverter.java @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.converters; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.ExternalReferenceLinkElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalReferenceLinkProperties; +import org.odpi.openmetadata.accessservices.assetmanager.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 transfers the relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into a ExternalReferenceElement bean. + */ +public class ExternalReferenceLinkConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity/relationship objects + * @param serviceName name of this component + * @param serverName local server name + */ + public ExternalReferenceLinkConverter(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 have + * 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 have + * 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 ExternalReferenceLinkElement) + { + ExternalReferenceLinkElement bean = (ExternalReferenceLinkElement) returnBean; + ExternalReferenceProperties externalReferenceProperties = new ExternalReferenceProperties(); + ExternalReferenceLinkProperties linkProperties = new ExternalReferenceLinkProperties(); + + if (entity != null) + { + bean.setElementHeader(this.getMetadataElementHeader(beanClass, entity, methodName)); + + /* + * 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.setDescription(this.removeDescription(instanceProperties)); + externalReferenceProperties.setUrl(this.removeURL(instanceProperties)); + externalReferenceProperties.setVersion(this.removeReferenceVersion(instanceProperties)); + externalReferenceProperties.setOrganization(this.removeOrganization(instanceProperties)); + + bean.setProperties(externalReferenceProperties); + } + else + { + handleMissingMetadataInstance(beanClass.getName(), TypeDefCategory.ENTITY_DEF, methodName); + } + + if (relationship != null) + { + InstanceProperties instanceProperties = new InstanceProperties(relationship.getProperties()); + + linkProperties.setLinkId(this.removeReferenceId(instanceProperties)); + linkProperties.setLinkDescription(this.removeDescription(instanceProperties)); + + bean.setLink(linkProperties); + } + } + + 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-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/DataAssetExchangeHandler.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/DataAssetExchangeHandler.java index b03de7f659a..cebac60440d 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/DataAssetExchangeHandler.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/DataAssetExchangeHandler.java @@ -15,7 +15,6 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExternalReferenceExchangeHandler.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExternalReferenceExchangeHandler.java new file mode 100644 index 00000000000..adf516cb3f6 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExternalReferenceExchangeHandler.java @@ -0,0 +1,991 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.accessservices.assetmanager.handlers; + +import org.odpi.openmetadata.accessservices.assetmanager.converters.ExternalReferenceConverter; + +import org.odpi.openmetadata.accessservices.assetmanager.converters.ExternalReferenceLinkConverter; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.ExternalReferenceElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.ExternalReferenceLinkElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalReferenceLinkProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalReferenceProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.generichandlers.ExternalReferenceHandler; +import org.odpi.openmetadata.commonservices.generichandlers.ExternalReferenceLinkHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; +import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * ExternalReferenceExchangeHandler is the server side handler for managing externalReference content. + */ +public class ExternalReferenceExchangeHandler extends ExchangeHandlerBase +{ + private ExternalReferenceHandler externalReferenceHandler; + private ExternalReferenceLinkHandler externalReferenceLinkHandler; + + private final static String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + /** + * Construct the externalReference exchange handler with information needed to work with externalReference related objects + * for Asset Manager OMAS. + * + * @param serviceName name of this service + * @param serverName name of the local server + * @param invalidParameterHandler handler for managing parameter errors + * @param repositoryHandler manages calls to the repository services + * @param repositoryHelper provides utilities for manipulating the repository services objects + * @param localServerUserId userId for this server + * @param securityVerifier open metadata security services verifier + * @param supportedZones list of zones that the access service is allowed to serve instances from. + * @param defaultZones list of zones that the access service should set in all new instances. + * @param publishZones list of zones that the access service sets up in published instances. + * @param auditLog destination for audit log events. + */ + public ExternalReferenceExchangeHandler(String serviceName, + String serverName, + InvalidParameterHandler invalidParameterHandler, + RepositoryHandler repositoryHandler, + OMRSRepositoryHelper repositoryHelper, + String localServerUserId, + OpenMetadataServerSecurityVerifier securityVerifier, + List supportedZones, + List defaultZones, + List publishZones, + AuditLog auditLog) + { + super(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.externalReferenceLinkHandler = new ExternalReferenceLinkHandler<>(new ExternalReferenceLinkConverter<>(repositoryHelper, serviceName, serverName), + ExternalReferenceLinkElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + } + + + + /* ======================================================== + * Managing the externalIds and related correlation properties. + */ + + + + /** + * Update each returned element with details of the correlation properties for the supplied asset manager. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param results list of elements + * @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) + */ + private void addCorrelationPropertiesToExternalReferences(String userId, + String assetManagerGUID, + String assetManagerName, + List results, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + if ((results != null) && (assetManagerGUID != null)) + { + for (MetadataElement externalReference : results) + { + if ((externalReference != null) && (externalReference.getElementHeader() != null) && (externalReference.getElementHeader().getGUID() != null)) + { + externalReference.setCorrelationHeaders(this.getCorrelationProperties(userId, + externalReference.getElementHeader().getGUID(), + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + assetManagerGUID, + assetManagerName, + null, + methodName)); + } + } + } + } + + + + /** + * Update each returned element with details of the correlation properties for the supplied asset manager. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param results list of elements + * @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) + */ + private void addCorrelationPropertiesToExternalReferenceLinks(String userId, + String assetManagerGUID, + String assetManagerName, + List results, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + if ((results != null) && (assetManagerGUID != null)) + { + for (MetadataElement externalReference : results) + { + if ((externalReference != null) && (externalReference.getElementHeader() != null) && (externalReference.getElementHeader().getGUID() != null)) + { + externalReference.setCorrelationHeaders(this.getCorrelationProperties(userId, + externalReference.getElementHeader().getGUID(), + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + assetManagerGUID, + assetManagerName, + null, + methodName)); + } + } + } + } + + + /* ======================================================== + * The ExternalReference entity describes a link to a remote resource such as a document or web page. + */ + + + /** + * Create a new metadata element to represent the root of a externalReference. All categories and terms are linked + * to a single externalReference. They are owned by this externalReference and if the externalReference is deleted, any linked terms and + * categories are deleted as well. + * + * @param userId calling user + * @param assetManagerIsHome ensure that only the asset manager can update this asset + * @param correlationProperties properties to help with the mapping of the elements in the external asset manager and open metadata + * @param externalReferenceProperties properties to store + * @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 methodName calling method + * + * @return unique identifier of the new metadata 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) + */ + public String createExternalReference(String userId, + boolean assetManagerIsHome, + MetadataCorrelationProperties correlationProperties, + ExternalReferenceProperties externalReferenceProperties, + String anchorGUID, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String propertiesParameterName = "externalReferenceProperties"; + final String qualifiedNameParameterName = "externalReferenceProperties.qualifiedName"; + + invalidParameterHandler.validateUserId(userId, methodName); + + invalidParameterHandler.validateObject(externalReferenceProperties, propertiesParameterName, methodName); + invalidParameterHandler.validateName(externalReferenceProperties.getQualifiedName(), qualifiedNameParameterName, methodName); + + String externalReferenceGUID; + + if (assetManagerIsHome) + { + externalReferenceGUID = externalReferenceHandler.createExternalReference(userId, + correlationProperties.getAssetManagerGUID(), + correlationProperties.getAssetManagerName(), + anchorGUID, + externalReferenceProperties.getQualifiedName(), + externalReferenceProperties.getDisplayName(), + externalReferenceProperties.getDescription(), + externalReferenceProperties.getUrl(), + externalReferenceProperties.getVersion(), + externalReferenceProperties.getOrganization(), + externalReferenceProperties.getAdditionalProperties(), + externalReferenceProperties.getTypeName(), + externalReferenceProperties.getExtendedProperties(), + externalReferenceProperties.getEffectiveFrom(), + externalReferenceProperties.getEffectiveTo(), + methodName); + } + else + { + externalReferenceGUID = externalReferenceHandler.createExternalReference(userId, + null, + null, + anchorGUID, + externalReferenceProperties.getQualifiedName(), + externalReferenceProperties.getDisplayName(), + externalReferenceProperties.getDescription(), + externalReferenceProperties.getUrl(), + externalReferenceProperties.getVersion(), + externalReferenceProperties.getOrganization(), + externalReferenceProperties.getAdditionalProperties(), + externalReferenceProperties.getTypeName(), + externalReferenceProperties.getExtendedProperties(), + externalReferenceProperties.getEffectiveFrom(), + externalReferenceProperties.getEffectiveTo(), + methodName); + } + + if (externalReferenceGUID != null) + { + this.createExternalIdentifier(userId, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + correlationProperties, + methodName); + } + + return externalReferenceGUID; + } + + + /** + * Update the metadata element representing an external reference. + * + * @param userId calling user + * @param correlationProperties properties to help with the mapping of the elements in the external asset manager and open metadata + * @param externalReferenceGUID unique identifier of the metadata element to update + * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? + * @param externalReferenceProperties new properties for this element + * @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 updateExternalReference(String userId, + MetadataCorrelationProperties correlationProperties, + String externalReferenceGUID, + boolean isMergeUpdate, + ExternalReferenceProperties externalReferenceProperties, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String propertiesParameterName = "externalReferenceProperties"; + final String qualifiedNameParameterName = "externalReferenceProperties.qualifiedName"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); + invalidParameterHandler.validateObject(externalReferenceProperties, propertiesParameterName, methodName); + + if (! isMergeUpdate) + { + invalidParameterHandler.validateName(externalReferenceProperties.getQualifiedName(), qualifiedNameParameterName, methodName); + } + + this.validateExternalIdentifier(userId, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + correlationProperties, + methodName); + + externalReferenceHandler.updateExternalReference(userId, + correlationProperties.getAssetManagerGUID(), + correlationProperties.getAssetManagerName(), + externalReferenceGUID, + externalReferenceGUIDParameterName, + externalReferenceProperties.getQualifiedName(), + externalReferenceProperties.getDisplayName(), + externalReferenceProperties.getDescription(), + externalReferenceProperties.getUrl(), + externalReferenceProperties.getVersion(), + externalReferenceProperties.getOrganization(), + externalReferenceProperties.getAdditionalProperties(), + externalReferenceProperties.getTypeName(), + externalReferenceProperties.getExtendedProperties(), + isMergeUpdate, + externalReferenceProperties.getEffectiveFrom(), + externalReferenceProperties.getEffectiveTo(), + methodName); + } + + + /** + * Remove the metadata element representing a externalReference. This will delete the externalReference and all categories and terms because + * the Anchors classifications are set up in these elements. + * + * @param userId calling user + * @param correlationProperties properties to help with the mapping of the elements in the external asset manager and open metadata + * @param externalReferenceGUID unique identifier of the metadata element to remove + * @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 removeExternalReference(String userId, + MetadataCorrelationProperties correlationProperties, + String externalReferenceGUID, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); + + this.validateExternalIdentifier(userId, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + correlationProperties, + methodName); + + if (correlationProperties != null) + { + externalReferenceHandler.removeExternalReference(userId, + correlationProperties.getAssetManagerGUID(), + correlationProperties.getAssetManagerName(), + externalReferenceGUID, + externalReferenceGUIDParameterName, + methodName); + } + else + { + externalReferenceHandler.removeExternalReference(userId, + null, + null, + externalReferenceGUID, + externalReferenceGUIDParameterName, + methodName); + } + } + + + + + /** + * Link an external reference to an object. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param attachedToGUID object linked to external references + * @param attachedToGUIDParameterName parameter name + * @param externalReferenceGUID unique identifier (guid) of the external reference details + * @param externalReferenceGUIDParameterName parameter name + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to. + * @param methodName calling method + * + * @return Unique identifier for new relationship + * + * @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. + */ + public String linkExternalReferenceToElement(String userId, + String assetManagerGUID, + String assetManagerName, + String attachedToGUID, + String attachedToGUIDParameterName, + String externalReferenceGUID, + String externalReferenceGUIDParameterName, + ExternalReferenceLinkProperties linkProperties, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(attachedToGUID, attachedToGUIDParameterName, methodName); + invalidParameterHandler.validateGUID(externalReferenceGUID, externalReferenceGUIDParameterName, methodName); + + String relationshipGUID; + if (linkProperties != null) + { + relationshipGUID = externalReferenceLinkHandler.setupExternalReferenceLink(userId, + assetManagerGUID, + assetManagerName, + attachedToGUID, + attachedToGUIDParameterName, + externalReferenceGUID, + externalReferenceGUIDParameterName, + linkProperties.getLinkId(), + linkProperties.getLinkDescription(), + linkProperties.getEffectiveFrom(), + linkProperties.getEffectiveTo(), + methodName); + } + else + { + relationshipGUID = externalReferenceLinkHandler.setupExternalReferenceLink(userId, + assetManagerGUID, + assetManagerName, + attachedToGUID, + attachedToGUIDParameterName, + externalReferenceGUID, + externalReferenceGUIDParameterName, + null, + null, + null, + null, + methodName); + } + + externalIdentifierHandler.logRelationshipCreation(assetManagerGUID, + assetManagerName, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + attachedToGUID, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + externalReferenceGUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + methodName); + + return relationshipGUID; + } + + + /** + * Update the link between an external reference to an object. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param externalReferenceLinkGUID unique identifier (guid) of the external reference details + * @param externalReferenceGUIDParameterName parameter name + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to + * @param methodName calling method + * + * @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. + */ + public void updateExternalReferenceToElementLink(String userId, + String assetManagerGUID, + String assetManagerName, + String externalReferenceLinkGUID, + String externalReferenceGUIDParameterName, + ExternalReferenceLinkProperties linkProperties, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceLinkGUID, externalReferenceGUIDParameterName, methodName); + + if (linkProperties != null) + { + externalReferenceLinkHandler.updateExternalReferenceLink(userId, + assetManagerGUID, + assetManagerName, + externalReferenceLinkGUID, + externalReferenceGUIDParameterName, + linkProperties.getLinkId(), + linkProperties.getLinkDescription(), + linkProperties.getEffectiveFrom(), + linkProperties.getEffectiveTo(), + methodName); + } + else + { + externalReferenceLinkHandler.updateExternalReferenceLink(userId, + assetManagerGUID, + assetManagerName, + externalReferenceLinkGUID, + externalReferenceGUIDParameterName, + null, + null, + null, + null, + methodName); + } + + externalIdentifierHandler.logRelationshipUpdate(assetManagerGUID, + assetManagerName, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + externalReferenceLinkGUID, + methodName); + } + + + /** + * Remove the link between a 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 assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param externalReferenceLinkGUID identifier of the external reference relationship + * @param externalReferenceGUIDParameterName parameter name + * @param methodName calling method + * + * @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. + */ + public void unlinkExternalReferenceFromElement(String userId, + String assetManagerGUID, + String assetManagerName, + String externalReferenceLinkGUID, + String externalReferenceGUIDParameterName, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(externalReferenceLinkGUID, externalReferenceGUIDParameterName, methodName); + + Relationship relationship = externalReferenceLinkHandler.clearExternalReferenceLink(userId, + assetManagerGUID, + assetManagerName, + externalReferenceLinkGUID, + externalReferenceGUIDParameterName, + null, + methodName); + + if (relationship != null) + { + externalIdentifierHandler.logRelationshipRemoval(assetManagerGUID, + assetManagerName, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + relationship.getEntityOneProxy().getGUID(), + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + relationship.getEntityTwoProxy().getGUID(), + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + methodName); + } + } + + + /** + * Retrieve the list of externalReference metadata elements that contain the search string. + * The search string is treated as a regular expression. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferences(String userId, + String assetManagerGUID, + String assetManagerName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List results = externalReferenceHandler.getExternalReferences(userId, startFrom, pageSize, effectiveTime, methodName); + + addCorrelationPropertiesToExternalReferences(userId, assetManagerGUID, assetManagerName, results , methodName); + + return results; + } + + + + + /** + * Retrieve the list of externalReference metadata elements that contain the search string. + * The search string is treated as a regular expression. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param searchString string to find in the properties + * @param searchStringParameterName name of parameter for search string + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List findExternalReferences(String userId, + String assetManagerGUID, + String assetManagerName, + String searchString, + String searchStringParameterName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List results = externalReferenceHandler.findExternalReferences(userId, searchString, searchStringParameterName, startFrom, pageSize, effectiveTime, methodName); + + addCorrelationPropertiesToExternalReferences(userId, assetManagerGUID, assetManagerName, results , methodName); + + return results; + } + + + /** + * Retrieve the list of externalReference metadata elements with a matching qualified or display name. + * There are no wildcards supported on this request. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param name name to search for + * @param nameParameterName name of parameter supplying name value + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesByName(String userId, + String assetManagerGUID, + String assetManagerName, + String name, + String nameParameterName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List results = externalReferenceHandler.getExternalReferencesByName(userId, name, nameParameterName, startFrom, pageSize, effectiveTime, methodName); + + addCorrelationPropertiesToExternalReferences(userId, assetManagerGUID, assetManagerName, results, methodName); + + return results; + } + + + + /** + * Retrieve the list of externalReference metadata elements with a matching qualified or display referenceId. + * There are no wildcards supported on this request. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique referenceId of software server capability representing the caller + * @param referenceId referenceId to search for + * @param referenceIdParameterName name of parameter supplying referenceId value + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesById(String userId, + String assetManagerGUID, + String assetManagerName, + String referenceId, + String referenceIdParameterName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List results = externalReferenceHandler.getExternalReferencesById(userId, referenceId, referenceIdParameterName, startFrom, pageSize, effectiveTime, methodName); + + addCorrelationPropertiesToExternalReferences(userId, assetManagerGUID, assetManagerName, results, methodName); + + return results; + } + + + + + /** + * Retrieve the list of externalReference metadata elements with a matching qualified or display url. + * There are no wildcards supported on this request. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique url of software server capability representing the caller + * @param url url to search for + * @param urlParameterName name of parameter supplying url value + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesByURL(String userId, + String assetManagerGUID, + String assetManagerName, + String url, + String urlParameterName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List results = externalReferenceHandler.getExternalReferencesByURL(userId, url, urlParameterName, startFrom, pageSize, effectiveTime, methodName); + + addCorrelationPropertiesToExternalReferences(userId, assetManagerGUID, assetManagerName, results, methodName); + + return results; + } + + + /** + * Retrieve the list of external references created by this caller. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesForAssetManager(String userId, + String assetManagerGUID, + String assetManagerName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String assetManagerGUIDParameterName = "assetManagerGUID"; + final String externalReferenceEntityParameterName = "externalReferenceEntity"; + final String externalReferenceGUIDParameterName = "externalReferenceEntity.getGUID()"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(assetManagerGUID, assetManagerGUIDParameterName, methodName); + + List results = new ArrayList<>(); + + List externalReferenceEntities = externalIdentifierHandler.getElementEntitiesForScope(userId, + assetManagerGUID, + assetManagerGUIDParameterName, + OpenMetadataAPIMapper.SOFTWARE_CAPABILITY_TYPE_NAME, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + startFrom, + pageSize, + effectiveTime, + methodName); + + if (externalReferenceEntities != null) + { + for (EntityDetail externalReferenceEntity : externalReferenceEntities) + { + if (externalReferenceEntity != null) + { + ExternalReferenceElement externalReferenceElement = externalReferenceHandler.getBeanFromEntity(userId, + externalReferenceEntity, + externalReferenceEntityParameterName, + methodName); + + if (externalReferenceElement != null) + { + externalReferenceElement.setCorrelationHeaders(this.getCorrelationProperties(userId, + externalReferenceEntity.getGUID(), + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + assetManagerGUID, + assetManagerName, + null, + methodName)); + + results.add(externalReferenceElement); + } + } + } + } + + if (results.isEmpty()) + { + return null; + } + else + { + return results; + } + } + + + /** + * Retrieve the list of external references attached to the supplied object. + * + * @param userId the name of the calling user. + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param attachedToGUID object linked to external reference + * @param attachedToGUIDParameterName name of attachedToGUID parameter + * @param effectiveTime the time that the retrieved elements must be effective for + * @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 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. + */ + public List retrieveAttachedExternalReferences(String userId, + String assetManagerGUID, + String assetManagerName, + String attachedToGUID, + String attachedToGUIDParameterName, + Date effectiveTime, + int startFrom, + int pageSize, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + List results = externalReferenceLinkHandler.getExternalReferences(userId, + attachedToGUID, + attachedToGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + supportedZones, + startFrom, + pageSize, + effectiveTime, + methodName); + + addCorrelationPropertiesToExternalReferenceLinks(userId, assetManagerGUID, assetManagerName, results, methodName); + + return results; + } + + + + /** + * Retrieve the externalReference metadata element with the supplied unique identifier. + * + * @param userId calling user + * @param assetManagerGUID unique identifier of software server capability representing the caller + * @param assetManagerName unique name of software server capability representing the caller + * @param guid unique identifier of the requested metadata element + * @param guidParameterName name of parameter for guid + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return matching metadata 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) + */ + public ExternalReferenceElement getExternalReferenceByGUID(String userId, + String assetManagerGUID, + String assetManagerName, + String guid, + String guidParameterName, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + ExternalReferenceElement externalReference = externalReferenceHandler.getBeanFromRepository(userId, + guid, + guidParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + effectiveTime, + methodName); + + if (externalReference != null) + { + externalReference.setCorrelationHeaders(this.getCorrelationProperties(userId, + guid, + guidParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + assetManagerGUID, + assetManagerName, + null, + methodName)); + } + + return externalReference; + } + + +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java index 0a4cacde34e..669ca341ed6 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerInstanceHandler.java @@ -3,6 +3,7 @@ package org.odpi.openmetadata.accessservices.assetmanager.server; import org.odpi.openmetadata.accessservices.assetmanager.handlers.DataAssetExchangeHandler; +import org.odpi.openmetadata.accessservices.assetmanager.handlers.ExternalReferenceExchangeHandler; import org.odpi.openmetadata.accessservices.assetmanager.handlers.GlossaryExchangeHandler; import org.odpi.openmetadata.accessservices.assetmanager.handlers.ProcessExchangeHandler; import org.odpi.openmetadata.accessservices.assetmanager.handlers.SchemaExchangeHandler; @@ -115,6 +116,33 @@ DataAssetExchangeHandler getDataAssetExchangeHandler(String userId, } + /** + * Retrieve the specific handler for the access service. + * + * @param userId calling user + * @param serverName name of the server tied to the request + * @param serviceOperationName name of the REST API call (typically the top-level methodName) + * @return handler for use by the requested instance + * @throws InvalidParameterException no available instance for the requested server + * @throws UserNotAuthorizedException user does not have access to the requested server + * @throws PropertyServerException error in the requested server + */ + ExternalReferenceExchangeHandler getExternalReferenceExchangeHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AssetManagerServicesInstance instance = (AssetManagerServicesInstance)super.getServerServiceInstance(userId, serverName, serviceOperationName); + + if (instance != null) + { + return instance.getExternalReferenceExchangeHandler(); + } + + return null; + } + /** * Retrieve the specific handler for the access service. diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java index e291f73f6af..a8ef80c12e5 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerServicesInstance.java @@ -6,6 +6,7 @@ import org.odpi.openmetadata.accessservices.assetmanager.converters.*; import org.odpi.openmetadata.accessservices.assetmanager.ffdc.AssetManagerErrorCode; import org.odpi.openmetadata.accessservices.assetmanager.handlers.DataAssetExchangeHandler; +import org.odpi.openmetadata.accessservices.assetmanager.handlers.ExternalReferenceExchangeHandler; import org.odpi.openmetadata.accessservices.assetmanager.handlers.GlossaryExchangeHandler; import org.odpi.openmetadata.accessservices.assetmanager.handlers.ProcessExchangeHandler; import org.odpi.openmetadata.accessservices.assetmanager.handlers.SchemaExchangeHandler; @@ -32,6 +33,7 @@ public class AssetManagerServicesInstance extends OMASServiceInstance private SoftwareCapabilityHandler assetManagerHandler; private ExternalIdentifierHandler externalIdentifierHandler; private DataAssetExchangeHandler dataAssetExchangeHandler; + private ExternalReferenceExchangeHandler externalReferenceHandler; private GlossaryExchangeHandler glossaryExchangeHandler; private ProcessExchangeHandler processExchangeHandler; private SchemaExchangeHandler schemaExchangeHandler; @@ -128,6 +130,18 @@ public AssetManagerServicesInstance(OMRSRepositoryConnector repositoryConnector, publishZones, auditLog); + this.externalReferenceHandler = new ExternalReferenceExchangeHandler(serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + this.glossaryExchangeHandler = new GlossaryExchangeHandler(serviceName, serverName, invalidParameterHandler, @@ -256,6 +270,22 @@ DataAssetExchangeHandler getDataAssetExchangeHandler() throws PropertyServerExce } + /** + * Return the handler for managing external reference objects. + * + * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully + */ + ExternalReferenceExchangeHandler getExternalReferenceExchangeHandler() throws PropertyServerException + { + final String methodName = "getExternalReferenceExchangeHandler"; + + validateActiveRepository(methodName); + + return externalReferenceHandler; + } + + /** * Return the handler for managing glossary objects. * @@ -309,9 +339,14 @@ SchemaExchangeHandler getSchemaExchangeHandler() throws PropertyServerException * Return the handler for governance action process requests. * * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully */ - public AssetHandler getGovernanceActionProcessHandler() + public AssetHandler getGovernanceActionProcessHandler() throws PropertyServerException { + final String methodName = "getGovernanceActionProcessHandler"; + + validateActiveRepository(methodName); + return governanceActionProcessHandler; } @@ -320,9 +355,14 @@ public AssetHandler getGovernanceActionProcessHa * Return the handler for governance action type requests. * * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully */ - GovernanceActionTypeHandler getGovernanceActionTypeHandler() + GovernanceActionTypeHandler getGovernanceActionTypeHandler() throws PropertyServerException { + final String methodName = "getGovernanceActionTypeHandler"; + + validateActiveRepository(methodName); + return governanceActionTypeHandler; } @@ -331,9 +371,14 @@ GovernanceActionTypeHandler getGovernanceActionType * Return the handler for governance action requests. * * @return handler object + * @throws PropertyServerException the instance has not been initialized successfully */ - GovernanceActionHandler getGovernanceActionHandler() + GovernanceActionHandler getGovernanceActionHandler() throws PropertyServerException { + final String methodName = "getGovernanceActionHandler"; + + validateActiveRepository(methodName); + return governanceActionHandler; } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/ExternalReferenceExchangeRESTServices.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/ExternalReferenceExchangeRESTServices.java new file mode 100644 index 00000000000..7c51cfe8d77 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/ExternalReferenceExchangeRESTServices.java @@ -0,0 +1,879 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.server; + +import org.odpi.openmetadata.accessservices.assetmanager.handlers.ExternalReferenceExchangeHandler; +import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import org.odpi.openmetadata.accessservices.assetmanager.rest.*; +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.VoidResponse; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.slf4j.LoggerFactory; + + +/** + * ExternalReferenceExchangeRESTServices is the server-side implementation of the Asset Manager OMAS's + * support for glossaries. It matches the ExternalReferenceExchangeClient. + */ +public class ExternalReferenceExchangeRESTServices +{ + private static AssetManagerInstanceHandler instanceHandler = new AssetManagerInstanceHandler(); + private static RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(ExternalReferenceExchangeRESTServices.class), + instanceHandler.getServiceName()); + + private RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + + /** + * Default constructor + */ + public ExternalReferenceExchangeRESTServices() + { + } + + + /** + * Create a definition of a external reference. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param assetManagerIsHome ensure that only the asset manager can update this asset + * @param requestBody properties for a external reference + * + * @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, + boolean assetManagerIsHome, + ExternalReferenceRequestBody requestBody) + { + final String methodName = "createExternalReference"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setGUID(handler.createExternalReference(userId, + assetManagerIsHome, + requestBody.getMetadataCorrelationProperties(), + requestBody.getElementProperties(), + requestBody.getAnchorGUID(), + 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 a external reference. + * + * @param serverName name of the server to route the request 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, + ExternalReferenceRequestBody requestBody) + { + final String methodName = "updateExternalReference"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + handler.updateExternalReference(userId, + requestBody.getMetadataCorrelationProperties(), + externalReferenceGUID, + isMergeUpdate, + requestBody.getElementProperties(), + 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 a external reference. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param requestBody unique identifiers of the external reference in the external asset manager + * + * @return void or + * InvalidParameterException guid or userId is null; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public VoidResponse deleteExternalReference(String serverName, + String userId, + String externalReferenceGUID, + MetadataCorrelationProperties requestBody) + { + final String methodName = "deleteExternalReference"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + handler.removeExternalReference(userId, requestBody, externalReferenceGUID, 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 to route the request to + * @param userId the name of the calling user. + * @param assetManagerIsHome ensure that only the asset manager can update this asset + * @param attachedToGUID object linked to external references. + * @param requestBody 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. + * + * @return Unique identifier for new relationship or + * InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public GUIDResponse linkExternalReferenceToElement(String serverName, + String userId, + boolean assetManagerIsHome, + String attachedToGUID, + String externalReferenceGUID, + ExternalReferenceLinkRequestBody requestBody) + { + final String methodName = "linkExternalReferenceToElement"; + final String attachedToGUIDParameterName = "attachedToGUID"; + final String externalReferenceGUIDParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + GUIDResponse response = new GUIDResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + if (assetManagerIsHome) + { + response.setGUID(handler.linkExternalReferenceToElement(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + attachedToGUID, + attachedToGUIDParameterName, + externalReferenceGUID, + externalReferenceGUIDParameterName, + requestBody.getElementProperties(), + methodName)); + } + else + { + response.setGUID(handler.linkExternalReferenceToElement(userId, + null, + null, + attachedToGUID, + attachedToGUIDParameterName, + externalReferenceGUID, + externalReferenceGUIDParameterName, + requestBody.getElementProperties(), + 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 link between an external reference to an object. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param externalReferenceLinkGUID 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 problem with the GUID or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public VoidResponse updateExternalReferenceToElementLink(String serverName, + String userId, + String externalReferenceLinkGUID, + ExternalReferenceLinkRequestBody requestBody) + { + final String methodName = "linkExternalReferenceToElement"; + final String externalReferenceGUIDParameterName = "externalReferenceLinkGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + handler.updateExternalReferenceToElementLink(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + externalReferenceLinkGUID, + externalReferenceGUIDParameterName, + requestBody.getElementProperties(), + 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 link between a external reference and an element. If the element is its anchor, the external reference is removed. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param externalReferenceLinkGUID identifier of the external reference relationship. + * @param requestBody unique identifier of software server capability representing the caller + * + * @return void or + * InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public VoidResponse unlinkExternalReferenceFromElement(String serverName, + String userId, + String externalReferenceLinkGUID, + AssetManagerIdentifiersRequestBody requestBody) + { + final String methodName = "linkExternalReferenceToElement"; + final String externalReferenceGUIDParameterName = "externalReferenceLinkGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + handler.unlinkExternalReferenceFromElement(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + externalReferenceLinkGUID, + externalReferenceGUIDParameterName, + 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 sorted in open metadata. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody the time that the retrieved elements must be effective for + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public ExternalReferenceElementsResponse getExternalReferences(String serverName, + String userId, + int startFrom, + int pageSize, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getExternalReferences"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementsResponse response = new ExternalReferenceElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.getExternalReferences(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + requestBody.getEffectiveTime(), + startFrom, + pageSize, + 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 requestBody. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public ExternalReferenceElementsResponse getExternalReferencesById(String serverName, + String userId, + int startFrom, + int pageSize, + NameRequestBody requestBody) + { + final String methodName = "getExternalReferencesById"; + final String nameParameterName = "resourceId"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementsResponse response = new ExternalReferenceElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.getExternalReferencesById(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + requestBody.getName(), + nameParameterName, + requestBody.getEffectiveTime(), + startFrom, + pageSize, + 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 to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody URL of the external resource. + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public ExternalReferenceElementsResponse getExternalReferencesByURL(String serverName, + String userId, + int startFrom, + int pageSize, + NameRequestBody requestBody) + { + final String methodName = "getExternalReferencesByURL"; + final String nameParameterName = "url"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementsResponse response = new ExternalReferenceElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.getExternalReferencesByURL(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + requestBody.getName(), + nameParameterName, + requestBody.getEffectiveTime(), + startFrom, + pageSize, + 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 name. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody name of the external resource. + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public ExternalReferenceElementsResponse getExternalReferencesByName(String serverName, + String userId, + int startFrom, + int pageSize, + NameRequestBody requestBody) + { + final String methodName = "getExternalReferencesByName"; + final String nameParameterName = "name"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementsResponse response = new ExternalReferenceElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.getExternalReferencesByName(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + requestBody.getName(), + nameParameterName, + requestBody.getEffectiveTime(), + startFrom, + pageSize, + 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 reference created on behalf of the named asset manager. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param requestBody the time that the retrieved elements must be effective for + * + * @return list of matching metadata elements 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 ExternalReferenceElementsResponse getExternalReferencesForAssetManager(String serverName, + String userId, + int startFrom, + int pageSize, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getExternalReferencesForAssetManager"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementsResponse response = new ExternalReferenceElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.getExternalReferencesForAssetManager(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + requestBody.getEffectiveTime(), + startFrom, + pageSize, + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Find the external references that contain the search string - which may contain wildcards. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param requestBody regular expression (RegEx) to search for + * @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 guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public ExternalReferenceElementsResponse findExternalReferences(String serverName, + String userId, + int startFrom, + int pageSize, + SearchStringRequestBody requestBody) + { + final String methodName = "findExternalReferences"; + final String searchStringParameterName = "requestBody"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementsResponse response = new ExternalReferenceElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.findExternalReferences(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + requestBody.getSearchString(), + searchStringParameterName, + requestBody.getEffectiveTime(), + startFrom, + pageSize, + 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 to route the request 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. + * @param requestBody the time that the retrieved elements must be effective for + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + public ExternalReferenceLinkElementsResponse retrieveAttachedExternalReferences(String serverName, + String userId, + String attachedToGUID, + int startFrom, + int pageSize, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "retrieveAttachedExternalReferences"; + final String guidParameterName = "attachedToGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceLinkElementsResponse response = new ExternalReferenceLinkElementsResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElementList(handler.retrieveAttachedExternalReferences(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + attachedToGUID, + guidParameterName, + requestBody.getEffectiveTime(), + startFrom, + pageSize, + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + 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 to route the request to + * @param userId calling user + * @param externalReferenceGUID unique identifier for the external reference + * @param requestBody the time that the retrieved elements must be effective for + * + * @return properties of the external reference or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + public ExternalReferenceElementResponse getExternalReferenceByGUID(String serverName, + String userId, + String externalReferenceGUID, + EffectiveTimeQueryRequestBody requestBody) + { + final String methodName = "getExternalReferenceByGUID"; + final String guidParameterName = "externalReferenceGUID"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + ExternalReferenceElementResponse response = new ExternalReferenceElementResponse(); + AuditLog auditLog = null; + + try + { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + if (requestBody != null) + { + ExternalReferenceExchangeHandler handler = instanceHandler.getExternalReferenceExchangeHandler(userId, serverName, methodName); + + response.setElement(handler.getExternalReferenceByGUID(userId, + requestBody.getAssetManagerGUID(), + requestBody.getAssetManagerName(), + externalReferenceGUID, + guidParameterName, + requestBody.getEffectiveTime(), + methodName)); + } + else + { + restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } +} diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/ExternalReferenceExchangeResource.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/ExternalReferenceExchangeResource.java new file mode 100644 index 00000000000..0f52af58b21 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/ExternalReferenceExchangeResource.java @@ -0,0 +1,412 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.accessservices.assetmanager.server.spring; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.odpi.openmetadata.accessservices.assetmanager.properties.MetadataCorrelationProperties; +import org.odpi.openmetadata.accessservices.assetmanager.rest.AssetManagerIdentifiersRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.EffectiveTimeQueryRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceElementResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceElementsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceLinkElementsResponse; +import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceLinkRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.ExternalReferenceRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.NameRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.rest.SearchStringRequestBody; +import org.odpi.openmetadata.accessservices.assetmanager.server.ExternalReferenceExchangeRESTServices; +import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * GlossaryExchangeResource is the server-side implementation of the Asset Manager OMAS's + * support for glossaries. It matches the GlossaryExchangeClient. + */ +@RestController +@RequestMapping("/servers/{serverName}/open-metadata/access-services/asset-manager/users/{userId}") + +@Tag(name="Asset Manager OMAS", + description="The Asset Manager OMAS provides APIs and events for managing metadata exchange with third party asset managers, such as data catalogs.", + externalDocs=@ExternalDocumentation(description="Asset Manager Open Metadata Access Service (OMAS)", + url="https://egeria-project.org/services/omas/asset-manager/overview")) + +public class ExternalReferenceExchangeResource +{ + private ExternalReferenceExchangeRESTServices restAPI = new ExternalReferenceExchangeRESTServices(); + + /** + * Default constructor + */ + public ExternalReferenceExchangeResource() + { + } + + + /** + * Create a definition of a external reference. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param assetManagerIsHome ensure that only the asset manager can update this asset + * @param requestBody properties for a external reference + * + * @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, + @RequestParam boolean assetManagerIsHome, + @RequestBody ExternalReferenceRequestBody requestBody) + { + return restAPI.createExternalReference(serverName, userId, assetManagerIsHome, requestBody); + } + + + /** + * Update the definition of a external reference. + * + * @param serverName name of the server to route the request 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}") + + public VoidResponse updateExternalReference(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID, + @RequestParam boolean isMergeUpdate, + @RequestBody ExternalReferenceRequestBody requestBody) + { + return restAPI.updateExternalReference(serverName, userId, externalReferenceGUID, isMergeUpdate, requestBody); + } + + + /** + * Remove the definition of a external reference. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param externalReferenceGUID unique identifier of external reference + * @param requestBody unique identifiers of the external reference in the external asset manager + * + * @return void or + * InvalidParameterException guid or userId is null; guid is not known + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references/{externalReferenceGUID}/remove") + + public VoidResponse deleteExternalReference(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID, + @RequestBody MetadataCorrelationProperties requestBody) + { + return restAPI.deleteExternalReference(serverName, userId, externalReferenceGUID, requestBody); + } + + + /** + * Link an external reference to an object. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param assetManagerIsHome ensure that only the asset manager can update this asset + * @param attachedToGUID object linked to external references. + * @param requestBody 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. + * + * @return Unique identifier for new relationship or + * InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/{externalReferenceGUID}/links/{attachedToGUID}") + + public GUIDResponse linkExternalReferenceToElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String attachedToGUID, + @PathVariable String externalReferenceGUID, + @RequestParam boolean assetManagerIsHome, + @RequestBody ExternalReferenceLinkRequestBody requestBody) + { + return restAPI.linkExternalReferenceToElement(serverName, userId, assetManagerIsHome, attachedToGUID, externalReferenceGUID, requestBody); + } + + + + /** + * Update the link between an external reference to an object. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param externalReferenceLinkGUID 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 problem with the GUID or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/links/{externalReferenceLinkGUID}/update") + + public VoidResponse updateExternalReferenceToElementLink(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceLinkGUID, + @RequestBody ExternalReferenceLinkRequestBody requestBody) + { + return restAPI.updateExternalReferenceToElementLink(serverName, userId, externalReferenceLinkGUID, requestBody); + } + + + /** + * Remove the link between a external reference and an element. If the element is its anchor, the external reference is removed. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param externalReferenceLinkGUID identifier of the external reference relationship. + * @param requestBody unique identifier of software server capability representing the caller + * + * @return void or + * InvalidParameterException problem with the GUID or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/links/{externalReferenceLinkGUID}/remove") + + public VoidResponse unlinkExternalReferenceFromElement(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceLinkGUID, + @RequestBody AssetManagerIdentifiersRequestBody requestBody) + { + return restAPI.unlinkExternalReferenceFromElement(serverName, userId, externalReferenceLinkGUID, requestBody); + } + + + /** + * Retrieve the list of external references sorted in open metadata. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody the time that the retrieved elements must be effective for + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/by-type") + + public ExternalReferenceElementsResponse getExternalReferences(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getExternalReferences(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve the list of external references for this requestBody. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/by-resource-id") + + public ExternalReferenceElementsResponse getExternalReferencesById(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody NameRequestBody requestBody) + { + return restAPI.getExternalReferencesById(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve the list of external references for this URL. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody URL of the external resource. + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/by-url") + + public ExternalReferenceElementsResponse 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 for this name. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param requestBody name of the external resource. + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/by-name") + + public ExternalReferenceElementsResponse getExternalReferencesByName(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody NameRequestBody requestBody) + { + return restAPI.getExternalReferencesByName(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve the list of external reference created on behalf of the named asset manager. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param requestBody the time that the retrieved elements must be effective for + * + * @return list of matching metadata elements 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 = "/external-references/by-asset-manager") + + public ExternalReferenceElementsResponse getExternalReferencesForAssetManager(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getExternalReferencesForAssetManager(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Find the external references that contain the search string - which may contain wildcards. + * + * @param serverName name of the server to route the request to + * @param userId the name of the calling user. + * @param requestBody regular expression (RegEx) to search for + * @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 guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/by-search-string") + + public ExternalReferenceElementsResponse findExternalReferences(@PathVariable String serverName, + @PathVariable String userId, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody SearchStringRequestBody requestBody) + { + return restAPI.findExternalReferences(serverName, userId, startFrom, pageSize, requestBody); + } + + + /** + * Retrieve the list of external references attached to the supplied object. + * + * @param serverName name of the server to route the request 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. + * @param requestBody the time that the retrieved elements must be effective for + * + * @return links to addition information or + * InvalidParameterException guid invalid or the external references are not correctly specified, or are null. + * PropertyServerException the server is not available. + * UserNotAuthorizedException the calling user is not authorized to issue the call. + */ + @PostMapping(path = "/external-references/attached-to/{attachedToGUID}") + + public ExternalReferenceLinkElementsResponse retrieveAttachedExternalReferences(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String attachedToGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, + @RequestBody EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.retrieveAttachedExternalReferences(serverName, userId, attachedToGUID, startFrom, pageSize, requestBody); + } + + + /** + * Return information about a specific external reference. + * + * @param serverName name of the server to route the request to + * @param userId calling user + * @param externalReferenceGUID unique identifier for the external reference + * @param requestBody the time that the retrieved elements must be effective for + * + * @return properties of the external reference or + * InvalidParameterException externalReferenceGUID or userId is null + * PropertyServerException problem accessing property server + * UserNotAuthorizedException security access problem + */ + @PostMapping(path = "/external-references/{externalReferenceGUID}/by-guid") + + public ExternalReferenceElementResponse getExternalReferenceByGUID(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String externalReferenceGUID, + @RequestBody EffectiveTimeQueryRequestBody requestBody) + { + return restAPI.getExternalReferenceByGUID(serverName, userId, externalReferenceGUID, requestBody); + } +} diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierHandler.java index 72823560656..65276a2d9af 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierHandler.java @@ -278,6 +278,34 @@ public void logRelationshipCreation(String scopeGUID, } + /** + * Create an audit log record to document that an external metadata source has created a relationship. + * + * @param scopeGUID unique identifier of the element representing the scope + * @param scopeQualifiedName unique name of the element representing the scope + * @param relationshipType type of relationship + * @param relationshipGUID unique identifier for the relationship + * @param methodName calling method + */ + public void logRelationshipUpdate(String scopeGUID, + String scopeQualifiedName, + String relationshipType, + String relationshipGUID, + String methodName) + { + if (scopeGUID != null) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.EXTERNAL_RELATIONSHIP_UPDATED.getMessageDefinition(serviceName, + relationshipType, + relationshipGUID, + methodName, + scopeGUID, + scopeQualifiedName)); + } + } + + /** * Create an audit log record to document that an external metadata source has created a relationship. * diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceBuilder.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceBuilder.java new file mode 100644 index 00000000000..d86b3253cb6 --- /dev/null +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceBuilder.java @@ -0,0 +1,238 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.commonservices.generichandlers; + +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; + +import java.util.Map; + +/** + * ExternalReferenceBuilder creates the parts for an entity that represents an external reference. + */ +public class ExternalReferenceBuilder extends ReferenceableBuilder +{ + private String displayName = null; + private String description = null; + private String url = null; + private String referenceVersion = null; + private String organization = null; + + + /** + * Create constructor + * + * @param qualifiedName unique name for the reference + * @param displayName short display name for the reference + * @param description description of the reference + * @param url the location of the reference + * @param referenceVersion version of the reference + * @param organization owning org for the reference + * @param additionalProperties additional properties for the reference + * @param typeGUID unique identifier of this element's type + * @param typeName unique name of this element's type + * @param extendedProperties properties for a subtype + * @param repositoryHelper helper methods + * @param serviceName name of this OMAS + * @param serverName name of local server + */ + ExternalReferenceBuilder(String qualifiedName, + String displayName, + String description, + String url, + String referenceVersion, + String organization, + Map additionalProperties, + String typeGUID, + String typeName, + Map extendedProperties, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(qualifiedName, + additionalProperties, + typeGUID, + typeName, + extendedProperties, + repositoryHelper, + serviceName, + serverName); + + this.displayName = displayName; + this.description = description; + this.url = url; + this.referenceVersion = referenceVersion; + this.organization = organization; + } + + + /** + * Create constructor + * + * @param qualifiedName unique name for the reference + * @param displayName short display name for the reference + * @param description description of the reference + * @param url the location of the reference + * @param referenceVersion version of the reference + * @param organization owning org for the reference + * @param additionalProperties additional properties for the reference + * @param repositoryHelper helper methods + * @param serviceName name of this OMAS + * @param serverName name of local server + */ + public ExternalReferenceBuilder(String qualifiedName, + String displayName, + String description, + String url, + String referenceVersion, + String organization, + Map additionalProperties, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(qualifiedName, + additionalProperties, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + null, + repositoryHelper, + serviceName, + serverName); + + this.displayName = displayName; + this.description = description; + this.url = url; + this.referenceVersion = referenceVersion; + this.organization = organization; + } + + + /** + * Create constructor + * + * @param qualifiedName unique name for the external reference + * @param displayName short display name for the external reference + * @param description description of the external reference + * @param repositoryHelper helper methods + * @param serviceName name of this OMAS + * @param serverName name of local server + */ + ExternalReferenceBuilder(String qualifiedName, + String displayName, + String description, + OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(qualifiedName, + null, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + null, + repositoryHelper, + serviceName, + serverName); + + this.displayName = displayName; + this.description = description; + } + + + /** + * Classification constructor + * + * @param repositoryHelper helper methods + * @param serviceName name of this OMAS + * @param serverName name of local server + */ + ExternalReferenceBuilder(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + repositoryHelper, + serviceName, + serverName); + } + + + /** + * Return the supplied bean properties in an InstanceProperties object. + * + * @param methodName name of the calling method + * @return InstanceProperties object + * @throws InvalidParameterException there is a problem with the properties + */ + @Override + public InstanceProperties getInstanceProperties(String methodName) throws InvalidParameterException + { + InstanceProperties properties = super.getInstanceProperties(methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.DISPLAY_NAME_PROPERTY_NAME, + displayName, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.DESCRIPTION_PROPERTY_NAME, + description, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.URL_PROPERTY_NAME, + url, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.REFERENCE_VERSION_PROPERTY_NAME, + referenceVersion, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.ORGANIZATION_PROPERTY_NAME, + organization, + methodName); + + return properties; + } + + /** + * Return the properties for a relationship between a referenceable and an external reference. + * + * @param referenceId the local reference identifier for the reference + * @param methodName name of the calling method + * @return InstanceProperties object + */ + InstanceProperties getLinkProperties(String referenceId, + String description, + String methodName) + { + InstanceProperties properties = null; + + if (referenceId != null) + { + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + null, + OpenMetadataAPIMapper.REFERENCE_ID_PROPERTY_NAME, + referenceId, + methodName); + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.DESCRIPTION_PROPERTY_NAME, + description, + methodName); + + } + + return properties; + } +} diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceHandler.java index 497de64875e..b74949d6ad6 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceHandler.java @@ -9,10 +9,14 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; /** * ExternalReferenceHandler manages ExternalReference objects. It runs server-side in @@ -67,84 +71,503 @@ public ExternalReferenceHandler(OpenMetadataAPIGenericConverter converter, } + /** - * Count the number of external references attached to an anchor entity. + * Create a definition of a operating platform. * - * @param userId calling user - * @param elementGUID identifier for the entity that the object is attached to - * @param effectiveTime the time that the retrieved elements must be effective for + * @param userId calling user + * @param externalSourceGUID guid of the software server capability entity that represented the external source - null for local + * @param externalSourceName name of the software server capability entity that represented the external source + * @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 qualifiedName unique name for the reference + * @param displayName short display name for the reference + * @param description description of the reference + * @param url the location of the reference + * @param referenceVersion version of the reference + * @param organization owning org for the reference + * @param additionalProperties additional properties for an external reference + * @param suppliedTypeName type of external reference + * @param extendedProperties properties for an external reference subtype + * @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 unique identifier of external reference + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public String createExternalReference(String userId, + String externalSourceGUID, + String externalSourceName, + String anchorGUID, + String qualifiedName, + String displayName, + String description, + String url, + String referenceVersion, + String organization, + Map additionalProperties, + String suppliedTypeName, + Map extendedProperties, + Date effectiveFrom, + Date effectiveTo, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + String typeName = OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME; + + if (suppliedTypeName != null) + { + typeName = suppliedTypeName; + } + + String typeGUID = invalidParameterHandler.validateTypeName(typeName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + serviceName, + methodName, + repositoryHelper); + + ExternalReferenceBuilder builder = new ExternalReferenceBuilder(qualifiedName, + displayName, + description, + url, + referenceVersion, + organization, + additionalProperties, + typeGUID, + suppliedTypeName, + extendedProperties, + repositoryHelper, + serviceName, + serverName); + + builder.setEffectivityDates(effectiveFrom, effectiveTo); + + if (anchorGUID != null) + { + builder.setAnchors(userId, anchorGUID, methodName); + } + + return this.createBeanInRepository(userId, + externalSourceGUID, + externalSourceName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + qualifiedName, + OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME, + builder, + methodName); + } + + + /** + * Update the operating platform. + * + * @param userId calling user + * @param externalSourceGUID guid of the software server capability entity that represented the external source - null for local + * @param externalSourceName name of the software server capability entity that represented the external source + * @param operatingPlatformGUID unique identifier of the operating platform to update + * @param operatingPlatformGUIDParameterName parameter passing the operatingPlatformGUID + * @param qualifiedName unique name for the reference + * @param displayName short display name for the reference + * @param description description of the reference + * @param url the location of the reference + * @param referenceVersion version of the reference + * @param organization owning org for the reference + * @param additionalProperties additional properties for an external reference + * @param suppliedTypeName name of sub type or null + * @param extendedProperties properties for a governance operatingPlatform subtype + * @param isMergeUpdate should the properties be merged with existing properties or replace the existing properties? + * @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 + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void updateExternalReference(String userId, + String externalSourceGUID, + String externalSourceName, + String operatingPlatformGUID, + String operatingPlatformGUIDParameterName, + String qualifiedName, + String displayName, + String description, + String url, + String referenceVersion, + String organization, + Map additionalProperties, + String suppliedTypeName, + Map extendedProperties, + boolean isMergeUpdate, + Date effectiveFrom, + Date effectiveTo, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String qualifiedNameParameterName = "qualifiedName"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(operatingPlatformGUID, operatingPlatformGUIDParameterName, methodName); + invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName); + + String typeName = OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME; + + if (suppliedTypeName != null) + { + typeName = suppliedTypeName; + } + + String typeGUID = invalidParameterHandler.validateTypeName(typeName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + serviceName, + methodName, + repositoryHelper); + + ExternalReferenceBuilder builder = new ExternalReferenceBuilder(qualifiedName, + displayName, + description, + url, + referenceVersion, + organization, + additionalProperties, + typeGUID, + typeName, + extendedProperties, + repositoryHelper, + serviceName, + serverName); + + builder.setEffectivityDates(effectiveFrom, effectiveTo); + + Date effectiveTime = getEffectiveTime(effectiveFrom, effectiveTo); + + this.updateBeanInRepository(userId, + externalSourceGUID, + externalSourceName, + operatingPlatformGUID, + operatingPlatformGUIDParameterName, + typeGUID, + typeName, + false, + false, + supportedZones, + builder.getInstanceProperties(methodName), + isMergeUpdate, + effectiveTime, + methodName); + } + + + /** + * Remove the metadata element representing an external reference. + * + * @param userId calling user + * @param externalSourceGUID guid of the software server capability entity that represented the external source - null for local + * @param externalSourceName name of the software server capability entity that represented the external source + * @param operatingPlatformGUID unique identifier of the metadata element to remove + * @param operatingPlatformGUIDParameterName parameter supplying the operatingPlatformGUID * @param methodName calling method - * @return count of attached objects or null if none found - * @throws InvalidParameterException the parameters are invalid - * @throws UserNotAuthorizedException user not authorized to issue this request - * @throws PropertyServerException problem accessing the property server + * + * @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 int countExternalReferences(String userId, - String elementGUID, - Date effectiveTime, - String methodName) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public void removeExternalReference(String userId, + String externalSourceGUID, + String externalSourceName, + String operatingPlatformGUID, + String operatingPlatformGUIDParameterName, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { - return super.countAttachments(userId, - elementGUID, - OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, - OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, - OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, - effectiveTime, - methodName); + this.deleteBeanInRepository(userId, + externalSourceGUID, + externalSourceName, + operatingPlatformGUID, + operatingPlatformGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + null, + null, + false, + false, + new Date(), + methodName); } /** - * Return the external references attached to an anchor entity. - * - * @param userId calling user - * @param elementGUID identifier for the entity that the reference is attached to - * @param elementGUIDParameterName name of parameter supplying the GUID - * @param elementTypeName name of the type of object being attached to - * @param serviceSupportedZones supported zones for calling service - * @param startingFrom where to start from in the list - * @param pageSize maximum number of results that can be returned + * Return information about a specific operating platform. + * + * @param userId calling user + * @param qualifiedName unique name for the operating platform + * @param qualifiedNameParameter name of parameter supplying the qualifiedName * @param effectiveTime the time that the retrieved elements must be effective for * @param methodName calling method * - * @return list of retrieved objects + * @return properties of the operating platform * - * @throws InvalidParameterException the input properties are invalid - * @throws UserNotAuthorizedException user not authorized to issue this request - * @throws PropertyServerException problem accessing the property server + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem */ - public List getExternalReferences(String userId, - String elementGUID, - String elementGUIDParameterName, - String elementTypeName, - List serviceSupportedZones, - int startingFrom, - int pageSize, - Date effectiveTime, - String methodName) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public B getExternalReferenceByQualifiedName(String userId, + String qualifiedName, + String qualifiedNameParameter, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { - return this.getAttachedElements(userId, - null, - null, - elementGUID, - elementGUIDParameterName, - elementTypeName, - OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, - OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + return this.getBeanByUniqueName(userId, + qualifiedName, + qualifiedNameParameter, + OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, - null, - null, - 0, - false, - false, - serviceSupportedZones, - startingFrom, - pageSize, effectiveTime, methodName); } + + + /** + * Retrieve the list of external reference metadata elements with a matching referenceId. + * There are no wildcards supported on this request. + * + * @param userId calling user + * @param referenceId referenceId to search for + * @param referenceIdParameterName parameter supplying referenceId + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesById(String userId, + String referenceId, + String referenceIdParameterName, + int startFrom, + int pageSize, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List specificMatchPropertyNames = new ArrayList<>(); + specificMatchPropertyNames.add(OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME); + + return this.getBeansByValue(userId, + referenceId, + referenceIdParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + specificMatchPropertyNames, + true, + null, + null, + false, + false, + supportedZones, + null, + startFrom, + pageSize, + effectiveTime, + methodName); + } + + + + /** + * Retrieve the list of external reference metadata elements with a matching name. + * There are no wildcards supported on this request. + * + * @param userId calling user + * @param name name to search for + * @param nameParameterName parameter supplying name + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesByName(String userId, + String name, + String nameParameterName, + int startFrom, + int pageSize, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List specificMatchPropertyNames = new ArrayList<>(); + specificMatchPropertyNames.add(OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME); + specificMatchPropertyNames.add(OpenMetadataAPIMapper.DISPLAY_NAME_PROPERTY_NAME); + + return this.getBeansByValue(userId, + name, + nameParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + specificMatchPropertyNames, + true, + null, + null, + false, + false, + supportedZones, + null, + startFrom, + pageSize, + effectiveTime, + methodName); + } + + + + /** + * Retrieve the list of external reference metadata elements with a matching url. + * There are no wildcards supported on this request. + * + * @param userId calling user + * @param url url to search for + * @param urlParameterName parameter supplying url + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getExternalReferencesByURL(String userId, + String url, + String urlParameterName, + int startFrom, + int pageSize, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + List specificMatchPropertyNames = new ArrayList<>(); + specificMatchPropertyNames.add(OpenMetadataAPIMapper.URL_PROPERTY_NAME); + + return this.getBeansByValue(userId, + url, + urlParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + specificMatchPropertyNames, + true, + null, + null, + false, + false, + supportedZones, + null, + startFrom, + pageSize, + effectiveTime, + methodName); + } + + + /** + * Return information about the defined operating platforms. + * + * @param userId calling user + * @param startingFrom position in the list (used when there are so many reports that paging is needed + * @param pageSize maximum number of elements to return an this call + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return properties of the operating platform + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getExternalReferences(String userId, + int startingFrom, + int pageSize, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return this.getBeansByType(userId, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + null, + false, + false, + supportedZones, + startingFrom, + pageSize, + effectiveTime, + methodName); + } + + + /** + * Retrieve the list of metadata elements that contain the search string. + * The search string is treated as a regular expression. + * + * @param userId calling user + * @param searchString string to find in the properties + * @param searchStringParameterName name of parameter supplying the search string + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * @param methodName calling method + * + * @return list of matching metadata elements + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List findExternalReferences(String userId, + String searchString, + String searchStringParameterName, + int startFrom, + int pageSize, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return this.findBeans(userId, + searchString, + searchStringParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + null, + startFrom, + pageSize, + effectiveTime, + methodName); + } } diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java new file mode 100644 index 00000000000..ea749750498 --- /dev/null +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java @@ -0,0 +1,406 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.commonservices.generichandlers; + +import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * ExternalReferenceLinkHandler manages retrieval of ExternalReference objects attached to a specific element. Thus it includes + * the relationship properties and entity properties in the bean. It runs server-side in + * the OMAG Server Platform and retrieves ExternalReference entities through the OMRSRepositoryConnector. + */ +public class ExternalReferenceLinkHandler extends ReferenceableHandler +{ + private static final Logger log = LoggerFactory.getLogger(ExternalReferenceLinkHandler.class); + + /** + * Construct the handler information needed to interact with the repository services + * + * @param converter specific converter for this bean class + * @param beanClass name of bean class that is represented by the generic class B + * @param serviceName name of this service + * @param serverName name of the local server + * @param invalidParameterHandler handler for managing parameter errors + * @param repositoryHandler manages calls to the repository services + * @param repositoryHelper provides utilities for manipulating the repository services objects + * @param localServerUserId userId for this server + * @param securityVerifier open metadata security services verifier + * @param supportedZones list of zones that the access service is allowed to serve Asset instances from. + * @param defaultZones list of zones that the access service should set in all new Asset instances. + * @param publishZones list of zones that the access service sets up in published Asset instances. + * @param auditLog destination for audit log events. + */ + public ExternalReferenceLinkHandler(OpenMetadataAPIGenericConverter converter, + Class beanClass, + String serviceName, + String serverName, + InvalidParameterHandler invalidParameterHandler, + RepositoryHandler repositoryHandler, + OMRSRepositoryHelper repositoryHelper, + String localServerUserId, + OpenMetadataServerSecurityVerifier securityVerifier, + List supportedZones, + List defaultZones, + List publishZones, + AuditLog auditLog) + { + super(converter, + beanClass, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); + } + + + /** + * Count the number of external references attached to an anchor entity. + * + * @param userId calling user + * @param elementGUID identifier for the entity that the object is attached to + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * @return count of attached objects or null if none found + * @throws InvalidParameterException the parameters are invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + public int countExternalReferences(String userId, + String elementGUID, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + return super.countAttachments(userId, + elementGUID, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + effectiveTime, + methodName); + } + + + + /** + * Create a relationship between a host and an operating platform. + * + * @param userId calling user + * @param externalSourceGUID guid of the software server capability entity that represented the external source - null for local + * @param externalSourceName name of the software server capability entity that represented the external source + * @param referenceableGUID unique identifier of the referenceable + * @param referenceableGUIDParameterName parameter supplying the referenceableGUID + * @param externalReferenceGUID unique identifier of the external reference + * @param externalReferenceGUIDParameterName parameter supplying the externalReferenceGUID + * @param referenceId local identifier for the reference + * @param referenceDescription short description for the link (think hover text) + * @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 unique identifier of 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 setupExternalReferenceLink(String userId, + String externalSourceGUID, + String externalSourceName, + String referenceableGUID, + String referenceableGUIDParameterName, + String externalReferenceGUID, + String externalReferenceGUIDParameterName, + String referenceId, + String referenceDescription, + Date effectiveFrom, + Date effectiveTo, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + ExternalReferenceBuilder builder = new ExternalReferenceBuilder(repositoryHelper, + serviceName, + serverName); + + InstanceProperties relationshipProperties = builder.getLinkProperties(referenceId, referenceDescription, methodName); + + return this.multiLinkElementToElement(userId, + externalSourceGUID, + externalSourceName, + referenceableGUID, + referenceableGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + externalReferenceGUID, + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + supportedZones, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + setUpEffectiveDates(relationshipProperties, effectiveFrom, effectiveTo), + null, + methodName); + } + + + /** + * Create a relationship between a host and an operating platform. + * + * @param userId calling user + * @param externalSourceGUID guid of the software server capability entity that represented the external source - null for local + * @param externalSourceName name of the software server capability entity that represented the external source + * @param relationshipGUID unique identifier of relationship + * @param relationshipGUIDParameterName parameter supplying the relationshipGUID + * @param referenceId local identifier for the reference + * @param referenceDescription short description for the link (think hover text) + * @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 unique identifier of 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 void updateExternalReferenceLink(String userId, + String externalSourceGUID, + String externalSourceName, + String relationshipGUID, + String relationshipGUIDParameterName, + String referenceId, + String referenceDescription, + Date effectiveFrom, + Date effectiveTo, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + ExternalReferenceBuilder builder = new ExternalReferenceBuilder(repositoryHelper, + serviceName, + serverName); + + InstanceProperties relationshipProperties = builder.getLinkProperties(referenceId, referenceDescription, methodName); + + this.updateElementToElementLink(userId, + externalSourceGUID, + externalSourceName, + relationshipGUID, + relationshipGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + false, + false, + supportedZones, + false, + setUpEffectiveDates(relationshipProperties, effectiveFrom, effectiveTo), + methodName); + } + + + /** + * Remove a relationship between a host and an operating platform.. + * + * @param userId calling user + * @param externalSourceGUID guid of the software server capability entity that represented the external source - null for local + * @param externalSourceName name of the software server capability entity that represented the external source + * @param relationshipGUID unique identifier of the referenceable + * @param relationshipGUIDParameterName parameter supplying the relationshipGUID + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return relationship that has just been deleted + * + * @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 Relationship clearExternalReferenceLink(String userId, + String externalSourceGUID, + String externalSourceName, + String relationshipGUID, + String relationshipGUIDParameterName, + Date effectiveTime, + String methodName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String referenceableGUIDParameterName = "relationship.getEntityOneProxy().getGUID()"; + final String externalReferenceGUIDParameterName = "relationship.getEntityTwoProxy().getGUID()"; + + Relationship relationship = this.getAttachmentLink(userId, + relationshipGUID, + relationshipGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + effectiveTime, + methodName); + + this.unlinkElementFromElement(userId, + false, + externalSourceGUID, + externalSourceName, + relationship.getEntityOneProxy().getGUID(), + referenceableGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + relationship.getEntityTwoProxy().getGUID(), + externalReferenceGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_GUID, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + false, + false, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + relationship, + methodName); + + return relationship; + } + + + /** + * Return the external references attached to an anchor entity. + * + * @param userId calling user + * @param startingGUID identifier for the entity that the reference is attached to + * @param startingGUIDParameterName name of parameter supplying the GUID + * @param startingTypeName name of the type of object being attached to + * @param serviceSupportedZones supported zones for calling service + * @param startingFrom where to start from in the list + * @param pageSize maximum number of results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * @param methodName calling method + * + * @return list of retrieved objects + * + * @throws InvalidParameterException the input properties are invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + public List getExternalReferences(String userId, + String startingGUID, + String startingGUIDParameterName, + String startingTypeName, + List serviceSupportedZones, + int startingFrom, + int pageSize, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(startingGUID, startingGUIDParameterName, methodName); + + this.validateAnchorEntity(userId, + startingGUID, + startingGUIDParameterName, + startingTypeName, + false, + false, + false, + serviceSupportedZones, + effectiveTime, + methodName); + + /* + * Validates the parameters and retrieves the links to attached keywords that are visible to this user. + * Relationships are returned so that the isPublic property from the relationship can be retrieved. + */ + List relationships = this.getAttachmentLinks(userId, + startingGUID, + startingGUIDParameterName, + startingTypeName, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_GUID, + OpenMetadataAPIMapper.REFERENCEABLE_TO_EXT_REF_TYPE_NAME, + null, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + 2, + false, + startingFrom, + pageSize, + effectiveTime, + methodName); + + if ((relationships == null) || (relationships.isEmpty())) + { + return null; + } + + List results = new ArrayList<>(); + + for (Relationship relationship : relationships) + { + if (relationship != null) + { + try + { + final String entityGUIDParameterName = "entity.getGUID"; + + EntityDetail entity = this.getEntityFromRepository(userId, + relationship.getEntityTwoProxy().getGUID(), + entityGUIDParameterName, + OpenMetadataAPIMapper.EXTERNAL_REFERENCE_TYPE_NAME, + null, + null, + false, + false, + effectiveTime, + methodName); + + if (entity != null) + { + B bean = converter.getNewBean(beanClass, entity, relationship, methodName); + + if (bean != null) + { + results.add(bean); + } + } + } + catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException inaccessibleEntity) + { + // skip entities that are not visible to this user + if (log.isDebugEnabled()) + { + log.debug("Skipping inaccessible entity", inaccessibleEntity); + } + } + } + } + + if (results.isEmpty()) + { + return null; + } + else + { + return results; + } + + } +} diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericConverter.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericConverter.java index be63de13bb8..3a7f24c0a07 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericConverter.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericConverter.java @@ -1255,6 +1255,28 @@ protected String removeReferenceVersion(InstanceProperties instanceProperties) } + /** + * Extract and delete the referenceId property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return string text or null + */ + protected String removeReferenceId(InstanceProperties instanceProperties) + { + final String methodName = "removeReferenceId"; + + if (instanceProperties != null) + { + return repositoryHelper.removeStringProperty(serviceName, + OpenMetadataAPIMapper.REFERENCE_ID_PROPERTY_NAME, + instanceProperties, + methodName); + } + + return null; + } + + /** * Extract the referenceId property from the supplied instance properties. * diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java index 9f9e414455e..556b1e612d3 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java @@ -5193,14 +5193,14 @@ public List getAttachedEntities(String userId, * @throws UserNotAuthorizedException user not authorized to issue this request * @throws PropertyServerException problem accessing the repositories */ - public Relationship getAttachmentLink(String userId, - String relationshipGUID, - String relationshipGUIDParameterName, - String relationshipTypeName, - Date effectiveTime, - String methodName) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public Relationship getAttachmentLink(String userId, + String relationshipGUID, + String relationshipGUIDParameterName, + String relationshipTypeName, + Date effectiveTime, + String methodName) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { Relationship relationship = repositoryHandler.getRelationshipByGUID(userId, diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java index 52225db7376..bb14712d4ca 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIMapper.java @@ -153,7 +153,7 @@ public class OpenMetadataAPIMapper public static final String URL_PROPERTY_NAME = "url"; /* from ExternalReference entity */ public static final String REFERENCE_VERSION_PROPERTY_NAME = "referenceVersion"; /* from ExternalReference entity */ - public static final String REFERENCE_ID_PROPERTY_NAME = "referenceId"; /* from ExternalReferenceLink relationship */ + public static final String REFERENCE_ID_PROPERTY_NAME = "referenceId"; /* from ExternalReferenceLink relationship */ /* also description property */ public static final String RELATED_MEDIA_TYPE_GUID = "747f8b86-fe7c-4c9b-ba75-979e093cc307"; diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OperatingPlatformHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OperatingPlatformHandler.java index d04b28809a3..161cfe27c9a 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OperatingPlatformHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OperatingPlatformHandler.java @@ -164,6 +164,7 @@ public void createOperatingPlatform(String userId, * @param additionalProperties additional properties for a governance operatingPlatform * @param suppliedTypeName name of sub type or null * @param extendedProperties properties for a governance operatingPlatform subtype + * @param isMergeUpdate should the properties be merged with existing properties or replace the existing properties? * @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 @@ -185,6 +186,7 @@ public void updateOperatingPlatform(String userId, Map additionalProperties, String suppliedTypeName, Map extendedProperties, + boolean isMergeUpdate, Date effectiveFrom, Date effectiveTo, String methodName) throws InvalidParameterException, @@ -238,7 +240,7 @@ public void updateOperatingPlatform(String userId, false, supportedZones, builder.getInstanceProperties(methodName), - false, + isMergeUpdate, effectiveTime, methodName); } diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java index e5d3547d5d9..8f52841703d 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java @@ -55,14 +55,21 @@ public enum GenericHandlersAuditCode implements AuditLogMessageSet "No action is required now but this message can be useful to understand where particular relationships " + "came from."), - EXTERNAL_RELATIONSHIP_REMOVED("OMAG-GENERIC-HANDLERS-0005", + EXTERNAL_RELATIONSHIP_UPDATED("OMAG-GENERIC-HANDLERS-0005", + OMRSAuditLogRecordSeverity.INFO, + "{0} has updated an existing {1} relationship {2} during method {3} on behalf of external metadata manager {4} ({5})", + "The updated properties of described relationship is stored in one of the connected open metadata repositories.", + "No action is required now but this message can be useful to understand where particular relationships' " + + "values came from."), + + EXTERNAL_RELATIONSHIP_REMOVED("OMAG-GENERIC-HANDLERS-0006", OMRSAuditLogRecordSeverity.INFO, "{0} has removed the {1} relationship between {2} {3} and {4} {5} during method {6} on behalf of external metadata manager {7} ({8})", "The removed relationship was stored in one of the connected open metadata repositories but has now been removed.", "No action is required now but this message can be useful to understand why a particular relationship " + "has been removed."), - UNABLE_TO_DELETE_UNANCHORED_BEAN("OMAG-GENERIC-HANDLERS-0006", + UNABLE_TO_DELETE_UNANCHORED_BEAN("OMAG-GENERIC-HANDLERS-0007", OMRSAuditLogRecordSeverity.EXCEPTION, "The Open Metadata Service {0} has deleted a relationship, resulting in entity {1} of type {2} ({3}) losing its anchor." + "An attempt was made to delete this unanchored entity, which failed. " + diff --git a/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataInstanceHandler.java b/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataInstanceHandler.java index b836ebacfe8..c2d48f1257c 100644 --- a/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataInstanceHandler.java +++ b/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataInstanceHandler.java @@ -251,11 +251,11 @@ ExternalIdentifierHandler getExternalIdentifierHandl * @throws UserNotAuthorizedException user does not have access to the requested server * @throws PropertyServerException error in the requested server */ - ExternalReferenceHandler getExternalReferenceHandler(String userId, - String serverName, - String serviceOperationName) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + ExternalReferenceLinkHandler getExternalReferenceHandler(String userId, + String serverName, + String serviceOperationName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException { OCFMetadataServicesInstance instance = (OCFMetadataServicesInstance)super.getServerServiceInstance(userId, serverName, diff --git a/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java b/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java index 87d1dc3902d..b6465a8f5c5 100644 --- a/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java +++ b/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java @@ -303,8 +303,9 @@ private AssetResponse getAssetResponse(String serverName, ExternalIdentifierHandler externalIdentifierHandler = instanceHandler.getExternalIdentifierHandler(userId, serverName, methodName); - ExternalReferenceHandler externalReferenceHandler = instanceHandler.getExternalReferenceHandler(userId, serverName, - methodName); + ExternalReferenceLinkHandler externalReferenceHandler = instanceHandler.getExternalReferenceHandler(userId, + serverName, + methodName); InformalTagHandler informalTagHandler = instanceHandler.getInformalTagHandler(userId, serverName, methodName); LicenseHandler licenseHandler = instanceHandler.getLicenseHandler(userId, serverName, @@ -819,7 +820,7 @@ public ExternalReferencesResponse getExternalReferences(String serverName, try { - ExternalReferenceHandler handler = instanceHandler.getExternalReferenceHandler(userId, serverName, methodName); + ExternalReferenceLinkHandler handler = instanceHandler.getExternalReferenceHandler(userId, serverName, methodName); auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); response.setList(handler.getExternalReferences(userId, diff --git a/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataServicesInstance.java b/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataServicesInstance.java index 2e420a28de8..048ea4203e1 100644 --- a/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataServicesInstance.java +++ b/open-metadata-implementation/common-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/commonservices/ocf/metadatamanagement/server/OCFMetadataServicesInstance.java @@ -15,7 +15,7 @@ /** - * ConnectedAssetServicesInstance caches references to OMRS objects for a specific server. + * OCFMetadataServicesInstance caches references to OMRS objects for a specific server. * It is also responsible for registering itself in the instance map. */ public class OCFMetadataServicesInstance extends OMASServiceInstance @@ -27,7 +27,7 @@ public class OCFMetadataServicesInstance extends OMASServiceInstance private ConnectorTypeHandler connectorTypeHandler; private EndpointHandler endpointHandler; private ExternalIdentifierHandler externalIdentifierHandler; - private ExternalReferenceHandler externalReferenceHandler; + private ExternalReferenceLinkHandler externalReferenceHandler; private GlossaryTermHandler glossaryTermHandler; private InformalTagHandler informalTagHandler; private LicenseHandler licenseHandler; @@ -171,19 +171,19 @@ public OCFMetadataServicesInstance(OMRSRepositoryConnector repositoryConnector, publishZones, auditLog); - this.externalReferenceHandler = new ExternalReferenceHandler<>(new ExternalReferenceConverter<>(repositoryHelper, serviceName, serverName), - ExternalReference.class, - serviceName, - serverName, - invalidParameterHandler, - repositoryHandler, - repositoryHelper, - localServerUserId, - securityVerifier, - supportedZones, - defaultZones, - publishZones, - auditLog); + this.externalReferenceHandler = new ExternalReferenceLinkHandler<>(new ExternalReferenceConverter<>(repositoryHelper, serviceName, serverName), + ExternalReference.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); this.glossaryTermHandler = new GlossaryTermHandler<>(new MeaningConverter<>(repositoryHelper, serviceName, serverName), Meaning.class, @@ -511,7 +511,7 @@ ExternalIdentifierHandler getExternalIdentifierHandl * @return handler object * @throws PropertyServerException the instance has not been initialized successfully */ - ExternalReferenceHandler getExternalReferenceHandler() throws PropertyServerException + ExternalReferenceLinkHandler getExternalReferenceHandler() throws PropertyServerException { final String methodName = "getExternalReferenceHandler"; From 70581ba24534e17c1995eb1331747781706e18d4 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Tue, 29 Mar 2022 22:58:24 +0100 Subject: [PATCH 03/16] Updae urls in swagger Signed-off-by: Mandy Chessell --- .../adminservices/spring/OperationalServicesResource.java | 2 +- .../adminservices/spring/ServerOriginResource.java | 2 +- .../serverchassis/springboot/OMAGServerPlatform.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/OperationalServicesResource.java b/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/OperationalServicesResource.java index f238dda7518..9f82783dc0c 100644 --- a/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/OperationalServicesResource.java +++ b/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/OperationalServicesResource.java @@ -25,7 +25,7 @@ description="The operational administration services support the management " + "of OMAG Server instances. This includes starting and stopping the servers as well as querying and changing their operational state.", externalDocs=@ExternalDocumentation(description="Further information", - url="https://egeria-project.org/guides/operations/guide/#operating-an-omag-server")) + url="https://egeria-project.org/guides/operations/overview/")) public class OperationalServicesResource diff --git a/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/ServerOriginResource.java b/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/ServerOriginResource.java index a687d36c4fc..63f6a6db2c7 100644 --- a/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/ServerOriginResource.java +++ b/open-metadata-implementation/admin-services/admin-services-spring/src/main/java/org/odpi/openmetadata/adminservices/spring/ServerOriginResource.java @@ -22,7 +22,7 @@ description="The operational administration services support the management " + "of OMAG Server instances. This includes starting and stopping the servers as well as querying and changing their operational state.", externalDocs=@ExternalDocumentation(description="Further information", - url="https://egeria-project.org/guides/operations/operating-omag-server/")) + url="https://egeria-project.org/guides/operations/overview/")) public class ServerOriginResource { diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java index e008fa9484f..2afa4d7e16b 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java @@ -57,13 +57,13 @@ "\n" + "NOTE: many REST APIS are not guaranteed to be backward-compatible from release to release since they have supported Java clients. " + "REST APIs may be used for development, testing, evaluation. Click on the documentation for each module to discover more ...", - license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"), - contact = @Contact(url = "https://odpi.github.io/egeria-docs", name = "Egeria Project", + license = @License(name = "Apache 2.0 License", url = "https://www.apache.org/licenses/LICENSE-2.0"), + contact = @Contact(url = "https://egeria-project.org", name = "Egeria Project", email = "egeria-technical-discuss@lists.lfaidata.foundation") ), externalDocs = @ExternalDocumentation(description = "OMAG Server Platform documentation", - url="https://egeria-project.org/guides/admin/") + url="https://egeria-project.org/concepts/omag-server-platform/") ) From f28b7b37af2eb96aa017f47814d7386224c9232e Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Tue, 29 Mar 2022 22:58:52 +0100 Subject: [PATCH 04/16] Add support for external references Signed-off-by: Mandy Chessell --- .../ExternalReferenceExchangeService.java | 162 ++++++++++++++---- 1 file changed, 127 insertions(+), 35 deletions(-) diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ExternalReferenceExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ExternalReferenceExchangeService.java index ff1651d06b5..95ce7199401 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ExternalReferenceExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ExternalReferenceExchangeService.java @@ -16,6 +16,7 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.integrationservices.catalog.ffdc.CatalogIntegratorErrorCode; +import java.util.Date; import java.util.List; import java.util.Map; @@ -224,21 +225,58 @@ public void deleteExternalReference(String externalReferenceGUID, * @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. * + * @return Unique identifier for new relationship + * * @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. */ - public void linkExternalReferenceToElement(String attachedToGUID, - String externalReferenceGUID, - ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public String linkExternalReferenceToElement(String attachedToGUID, + String externalReferenceGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { final String methodName = "linkExternalReferenceToElement"; if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - externalReferenceClient.linkExternalReferenceToElement(userId, assetManagerGUID, assetManagerName, attachedToGUID, externalReferenceGUID, linkProperties); + return externalReferenceClient.linkExternalReferenceToElement(userId, assetManagerGUID, assetManagerName, assetManagerIsHome, attachedToGUID, externalReferenceGUID, linkProperties); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + + /** + * Update the link between an external reference to an object. + * + * @param linkProperties description for the reference from the perspective of the object that the reference is being attached to. + * @param externalReferenceLinkGUID 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. + */ + public void updateExternalReferenceToElementLink(String externalReferenceLinkGUID, + ExternalReferenceLinkProperties linkProperties) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "linkExternalReferenceToElement"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + externalReferenceClient.updateExternalReferenceToElementLink(userId, assetManagerGUID, assetManagerName, externalReferenceLinkGUID, linkProperties); } else { @@ -256,23 +294,21 @@ public void linkExternalReferenceToElement(String attac /** * Remove the link between a external reference and an element. If the element is its anchor, the external reference is removed. * - * @param attachedToGUID object linked to external references. - * @param externalReferenceGUID identifier of the external reference. + * @param externalReferenceLinkGUID identifier of the external reference relationship. * * @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. */ - public void unlinkExternalReferenceFromElement(String attachedToGUID, - String externalReferenceGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public void unlinkExternalReferenceFromElement(String externalReferenceLinkGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { final String methodName = "unlinkExternalReferenceFromElement"; if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) { - externalReferenceClient.unlinkExternalReferenceFromElement(userId, assetManagerGUID, assetManagerName, attachedToGUID, externalReferenceGUID); + externalReferenceClient.unlinkExternalReferenceFromElement(userId, assetManagerGUID, assetManagerName, externalReferenceLinkGUID); } else { @@ -288,27 +324,25 @@ public void unlinkExternalReferenceFromElement(String attachedToGUID, /** - * Return information about a specific external reference. + * Retrieve the list of external references sorted in open metadata. * - * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller - * @param externalReferenceGUID unique identifier for the external reference + * @param effectiveTime the time that the retrieved elements must be effective for + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. * - * @return properties of the external reference + * @return links to addition information. * - * @throws InvalidParameterException externalReferenceGUID or userId is null - * @throws PropertyServerException problem accessing property server - * @throws UserNotAuthorizedException security access problem + * @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. */ - public ExternalReferenceElement getExternalReferenceByGUID(String userId, - String assetManagerGUID, - String assetManagerName, - String externalReferenceGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + public List getExternalReferences(Date effectiveTime, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { - return externalReferenceClient.getExternalReferenceByGUID(userId, assetManagerGUID, assetManagerName, externalReferenceGUID); + return externalReferenceClient.getExternalReferences(userId, assetManagerGUID, assetManagerName, effectiveTime, startFrom, pageSize); } @@ -316,6 +350,7 @@ public ExternalReferenceElement getExternalReferenceByGUID(String userId, * Retrieve the list of external references for this resourceId. * * @param resourceId unique reference id assigned by the resource owner (supports wildcards). This is the qualified name of the entity + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -326,12 +361,13 @@ public ExternalReferenceElement getExternalReferenceByGUID(String userId, * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. */ public List getExternalReferencesById(String resourceId, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { - return externalReferenceClient.getExternalReferencesById(userId, assetManagerGUID, assetManagerName, resourceId, startFrom, pageSize); + return externalReferenceClient.getExternalReferencesById(userId, assetManagerGUID, assetManagerName, resourceId, effectiveTime, startFrom, pageSize); } @@ -339,6 +375,7 @@ public List getExternalReferencesById(String resourceI * Retrieve the list of external references for this URL. * * @param url URL of the external resource. + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -349,18 +386,46 @@ public List getExternalReferencesById(String resourceI * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. */ public List getExternalReferencesByURL(String url, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { - return externalReferenceClient.getExternalReferencesByURL(userId, assetManagerGUID, assetManagerName, url, startFrom, pageSize); + return externalReferenceClient.getExternalReferencesByURL(userId, assetManagerGUID, assetManagerName, url, effectiveTime, startFrom, pageSize); } + + + /** + * Retrieve the list of external references for this name. + * + * @param name qualifiedName or displayName of the external resource. + * @param effectiveTime the time that the retrieved elements must be effective for + * @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. + */ + public List getExternalReferencesByName(String name, + Date effectiveTime, + int startFrom, + int pageSize) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + return externalReferenceClient.getExternalReferencesByName(userId, assetManagerGUID, assetManagerName, name, effectiveTime, startFrom, pageSize); + } + /** * Retrieve the list of external reference created on behalf of the named asset manager. * + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom paging start point * @param pageSize maximum results that can be returned * @@ -370,12 +435,13 @@ public List getExternalReferencesByURL(String url, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public List getExternalReferencesForAssetManager(int startFrom, + public List getExternalReferencesForAssetManager(Date effectiveTime, + int startFrom, int pageSize) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - return externalReferenceClient.getExternalReferencesForAssetManager(userId, assetManagerGUID, assetManagerName, startFrom, pageSize); + return externalReferenceClient.getExternalReferencesForAssetManager(userId, assetManagerGUID, assetManagerName, effectiveTime, startFrom, pageSize); } @@ -383,6 +449,7 @@ public List getExternalReferencesForAssetManager(int * Find the external references that contain the search string - which may contain wildcards. * * @param searchString regular expression (RegEx) to search for + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -393,12 +460,13 @@ public List getExternalReferencesForAssetManager(int * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. */ public List findExternalReferences(String searchString, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { - return externalReferenceClient.findExternalReferences(userId, assetManagerGUID, assetManagerName, searchString, startFrom, pageSize); + return externalReferenceClient.findExternalReferences(userId, assetManagerGUID, assetManagerName, searchString, effectiveTime, startFrom, pageSize); } @@ -406,6 +474,7 @@ public List findExternalReferences(String searchString * Retrieve the list of external references attached to the supplied object. * * @param attachedToGUID object linked to external reference. + * @param effectiveTime the time that the retrieved elements must be effective for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. * @@ -416,11 +485,34 @@ public List findExternalReferences(String searchString * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. */ public List retrieveAttachedExternalReferences(String attachedToGUID, + Date effectiveTime, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { - return externalReferenceClient.retrieveAttachedExternalReferences(userId, assetManagerGUID, assetManagerName, attachedToGUID, startFrom, pageSize); + return externalReferenceClient.retrieveAttachedExternalReferences(userId, assetManagerGUID, assetManagerName, attachedToGUID, effectiveTime, startFrom, pageSize); } + + + /** + * Return information about a specific external reference. + * + * @param effectiveTime the time that the retrieved elements must be effective for + * @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 + */ + public ExternalReferenceElement getExternalReferenceByGUID(Date effectiveTime, + String externalReferenceGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return externalReferenceClient.getExternalReferenceByGUID(userId, assetManagerGUID, assetManagerName, externalReferenceGUID, effectiveTime); + } + } From e1c160c9ab93bf495ab386f4d529f20bf7f8b423 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Tue, 29 Mar 2022 22:59:40 +0100 Subject: [PATCH 05/16] Minor formatting fixes Signed-off-by: Mandy Chessell --- .../docs/design/access-services-design-guidelines.md | 2 +- .../properties/ConfigurationItemRelationshipProperties.java | 1 + .../commonservices/ffdc/rest/RegisteredOMAGService.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/open-metadata-implementation/access-services/docs/design/access-services-design-guidelines.md b/open-metadata-implementation/access-services/docs/design/access-services-design-guidelines.md index f610435dbbf..cf55fc09df4 100644 --- a/open-metadata-implementation/access-services/docs/design/access-services-design-guidelines.md +++ b/open-metadata-implementation/access-services/docs/design/access-services-design-guidelines.md @@ -73,7 +73,7 @@ implementing the OMAS one scenario at a time. * Define who the intended consumer(s) of the OMAS is/are, the types of information they need from the metadata repository and the tasks they need to perform on that metadata. Ideally pick one or two appropriate persona - from [Coco Pharmaceuticals](https://odpi.github.io/data-governance/coco-pharmaceuticals/personas/) to help + from [Coco Pharmaceuticals](https://egeria-project.org/practices/coco-pharmaceuticals/personas/overview/) to help clarify who the consumer is if it is a person. Use the vocabulary that is familiar to the consumer community in your description, rather than the vocabulary used in the diff --git a/open-metadata-implementation/access-services/it-infrastructure/it-infrastructure-api/src/main/java/org/odpi/openmetadata/accessservices/itinfrastructure/properties/ConfigurationItemRelationshipProperties.java b/open-metadata-implementation/access-services/it-infrastructure/it-infrastructure-api/src/main/java/org/odpi/openmetadata/accessservices/itinfrastructure/properties/ConfigurationItemRelationshipProperties.java index 57c54164086..42adc01ca2a 100644 --- a/open-metadata-implementation/access-services/it-infrastructure/it-infrastructure-api/src/main/java/org/odpi/openmetadata/accessservices/itinfrastructure/properties/ConfigurationItemRelationshipProperties.java +++ b/open-metadata-implementation/access-services/it-infrastructure/it-infrastructure-api/src/main/java/org/odpi/openmetadata/accessservices/itinfrastructure/properties/ConfigurationItemRelationshipProperties.java @@ -29,6 +29,7 @@ { @JsonSubTypes.Type(value = ServerAssetUseProperties.class, name = "ServerAssetUseProperties"), @JsonSubTypes.Type(value = CapabilityDeploymentProperties.class, name = "CapabilityDeploymentProperties"), + @JsonSubTypes.Type(value = DeploymentProperties.class, name = "DeploymentProperties"), @JsonSubTypes.Type(value = ControlFlowProperties.class, name = "ControlFlowProperties"), @JsonSubTypes.Type(value = DataFlowProperties.class, name = "DataFlowProperties"), @JsonSubTypes.Type(value = ProcessCallProperties.class, name = "ProcessCallProperties"), diff --git a/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/RegisteredOMAGService.java b/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/RegisteredOMAGService.java index 6cc4c1d302a..a6b06f87923 100644 --- a/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/RegisteredOMAGService.java +++ b/open-metadata-implementation/common-services/ffdc-services/src/main/java/org/odpi/openmetadata/commonservices/ffdc/rest/RegisteredOMAGService.java @@ -25,7 +25,7 @@ public class RegisteredOMAGService implements Serializable { private static final long serialVersionUID = 1L; - private int serviceId = 0; + private int serviceId = 0; private String serviceName = null; private ComponentDevelopmentStatus serviceDevelopmentStatus = null; private String serviceURLMarker = null; From 5fa09fa4bcc57cd90b6fa8cdcafbdfc40ec3f28c Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 16:58:37 +0100 Subject: [PATCH 06/16] Consolidate governance action contexts Signed-off-by: Mandy Chessell --- .../ffdc/GovernanceActionAuditCode.java | 7 + .../GovernanceActionServiceHandler.java | 146 +- .../server/GovernanceActionRESTServices.java | 4 +- .../GovernanceActionContext.java | 1502 +++++++++++++++++ .../GovernanceActionService.java | 112 +- .../GovernanceActionServiceConnector.java | 143 ++ .../governanceaction/GovernanceContext.java | 194 +-- .../ProvisioningGovernanceActionService.java | 4 +- .../ProvisioningGovernanceContext.java | 271 +-- .../RemediationGovernanceActionService.java | 4 +- .../RemediationGovernanceContext.java | 392 ++--- .../TriageGovernanceActionService.java | 4 +- .../TriageGovernanceContext.java | 167 +- .../VerificationGovernanceActionService.java | 5 +- .../VerificationGovernanceContext.java | 29 +- .../WatchdogGovernanceActionService.java | 8 +- .../WatchdogGovernanceContext.java | 120 +- .../ffdc/EngineHostServicesAuditCode.java | 27 +- .../admin/GovernanceServiceHandler.java | 85 +- 19 files changed, 2084 insertions(+), 1140 deletions(-) create mode 100644 open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java create mode 100644 open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionServiceConnector.java diff --git a/open-metadata-implementation/engine-services/governance-action/governance-action-api/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/ffdc/GovernanceActionAuditCode.java b/open-metadata-implementation/engine-services/governance-action/governance-action-api/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/ffdc/GovernanceActionAuditCode.java index 0ba3aa062d3..6e93f30c72c 100644 --- a/open-metadata-implementation/engine-services/governance-action/governance-action-api/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/ffdc/GovernanceActionAuditCode.java +++ b/open-metadata-implementation/engine-services/governance-action/governance-action-api/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/ffdc/GovernanceActionAuditCode.java @@ -184,6 +184,13 @@ public enum GovernanceActionAuditCode implements AuditLogMessageSet "Its class is {2} rather than a subclass of {3}", "The governance action request is not run and an error is returned to the caller. Subsequent calls to this service will fail in the same way", "Correct the configuration for the Governance Action OMES to only include valid governance action service implementations."), + + GOVERNANCE_ACTION_INITIALIZED("OMES-GOVERNANCE-ACTION-0032", + OMRSAuditLogRecordSeverity.STARTUP, + "{0} governance service {1} with request type {2} has initialized in governance engine {3}", + "The governance engine is starting a governance action request.", + "Validate that the governance action ran to successful completion."), + ; diff --git a/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/handlers/GovernanceActionServiceHandler.java b/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/handlers/GovernanceActionServiceHandler.java index 14966b2df51..a4fcb21e7ff 100644 --- a/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/handlers/GovernanceActionServiceHandler.java +++ b/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/handlers/GovernanceActionServiceHandler.java @@ -26,9 +26,9 @@ */ public class GovernanceActionServiceHandler extends GovernanceServiceHandler { - private GovernanceActionService governanceActionService; - private String governanceActionServiceType; - private GovernanceContext governanceContext; + private GovernanceActionServiceConnector governanceActionService; + private String governanceActionServiceType; + private GovernanceContext governanceContext; /** @@ -87,6 +87,7 @@ public class GovernanceActionServiceHandler extends GovernanceServiceHandler final String actionDescription = "Initializing GovernanceActionService"; final String governanceActionServiceConnectorParameterName = "governanceActionServiceConnector"; + final String genericGovernanceActionServiceType = "GovernanceActionService"; final String watchdogGovernanceActionServiceType = "WatchdogGovernanceActionService"; final String provisioningGovernanceActionServiceType = "ProvisioningGovernanceActionService"; final String verificationGovernanceActionServiceType = "VerificationGovernanceActionService"; @@ -102,49 +103,9 @@ public class GovernanceActionServiceHandler extends GovernanceServiceHandler this, governanceActionUserId); - if (governanceActionServiceConnector instanceof WatchdogGovernanceActionService) + if (governanceActionServiceConnector instanceof GovernanceActionServiceConnector) { - WatchdogGovernanceContext context = new WatchdogGovernanceContext(governanceActionUserId, - governanceActionGUID, - requestType, - requestParameters, - requestSourceElements, - actionTargetElements, - openMetadataClient); - - WatchdogGovernanceActionService service = (WatchdogGovernanceActionService)governanceActionServiceConnector; - - service.setGovernanceContext(context); - service.setAuditLog(auditLog); - service.setGovernanceServiceName(governanceServiceName); - - this.governanceContext = context; - this.governanceActionService = service; - this.governanceActionServiceType = watchdogGovernanceActionServiceType; - } - else if (governanceActionServiceConnector instanceof VerificationGovernanceActionService) - { - VerificationGovernanceContext context = new VerificationGovernanceContext(governanceActionUserId, - governanceActionGUID, - requestType, - requestParameters, - requestSourceElements, - actionTargetElements, - openMetadataClient); - - VerificationGovernanceActionService service = (VerificationGovernanceActionService)governanceActionServiceConnector; - - service.setGovernanceContext(context); - service.setAuditLog(auditLog); - service.setGovernanceServiceName(governanceServiceName); - - this.governanceContext = context; - this.governanceActionService = service; - this.governanceActionServiceType = verificationGovernanceActionServiceType; - } - else if (governanceActionServiceConnector instanceof TriageGovernanceActionService) - { - TriageGovernanceContext context = new TriageGovernanceContext(governanceActionUserId, + GovernanceActionContext context = new GovernanceActionContext(governanceActionUserId, governanceActionGUID, requestType, requestParameters, @@ -152,7 +113,7 @@ else if (governanceActionServiceConnector instanceof TriageGovernanceActionServi actionTargetElements, openMetadataClient); - TriageGovernanceActionService service = (TriageGovernanceActionService)governanceActionServiceConnector; + GovernanceActionServiceConnector service = (GovernanceActionServiceConnector) governanceActionServiceConnector; service.setGovernanceContext(context); service.setAuditLog(auditLog); @@ -160,60 +121,51 @@ else if (governanceActionServiceConnector instanceof TriageGovernanceActionServi this.governanceContext = context; this.governanceActionService = service; - this.governanceActionServiceType = triageGovernanceActionServiceType; - } - else if (governanceActionServiceConnector instanceof RemediationGovernanceActionService) - { - RemediationGovernanceContext context = new RemediationGovernanceContext(governanceActionUserId, - governanceActionGUID, - requestType, - requestParameters, - requestSourceElements, - actionTargetElements, - openMetadataClient); - RemediationGovernanceActionService service = (RemediationGovernanceActionService)governanceActionServiceConnector; - - service.setGovernanceContext(context); - service.setAuditLog(auditLog); - service.setGovernanceServiceName(governanceServiceName); - - this.governanceContext = context; - this.governanceActionService = service; - this.governanceActionServiceType = remediationGovernanceActionServiceType; - } - else if (governanceActionServiceConnector instanceof ProvisioningGovernanceActionService) - { - ProvisioningGovernanceContext context = new ProvisioningGovernanceContext(governanceActionUserId, - governanceActionGUID, - requestType, - requestParameters, - requestSourceElements, - actionTargetElements, - openMetadataClient); - - ProvisioningGovernanceActionService service = (ProvisioningGovernanceActionService)governanceActionServiceConnector; - - service.setGovernanceContext(context); - service.setAuditLog(auditLog); - service.setGovernanceServiceName(governanceServiceName); + if (governanceActionServiceConnector instanceof GovernanceActionService) + { + this.governanceActionServiceType = genericGovernanceActionServiceType; + } + else if (governanceActionServiceConnector instanceof WatchdogGovernanceActionService) + { + this.governanceActionServiceType = watchdogGovernanceActionServiceType; + } + else if (governanceActionServiceConnector instanceof VerificationGovernanceActionService) + { + this.governanceActionServiceType = verificationGovernanceActionServiceType; + } + else if (governanceActionServiceConnector instanceof TriageGovernanceActionService) + { + this.governanceActionServiceType = triageGovernanceActionServiceType; + } + else if (governanceActionServiceConnector instanceof RemediationGovernanceActionService) + { + this.governanceActionServiceType = remediationGovernanceActionServiceType; + } + else if (governanceActionServiceConnector instanceof ProvisioningGovernanceActionService) + { + this.governanceActionServiceType = provisioningGovernanceActionServiceType; + } + else + { + auditLog.logMessage(actionDescription, + GovernanceActionAuditCode.UNKNOWN_GOVERNANCE_ACTION_SERVICE.getMessageDefinition(governanceActionServiceName, + requestType, + governanceActionServiceConnector.getClass().getName())); + throw new InvalidParameterException( + GovernanceActionErrorCode.UNKNOWN_GOVERNANCE_ACTION_SERVICE.getMessageDefinition(governanceActionServiceName, + requestType, + governanceActionServiceConnector.getClass().getName()), + this.getClass().getName(), + actionDescription, + governanceActionServiceConnectorParameterName); + } - this.governanceContext = context; - this.governanceActionService = service; - this.governanceActionServiceType = provisioningGovernanceActionServiceType; - } - else if (governanceActionServiceConnector instanceof GovernanceActionService) - { auditLog.logMessage(actionDescription, - GovernanceActionAuditCode.UNKNOWN_GOVERNANCE_ACTION_SERVICE.getMessageDefinition(governanceActionServiceName, - requestType, - governanceActionServiceConnector.getClass().getName())); - throw new InvalidParameterException(GovernanceActionErrorCode.UNKNOWN_GOVERNANCE_ACTION_SERVICE.getMessageDefinition(governanceActionServiceName, - requestType, - governanceActionServiceConnector.getClass().getName()), - this.getClass().getName(), - actionDescription, - governanceActionServiceConnectorParameterName); + GovernanceActionAuditCode.GOVERNANCE_ACTION_INITIALIZED.getMessageDefinition(governanceActionServiceName, + requestType, + governanceActionServiceConnector.getClass().getName(), + getGovernanceEngineName())); } else { diff --git a/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/server/GovernanceActionRESTServices.java b/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/server/GovernanceActionRESTServices.java index c88bbe0e868..5085b839e61 100644 --- a/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/server/GovernanceActionRESTServices.java +++ b/open-metadata-implementation/engine-services/governance-action/governance-action-server/src/main/java/org/odpi/openmetadata/engineservices/governanceaction/server/GovernanceActionRESTServices.java @@ -10,7 +10,7 @@ import org.odpi.openmetadata.commonservices.ffdc.rest.ConnectorTypeResponse; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; -import org.odpi.openmetadata.frameworks.governanceaction.GovernanceActionService; +import org.odpi.openmetadata.frameworks.governanceaction.GovernanceActionServiceConnector; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public ConnectorTypeResponse validateConnector(String serverName, auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); ConnectorReport connectorReport = instanceHandler.validateConnector(connectorProviderClassName, - GovernanceActionService.class, + GovernanceActionServiceConnector.class, EngineServiceDescription.GOVERNANCE_ACTION_OMES.getEngineServiceFullName()); if (connectorReport != null) { diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java new file mode 100644 index 00000000000..dbecacee193 --- /dev/null +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionContext.java @@ -0,0 +1,1502 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.frameworks.governanceaction; + +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.governanceaction.events.WatchdogEventType; +import org.odpi.openmetadata.frameworks.governanceaction.ffdc.GAFErrorCode; +import org.odpi.openmetadata.frameworks.governanceaction.properties.ActionTargetElement; +import org.odpi.openmetadata.frameworks.governanceaction.properties.CompletionStatus; +import org.odpi.openmetadata.frameworks.governanceaction.properties.ElementStatus; +import org.odpi.openmetadata.frameworks.governanceaction.properties.GovernanceActionStatus; +import org.odpi.openmetadata.frameworks.governanceaction.properties.IncidentDependency; +import org.odpi.openmetadata.frameworks.governanceaction.properties.IncidentImpactedElement; +import org.odpi.openmetadata.frameworks.governanceaction.properties.NewActionTarget; +import org.odpi.openmetadata.frameworks.governanceaction.properties.OpenMetadataElement; +import org.odpi.openmetadata.frameworks.governanceaction.properties.PortType; +import org.odpi.openmetadata.frameworks.governanceaction.properties.RequestSourceElement; +import org.odpi.openmetadata.frameworks.governanceaction.search.ElementProperties; +import org.odpi.openmetadata.frameworks.governanceaction.search.MatchCriteria; +import org.odpi.openmetadata.frameworks.governanceaction.search.PrimitiveDefCategory; +import org.odpi.openmetadata.frameworks.governanceaction.search.PrimitivePropertyValue; +import org.odpi.openmetadata.frameworks.governanceaction.search.PropertyComparisonOperator; +import org.odpi.openmetadata.frameworks.governanceaction.search.PropertyCondition; +import org.odpi.openmetadata.frameworks.governanceaction.search.PropertyHelper; +import org.odpi.openmetadata.frameworks.governanceaction.search.SearchProperties; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * GovernanceContext provides the governance action service with access to information about + * the governance request along with the open metadata repository interfaces. + * The abstract methods are implemented by the technology that supports the real metadata store. + */ +public class GovernanceActionContext implements GovernanceContext, + ProvisioningGovernanceContext, + RemediationGovernanceContext, + TriageGovernanceContext, + VerificationGovernanceContext, + WatchdogGovernanceContext +{ + private String userId; + + private String requestType; + private Map requestParameters; + + private List requestSourceElements; + private List actionTargetElements; + + + private volatile CompletionStatus completionStatus = null; + + private String governanceActionGUID; + private OpenMetadataClient openMetadataStore; + private PropertyHelper propertyHelper = new PropertyHelper(); + + + /** + * Constructor sets up the key parameters for processing the request to the governance action service. + * + * @param userId calling user + * @param governanceActionGUID unique identifier of the governance action that triggered this governance service + * @param requestType unique identifier of the asset that the annotations should be attached to + * @param requestParameters name-value properties to control the governance action service + * @param requestSourceElements metadata elements associated with the request to the governance action service + * @param actionTargetElements metadata elements that need to be worked on by the governance action service + * @param openMetadataStore client to the metadata store for use by the governance action service + */ + public GovernanceActionContext(String userId, + String governanceActionGUID, + String requestType, + Map requestParameters, + List requestSourceElements, + List actionTargetElements, + OpenMetadataClient openMetadataStore) + { + this.userId = userId; + this.governanceActionGUID = governanceActionGUID; + this.requestType = requestType; + this.requestParameters = requestParameters; + this.requestSourceElements = requestSourceElements; + this.actionTargetElements = actionTargetElements; + this.openMetadataStore = openMetadataStore; + } + + + /** + * Return the unique identifier of the asset being discovered. + * + * @return string guid + */ + @Override + public String getRequestType() + { + return requestType; + } + + + /** + * Return the properties that hold the parameters used to drive the governance action service's processing. + * + * @return property map + */ + @Override + public Map getRequestParameters() + { + return requestParameters; + } + + + /** + * Return the list of metadata elements associated with the request to the governance action service. + * This list will not change during the lifetime of the service. + * + * @return list of request source elements + */ + @Override + public List getRequestSourceElements() + { + return requestSourceElements; + } + + + /** + * Return the list of elements that this governance action service should work on. + * + * @return cached list of action target metadata elements + */ + @Override + public List getActionTargetElements() + { + return actionTargetElements; + } + + + /** + * Return the client to access metadata from the open metadata repositories. This enables the + * governance action service to retrieve more information about the metadata elements linked to the + * request source and action target elements. + * + * @return metadata store client + */ + @Override + public OpenMetadataStore getOpenMetadataStore() + { + return openMetadataStore; + } + + + /** + * Create an incident report to capture the situation detected by this governance action service. + * This incident report will be processed by other governance activities. + * + * @param qualifiedName unique identifier to give this new incident report + * @param domainIdentifier governance domain associated with this action (0=ALL) + * @param background description of the situation + * @param impactedResources details of the resources impacted by this situation + * @param previousIncidents links to previous incident reports covering this situation + * @param incidentClassifiers initial classifiers for the incident report + * @param additionalProperties additional arbitrary properties for the incident reports + * + * @return unique identifier of the resulting incident report + * + * @throws InvalidParameterException null or non-unique qualified name for the incident report + * @throws UserNotAuthorizedException this governance action service is not authorized to create a incident report + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createIncidentReport(String qualifiedName, + int domainIdentifier, + String background, + List impactedResources, + List previousIncidents, + Map incidentClassifiers, + Map additionalProperties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.createIncidentReport(qualifiedName, + domainIdentifier, + background, + impactedResources, + previousIncidents, + incidentClassifiers, + additionalProperties); + } + + + /** + * Update the status of a specific action target. By default, these values are derived from + * the values for the governance action service. However, if the governance action service has to process name + * target elements, then setting the status on each individual target will show the progress of the + * governance action service. + * + * @param actionTargetGUID unique identifier of the governance action service. + * @param status status enum to show its progress + * @param startDate date/time that the governance action service started processing the target + * @param completionDate date/time that the governance process completed processing this target. + * + * @throws InvalidParameterException the action target GUID is not recognized + * @throws UserNotAuthorizedException the governance action service is not authorized to update the action target properties + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public void updateActionTargetStatus(String actionTargetGUID, + GovernanceActionStatus status, + Date startDate, + Date completionDate) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.updateActionTargetStatus(actionTargetGUID, status, startDate, completionDate); + } + + + /** + * Declare that all of the processing for the governance action service is finished and the status of the work. + * + * @param status completion status enum value + * @param outputGuards optional guard strings for triggering subsequent action(s) + * + * @throws InvalidParameterException the completion status is null + * @throws UserNotAuthorizedException the governance action service is not authorized to update the governance + * action service completion status + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public synchronized void recordCompletionStatus(CompletionStatus status, + List outputGuards) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + this.completionStatus = status; + + openMetadataStore.recordCompletionStatus(status, outputGuards, requestParameters, null); + } + + + /** + * Declare that all of the processing for the governance action service is finished and the status of the work. + * + * @param status completion status enum value + * @param outputGuards optional guard strings for triggering subsequent action(s) + * @param newActionTargets list of action target names to GUIDs for the resulting governance action service + * + * @throws InvalidParameterException the completion status is null + * @throws UserNotAuthorizedException the governance action service is not authorized to update the governance + * action service completion status + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public synchronized void recordCompletionStatus(CompletionStatus status, + List outputGuards, + List newActionTargets) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + this.completionStatus = status; + + openMetadataStore.recordCompletionStatus(status, outputGuards, requestParameters, newActionTargets); + } + + + /** + * Declare that all of the processing for the governance action service is finished and the status of the work. + * + * @param status completion status enum value + * @param outputGuards optional guard strings for triggering subsequent action(s) + * @param newRequestParameters additional request parameters. These override/augment any request parameters defined for the next invoked service + * @param newActionTargets list of action target names to GUIDs for the resulting governance action service + * + * @throws InvalidParameterException the completion status is null + * @throws UserNotAuthorizedException the governance action service is not authorized to update the governance + * action service completion status + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public synchronized void recordCompletionStatus(CompletionStatus status, + List outputGuards, + Map newRequestParameters, + List newActionTargets) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + this.completionStatus = status; + + Map combinedRequestParameters = new HashMap<>(); + + if (requestParameters != null) + { + combinedRequestParameters.putAll(requestParameters); + } + + if (newRequestParameters != null) + { + combinedRequestParameters.putAll(newRequestParameters); + } + + openMetadataStore.recordCompletionStatus(status, outputGuards, combinedRequestParameters, newActionTargets); + } + + + /** + * Return any completion status from the governance action service. + * + * @return completion status enum + */ + @Override + public synchronized CompletionStatus getCompletionStatus() + { + return completionStatus; + } + + + /* + * Provisioning methods + */ + + + + /** + * Pack the basic properties into an ElementProperties object. + * + * @param qualifiedName the unique name of the new metadata element + * @param name the technical name of the metadata element + * @param description the description of the metadata element + * @return ElementProperties contain the supplied properties. + * @throws InvalidParameterException null qualifiedName + */ + private ElementProperties packBasicProperties(String qualifiedName, + String name, + String description, + String methodName) throws InvalidParameterException + { + final String qualifiedNamePropertyName = "qualifiedName"; + final String namePropertyName = "name"; + final String descriptionPropertyName = "description"; + + propertyHelper.validateMandatoryName(qualifiedName, qualifiedNamePropertyName, methodName); + + ElementProperties properties = propertyHelper.addStringProperty(null, qualifiedNamePropertyName, qualifiedName); + + if (name != null) + { + properties = propertyHelper.addStringProperty(properties, namePropertyName, name); + } + + if (description != null) + { + properties = propertyHelper.addStringProperty(properties, descriptionPropertyName, description); + } + + return properties; + } + + + /** + * Create an asset such as a data file, database, API or server. This is used if the provisioning + * governance action service has created a new asset as part of the provisioning process. + * This interface includes an optional templateGUID to copy the structure of an existing asset of the same type. + * + * @param assetTypeName the type name of the asset. This is the name of an open metadata type that inherits from "Asset". + * @param qualifiedName the unique name of the new asset + * @param name the technical display name of the asset + * @param description the description of the asset + * + * @return unique identifier of the new asset + * + * @throws InvalidParameterException the type name or qualified name is null or invalid + * @throws UserNotAuthorizedException this governance action service is not authorized to create an asset + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public String createAsset(String assetTypeName, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAsset"; + + ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); + + return openMetadataStore.createMetadataElementInStore(assetTypeName, ElementStatus.ACTIVE, null, null, properties, null); + } + + + /** + * Create an asset such as a data file, database, API or server. This is used if the provisioning + * governance action service has created a new asset as part of the provisioning process. + * This interface includes an optional templateGUID to copy the structure of an existing asset of the same type. + * + * @param templateGUID the unique identifier of the existing asset to copy (this will copy all of the attachments + * such as nested content, schema, connection etc) + * @param qualifiedName the unique name of the new asset + * @param name the technical display name of the asset + * @param description the description of the asset + * + * @return unique identifier of the new asset + * + * @throws InvalidParameterException the type name or qualified name is null or invalid + * @throws UserNotAuthorizedException this governance action service is not authorized to create an asset + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public String createAssetFromTemplate(String templateGUID, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAssetFromTemplate"; + + ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); + + return openMetadataStore.createMetadataElementInStore(null, ElementStatus.ACTIVE, null, null, properties, templateGUID); + } + + + /** + * Create a new process to represent the processing of this governance action process. + * + * @param processTypeName the type name of the process. This is the name of an open metadata type that inherits from "Process". + * @param initialStatus status value of the process + * @param qualifiedName the unique name of the new process + * @param name the technical display name of the process + * @param description the description of the process + * + * @return unique identifier of the new process + * + * @throws InvalidParameterException the type name or qualified name is null or invalid + * @throws UserNotAuthorizedException this governance action service is not authorized to create a process + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public String createProcess(String processTypeName, + ElementStatus initialStatus, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createProcess"; + + ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); + + return openMetadataStore.createMetadataElementInStore(processTypeName, + initialStatus, + null, + null, + properties, + null); + } + + + /** + * Create a new process to represent the processing of this governance action process. + * + * @param templateGUID the unique identifier of the existing process to copy (this will copy all of the attachments such as ports, nested content, + * schema, connection etc) + * @param initialStatus status value of the process + * @param qualifiedName the unique name of the new process + * @param name the technical display name of the process + * @param description the description of the process + * + * @return unique identifier of the new process + * + * @throws InvalidParameterException the type name or qualified name is null or invalid + * @throws UserNotAuthorizedException this governance action service is not authorized to create a process + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public String createProcessFromTemplate(String templateGUID, + ElementStatus initialStatus, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createProcess"; + + ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); + + return openMetadataStore.createMetadataElementInStore(null, + initialStatus, + null, + null, + properties, + templateGUID); + } + + + /** + * Create a process that represents the processing instance of this governance action. + * @param processTypeName the type name of the process. This is the name of an open metadata type that inherits from "Process". + * @param initialStatus status value of the process + * @param qualifiedName the unique name of the new process + * @param name the technical display name of the process + * @param description the description of the process + * @param parentGUID the unique identifier of the existing process to copy (this will copy all of the attachments such as ports, nested content, + * schema, connection etc) + * + * @return unique identifier of the new process + * + * @throws InvalidParameterException the type name or qualified name is null or invalid + * @throws UserNotAuthorizedException this governance action service is not authorized to create a process + * @throws PropertyServerException there is a problem connecting to the metadata store + */ + @Override + public String createChildProcess(String processTypeName, + ElementStatus initialStatus, + String qualifiedName, + String name, + String description, + String parentGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createProcess"; + + ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); + + String processGUID = openMetadataStore.createMetadataElementInStore(processTypeName, + initialStatus, + null, + null, + properties, + null); + + if (processGUID != null) + { + ElementProperties relationshipProperties = propertyHelper.addEnumProperty(null, + "containmentType", + "ProcessContainmentType", + "OWNED"); + + openMetadataStore.createRelatedElementsInStore("ProcessHierarchy", + parentGUID, + processGUID, + false, + false, + null, + null, + relationshipProperties, + new Date()); + } + + return processGUID; + } + + + /** + * Add a port to a process. + * + * @param processGUID unique identifier of the process + * @param qualifiedName unique name for the port + * @param displayName display name for the port + * @param portType type of port (direction of data flow) + * @param templateGUID optional unique identifier of a template port to copy + * + * @return unique identifier of the new port + * + * @throws InvalidParameterException the processGUID or qualified name is null or is invalid + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createPort(String processGUID, + String qualifiedName, + String displayName, + PortType portType, + String templateGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createProcess"; + + final String portTypeName = "PortImplementation"; + final String processPortTypeName = "ProcessPort"; + + final String displayNamePropertyName = "displayName"; + final String portTypePropertyName = "portType"; + final String portTypeTypeName = "PortType"; + + final String processGUIDParameterName = "processGUID"; + + propertyHelper.validateGUID(processGUID, processGUIDParameterName, methodName); + + ElementProperties properties = packBasicProperties(qualifiedName, null, null, methodName); + + if (displayName != null) + { + properties = propertyHelper.addStringProperty(properties, displayNamePropertyName, displayName); + } + + if (portType != null) + { + properties = propertyHelper.addEnumProperty(properties, portTypePropertyName, portTypeTypeName, portType.getOpenTypeSymbolicName()); + } + + String portGUID = openMetadataStore.createMetadataElementInStore(portTypeName, ElementStatus.ACTIVE, null, null, properties, templateGUID); + + openMetadataStore.createRelatedElementsInStore(processPortTypeName, processGUID, portGUID, false, false, null, null, null, new Date()); + + return portGUID; + } + + + /** + * Create a lineage mapping relationship between a source and target element. This could be between two assets, two process ports or + * two schema elements. + * + * @param sourceElementGUID unique identifier of the element that describes the source of the data. + * @param targetElementGUID unique identifier of the element that describes the destination of the data. + * + * @return unique identifier of the relationship + * + * @throws InvalidParameterException one of the GUIDs is null or is invalid + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createLineageMapping(String sourceElementGUID, + String targetElementGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createLineageMapping"; + final String lineageMappingTypeName = "LineageMapping"; + + final String sourceElementGUIDParameterName = "sourceElementGUID"; + final String targetElementGUIDParameterName = "targetElementGUID"; + + propertyHelper.validateGUID(sourceElementGUID, sourceElementGUIDParameterName, methodName); + propertyHelper.validateGUID(targetElementGUID, targetElementGUIDParameterName, methodName); + + return openMetadataStore.createRelatedElementsInStore(lineageMappingTypeName, sourceElementGUID, targetElementGUID, false, false, null, null, null, new Date()); + } + + /* + * Remediation methods + */ + + /** + * Create a new metadata element in the metadata store. The type name comes from the open metadata types. + * The selected type also controls the names and types of the properties that are allowed. + * This metadata element will be given an initial status of ACTIVE which is sufficient for most types of elements. + * + * @param metadataElementTypeName type name of the new metadata element + * @param properties properties of the new metadata element + * @param templateGUID the unique identifier of the existing asset to copy (this will copy all of the attachments such as nested content, schema + * connection etc) + * + * @return unique identifier of the new metadata element + * + * @throws InvalidParameterException the type name, status or one of the properties is invalid + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createMetadataElement(String metadataElementTypeName, + ElementProperties properties, + String templateGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.createMetadataElementInStore(metadataElementTypeName, ElementStatus.ACTIVE, null, null, properties, templateGUID); + } + + + /** + * Create a new metadata element in the metadata store. The type name comes from the open metadata types. + * The selected type also controls the names and types of the properties that are allowed. + * This version of the method allows access to advanced features such as multiple states and + * effectivity dates. + * + * @param metadataElementTypeName type name of the new metadata element + * @param initialStatus initial status of the metadata element + * @param effectiveFrom the date when this element is active - null for active on creation + * @param effectiveTo the date when this element becomes inactive - null for active until deleted + * @param properties properties of the new metadata element + * @param templateGUID the unique identifier of the existing asset to copy (this will copy all of the attachments such as nested content, schema + * connection etc) + * + * @return unique identifier of the new metadata element + * + * @throws InvalidParameterException the type name, status or one of the properties is invalid + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createMetadataElement(String metadataElementTypeName, + ElementStatus initialStatus, + Date effectiveFrom, + Date effectiveTo, + ElementProperties properties, + String templateGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.createMetadataElementInStore(metadataElementTypeName, initialStatus, effectiveFrom, effectiveTo, properties, templateGUID); + } + + + /** + * Update the properties of a specific metadata element. The properties must match the type definition associated with the + * metadata element when it was created. However, it is possible to update a few properties, or replace all of them by + * the value used in the replaceProperties flag. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param replaceProperties flag to indicate whether to completely replace the existing properties with the new properties, or just update + * the individual properties specified on the request. + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param properties new properties for the metadata element + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @throws InvalidParameterException either the unique identifier or the properties are invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void updateMetadataElement(String metadataElementGUID, + boolean replaceProperties, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.updateMetadataElementInStore(metadataElementGUID, + replaceProperties, + forLineage, + forDuplicateProcessing, + properties, + effectiveTime); + } + + + /** + * Update the status of specific metadata element. The new status must match a status value that is defined for the element's type + * assigned when it was created. The effectivity dates control the visibility of the element + * through specific APIs. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param newElementStatus new status value - or null to leave as is + * @param effectiveFrom the date when this element is active - null for active now + * @param effectiveTo the date when this element becomes inactive - null for active until deleted + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @throws InvalidParameterException either the unique identifier or the status are invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void updateMetadataElementStatus(String metadataElementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + ElementStatus newElementStatus, + Date effectiveFrom, + Date effectiveTo, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.updateMetadataElementStatusInStore(metadataElementGUID, + forLineage, + forDuplicateProcessing, + newElementStatus, + effectiveFrom, + effectiveTo, + effectiveTime); + } + + + /** + * Delete a specific metadata element. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query 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) + * + * @throws InvalidParameterException the unique identifier is null or invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to delete this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void deleteMetadataElement(String metadataElementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.deleteMetadataElementInStore(metadataElementGUID, + forLineage, + forDuplicateProcessing, + effectiveTime); + } + + + /** + * Add a new classification to the metadata element. Note that only one classification with the same name can be attached to + * a metadata element. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName name of the classification to add (if the classification is already present then use reclassify) + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param properties properties to store in the new classification. These must conform to the valid properties associated with the + * classification name + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @throws InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void classifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.classifyMetadataElementInStore(metadataElementGUID, + classificationName, + forLineage, + forDuplicateProcessing, + null, + null, + properties, + effectiveTime); + } + + + /** + * Add a new classification to the metadata element. Note that only one classification with the same name can be attached to + * a metadata element. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName name of the classification to add (if the classification is already present then use reclassify) + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param effectiveFrom the date when this classification is active - null for active now + * @param effectiveTo the date when this classification becomes inactive - null for active until deleted + * @param properties properties to store in the new classification. These must conform to the valid properties associated with the + * classification name + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @throws InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void classifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveFrom, + Date effectiveTo, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.classifyMetadataElementInStore(metadataElementGUID, + classificationName, + forLineage, + forDuplicateProcessing, + effectiveFrom, + effectiveTo, + properties, + effectiveTime); + } + + + /** + * Update the properties of a classification that is currently attached to a specific metadata element. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to update + * @param replaceProperties flag to indicate whether to completely replace the existing properties with the new properties, or just update + * the individual properties specified on the request. + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param properties new properties for the classification + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @throws InvalidParameterException the unique identifier or classification name is null or invalid in some way; properties do not match the + * valid properties associated with the classification's type definition + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element/classification + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void reclassifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean replaceProperties, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.reclassifyMetadataElementInStore(metadataElementGUID, + classificationName, + replaceProperties, + forLineage, + forDuplicateProcessing, + properties, + effectiveTime); + } + + + + /** + * Update the effectivity dates of a specific classification attached to a metadata element. + * The effectivity dates control the visibility of the classification through specific APIs. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to update + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param effectiveFrom the date when this element is active - null for active now + * @param effectiveTo the date when this element becomes inactive - null for active until deleted + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @throws InvalidParameterException either the unique identifier or the status are invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void updateClassificationStatus(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveFrom, + Date effectiveTo, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.updateClassificationStatusInStore(metadataElementGUID, + classificationName, + forLineage, + forDuplicateProcessing, + effectiveFrom, + effectiveTo, + effectiveTime); + } + + + /** + * Remove the named classification from a specific metadata element. + * + * @param metadataElementGUID unique identifier of the metadata element to update + * @param classificationName unique name of the classification to remove + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query 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) + * + * @throws InvalidParameterException the unique identifier or classification name is null or invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to remove this classification + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void unclassifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.unclassifyMetadataElementInStore(metadataElementGUID, + classificationName, + forLineage, + forDuplicateProcessing, + effectiveTime); + } + + + /** + * Create a relationship between two metadata elements. It is important to put the right element at each end of the relationship + * according to the type definition since this will affect how the relationship is interpreted. + * + * @param relationshipTypeName name of the type of relationship to create. This will determine the types of metadata elements that can be + * related and the properties that can be associated with this relationship. + * @param metadataElement1GUID unique identifier of the metadata element at end 1 of the relationship + * @param metadataElement2GUID unique identifier of the metadata element at end 2 of the relationship + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param properties the properties of the relationship + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @return unique identifier of the new relationship + * + * @throws InvalidParameterException the unique identifier's of the metadata elements are null or invalid in some way; the properties are + * not valid for this type of relationship + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createRelatedElements(String relationshipTypeName, + String metadataElement1GUID, + String metadataElement2GUID, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.createRelatedElementsInStore(relationshipTypeName, + metadataElement1GUID, + metadataElement2GUID, + forLineage, + forDuplicateProcessing, + null, + null, + properties, + effectiveTime); + } + + + /** + * Create a relationship between two metadata elements. It is important to put the right element at each end of the relationship + * according to the type definition since this will affect how the relationship is interpreted. + * + * @param relationshipTypeName name of the type of relationship to create. This will determine the types of metadata elements that can be + * related and the properties that can be associated with this relationship. + * @param metadataElement1GUID unique identifier of the metadata element at end 1 of the relationship + * @param metadataElement2GUID unique identifier of the metadata element at end 2 of the relationship + * @param forLineage the query is to support lineage retrieval + * @param forDuplicateProcessing the query is for duplicate processing and so must not deduplicate + * @param effectiveFrom the date when this element is active - null for active now + * @param effectiveTo the date when this element becomes inactive - null for active until deleted + * @param properties the properties of the relationship + * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) + * + * @return unique identifier of the new relationship + * + * @throws InvalidParameterException the unique identifier's of the metadata elements are null or invalid in some way; the properties are + * not valid for this type of relationship + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String createRelatedElements(String relationshipTypeName, + String metadataElement1GUID, + String metadataElement2GUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveFrom, + Date effectiveTo, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.createRelatedElementsInStore(relationshipTypeName, + metadataElement1GUID, + metadataElement2GUID, + forLineage, + forDuplicateProcessing, + effectiveFrom, + effectiveTo, + properties, + effectiveTime); + } + + + /** + * Update the properties associated with a relationship. + * + * @param relationshipGUID unique identifier of the relationship to update + * @param replaceProperties flag to indicate whether to completely replace the existing properties with the new properties, or just update + * the individual properties specified on the request. + * @param properties new properties for the classification + * + * @throws InvalidParameterException the unique identifier of the relationship is null or invalid in some way; the properties are + * not valid for this type of relationship + * @throws UserNotAuthorizedException the governance action service is not authorized to update this relationship + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void updateRelatedElements(String relationshipGUID, + boolean replaceProperties, + ElementProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.updateRelatedElementsInStore(relationshipGUID, replaceProperties, properties); + } + + + /** + * Update the effectivity dates of a specific relationship between metadata elements. + * The effectivity dates control the visibility of the classification through specific APIs. + * + * @param relationshipGUID unique identifier of the relationship to update + * @param effectiveFrom the date when this element is active - null for active now + * @param effectiveTo the date when this element becomes inactive - null for active until deleted + * + * @throws InvalidParameterException either the unique identifier or the status are invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to update this element + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void updateRelatedElementsStatus(String relationshipGUID, + Date effectiveFrom, + Date effectiveTo) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.updateRelatedElementsStatusInStore(relationshipGUID, effectiveFrom, effectiveTo); + } + + + /** + * Delete a relationship between two metadata elements. + * + * @param relationshipGUID unique identifier of the relationship to delete + * + * @throws InvalidParameterException the unique identifier of the relationship is null or invalid in some way + * @throws UserNotAuthorizedException the governance action service is not authorized to delete this relationship + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void deleteRelatedElements(String relationshipGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.deleteRelatedElementsInStore(relationshipGUID); + } + + + /** + * Link elements as peer duplicates. Create a simple relationship between two elements. + * If the relationship already exists, the properties are updated. + * + * @param metadataElement1GUID unique identifier of the metadata element at end 1 of the relationship + * @param metadataElement2GUID unique identifier of the metadata element at end 2 of the relationship + * @param statusIdentifier what is the status of this relationship (negative means untrusted, 0 means unverified and positive means trusted) + * @param steward identifier of the steward + * @param stewardTypeName type of element used to identify the steward + * @param stewardPropertyName property name used to identify steward + * @param source source of the duplicate detection processing + * @param notes notes for the steward + * @throws InvalidParameterException the unique identifier's of the metadata elements are null or invalid in some way; the properties are + * not valid for this type of relationship + * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public void linkElementsAsPeerDuplicates(String metadataElement1GUID, + String metadataElement2GUID, + int statusIdentifier, + String steward, + String stewardTypeName, + String stewardPropertyName, + String source, + String notes) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + openMetadataStore.linkElementsAsPeerDuplicates(metadataElement1GUID, + metadataElement2GUID, + statusIdentifier, + steward, + stewardTypeName, + stewardPropertyName, + source, + notes); + } + + + /* + * Triage methods + */ + + /** + * Create a To Do request for someone to work on. + * + * @param toDoQualifiedName unique name for the to do. (Could be the engine name and a guid?) + * @param title short meaningful phrase for the person receiving the request + * @param instructions further details on what to do + * @param priority priority value (based on organization's scale) + * @param dueDate date/time this needs to be completed + * @param assignTo qualified name of the PersonRole element for the recipient + * @return unique identifier of new to do element + * @throws InvalidParameterException either todoQualifiedName or assignedTo are null or not recognized + * @throws UserNotAuthorizedException the governance action service is not authorized to create a to do + * @throws PropertyServerException there is a problem connecting to (or inside) the metadata store + */ + @Override + public String openToDo(String toDoQualifiedName, + String title, + String instructions, + int priority, + Date dueDate, + String assignTo) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "openToDo"; + + final String todoTypeName = "ToDo"; + final String personRoleTypeName = "PersonRole"; + final String actionAssignmentTypeName = "ActionAssignment"; + + final String qualifiedNamePropertyName = "qualifiedName"; + final String titlePropertyName = "name"; + final String instructionsPropertyName = "description"; + final String priorityPropertyName = "priority"; + final String dueDatePropertyName = "dueTime"; + final String statusPropertyName = "status"; + final String statusPropertyTypeName = "ToDoStatus"; + final String openEnumPropertyValue = "Open"; + + final String toDoQualifiedNameParameterName = "toDoQualifiedName"; + final String assignToParameterName = "assignTo"; + + propertyHelper.validateMandatoryName(toDoQualifiedName, toDoQualifiedNameParameterName, methodName); + propertyHelper.validateMandatoryName(assignTo, assignToParameterName, methodName); + + SearchProperties searchProperties = new SearchProperties(); + List conditions = new ArrayList<>(); + PropertyCondition condition = new PropertyCondition(); + PrimitivePropertyValue primitivePropertyValue = new PrimitivePropertyValue(); + + primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); + primitivePropertyValue.setPrimitiveValue(assignTo); + primitivePropertyValue.setTypeName(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getName()); + + condition.setProperty(qualifiedNamePropertyName); + condition.setOperator(PropertyComparisonOperator.EQ); + condition.setValue(primitivePropertyValue); + + conditions.add(condition); + + searchProperties.setConditions(conditions); + searchProperties.setMatchCriteria(MatchCriteria.ALL); + + /* + * Validate that there is a person role to assign the "to do" to + */ + List personRoleMatches = openMetadataStore.findMetadataElements(personRoleTypeName, + null, + searchProperties, + null, + null, + null, + null, + false, + false, + new Date(), + 0, + 0); + + if ((personRoleMatches == null) || personRoleMatches.isEmpty()) + { + throw new InvalidParameterException(GAFErrorCode.UNKNOWN_ELEMENT.getMessageDefinition(toDoQualifiedName, + toDoQualifiedNameParameterName, + methodName), + this.getClass().getName(), + methodName, + toDoQualifiedNameParameterName); + } + else if (personRoleMatches.size() > 1) + { + List matchingGUIDs = new ArrayList<>(); + + for (OpenMetadataElement element : personRoleMatches) + { + if (element != null) + { + matchingGUIDs.add(element.getElementGUID()); + } + } + + throw new InvalidParameterException(GAFErrorCode.DUPLICATE_ELEMENT.getMessageDefinition(toDoQualifiedName, + toDoQualifiedNameParameterName, + methodName, + matchingGUIDs.toString()), + this.getClass().getName(), + methodName, + toDoQualifiedNameParameterName); + } + + OpenMetadataElement personRoleElement = personRoleMatches.get(0); + String personRoleGUID = null; + + if ((personRoleElement != null) && (personRoleElement.getElementGUID() != null)) + { + personRoleGUID = personRoleElement.getElementGUID(); + } + + /* + * Create the to do entity + */ + ElementProperties properties = propertyHelper.addStringProperty(null, qualifiedNamePropertyName, toDoQualifiedName); + + if (title != null) + { + properties = propertyHelper.addStringProperty(properties, titlePropertyName, title); + } + + if (instructions != null) + { + properties = propertyHelper.addStringProperty(properties, instructionsPropertyName, instructionsPropertyName); + } + + if (dueDate != null) + { + properties = propertyHelper.addDateProperty(properties, dueDatePropertyName, dueDate); + } + + properties = propertyHelper.addIntProperty(properties, priorityPropertyName, priority); + properties = propertyHelper.addEnumProperty(properties, statusPropertyName, statusPropertyTypeName, openEnumPropertyValue); + + String todoGUID = openMetadataStore.createMetadataElementInStore(todoTypeName, ElementStatus.ACTIVE, null, null, properties, null); + + /* + * Link the "to do" and the person role + */ + openMetadataStore.createRelatedElementsInStore(actionAssignmentTypeName, personRoleGUID, todoGUID, false, false,null, null, null, new Date()); + + return todoGUID; + } + + + /* + * Verification methods + */ + + + /* + * Watchdog methods + */ + + + + /** + * Register a listener to receive events about changes to metadata elements in the open metadata store. + * There can be only one registered listener. If this method is called more than once, the new parameters + * replace the existing parameters. This means the watchdog governance action service can change the + * listener and the parameters that control the types of events received while it is running. + * + * The types of events passed to the listener are controlled by the combination of the interesting event types and + * the interesting metadata types. That is an event is only passed to the listener if it matches both + * the interesting event types and the interesting metadata types. + * + * If specific instance, interestingEventTypes or interestingMetadataTypes are null, it defaults to "any". + * If the listener parameter is null, no more events are passed to the listener. + * The type name specified in the interestingMetadataTypes refers to the subject of the event - so it is the type of the metadata element + * for metadata element types, the type of the relationship for related elements events and the name of the classification + * for classification events. + * + * @param listener listener object to receive events + * @param interestingEventTypes types of events that should be passed to the listener + * @param interestingMetadataTypes types of elements that are the subject of the interesting event types + * @param specificInstance unique identifier of a specific instance (metadata element or relationship) to watch for + * + * @throws InvalidParameterException one or more of the type names are unrecognized + */ + @Override + public void registerListener(WatchdogGovernanceListener listener, + List interestingEventTypes, + List interestingMetadataTypes, + String specificInstance) throws InvalidParameterException + { + openMetadataStore.registerListener(listener, interestingEventTypes, interestingMetadataTypes, specificInstance); + } + + + /** + * Unregister the listener permanently from the event infrastructure. + */ + @Override + public void disconnectListener() + { + openMetadataStore.disconnectListener(); + } + + + /** + * Create a governance action in the metadata store which will trigger the governance action service + * associated with the supplied request type. The governance action remains to act as a record + * of the actions taken for auditing. + * + * @param qualifiedName unique identifier to give this governance action + * @param domainIdentifier governance domain associated with this action (0=ALL) + * @param displayName display name for this action + * @param description description for this action + * @param requestSourceGUIDs request source elements for the resulting governance action service + * @param actionTargets map of action target names to GUIDs for the resulting governance action service + * @param startTime future start time or null for "as soon as possible". + * @param governanceEngineName name of the governance engine to run the request + * @param requestType request type to identify the governance action service to run + * @param requestParameters properties to pass to the governance action service + * + * @return unique identifier of the governance action + * + * @throws InvalidParameterException null qualified name + * @throws UserNotAuthorizedException this governance action service is not authorized to create a governance action + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String initiateGovernanceAction(String qualifiedName, + int domainIdentifier, + String displayName, + String description, + List requestSourceGUIDs, + List actionTargets, + Date startTime, + String governanceEngineName, + String requestType, + Map requestParameters) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.initiateGovernanceAction(qualifiedName, + domainIdentifier, + displayName, + description, + requestSourceGUIDs, + actionTargets, + startTime, + governanceEngineName, + requestType, + requestParameters); + } + + + /** + * Using the named governance action process as a template, initiate a chain of governance actions. + * + * @param processQualifiedName unique name of the governance action process to use + * @param requestParameters request parameters to pass to the governance actions called in the governance action process + * @param requestSourceGUIDs request source elements for the resulting governance action service + * @param actionTargets map of action target names to GUIDs for the resulting governance action service + * @param startTime future start time or null for "as soon as possible". + * + * @return unique identifier of the first governance action of the process + * + * @throws InvalidParameterException null or unrecognized qualified name of the process + * @throws UserNotAuthorizedException this governance action service is not authorized to create a governance action process + * @throws PropertyServerException there is a problem with the metadata store + */ + @Override + public String initiateGovernanceActionProcess(String processQualifiedName, + Map requestParameters, + List requestSourceGUIDs, + List actionTargets, + Date startTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return openMetadataStore.initiateGovernanceActionProcess(processQualifiedName, requestParameters, requestSourceGUIDs, actionTargets, startTime); + } + + + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "GovernanceContext{" + + "userId='" + userId + '\'' + + ", requestType='" + requestType + '\'' + + ", requestParameters=" + requestParameters + + ", requestSourceElements=" + requestSourceElements + + ", actionTargetElements=" + actionTargetElements + + ", completionStatus=" + completionStatus + + ", openMetadataStore=" + openMetadataStore + + ", propertyHelper=" + propertyHelper + + '}'; + } +} diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionService.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionService.java index 07abff1a6a7..42d1077c3c3 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionService.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionService.java @@ -2,17 +2,9 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.frameworks.governanceaction; -import org.odpi.openmetadata.frameworks.auditlog.AuditLog; -import org.odpi.openmetadata.frameworks.auditlog.AuditLoggingComponent; -import org.odpi.openmetadata.frameworks.auditlog.ComponentDescription; -import org.odpi.openmetadata.frameworks.connectors.Connector; -import org.odpi.openmetadata.frameworks.connectors.ConnectorBase; -import org.odpi.openmetadata.frameworks.connectors.VirtualConnectorExtension; + import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; -import org.odpi.openmetadata.frameworks.governanceaction.ffdc.GAFErrorCode; -import org.odpi.openmetadata.frameworks.governanceaction.ffdc.GovernanceServiceException; -import java.util.List; /** * GovernanceActionService describes the base class for a specific type of connector that is responsible for preforming @@ -30,102 +22,56 @@ * When you build a governance action service, you extend the governance action service class that matches the purpose of your governance action * to ensure your code receives a context with the appropriate interface. */ -public abstract class GovernanceActionService extends ConnectorBase implements AuditLoggingComponent, VirtualConnectorExtension +public abstract class GovernanceActionService extends GovernanceActionServiceConnector { - protected String governanceServiceName = ""; - protected AuditLog auditLog = null; - protected List embeddedConnectors = null; - - /** - * Receive an audit log object that can be used to record audit log messages. The caller has initialized it - * with the correct component description and log destinations. - * - * @param auditLog audit log object - */ - @Override - public void setAuditLog(AuditLog auditLog) - { - this.auditLog = auditLog; - } + protected GovernanceActionContext governanceContext = null; /** - * Return the component description that is used by this connector in the audit log. + * Set up details of the the governance action request and access to the metadata store. + * This method is called before start and should not be null * - * @return id, name, description, wiki page URL. + * @param governanceContext specialist context for this type of governance action. */ - @Override - public ComponentDescription getConnectorComponentDescription() + public synchronized void setGovernanceContext(GovernanceActionContext governanceContext) { - if ((this.auditLog != null) && (this.auditLog.getReport() != null)) - { - return auditLog.getReport().getReportingComponent(); - } - - return null; + this.governanceContext = governanceContext; } /** - * Set up the list of connectors that this virtual connector will use to support its interface. - * The connectors are initialized waiting to start. When start() is called on the - * virtual connector, it needs to pass start() to each of the embedded connectors. Similarly for - * disconnect(). + * Indicates that the governance action service is completely configured and can begin processing. * - * @param embeddedConnectors list of connectors - */ - public void initializeEmbeddedConnectors(List embeddedConnectors) - { - this.embeddedConnectors = embeddedConnectors; - } - - - /** - * Set up the governance action service name. This is used in error messages. + * This is a standard method from the Open Connector Framework (OCF) so + * be sure to call super.start() in your version. * - * @param governanceServiceName name of the service + * @throws ConnectorCheckedException there is a problem within the governance action service. */ - public void setGovernanceServiceName(String governanceServiceName) + @Override + public void start() throws ConnectorCheckedException { - this.governanceServiceName = governanceServiceName; + super.start(); + super.validateContext(governanceContext); } /** - * Provide a common exception for unexpected errors. + * Disconnect is called either because this governance action service called governanceContext.recordCompletionStatus() + * or the administer requested this governance action service stop running or the hosting server is shutting down. * - * @param methodName calling method - * @param error caught exception - * @throws GovernanceServiceException wrapped exception - */ - protected void handleUnexpectedException(String methodName, - Throwable error) throws ConnectorCheckedException - { - throw new GovernanceServiceException(GAFErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(governanceServiceName, - error.getClass().getName(), - methodName, - error.getMessage()), - this.getClass().getName(), - methodName); - } - - - /** - * Verify that the context has been set up in the subclass + * If disconnect completes before the governance action service records + * its completion status then the governance action service is restarted either at the administrator's request + * or the next time the server starts. + * If you do not want this governance action service restarted, be sure to record the completion status in disconnect(). * - * @param governanceContext context from the subclass - * @throws ConnectorCheckedException error to say that the connector (governance action service) is not able to proceed because - * it has not been set up correctly. + * The disconnect() method is a standard method from the Open Connector Framework (OCF). If you need to override this method + * be sure to call super.disconnect() in your version. + * + * @throws ConnectorCheckedException there is a problem within the governance action service. */ - public void validateContext(GovernanceContext governanceContext) throws ConnectorCheckedException + @Override + public void disconnect() throws ConnectorCheckedException { - final String methodName = "start"; - - if (governanceContext == null) - { - throw new GovernanceServiceException(GAFErrorCode.NULL_GOVERNANCE_CONTEXT.getMessageDefinition(governanceServiceName), - this.getClass().getName(), - methodName); - } + super.disconnect(); } } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionServiceConnector.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionServiceConnector.java new file mode 100644 index 00000000000..e89f779d0c2 --- /dev/null +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceActionServiceConnector.java @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: Apache 2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.frameworks.governanceaction; + +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLoggingComponent; +import org.odpi.openmetadata.frameworks.auditlog.ComponentDescription; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ConnectorBase; +import org.odpi.openmetadata.frameworks.connectors.VirtualConnectorExtension; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.frameworks.governanceaction.ffdc.GAFErrorCode; +import org.odpi.openmetadata.frameworks.governanceaction.ffdc.GovernanceServiceException; + +import java.util.List; + +/** + * GovernanceActionServiceConnector describes the base class for a specific type of connector that is responsible for preforming + * specific governance actions on demand. There are five types of governance action service: + * + *
    + *
  • WatchdogGovernanceActionService - monitors for changes to the metadata elements and initiates other governance actions depending on the nature of the change.
  • + *
  • VerificationGovernanceActionService - tests values in the metadata elements to detect errors or to classify the status of the metadata elements.
  • + *
  • TriageGovernanceActionService - manages the choices on how to resolve a situation, often involving a human decision maker.
  • + *
  • RemediationGovernanceActionService - maintains the metadata elements.
  • + *
  • ProvisioningGovernanceActionService - provisions resources in the digital landscape and maintains lineage.
  • + *
+ * + * Each type of governance action service is passed a specialize context that provides it with the metadata methods it needs for its specific role. + * When you build a governance action service, you extend the governance action service class that matches the purpose of your governance action + * to ensure your code receives a context with the appropriate interface. + * + * In addition there is a generic governance action service called GovernanceActionService that combines all of the functions of the + * five specialist types of governance action service. It is used when if is more efficient to combine the functions into one execution. + */ +public abstract class GovernanceActionServiceConnector extends ConnectorBase implements AuditLoggingComponent, VirtualConnectorExtension +{ + protected String governanceServiceName = ""; + protected AuditLog auditLog = null; + protected List embeddedConnectors = null; + + /** + * Receive an audit log object that can be used to record audit log messages. The caller has initialized it + * with the correct component description and log destinations. + * + * @param auditLog audit log object + */ + @Override + public void setAuditLog(AuditLog auditLog) + { + this.auditLog = auditLog; + } + + + /** + * Return the component description that is used by this connector in the audit log. + * + * @return id, name, description, wiki page URL. + */ + @Override + public ComponentDescription getConnectorComponentDescription() + { + if ((this.auditLog != null) && (this.auditLog.getReport() != null)) + { + return auditLog.getReport().getReportingComponent(); + } + + return null; + } + + + /** + * Set up the list of connectors that this virtual connector will use to support its interface. + * The connectors are initialized waiting to start. When start() is called on the + * virtual connector, it needs to pass start() to each of the embedded connectors. Similarly for + * disconnect(). + * + * @param embeddedConnectors list of connectors + */ + public void initializeEmbeddedConnectors(List embeddedConnectors) + { + this.embeddedConnectors = embeddedConnectors; + } + + + /** + * Set up the governance action service name. This is used in error messages. + * + * @param governanceServiceName name of the service + */ + public void setGovernanceServiceName(String governanceServiceName) + { + this.governanceServiceName = governanceServiceName; + } + + + /** + * Provide a common exception for unexpected errors. + * + * @param methodName calling method + * @param error caught exception + * @throws GovernanceServiceException wrapped exception + */ + protected void handleUnexpectedException(String methodName, + Throwable error) throws ConnectorCheckedException + { + throw new GovernanceServiceException(GAFErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(governanceServiceName, + error.getClass().getName(), + methodName, + error.getMessage()), + this.getClass().getName(), + methodName); + } + + + /** + * Set up details of the the governance action request and access to the metadata store. + * This method is called before start and should not be null + * + * @param governanceContext specialist context for this type of governance action. + */ + public abstract void setGovernanceContext(GovernanceActionContext governanceContext); + + + /** + * Verify that the context has been set up in the subclass + * + * @param governanceContext context from the subclass + * @throws ConnectorCheckedException error to say that the connector (governance action service) is not able to proceed because + * it has not been set up correctly. + */ + public void validateContext(GovernanceContext governanceContext) throws ConnectorCheckedException + { + final String methodName = "start"; + + if (governanceContext == null) + { + throw new GovernanceServiceException(GAFErrorCode.NULL_GOVERNANCE_CONTEXT.getMessageDefinition(governanceServiceName), + this.getClass().getName(), + methodName); + } + } +} diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceContext.java index f14d900b814..7d1331f89f0 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/GovernanceContext.java @@ -6,10 +6,8 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.frameworks.governanceaction.properties.*; -import org.odpi.openmetadata.frameworks.governanceaction.search.*; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,61 +17,15 @@ * the governance request along with the open metadata repository interfaces. * The abstract methods are implemented by the technology that supports the real metadata store. */ -public class GovernanceContext +public interface GovernanceContext { - private String userId; - - private String requestType; - private Map requestParameters; - - private List requestSourceElements; - private List actionTargetElements; - - private String governanceActionGUID; - - private volatile CompletionStatus completionStatus = null; - - OpenMetadataClient openMetadataStore; - PropertyHelper propertyHelper = new PropertyHelper(); - - /** - * Constructor sets up the key parameters for processing the request to the governance action service. - * - * @param userId calling user - * @param governanceActionGUID unique identifier of the governance action that triggered this governance service - * @param requestType unique identifier of the asset that the annotations should be attached to - * @param requestParameters name-value properties to control the governance action service - * @param requestSourceElements metadata elements associated with the request to the governance action service - * @param actionTargetElements metadata elements that need to be worked on by the governance action service - * @param openMetadataStore client to the metadata store for use by the governance action service - */ - public GovernanceContext(String userId, - String governanceActionGUID, - String requestType, - Map requestParameters, - List requestSourceElements, - List actionTargetElements, - OpenMetadataClient openMetadataStore) - { - this.userId = userId; - this.governanceActionGUID = governanceActionGUID; - this.requestType = requestType; - this.requestParameters = requestParameters; - this.requestSourceElements = requestSourceElements; - this.actionTargetElements = actionTargetElements; - this.openMetadataStore = openMetadataStore; - } - /** * Return the unique identifier of the asset being discovered. * * @return string guid */ - public String getRequestType() - { - return requestType; - } + String getRequestType(); /** @@ -81,10 +33,7 @@ public String getRequestType() * * @return property map */ - public Map getRequestParameters() - { - return requestParameters; - } + Map getRequestParameters(); /** @@ -93,10 +42,7 @@ public Map getRequestParameters() * * @return list of request source elements */ - public List getRequestSourceElements() - { - return requestSourceElements; - } + List getRequestSourceElements(); /** @@ -104,10 +50,7 @@ public List getRequestSourceElements() * * @return cached list of action target metadata elements */ - public List getActionTargetElements() - { - return actionTargetElements; - } + List getActionTargetElements(); /** @@ -117,10 +60,7 @@ public List getActionTargetElements() * * @return metadata store client */ - public OpenMetadataStore getOpenMetadataStore() - { - return openMetadataStore; - } + OpenMetadataStore getOpenMetadataStore(); /** @@ -141,24 +81,15 @@ public OpenMetadataStore getOpenMetadataStore() * @throws UserNotAuthorizedException this governance action service is not authorized to create a incident report * @throws PropertyServerException there is a problem with the metadata store */ - public String createIncidentReport(String qualifiedName, - int domainIdentifier, - String background, - List impactedResources, - List previousIncidents, - Map incidentClassifiers, - Map additionalProperties) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.createIncidentReport(qualifiedName, - domainIdentifier, - background, - impactedResources, - previousIncidents, - incidentClassifiers, - additionalProperties); - } + String createIncidentReport(String qualifiedName, + int domainIdentifier, + String background, + List impactedResources, + List previousIncidents, + Map incidentClassifiers, + Map additionalProperties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -176,15 +107,12 @@ public String createIncidentReport(String qualifiedName, * @throws UserNotAuthorizedException the governance action service is not authorized to update the action target properties * @throws PropertyServerException there is a problem connecting to the metadata store */ - public void updateActionTargetStatus(String actionTargetGUID, - GovernanceActionStatus status, - Date startDate, - Date completionDate) throws InvalidParameterException, + void updateActionTargetStatus(String actionTargetGUID, + GovernanceActionStatus status, + Date startDate, + Date completionDate) throws InvalidParameterException, UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.updateActionTargetStatus(actionTargetGUID, status, startDate, completionDate); - } + PropertyServerException; /** @@ -198,15 +126,10 @@ public void updateActionTargetStatus(String actionTargetGUID, * action service completion status * @throws PropertyServerException there is a problem connecting to the metadata store */ - public synchronized void recordCompletionStatus(CompletionStatus status, - List outputGuards) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - this.completionStatus = status; - - openMetadataStore.recordCompletionStatus(status, outputGuards, requestParameters, null); - } + void recordCompletionStatus(CompletionStatus status, + List outputGuards) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -221,16 +144,12 @@ public synchronized void recordCompletionStatus(CompletionStatus status, * action service completion status * @throws PropertyServerException there is a problem connecting to the metadata store */ - public synchronized void recordCompletionStatus(CompletionStatus status, - List outputGuards, - List newActionTargets) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - this.completionStatus = status; + void recordCompletionStatus(CompletionStatus status, + List outputGuards, + List newActionTargets) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; - openMetadataStore.recordCompletionStatus(status, outputGuards, requestParameters, newActionTargets); - } /** @@ -246,29 +165,12 @@ public synchronized void recordCompletionStatus(CompletionStatus status, * action service completion status * @throws PropertyServerException there is a problem connecting to the metadata store */ - public synchronized void recordCompletionStatus(CompletionStatus status, - List outputGuards, - Map newRequestParameters, - List newActionTargets) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - this.completionStatus = status; - - Map combinedRequestParameters = new HashMap<>(); - - if (requestParameters != null) - { - combinedRequestParameters.putAll(requestParameters); - } - - if (newRequestParameters != null) - { - combinedRequestParameters.putAll(newRequestParameters); - } - - openMetadataStore.recordCompletionStatus(status, outputGuards, combinedRequestParameters, newActionTargets); - } + void recordCompletionStatus(CompletionStatus status, + List outputGuards, + Map newRequestParameters, + List newActionTargets) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -276,29 +178,5 @@ public synchronized void recordCompletionStatus(CompletionStatus status, * * @return completion status enum */ - public synchronized CompletionStatus getCompletionStatus() - { - return completionStatus; - } - - - /** - * Standard toString method. - * - * @return print out of variables in a JSON-style - */ - @Override - public String toString() - { - return "GovernanceContext{" + - "userId='" + userId + '\'' + - ", requestType='" + requestType + '\'' + - ", requestParameters=" + requestParameters + - ", requestSourceElements=" + requestSourceElements + - ", actionTargetElements=" + actionTargetElements + - ", completionStatus=" + completionStatus + - ", openMetadataStore=" + openMetadataStore + - ", propertyHelper=" + propertyHelper + - '}'; - } + CompletionStatus getCompletionStatus(); } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceActionService.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceActionService.java index 6c94c658e45..5491327d198 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceActionService.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceActionService.java @@ -21,7 +21,7 @@ * Once the provisioning work is complete, and any lineage metadata is created, your start() method should call * governanceContext.recordCompletionStatus() and then return. */ -public abstract class ProvisioningGovernanceActionService extends GovernanceActionService +public abstract class ProvisioningGovernanceActionService extends GovernanceActionServiceConnector { protected ProvisioningGovernanceContext governanceContext = null; @@ -32,7 +32,7 @@ public abstract class ProvisioningGovernanceActionService extends GovernanceActi * * @param governanceContext specialist context for this type of governance action. */ - public synchronized void setGovernanceContext(ProvisioningGovernanceContext governanceContext) + public synchronized void setGovernanceContext(GovernanceActionContext governanceContext) { this.governanceContext = governanceContext; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceContext.java index afe630a5fcf..77c8eb31b39 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/ProvisioningGovernanceContext.java @@ -5,15 +5,9 @@ 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.governanceaction.properties.ActionTargetElement; import org.odpi.openmetadata.frameworks.governanceaction.properties.ElementStatus; import org.odpi.openmetadata.frameworks.governanceaction.properties.PortType; -import org.odpi.openmetadata.frameworks.governanceaction.properties.RequestSourceElement; -import org.odpi.openmetadata.frameworks.governanceaction.search.ElementProperties; -import java.util.Date; -import java.util.List; -import java.util.Map; /** * ProvisioningGovernanceContext provides access to details of the provisioning request along with basic access to the @@ -26,67 +20,8 @@ * if needed. Alternatively, the provisioning service can specify a guard on completion to initiate a remediation service to fill out the * lineage metadata in more detail. */ -public class ProvisioningGovernanceContext extends GovernanceContext +public interface ProvisioningGovernanceContext extends GovernanceContext { - /** - * Constructor sets up the key parameters for processing the request to the governance action service. - * - * @param userId calling user - * @param governanceActionGUID unique identifier of the governance action that triggered this governance service - * @param requestType unique identifier of the asset that the annotations should be attached to - * @param requestParameters name-value properties to control the governance action service - * @param requestSourceElements metadata elements associated with the request to the governance action service - * @param actionTargetElements metadata elements that need to be worked on by the governance action service - * @param openMetadataStore client to the metadata store for use by the governance action service - */ - public ProvisioningGovernanceContext(String userId, - String governanceActionGUID, - String requestType, - Map requestParameters, - List requestSourceElements, - List actionTargetElements, - OpenMetadataClient openMetadataStore) - { - super(userId, governanceActionGUID, requestType, requestParameters, requestSourceElements, actionTargetElements, openMetadataStore); - } - - - /** - * Pack the basic properties into an ElementProperties object. - * - * @param qualifiedName the unique name of the new metadata element - * @param name the technical name of the metadata element - * @param description the description of the metadata element - * @return ElementProperties contain the supplied properties. - * @throws InvalidParameterException null qualifiedName - */ - private ElementProperties packBasicProperties(String qualifiedName, - String name, - String description, - String methodName) throws InvalidParameterException - { - final String qualifiedNamePropertyName = "qualifiedName"; - final String namePropertyName = "name"; - final String descriptionPropertyName = "description"; - - propertyHelper.validateMandatoryName(qualifiedName, qualifiedNamePropertyName, methodName); - - ElementProperties properties = propertyHelper.addStringProperty(null, qualifiedNamePropertyName, qualifiedName); - - if (name != null) - { - properties = propertyHelper.addStringProperty(properties, namePropertyName, name); - } - - if (description != null) - { - properties = propertyHelper.addStringProperty(properties, descriptionPropertyName, description); - } - - return properties; - } - - /** * Create an asset such as a data file, database, API or server. This is used if the provisioning * governance action service has created a new asset as part of the provisioning process. @@ -103,19 +38,12 @@ private ElementProperties packBasicProperties(String qualifiedName, * @throws UserNotAuthorizedException this governance action service is not authorized to create an asset * @throws PropertyServerException there is a problem connecting to the metadata store */ - public String createAsset(String assetTypeName, - String qualifiedName, - String name, - String description) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createAsset"; - - ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); - - return openMetadataStore.createMetadataElementInStore(assetTypeName, ElementStatus.ACTIVE, null, null, properties, null); - } + String createAsset(String assetTypeName, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -135,19 +63,12 @@ public String createAsset(String assetTypeName, * @throws UserNotAuthorizedException this governance action service is not authorized to create an asset * @throws PropertyServerException there is a problem connecting to the metadata store */ - public String createAssetFromTemplate(String templateGUID, - String qualifiedName, - String name, - String description) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createAssetFromTemplate"; - - ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); - - return openMetadataStore.createMetadataElementInStore(null, ElementStatus.ACTIVE, null, null, properties, templateGUID); - } + String createAssetFromTemplate(String templateGUID, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -165,25 +86,13 @@ public String createAssetFromTemplate(String templateGUID, * @throws UserNotAuthorizedException this governance action service is not authorized to create a process * @throws PropertyServerException there is a problem connecting to the metadata store */ - public String createProcess(String processTypeName, - ElementStatus initialStatus, - String qualifiedName, - String name, - String description) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createProcess"; - - ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); - - return openMetadataStore.createMetadataElementInStore(processTypeName, - initialStatus, - null, - null, - properties, - null); - } + String createProcess(String processTypeName, + ElementStatus initialStatus, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -202,25 +111,13 @@ public String createProcess(String processTypeName, * @throws UserNotAuthorizedException this governance action service is not authorized to create a process * @throws PropertyServerException there is a problem connecting to the metadata store */ - public String createProcessFromTemplate(String templateGUID, - ElementStatus initialStatus, - String qualifiedName, - String name, - String description) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createProcess"; - - ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); - - return openMetadataStore.createMetadataElementInStore(null, - initialStatus, - null, - null, - properties, - templateGUID); - } + String createProcessFromTemplate(String templateGUID, + ElementStatus initialStatus, + String qualifiedName, + String name, + String description) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -239,46 +136,14 @@ public String createProcessFromTemplate(String templateGUID, * @throws UserNotAuthorizedException this governance action service is not authorized to create a process * @throws PropertyServerException there is a problem connecting to the metadata store */ - public String createChildProcess(String processTypeName, - ElementStatus initialStatus, - String qualifiedName, - String name, - String description, - String parentGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createProcess"; - - ElementProperties properties = packBasicProperties(qualifiedName, name, description, methodName); - - String processGUID = openMetadataStore.createMetadataElementInStore(processTypeName, - initialStatus, - null, - null, - properties, - null); - - if (processGUID != null) - { - ElementProperties relationshipProperties = propertyHelper.addEnumProperty(null, - "containmentType", - "ProcessContainmentType", - "OWNED"); - - openMetadataStore.createRelatedElementsInStore("ProcessHierarchy", - parentGUID, - processGUID, - false, - false, - null, - null, - relationshipProperties, - new Date()); - } - - return processGUID; - } + String createChildProcess(String processTypeName, + ElementStatus initialStatus, + String qualifiedName, + String name, + String description, + String parentGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -296,45 +161,13 @@ public String createChildProcess(String processTypeName, * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of element * @throws PropertyServerException there is a problem with the metadata store */ - public String createPort(String processGUID, - String qualifiedName, - String displayName, - PortType portType, - String templateGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createProcess"; - - final String portTypeName = "PortImplementation"; - final String processPortTypeName = "ProcessPort"; - - final String displayNamePropertyName = "displayName"; - final String portTypePropertyName = "portType"; - final String portTypeTypeName = "PortType"; - - final String processGUIDParameterName = "processGUID"; - - propertyHelper.validateGUID(processGUID, processGUIDParameterName, methodName); - - ElementProperties properties = packBasicProperties(qualifiedName, null, null, methodName); - - if (displayName != null) - { - properties = propertyHelper.addStringProperty(properties, displayNamePropertyName, displayName); - } - - if (portType != null) - { - properties = propertyHelper.addEnumProperty(properties, portTypePropertyName, portTypeTypeName, portType.getOpenTypeSymbolicName()); - } - - String portGUID = openMetadataStore.createMetadataElementInStore(portTypeName, ElementStatus.ACTIVE, null, null, properties, templateGUID); - - openMetadataStore.createRelatedElementsInStore(processPortTypeName, processGUID, portGUID, false, false, null, null, null, new Date()); - - return portGUID; - } + String createPort(String processGUID, + String qualifiedName, + String displayName, + PortType portType, + String templateGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -350,20 +183,8 @@ public String createPort(String processGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship * @throws PropertyServerException there is a problem with the metadata store */ - public String createLineageMapping(String sourceElementGUID, - String targetElementGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "createLineageMapping"; - final String lineageMappingTypeName = "LineageMapping"; - - final String sourceElementGUIDParameterName = "sourceElementGUID"; - final String targetElementGUIDParameterName = "targetElementGUID"; - - propertyHelper.validateGUID(sourceElementGUID, sourceElementGUIDParameterName, methodName); - propertyHelper.validateGUID(targetElementGUID, targetElementGUIDParameterName, methodName); - - return openMetadataStore.createRelatedElementsInStore(lineageMappingTypeName, sourceElementGUID, targetElementGUID, false, false, null, null, null, new Date()); - } + String createLineageMapping(String sourceElementGUID, + String targetElementGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceActionService.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceActionService.java index f0629714aff..fa8f0a8583b 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceActionService.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceActionService.java @@ -16,7 +16,7 @@ * Once the remediation work is complete, your start() method should call * governanceContext.recordCompletionStatus() and then return. */ -public abstract class RemediationGovernanceActionService extends GovernanceActionService +public abstract class RemediationGovernanceActionService extends GovernanceActionServiceConnector { protected RemediationGovernanceContext governanceContext = null; @@ -27,7 +27,7 @@ public abstract class RemediationGovernanceActionService extends GovernanceActio * * @param governanceContext specialist context for this type of governance action. */ - public synchronized void setGovernanceContext(RemediationGovernanceContext governanceContext) + public synchronized void setGovernanceContext(GovernanceActionContext governanceContext) { this.governanceContext = governanceContext; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceContext.java index 60a9695c4b0..5b48c1ee3f3 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/RemediationGovernanceContext.java @@ -5,14 +5,11 @@ 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.governanceaction.properties.ActionTargetElement; import org.odpi.openmetadata.frameworks.governanceaction.properties.ElementStatus; -import org.odpi.openmetadata.frameworks.governanceaction.properties.RequestSourceElement; import org.odpi.openmetadata.frameworks.governanceaction.search.ElementProperties; import java.util.Date; -import java.util.List; -import java.util.Map; + /** * RemediationGovernanceContext provides access to details of the remediation request along with access to the @@ -25,31 +22,8 @@ * The requestSourceElements could then have the schema annotations created by a discovery service. * These would guide the */ -public class RemediationGovernanceContext extends GovernanceContext +public interface RemediationGovernanceContext extends GovernanceContext { - /** - * Constructor sets up the key parameters for processing the request to the governance action service. - * - * @param userId calling user - * @param governanceActionGUID unique identifier of the governance action that triggered this governance service - * @param requestType unique identifier of the asset that the annotations should be attached to - * @param requestParameters name-value properties to control the governance action service - * @param requestSourceElements metadata elements associated with the request to the governance action service - * @param actionTargetElements metadata elements that need to be worked on by the governance action service - * @param openMetadataStore client to the metadata store for use by the governance action service - */ - public RemediationGovernanceContext(String userId, - String governanceActionGUID, - String requestType, - Map requestParameters, - List requestSourceElements, - List actionTargetElements, - OpenMetadataClient openMetadataStore) - { - super(userId, governanceActionGUID, requestType, requestParameters, requestSourceElements, actionTargetElements, openMetadataStore); - } - - /** * Create a new metadata element in the metadata store. The type name comes from the open metadata types. * The selected type also controls the names and types of the properties that are allowed. @@ -66,14 +40,11 @@ public RemediationGovernanceContext(String userId, * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of element * @throws PropertyServerException there is a problem with the metadata store */ - public String createMetadataElement(String metadataElementTypeName, - ElementProperties properties, - String templateGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.createMetadataElementInStore(metadataElementTypeName, ElementStatus.ACTIVE, null, null, properties, templateGUID); - } + String createMetadataElement(String metadataElementTypeName, + ElementProperties properties, + String templateGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -96,17 +67,14 @@ public String createMetadataElement(String metadataElementTypeName, * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of element * @throws PropertyServerException there is a problem with the metadata store */ - public String createMetadataElement(String metadataElementTypeName, - ElementStatus initialStatus, - Date effectiveFrom, - Date effectiveTo, - ElementProperties properties, - String templateGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.createMetadataElementInStore(metadataElementTypeName, initialStatus, effectiveFrom, effectiveTo, properties, templateGUID); - } + String createMetadataElement(String metadataElementTypeName, + ElementStatus initialStatus, + Date effectiveFrom, + Date effectiveTo, + ElementProperties properties, + String templateGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -126,22 +94,14 @@ public String createMetadataElement(String metadataElementTypeName, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element * @throws PropertyServerException there is a problem with the metadata store */ - public void updateMetadataElement(String metadataElementGUID, - boolean replaceProperties, - boolean forLineage, - boolean forDuplicateProcessing, - ElementProperties properties, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.updateMetadataElementInStore(metadataElementGUID, - replaceProperties, - forLineage, - forDuplicateProcessing, - properties, - effectiveTime); - } + void updateMetadataElement(String metadataElementGUID, + boolean replaceProperties, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -161,24 +121,15 @@ public void updateMetadataElement(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element * @throws PropertyServerException there is a problem with the metadata store */ - public void updateMetadataElementStatus(String metadataElementGUID, - boolean forLineage, - boolean forDuplicateProcessing, - ElementStatus newElementStatus, - Date effectiveFrom, - Date effectiveTo, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.updateMetadataElementStatusInStore(metadataElementGUID, - forLineage, - forDuplicateProcessing, - newElementStatus, - effectiveFrom, - effectiveTo, - effectiveTime); - } + void updateMetadataElementStatus(String metadataElementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + ElementStatus newElementStatus, + Date effectiveFrom, + Date effectiveTo, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -193,18 +144,12 @@ public void updateMetadataElementStatus(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to delete this element * @throws PropertyServerException there is a problem with the metadata store */ - public void deleteMetadataElement(String metadataElementGUID, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.deleteMetadataElementInStore(metadataElementGUID, - forLineage, - forDuplicateProcessing, - effectiveTime); - } + void deleteMetadataElement(String metadataElementGUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -224,24 +169,14 @@ public void deleteMetadataElement(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element * @throws PropertyServerException there is a problem with the metadata store */ - public void classifyMetadataElement(String metadataElementGUID, - String classificationName, - boolean forLineage, - boolean forDuplicateProcessing, - ElementProperties properties, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.classifyMetadataElementInStore(metadataElementGUID, - classificationName, - forLineage, - forDuplicateProcessing, - null, - null, - properties, - effectiveTime); - } + void classifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -263,26 +198,16 @@ public void classifyMetadataElement(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element * @throws PropertyServerException there is a problem with the metadata store */ - public void classifyMetadataElement(String metadataElementGUID, - String classificationName, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveFrom, - Date effectiveTo, - ElementProperties properties, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.classifyMetadataElementInStore(metadataElementGUID, - classificationName, - forLineage, - forDuplicateProcessing, - effectiveFrom, - effectiveTo, - properties, - effectiveTime); - } + void classifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveFrom, + Date effectiveTo, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -302,25 +227,15 @@ public void classifyMetadataElement(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element/classification * @throws PropertyServerException there is a problem with the metadata store */ - public void reclassifyMetadataElement(String metadataElementGUID, - String classificationName, - boolean replaceProperties, - boolean forLineage, - boolean forDuplicateProcessing, - ElementProperties properties, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.reclassifyMetadataElementInStore(metadataElementGUID, - classificationName, - replaceProperties, - forLineage, - forDuplicateProcessing, - properties, - effectiveTime); - } - + void reclassifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean replaceProperties, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -339,24 +254,15 @@ public void reclassifyMetadataElement(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element * @throws PropertyServerException there is a problem with the metadata store */ - public void updateClassificationStatus(String metadataElementGUID, - String classificationName, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveFrom, - Date effectiveTo, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.updateClassificationStatusInStore(metadataElementGUID, - classificationName, - forLineage, - forDuplicateProcessing, - effectiveFrom, - effectiveTo, - effectiveTime); - } + void updateClassificationStatus(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveFrom, + Date effectiveTo, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -372,20 +278,13 @@ public void updateClassificationStatus(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to remove this classification * @throws PropertyServerException there is a problem with the metadata store */ - public void unclassifyMetadataElement(String metadataElementGUID, - String classificationName, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.unclassifyMetadataElementInStore(metadataElementGUID, - classificationName, - forLineage, - forDuplicateProcessing, - effectiveTime); - } + void unclassifyMetadataElement(String metadataElementGUID, + String classificationName, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -408,26 +307,15 @@ public void unclassifyMetadataElement(String metadataElementGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship * @throws PropertyServerException there is a problem with the metadata store */ - public String createRelatedElements(String relationshipTypeName, - String metadataElement1GUID, - String metadataElement2GUID, - boolean forLineage, - boolean forDuplicateProcessing, - ElementProperties properties, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.createRelatedElementsInStore(relationshipTypeName, - metadataElement1GUID, - metadataElement2GUID, - forLineage, - forDuplicateProcessing, - null, - null, - properties, - effectiveTime); - } + String createRelatedElements(String relationshipTypeName, + String metadataElement1GUID, + String metadataElement2GUID, + boolean forLineage, + boolean forDuplicateProcessing, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -452,28 +340,17 @@ public String createRelatedElements(String relationshipTypeName, * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship * @throws PropertyServerException there is a problem with the metadata store */ - public String createRelatedElements(String relationshipTypeName, - String metadataElement1GUID, - String metadataElement2GUID, - boolean forLineage, - boolean forDuplicateProcessing, - Date effectiveFrom, - Date effectiveTo, - ElementProperties properties, - Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.createRelatedElementsInStore(relationshipTypeName, - metadataElement1GUID, - metadataElement2GUID, - forLineage, - forDuplicateProcessing, - effectiveFrom, - effectiveTo, - properties, - effectiveTime); - } + String createRelatedElements(String relationshipTypeName, + String metadataElement1GUID, + String metadataElement2GUID, + boolean forLineage, + boolean forDuplicateProcessing, + Date effectiveFrom, + Date effectiveTo, + ElementProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -489,14 +366,11 @@ public String createRelatedElements(String relationshipTypeName, * @throws UserNotAuthorizedException the governance action service is not authorized to update this relationship * @throws PropertyServerException there is a problem with the metadata store */ - public void updateRelatedElements(String relationshipGUID, - boolean replaceProperties, - ElementProperties properties) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.updateRelatedElementsInStore(relationshipGUID, replaceProperties, properties); - } + void updateRelatedElements(String relationshipGUID, + boolean replaceProperties, + ElementProperties properties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -511,14 +385,11 @@ public void updateRelatedElements(String relationshipGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to update this element * @throws PropertyServerException there is a problem with the metadata store */ - public void updateRelatedElementsStatus(String relationshipGUID, - Date effectiveFrom, - Date effectiveTo) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.updateRelatedElementsStatusInStore(relationshipGUID, effectiveFrom, effectiveTo); - } + void updateRelatedElementsStatus(String relationshipGUID, + Date effectiveFrom, + Date effectiveTo) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -530,12 +401,10 @@ public void updateRelatedElementsStatus(String relationshipGUID, * @throws UserNotAuthorizedException the governance action service is not authorized to delete this relationship * @throws PropertyServerException there is a problem with the metadata store */ - public void deleteRelatedElements(String relationshipGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.deleteRelatedElementsInStore(relationshipGUID); - } + void deleteRelatedElements(String relationshipGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; + /** * Link elements as peer duplicates. Create a simple relationship between two elements. @@ -554,25 +423,14 @@ public void deleteRelatedElements(String relationshipGUID) throws InvalidParamet * @throws UserNotAuthorizedException the governance action service is not authorized to create this type of relationship * @throws PropertyServerException there is a problem with the metadata store */ - public void linkElementsAsPeerDuplicates(String metadataElement1GUID, - String metadataElement2GUID, - int statusIdentifier, - String steward, - String stewardTypeName, - String stewardPropertyName, - String source, - String notes) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - openMetadataStore.linkElementsAsPeerDuplicates(metadataElement1GUID, - metadataElement2GUID, - statusIdentifier, - steward, - stewardTypeName, - stewardPropertyName, - source, - notes); - } - + void linkElementsAsPeerDuplicates(String metadataElement1GUID, + String metadataElement2GUID, + int statusIdentifier, + String steward, + String stewardTypeName, + String stewardPropertyName, + String source, + String notes) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceActionService.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceActionService.java index af2a68a0291..d3f6ee1e606 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceActionService.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceActionService.java @@ -22,7 +22,7 @@ * It is through these guards that either the triage decision is communicated, or another governance action service is initiated to * take the next step. */ -public abstract class TriageGovernanceActionService extends GovernanceActionService +public abstract class TriageGovernanceActionService extends GovernanceActionServiceConnector { protected TriageGovernanceContext governanceContext = null; @@ -33,7 +33,7 @@ public abstract class TriageGovernanceActionService extends GovernanceActionServ * * @param governanceContext specialist context for this type of governance action. */ - public synchronized void setGovernanceContext(TriageGovernanceContext governanceContext) + public synchronized void setGovernanceContext(GovernanceActionContext governanceContext) { this.governanceContext = governanceContext; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceContext.java index f363d2744d2..4e5aaafb04c 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/TriageGovernanceContext.java @@ -26,31 +26,8 @@ * or directly completing the associated governance action with a decision for the completion status and guards that are used to * determine the next step to proceed. */ -public class TriageGovernanceContext extends GovernanceContext +public interface TriageGovernanceContext extends GovernanceContext { - /** - * Constructor sets up the key parameters for processing the request to the governance action service. - * - * @param userId calling user - * @param governanceActionGUID unique identifier of the governance action that triggered this governance service - * @param requestType unique identifier of the asset that the annotations should be attached to - * @param requestParameters name-value properties to control the governance action service - * @param requestSourceElements metadata elements associated with the request to the governance action service - * @param actionTargetElements metadata elements that need to be worked on by the governance action service - * @param openMetadataStore client to the metadata store for use by the governance action service - */ - public TriageGovernanceContext(String userId, - String governanceActionGUID, - String requestType, - Map requestParameters, - List requestSourceElements, - List actionTargetElements, - OpenMetadataClient openMetadataStore) - { - super(userId, governanceActionGUID, requestType, requestParameters, requestSourceElements, actionTargetElements, openMetadataStore); - } - - /** * Create a To Do request for someone to work on. * @@ -65,138 +42,12 @@ public TriageGovernanceContext(String userId, * @throws UserNotAuthorizedException the governance action service is not authorized to create a to do * @throws PropertyServerException there is a problem connecting to (or inside) the metadata store */ - public String openToDo(String toDoQualifiedName, - String title, - String instructions, - int priority, - Date dueDate, - String assignTo) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "openToDo"; - - final String todoTypeName = "ToDo"; - final String personRoleTypeName = "PersonRole"; - final String actionAssignmentTypeName = "ActionAssignment"; - - final String qualifiedNamePropertyName = "qualifiedName"; - final String titlePropertyName = "name"; - final String instructionsPropertyName = "description"; - final String priorityPropertyName = "priority"; - final String dueDatePropertyName = "dueTime"; - final String statusPropertyName = "status"; - final String statusPropertyTypeName = "ToDoStatus"; - final String openEnumPropertyValue = "Open"; - - final String toDoQualifiedNameParameterName = "toDoQualifiedName"; - final String assignToParameterName = "assignTo"; - - propertyHelper.validateMandatoryName(toDoQualifiedName, toDoQualifiedNameParameterName, methodName); - propertyHelper.validateMandatoryName(assignTo, assignToParameterName, methodName); - - SearchProperties searchProperties = new SearchProperties(); - List conditions = new ArrayList<>(); - PropertyCondition condition = new PropertyCondition(); - PrimitivePropertyValue primitivePropertyValue = new PrimitivePropertyValue(); - - primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); - primitivePropertyValue.setPrimitiveValue(assignTo); - primitivePropertyValue.setTypeName(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getName()); - - condition.setProperty(qualifiedNamePropertyName); - condition.setOperator(PropertyComparisonOperator.EQ); - condition.setValue(primitivePropertyValue); - - conditions.add(condition); - - searchProperties.setConditions(conditions); - searchProperties.setMatchCriteria(MatchCriteria.ALL); - - /* - * Validate that there is a person role to assign the "to do" to - */ - List personRoleMatches = openMetadataStore.findMetadataElements(personRoleTypeName, - null, - searchProperties, - null, - null, - null, - null, - false, - false, - new Date(), - 0, - 0); - - if ((personRoleMatches == null) || personRoleMatches.isEmpty()) - { - throw new InvalidParameterException(GAFErrorCode.UNKNOWN_ELEMENT.getMessageDefinition(toDoQualifiedName, - toDoQualifiedNameParameterName, - methodName), - this.getClass().getName(), - methodName, - toDoQualifiedNameParameterName); - } - else if (personRoleMatches.size() > 1) - { - List matchingGUIDs = new ArrayList<>(); - - for (OpenMetadataElement element : personRoleMatches) - { - if (element != null) - { - matchingGUIDs.add(element.getElementGUID()); - } - } - - throw new InvalidParameterException(GAFErrorCode.DUPLICATE_ELEMENT.getMessageDefinition(toDoQualifiedName, - toDoQualifiedNameParameterName, - methodName, - matchingGUIDs.toString()), - this.getClass().getName(), - methodName, - toDoQualifiedNameParameterName); - } - - OpenMetadataElement personRoleElement = personRoleMatches.get(0); - String personRoleGUID = null; - - if ((personRoleElement != null) && (personRoleElement.getElementGUID() != null)) - { - personRoleGUID = personRoleElement.getElementGUID(); - } - - /* - * Create the to do entity - */ - ElementProperties properties = propertyHelper.addStringProperty(null, qualifiedNamePropertyName, toDoQualifiedName); - - if (title != null) - { - properties = propertyHelper.addStringProperty(properties, titlePropertyName, title); - } - - if (instructions != null) - { - properties = propertyHelper.addStringProperty(properties, instructionsPropertyName, instructionsPropertyName); - } - - if (dueDate != null) - { - properties = propertyHelper.addDateProperty(properties, dueDatePropertyName, dueDate); - } - - properties = propertyHelper.addIntProperty(properties, priorityPropertyName, priority); - properties = propertyHelper.addEnumProperty(properties, statusPropertyName, statusPropertyTypeName, openEnumPropertyValue); - - String todoGUID = openMetadataStore.createMetadataElementInStore(todoTypeName, ElementStatus.ACTIVE, null, null, properties, null); - - /* - * Link the "to do" and the person role - */ - openMetadataStore.createRelatedElementsInStore(actionAssignmentTypeName, personRoleGUID, todoGUID, false, false,null, null, null, new Date()); - - return todoGUID; - } + String openToDo(String toDoQualifiedName, + String title, + String instructions, + int priority, + Date dueDate, + String assignTo) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceActionService.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceActionService.java index 404133c6169..76f50c98d66 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceActionService.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceActionService.java @@ -18,18 +18,17 @@ * governanceContext.recordCompletionStatus() and then return. The recordCompletionStatus() call will include guards that are used to determine * the next step. */ -public abstract class VerificationGovernanceActionService extends GovernanceActionService +public abstract class VerificationGovernanceActionService extends GovernanceActionServiceConnector { protected VerificationGovernanceContext governanceContext = null; - /** * Set up details of the the governance action request and access to the metadata store. * This method is called before start and should not be null * * @param governanceContext specialist context for this type of governance action. */ - public synchronized void setGovernanceContext(VerificationGovernanceContext governanceContext) + public synchronized void setGovernanceContext(GovernanceActionContext governanceContext) { this.governanceContext = governanceContext; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceContext.java index a30d50225d5..0a3e5edc82d 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/VerificationGovernanceContext.java @@ -2,11 +2,6 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.frameworks.governanceaction; -import org.odpi.openmetadata.frameworks.governanceaction.properties.ActionTargetElement; -import org.odpi.openmetadata.frameworks.governanceaction.properties.RequestSourceElement; - -import java.util.List; -import java.util.Map; /** * VerificationGovernanceContext provides access to details of the verification request along with access to the @@ -18,27 +13,9 @@ * metadata element, a verification service could check that the schema metadata elements for the Asset * are correct. */ -public class VerificationGovernanceContext extends GovernanceContext +public interface VerificationGovernanceContext extends GovernanceContext { - /** - * Constructor sets up the key parameters for processing the request to the governance action service. - * - * @param userId calling user - * @param governanceActionGUID unique identifier of the governance action that triggered this governance service - * @param requestType unique identifier of the asset that the annotations should be attached to - * @param requestParameters name-value properties to control the governance action service - * @param requestSourceElements metadata elements associated with the request to the governance action service - * @param actionTargetElements metadata elements that need to be worked on by the governance action service - * @param openMetadataStore client to the metadata store for use by the governance action service + /* + * No additional methods needed for verification */ - public VerificationGovernanceContext(String userId, - String governanceActionGUID, - String requestType, - Map requestParameters, - List requestSourceElements, - List actionTargetElements, - OpenMetadataClient openMetadataStore) - { - super(userId, governanceActionGUID, requestType, requestParameters, requestSourceElements, actionTargetElements, openMetadataStore); - } } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceActionService.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceActionService.java index 8da7ab8f744..16e0a898909 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceActionService.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceActionService.java @@ -25,18 +25,18 @@ * governanceContext.recordCompletionStatus() and then return. The recordCompletionStatus() call will include guards that are used to determine * the next step if any. */ -public abstract class WatchdogGovernanceActionService extends GovernanceActionService +public abstract class WatchdogGovernanceActionService extends GovernanceActionServiceConnector { protected WatchdogGovernanceContext governanceContext = null; - + /** * Set up details of the the governance action request and access to the metadata store. - * This method is called before start and should + * This method is called before start and should not be null * * @param governanceContext specialist context for this type of governance action. */ - public synchronized void setGovernanceContext(WatchdogGovernanceContext governanceContext) + public synchronized void setGovernanceContext(GovernanceActionContext governanceContext) { this.governanceContext = governanceContext; } diff --git a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java index c07b31dd7d3..e24e8f96cb5 100644 --- a/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java +++ b/open-metadata-implementation/frameworks/governance-action-framework/src/main/java/org/odpi/openmetadata/frameworks/governanceaction/WatchdogGovernanceContext.java @@ -18,36 +18,8 @@ * the request, open metadata store, the ability to register a listener to receive governance events and initiate * new governance activity. */ -public class WatchdogGovernanceContext extends GovernanceContext +public interface WatchdogGovernanceContext extends GovernanceContext { - private WatchdogGovernanceListener registeredListener = null; - private List interestingEvents = null; - private List interestingTypes = null; - - - /** - * Constructor sets up the key parameters for processing the request to the governance action service. - * - * @param userId calling user - * @param governanceActionGUID unique identifier of the governance action that triggered this governance service - * @param requestType unique identifier of the asset that the annotations should be attached to - * @param requestParameters name-value properties to control the governance action service - * @param requestSourceElements metadata elements associated with the request to the governance action service - * @param actionTargetElements metadata elements that need to be worked on by the governance action service - * @param openMetadataStore client to the metadata store for use by the governance action service - */ - public WatchdogGovernanceContext(String userId, - String governanceActionGUID, - String requestType, - Map requestParameters, - List requestSourceElements, - List actionTargetElements, - OpenMetadataClient openMetadataStore) - { - super(userId, governanceActionGUID, requestType, requestParameters, requestSourceElements, actionTargetElements, openMetadataStore); - } - - /** * Register a listener to receive events about changes to metadata elements in the open metadata store. * There can be only one registered listener. If this method is called more than once, the new parameters @@ -71,22 +43,16 @@ public WatchdogGovernanceContext(String userId, * * @throws InvalidParameterException one or more of the type names are unrecognized */ - public void registerListener(WatchdogGovernanceListener listener, - List interestingEventTypes, - List interestingMetadataTypes, - String specificInstance) throws InvalidParameterException - { - openMetadataStore.registerListener(listener, interestingEventTypes, interestingMetadataTypes, specificInstance); - } + void registerListener(WatchdogGovernanceListener listener, + List interestingEventTypes, + List interestingMetadataTypes, + String specificInstance) throws InvalidParameterException; /** * Unregister the listener permanently from the event infrastructure. */ - void disconnectListener() - { - openMetadataStore.disconnectListener(); - } + void disconnectListener(); /** @@ -111,30 +77,18 @@ void disconnectListener() * @throws UserNotAuthorizedException this governance action service is not authorized to create a governance action * @throws PropertyServerException there is a problem with the metadata store */ - public String initiateGovernanceAction(String qualifiedName, - int domainIdentifier, - String displayName, - String description, - List requestSourceGUIDs, - List actionTargets, - Date startTime, - String governanceEngineName, - String requestType, - Map requestParameters) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.initiateGovernanceAction(qualifiedName, - domainIdentifier, - displayName, - description, - requestSourceGUIDs, - actionTargets, - startTime, - governanceEngineName, - requestType, - requestParameters); - } + String initiateGovernanceAction(String qualifiedName, + int domainIdentifier, + String displayName, + String description, + List requestSourceGUIDs, + List actionTargets, + Date startTime, + String governanceEngineName, + String requestType, + Map requestParameters) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; /** @@ -152,35 +106,11 @@ public String initiateGovernanceAction(String qualifiedName, * @throws UserNotAuthorizedException this governance action service is not authorized to create a governance action process * @throws PropertyServerException there is a problem with the metadata store */ - public String initiateGovernanceActionProcess(String processQualifiedName, - Map requestParameters, - List requestSourceGUIDs, - List actionTargets, - Date startTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - return openMetadataStore.initiateGovernanceActionProcess(processQualifiedName, requestParameters, requestSourceGUIDs, actionTargets, startTime); - } - - - /** - * Standard toString method. - * - * @return print out of variables in a JSON-style - */ - @Override - public String toString() - { - return "WatchdogGovernanceContext{" + - "registeredListener=" + registeredListener + - ", interestingEvents=" + interestingEvents + - ", interestingTypes=" + interestingTypes + - ", requestType='" + getRequestType() + '\'' + - ", requestParameters=" + getRequestParameters() + - ", requestSourceElements=" + getRequestSourceElements() + - ", actionTargetElements=" + getActionTargetElements() + - ", openMetadataStore=" + getOpenMetadataStore() + - '}'; - } + String initiateGovernanceActionProcess(String processQualifiedName, + Map requestParameters, + List requestSourceGUIDs, + List actionTargets, + Date startTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException; } diff --git a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-api/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/ffdc/EngineHostServicesAuditCode.java b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-api/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/ffdc/EngineHostServicesAuditCode.java index 337c6530731..756092cc1b6 100644 --- a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-api/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/ffdc/EngineHostServicesAuditCode.java +++ b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-api/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/ffdc/EngineHostServicesAuditCode.java @@ -290,13 +290,26 @@ public enum EngineHostServicesAuditCode implements AuditLogMessageSet "call to request that the governance engine calls the Governance Engine OMAS to refresh the configuration for " + "the governance service."), - GOVERNANCE_ACTION_FAILED("ENGINE-HOST-SERVICES-0032", - OMRSAuditLogRecordSeverity.ERROR, - "Failed to execute governance action for governance engine {0}. The exception was {1} with error message {2}", - "The governance engine is unable to process the governance action request. The exception explains the " + - "reason. The governance action has been marked as FAILED.", - "Review the error messages and resolve the cause of the problem. Once resolved, it is possible to " + - "retry the governance action by updating its status back to REQUESTED status."), + GOVERNANCE_ACTION_TARGET_COMPLETION("ENGINE-HOST-SERVICES-0032", + OMRSAuditLogRecordSeverity.INFO, + "Governance action {0} running governance service {1} for governance engine {2} with request type {3} has recorded completion on action target {4} with status {5} (start time {6}; completion time {7})", + "The governance action request has completed processing on one of its action targets.", + "Validate that the processing of this action target is correct."), + + GOVERNANCE_ACTION_RECORD_COMPLETION("ENGINE-HOST-SERVICES-0033", + OMRSAuditLogRecordSeverity.SHUTDOWN, + "Governance action {0} running governance service {1} for governance engine {2} with request type {3} has recorded completion status of {4} and output guards of {5}. Next governance action is given request parameters called {6} and action targets of {7}", + "The governance engine is unable to process the governance action request. The exception explains the " + + "reason. The governance action has been marked as FAILED.", + "Validate that the processing of this governance action request is correct."), + + GOVERNANCE_ACTION_FAILED("ENGINE-HOST-SERVICES-0034", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Failed to execute governance action for governance engine {0}. The exception was {1} with error message {2}", + "The governance engine is unable to process the governance action request. The exception explains the " + + "reason. The governance action has been marked as FAILED.", + "Review the error messages and resolve the cause of the problem. Once resolved, it is possible to " + + "retry the governance action by updating its status back to REQUESTED status."), NO_OMAS_SERVER_URL("ENGINE-HOST-SERVICES-0150", OMRSAuditLogRecordSeverity.ERROR, diff --git a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-registration/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/admin/GovernanceServiceHandler.java b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-registration/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/admin/GovernanceServiceHandler.java index cd447d13374..cf339cf77f5 100644 --- a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-registration/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/admin/GovernanceServiceHandler.java +++ b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-registration/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/admin/GovernanceServiceHandler.java @@ -13,6 +13,7 @@ import org.odpi.openmetadata.frameworks.governanceaction.properties.CompletionStatus; import org.odpi.openmetadata.frameworks.governanceaction.properties.GovernanceActionStatus; import org.odpi.openmetadata.frameworks.governanceaction.properties.NewActionTarget; +import org.odpi.openmetadata.governanceservers.enginehostservices.ffdc.EngineHostServicesAuditCode; import java.util.Date; import java.util.List; @@ -133,10 +134,40 @@ public void updateActionTargetStatus(String actionTargetGUID, UserNotAuthorizedException, PropertyServerException { - if (governanceActionGUID != null) + final String methodName = "updateActionTargetStatus"; + + if (auditLog != null) { - governanceActionClient.updateActionTargetStatus(engineHostUserId, actionTargetGUID, status, startDate, completionDate); + String statusString = ""; + String startTime = ""; + String completionTime = ""; + + if (status != null) + { + statusString = status.getName(); + } + + if (startDate != null) + { + startTime = startDate.toString(); + } + + if (completionDate != null) + { + completionTime = completionDate.toString(); + } + + auditLog.logMessage(methodName, EngineHostServicesAuditCode.GOVERNANCE_ACTION_TARGET_COMPLETION.getMessageDefinition(governanceActionGUID, + governanceServiceName, + getGovernanceEngineName(), + requestType, + actionTargetGUID, + statusString, + startTime, + completionTime)); } + + governanceActionClient.updateActionTargetStatus(engineHostUserId, actionTargetGUID, status, startDate, completionDate); } @@ -159,15 +190,51 @@ public void recordCompletionStatus(CompletionStatus status, UserNotAuthorizedException, PropertyServerException { - if (governanceActionGUID != null) + final String methodName = "recordCompletionStatus"; + + if (auditLog != null) { - governanceActionClient.recordCompletionStatus(engineHostUserId, - governanceActionGUID, - requestParameters, - status, - outputGuards, - newActionTargets); + String statusString = ""; + String guardsString = ""; + String requestParameterNames = ""; + String actionTargets = ""; + + if (status != null) + { + statusString = status.getName(); + } + + if (outputGuards != null) + { + guardsString = outputGuards.toString(); + } + + if (requestParameters != null) + { + requestParameterNames = requestParameters.keySet().toString(); + } + + if (newActionTargets != null) + { + actionTargets = newActionTargets.toString(); + } + + auditLog.logMessage(methodName, EngineHostServicesAuditCode.GOVERNANCE_ACTION_RECORD_COMPLETION.getMessageDefinition(governanceActionGUID, + governanceServiceName, + getGovernanceEngineName(), + requestType, + statusString, + guardsString, + requestParameterNames, + actionTargets)); } + + governanceActionClient.recordCompletionStatus(engineHostUserId, + governanceActionGUID, + requestParameters, + status, + outputGuards, + newActionTargets); } From aff44035dcfcd42125d7fba86d829e2ec860194f Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:00:14 +0100 Subject: [PATCH 07/16] Correct NoteLogAuthorship - end 1 to PersonRole Signed-off-by: Mandy Chessell --- .../opentypes/OpenMetadataTypesArchive.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java index 3bc763d2c4d..e2d57dfe8ca 100644 --- a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive.java @@ -164,6 +164,7 @@ public void getOriginalTypes() */ update0011ManagingReferenceables(); update0015LinkedMediaTypes(); + update0160NoteLogs(); update0030OperatingPlatforms(); update0057SoftwareServices(); update0070NetworksAndGateways(); @@ -545,5 +546,71 @@ private TypeDefPatch updateNetworkGatewayLinkRelationship() * ------------------------------------------------------------------------------------------------------- */ + + /** + * Enable any person role to author note logs. + */ + private void update0160NoteLogs() + { + this.archiveBuilder.addTypeDefPatch(updateNoteLogAuthorshipRelationship()); + } + + + private TypeDefPatch updateNoteLogAuthorshipRelationship() + { + /* + * Create the Patch + */ + final String typeName = "NoteLogAuthorship"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "PersonRole"; + final String end1AttributeName = "authors"; + final String end1AttributeDescription = "Person contributing to the note log."; + final String end1AttributeDescriptionGUID = null; + final RelationshipEndCardinality end1Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + typeDefPatch.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "NoteLog"; + final String end2AttributeName = "authoredNoteLogs"; + final String end2AttributeDescription = "Note log containing contributions."; + final String end2AttributeDescriptionGUID = null; + final RelationshipEndCardinality end2Cardinality = RelationshipEndCardinality.ANY_NUMBER; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + typeDefPatch.setEndDef2(relationshipEndDef); + + return typeDefPatch; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + } From d3d6d160b4e593b9bf203373e92c53a8c9170ed6 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:01:21 +0100 Subject: [PATCH 08/16] New update tests Signed-off-by: Mandy Chessell --- .../fvt/databases/CreateDatabaseTest.java | 125 +++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/open-metadata-test/open-metadata-fvt/access-services-fvt/data-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/datamanager/fvt/databases/CreateDatabaseTest.java b/open-metadata-test/open-metadata-fvt/access-services-fvt/data-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/datamanager/fvt/databases/CreateDatabaseTest.java index 34a29b4f4b9..caef0f107ca 100644 --- a/open-metadata-test/open-metadata-fvt/access-services-fvt/data-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/datamanager/fvt/databases/CreateDatabaseTest.java +++ b/open-metadata-test/open-metadata-fvt/access-services-fvt/data-manager-fvt/src/main/java/org/odpi/openmetadata/accessservices/datamanager/fvt/databases/CreateDatabaseTest.java @@ -56,6 +56,11 @@ public class CreateDatabaseTest private final static String databaseColumnDescription = "DatabaseColumn description"; private final static String databaseColumnType = "string"; + private final static String databaseColumnTwoName = "TestDatabaseColumn2"; + private final static String databaseColumnTwoDisplayName = "DatabaseColumn2 displayName"; + private final static String databaseColumnTwoDescription = "DatabaseColumn2 description"; + private final static String databaseColumnTwoType = "date"; + /** * Run all of the defined tests and capture the results. @@ -117,7 +122,6 @@ private static void runIt(String serverPlatformRootURL, String databaseTableGUID = thisTest.createDatabaseTable(client, databaseManagerGUID, databaseSchemaGUID, userId); String databaseColumnGUID = thisTest.createDatabaseColumn(client, databaseManagerGUID, databaseTableGUID, userId); - /* * Check that all elements are deleted when the database is deleted. */ @@ -192,6 +196,125 @@ private static void runIt(String serverPlatformRootURL, thisTest.checkDatabaseSchemaGone(client, databaseSchemaGUID, null, activityName, userId); thisTest.checkDatabaseGone(client, databaseGUID, activityName, userId); + + /* + * Recreate database + */ + activityName= "deleteOneByOne"; + + databaseGUID = thisTest.getDatabase(client, databaseManagerGUID, userId); + databaseSchemaGUID = thisTest.getDatabaseSchema(client, databaseManagerGUID, databaseGUID, userId); + databaseTableGUID = thisTest.createDatabaseTable(client, databaseManagerGUID, databaseSchemaGUID, userId); + databaseColumnGUID = thisTest.createDatabaseColumn(client, databaseManagerGUID, databaseTableGUID, userId); + + /* + * Update tests + */ + activityName = "updateNonExistentColumn"; + + String databaseColumnTwoGUID = "Blah Blah"; + DatabaseColumnProperties databaseColumnTwoProperties = new DatabaseColumnProperties(); + databaseColumnTwoProperties.setQualifiedName(databaseColumnTwoName); + databaseColumnTwoProperties.setDisplayName(databaseColumnDisplayName); // Note wrong value + databaseColumnTwoProperties.setDescription(databaseColumnTwoDescription); + databaseColumnTwoProperties.setDataType(databaseColumnType); // Note wrong value + + try + { + + client.updateDatabaseColumn(userId, databaseManagerGUID, databaseManagerName, databaseColumnTwoGUID, databaseColumnTwoProperties); + throw new FVTUnexpectedCondition(testCaseName, activityName); + } + catch (InvalidParameterException expectedError) + { + // very good + } + + activityName = "updateColumnWithSameProperties"; + + databaseColumnTwoGUID = client.createDatabaseColumn(userId, databaseManagerGUID, databaseManagerName, databaseTableGUID, databaseColumnTwoProperties); + + DatabaseColumnElement beforeElement = client.getDatabaseColumnByGUID(userId, databaseColumnTwoGUID); + + client.updateDatabaseColumn(userId, databaseManagerGUID, databaseManagerName, databaseColumnTwoGUID, databaseColumnTwoProperties); + + DatabaseColumnElement afterElement = client.getDatabaseColumnByGUID(userId, databaseColumnTwoGUID); + + /* + * No change should occur in the version number because the properties are not different. + */ + if (! beforeElement.getElementHeader().getVersions().equals(afterElement.getElementHeader().getVersions())) + { + throw new FVTUnexpectedCondition(testCaseName, activityName + "(version changed from " + beforeElement.getElementHeader().getVersions() + " to " + afterElement.getElementHeader().getVersions() + ")"); + } + + activityName = "updateColumnClassificationProperties"; + + /* + * This change effects the classification of the column + */ + databaseColumnTwoProperties.setDataType(databaseColumnTwoType); + + client.updateDatabaseColumn(userId, databaseManagerGUID, databaseManagerName, databaseColumnTwoGUID, databaseColumnTwoProperties); + + afterElement = client.getDatabaseColumnByGUID(userId, databaseColumnTwoGUID); + + /* + * No change should occur in the version number because the entity properties are not different. + */ + if (! beforeElement.getElementHeader().getVersions().equals(afterElement.getElementHeader().getVersions())) + { + throw new FVTUnexpectedCondition(testCaseName, activityName + "(version changed from " + beforeElement.getElementHeader().getVersions() + " to " + afterElement.getElementHeader().getVersions() + ")"); + } + + if (! databaseColumnTwoType.equals(afterElement.getDatabaseColumnProperties().getDataType())) + { + throw new FVTUnexpectedCondition(testCaseName, activityName + "(data type should be " + databaseColumnTwoType + " rather than " + afterElement.getDatabaseColumnProperties().getDataType() + ")"); + } + + /* + * This change affects the entity + */ + activityName = "updateColumnProperties"; + + databaseColumnTwoProperties.setDisplayName(databaseColumnTwoDisplayName); + + client.updateDatabaseColumn(userId, databaseManagerGUID, databaseManagerName, databaseColumnTwoGUID, databaseColumnTwoProperties); + + afterElement = client.getDatabaseColumnByGUID(userId, databaseColumnTwoGUID); + + /* + * The change should have taken effect. + */ + if (beforeElement.getElementHeader().getVersions().equals(afterElement.getElementHeader().getVersions())) + { + throw new FVTUnexpectedCondition(testCaseName, activityName + "(version did not change from " + beforeElement.getElementHeader().getVersions() + ")"); + } + + if (! databaseColumnTwoDisplayName.equals(afterElement.getDatabaseColumnProperties().getDisplayName())) + { + throw new FVTUnexpectedCondition(testCaseName, activityName + "(display name should be " + databaseColumnTwoDisplayName + " rather than " + afterElement.getDatabaseColumnProperties().getDisplayName() + ")"); + } + + /* + * Check that all elements are deleted when the database is deleted. + */ + activityName = "cascadedDelete"; + try + { + client.removeDatabase(userId, databaseManagerGUID, databaseManagerName, databaseGUID, databaseName); + + thisTest.checkDatabaseGone(client, databaseGUID, activityName, userId); + thisTest.checkDatabaseSchemaGone(client, databaseSchemaGUID, null, activityName, userId); + thisTest.checkDatabaseTableGone(client, databaseTableGUID, null, activityName, userId); + thisTest.checkDatabaseColumnGone(client, databaseColumnGUID, null, activityName, userId); + thisTest.checkDatabaseColumnGone(client, databaseColumnTwoGUID, null, activityName, userId); + } + catch (Exception unexpectedError) + { + throw new FVTUnexpectedCondition(testCaseName, activityName, unexpectedError); + } + } catch (Exception unexpectedError) { From 04a4941f4107b17e7ce707150348783163623752 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:03:00 +0100 Subject: [PATCH 09/16] Consolidate classification checks Signed-off-by: Mandy Chessell --- .../OpenMetadataServerSecurityConnector.java | 11 +-- .../OpenMetadataServerSecurityVerifier.java | 82 +------------------ ...OMRSMetadataDefaultRepositorySecurity.java | 1 + .../OpenMetadataRepositorySecurity.java | 57 +------------ 4 files changed, 6 insertions(+), 145 deletions(-) diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java index 737334a3fa9..f0e62f72012 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-connectors/src/main/java/org/odpi/openmetadata/metadatasecurity/connectors/OpenMetadataServerSecurityConnector.java @@ -10,16 +10,11 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; -import org.odpi.openmetadata.metadatasecurity.OpenMetadataAssetSecurity; -import org.odpi.openmetadata.metadatasecurity.OpenMetadataConnectionSecurity; -import org.odpi.openmetadata.metadatasecurity.OpenMetadataServerSecurity; -import org.odpi.openmetadata.metadatasecurity.OpenMetadataServiceSecurity; import org.odpi.openmetadata.metadatasecurity.ffdc.OpenMetadataSecurityAuditCode; import org.odpi.openmetadata.metadatasecurity.ffdc.OpenMetadataSecurityErrorCode; import org.odpi.openmetadata.metadatasecurity.properties.AssetAuditHeader; import org.odpi.openmetadata.metadatasecurity.properties.Asset; import org.odpi.openmetadata.metadatasecurity.properties.Connection; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OpenMetadataRepositorySecurity; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.AttributeTypeDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef; @@ -1366,7 +1361,7 @@ protected void validateUserForEntityUpdate(String userId, */ protected void validateUserForEntityClassificationAdd(String userId, String metadataCollectionName, - EntityDetail instance, + EntitySummary instance, String classificationName, InstanceProperties properties) throws UserNotAuthorizedException { @@ -1398,7 +1393,7 @@ protected void validateUserForEntityClassificationAdd(String user */ protected void validateUserForEntityClassificationUpdate(String userId, String metadataCollectionName, - EntityDetail instance, + EntitySummary instance, String classificationName, InstanceProperties properties) throws UserNotAuthorizedException { @@ -1429,7 +1424,7 @@ protected void validateUserForEntityClassificationUpdate(String u */ protected void validateUserForEntityClassificationDelete(String userId, String metadataCollectionName, - EntityDetail instance, + EntitySummary instance, String classificationName) throws UserNotAuthorizedException { final String methodName = "validateUserForEntityClassificationDelete"; diff --git a/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java b/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java index e9cc61c3ae5..c76cd34293b 100644 --- a/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java +++ b/open-metadata-implementation/common-services/metadata-security/metadata-security-server/src/main/java/org/odpi/openmetadata/metadatasecurity/server/OpenMetadataServerSecurityVerifier.java @@ -1089,34 +1089,6 @@ public void validateUserForEntityUpdate(String userId, } - /** - * Tests for whether a specific user should have the right to add a classification to an entity proxy - * within a repository. - * - * @param userId identifier of user - * @param metadataCollectionName configurable name of the metadata collection - * @param instance instance proxy - * @param classificationName String name for the classification. - * @param properties list of properties for the classification. - * @throws UserNotAuthorizedException the user is not authorized to maintain instances - */ - @Override - public void validateUserForEntityClassificationAdd(String userId, - String metadataCollectionName, - EntityProxy instance, - String classificationName, - InstanceProperties properties) throws UserNotAuthorizedException - { - if (repositorySecurityConnector != null) - { - repositorySecurityConnector.validateUserForEntityClassificationAdd(userId, - metadataCollectionName, - instance, - classificationName, - properties); - } - } - /** * Tests for whether a specific user should have the right to add a classification to an entity instance * within a repository. @@ -1146,34 +1118,6 @@ public void validateUserForEntityClassificationAdd(String userId, } - /** - * Tests for whether a specific user should have the right to update the classification for an entity proxy - * within a repository. - * - * @param userId identifier of user - * @param metadataCollectionName configurable name of the metadata collection - * @param instance instance proxy - * @param classificationName String name for the classification. - * @param properties list of properties for the classification. - * @throws UserNotAuthorizedException the user is not authorized to maintain instances - */ - @Override - public void validateUserForEntityClassificationUpdate(String userId, - String metadataCollectionName, - EntityProxy instance, - String classificationName, - InstanceProperties properties) throws UserNotAuthorizedException - { - if (repositorySecurityConnector != null) - { - repositorySecurityConnector.validateUserForEntityClassificationUpdate(userId, - metadataCollectionName, - instance, - classificationName, - properties); - } - } - /** * Tests for whether a specific user should have the right to update the classification for an entity instance * within a repository. @@ -1203,31 +1147,6 @@ public void validateUserForEntityClassificationUpdate(String user } - /** - * Tests for whether a specific user should have the right to delete a classification from an entity proxy - * within a repository. - * - * @param userId identifier of user - * @param metadataCollectionName configurable name of the metadata collection - * @param instance instance proxy - * @param classificationName String name for the classification. - * @throws UserNotAuthorizedException the user is not authorized to maintain instances - */ - @Override - public void validateUserForEntityClassificationDelete(String userId, - String metadataCollectionName, - EntityProxy instance, - String classificationName) throws UserNotAuthorizedException - { - if (repositorySecurityConnector != null) - { - repositorySecurityConnector.validateUserForEntityClassificationDelete(userId, - metadataCollectionName, - instance, - classificationName); - } - } - /** * Tests for whether a specific user should have the right to delete a classification from an entity instance * within a repository. @@ -1253,6 +1172,7 @@ public void validateUserForEntityClassificationDelete(String user } } + /** * Tests for whether a specific user should have the right to delete a instance within a repository. * diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataDefaultRepositorySecurity.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataDefaultRepositorySecurity.java index ddaf3345f73..e830ad651ff 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataDefaultRepositorySecurity.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OMRSMetadataDefaultRepositorySecurity.java @@ -278,6 +278,7 @@ public void validateUserForEntityClassificationAdd(String userId, { } + /** * Tests for whether a specific user should have the right to update the classification for an entity instance * within a repository. diff --git a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java index a9ff95dbbab..20bba20d6e2 100644 --- a/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java +++ b/open-metadata-implementation/repository-services/repository-services-apis/src/main/java/org/odpi/openmetadata/repositoryservices/connectors/stores/metadatacollectionstore/OpenMetadataRepositorySecurity.java @@ -216,25 +216,6 @@ void validateUserForEntityUpdate(String userId, String metadataCollectionName, EntityDetail instance) throws UserNotAuthorizedException; - /** - * Tests for whether a specific user should have the right to add a classification to an entity instance - * within a repository. - * - * @param userId identifier of user - * @param metadataCollectionName configurable name of the metadata collection - * @param instance instance proxy - * @param classificationName String name for the classification. - * @param properties list of properties for the classification. - * @throws UserNotAuthorizedException the user is not authorized to maintain instances - */ - default void validateUserForEntityClassificationAdd(String userId, - String metadataCollectionName, - EntityProxy instance, - String classificationName, - InstanceProperties properties) throws UserNotAuthorizedException - { - // - } /** * Tests for whether a specific user should have the right to add a classification to an entity instance @@ -253,25 +234,6 @@ void validateUserForEntityClassificationAdd(String userId, String classificationName, InstanceProperties properties) throws UserNotAuthorizedException; - /** - * Tests for whether a specific user should have the right to update a classification for an entity instance - * within a repository. - * - * @param userId identifier of user - * @param metadataCollectionName configurable name of the metadata collection - * @param instance instance proxy - * @param classificationName String name for the classification. - * @param properties list of properties for the classification. - * @throws UserNotAuthorizedException the user is not authorized to maintain instances - */ - default void validateUserForEntityClassificationUpdate(String userId, - String metadataCollectionName, - EntityProxy instance, - String classificationName, - InstanceProperties properties) throws UserNotAuthorizedException - { - // - } /** * Tests for whether a specific user should have the right to update a classification for an entity instance @@ -291,24 +253,6 @@ void validateUserForEntityClassificationUpdate(String userId, InstanceProperties properties) throws UserNotAuthorizedException; - /** - * Tests for whether a specific user should have the right to delete a classification from an entity instance - * within a repository. - * - * @param userId identifier of user - * @param metadataCollectionName configurable name of the metadata collection - * @param instance instance proxy - * @param classificationName String name for the classification. - * @throws UserNotAuthorizedException the user is not authorized to maintain instances - */ - default void validateUserForEntityClassificationDelete(String userId, - String metadataCollectionName, - EntityProxy instance, - String classificationName) throws UserNotAuthorizedException - { - // - } - /** * Tests for whether a specific user should have the right to delete a classification from an entity instance * within a repository. @@ -324,6 +268,7 @@ void validateUserForEntityClassificationDelete(String userId, EntitySummary instance, String classificationName) throws UserNotAuthorizedException; + /** * Tests for whether a specific user should have the right to delete a instance within a repository. * From 8983faefa111c6f023e6e3a61418ec8e918698dd Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:03:48 +0100 Subject: [PATCH 10/16] Improve log messages for governance actions Signed-off-by: Mandy Chessell --- .../GovernanceActionHandler.java | 180 +++++++++++++++--- .../ffdc/GenericHandlersAuditCode.java | 54 ++++++ 2 files changed, 210 insertions(+), 24 deletions(-) diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GovernanceActionHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GovernanceActionHandler.java index c692f6dbac6..1be38378924 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GovernanceActionHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/GovernanceActionHandler.java @@ -3,6 +3,7 @@ package org.odpi.openmetadata.commonservices.generichandlers; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.generichandlers.ffdc.GenericHandlersAuditCode; import org.odpi.openmetadata.commonservices.generichandlers.ffdc.GenericHandlersErrorCode; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryEntitiesIterator; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; @@ -386,6 +387,56 @@ public String initiateGovernanceAction(String userId, invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName); invalidParameterHandler.validateName(governanceEngineName, engineNameParameterName, methodName); + /* + * Log details of the requested governance action. + */ + String receivedGuardsString = ""; + String mandatoryGuardsString = ""; + String startTimeString = ""; + String requestParameterNames = ""; + + if (receivedGuards != null) + { + receivedGuardsString = receivedGuards.toString(); + } + + if (mandatoryGuards != null) + { + mandatoryGuardsString = mandatoryGuards.toString(); + } + + if (startTime != null) + { + startTimeString = startTime.toString(); + } + + if (requestParameters != null) + { + requestParameterNames = requestParameters.keySet().toString(); + } + + if (governanceActionTypeName != null) + { + auditLog.logMessage(methodName, GenericHandlersAuditCode.INITIATE_GOVERNANCE_ACTION_FROM_TYPE.getMessageDefinition(qualifiedName, + governanceActionTypeName, + requestType, + governanceEngineName, + receivedGuardsString, + mandatoryGuardsString, + requestParameterNames, + startTimeString)); + } + else + { + auditLog.logMessage(methodName, GenericHandlersAuditCode.INITIATE_GOVERNANCE_ACTION.getMessageDefinition(qualifiedName, + requestType, + governanceEngineName, + receivedGuardsString, + mandatoryGuardsString, + requestParameterNames, + startTimeString)); + } + /* * Effective time is set to "any time" and all elements that make up the governance action * are set up without effectivity dates. Any control on start time is done using the startTime property. @@ -516,6 +567,7 @@ public String initiateGovernanceAction(String userId, this.addActionTargets(userId, governanceActionGUID, governanceActionGUIDParameterName, + qualifiedName, actionTargets, methodName); @@ -539,6 +591,7 @@ public String initiateGovernanceAction(String userId, * @param userId calling user * @param governanceActionGUID unique identifier of the governance action to connector the targets to * @param governanceActionGUIDParameterName parameter passing the governanceActionGUID + * @param governanceActionName name of governance action - for logging * @param actionTargets map of action target names to GUIDs for the resulting governance action service * @param methodName calling method * @throws InvalidParameterException null qualified name @@ -548,6 +601,7 @@ public String initiateGovernanceAction(String userId, private void addActionTargets(String userId, String governanceActionGUID, String governanceActionGUIDParameterName, + String governanceActionName, List actionTargets, String methodName) throws InvalidParameterException, UserNotAuthorizedException, @@ -559,32 +613,41 @@ private void addActionTargets(String userId, for (NewActionTarget actionTarget : actionTargets) { - String actionTargetGUID = actionTarget.getActionTargetGUID(); - String actionTargetName = actionTarget.getActionTargetName(); - if (actionTargetGUID != null) + if (actionTarget != null) { - InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, - null, - OpenMetadataAPIMapper.ACTION_TARGET_NAME_PROPERTY_NAME, - actionTargetName, - methodName); + String actionTargetGUID = actionTarget.getActionTargetGUID(); + String actionTargetName = actionTarget.getActionTargetName(); - this.linkElementToElement(userId, - null, - null, - governanceActionGUID, - governanceActionGUIDParameterName, - OpenMetadataAPIMapper.GOVERNANCE_ACTION_TYPE_NAME, - actionTargetGUID, - actionTargetGUIDParameterName, - OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, - false, - false, - supportedZones, - OpenMetadataAPIMapper.TARGET_FOR_ACTION_TYPE_GUID, - OpenMetadataAPIMapper.TARGET_FOR_ACTION_TYPE_NAME, - properties, - methodName); + if (actionTargetGUID != null) + { + InstanceProperties properties = repositoryHelper.addStringPropertyToInstance(serviceName, + null, + OpenMetadataAPIMapper.ACTION_TARGET_NAME_PROPERTY_NAME, + actionTargetName, + methodName); + + this.linkElementToElement(userId, + null, + null, + governanceActionGUID, + governanceActionGUIDParameterName, + OpenMetadataAPIMapper.GOVERNANCE_ACTION_TYPE_NAME, + actionTargetGUID, + actionTargetGUIDParameterName, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + false, + false, + supportedZones, + OpenMetadataAPIMapper.TARGET_FOR_ACTION_TYPE_GUID, + OpenMetadataAPIMapper.TARGET_FOR_ACTION_TYPE_NAME, + properties, + methodName); + + auditLog.logMessage(methodName, GenericHandlersAuditCode.ADD_ACTION_TARGETS.getMessageDefinition(actionTargetName, + actionTargetGUID, + governanceActionName, + governanceActionGUID)); + } } } } @@ -910,6 +973,8 @@ public void claimGovernanceAction(String userId, true, effectiveTime, methodName); + + auditLog.logMessage(methodName, GenericHandlersAuditCode.SUCCESSFUL_ACTION_CLAIM_REQUEST.getMessageDefinition(userId, governanceActionGUID)); } else { @@ -944,6 +1009,57 @@ public void claimGovernanceAction(String userId, } + /** + * Create a string message for log messages. + * + * @param ordinal ordinal for the status + * @return string name + */ + private String getGovernanceActionStatusName(int ordinal) + { + String governanceActionStatusName = "UNKNOWN"; + switch(ordinal) + { + case OpenMetadataAPIMapper.REQUESTED_GA_STATUS_ORDINAL: + governanceActionStatusName = "REQUESTED"; + break; + + case OpenMetadataAPIMapper.APPROVED_GA_STATUS_ORDINAL: + governanceActionStatusName = "APPROVED"; + break; + + case OpenMetadataAPIMapper.WAITING_GA_STATUS_ORDINAL: + governanceActionStatusName = "WAITING"; + break; + + case OpenMetadataAPIMapper.IN_PROGRESS_GA_STATUS_ORDINAL: + governanceActionStatusName = "IN_PROGRESS"; + break; + + case OpenMetadataAPIMapper.ACTIONED_GA_STATUS_ORDINAL: + governanceActionStatusName = "ACTIONED"; + break; + + case OpenMetadataAPIMapper.INVALID_GA_STATUS_ORDINAL: + governanceActionStatusName = "iNVALID"; + break; + + case OpenMetadataAPIMapper.IGNORED_GA_STATUS_ORDINAL: + governanceActionStatusName = "IGNORED"; + break; + + case OpenMetadataAPIMapper.FAILED_GA_STATUS_ORDINAL: + governanceActionStatusName = "FAILED"; + break; + + case OpenMetadataAPIMapper.OTHER_GA_STATUS_ORDINAL: + governanceActionStatusName = "OTHER"; + break; + } + + return governanceActionStatusName; + } + /** * Update the status of the governance action - providing the caller is permitted. @@ -989,6 +1105,11 @@ public void updateGovernanceActionStatus(String userId, if (properties != null) { + int currentStatus = repositoryHelper.getEnumPropertyOrdinal(serviceName, + OpenMetadataAPIMapper.ACTION_STATUS_PROPERTY_NAME, + properties, + methodName); + String processingEngineUserId = repositoryHelper.getStringProperty(serviceName, OpenMetadataAPIMapper.PROCESSING_ENGINE_USER_ID_PROPERTY_NAME, properties, @@ -1026,6 +1147,12 @@ public void updateGovernanceActionStatus(String userId, true, effectiveTime, methodName); + + auditLog.logMessage(methodName, GenericHandlersAuditCode.GOVERNANCE_ACTION_STATUS_CHANGE.getMessageDefinition(this.getGovernanceActionStatusName(currentStatus), + this.getGovernanceActionStatusName(governanceActionStatus), + governanceActionGUID, + userId)); + } else { @@ -1731,9 +1858,14 @@ private String newGovernanceActionNeeded(String userId, * Need to use this governance action rather than creating a new one. It needs updating with the * additional action targets and the output guards. It may then be ready to run. */ + String nextGovernanceActionName = repositoryHelper.getStringProperty(serviceName, + OpenMetadataAPIMapper.QUALIFIED_NAME_PROPERTY_NAME, + nextGovernanceAction.getProperties(), + methodName); this.addActionTargets(userId, nextGovernanceAction.getGUID(), governanceActionGUIDParameterName, + nextGovernanceActionName, newActionTargets, methodName); diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java index 8f52841703d..15e0ba17b87 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ffdc/GenericHandlersAuditCode.java @@ -78,6 +78,60 @@ public enum GenericHandlersAuditCode implements AuditLogMessageSet "This message is to highlight that an entity has lost its anchor, and a delete was attempted on it, but failed. " + "An administrator should assess what is required for the entity, and either delete it or supply a new anchor for it."), + IGNORING_UNNECESSARY_ENTITY_UPDATE("OMAG-GENERIC-HANDLERS-0008", + OMRSAuditLogRecordSeverity.INFO, + "Ignoring unnecessary update to {0} entity with unique identifier {1} through method {2} by user {3}", + "No update is made to the entity in the repository because the new properties are the same as the old. In order to determine that the update is unnecessary, Egeria has retrieved the existing entity from the repository and compared it to the new values.", + "Determine if the processing by Egeria is the most efficient way to detect if an update is required to the entity and make adjustments to the caller's logic if appropriate."), + + IGNORING_UNNECESSARY_RELATIONSHIP_UPDATE("OMAG-GENERIC-HANDLERS-0009", + OMRSAuditLogRecordSeverity.INFO, + "Ignoring unnecessary update to {0} relationship with unique identifier {1} through method {2} by user {3}", + "No update is made to the relationship in the repository because the new properties are the same as the old. In order to determine that the update is unnecessary, Egeria has retrieved the existing relationship from the repository and compared it to the new values.", + "Determine if the processing by Egeria is the most efficient way to detect if an update is required to the relationship and make adjustments to the caller's logic if appropriate."), + + IGNORING_UNNECESSARY_CLASSIFICATION_UPDATE("OMAG-GENERIC-HANDLERS-0010", + OMRSAuditLogRecordSeverity.INFO, + "Ignoring unnecessary update to {0} classification attached to entity with unique identifier {1} through method {2} by user {3}", + "No update is made to the classification in the repository because the new properties are the same as the old. In order to determine that the update is unnecessary, Egeria has retrieved the existing entity from the repository and compared the classification properties to the new values.", + "Determine if the processing by Egeria is the most efficient way to detect if an update is required to the classification and make adjustments to the caller's logic if appropriate."), + + INITIATE_GOVERNANCE_ACTION("OMAG-GENERIC-HANDLERS-0020", + OMRSAuditLogRecordSeverity.STARTUP, + "Initializing a new governance action {0} for request type {1} to run on governance engine {2} with receivedGuards of {3}, mandatoryGuards of {4}, supplied with request parameters {5} and a start time of {6}", + "A new GovernanceAction entity is created. This will be picked up by the Governance Engine OMASs running in the connected cohorts and passed onto their connected engine hosts. These engine hosts will compete for the right to execute the governance action.", + "Validate that this governance action should be initialized. If so, check that the Governance Engine OMASs running in the connected cohorts publish the governance action to their connected engine host(s)."), + + INITIATE_GOVERNANCE_ACTION_FROM_TYPE("OMAG-GENERIC-HANDLERS-0021", + OMRSAuditLogRecordSeverity.STARTUP, + "Initializing a new governance action {0} from governance action type {1} for request type {2} to run on governance engine {3} with receivedGuards of {4}, mandatoryGuards of {5}, supplied with request parameters {6} and a start time of {7}", + "A new GovernanceAction entity is created using the definition of the governance action type. This will be picked up by the Governance Engine OMASs running in the connected cohorts and passed onto their connected engine hosts. These engine hosts will compete for the right to execute the governance action.", + "Validate that this governance action should be initialized using this type. If so, check that the Governance Engine OMASs running in the connected cohorts publish the governance action to their connected engine host(s)."), + + ADD_ACTION_TARGETS("OMAG-GENERIC-HANDLERS-0022", + OMRSAuditLogRecordSeverity.STARTUP, + "Adding action target {0} ({1}) to governance action {2} ({3})", + "The governance action is linked to the action target so that it is made available to the governance action service when it runs.", + "Validate that this action target should be added to the governance action."), + + ACTION_CLAIM_REQUEST("OMAG-GENERIC-HANDLERS-0023", + OMRSAuditLogRecordSeverity.STARTUP, + "Governance engine with {0} userId is claiming governance action {1}", + "The governance engine is requesting permission to execute the governance action. This will be successful if the governance engine is the first to claim the governance action and it is in APPROVED status.", + "Validate that one of the governance engines successfully claims the governance action."), + + SUCCESSFUL_ACTION_CLAIM_REQUEST("OMAG-GENERIC-HANDLERS-0024", + OMRSAuditLogRecordSeverity.STARTUP, + "Governance engine with {0} userId has successfully claimed governance action {1}", + "The governance action is updated to show that the governance engine has claimed it and that its status is now WAITING. This will be successful if the governance engine is the first to claim the governance action and it is in APPROVED status.", + "Validate that only one of the governance engines successfully claims the governance action."), + + GOVERNANCE_ACTION_STATUS_CHANGE("OMAG-GENERIC-HANDLERS-0025", + OMRSAuditLogRecordSeverity.STARTUP, + "Status changed from {0} to {1} for governance action {2} by governance engine with {3} userId", + "The governance action's status has been updated as requested.", + "Validate that the status change is valid."), + ; private String logMessageId; From 22b935cce2a2bb6f05833d435ddeba12b09351e6 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:04:50 +0100 Subject: [PATCH 11/16] Log refresh time Signed-off-by: Mandy Chessell --- .../ffdc/IntegrationDaemonServicesAuditCode.java | 10 ++++++++-- .../handlers/IntegrationConnectorHandler.java | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-api/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/ffdc/IntegrationDaemonServicesAuditCode.java b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-api/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/ffdc/IntegrationDaemonServicesAuditCode.java index 2b6efe2eae1..e9b6c0097e8 100644 --- a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-api/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/ffdc/IntegrationDaemonServicesAuditCode.java +++ b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-api/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/ffdc/IntegrationDaemonServicesAuditCode.java @@ -288,13 +288,19 @@ public enum IntegrationDaemonServicesAuditCode implements AuditLogMessageSet "The thread is about to call refresh() on the integration connectors hosted in this daemon.", "Ensure that the connector does not report any errors during the refresh processing."), - DAEMON_THREAD_TERMINATING("INTEGRATION-DAEMON-SERVICES-0043", + DAEMON_CONNECTOR_REFRESH_COMPLETE("INTEGRATION-DAEMON-SERVICES-0043", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} in integration daemon {1} has completed refresh processing in {2} millisecond", + "The to call refresh() has returned.", + "Verify that the time between refresh calls is appropriate for the connector."), + + DAEMON_THREAD_TERMINATING("INTEGRATION-DAEMON-SERVICES-0044", OMRSAuditLogRecordSeverity.SHUTDOWN, "The integration daemon thread for integration daemon {0} is shutting down", "The thread will stop calling refresh() on the integration connectors hosted in this daemon and stop running.", "Ensure that the thread terminates without errors."), - DAEMON_THREAD_CONNECTOR_ERROR("INTEGRATION-DAEMON-SERVICES-0044", + DAEMON_THREAD_CONNECTOR_ERROR("INTEGRATION-DAEMON-SERVICES-0045", OMRSAuditLogRecordSeverity.EXCEPTION, "The integration daemon thread for integration daemon {0} caught a {1} exception from an integration connector containing message {2}", "The integration daemon thread will move to the next connector and revisit this connector at the next refresh time.", diff --git a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java index 9ada053bd8b..9e71b66d17a 100644 --- a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java +++ b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java @@ -466,6 +466,8 @@ public synchronized void refreshConnector(String actionDescription, } if (integrationConnectorStatus == IntegrationConnectorStatus.RUNNING) { + Date refreshStart = new Date(); + if (auditLog != null) { if (firstCall) @@ -483,6 +485,16 @@ public synchronized void refreshConnector(String actionDescription, } integrationConnector.refresh(); + + if (auditLog != null) + { + Date refreshEnd = new Date(); + + auditLog.logMessage(actionDescription, + IntegrationDaemonServicesAuditCode.DAEMON_CONNECTOR_REFRESH_COMPLETE.getMessageDefinition(integrationConnectorName, + integrationDaemonName, + Long.toString(refreshEnd.getTime() - refreshStart.getTime()))); + } } this.lastRefreshTime = new Date(); From 7ee7fae7aee89d5cb2b272c74020dd53a24849ca Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:06:43 +0100 Subject: [PATCH 12/16] Fix update of embedded schema type Signed-off-by: Mandy Chessell --- .../client/DatabaseManagerClient.java | 2 + .../server/SchemaManagerRESTServices.java | 7 + .../OpenMetadataAPIGenericHandler.java | 80 +++++++++ .../RelationalDataHandler.java | 137 +++++---------- .../SchemaAttributeHandler.java | 166 ++++++++++++++---- 5 files changed, 263 insertions(+), 129 deletions(-) diff --git a/open-metadata-implementation/access-services/data-manager/data-manager-client/src/main/java/org/odpi/openmetadata/accessservices/datamanager/client/DatabaseManagerClient.java b/open-metadata-implementation/access-services/data-manager/data-manager-client/src/main/java/org/odpi/openmetadata/accessservices/datamanager/client/DatabaseManagerClient.java index 18a882f8667..7de4dfd2a23 100644 --- a/open-metadata-implementation/access-services/data-manager/data-manager-client/src/main/java/org/odpi/openmetadata/accessservices/datamanager/client/DatabaseManagerClient.java +++ b/open-metadata-implementation/access-services/data-manager/data-manager-client/src/main/java/org/odpi/openmetadata/accessservices/datamanager/client/DatabaseManagerClient.java @@ -2010,12 +2010,14 @@ public void updateDatabaseColumn(String userId, final String methodName = "updateDatabaseColumn"; final String elementGUIDParameterName = "databaseColumnGUID"; final String propertiesParameterName = "databaseColumnProperties"; + final String qualifiedNameParameterName = "databaseColumnProperties.qualifiedName"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(databaseManagerGUID, databaseManagerGUIDParameterName, methodName); invalidParameterHandler.validateName(databaseManagerName, databaseManagerNameParameterName, methodName); invalidParameterHandler.validateGUID(databaseColumnGUID, elementGUIDParameterName, methodName); invalidParameterHandler.validateObject(databaseColumnProperties, propertiesParameterName, methodName); + invalidParameterHandler.validateName(databaseColumnProperties.getQualifiedName(), qualifiedNameParameterName, methodName); final String urlTemplate = serverPlatformURLRoot + editURLTemplatePrefix + "/tables/columns/{4}"; diff --git a/open-metadata-implementation/access-services/data-manager/data-manager-server/src/main/java/org/odpi/openmetadata/accessservices/datamanager/server/SchemaManagerRESTServices.java b/open-metadata-implementation/access-services/data-manager/data-manager-server/src/main/java/org/odpi/openmetadata/accessservices/datamanager/server/SchemaManagerRESTServices.java index 87e6176a8ad..d192b28b77f 100644 --- a/open-metadata-implementation/access-services/data-manager/data-manager-server/src/main/java/org/odpi/openmetadata/accessservices/datamanager/server/SchemaManagerRESTServices.java +++ b/open-metadata-implementation/access-services/data-manager/data-manager-server/src/main/java/org/odpi/openmetadata/accessservices/datamanager/server/SchemaManagerRESTServices.java @@ -1515,6 +1515,12 @@ public VoidResponse updateSchemaAttribute(String serverName, qualifiedNameParameterName, requestBody.getDisplayName(), requestBody.getDescription(), + requestBody.getExternalTypeGUID(), + requestBody.getDataType(), + requestBody.getDefaultValue(), + requestBody.getFixedValue(), + requestBody.getValidValuesSetGUID(), + null, requestBody.getIsDeprecated(), requestBody.getElementPosition(), requestBody.getMinCardinality(), @@ -1530,6 +1536,7 @@ public VoidResponse updateSchemaAttribute(String serverName, requestBody.getNativeJavaClass(), requestBody.getAliases(), requestBody.getAdditionalProperties(), + requestBody.getTypeName(), requestBody.getExtendedProperties(), isMergeUpdate, methodName); diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java index 556b1e612d3..913e4968f92 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java @@ -545,6 +545,32 @@ public void setClassificationInRepository(String userId, classificationProperties, existingClassification.getProperties()); + /* + * If there are no properties to change then nothing more to do + */ + if ((newProperties == null) && (existingClassification.getProperties() == null)) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.IGNORING_UNNECESSARY_CLASSIFICATION_UPDATE.getMessageDefinition(classificationTypeName, + beanEntity.getGUID(), + methodName, + userId)); + return; + } + + /* + * If nothing has changed in the properties then nothing to do + */ + if ((newProperties != null) && (newProperties.equals(existingClassification.getProperties()))) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.IGNORING_UNNECESSARY_CLASSIFICATION_UPDATE.getMessageDefinition(classificationTypeName, + beanEntity.getGUID(), + methodName, + userId)); + return; + } + repositoryHandler.reclassifyEntity(userId, externalSourceGUID, externalSourceName, @@ -1238,6 +1264,33 @@ public void updateRelationshipProperties(String userId, effectiveTime, methodName); + + /* + * If there are no properties to change then nothing more to do + */ + if ((newProperties == null) && (relationship.getProperties() == null)) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.IGNORING_UNNECESSARY_RELATIONSHIP_UPDATE.getMessageDefinition(relationship.getType().getTypeDefName(), + relationship.getGUID(), + methodName, + userId)); + return; + } + + /* + * If nothing has changed in the properties then nothing to do + */ + if ((newProperties != null) && (newProperties.equals(relationship.getProperties()))) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.IGNORING_UNNECESSARY_RELATIONSHIP_UPDATE.getMessageDefinition(relationship.getType().getTypeDefName(), + relationship.getGUID(), + methodName, + userId)); + return; + } + repositoryHandler.updateRelationshipProperties(userId, externalSourceGUID, externalSourceName, @@ -6609,6 +6662,33 @@ public void updateBeanInRepository(String userId, updateProperties, originalEntity.getProperties()); + /* + * If there are no properties to change then nothing more to do + */ + if ((newProperties == null) && (originalEntity.getProperties() == null)) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.IGNORING_UNNECESSARY_ENTITY_UPDATE.getMessageDefinition(originalEntity.getType().getTypeDefName(), + originalEntity.getGUID(), + methodName, + userId)); + return; + } + + /* + * If nothing has changed in the properties then nothing to do + */ + if ((newProperties != null) && (newProperties.equals(originalEntity.getProperties()))) + { + auditLog.logMessage(methodName, + GenericHandlersAuditCode.IGNORING_UNNECESSARY_ENTITY_UPDATE.getMessageDefinition(originalEntity.getType().getTypeDefName(), + originalEntity.getGUID(), + methodName, + userId)); + + return; + } + /* * Validate that any changes to the unique properties do not clash with other entities. */ diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/RelationalDataHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/RelationalDataHandler.java index fe774355307..44cc717e9d3 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/RelationalDataHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/RelationalDataHandler.java @@ -4020,107 +4020,56 @@ public void updateDatabaseColumn(String userId, * Check that the type name requested is valid. */ String attributeTypeName = OpenMetadataAPIMapper.RELATIONAL_COLUMN_TYPE_NAME; - String attributeTypeId = OpenMetadataAPIMapper.RELATIONAL_COLUMN_TYPE_GUID; if (typeName != null) { attributeTypeName = typeName; - attributeTypeId = invalidParameterHandler.validateTypeName(typeName, - OpenMetadataAPIMapper.RELATIONAL_COLUMN_TYPE_NAME, - serviceName, - methodName, - repositoryHelper); + invalidParameterHandler.validateTypeName(typeName, + OpenMetadataAPIMapper.RELATIONAL_COLUMN_TYPE_NAME, + serviceName, + methodName, + repositoryHelper); } - /* - * Retrieve the current schema attribute for the database column. An exception is thrown if the guid is invalid, points to - * an entity of the wrong type, or one with the CalculatedValue classification on its schema type. - */ - EntityDetail columnSchemaAttribute = databaseColumnHandler.getEntityFromRepository(userId, - databaseColumnGUID, - elementGUIDParameterName, - OpenMetadataAPIMapper.RELATIONAL_COLUMN_TYPE_NAME, - null, - null, - false, - false, - null, - methodName); - - if (columnSchemaAttribute != null) - { - /* - * Load up the builder objects for processing by the generic handler. The builders manage the properties - * of the metadata elements that make up the database table, and the schemaTypeHandler manages the elements themselves. - */ - SchemaAttributeBuilder schemaAttributeBuilder = new SchemaAttributeBuilder(qualifiedName, - displayName, - description, - elementPosition, - minCardinality, - maxCardinality, - isDeprecated, - defaultValueOverride, - allowsDuplicateValues, - orderedValues, - sortOrder, - minimumLength, - length, - significantDigits, - isNullable, - nativeJavaClass, - aliases, - additionalProperties, - attributeTypeId, - attributeTypeName, - extendedProperties, - repositoryHelper, - serviceName, - serverName); - - SchemaTypeBuilder schemaTypeBuilder = databaseColumnHandler.getSchemaTypeBuilder(qualifiedName, - externalSchemaTypeGUID, - dataType, - defaultValue, - fixedValue, - validValuesSetGUID); - - - schemaAttributeBuilder.setSchemaType(userId, schemaTypeBuilder, methodName); - - /* - * The formula is set if the column is derived - */ - if (formula != null) - { - schemaAttributeBuilder.setCalculatedValue(userId, databaseManagerGUID, databaseManagerName, formula, methodName); - } - - databaseColumnHandler.updateBeanInRepository(userId, - databaseManagerGUID, - databaseManagerName, - databaseColumnGUID, - elementGUIDParameterName, - attributeTypeId, - attributeTypeName, - schemaAttributeBuilder.getInstanceProperties(methodName), - false, - methodName); + databaseColumnHandler.updateSchemaAttribute(userId, + databaseManagerGUID, + databaseManagerName, + databaseColumnGUID, + elementGUIDParameterName, + qualifiedName, + qualifiedNameParameterName, + displayName, + description, + externalSchemaTypeGUID, + dataType, + defaultValue, + fixedValue, + validValuesSetGUID, + formula, + isDeprecated, + elementPosition, + minCardinality, + maxCardinality, + allowsDuplicateValues, + orderedValues, + defaultValueOverride, + sortOrder, + minimumLength, + length, + significantDigits, + isNullable, + nativeJavaClass, + aliases, + additionalProperties, + attributeTypeName, + extendedProperties, + false, + methodName); - databaseColumnHandler.setVendorProperties(userId, - databaseColumnGUID, - vendorProperties, - methodName); - } - else - { - invalidParameterHandler.throwUnknownElement(userId, - databaseColumnGUID, - attributeTypeName, - serviceName, - serverName, - methodName); - } + databaseColumnHandler.setVendorProperties(userId, + databaseColumnGUID, + vendorProperties, + methodName); } diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/SchemaAttributeHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/SchemaAttributeHandler.java index 576f4ea92bd..be275227ddc 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/SchemaAttributeHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/SchemaAttributeHandler.java @@ -1469,6 +1469,12 @@ public List findSchemaAttributes(String userId, * @param qualifiedNameParameterName name of parameter supplying the qualified name * @param displayName the stored display name property for the database table * @param description the stored description property associated with the database table + * @param externalSchemaTypeGUID unique identifier of an external schema identifier + * @param dataType data type name - for stored values + * @param defaultValue string containing default value - for stored values + * @param fixedValue string containing fixed value - for literals + * @param validValuesSetGUID unique identifier for a valid values set to support + * @param formula String formula - for derived values * @param isDeprecated is this table deprecated? * @param elementPosition the position of this column in its parent table. * @param minCardinality minimum number of repeating instances allowed for this column - typically 1 @@ -1501,6 +1507,12 @@ public void updateSchemaAttribute(String userId, String qualifiedNameParameterName, String displayName, String description, + String externalSchemaTypeGUID, + String dataType, + String defaultValue, + String fixedValue, + String validValuesSetGUID, + String formula, boolean isDeprecated, int elementPosition, int minCardinality, @@ -1516,6 +1528,7 @@ public void updateSchemaAttribute(String userId, String nativeJavaClass, List aliases, Map additionalProperties, + String typeName, Map extendedProperties, boolean isMergeUpdate, String methodName) throws InvalidParameterException, @@ -1530,45 +1543,128 @@ public void updateSchemaAttribute(String userId, invalidParameterHandler.validateName(qualifiedName, qualifiedNameParameterName, methodName); } - /* - * Load up the builder objects. The builders manage the properties of the metadata elements that make up the schema attribute, - * and the schemaTypeHandler manages the type. + * Check that the type name requested is valid. */ - SchemaAttributeBuilder schemaAttributeBuilder = new SchemaAttributeBuilder(qualifiedName, - displayName, - description, - elementPosition, - minCardinality, - maxCardinality, - isDeprecated, - defaultValueOverride, - allowsDuplicateValues, - orderedValues, - sortOrder, - minimumLength, - length, - significantDigits, - isNullable, - nativeJavaClass, - aliases, - additionalProperties, - OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_GUID, - OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME, - extendedProperties, - repositoryHelper, - serviceName, - serverName); + String attributeTypeName = OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME; + String attributeTypeId = OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_GUID; + if (typeName != null) + { + attributeTypeName = typeName; + attributeTypeId = invalidParameterHandler.validateTypeName(typeName, + OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME, + serviceName, + methodName, + repositoryHelper); + } - this.updateSchemaAttribute(userId, - externalSourceGUID, - externalSourceName, - schemaAttributeGUID, - schemaAttributeGUIDParameterName, - schemaAttributeBuilder.getInstanceProperties(methodName), - isMergeUpdate, - methodName); + EntityDetail schemaAttributeEntity = this.getEntityFromRepository(userId, + schemaAttributeGUID, + schemaAttributeGUIDParameterName, + attributeTypeName, + null, + null, + false, + false, + null, + methodName); + + if (schemaAttributeEntity != null) + { + /* + * Load up the builder objects. The builders manage the properties of the metadata elements that make up the schema attribute, + * and the schemaTypeHandler manages the type. + */ + SchemaAttributeBuilder schemaAttributeBuilder = new SchemaAttributeBuilder(qualifiedName, + displayName, + description, + elementPosition, + minCardinality, + maxCardinality, + isDeprecated, + defaultValueOverride, + allowsDuplicateValues, + orderedValues, + sortOrder, + minimumLength, + length, + significantDigits, + isNullable, + nativeJavaClass, + aliases, + additionalProperties, + attributeTypeId, + attributeTypeName, + extendedProperties, + repositoryHelper, + serviceName, + serverName); + + + InstanceProperties instanceProperties = schemaAttributeBuilder.getInstanceProperties(methodName); + + this.updateBeanInRepository(userId, + externalSourceGUID, + externalSourceName, + schemaAttributeGUID, + schemaAttributeGUIDParameterName, + OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_GUID, + OpenMetadataAPIMapper.SCHEMA_ATTRIBUTE_TYPE_NAME, + false, + false, + supportedZones, + instanceProperties, + true, + this.getEffectiveTime(instanceProperties), + methodName); + + SchemaTypeBuilder schemaTypeBuilder = this.getSchemaTypeBuilder(qualifiedName, + externalSchemaTypeGUID, + dataType, + defaultValue, + fixedValue, + validValuesSetGUID); + + // todo this logic assumes the schema type is stored as a classification + setClassificationInRepository(userId, + externalSourceGUID, + externalSourceName, + schemaAttributeEntity, + schemaAttributeGUIDParameterName, + attributeTypeName, + OpenMetadataAPIMapper.TYPE_EMBEDDED_ATTRIBUTE_CLASSIFICATION_TYPE_GUID, + OpenMetadataAPIMapper.TYPE_EMBEDDED_ATTRIBUTE_CLASSIFICATION_TYPE_NAME, + schemaTypeBuilder.getTypeEmbeddedInstanceProperties(methodName), + isMergeUpdate, + false, + false, + null, + methodName); + + /* + * The formula is set if the column is derived + */ + if (formula != null) + { + schemaAttributeBuilder.setCalculatedValue(userId, externalSourceGUID, externalSourceName, formula, methodName); + + setClassificationInRepository(userId, + externalSourceGUID, + externalSourceName, + schemaAttributeEntity, + schemaAttributeGUIDParameterName, + attributeTypeName, + OpenMetadataAPIMapper.TYPE_EMBEDDED_ATTRIBUTE_CLASSIFICATION_TYPE_GUID, + OpenMetadataAPIMapper.TYPE_EMBEDDED_ATTRIBUTE_CLASSIFICATION_TYPE_NAME, + schemaTypeBuilder.getTypeEmbeddedInstanceProperties(methodName), + isMergeUpdate, + false, + false, + null, + methodName); + } + } } From db8b92c458834d4c2ddff2972971ed579eb4e9d7 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:08:17 +0100 Subject: [PATCH 13/16] Move OMAG-REPOSITORY-HANDLER-0009 to ERROR from EXCEPTION Signed-off-by: Mandy Chessell --- .../commonservices/repositoryhandler/RepositoryHandler.java | 1 + .../repositoryhandler/RepositoryHandlerAuditCode.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java index f1466e6cacd..139836c9cef 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandler.java @@ -2024,6 +2024,7 @@ public void reclassifyEntity(String userId, forDuplicateProcessing, effectiveTime, methodName); + EntityProxy entityProxy = repositoryHelper.getNewEntityProxy(userId, entityDetail); Classification newClassification = metadataCollection.updateEntityClassification(userId, diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandlerAuditCode.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandlerAuditCode.java index 1c3c775b70e..4e42d9f7b47 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandlerAuditCode.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryHandlerAuditCode.java @@ -85,7 +85,7 @@ public enum RepositoryHandlerAuditCode implements AuditLogMessageSet "There is probably an error in the implementation of the repository that originated the relationship."), UNAVAILABLE_ENTITY( "OMAG-REPOSITORY-HANDLER-0009", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "A {0} entity with unique identifier {1} has been retrieved by method {2} from service {3} but it is not visible to the caller {4}: effective time is {5}; entity is effective from {6} to {7} with classifications {8}", "The system is unable to format all or part of the response because the entity either has effectivity dates that are not effective for the time that the entity is retrieved or it is classified as a memento.", "Use knowledge of the request and the contents of the repositories to determine if the entity is set up correctly or needs to be updated."), From 04e504529ec6087fee302c131abaf6fb3e4fe0c1 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 17:09:43 +0100 Subject: [PATCH 14/16] Minor message corrections Signed-off-by: Mandy Chessell --- .../BasicFilesIntegrationConnectorsAuditCode.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/files-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/basicfiles/ffdc/BasicFilesIntegrationConnectorsAuditCode.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/files-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/basicfiles/ffdc/BasicFilesIntegrationConnectorsAuditCode.java index c5ed64c895a..4e0c5bfc3e1 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/files-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/basicfiles/ffdc/BasicFilesIntegrationConnectorsAuditCode.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/files-integration-connectors/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/basicfiles/ffdc/BasicFilesIntegrationConnectorsAuditCode.java @@ -32,11 +32,11 @@ public enum BasicFilesIntegrationConnectorsAuditCode implements AuditLogMessageS "No specific action is required. This message is to confirm the configuration for the integration connector."), BAD_CONFIGURATION("BASIC-FILES-INTEGRATION-CONNECTORS-0002", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "The {0} integration connector encountered an {1} exception when opening directory {2} during the {3} method. The exception message included was {4}", "The exception is passed back to the Files Integrator OMIS in the integration daemon that is hosting " + "this connector to enable it to perform error handling. More messages are likely to follow describing the " + - "error handling that was performed. These can help to determine how to recover from this error", + "error handling that was performed. These can help to determine how to recover from this error.", "This message contains the exception that was the original cause of the problem. Use the information from the " + "exception stack trace to determine why the connector is not able to access the directory and resolve that issue. " + "Use the messages that where subsequently logged during the error handling to discover how to restart the " + @@ -52,7 +52,7 @@ public enum BasicFilesIntegrationConnectorsAuditCode implements AuditLogMessageS "ask the Egeria community for help to determine why the FileFolder asset is incomplete."), UNEXPECTED_EXC_RETRIEVING_FOLDER("BASIC-FILES-INTEGRATION-CONNECTORS-0004", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "An unexpected {0} exception was returned to the {1} integration connector by the Files Integrator OMIS {2} " + "method when trying to retrieve the FileFolder asset for directory {3} (absolute path {4}). The error message was {5}", "The exception is returned to the integration daemon that is hosting this connector to enable it to perform error handling.", @@ -68,7 +68,7 @@ public enum BasicFilesIntegrationConnectorsAuditCode implements AuditLogMessageS "No action is required unless there are errors that follow indicating that the monitoring of the directory failed to start."), UNEXPECTED_EXC_MONITOR_START("BASIC-FILES-INTEGRATION-CONNECTORS-0006", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "An unexpected {0} exception was returned to the {1} integration connector by the Apache Commons " + "FileAlterationMonitor for directory {2} while it was starting the monitoring service. The error message was {3}", "The exception is logged and the integration connector continues to synchronize metadata " + @@ -86,7 +86,7 @@ public enum BasicFilesIntegrationConnectorsAuditCode implements AuditLogMessageS "No action is required unless there are errors that follow indicating that the monitoring failed to stop."), UNEXPECTED_EXC_MONITOR_STOP("BASIC-FILES-INTEGRATION-CONNECTORS-0008", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "An unexpected {0} exception was returned to the {1} integration connector by the Apache Commons " + "FileAlterationMonitor for directory {2} while it stopping the monitoring service. The error message was {3}", "The exception is logged and the integration connector continues to shutdown.", @@ -112,7 +112,7 @@ public enum BasicFilesIntegrationConnectorsAuditCode implements AuditLogMessageS "No action is required. This message is to record the reason why the DataFolder was updated."), UNEXPECTED_EXC_FOLDER_UPDATE("BASIC-FILES-INTEGRATION-CONNECTORS-0012", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "An unexpected {0} exception was returned to the {1} integration connector when it tried to update the " + "DataFolder {2} in the metadata repositories for directory {3}. The error message was {4}", "The exception is logged and the integration connector continues to synchronize metadata.", @@ -129,7 +129,7 @@ public enum BasicFilesIntegrationConnectorsAuditCode implements AuditLogMessageS "ask the Egeria community for help to determine why the DataFile element is incomplete."), UNEXPECTED_EXC_DATA_FILE_UPDATE("BASIC-FILES-INTEGRATION-CONNECTORS-0014", - OMRSAuditLogRecordSeverity.EXCEPTION, + OMRSAuditLogRecordSeverity.ERROR, "An unexpected {0} exception was returned to the {1} integration connector when it tried to update the " + "DataFile in the metadata repositories for file {2}. The error message was {3}", "The exception is logged and the integration connector continues to synchronize metadata. " + From 605cbde5ccebddae9be8d609c72ccc0b8787e901 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 18:01:23 +0100 Subject: [PATCH 15/16] Update javadoc Signed-off-by: Mandy Chessell --- .../commonservices/generichandlers/DataFieldHandler.java | 5 +++++ .../generichandlers/DisplayDataContainerHandler.java | 4 +--- .../generichandlers/ExternalReferenceLinkHandler.java | 2 -- .../generichandlers/OpenMetadataAPIGenericHandler.java | 9 +++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DataFieldHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DataFieldHandler.java index ca51736a9fa..25ae570b696 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DataFieldHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DataFieldHandler.java @@ -20,6 +20,11 @@ import java.util.List; import java.util.Map; +/** + * Handler for data fields which are part of discovery reports. + * + * @param class of bean + */ public class DataFieldHandler extends OpenMetadataAPIGenericHandler { /** diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DisplayDataContainerHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DisplayDataContainerHandler.java index 48dea38c8fc..79edcb5bc2c 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DisplayDataContainerHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/DisplayDataContainerHandler.java @@ -31,7 +31,7 @@ public class DisplayDataContainerHandler extends private InvalidParameterHandler invalidParameterHandler; private SchemaAttributeHandler dataContainerHandler; - protected RepositoryErrorHandler errorHandler; + protected RepositoryErrorHandler errorHandler; /* initialized in constructor */ /** @@ -88,8 +88,6 @@ public DisplayDataContainerHandler(OpenMetadataAPIGenericConverter(dataContainerConverter, dataContainerClass, schemaTypeConverter, diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java index ea749750498..4fdd0c8b573 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalReferenceLinkHandler.java @@ -183,8 +183,6 @@ public String setupExternalReferenceLink(String userId, * @param effectiveTo ending time for this relationship (null for all time) * @param methodName calling method * - * @return unique identifier of 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) diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java index 2a28d2c0b4b..c11f2315533 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java @@ -13561,6 +13561,8 @@ public void updateElementToElementLink(String userId, * @param isMergeUpdate should the supplied properties be merged with existing properties (true) by replacing the just the properties with * matching names, or should the entire properties of the instance be replaced? * @param relationshipProperties properties to add to the relationship or null if no properties to add + * @param effectiveFrom the date when this element is active - null for active now + * @param effectiveTo the date when this element becomes inactive - null for active until deleted * @param methodName calling method * * @throws InvalidParameterException one of the parameters is null or invalid. @@ -15183,6 +15185,8 @@ public boolean isEntityATypeOf(String userId, * @param sequencingProperty String name of the entity property that is to be used to sequence the results. * Null means do not sequence on a property name (see SequencingOrder). * @param sequencingOrder Enum defining how the results should be ordered. + * @param forLineage the request is to support lineage retrieval this means entities with the Memento classification can be returned + * @param forDuplicateProcessing the request is for duplicate processing and so must not deduplicate * @param startingFrom the starting element number of the entities to return. * This is used when retrieving elements * beyond the first page of results. Zero means start from the first element. @@ -15191,8 +15195,9 @@ public boolean isEntityATypeOf(String userId, * @param methodName calling method * @return a list of entities matching the supplied criteria; null means no matching entities in the metadata * collection; list (even if empty) means more to receive - * @throws UserNotAuthorizedException user not authorized to issue this request. - * @throws PropertyServerException problem retrieving the entity. + * @throws InvalidParameterException bad parameter + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem retrieving the entity */ public List findEntities(String userId, String entityTypeGUID, From 646d7d9c86c37d9543f5a192efa9b5de38ab1535 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Sun, 3 Apr 2022 18:05:03 +0100 Subject: [PATCH 16/16] Correct max page size in iterator Signed-off-by: Mandy Chessell --- .../repositoryhandler/RepositoryEntitiesIterator.java | 2 +- .../repositoryhandler/RepositoryFindEntitiesIterator.java | 2 +- .../RepositoryFindRelationshipsIterator.java | 2 +- .../commonservices/repositoryhandler/RepositoryIterator.java | 5 +++-- .../repositoryhandler/RepositoryIteratorForEntities.java | 2 +- .../repositoryhandler/RepositoryRelatedEntitiesIterator.java | 5 +++-- .../repositoryhandler/RepositoryRelationshipsIterator.java | 2 +- .../RepositorySelectedEntitiesIterator.java | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryEntitiesIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryEntitiesIterator.java index 82691d94302..e63dfcd2972 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryEntitiesIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryEntitiesIterator.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java index cb54fadca1d..34ddd5495c4 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindEntitiesIterator.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +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.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindRelationshipsIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindRelationshipsIterator.java index 7f0ed13a704..5acb8a1431f 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindRelationshipsIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryFindRelationshipsIterator.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +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.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIterator.java index 470e1f468f3..8162eac54e0 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIterator.java @@ -54,9 +54,10 @@ public RepositoryIterator(RepositoryHandler repositoryHandler, this.forDuplicateProcessing = forDuplicateProcessing; this.effectiveTime = effectiveTime; this.pageSize = invalidParameterHandler.validatePaging(startingFrom, pageSize, methodName); - if(pageSize == 0) + + if (this.pageSize == 0) { - pageSize = MAX_PAGE_SIZE; + this.pageSize = MAX_PAGE_SIZE; } } } diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIteratorForEntities.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIteratorForEntities.java index ec31fe12214..43d70c4687a 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIteratorForEntities.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryIteratorForEntities.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +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.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelatedEntitiesIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelatedEntitiesIterator.java index f0d4e59de78..2a409ff6fe0 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelatedEntitiesIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelatedEntitiesIterator.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +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.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; @@ -65,7 +65,8 @@ public RepositoryRelatedEntitiesIterator(RepositoryHandler repositoryHandl int startingFrom, int pageSize, Date effectiveTime, - String methodName) throws InvalidParameterException { + String methodName) throws InvalidParameterException + { super(repositoryHandler, invalidParameterHandler, userId, diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelationshipsIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelationshipsIterator.java index 5885272cc54..00dbc0d8629 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelationshipsIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositoryRelationshipsIterator.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +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.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; diff --git a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java index 3e5a112f196..745912d1db0 100644 --- a/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java +++ b/open-metadata-implementation/common-services/repository-handler/src/main/java/org/odpi/openmetadata/commonservices/repositoryhandler/RepositorySelectedEntitiesIterator.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.commonservices.repositoryhandler; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; -import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; +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.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria;