diff --git a/open-metadata-distribution/open-metadata-assemblies/build.gradle b/open-metadata-distribution/open-metadata-assemblies/build.gradle index afa46bbc345..fd1d7a7d71e 100644 --- a/open-metadata-distribution/open-metadata-assemblies/build.gradle +++ b/open-metadata-distribution/open-metadata-assemblies/build.gradle @@ -31,11 +31,13 @@ dependencies { implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:basic-file-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector') + implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-encrypted-file-store-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-file-store-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors') implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector') + implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector') implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors') implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:elasticsearch-integration-connector') @@ -134,6 +136,7 @@ distributions { from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:basic-file-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector').jar } + from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-encrypted-file-store-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-file-store-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:discovery-service-connectors').jar } @@ -141,6 +144,7 @@ distributions { from { project(':open-metadata-implementation:adapters:open-connectors:governance-action-connectors').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector').jar } + from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors').jar } @@ -177,6 +181,7 @@ distributions { from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:basic-file-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector').jar } + from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-encrypted-file-store-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-file-store-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:discovery-service-connectors').jar } @@ -185,6 +190,7 @@ distributions { from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector').jar } + from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors').jar } from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:elasticsearch-integration-connector').jar } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/GlossaryExchangeInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/GlossaryExchangeInterface.java index 365996c16af..dfd80edb968 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/GlossaryExchangeInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/GlossaryExchangeInterface.java @@ -2032,6 +2032,7 @@ List getTermsForGlossaryCategory(String * @param assetManagerGUID unique identifier of software capability representing the caller * @param assetManagerName unique name of software capability representing the caller * @param glossaryTermGUID unique identifier of the glossary term of interest + * @param limitResultsByStatus list of statuses that the term must have * @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 diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/LineageExchangeInterface.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/LineageExchangeInterface.java index cff7ed25a71..529667dbbd9 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/LineageExchangeInterface.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/api/exchange/LineageExchangeInterface.java @@ -1556,6 +1556,7 @@ List getProcessCallers(String userId, * @param forLineage return elements marked with the Memento classification? * @param forDuplicateProcessing do not merge elements marked as duplicates? * + * @return unique identifier of the 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/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/events/AssetManagerEventType.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/events/AssetManagerEventType.java index 9c5c467b653..e1bfad3cdef 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/events/AssetManagerEventType.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/events/AssetManagerEventType.java @@ -20,17 +20,64 @@ @JsonIgnoreProperties(ignoreUnknown=true) public enum AssetManagerEventType implements Serializable { + /** + * An event that is not recognized by the local server. + */ UNKNOWN_EVENT (0, "Unknown Event", "An event that is not recognized by the local server."), + + /** + * An element has been distributed around the cohort - could be for the first time. + */ REFRESH_ELEMENT_EVENT (1, "Refresh Element", "An element has been distributed around the cohort - could be for the first time."), + + /** + * A new element has been created. + */ NEW_ELEMENT_CREATED (2, "New Element", "A new element has been created."), + + /** + * An element's properties has been updated. + */ ELEMENT_UPDATED (3, "Element Updated", "An element's properties has been updated."), + + /** + * An element and all its anchored elements have been deleted. + */ ELEMENT_DELETED (4, "Element Deleted", "An element and all its anchored elements have been deleted."), + + /** + * A classification has been added to an element. + */ ELEMENT_CLASSIFIED (5, "Element Classified", "A classification has been added to an element."), + + /** + * The properties for a classification attached to an element have been updated. + */ ELEMENT_RECLASSIFIED (6, "Element Reclassified", "The properties for a classification attached to an element have been updated."), + + /** + * A classification has been removed from an element. + */ ELEMENT_DECLASSIFIED (7, "Element Declassified", "A classification has been removed from an element."), + + /** + * An element that was once deleted has been restored. + */ ELEMENT_RESTORED (8, "Element Restored", "An element that was once deleted has been restored."), + + /** + * An element's GUID has changed. + */ ELEMENT_GUID_CHANGED (9, "Element GUID Changed", "An element's GUID has changed."), + + /** + * An element's type has changed. + */ ELEMENT_TYPE_CHANGED (10, "Element Type Changed", "An element's type has changed."), + + /** + * An element's home has changed. + */ ELEMENT_HOME_CHANGED (11, "Element Home Changed", "An element's home has changed."), ; diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/MetadataCorrelationHeader.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/MetadataCorrelationHeader.java index 3899b354f88..f6f345693db 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/MetadataCorrelationHeader.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/metadataelements/MetadataCorrelationHeader.java @@ -25,8 +25,6 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class MetadataCorrelationHeader extends MetadataCorrelationProperties { - @Serial - private static final long serialVersionUID = 1L; private Date lastSynchronized = null; @@ -91,13 +89,18 @@ public String toString() "lastSynchronized=" + lastSynchronized + ", assetManagerGUID='" + getAssetManagerGUID() + '\'' + ", assetManagerName='" + getAssetManagerName() + '\'' + - ", permittedSynchronization=" + getSynchronizationDirection() + + ", synchronizationDirection=" + getSynchronizationDirection() + ", synchronizationDescription='" + getSynchronizationDescription() + '\'' + ", externalIdentifier='" + getExternalIdentifier() + '\'' + ", externalIdentifierName='" + getExternalIdentifierName() + '\'' + ", externalIdentifierUsage='" + getExternalIdentifierUsage() + '\'' + ", externalIdentifierSource='" + getExternalIdentifierSource() + '\'' + ", keyPattern=" + getKeyPattern() + + ", externalInstanceCreatedBy='" + getExternalInstanceCreatedBy() + '\'' + + ", externalInstanceCreationTime=" + getExternalInstanceCreationTime() + + ", externalInstanceLastUpdatedBy='" + getExternalInstanceLastUpdatedBy() + '\'' + + ", externalInstanceLastUpdateTime=" + getExternalInstanceLastUpdateTime() + + ", externalInstanceVersion=" + getExternalInstanceVersion() + ", mappingProperties=" + getMappingProperties() + '}'; } 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 e02c400a619..386ee16a5b4 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 @@ -27,7 +27,8 @@ }) public class DataAssetProperties extends AssetProperties { - private boolean isReferenceAsset = false; + private boolean isReferenceAsset = false; + private String deployedImplementationType = null; /** @@ -50,6 +51,7 @@ public DataAssetProperties(DataAssetProperties template) if (template != null) { isReferenceAsset = template.getIsReferenceAsset(); + deployedImplementationType = template.getDeployedImplementationType(); } } @@ -76,6 +78,28 @@ public void setIsReferenceAsset(boolean referenceAsset) } + /** + * Retrieve the name of the technology used for this data asset. + * + * @return string name + */ + public String getDeployedImplementationType() + { + return deployedImplementationType; + } + + + /** + * Set up the name of the technology used for this data asset. + * + * @param deployedImplementationType string name + */ + public void setDeployedImplementationType(String deployedImplementationType) + { + this.deployedImplementationType = deployedImplementationType; + } + + /** * Standard toString method. * @@ -89,6 +113,7 @@ public String toString() ", versionIdentifier='" + getVersionIdentifier() + '\'' + ", technicalDescription='" + getTechnicalDescription() + '\'' + ", isReferenceAsset=" + isReferenceAsset + + ", deployedImplementationType=" + deployedImplementationType + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + ", effectiveFrom=" + getEffectiveFrom() + 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 105ae7dd1fe..979fe305e7a 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 @@ -107,6 +107,7 @@ public String toString() ", versionIdentifier='" + getVersionIdentifier() + '\'' + ", technicalDescription='" + getTechnicalDescription() + '\'' + ", isReferenceAsset=" + getIsReferenceAsset() + + ", deployedImplementationType=" + getDeployedImplementationType() + ", formula='" + formula + '\'' + ", formulaType='" + formulaType + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + 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 84606dd62a0..2abf871ef61 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 @@ -252,6 +252,7 @@ public String toString() ", encodingDescription='" + encodingDescription + '\'' + ", encodingProperties=" + encodingProperties + ", isReferenceAsset=" + getIsReferenceAsset() + + ", deployedImplementationType=" + getDeployedImplementationType() + ", technicalName='" + getTechnicalName() + '\'' + ", versionIdentifier='" + getVersionIdentifier() + '\'' + ", technicalDescription='" + getTechnicalDescription() + '\'' + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalIdentifierProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalIdentifierProperties.java index e31d6c94e1c..141fc2348a3 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalIdentifierProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ExternalIdentifierProperties.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.Date; import java.util.Map; import java.util.Objects; @@ -21,14 +22,19 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class ExternalIdentifierProperties { - private SynchronizationDirection synchronizationDirection = null; - private String synchronizationDescription = null; - private String externalIdentifier = null; - private String externalIdentifierName = null; - private String externalIdentifierUsage = null; - private String externalIdentifierSource = null; - private KeyPattern keyPattern = null; - private Map mappingProperties = null; + private SynchronizationDirection synchronizationDirection = null; + private String synchronizationDescription = null; + private String externalIdentifier = null; + private String externalIdentifierName = null; + private String externalIdentifierUsage = null; + private String externalIdentifierSource = null; + private KeyPattern keyPattern = null; + private String externalInstanceCreatedBy = null; + private Date externalInstanceCreationTime = null; + private String externalInstanceLastUpdatedBy = null; + private Date externalInstanceLastUpdateTime = null; + private long externalInstanceVersion = 0L; + private Map mappingProperties = null; /** * Default constructor @@ -55,6 +61,11 @@ public ExternalIdentifierProperties(ExternalIdentifierProperties template) externalIdentifierUsage = template.getExternalIdentifierUsage(); externalIdentifierSource = template.getExternalIdentifierSource(); keyPattern = template.getKeyPattern(); + externalInstanceCreatedBy = template.getExternalInstanceCreatedBy(); + externalInstanceCreationTime = template.getExternalInstanceCreationTime(); + externalInstanceLastUpdatedBy = template.getExternalInstanceLastUpdatedBy(); + externalInstanceLastUpdateTime = template.getExternalInstanceLastUpdateTime(); + externalInstanceVersion = template.getExternalInstanceVersion(); mappingProperties = template.getMappingProperties(); } } @@ -216,6 +227,116 @@ public KeyPattern getKeyPattern() } + /** + * Return the username of the person or process that created the instance in the external system. + * + * @return name + */ + public String getExternalInstanceCreatedBy() + { + return externalInstanceCreatedBy; + } + + + /** + * Set up the username of the person or process that created the instance in the external system. + * + * @param externalInstanceCreatedBy name + */ + public void setExternalInstanceCreatedBy(String externalInstanceCreatedBy) + { + this.externalInstanceCreatedBy = externalInstanceCreatedBy; + } + + + /** + * Return the date/time when the instance in the external system was created. + * + * @return date + */ + public Date getExternalInstanceCreationTime() + { + return externalInstanceCreationTime; + } + + + /** + * Set up the date/time when the instance in the external system was created. + * + * @param externalInstanceCreationTime date + */ + public void setExternalInstanceCreationTime(Date externalInstanceCreationTime) + { + this.externalInstanceCreationTime = externalInstanceCreationTime; + } + + + /** + * Return the username of the person or process that last updated the instance in the external system. + * + * @return name + */ + public String getExternalInstanceLastUpdatedBy() + { + return externalInstanceLastUpdatedBy; + } + + + /** + * Set up the username of the person or process that last updated the instance in the external system. + * + * @param externalInstanceLastUpdatedBy name + */ + public void setExternalInstanceLastUpdatedBy(String externalInstanceLastUpdatedBy) + { + this.externalInstanceLastUpdatedBy = externalInstanceLastUpdatedBy; + } + + + /** + * Return the date/time that the instance in the external system was last updated. + * + * @return date + */ + public Date getExternalInstanceLastUpdateTime() + { + return externalInstanceLastUpdateTime; + } + + + /** + * Set up the date/time that the instance in the external system was last updated. + * + * @param externalInstanceLastUpdateTime date + */ + public void setExternalInstanceLastUpdateTime(Date externalInstanceLastUpdateTime) + { + this.externalInstanceLastUpdateTime = externalInstanceLastUpdateTime; + } + + + /** + * Return the latest version of the element in the external system. + * + * @return long + */ + public long getExternalInstanceVersion() + { + return externalInstanceVersion; + } + + + /** + * Set up the latest version of the element in the external system. + * + * @param externalInstanceVersion long + */ + public void setExternalInstanceVersion(long externalInstanceVersion) + { + this.externalInstanceVersion = externalInstanceVersion; + } + + /** * Return any additional properties to help with the mapping of the external identifier to open * metadata elements. @@ -265,6 +386,11 @@ public String toString() ", externalIdentifierUsage='" + externalIdentifierUsage + '\'' + ", externalIdentifierSource='" + externalIdentifierSource + '\'' + ", keyPattern=" + keyPattern + + ", externalInstanceCreatedBy='" + externalInstanceCreatedBy + '\'' + + ", externalInstanceCreationTime=" + externalInstanceCreationTime + + ", externalInstanceLastUpdatedBy='" + externalInstanceLastUpdatedBy + '\'' + + ", externalInstanceLastUpdateTime='" + externalInstanceLastUpdateTime + '\'' + + ", externalInstanceVersion=" + externalInstanceVersion + ", mappingProperties=" + mappingProperties + '}'; } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/MetadataCorrelationProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/MetadataCorrelationProperties.java index 3afb60fe510..d9708622982 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/MetadataCorrelationProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/MetadataCorrelationProperties.java @@ -113,16 +113,21 @@ public void setAssetManagerName(String assetManagerName) public String toString() { return "MetadataCorrelationProperties{" + - "synchronizationDirection=" + getSynchronizationDirection() + + "assetManagerGUID='" + assetManagerGUID + '\'' + + ", assetManagerName='" + assetManagerName + '\'' + + ", synchronizationDirection=" + getSynchronizationDirection() + ", synchronizationDescription='" + getSynchronizationDescription() + '\'' + ", externalIdentifier='" + getExternalIdentifier() + '\'' + ", externalIdentifierName='" + getExternalIdentifierName() + '\'' + ", externalIdentifierUsage='" + getExternalIdentifierUsage() + '\'' + ", externalIdentifierSource='" + getExternalIdentifierSource() + '\'' + ", keyPattern=" + getKeyPattern() + + ", externalInstanceCreatedBy='" + getExternalInstanceCreatedBy() + '\'' + + ", externalInstanceCreationTime=" + getExternalInstanceCreationTime() + + ", externalInstanceLastUpdatedBy='" + getExternalInstanceLastUpdatedBy() + '\'' + + ", externalInstanceLastUpdateTime=" + getExternalInstanceLastUpdateTime() + + ", externalInstanceVersion=" + getExternalInstanceVersion() + ", mappingProperties=" + getMappingProperties() + - ", assetManagerGUID='" + assetManagerGUID + '\'' + - ", assetManagerName='" + assetManagerName + '\'' + '}'; } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ProcessProperties.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ProcessProperties.java index 10769d97a99..8cf796664e3 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ProcessProperties.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-api/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/properties/ProcessProperties.java @@ -12,16 +12,17 @@ /** * Process properties defines the properties of a process. A process is a series of steps and decisions in operation * in the organization. It is typically an automated process but may be performed by a person. - * Only set the implementationLanguage if the process is automated. + * Only set the deployedImplementationType or implementationLanguage if the process is automated - ie inherits from DeployedSoftwareComponent. */ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) public class ProcessProperties extends AssetProperties { - private String formula = null; - private String formulaType = null; - private String implementationLanguage = null; + private String formula = null; + private String formulaType = null; + private String deployedImplementationType = null; + private String implementationLanguage = null; /** * Default constructor @@ -46,6 +47,7 @@ public ProcessProperties(ProcessProperties template) formula = template.getFormula(); formulaType = template.getFormulaType(); implementationLanguage = template.getImplementationLanguage(); + deployedImplementationType = template.getDeployedImplementationType(); } } @@ -92,7 +94,29 @@ public void setFormulaType(String formulaType) /** - * Return the name of the programming language that this process is implemented in. + * Retrieve the name of the technology used for this process (DeployedComponentType only). + * + * @return string name + */ + public String getDeployedImplementationType() + { + return deployedImplementationType; + } + + + /** + * Set up the name of the technology used for this process (DeployedComponentType only). + * + * @param deployedImplementationType string name + */ + public void setDeployedImplementationType(String deployedImplementationType) + { + this.deployedImplementationType = deployedImplementationType; + } + + + /** + * Return the name of the programming language that this process is implemented in (DeployedComponentType only). * * @return string name */ @@ -103,7 +127,7 @@ public String getImplementationLanguage() /** - * Set up the name of the programming language that this process is implemented in. + * Set up the name of the programming language that this process is implemented in (DeployedComponentType only). * * @param implementationLanguage string name */ @@ -123,6 +147,7 @@ public String toString() { return "ProcessProperties{" + ", formula='" + formula + '\'' + + ", deployedImplementationType='" + deployedImplementationType + '\'' + ", implementationLanguage='" + implementationLanguage + '\'' + ", technicalName='" + getTechnicalName() + '\'' + ", versionIdentifier='" + getVersionIdentifier() + '\'' + diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/ExternalAssetManagerClient.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/ExternalAssetManagerClient.java index 6546eee7dad..c442eadbd28 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/ExternalAssetManagerClient.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-client/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/client/exchange/ExternalAssetManagerClient.java @@ -472,8 +472,8 @@ public void confirmSynchronization(String userId, requestBody, serverName, userId, - openMetadataElementGUID, - openMetadataElementTypeName); + openMetadataElementTypeName, + openMetadataElementGUID); } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/AssetManagerConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/AssetManagerConverter.java index 347ddc4a01b..534adff2cc4 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/AssetManagerConverter.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/AssetManagerConverter.java @@ -56,9 +56,8 @@ public B getNewBean(Class beanClass, */ B returnBean = beanClass.getDeclaredConstructor().newInstance(); - if (returnBean instanceof SoftwareCapabilityElement) + if (returnBean instanceof SoftwareCapabilityElement bean) { - SoftwareCapabilityElement bean = (SoftwareCapabilityElement) returnBean; AssetManagerProperties assetManagerProperties = new AssetManagerProperties(); if (entity != null) diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalIdentifierConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalIdentifierConverter.java index ee66a504058..a77e46e2368 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalIdentifierConverter.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ExternalIdentifierConverter.java @@ -123,7 +123,11 @@ public B getNewComplexBean(Class beanClass, bean.setExternalIdentifier(this.removeIdentifier(instanceProperties)); bean.setKeyPattern(this.removeKeyPattern(instanceProperties)); - bean.setMappingProperties(this.removeMappingProperties(instanceProperties)); + bean.setExternalInstanceCreatedBy(this.removeExternalInstanceCreatedBy(instanceProperties)); + bean.setExternalInstanceCreationTime(this.removeExternalInstanceCreationTime(instanceProperties)); + bean.setExternalInstanceLastUpdatedBy(this.removeExternalInstanceLastUpdatedBy(instanceProperties)); + bean.setExternalInstanceLastUpdateTime(this.removeExternalInstanceLastUpdateTime(instanceProperties)); + bean.setExternalInstanceVersion(this.removeExternalInstanceVersion(instanceProperties)); if (relationships != null) { @@ -158,6 +162,7 @@ else if (repositoryHelper.isTypeOf(serviceName, bean.setExternalIdentifierName(this.removeDescription(instanceProperties)); bean.setExternalIdentifierUsage(this.removeUsage(instanceProperties)); bean.setExternalIdentifierSource(this.removeSource(instanceProperties)); + bean.setMappingProperties(this.removeMappingProperties(instanceProperties)); bean.setLastSynchronized(this.removeLastSynchronized(instanceProperties)); } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ProcessConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ProcessConverter.java index cf8d6c995f8..95f812cf552 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ProcessConverter.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/ProcessConverter.java @@ -57,9 +57,8 @@ public B getNewBean(Class beanClass, */ B returnBean = beanClass.getDeclaredConstructor().newInstance(); - if (returnBean instanceof ProcessElement) + if (returnBean instanceof ProcessElement bean) { - ProcessElement bean = (ProcessElement) returnBean; ProcessProperties processProperties = new ProcessProperties(); if (entity != null) @@ -79,6 +78,7 @@ public B getNewBean(Class beanClass, processProperties.setFormula(this.removeFormula(instanceProperties)); processProperties.setFormulaType(this.removeFormulaType(instanceProperties)); + processProperties.setDeployedImplementationType(this.removeDeployedImplementationType(instanceProperties)); processProperties.setImplementationLanguage(this.removeImplementationLanguage(instanceProperties)); /* diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/SoftwareCapabilityConverter.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/SoftwareCapabilityConverter.java new file mode 100644 index 00000000000..ddb164d38e7 --- /dev/null +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/converters/SoftwareCapabilityConverter.java @@ -0,0 +1,125 @@ +/* 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.SoftwareCapabilityElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SoftwareCapabilitiesProperties; +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; + +/** + * SoftwareCapabilityConverter transfers the relevant properties from an Open Metadata Repository Services (OMRS) + * EntityDetail object into a SoftwareCapabilityElement bean. + */ +public class SoftwareCapabilityConverter extends AssetManagerOMASConverter +{ + /** + * Constructor + * + * @param repositoryHelper helper object to parse entity + * @param serviceName name of this component + * @param serverName local server name + */ + public SoftwareCapabilityConverter(OMRSRepositoryHelper repositoryHelper, + String serviceName, + String serverName) + { + super(repositoryHelper, serviceName, serverName); + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @Override + public B getNewBean(Class beanClass, + EntityDetail entity, + String methodName) throws PropertyServerException + { + 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 SoftwareCapabilityElement bean) + { + SoftwareCapabilitiesProperties softwareCapabilitiesProperties = new SoftwareCapabilitiesProperties(); + + if (entity != null) + { + bean.setElementHeader(this.getMetadataElementHeader(beanClass, entity, methodName)); + + InstanceProperties instanceProperties = new InstanceProperties(entity.getProperties()); + + softwareCapabilitiesProperties.setQualifiedName(this.removeQualifiedName(instanceProperties)); + softwareCapabilitiesProperties.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); + softwareCapabilitiesProperties.setTechnicalName(this.removeName(instanceProperties)); + softwareCapabilitiesProperties.setTechnicalDescription(this.removeDescription(instanceProperties)); + softwareCapabilitiesProperties.setTypeDescription(this.removeCapabilityType(instanceProperties)); + softwareCapabilitiesProperties.setVersion(this.removeCapabilityVersion(instanceProperties)); + softwareCapabilitiesProperties.setPatchLevel(this.removePatchLevel(instanceProperties)); + softwareCapabilitiesProperties.setSource(this.removeSource(instanceProperties)); + + /* + * Any remaining properties are returned in the extended properties. They are + * assumed to be defined in a subtype. + */ + softwareCapabilitiesProperties.setTypeName(bean.getElementHeader().getType().getTypeName()); + softwareCapabilitiesProperties.setExtendedProperties(this.getRemainingExtendedProperties(instanceProperties)); + + bean.setSoftwareCapabilitiesProperties(softwareCapabilitiesProperties); + } + else + { + handleMissingMetadataInstance(SoftwareCapabilitiesProperties.class.getName(), + TypeDefCategory.ENTITY_DEF, + methodName); + } + } + + return returnBean; + } + catch (IllegalAccessException | InstantiationException | ClassCastException | NoSuchMethodException | InvocationTargetException error) + { + super.handleInvalidBeanClass(beanClass.getName(), error, methodName); + } + + return null; + } + + + /** + * Using the supplied instances, return a new instance of the bean. This is used for beans that + * contain a combination of the properties from an entity and that of a connected relationship. + * + * @param beanClass name of the class to create + * @param entity entity containing the properties + * @param relationship relationship containing the properties + * @param methodName calling method + * @return bean populated with properties from the instances supplied + * @throws PropertyServerException there is a problem instantiating the bean + */ + @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/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 e0664a15327..7cf7371a98b 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 @@ -5,10 +5,12 @@ import org.odpi.openmetadata.accessservices.assetmanager.converters.AssetConverter; import org.odpi.openmetadata.accessservices.assetmanager.converters.ElementHeaderConverter; +import org.odpi.openmetadata.accessservices.assetmanager.converters.SoftwareCapabilityConverter; import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.*; import org.odpi.openmetadata.accessservices.assetmanager.properties.*; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler; +import org.odpi.openmetadata.commonservices.generichandlers.FilesAndFoldersHandler; import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; @@ -25,6 +27,7 @@ import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,7 +37,8 @@ */ public class DataAssetExchangeHandler extends ExchangeHandlerBase { - private final AssetHandler assetHandler; + private final AssetHandler assetHandler; + private final FilesAndFoldersHandler filesAndFoldersHandler; private final static String assetGUIDParameterName = "assetGUID"; @@ -79,7 +83,9 @@ public DataAssetExchangeHandler(String serviceName, publishZones, auditLog); - assetHandler = new AssetHandler<>(new AssetConverter<>(repositoryHelper, serviceName, serverName), + AssetConverter assetConverter = new AssetConverter<>(repositoryHelper, serviceName, serverName); + + assetHandler = new AssetHandler<>(assetConverter, DataAssetElement.class, serviceName, serverName, @@ -92,6 +98,24 @@ public DataAssetExchangeHandler(String serviceName, defaultZones, publishZones, auditLog); + + filesAndFoldersHandler = new FilesAndFoldersHandler<>(new SoftwareCapabilityConverter<>(repositoryHelper, serviceName, serverName), + SoftwareCapabilityElement.class, + assetConverter, + DataAssetElement.class, + assetConverter, + DataAssetElement.class, + serviceName, + serverName, + invalidParameterHandler, + repositoryHandler, + repositoryHelper, + localServerUserId, + securityVerifier, + supportedZones, + defaultZones, + publishZones, + auditLog); } @@ -206,6 +230,24 @@ public String createDataAsset(String userId, typeName = assetProperties.getTypeName(); } + Map assetExtendedProperties = new HashMap<>(); + if (assetProperties.getExtendedProperties() != null) + { + assetExtendedProperties.putAll(assetProperties.getExtendedProperties()); + } + + if (assetProperties instanceof DataStoreProperties dataStoreProperties) + { + assetExtendedProperties.put(OpenMetadataAPIMapper.PATH_NAME_PROPERTY_NAME, dataStoreProperties.getPathName()); + assetExtendedProperties.put(OpenMetadataAPIMapper.STORE_CREATE_TIME_PROPERTY_NAME, dataStoreProperties.getCreateTime()); + assetExtendedProperties.put(OpenMetadataAPIMapper.STORE_UPDATE_TIME_PROPERTY_NAME, dataStoreProperties.getModifiedTime()); + } + + if (assetExtendedProperties.isEmpty()) + { + assetExtendedProperties = null; + } + String assetGUID = assetHandler.createAssetInRepository(userId, this.getExternalSourceGUID(correlationProperties, assetManagerIsHome), this.getExternalSourceName(correlationProperties, assetManagerIsHome), @@ -215,7 +257,7 @@ public String createDataAsset(String userId, assetProperties.getTechnicalDescription(), assetProperties.getAdditionalProperties(), typeName, - assetProperties.getExtendedProperties(), + assetExtendedProperties, InstanceStatus.ACTIVE, assetProperties.getEffectiveFrom(), assetProperties.getEffectiveTo(), @@ -236,6 +278,77 @@ public String createDataAsset(String userId, effectiveTime, methodName); + if (assetProperties instanceof DataStoreProperties dataStoreProperties) + { + if ((dataStoreProperties.getEncodingType() != null) || + (dataStoreProperties.getEncodingLanguage() != null) || + (dataStoreProperties.getEncodingDescription() != null) || + (dataStoreProperties.getEncodingProperties() != null)) + { + InstanceProperties classificationProperties; + + classificationProperties = repositoryHelper.addStringPropertyToInstance(serviceName, + null, + OpenMetadataAPIMapper.ENCODING_TYPE_PROPERTY_NAME, + dataStoreProperties.getEncodingType(), + methodName); + classificationProperties = repositoryHelper.addStringPropertyToInstance(serviceName, + classificationProperties, + OpenMetadataAPIMapper.ENCODING_LANGUAGE_PROPERTY_NAME, + dataStoreProperties.getEncodingLanguage(), + methodName); + classificationProperties = repositoryHelper.addStringPropertyToInstance(serviceName, + classificationProperties, + OpenMetadataAPIMapper.ENCODING_DESCRIPTION_PROPERTY_NAME, + dataStoreProperties.getEncodingDescription(), + methodName); + classificationProperties = repositoryHelper.addStringMapPropertyToInstance(serviceName, + classificationProperties, + OpenMetadataAPIMapper.ENCODING_DESCRIPTION_PROPERTY_NAME, + dataStoreProperties.getEncodingProperties(), + methodName); + + + assetHandler.setClassificationInRepository(userId, + this.getExternalSourceGUID(correlationProperties, assetManagerIsHome), + this.getExternalSourceName(correlationProperties, assetManagerIsHome), + assetGUID, + assetGUIDParameterName, + OpenMetadataAPIMapper.DATA_STORE_TYPE_NAME, + OpenMetadataAPIMapper.DATA_STORE_ENCODING_CLASSIFICATION_GUID, + OpenMetadataAPIMapper.DATA_STORE_ENCODING_CLASSIFICATION_NAME, + classificationProperties, + true, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + } + } + + /* + * For files and folders + */ + if (((repositoryHelper.isTypeOf(serviceName, typeName, OpenMetadataAPIMapper.DATA_FILE_TYPE_NAME)) || + (repositoryHelper.isTypeOf(serviceName, typeName, OpenMetadataAPIMapper.DATA_FOLDER_TYPE_NAME))) && + (assetExtendedProperties != null) && + (assetExtendedProperties.get(OpenMetadataAPIMapper.PATH_NAME_PROPERTY_NAME) != null)) + { + final String pathNameParameterName = "assetProperties.getExtendedProperties().get(parameterName)"; + filesAndFoldersHandler.addFileAssetPath(userId, + this.getExternalSourceGUID(correlationProperties, assetManagerIsHome), + this.getExternalSourceName(correlationProperties, assetManagerIsHome), + assetGUID, + assetGUIDParameterName, + typeName, + assetProperties.getExtendedProperties().get(OpenMetadataAPIMapper.PATH_NAME_PROPERTY_NAME).toString(), + pathNameParameterName, + forLineage, + forDuplicateProcessing, + effectiveTime, + methodName); + } + this.createExternalIdentifier(userId, assetGUID, assetGUIDParameterName, @@ -724,10 +837,8 @@ public String setupRelatedDataAsset(String userId, if (relationshipProperties != null) { - if (relationshipProperties instanceof DataContentForDataSetProperties) + if (relationshipProperties instanceof DataContentForDataSetProperties dataContentForDataSetProperties) { - DataContentForDataSetProperties dataContentForDataSetProperties = (DataContentForDataSetProperties) relationshipProperties; - instanceProperties = repositoryHelper.addStringPropertyToInstance(serviceName, null, OpenMetadataAPIMapper.QUERY_ID_PROPERTY_NAME, dataContentForDataSetProperties.getQueryId(), methodName); instanceProperties = repositoryHelper.addStringPropertyToInstance(serviceName, instanceProperties, OpenMetadataAPIMapper.QUERY_PROPERTY_NAME, dataContentForDataSetProperties.getQuery(), methodName); } @@ -939,10 +1050,8 @@ public void updateAssetRelationship(String userId, if (relationshipProperties != null) { - if (relationshipProperties instanceof DataContentForDataSetProperties) + if (relationshipProperties instanceof DataContentForDataSetProperties dataContentForDataSetProperties) { - DataContentForDataSetProperties dataContentForDataSetProperties = (DataContentForDataSetProperties) relationshipProperties; - instanceProperties = repositoryHelper.addStringPropertyToInstance(serviceName, null, OpenMetadataAPIMapper.QUERY_ID_PROPERTY_NAME, dataContentForDataSetProperties.getQueryId(), methodName); instanceProperties = repositoryHelper.addStringPropertyToInstance(serviceName, instanceProperties, OpenMetadataAPIMapper.QUERY_PROPERTY_NAME, dataContentForDataSetProperties.getQuery(), methodName); } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExchangeHandlerBase.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExchangeHandlerBase.java index 6e92168b344..75ce7f07619 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExchangeHandlerBase.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/handlers/ExchangeHandlerBase.java @@ -304,6 +304,11 @@ void createExternalIdentifier(String userId, correlationProperties.getExternalIdentifierUsage(), correlationProperties.getExternalIdentifierSource(), correlationProperties.getMappingProperties(), + correlationProperties.getExternalInstanceCreatedBy(), + correlationProperties.getExternalInstanceCreationTime(), + correlationProperties.getExternalInstanceLastUpdatedBy(), + correlationProperties.getExternalInstanceLastUpdateTime(), + correlationProperties.getExternalInstanceVersion(), correlationProperties.getAssetManagerGUID(), assetManagerGUIDParameterName, correlationProperties.getAssetManagerName(), diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerRESTServices.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerRESTServices.java index 3f7a8219c70..60f3d1c616a 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerRESTServices.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/AssetManagerRESTServices.java @@ -336,6 +336,11 @@ public VoidResponse addExternalIdentifier(String serverNa requestBody.getExternalIdentifierUsage(), requestBody.getExternalIdentifierSource(), requestBody.getMappingProperties(), + requestBody.getExternalInstanceCreatedBy(), + requestBody.getExternalInstanceCreationTime(), + requestBody.getExternalInstanceLastUpdatedBy(), + requestBody.getExternalInstanceLastUpdateTime(), + requestBody.getExternalInstanceVersion(), requestBody.getAssetManagerGUID(), assetManagerGUIDParameterName, requestBody.getAssetManagerName(), @@ -439,6 +444,11 @@ public VoidResponse updateExternalIdentifier(String serve requestBody.getExternalIdentifierUsage(), requestBody.getExternalIdentifierSource(), requestBody.getMappingProperties(), + requestBody.getExternalInstanceCreatedBy(), + requestBody.getExternalInstanceCreationTime(), + requestBody.getExternalInstanceLastUpdatedBy(), + requestBody.getExternalInstanceLastUpdateTime(), + requestBody.getExternalInstanceVersion(), requestBody.getAssetManagerGUID(), assetManagerGUIDParameterName, requestBody.getAssetManagerName(), @@ -603,13 +613,13 @@ public VoidResponse removeExternalIdentifier(String serve * UserNotAuthorizedException user not authorized to issue this request * PropertyServerException problem accessing the property server */ - public VoidResponse confirmSynchronization(String serverName, - String userId, - String openMetadataElementGUID, - String openMetadataElementTypeName, - boolean forLineage, - boolean forDuplicateProcessing, - UpdateRequestBody requestBody) + public VoidResponse confirmSynchronization(String serverName, + String userId, + String openMetadataElementGUID, + String openMetadataElementTypeName, + boolean forLineage, + boolean forDuplicateProcessing, + MetadataCorrelationProperties requestBody) { final String methodName = "confirmSynchronization"; final String openMetadataElementGUIDParameterName = "openMetadataElementGUID"; @@ -625,7 +635,7 @@ public VoidResponse confirmSynchronization(String serverName, { auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getMetadataCorrelationProperties() != null)) + if (requestBody != null) { ExternalIdentifierHandler handler = instanceHandler.getExternalIdentifierHandler(userId, serverName, @@ -635,15 +645,15 @@ public VoidResponse confirmSynchronization(String serverName, openMetadataElementGUID, openMetadataElementGUIDParameterName, openMetadataElementTypeName, - requestBody.getMetadataCorrelationProperties().getExternalIdentifier(), + requestBody.getExternalIdentifier(), externalIdentifierParameterName, - requestBody.getMetadataCorrelationProperties().getAssetManagerGUID(), + requestBody.getAssetManagerGUID(), assetManagerGUIDParameterName, - requestBody.getMetadataCorrelationProperties().getAssetManagerName(), + requestBody.getAssetManagerName(), OpenMetadataAPIMapper.SOFTWARE_CAPABILITY_TYPE_NAME, forLineage, forDuplicateProcessing, - requestBody.getEffectiveTime(), + null, methodName); } else diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/LineageExchangeRESTServices.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/LineageExchangeRESTServices.java index e7a9ca10401..cf2e3591de8 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/LineageExchangeRESTServices.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-server/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/LineageExchangeRESTServices.java @@ -328,10 +328,8 @@ public VoidResponse setupProcessParent(String serverName, if (requestBody != null) { - if (requestBody.getProperties() instanceof ProcessContainmentProperties) + if (requestBody.getProperties() instanceof ProcessContainmentProperties properties) { - ProcessContainmentProperties properties = (ProcessContainmentProperties) requestBody.getProperties(); - handler.setupProcessParent(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -2244,14 +2242,23 @@ public VoidResponse setBusinessSignificant(String serverName, if (requestBody != null) { - handler.setBusinessSignificant(userId, requestBody.getMetadataCorrelationProperties(), elementGUID, + handler.setBusinessSignificant(userId, + requestBody.getMetadataCorrelationProperties(), + elementGUID, forLineage, forDuplicateProcessing, - requestBody.getEffectiveTime(), methodName); + requestBody.getEffectiveTime(), + methodName); } else { - restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + handler.setBusinessSignificant(userId, + null, + elementGUID, + forLineage, + forDuplicateProcessing, + new Date(), + methodName); } } catch (Exception error) @@ -2302,14 +2309,22 @@ public VoidResponse clearBusinessSignificant(String serverName, if (requestBody != null) { - handler.clearBusinessSignificant(userId, requestBody.getMetadataCorrelationProperties(), elementGUID, + handler.clearBusinessSignificant(userId, + requestBody.getMetadataCorrelationProperties(), + elementGUID, forLineage, forDuplicateProcessing, requestBody.getEffectiveTime(), methodName); } else { - restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + handler.clearBusinessSignificant(userId, + null, + elementGUID, + forLineage, + forDuplicateProcessing, + new Date(), + methodName); } } catch (Exception error) @@ -2362,10 +2377,8 @@ public GUIDResponse setupDataFlow(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof DataFlowProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof DataFlowProperties dataFlowProperties)) { - DataFlowProperties dataFlowProperties = (DataFlowProperties) requestBody.getProperties(); - response.setGUID(handler.setupDataFlow(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -2384,7 +2397,21 @@ public GUIDResponse setupDataFlow(String serverName, } else { - restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + response.setGUID(handler.setupDataFlow(userId, + null, + null, + assetManagerIsHome, + dataSupplierGUID, + dataConsumerGUID, + null, + null, + null, + null, + null, + forLineage, + forDuplicateProcessing, + new Date(), + methodName)); } } catch (Exception error) @@ -2504,11 +2531,10 @@ public VoidResponse updateDataFlow(String serverName, { auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof DataFlowProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof DataFlowProperties properties)) { ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - DataFlowProperties properties = (DataFlowProperties)requestBody.getProperties(); handler.updateDataFlow(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -2742,7 +2768,6 @@ public DataFlowElementsResponse getDataFlowSuppliers(String new Date(), methodName)); } - } catch (Exception error) { @@ -2794,10 +2819,8 @@ public GUIDResponse setupControlFlow(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof ControlFlowProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof ControlFlowProperties properties)) { - ControlFlowProperties properties = (ControlFlowProperties)requestBody.getProperties(); - response.setGUID(handler.setupControlFlow(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -2816,7 +2839,21 @@ public GUIDResponse setupControlFlow(String serverName, } else { - restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + response.setGUID(handler.setupControlFlow(userId, + null, + null, + assetManagerIsHome, + currentStepGUID, + nextStepGUID, + null, + null, + null, + null, + null, + forLineage, + forDuplicateProcessing, + new Date(), + methodName)); } } catch (Exception error) @@ -2938,10 +2975,8 @@ public VoidResponse updateControlFlow(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof ControlFlowProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof ControlFlowProperties properties)) { - ControlFlowProperties properties = (ControlFlowProperties)requestBody.getProperties(); - handler.updateControlFlow(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -3080,14 +3115,28 @@ public ControlFlowElementsResponse getControlFlowNextSteps(String ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - response.setElementList(handler.getControlFlowNextSteps(userId, - currentStepGUID, - startFrom, - pageSize, - forLineage, - forDuplicateProcessing, - requestBody.getEffectiveTime(), - methodName)); + if (requestBody != null) + { + response.setElementList(handler.getControlFlowNextSteps(userId, + currentStepGUID, + startFrom, + pageSize, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime(), + methodName)); + } + else + { + response.setElementList(handler.getControlFlowNextSteps(userId, + currentStepGUID, + startFrom, + pageSize, + forLineage, + forDuplicateProcessing, + new Date(), + methodName)); + } } catch (Exception error) { @@ -3139,14 +3188,28 @@ public ControlFlowElementsResponse getControlFlowPreviousSteps(String ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - response.setElementList(handler.getControlFlowPreviousSteps(userId, - currentStepGUID, - startFrom, - pageSize, - forLineage, - forDuplicateProcessing, - requestBody.getEffectiveTime(), - methodName)); + if (requestBody != null) + { + response.setElementList(handler.getControlFlowPreviousSteps(userId, + currentStepGUID, + startFrom, + pageSize, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime(), + methodName)); + } + else + { + response.setElementList(handler.getControlFlowPreviousSteps(userId, + currentStepGUID, + startFrom, + pageSize, + forLineage, + forDuplicateProcessing, + new Date(), + methodName)); + } } catch (Exception error) { @@ -3198,9 +3261,8 @@ public GUIDResponse setupProcessCall(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof ProcessCallProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof ProcessCallProperties properties)) { - ProcessCallProperties properties = (ProcessCallProperties)requestBody.getProperties(); response.setGUID(handler.setupProcessCall(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -3219,7 +3281,21 @@ public GUIDResponse setupProcessCall(String serverName, } else { - restExceptionHandler.handleNoRequestBody(userId, methodName, serverName); + response.setGUID(handler.setupProcessCall(userId, + null, + null, + assetManagerIsHome, + callerGUID, + calledGUID, + null, + null, + null, + null, + null, + forLineage, + forDuplicateProcessing, + new Date(), + methodName)); } } catch (Exception error) @@ -3341,10 +3417,8 @@ public VoidResponse updateProcessCall(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof ProcessCallProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof ProcessCallProperties properties)) { - ProcessCallProperties properties = (ProcessCallProperties) requestBody.getProperties(); - handler.updateProcessCall(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -3556,14 +3630,28 @@ public ProcessCallElementsResponse getProcessCallers(String ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - response.setElementList(handler.getProcessCallers(userId, - calledGUID, - startFrom, - pageSize, - forLineage, - forDuplicateProcessing, - requestBody.getEffectiveTime(), - methodName)); + if (requestBody != null) + { + response.setElementList(handler.getProcessCallers(userId, + calledGUID, + startFrom, + pageSize, + forLineage, + forDuplicateProcessing, + requestBody.getEffectiveTime(), + methodName)); + } + else + { + response.setElementList(handler.getProcessCallers(userId, + calledGUID, + startFrom, + pageSize, + forLineage, + forDuplicateProcessing, + new Date(), + methodName)); + } } catch (Exception error) { @@ -3615,12 +3703,11 @@ public GUIDResponse setupLineageMapping(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - String guid = null; + String guid; if (requestBody != null) { - if (requestBody.getProperties() instanceof DataFlowProperties) + if (requestBody.getProperties() instanceof DataFlowProperties properties) { - DataFlowProperties properties = (DataFlowProperties)requestBody.getProperties(); guid = handler.setupLineageMapping(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -3790,9 +3877,8 @@ public VoidResponse updateLineageMapping(String serverName, ProcessExchangeHandler handler = instanceHandler.getProcessExchangeHandler(userId, serverName, methodName); - if ((requestBody != null) && (requestBody.getProperties() instanceof LineageMappingProperties)) + if ((requestBody != null) && (requestBody.getProperties() instanceof LineageMappingProperties properties)) { - LineageMappingProperties properties = (LineageMappingProperties) requestBody.getProperties(); handler.updateLineageMapping(userId, requestBody.getAssetManagerGUID(), requestBody.getAssetManagerName(), @@ -3876,7 +3962,7 @@ public VoidResponse clearLineageMapping(String serverName lineageMappingGUID, forLineage, forDuplicateProcessing, - null, + new Date(), methodName); } } @@ -3949,7 +4035,7 @@ public LineageMappingElementsResponse getDestinationLineageMappings(String pageSize, forLineage, forDuplicateProcessing, - null, + new Date(), methodName)); } } @@ -4022,7 +4108,7 @@ public LineageMappingElementsResponse getSourceLineageMappings(String pageSize, forLineage, forDuplicateProcessing, - null, + new Date(), methodName)); } } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/AssetManagerOMASResource.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/AssetManagerOMASResource.java index 970aec47ac7..88132c15173 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/AssetManagerOMASResource.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/AssetManagerOMASResource.java @@ -209,17 +209,17 @@ public VoidResponse removeExternalIdentifier(@PathVariable String * UserNotAuthorizedException user not authorized to issue this request * PropertyServerException problem accessing the property server */ - @PostMapping(path = "/asset-managers/elements/{openMetadataElementTypeName}/{openMetadataElementGUID}/external-identifiers") + @PostMapping(path = "/asset-managers/elements/{openMetadataElementTypeName}/{openMetadataElementGUID}/synchronized") public VoidResponse confirmSynchronization(@PathVariable String serverName, @PathVariable String userId, @PathVariable String openMetadataElementGUID, @PathVariable String openMetadataElementTypeName, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody UpdateRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody MetadataCorrelationProperties requestBody) { return restAPI.confirmSynchronization(serverName, userId, openMetadataElementGUID, openMetadataElementTypeName, forLineage, forDuplicateProcessing, requestBody); } diff --git a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/LineageExchangeResource.java b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/LineageExchangeResource.java index 9973d11c9e2..775aaed8755 100644 --- a/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/LineageExchangeResource.java +++ b/open-metadata-implementation/access-services/asset-manager/asset-manager-spring/src/main/java/org/odpi/openmetadata/accessservices/assetmanager/server/spring/LineageExchangeResource.java @@ -1019,10 +1019,11 @@ public VoidResponse setBusinessSignificant(@PathVariable String @PathVariable String userId, @PathVariable String elementGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody UpdateRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + UpdateRequestBody requestBody) { return restAPI.setBusinessSignificant(serverName, userId, elementGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1049,10 +1050,11 @@ public VoidResponse clearBusinessSignificant(@PathVariable String @PathVariable String userId, @PathVariable String elementGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody UpdateRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + UpdateRequestBody requestBody) { return restAPI.clearBusinessSignificant(serverName, userId, elementGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1086,7 +1088,8 @@ public GUIDResponse setupDataFlow(@PathVariable String serverName, boolean forLineage, @RequestParam (required = false, defaultValue = "false") boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.setupDataFlow(serverName, userId, dataSupplierGUID, dataConsumerGUID, assetManagerIsHome, forLineage, forDuplicateProcessing, requestBody); } @@ -1120,7 +1123,8 @@ public DataFlowElementResponse getDataFlow(@PathVariable String serverN boolean forLineage, @RequestParam (required = false, defaultValue = "false") boolean forDuplicateProcessing, - @RequestBody NameRequestBody requestBody) + @RequestBody (required = false) + NameRequestBody requestBody) { return restAPI.getDataFlow(serverName, userId, dataSupplierGUID, dataConsumerGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1143,14 +1147,15 @@ public DataFlowElementResponse getDataFlow(@PathVariable String serverN */ @PostMapping(path = "/data-flows/{dataFlowGUID}/update") - public VoidResponse updateDataFlow(@PathVariable String serverName, - @PathVariable String userId, + public VoidResponse updateDataFlow(@PathVariable String serverName, + @PathVariable String userId, @PathVariable String dataFlowGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.updateDataFlow(serverName, userId, dataFlowGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1173,14 +1178,15 @@ public VoidResponse updateDataFlow(@PathVariable String serverName, */ @PostMapping(path = "/data-flows/{dataFlowGUID}/remove") - public VoidResponse clearDataFlow(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String dataFlowGUID, + public VoidResponse clearDataFlow(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String dataFlowGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.clearDataFlow(serverName, userId, dataFlowGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1205,16 +1211,17 @@ public VoidResponse clearDataFlow(@PathVariable String */ @PostMapping(path = "/data-flows/suppliers/{dataSupplierGUID}/consumers/retrieve") - public DataFlowElementsResponse getDataFlowConsumers(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String dataSupplierGUID, - @RequestParam int startFrom, - @RequestParam int pageSize, + public DataFlowElementsResponse getDataFlowConsumers(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String dataSupplierGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getDataFlowConsumers(serverName, userId, dataSupplierGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1239,16 +1246,17 @@ public DataFlowElementsResponse getDataFlowConsumers(@PathVariable String */ @PostMapping(path = "/data-flows/consumers/{dataConsumerGUID}/suppliers/retrieve") - public DataFlowElementsResponse getDataFlowSuppliers(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String dataConsumerGUID, - @RequestParam int startFrom, - @RequestParam int pageSize, + public DataFlowElementsResponse getDataFlowSuppliers(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String dataConsumerGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getDataFlowSuppliers(serverName, userId, dataConsumerGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1273,16 +1281,17 @@ public DataFlowElementsResponse getDataFlowSuppliers(@PathVariable String */ @PostMapping(path = "/control-flows/current-steps/{currentStepGUID}/next-steps/{nextStepGUID}") - public GUIDResponse setupControlFlow(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String currentStepGUID, - @PathVariable String nextStepGUID, - @RequestParam boolean assetManagerIsHome, + public GUIDResponse setupControlFlow(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String currentStepGUID, + @PathVariable String nextStepGUID, + @RequestParam boolean assetManagerIsHome, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.setupControlFlow(serverName, userId, currentStepGUID, nextStepGUID, assetManagerIsHome, forLineage, forDuplicateProcessing, requestBody); } @@ -1313,10 +1322,11 @@ public ControlFlowElementResponse getControlFlow(@PathVariable String s @PathVariable String currentStepGUID, @PathVariable String nextStepGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody NameRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + NameRequestBody requestBody) { return restAPI.getControlFlow(serverName, userId, currentStepGUID, nextStepGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1343,10 +1353,11 @@ public VoidResponse updateControlFlow(@PathVariable String serve @PathVariable String userId, @PathVariable String controlFlowGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.updateControlFlow(serverName, userId, controlFlowGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1369,14 +1380,15 @@ public VoidResponse updateControlFlow(@PathVariable String serve */ @PostMapping(path = "/control-flows/{controlFlowGUID}/remove") - public VoidResponse clearControlFlow(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String controlFlowGUID, + public VoidResponse clearControlFlow(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String controlFlowGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.clearControlFlow(serverName, userId, controlFlowGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1401,16 +1413,17 @@ public VoidResponse clearControlFlow(@PathVariable String */ @PostMapping(path = "/control-flows/current-steps/{currentStepGUID}/next-steps/retrieve") - public ControlFlowElementsResponse getControlFlowNextSteps(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String currentStepGUID, - @RequestParam int startFrom, - @RequestParam int pageSize, + public ControlFlowElementsResponse getControlFlowNextSteps(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String currentStepGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getControlFlowNextSteps(serverName, userId, currentStepGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1435,16 +1448,17 @@ public ControlFlowElementsResponse getControlFlowNextSteps(@PathVariable String */ @PostMapping(path = "/control-flows/current-steps/{currentStepGUID}/previous-steps/retrieve") - public ControlFlowElementsResponse getControlFlowPreviousSteps(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String currentStepGUID, - @RequestParam int startFrom, - @RequestParam int pageSize, + public ControlFlowElementsResponse getControlFlowPreviousSteps(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String currentStepGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getControlFlowPreviousSteps(serverName, userId, currentStepGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1509,10 +1523,11 @@ public ProcessCallElementResponse getProcessCall(@PathVariable String s @PathVariable String callerGUID, @PathVariable String calledGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody NameRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + NameRequestBody requestBody) { return restAPI.getProcessCall(serverName, userId, callerGUID, calledGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1542,7 +1557,8 @@ public VoidResponse updateProcessCall(@PathVariable String serve boolean forLineage, @RequestParam (required = false, defaultValue = "false") boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.updateProcessCall(serverName, userId, processCallGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1565,14 +1581,15 @@ public VoidResponse updateProcessCall(@PathVariable String serve */ @PostMapping(path = "/process-calls/{processCallGUID}/remove") - public VoidResponse clearProcessCall(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String processCallGUID, + public VoidResponse clearProcessCall(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String processCallGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.clearProcessCall(serverName, userId, processCallGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1597,16 +1614,17 @@ public VoidResponse clearProcessCall(@PathVariable String */ @PostMapping(path = "/process-calls/callers/{callerGUID}/called/retrieve") - public ProcessCallElementsResponse getProcessCalled(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String callerGUID, - @RequestParam int startFrom, - @RequestParam int pageSize, + public ProcessCallElementsResponse getProcessCalled(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String callerGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getProcessCalled(serverName, userId, callerGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1631,16 +1649,17 @@ public ProcessCallElementsResponse getProcessCalled(@PathVariable String */ @PostMapping(path = "/process-calls/called/{calledGUID}/callers/retrieve") - public ProcessCallElementsResponse getProcessCallers(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String calledGUID, - @RequestParam int startFrom, - @RequestParam int pageSize, + public ProcessCallElementsResponse getProcessCallers(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String calledGUID, + @RequestParam int startFrom, + @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getProcessCallers(serverName, userId, calledGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1674,7 +1693,8 @@ public GUIDResponse setupLineageMapping(@PathVariable String boolean forLineage, @RequestParam (required = false, defaultValue = "false") boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.setupLineageMapping(serverName, userId, sourceElementGUID, destinationElementGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1705,10 +1725,11 @@ public LineageMappingElementResponse getLineageMapping(@PathVariable String @PathVariable String sourceElementGUID, @PathVariable String destinationElementGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody NameRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + NameRequestBody requestBody) { return restAPI.getLineageMapping(serverName, userId, sourceElementGUID, destinationElementGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1735,10 +1756,11 @@ public VoidResponse updateLineageMapping(@PathVariable String @PathVariable String userId, @PathVariable String lineageMappingGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody RelationshipRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + RelationshipRequestBody requestBody) { return restAPI.updateLineageMapping(serverName, userId, lineageMappingGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1761,14 +1783,15 @@ public VoidResponse updateLineageMapping(@PathVariable String */ @PostMapping(path = "/lineage-mappings/{lineageMappingGUID}/remove") - public VoidResponse clearLineageMapping(@PathVariable String serverName, - @PathVariable String userId, - @PathVariable String lineageMappingGUID, + public VoidResponse clearLineageMapping(@PathVariable String serverName, + @PathVariable String userId, + @PathVariable String lineageMappingGUID, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.clearLineageMapping(serverName, userId, lineageMappingGUID, forLineage, forDuplicateProcessing, requestBody); } @@ -1799,10 +1822,11 @@ public LineageMappingElementsResponse getDestinationLineageMappings(@PathVariabl @RequestParam int startFrom, @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getDestinationLineageMappings(serverName, userId, sourceElementGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } @@ -1833,10 +1857,11 @@ public LineageMappingElementsResponse getSourceLineageMappings(@PathVariable Str @RequestParam int startFrom, @RequestParam int pageSize, @RequestParam (required = false, defaultValue = "false") - boolean forLineage, + boolean forLineage, @RequestParam (required = false, defaultValue = "false") - boolean forDuplicateProcessing, - @RequestBody EffectiveTimeQueryRequestBody requestBody) + boolean forDuplicateProcessing, + @RequestBody (required = false) + EffectiveTimeQueryRequestBody requestBody) { return restAPI.getSourceLineageMappings(serverName, userId, destinationElementGUID, startFrom, pageSize, forLineage, forDuplicateProcessing, requestBody); } diff --git a/open-metadata-implementation/adapters/open-connectors/data-store-connectors/README.md b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/README.md index e9ceb226ebe..4f427cc7113 100644 --- a/open-metadata-implementation/adapters/open-connectors/data-store-connectors/README.md +++ b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/README.md @@ -3,18 +3,13 @@ # Data Store Connectors -The Data Store Connectors module contains -a small collection of connectors for applications. -The aim is to eventually cover most common types of data sources. -connectors to different types of data stores. These connectors implement the +The Data Store Connectors module contains a small collection of +[resource connectors](https://egeria-project.org/concepts/digital-resource-connector/) for accessing the most common types of data sources. -[Open Connector Framework (OCF)](../../../frameworks/open-connector-framework) **Connector** interface. -* **[file-connectors](file-connectors)** provides connector to read files. - - -There is a code sample that shows how to work with the file connector +* **[file-connectors](file-connectors)** provides connector to read files. There is a code sample that shows how to work with the file connector in the [asset-management-samples](../../../../open-metadata-resources/open-metadata-samples/access-services-samples/asset-management-samples). +* **[jdbc-resource-connector](jdbc-resource-connector)** provides access to a JDBC resource through a connector. ---- * Return to [open-connectors](..) module. diff --git a/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/README.md b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/README.md new file mode 100644 index 00000000000..4edf1d09c4a --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/README.md @@ -0,0 +1,11 @@ + + + +# JDBC Resource Connector + +Provides a basic implementation of the interface javax.sql.DataSource interface in order to establish a connection to target database. Because of a method clash, the interface has been implemented as an inner class of the connector and to get the implementation, one must call: +``` +jdbcConnector.asDataSource() +``` + +See [JDBC Integration Connector](../jdbc-integration-connector/README.MD) for actual usage example. \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/build.gradle b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/build.gradle new file mode 100644 index 00000000000..75c412857dc --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/build.gradle @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Contributors to the ODPi Egeria project. + */ + +// Artifact names are taken from the directory by default, set in settings.gradle to override +// The 'name' for the maven artifact, and description are set here +description = 'JDBC Resource Connector for Egeria' + +dependencies { + compileOnly 'org.slf4j:slf4j-api' + compileOnly 'com.fasterxml.jackson.core:jackson-annotations' + compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework') + compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework') +} + diff --git a/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/resource/jdbc/JDBCResourceConnector.java b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/resource/jdbc/JDBCResourceConnector.java new file mode 100644 index 00000000000..8f7c4d52788 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/resource/jdbc/JDBCResourceConnector.java @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.adapters.connectors.resource.jdbc; + +import org.odpi.openmetadata.frameworks.connectors.ConnectorBase; + +import javax.sql.DataSource; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; + +/** + * JDBCResourceConnector provides basic implementation of {@link DataSource} interface in order to get a {@link Connection} to + * target database. This is done via a static inner class, since {@link DataSource#getConnection()} clashes with + * {@link ConnectorBase#getConnection()} + */ +public class JDBCResourceConnector extends ConnectorBase { + + /** + * Get as {@link DataSource} + * + * @return implementation + */ + public DataSource asDataSource(){ + return new JdbcConnectorAsDataSource(); + } + + private class JdbcConnectorAsDataSource implements DataSource { + + @Override + public Connection getConnection() throws SQLException { + return DriverManager.getConnection(connectionBean.getEndpoint().getAddress(), connectionBean.getUserId(), + connectionBean.getClearPassword()); + } + + @Override + public Connection getConnection(String username, String password) throws SQLException { + return DriverManager.getConnection(connectionBean.getEndpoint().getAddress(), username, password); + } + + @Override + public PrintWriter getLogWriter() throws SQLException { + return null; + } + + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + + } + + @Override + public void setLoginTimeout(int seconds) throws SQLException { + + } + + @Override + public int getLoginTimeout() throws SQLException { + return 0; + } + + @Override + public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { + return null; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/resource/jdbc/JDBCResourceConnectorProvider.java b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/resource/jdbc/JDBCResourceConnectorProvider.java new file mode 100644 index 00000000000..0fd7d23a6b0 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/data-store-connectors/jdbc-resource-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/resource/jdbc/JDBCResourceConnectorProvider.java @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.adapters.connectors.resource.jdbc; + +import org.odpi.openmetadata.frameworks.connectors.ConnectorProviderBase; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType; + +import javax.sql.DataSource; + +/** + * JDBCResourceConnectorProvider is the OCF connector provider for the jdbc resource connector. + */ +public class JDBCResourceConnectorProvider extends ConnectorProviderBase +{ + static final String connectorTypeGUID = "64463b01-92f6-4d7b-9737-f1d20b2654f4"; + static final String connectorQualifiedName = "Egeria::RelationalDbConnectors::Jdbc"; + static final String connectorDisplayName = "Relational Database JDBC Connector"; + static final String connectorTypeDescription = "Connector supports reading of metadata from relational databases using exclusively the JDBC API"; + + private static final String assetTypeName = "Database"; + + /** + * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific + * registry store implementation. + */ + public JDBCResourceConnectorProvider() { + super(); + super.setConnectorClassName(JDBCResourceConnector.class.getName()); + + ConnectorType connectorType = new ConnectorType(); + connectorType.setType(ConnectorType.getConnectorTypeType()); + connectorType.setGUID(connectorTypeGUID); + connectorType.setQualifiedName(connectorQualifiedName); + connectorType.setDisplayName(connectorDisplayName); + connectorType.setDescription(connectorTypeDescription); + connectorType.setSupportedAssetTypeName(assetTypeName); + connectorType.setConnectorProviderClassName(this.getClass().getName()); + + connectorInterfaces.add(DataSource.class.getName()); + connectorType.setConnectorInterfaces(connectorInterfaces); + + super.connectorTypeBean = connectorType; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/docs/atlas-types.drawio b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/docs/atlas-types.drawio index 2f88963995b..6b93bf94ed4 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/docs/atlas-types.drawio +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/docs/atlas-types.drawio @@ -1,668 +1,3020 @@ - - - + + + - + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - - - - + - + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + - - + + - - + + - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + - - + - + + + + - + - - + + - - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - - - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + + + + - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + + + + - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - - - - + + - + + + + - + - - + + - - + + - - + + - - + + + + - - + + - - + + - - + + - - + + - + - - + - + - + - - + + - - + + - - + + - - + + - - + + - - - - + + - - + + - + - - - - - - + - - - - - - - - - - + - - + - + + + + + + + - + - - + + - - + + - - + + - - + + - + - + - - + + - + + + + + + + - + - - + + - + + + + + + + - + - - + + - + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - + + - - + + - - + + - + - - + - + + + + + + + + + + - - - - - - + - - + + - - + + - - + + - - + + - + - - - - - - + - - + + - - + + - - + + - - + + + + - - + + - - + + - - + + - - + + + + - + + + + + + + + + + - - + - - + + - - + + - - + + - - + + - + - - + - - + + - - + + - - + + + + - - + + - - - - - - - - @@ -892,4 +3244,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasGlossaryIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasGlossaryIntegrationModule.java deleted file mode 100644 index 55ea0a23c9b..00000000000 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasGlossaryIntegrationModule.java +++ /dev/null @@ -1,2806 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas; - - -import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; -import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryCategoryElement; -import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryElement; -import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; -import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataCorrelationHeader; -import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataElement; -import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; -import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryCategoryProperties; -import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryProperties; -import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermProperties; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.NameConflictException; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryAnchorElement; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryBaseProperties; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryCategoryElement; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryElement; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryMemberBaseProperties; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryTermElement; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelatedCategoryHeader; -import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelatedTermHeader; -import org.odpi.openmetadata.frameworks.auditlog.AuditLog; -import org.odpi.openmetadata.frameworks.connectors.Connector; -import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; -import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; -import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; -import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; -import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; -import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; -import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; -import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; -import org.odpi.openmetadata.integrationservices.catalog.connector.GlossaryExchangeService; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - - -/** - * ApacheAtlasIntegrationConnector exchanges glossary terms between Apache Atlas and the open metadata ecosystem. - */ -public class ApacheAtlasGlossaryIntegrationModule extends AtlasIntegrationModuleBase -{ - private final static String atlasGUIDPropertyName = "atlasGUID"; - - private String fixedEgeriaGlossaryQualifiedName = null; - private String fixedEgeriaGlossaryGUID = null; - private String atlasGlossaryName = null; - - private final GlossaryExchangeService glossaryExchangeService; - - /** - * Constructor for the module is supplied with the runtime context in order to operate. - * - * @param connectorName name of the connector (for messages) - * @param connectionProperties connection properties used to start the connector - * @param auditLog logging destination - * @param myContext integration context - * @param targetRootURL URL to connect to Apache Atlas - * @param atlasClient client to connect to Apache Atlas - * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector - * @throws UserNotAuthorizedException - */ - public ApacheAtlasGlossaryIntegrationModule(String connectorName, - ConnectionProperties connectionProperties, - AuditLog auditLog, - CatalogIntegratorContext myContext, - String targetRootURL, - ApacheAtlasRESTClient atlasClient, - List embeddedConnectors) throws UserNotAuthorizedException - { - super(connectorName, - connectionProperties, - auditLog, - myContext, - targetRootURL, - atlasClient, - embeddedConnectors, - new String[]{"Glossary", "GlossaryCategory", "GlossaryTerm"}); - - final String methodName = "ApacheAtlasGlossaryIntegrationModule()"; - - Map configurationProperties = connectionProperties.getConfigurationProperties(); - - if (configurationProperties != null) - { - fixedEgeriaGlossaryQualifiedName = configurationProperties.get(ApacheAtlasIntegrationProvider.EGERIA_GLOSSARY_QUALIFIED_NAME_CONFIGURATION_PROPERTY).toString(); - atlasGlossaryName = configurationProperties.get(ApacheAtlasIntegrationProvider.ATLAS_GLOSSARY_NAME_CONFIGURATION_PROPERTY).toString(); - } - - /* - * Record the configuration - */ - if (auditLog != null) - { - if (fixedEgeriaGlossaryQualifiedName == null) - { - auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_ALL_EGERIA_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL)); - } - else - { - auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_SPECIFIC_EGERIA_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL, - fixedEgeriaGlossaryQualifiedName)); - } - - if (atlasGlossaryName == null) - { - auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_ALL_ATLAS_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL)); - } - else - { - auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_SPECIFIC_ATLAS_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL, atlasGlossaryName)); - } - } - - /* - * The glossaryExchangeService provides access to the open metadata API. - */ - glossaryExchangeService = myContext.getGlossaryExchangeService(); - } - - - /* ============================================================================== - * Standard methods that trigger activity. - */ - - /** - * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. - * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration - * as well as any external REST API calls to explicitly refresh the connector. - *

- * This method performs two sweeps. It first retrieves the glossary elements from Egeria and synchronizes them with Apache Atlas. - * The second sweep works through the glossaries in Apache Atlas and ensures that none have been missed out by the first sweep. - * - * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. - */ - @Override - public void refresh() throws ConnectorCheckedException - { - final String methodName = "refresh"; - - try - { - /* - * Sweep 1 - Egeria to Atlas - but only if the configuration allows the exchange. - */ - if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || - (myContext.getPermittedSynchronization() == PermittedSynchronization.TO_THIRD_PARTY)) - { - if (fixedEgeriaGlossaryQualifiedName == null) - { - /* - * Exchange all glossaries found in the open metadata ecosystem. - */ - List glossaries = glossaryExchangeService.findGlossaries(".*", 0, 0, new Date()); - - if (glossaries != null) - { - for (GlossaryElement glossary : glossaries) - { - this.processEgeriaGlossary(glossary); - } - } - } - else - { - /* - * Only exchange the specific named glossary - */ - GlossaryElement glossary = this.getGlossaryElement(fixedEgeriaGlossaryQualifiedName, methodName); - - if (glossary != null) - { - this.processEgeriaGlossary(glossary); - } - else - { - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.UNABLE_TO_RETRIEVE_EGERIA_GLOSSARY.getMessageDefinition(connectorName, - fixedEgeriaGlossaryQualifiedName)); - } - } - } - } - - /* - * Sweep 2 - Atlas to Egeria - assuming metadata synchronization is set up to copy metadata from Apache Atlas to the open metadata ecosystem. - */ - if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || - (myContext.getPermittedSynchronization() == PermittedSynchronization.FROM_THIRD_PARTY)) - { - /* - * The Atlas Glossaries are retrieved one at a time. The aim is to look for new glossaries in Apache Atlas that have no presence in - * the open metadata ecosystem. - */ - int glossaryCount = 0; - boolean requestedAtlasGlossaryMissing = (atlasGlossaryName != null); - - AtlasGlossaryElement atlasGlossary = atlasClient.getAtlasGlossary(glossaryCount); - - while (atlasGlossary != null) - { - /* - * Focus on the Atlas owned glossaries as the Egeria owned glossaries have already been synchronized. - */ - if (! this.isEgeriaOwned(atlasGlossary)) - { - /* - * This glossary has never been synchronized with the open metadata ecosystem. - */ - if (atlasGlossaryName == null) - { - /* - * The connector is configured to synchronize all Atlas glossaries. - */ - this.processAtlasGlossary(atlasGlossary); - } - else if (atlasGlossaryName.equals(atlasGlossary.getName())) - { - /* - * The specifically requested glossary has been found. - */ - this.processAtlasGlossary(atlasGlossary); - requestedAtlasGlossaryMissing = false; - } - } - - atlasGlossary = atlasClient.getAtlasGlossary(glossaryCount++); - } - - /* - * This message means that the specifically requested Atlas glossary has not been found. - * The connector will try again on the next refresh. - */ - if (requestedAtlasGlossaryMissing) - { - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.UNABLE_TO_RETRIEVE_ATLAS_GLOSSARY.getMessageDefinition(connectorName, - atlasGlossaryName)); - } - } - } - } - catch (Exception error) - { - if (auditLog != null) - { - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - error); - } - - throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - this.getClass().getName(), - methodName, - error); - } - } - - - /** - * Process an event that was published by the Asset Manager OMAS. This connector is only interested in - * glossaries, glossary categories and glossary terms. The listener is only registered if metadata is flowing - * from the open metadata ecosystem to Apache Atlas. - * - * @param event event object - */ - @Override - public void processEvent(AssetManagerOutTopicEvent event) - { - if (! myContext.isRefreshInProgress()) - { - try - { - ElementHeader elementHeader = event.getElementHeader(); - - if ((elementHeader != null) && (! isAtlasOwnedElement(elementHeader))) - { - /* - * Understand the type of the element that has changed to determine if it is of interest. - */ - if (myContext.isTypeOf(elementHeader, "Glossary")) - { - if (validGlossaryElement(elementHeader)) - { - processEgeriaGlossary(glossaryExchangeService.getGlossaryByGUID(elementHeader.getGUID(), null)); - } - } - else if (myContext.isTypeOf(elementHeader, "GlossaryTerm")) - { - if (validTermElement(elementHeader)) - { - processEgeriaGlossaryTerm(glossaryExchangeService.getGlossaryTermByGUID(elementHeader.getGUID(), null)); - } - } - else if (myContext.isTypeOf(elementHeader, "GlossaryCategory")) - { - if (validCategoryElement(elementHeader)) - { - processEgeriaGlossaryCategory(glossaryExchangeService.getGlossaryCategoryByGUID(elementHeader.getGUID(), null)); - } - } - } - } - catch (InvalidParameterException error) - { - // Ignore as likely to be a deleted element - } - catch (Exception error) - { - final String methodName = "processEvent"; - - if (auditLog != null) - { - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - error); - } - } - } - } - - - /* ============================================================================================= - * Extract the guids from elements. If the GUIDs are null then the element needs to be created. - */ - - /** - * Check that the open metadata element is from an appropriate glossary. - * - * @param elementHeader details of the element to check - * @return boolean flag - true means it is ok to process the element - * @throws ConnectorCheckedException unexpected problem connecting to Egeria. - */ - private boolean validGlossaryElement(ElementHeader elementHeader) throws ConnectorCheckedException - { - final String methodName = "validGlossaryElement"; - - if (fixedEgeriaGlossaryQualifiedName != null) - { - String glossaryGUID = elementHeader.getGUID(); - - /* - * Set up the cached glossary GUID if not already set up. - */ - if (fixedEgeriaGlossaryGUID == null) - { - GlossaryElement glossaryElement = this.getGlossaryElement(fixedEgeriaGlossaryQualifiedName, methodName); - - if (glossaryElement != null) - { - fixedEgeriaGlossaryGUID = glossaryElement.getElementHeader().getGUID(); - } - } - - return glossaryGUID.equals(fixedEgeriaGlossaryGUID); - } - - return true; - } - - - /** - * Check that the open metadata element is from an appropriate glossary. - * - * @param elementHeader details of the element to check - * @return boolean flag - true means it is ok to process the element - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - * @throws ConnectorCheckedException problem with connector mechanism - */ - private boolean validTermElement(ElementHeader elementHeader) throws ConnectorCheckedException, - InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - final String methodName = "validTermElement"; - - if (fixedEgeriaGlossaryQualifiedName != null) - { - GlossaryElement glossary = glossaryExchangeService.getGlossaryForTerm(elementHeader.getGUID(), new Date()); - - if (glossary != null) - { - /* - * Set up the cached glossary GUID if not already set up. - */ - if (fixedEgeriaGlossaryGUID == null) - { - GlossaryElement fixedGlossaryElement = this.getGlossaryElement(fixedEgeriaGlossaryQualifiedName, methodName); - - if (fixedGlossaryElement != null) - { - fixedEgeriaGlossaryGUID = fixedGlossaryElement.getElementHeader().getGUID(); - } - } - - return glossary.getElementHeader().getGUID().equals(fixedEgeriaGlossaryGUID); - } - else - { - return false; - } - } - - return true; - } - - - /** - * Check that the open metadata element is from an appropriate glossary. - * - * @param elementHeader details of the element to check - * @return boolean flag - true means it is ok to process the element - * @throws ConnectorCheckedException unexpected problem connecting to Egeria. - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - * @throws ConnectorCheckedException problem with connector mechanism - */ - private boolean validCategoryElement(ElementHeader elementHeader) throws ConnectorCheckedException, - InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - final String methodName = "validCategoryElement"; - - if (fixedEgeriaGlossaryQualifiedName != null) - { - GlossaryElement glossary = glossaryExchangeService.getGlossaryForCategory(elementHeader.getGUID(), new Date()); - - if (glossary != null) - { - /* - * Set up the cached glossary GUID if not already set up. - */ - if (fixedEgeriaGlossaryGUID == null) - { - GlossaryElement fixedGlossaryElement = this.getGlossaryElement(fixedEgeriaGlossaryQualifiedName, methodName); - - if (fixedGlossaryElement != null) - { - fixedEgeriaGlossaryGUID = fixedGlossaryElement.getElementHeader().getGUID(); - } - } - - return glossary.getElementHeader().getGUID().equals(fixedEgeriaGlossaryGUID); - } - else - { - return false; - } - } - - return true; - } - - - /** - * Return the unique identifier for the equivalent element in Apache Atlas. - * - * @param metadataElement retrieved metadata element - * @return string guid - */ - private String getAtlasGUID(MetadataElement metadataElement) - { - if (metadataElement.getCorrelationHeaders() != null) - { - for (MetadataCorrelationHeader metadataCorrelationHeader : metadataElement.getCorrelationHeaders()) - { - if (metadataCorrelationHeader.getExternalIdentifierName().equals(atlasGUIDPropertyName)) - { - return metadataCorrelationHeader.getExternalIdentifier(); - } - } - } - - return null; - } - - - /** - * Return the unique identifier for the equivalent element in Apache Atlas. - * - * @param metadataElement retrieved metadata element - * @return string guid - */ - private String retryGetAtlasGUID(GlossaryCategoryElement metadataElement) - { - try - { - GlossaryCategoryElement refreshedCategory = glossaryExchangeService.getGlossaryCategoryByGUID(metadataElement.getElementHeader().getGUID(), - new Date()); - - return this.getAtlasGUID(refreshedCategory); - } - catch (Exception notFound) - { - // try again later. - } - - return null; - } - - - /** - * Return the unique identifier for the equivalent element in Apache Atlas. - * - * @param metadataElement retrieved metadata element - * @return string guid - */ - private String retryGetAtlasGUID(GlossaryTermElement metadataElement) - { - try - { - GlossaryTermElement refreshedTerm = glossaryExchangeService.getGlossaryTermByGUID(metadataElement.getElementHeader().getGUID(), - new Date()); - - return this.getAtlasGUID(refreshedTerm); - } - catch (Exception notFound) - { - // try again later. - } - - return null; - } - - - /** - * Return the unique identifier for the equivalent element in the open metadata ecosystem. - * - * @param atlasElement retrieved atlas element - * @return string guid - */ - private String getEgeriaGUID(AtlasGlossaryBaseProperties atlasElement) - { - if (atlasElement.getAdditionalAttributes() != null) - { - Object guidProperty = atlasElement.getAdditionalAttributes().get(egeriaGUIDPropertyName); - - if (guidProperty != null) - { - return guidProperty.toString(); - } - } - - return null; - } - - - /* ================================================================ - * Determine which direction that metadata is flowing - */ - - /** - * Return a flag indicating whether an element retrieved from the open metadata ecosystem. - * - * @param elementHeader header from open metadata ecosystem - * @return boolean flag - */ - private boolean isAtlasOwnedElement(ElementHeader elementHeader) - { - return (elementHeader.getOrigin().getHomeMetadataCollectionId() != null) && - (elementHeader.getOrigin().getHomeMetadataCollectionId().equals(myContext.getAssetManagerGUID())); - } - - - /** - * Return a flag to indicate whether an atlas glossary element is owned by Egeria (open metadata ecosystem) - * or is owned by Apache Atlas. This becomes important around delete scenarios. - * - * @param properties properties of the Atlas element - * @return boolean - true means the element originated in the open metadata ecosystem - */ - private boolean isEgeriaOwned(AtlasGlossaryBaseProperties properties) - { - Map additionalAttributes = properties.getAdditionalAttributes(); - - return (additionalAttributes != null) && - (additionalAttributes.containsKey(egeriaOwnedPropertyName)) && - ("true".equals(additionalAttributes.get(egeriaOwnedPropertyName).toString())); - } - - - /* ===================================================================================== - * Take a specific glossary element and determine which way to synchronize metadata. - */ - - /** - * The connector is about to process a glossary from the open metadata ecosystem. The origin of this element is unknown. - * - * @param egeriaGlossary open metadata glossary - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - */ - private void processEgeriaGlossary(GlossaryElement egeriaGlossary) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "processEgeriaGlossary"; - - if (egeriaGlossary != null) - { - /* - * First stage is to ensure the properties of the glossary root element are synchronized. - */ - if (isAtlasOwnedElement(egeriaGlossary.getElementHeader())) - { - /* - * This element originated in Apache Atlas. The element from the open metadata ecosystem is just a copy. Therefore, - * we refresh its content from the Apache Atlas original. - */ - String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); - if (atlasGlossaryGUID != null) - { - refreshAtlasGlossaryInEgeria(atlasClient.getAtlasGlossary(atlasGlossaryGUID), egeriaGlossary); - } - else if (auditLog != null) - { - /* - * Something has caused the external identifier for this - */ - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.EGERIA_GUID_MISSING.getMessageDefinition("Glossary", - egeriaGlossary.getElementHeader().getGUID())); - } - } - else - { - /* - * This element originated in the open metadata ecosystem, so it is possible to copy it directly to Apache Atlas. - */ - refreshEgeriaGlossaryInAtlas(egeriaGlossary); - } - - /* - * Once the root element is synchronized, the categories and then the terms are synchronized. - * It is possible that these elements have different ownership to the root glossary element. - */ - processEgeriaGlossaryCategories(egeriaGlossary); - processEgeriaGlossaryTerms(egeriaGlossary); - } - } - - - /** - * The connector is processing a glossary from the open metadata ecosystem. It is ready to step through each term in the glossary. - * The origin of each term is unknown. - * - * @param glossary open metadata glossary - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - */ - private void processEgeriaGlossaryTerms(GlossaryElement glossary) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - if (glossary != null) - { - /* - * Step through the terms in the Egeria Glossary and make sure all term properties are synchronized. - */ - int startFrom = 0; - List egeriaGlossaryTerms = glossaryExchangeService.getTermsForGlossary(glossary.getElementHeader().getGUID(), - startFrom, - myContext.getMaxPageSize(), - new Date()); - - while (egeriaGlossaryTerms != null) - { - for (GlossaryTermElement egeriaGlossaryTerm : egeriaGlossaryTerms) - { - this.processEgeriaGlossaryTerm(egeriaGlossaryTerm); - } - - startFrom = startFrom + myContext.getMaxPageSize(); - egeriaGlossaryTerms = glossaryExchangeService.getTermsForGlossary(glossary.getElementHeader().getGUID(), - startFrom, - myContext.getMaxPageSize(), - new Date()); - } - } - } - - - /** - * Copy the content of open metadata ecosystem glossary term to Apache Atlas. - * - * @param glossaryTermElement open metadata glossaryTermElement - * @throws PropertyServerException problem communicating with Apache Atlas - */ - private void processEgeriaGlossaryTerm(GlossaryTermElement glossaryTermElement) throws PropertyServerException, - InvalidParameterException, - UserNotAuthorizedException - { - if (glossaryTermElement != null) - { - final String methodName = "processEgeriaGlossaryTerm"; - - if (isAtlasOwnedElement(glossaryTermElement.getElementHeader())) - { - /* - * This element originated in Apache Atlas. The element from the open metadata ecosystem is just a copy. Therefore, - * we refresh its content from the Apache Atlas original. - */ - String atlasGlossaryTermGUID = getAtlasGUID(glossaryTermElement); - if (atlasGlossaryTermGUID != null) - { - refreshAtlasGlossaryTermInEgeria(atlasClient.getAtlasGlossaryTerm(atlasGlossaryTermGUID), glossaryTermElement); - } - else if (auditLog != null) - { - /* - * Something has caused the external identifier for this - */ - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.EGERIA_GUID_MISSING.getMessageDefinition("GlossaryTerm", - glossaryTermElement.getElementHeader().getGUID())); - } - } - else - { - /* - * This element originated in the open metadata ecosystem, so it is possible to copy it directly to Apache Atlas. - */ - refreshEgeriaGlossaryTermInAtlas(glossaryTermElement, this.getDestinationAtlasGlossary(glossaryTermElement.getElementHeader())); - } - } - } - - - /** - * The connector is processing a glossary from the open metadata ecosystem. It is ready to step through each category in the glossary. - * The origin of each category is unknown. - * - * @param egeriaGlossary open metadata glossary - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - */ - private void processEgeriaGlossaryCategories(GlossaryElement egeriaGlossary) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - if (egeriaGlossary != null) - { - /* - * Step through the categories in the Egeria Glossary and make sure all category properties are synchronized. - */ - int startFrom = 0; - List egeriaGlossaryCategories = glossaryExchangeService.getCategoriesForGlossary(egeriaGlossary.getElementHeader().getGUID(), - startFrom, - myContext.getMaxPageSize(), - new Date()); - - while (egeriaGlossaryCategories != null) - { - for (GlossaryCategoryElement egeriaGlossaryCategory : egeriaGlossaryCategories) - { - this.processEgeriaGlossaryCategory(egeriaGlossaryCategory); - } - - startFrom = startFrom + myContext.getMaxPageSize(); - egeriaGlossaryCategories = glossaryExchangeService.getCategoriesForGlossary(egeriaGlossary.getElementHeader().getGUID(), - startFrom, - myContext.getMaxPageSize(), - new Date()); - } - } - } - - - /** - * Copy the content of open metadata ecosystem glossary category to Apache Atlas. - * - * @param glossaryCategoryElement open metadata glossaryCategoryElement - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - */ - private void processEgeriaGlossaryCategory(GlossaryCategoryElement glossaryCategoryElement) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "processEgeriaGlossaryCategory"; - - if (isAtlasOwnedElement(glossaryCategoryElement.getElementHeader())) - { - /* - * This element originated in Apache Atlas. The element from the open metadata ecosystem is just a copy. Therefore, - * we refresh its content from the Apache Atlas original. - */ - String atlasGlossaryCategoryGUID = getAtlasGUID(glossaryCategoryElement); - if (atlasGlossaryCategoryGUID != null) - { - refreshAtlasGlossaryCategoryInEgeria(atlasClient.getAtlasGlossaryCategory(atlasGlossaryCategoryGUID), - glossaryCategoryElement); - } - else if (auditLog != null) - { - /* - * Something has caused the external identifier for this - */ - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.EGERIA_GUID_MISSING.getMessageDefinition("GlossaryCategory", - glossaryCategoryElement.getElementHeader().getGUID())); - } - } - else - { - /* - * This element originated in the open metadata ecosystem, so it is possible to copy it directly to Apache Atlas. - */ - refreshEgeriaGlossaryCategoryInAtlas(this.getDestinationAtlasGlossary(glossaryCategoryElement.getElementHeader()), - glossaryCategoryElement); - } - } - - - /** - * Load glossary that originated in Apache Atlas into the open metadata ecosystem. - * - * @param atlasGlossaryElement glossary retrieved from Apache Atlas - * @throws PropertyServerException problem communicating with Apache Atlas - */ - private void processAtlasGlossary(AtlasGlossaryElement atlasGlossaryElement) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "processAtlasGlossary"; - - String egeriaGlossaryGUID = this.getEgeriaGUID(atlasGlossaryElement); - - if (egeriaGlossaryGUID == null) - { - /* - * Assume the glossary is Atlas-owned because it has not been synchronized with Egeria. - */ - this.createAtlasGlossaryInEgeria(atlasGlossaryElement); - this.processAtlasGlossaryCategories(atlasGlossaryElement); - this.processAtlasGlossaryTerms(atlasGlossaryElement); - } - else if (this.isEgeriaOwned(atlasGlossaryElement)) - { - GlossaryElement egeriaGlossaryElement = null; - - try - { - egeriaGlossaryElement = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, new Date()); - } - catch (InvalidParameterException missingGlossary) - { - /* - * The Egeria glossary has been unilaterally deleted - so remove the atlas equivalent. - */ - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.EGERIA_GLOSSARY_DELETED.getMessageDefinition(egeriaGlossaryGUID, atlasGlossaryElement.getName())); - } - } - - if (egeriaGlossaryElement == null) - { - atlasClient.deleteAtlasGlossary(atlasGlossaryElement); - } - else - { - this.refreshEgeriaGlossaryInAtlas(egeriaGlossaryElement); - this.processEgeriaGlossaryCategories(egeriaGlossaryElement); - this.processEgeriaGlossaryTerms(egeriaGlossaryElement); - } - } - else // Atlas Owned - { - AtlasGlossaryElement owningAtlasGlossary = atlasGlossaryElement; - GlossaryElement egeriaGlossaryElement = null; - - try - { - egeriaGlossaryElement = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, new Date()); - } - catch (InvalidParameterException missingGlossary) - { - /* - * The Egeria glossary has been unilaterally deleted - so put it back. - * First remove the GUID for the deleted glossary from the Apache Atlas Glossary - * and then make a new copy the Atlas glossary in the open metadata ecosystem. - */ - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.REPLACING_EGERIA_GLOSSARY.getMessageDefinition(egeriaGlossaryGUID, - atlasGlossaryElement.getName(), - connectorName)); - } - - owningAtlasGlossary = this.clearEgeriaGUIDFromGlossary(atlasGlossaryElement); - } - - this.refreshAtlasGlossaryInEgeria(owningAtlasGlossary, egeriaGlossaryElement); - - this.processAtlasGlossaryCategories(owningAtlasGlossary); - this.processAtlasGlossaryTerms(owningAtlasGlossary); - } - } - - - /** - * Process each glossary term attached to an Atlas glossary. - * - * @param atlasGlossaryElement glossary from Atlas which includes a list of terms for the glossary - * @throws PropertyServerException problem communicating with Egeria or Atlas - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security problem - */ - private void processAtlasGlossaryTerms(AtlasGlossaryElement atlasGlossaryElement) throws PropertyServerException, - InvalidParameterException, - UserNotAuthorizedException - { - if (atlasGlossaryElement != null) - { - if (atlasGlossaryElement.getTerms() != null) - { - for (AtlasRelatedTermHeader relatedAtlasTerm : atlasGlossaryElement.getTerms()) - { - processAtlasGlossaryTerm(atlasClient.getAtlasGlossaryTerm(relatedAtlasTerm.getTermGuid()), atlasGlossaryElement); - } - } - } - } - - - /** - * Process an individual terms from an atlas glossary - at this point we do not know if it is owned by Atlas or Egeria. - * - * @param atlasGlossaryTerm term to process - * @param atlasGlossary glossary where it came from - * @throws PropertyServerException problem communicating with Egeria or Atlas - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security problem - */ - private void processAtlasGlossaryTerm(AtlasGlossaryTermElement atlasGlossaryTerm, - AtlasGlossaryElement atlasGlossary) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - final String methodName = "processAtlasGlossaryTerm"; - - String egeriaTermGUID = this.getEgeriaGUID(atlasGlossaryTerm); - - if (egeriaTermGUID == null) - { - /* - * Assume the term is Atlas-owned because it has not been synchronized with Egeria. - */ - this.createAtlasGlossaryTermInEgeria(atlasGlossaryTerm, this.getEgeriaDestinationGlossaryForElement(atlasGlossaryTerm)); - } - else if (this.isEgeriaOwned(atlasGlossaryTerm)) - { - GlossaryTermElement egeriaGlossaryTerm = null; - - try - { - egeriaGlossaryTerm = glossaryExchangeService.getGlossaryTermByGUID(egeriaTermGUID, new Date()); - } - catch (InvalidParameterException missingTerm) - { - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.EGERIA_GLOSSARY_TERM_DELETED.getMessageDefinition(egeriaTermGUID, - atlasGlossaryTerm.getName())); - } - } - - if (egeriaGlossaryTerm == null) - { - atlasClient.deleteAtlasGlossaryTerm(atlasGlossaryTerm); - } - else - { - this.refreshEgeriaGlossaryTermInAtlas(egeriaGlossaryTerm, atlasGlossary); - } - } - else // Atlas Owned - { - AtlasGlossaryTermElement owningAtlasTerm = atlasGlossaryTerm; - GlossaryTermElement egeriaGlossaryTerm = null; - - try - { - egeriaGlossaryTerm = glossaryExchangeService.getGlossaryTermByGUID(egeriaTermGUID, new Date()); - } - catch (InvalidParameterException missingTerm) - { - /* - * The Egeria glossary term has been unilaterally deleted - so put it back. - * First remove the GUID for the deleted glossary from the Apache Atlas Glossary - * and then make a new copy the Atlas glossary in the open metadata ecosystem. - */ - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.REPLACING_EGERIA_GLOSSARY_TERM.getMessageDefinition(egeriaTermGUID, - atlasGlossaryTerm.getName(), - connectorName)); - } - owningAtlasTerm = this.clearEgeriaGUIDFromTerm(atlasGlossaryTerm); - } - - if (egeriaGlossaryTerm == null) - { - this.createAtlasGlossaryTermInEgeria(owningAtlasTerm, - this.getEgeriaDestinationGlossaryForElement(owningAtlasTerm)); - } - else - { - this.refreshAtlasGlossaryTermInEgeria(owningAtlasTerm, egeriaGlossaryTerm); - } - } - } - - - /** - * Step through all the categories in an Atlas glossary to determine what needs to be synchronized. - * - * @param atlasGlossaryElement atlas glossary to process - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - */ - private void processAtlasGlossaryCategories(AtlasGlossaryElement atlasGlossaryElement) throws PropertyServerException, - InvalidParameterException, - UserNotAuthorizedException - { - if (atlasGlossaryElement != null) - { - if (atlasGlossaryElement.getCategories() != null) - { - for (AtlasRelatedCategoryHeader relatedAtlasCategory : atlasGlossaryElement.getCategories()) - { - processAtlasGlossaryCategory(atlasClient.getAtlasGlossaryCategory(relatedAtlasCategory.getCategoryGuid()), - atlasGlossaryElement); - } - } - } - } - - - /** - * Synchronize a specific category found in Apache Atlas - the origin of this element is not known at the start. - * - * @param atlasGlossaryCategory category of interest - * @param atlasGlossary full list of glossary contents - * @throws PropertyServerException problem communicating with Egeria or Atlas - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security problem - */ - private void processAtlasGlossaryCategory(AtlasGlossaryCategoryElement atlasGlossaryCategory, - AtlasGlossaryElement atlasGlossary) throws PropertyServerException, - InvalidParameterException, - UserNotAuthorizedException - { - final String methodName = "processAtlasGlossaryCategory"; - - String egeriaCategoryGUID = this.getEgeriaGUID(atlasGlossaryCategory); - - if (egeriaCategoryGUID == null) - { - /* - * Assume the category is Atlas-owned because it has not been synchronized with Egeria. - */ - this.createAtlasGlossaryCategoryInEgeria(atlasGlossaryCategory, this.getEgeriaDestinationGlossaryForElement(atlasGlossaryCategory)); - } - else if (this.isEgeriaOwned(atlasGlossaryCategory)) - { - GlossaryCategoryElement egeriaGlossaryCategory = null; - - try - { - egeriaGlossaryCategory = glossaryExchangeService.getGlossaryCategoryByGUID(egeriaCategoryGUID, new Date()); - } - catch (InvalidParameterException missingCategory) - { - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.EGERIA_GLOSSARY_CATEGORY_DELETED.getMessageDefinition(egeriaCategoryGUID, - atlasGlossaryCategory.getName())); - } - } - - if (egeriaGlossaryCategory == null) - { - atlasClient.deleteAtlasGlossaryCategory(atlasGlossaryCategory); - } - else - { - this.refreshEgeriaGlossaryCategoryInAtlas(atlasGlossary, egeriaGlossaryCategory); - } - } - else // Atlas Owned - { - AtlasGlossaryCategoryElement owningAtlasCategory = atlasGlossaryCategory; - GlossaryCategoryElement egeriaGlossaryCategory = null; - - try - { - egeriaGlossaryCategory = glossaryExchangeService.getGlossaryCategoryByGUID(egeriaCategoryGUID, new Date()); - } - catch (InvalidParameterException missingCategory) - { - /* - * The Egeria glossary category has been unilaterally deleted - so put it back. - * First remove the GUID for the deleted glossary from the Apache Atlas Glossary - * and then make a new copy the Atlas glossary in the open metadata ecosystem. - */ - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.REPLACING_EGERIA_GLOSSARY_CATEGORY.getMessageDefinition(egeriaCategoryGUID, - atlasGlossaryCategory.getName(), - connectorName)); - } - owningAtlasCategory = this.clearEgeriaGUIDFromCategory(atlasGlossaryCategory); - } - - if (egeriaGlossaryCategory == null) - { - this.createAtlasGlossaryCategoryInEgeria(owningAtlasCategory, - this.getEgeriaDestinationGlossaryForElement(owningAtlasCategory)); - } - else - { - this.refreshAtlasGlossaryCategoryInEgeria(owningAtlasCategory, egeriaGlossaryCategory); - } - } - } - - - /* ====================================================================== - * Control the exchange of metadata in one direction. Callers have determined the correct direction - * that metadata is flowing. - */ - - /** - * Copy the content of open metadata ecosystem glossary to Apache Atlas. - * - * @param egeriaGlossaryElement open metadata glossary - */ - private void refreshEgeriaGlossaryInAtlas(GlossaryElement egeriaGlossaryElement) - { - if (egeriaGlossaryElement != null) - { - AtlasGlossaryElement atlasGlossary = this.getDestinationAtlasGlossary(egeriaGlossaryElement.getElementHeader()); - - if (auditLog != null) - { - final String methodName = "refreshEgeriaGlossaryTermInAtlas"; - String atlasGlossaryName = null; - - if (atlasGlossary != null) - { - atlasGlossaryName = atlasGlossary.getName(); - } - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_EGERIA_GLOSSARY.getMessageDefinition(connectorName, - egeriaGlossaryElement.getGlossaryProperties().getDisplayName(), - egeriaGlossaryElement.getElementHeader().getGUID(), - atlasGlossaryName)); - } - } - } - - - /** - * Copy the content of open metadata ecosystem glossary term to Apache Atlas. - * This is called when a change is made to a glossary term in the open metadata ecosystem. - * There are lots of strange timing windows with events and so any anomaly found in the open metadata system - * results in the term being ignored. - * - * @param egeriaGlossaryTerm open metadata glossary term - * @param atlasGlossaryDestination the Atlas glossary where the term is to be copied to - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security problem - * @throws PropertyServerException problem communicating either with the open metadata access server or Apache Atlas - */ - private void refreshEgeriaGlossaryTermInAtlas(GlossaryTermElement egeriaGlossaryTerm, - AtlasGlossaryElement atlasGlossaryDestination) throws PropertyServerException, InvalidParameterException, UserNotAuthorizedException - { - final String methodName = "refreshEgeriaGlossaryTermInAtlas"; - - if (egeriaGlossaryTerm != null) - { - String atlasGlossaryTermGUID = this.getAtlasGUID(egeriaGlossaryTerm); - AtlasGlossaryTermElement atlasGlossaryTerm = null; - - if (atlasGlossaryTermGUID == null) - { - GlossaryElement egeriaGlossary = null; - - try - { - egeriaGlossary = glossaryExchangeService.getGlossaryForTerm(egeriaGlossaryTerm.getElementHeader().getGUID(), new Date()); - } - catch (Exception error) - { - /* - * The glossary is not found - ignore the term for now - it is probably a timing window and the term is about to be deleted - */ - if (auditLog != null) - { - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - error); - } - } - - if (egeriaGlossary != null) - { - String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); - - if (atlasGlossaryGUID != null) - { - atlasGlossaryTerm = this.getAtlasGlossaryTermProperties(egeriaGlossaryTerm, null, atlasGlossaryDestination); - - int termNameIndex = 1; - while (atlasGlossaryTermGUID == null) - { - try - { - atlasGlossaryTermGUID = atlasClient.createAtlasGlossaryTerm(atlasGlossaryTerm); - } - catch (NameConflictException conflictException) - { - atlasGlossaryTermGUID = retryGetAtlasGUID(egeriaGlossaryTerm); - - if (atlasGlossaryTermGUID == null) - { - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.TERM_ALREADY_EXISTS.getMessageDefinition(atlasGlossaryTerm.getName())); - } - - atlasGlossaryTerm.setName(egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName() + " (" + termNameIndex++ + ")"); - } - } - } - - if (auditLog != null) - { - - String atlasTermName = atlasGlossaryTermGUID; - - if (atlasGlossaryTerm != null) - { - atlasTermName = atlasGlossaryTerm.getName(); - } - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_EGERIA_GLOSSARY_TERM.getMessageDefinition(connectorName, - egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), - egeriaGlossaryTerm.getElementHeader().getGUID(), - atlasTermName)); - } - - atlasGlossaryTerm.setGuid(atlasGlossaryTermGUID); - } - } - } - - if (atlasGlossaryTermGUID != null) - { - /* - * The term exists in Atlas so just update its properties. - */ - if (atlasGlossaryTerm == null) - { - atlasGlossaryTerm = this.getAtlasGlossaryTermProperties(egeriaGlossaryTerm, - atlasGlossaryTermGUID, - atlasGlossaryDestination); - } - - this.ensureAtlasExternalIdentifier(egeriaGlossaryTerm, atlasGlossaryTermGUID); - - List categories = glossaryExchangeService.getCategoriesForTerm(egeriaGlossaryTerm.getElementHeader().getGUID(), - 0, - myContext.getMaxPageSize(), - new Date()); - if (categories != null) - { - List atlasCategories = new ArrayList<>(); - - for (GlossaryCategoryElement category : categories) - { - String atlasCategoryGUID = this.getAtlasGUID(category); - - if (atlasCategoryGUID != null) - { - AtlasRelatedCategoryHeader atlasCategory = new AtlasRelatedCategoryHeader(); - - atlasCategory.setCategoryGuid(atlasCategoryGUID); - - atlasCategories.add(atlasCategory); - } - } - - if (! atlasCategories.isEmpty()) - { - atlasGlossaryTerm.setCategories(atlasCategories); - } - } - - atlasClient.saveAtlasGlossaryTerm(atlasGlossaryTerm); - } - } - } - - - /** - * Copy the content of open metadata ecosystem glossary to Apache Atlas. - * - * @param atlasGlossaryDestination information about the Apache Atlas glossary where the Egeria category is to be copied. - * @param egeriaGlossaryCategory open metadata glossary category - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security problem - * @throws PropertyServerException problem communicating either with the open metadata access server or Apache Atlas - */ - private void refreshEgeriaGlossaryCategoryInAtlas(AtlasGlossaryElement atlasGlossaryDestination, - GlossaryCategoryElement egeriaGlossaryCategory) throws PropertyServerException, - InvalidParameterException, - UserNotAuthorizedException - { - final String methodName = "refreshEgeriaGlossaryCategoryInAtlas"; - - if (egeriaGlossaryCategory != null) - { - String atlasGlossaryCategoryGUID = this.getAtlasGUID(egeriaGlossaryCategory); - AtlasGlossaryCategoryElement atlasGlossaryCategory = null; - - if (atlasGlossaryCategoryGUID == null) - { - GlossaryElement egeriaGlossary = null; - - try - { - egeriaGlossary = glossaryExchangeService.getGlossaryForCategory(egeriaGlossaryCategory.getElementHeader().getGUID(), new Date()); - } - catch (Exception error) - { - /* - * The glossary is not found - ignore the term for now - it is probably a timing window and the term is about to be deleted - */ - if (auditLog != null) - { - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - error); - } - } - - if (egeriaGlossary != null) - { - String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); - - if (atlasGlossaryGUID != null) - { - atlasGlossaryCategory = this.getAtlasGlossaryCategoryProperties(egeriaGlossaryCategory, null, atlasGlossaryDestination); - - int categoryNameIndex = 1; - while (atlasGlossaryCategoryGUID == null) - { - try - { - atlasGlossaryCategoryGUID = atlasClient.createAtlasGlossaryCategory(atlasGlossaryCategory); - } - catch (NameConflictException conflictException) - { - atlasGlossaryCategoryGUID = retryGetAtlasGUID(egeriaGlossaryCategory); - - if (atlasGlossaryCategoryGUID == null) - { - if (auditLog != null) - { - auditLog.logMessage(methodName, - ApacheAtlasAuditCode.CATEGORY_ALREADY_EXISTS.getMessageDefinition( - atlasGlossaryCategory.getName())); - } - - atlasGlossaryCategory.setName(egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName() + " (" + categoryNameIndex++ + ")"); - } - } - } - - if (auditLog != null) - { - - String atlasCategoryName = atlasGlossaryCategoryGUID; - - if (atlasGlossaryCategory != null) - { - atlasCategoryName = atlasGlossaryCategory.getName(); - } - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_EGERIA_GLOSSARY_CATEGORY.getMessageDefinition(connectorName, - egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), - egeriaGlossaryCategory.getElementHeader().getGUID(), - atlasCategoryName)); - } - - atlasGlossaryCategory.setGuid(atlasGlossaryCategoryGUID); - } - } - } - - if (atlasGlossaryCategoryGUID != null) - { - this.ensureAtlasExternalIdentifier(egeriaGlossaryCategory, atlasGlossaryCategoryGUID); - - /* - * The term exists in Atlas so just update its properties. - */ - if (atlasGlossaryCategory == null) - { - atlasGlossaryCategory = this.getAtlasGlossaryCategoryProperties(egeriaGlossaryCategory, - atlasGlossaryCategoryGUID, - atlasGlossaryDestination); - } - - GlossaryCategoryElement parentCategory = glossaryExchangeService.getGlossaryCategoryParent(egeriaGlossaryCategory.getElementHeader().getGUID(), - new Date()); - - if (parentCategory != null) - { - String atlasParentGUID = this.getAtlasGUID(parentCategory); - - if (atlasParentGUID != null) - { - AtlasRelatedCategoryHeader atlasParent = new AtlasRelatedCategoryHeader(); - atlasParent.setCategoryGuid(atlasParentGUID); - - atlasGlossaryCategory.setParentCategory(atlasParent); - } - } - - atlasClient.saveAtlasGlossaryCategory(atlasGlossaryCategory); - - if (auditLog != null) - { - String atlasCategoryName = atlasGlossaryCategoryGUID; - - if (atlasGlossaryCategory != null) - { - atlasCategoryName = atlasGlossaryCategory.getName(); - } - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_EGERIA_GLOSSARY_CATEGORY.getMessageDefinition(connectorName, - egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), - egeriaGlossaryCategory.getElementHeader().getGUID(), - atlasCategoryName)); - } - } - } - } - - - /** - * Copy the content of the Apache Atlas glossary to the open metadata ecosystem. - * - * @param atlasGlossaryElement atlas glossary - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security error - * @throws PropertyServerException problem communicating with Apache Atlas or Egeria - */ - private void refreshAtlasGlossaryInEgeria(AtlasGlossaryElement atlasGlossaryElement, - GlossaryElement egeriaGlossaryElement) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - final String methodName = "refreshAtlasGlossaryInEgeria"; - - /* - * The glossary information is successfully retrieved from Apache Atlas. - */ - if (atlasGlossaryElement != null) - { - if (egeriaGlossaryElement == null) - { - /* - * Create Glossary in Egeria and add the new Glossary's GUID to atlas. - */ - atlasGlossaryElement = this.createAtlasGlossaryInEgeria(atlasGlossaryElement); - - String egeriaGlossaryGUID = this.getEgeriaGUID(atlasGlossaryElement); - - if (egeriaGlossaryGUID != null) - { - egeriaGlossaryElement = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, new Date()); - } - } - else - { - GlossaryProperties glossaryProperties = this.getEgeriaGlossaryProperties(atlasGlossaryElement); - - glossaryExchangeService.updateGlossary(getEgeriaGUID(atlasGlossaryElement), - null, - true, - glossaryProperties, - null); - } - - if (auditLog != null) - { - String egeriaQualifiedName = null; - String egeriaGUID = null; - - if (egeriaGlossaryElement != null) - { - egeriaQualifiedName = egeriaGlossaryElement.getGlossaryProperties().getQualifiedName(); - egeriaGUID = egeriaGlossaryElement.getElementHeader().getGUID(); - } - - if (auditLog != null) - { - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_ATLAS_GLOSSARY.getMessageDefinition(connectorName, - atlasGlossaryElement.getName(), - egeriaQualifiedName, - egeriaGUID)); - } - } - } - } - - - /** - * Create a new glossary in the open metadata ecosystem that matches a glossary from Atlas. - * - * @param atlasGlossaryElement glossary from Atlas that is to be copied to Egeria - * @return Atlas glossary updated with GUID from Egeria - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private AtlasGlossaryElement createAtlasGlossaryInEgeria(AtlasGlossaryElement atlasGlossaryElement) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryElement.getGuid()); - GlossaryProperties glossaryProperties = this.getEgeriaGlossaryProperties(atlasGlossaryElement); - - String glossaryGUID = glossaryExchangeService.createGlossary(true, - externalIdentifierProperties, - glossaryProperties); - - if (auditLog != null) - { - final String methodName = "createAtlasGlossaryInEgeria"; - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_ATLAS_GLOSSARY.getMessageDefinition(connectorName, - atlasGlossaryElement.getName(), - glossaryProperties.getQualifiedName(), - glossaryGUID)); - } - - /* - * Save the glossaryGUID from Egeria in the Atlas Glossary's AdditionalAttributes. - */ - Map glossaryAdditionalAttributes = atlasGlossaryElement.getAdditionalAttributes(); - if (glossaryAdditionalAttributes == null) - { - glossaryAdditionalAttributes = new HashMap<>(); - } - - glossaryAdditionalAttributes.put(egeriaGUIDPropertyName, glossaryGUID); - glossaryAdditionalAttributes.put(egeriaOwnedPropertyName, false); - atlasGlossaryElement.setAdditionalAttributes(glossaryAdditionalAttributes); - - return atlasClient.saveAtlasGlossary(atlasGlossaryElement); - } - - - /** - * Copy the content of the Apache Atlas glossary term to the open metadata ecosystem. - * - * @param atlasGlossaryTerm atlas glossary term - * @param egeriaGlossaryTerm glossary term to update - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void refreshAtlasGlossaryTermInEgeria(AtlasGlossaryTermElement atlasGlossaryTerm, - GlossaryTermElement egeriaGlossaryTerm) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - GlossaryTermProperties glossaryTermProperties = this.getEgeriaGlossaryTermProperties(atlasGlossaryTerm); - - glossaryExchangeService.updateGlossaryTerm(egeriaGlossaryTerm.getElementHeader().getGUID(), - atlasGlossaryTerm.getGuid(), - false, - glossaryTermProperties, - new Date()); - - if (auditLog != null) - { - final String methodName = "refreshAtlasGlossaryTermInEgeria"; - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_ATLAS_GLOSSARY_TERM.getMessageDefinition(connectorName, - atlasGlossaryTerm.getName(), - glossaryTermProperties.getQualifiedName(), - egeriaGlossaryTerm.getElementHeader().getGUID())); - } - - this.setUpTermCategoriesInEgeria(egeriaGlossaryTerm.getElementHeader().getGUID(), atlasGlossaryTerm); - this.setUpTermRelationshipsInEgeria(egeriaGlossaryTerm.getElementHeader().getGUID(), atlasGlossaryTerm); - } - - - /** - * Set up an Atlas glossary in the open metadata ecosystem. - * - * @param atlasGlossaryTerm term retrieved from Apache Atlas - * @param destinationGlossary Glossary in the open metadata ecosystem to create the term in - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void createAtlasGlossaryTermInEgeria(AtlasGlossaryTermElement atlasGlossaryTerm, - GlossaryElement destinationGlossary) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryTerm.getGuid()); - GlossaryTermProperties glossaryTermProperties = this.getEgeriaGlossaryTermProperties(atlasGlossaryTerm); - - String egeriaTermGUID = glossaryExchangeService.createGlossaryTerm(destinationGlossary.getElementHeader().getGUID(), - true, - externalIdentifierProperties, - glossaryTermProperties, - new Date()); - - if (auditLog != null) - { - final String methodName = "createAtlasGlossaryTermInEgeria"; - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_ATLAS_GLOSSARY_TERM.getMessageDefinition(connectorName, - atlasGlossaryTerm.getName(), - glossaryTermProperties.getQualifiedName(), - egeriaTermGUID)); - } - - /* - * Save the egeriaTermGUID from Egeria in the Atlas Glossary Term's AdditionalAttributes. - */ - Map glossaryAdditionalAttributes = atlasGlossaryTerm.getAdditionalAttributes(); - if (glossaryAdditionalAttributes == null) - { - glossaryAdditionalAttributes = new HashMap<>(); - } - - glossaryAdditionalAttributes.put(egeriaGUIDPropertyName, egeriaTermGUID); - glossaryAdditionalAttributes.put(egeriaOwnedPropertyName, false); - atlasGlossaryTerm.setAdditionalAttributes(glossaryAdditionalAttributes); - - atlasClient.saveAtlasGlossaryTerm(atlasGlossaryTerm); - - this.setUpTermCategoriesInEgeria(egeriaTermGUID, atlasGlossaryTerm); - this.setUpTermRelationshipsInEgeria(egeriaTermGUID, atlasGlossaryTerm); - } - - - /** - * Return the Egeria glossary that matches the glossary where this Atlas element originates from. - * - * @param atlasGlossaryMember element to determine the glossary for - * @return atlas glossary or null - */ - private GlossaryElement getEgeriaDestinationGlossaryForElement(AtlasGlossaryMemberBaseProperties atlasGlossaryMember) - { - if (atlasGlossaryMember != null) - { - AtlasGlossaryAnchorElement glossaryAnchorElement = atlasGlossaryMember.getAnchor(); - - if (glossaryAnchorElement != null) - { - try - { - AtlasGlossaryElement atlasGlossary = atlasClient.getAtlasGlossary(glossaryAnchorElement.getGlossaryGuid()); - - if (atlasGlossary != null) - { - String egeriaGlossaryGUID = getEgeriaGUID(atlasGlossary); - - if (egeriaGlossaryGUID != null) - { - return glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, new Date()); - } - } - } - catch (Exception notFound) - { - /* - * The glossary is not found - ignore the element for now - it is probably a timing window, and it is about to be deleted. - */ - if (auditLog != null) - { - final String methodName = "getEgeriaDestinationGlossaryForElement"; - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - notFound.getClass().getName(), - methodName, - notFound.getMessage()), - notFound); - } - } - } - } - - return null; - } - - - /** - * Retrieve the up-to-date Atlas Glossary to use to update either a glossary term or category. - * The Atlas glossary ahs not yet been created, it is created. If it already exists, it is updated with the latest - * information from Egeria before being returned. - * - * @param elementHeader term or category header. - * @return atlas glossary element - or null if not possible to synchronize with Apache Atlas - */ - private AtlasGlossaryElement getDestinationAtlasGlossary(ElementHeader elementHeader) - { - try - { - GlossaryElement egeriaGlossary = null; - - /* - * Understand the type of the element since it affects how the glossary is located. - */ - if (myContext.isTypeOf(elementHeader, "Glossary")) - { - egeriaGlossary = glossaryExchangeService.getGlossaryByGUID(elementHeader.getGUID(), null); - } - else if (myContext.isTypeOf(elementHeader, "GlossaryTerm")) - { - egeriaGlossary = glossaryExchangeService.getGlossaryForTerm(elementHeader.getGUID(), null); - } - else if (myContext.isTypeOf(elementHeader, "GlossaryCategory")) - { - egeriaGlossary = glossaryExchangeService.getGlossaryForCategory(elementHeader.getGUID(), null); - } - - if ((egeriaGlossary != null) && (egeriaGlossary.getGlossaryProperties() != null)) - { - String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); - - if (atlasGlossaryGUID == null) - { - /* - * Need to create the glossary - */ - AtlasGlossaryElement atlasGlossaryElement = this.getAtlasGlossaryProperties(egeriaGlossary, null); - - atlasGlossaryGUID = atlasClient.createAtlasGlossary(atlasGlossaryElement); - - this.ensureAtlasExternalIdentifier(egeriaGlossary, atlasGlossaryGUID); - } - else - { - /* - * Update the glossary properties in case they have changed. - */ - AtlasGlossaryElement atlasGlossaryElement = this.getAtlasGlossaryProperties(egeriaGlossary, - atlasClient.getAtlasGlossary(atlasGlossaryGUID)); - - atlasClient.saveAtlasGlossary(atlasGlossaryElement); - - this.ensureAtlasExternalIdentifier(egeriaGlossary, atlasGlossaryElement.getGuid()); - } - - if (atlasGlossaryGUID != null) - { - return atlasClient.getAtlasGlossary(atlasGlossaryGUID); - } - - } - } - catch (Exception notFound) - { - final String methodName = "getDestinationAtlasGlossary"; - /* - * The Egeria glossary is not found - ignore the element for now - it is probably a timing window and the term is about to be deleted. - */ - if (auditLog != null) - { - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - notFound.getClass().getName(), - methodName + "(" + elementHeader.getGUID() + ")", - notFound.getMessage()), - notFound); - } - } - - return null; - } - - - /** - * Set up the relationships between a glossary term and its categories defined in Atlas. - * - * @param egeriaTermGUID glossary term to work with - * @param atlasGlossaryTerm atlas equivalent that includes its categories - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void setUpTermCategoriesInEgeria(String egeriaTermGUID, - AtlasGlossaryTermElement atlasGlossaryTerm) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - if (atlasGlossaryTerm.getCategories() != null) - { - for (AtlasRelatedCategoryHeader relatedCategory : atlasGlossaryTerm.getCategories()) - { - AtlasGlossaryCategoryElement atlasGlossaryCategory = atlasClient.getAtlasGlossaryCategory(relatedCategory.getCategoryGuid()); - - if (atlasGlossaryCategory != null) - { - String egeriaCategoryGUID = this.getEgeriaGUID(atlasGlossaryCategory); - - if (egeriaCategoryGUID != null) - { - glossaryExchangeService.setupTermCategory(egeriaCategoryGUID, egeriaTermGUID, null, new Date()); - } - } - } - } - - /* - * This next piece ensures that atlas category relationships that have been deleted are no longer represented in the open metadata ecosystem. - */ - Map atlasCategories = getAtlasCategoriesForElement(atlasGlossaryTerm.getCategories()); - - int startFrom = 0; - List linkedCategories = glossaryExchangeService.getCategoriesForTerm(egeriaTermGUID, - startFrom, - myContext.getMaxPageSize(), - new Date()); - - while (linkedCategories != null) - { - for (GlossaryCategoryElement egeriaCategory : linkedCategories) - { - if (this.isAtlasOwnedElement(egeriaCategory.getElementHeader())) - { - String atlasCategoryGUID = this.getAtlasGUID(egeriaCategory); - if (! atlasCategories.containsKey(atlasCategoryGUID)) - { - /* - * The category relationship has been deleted in Atlas so should be deleted in the open metadata ecosystem - */ - glossaryExchangeService.clearTermCategory(egeriaCategory.getElementHeader().getGUID(), egeriaTermGUID, new Date()); - } - } - } - - startFrom = startFrom + myContext.getMaxPageSize(); - linkedCategories = glossaryExchangeService.getCategoriesForTerm(egeriaTermGUID, - startFrom, - myContext.getMaxPageSize(), - new Date()); - } - } - - - /** - * Set up the term to term relationships in the open metadata ecosystem for a term. - * - * @param egeriaTermGUID term to work with - * @param atlasGlossaryTerm details from Atlas to copy - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void setUpTermRelationshipsInEgeria(String egeriaTermGUID, - AtlasGlossaryTermElement atlasGlossaryTerm) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - // todo sort out term-to-term relationships - } - - - /** - * Copy the content of the Apache Atlas glossary category to the open metadata ecosystem. - * - * @param atlasCategory atlas glossary category - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void refreshAtlasGlossaryCategoryInEgeria(AtlasGlossaryCategoryElement atlasCategory, - GlossaryCategoryElement egeriaCategory) throws PropertyServerException, - InvalidParameterException, - UserNotAuthorizedException - { - GlossaryCategoryProperties glossaryCategoryProperties = this.getEgeriaGlossaryCategoryProperties(atlasCategory); - - glossaryExchangeService.updateGlossaryCategory(egeriaCategory.getElementHeader().getGUID(), - atlasCategory.getGuid(), - false, - glossaryCategoryProperties, - new Date()); - - if (auditLog != null) - { - final String methodName = "refreshAtlasGlossaryCategoryInEgeria"; - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_ATLAS_GLOSSARY_CATEGORY.getMessageDefinition(connectorName, - atlasCategory.getName(), - glossaryCategoryProperties.getQualifiedName(), - egeriaCategory.getElementHeader().getGUID())); - } - - this.setUpCategoryHierarchyInEgeria(egeriaCategory.getElementHeader().getGUID(), atlasCategory); - } - - - /** - * Create a new category in the open metadata ecosystem. - * - * @param atlasGlossaryCategory category details from atlas to copy - * @param destinationGlossary Open metadata glossary to add the category to - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void createAtlasGlossaryCategoryInEgeria(AtlasGlossaryCategoryElement atlasGlossaryCategory, - GlossaryElement destinationGlossary) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryCategory.getGuid()); - GlossaryCategoryProperties glossaryCategoryProperties = this.getEgeriaGlossaryCategoryProperties(atlasGlossaryCategory); - - String egeriaCategoryGUID = glossaryExchangeService.createGlossaryCategory(destinationGlossary.getElementHeader().getGUID(), - true, - externalIdentifierProperties, - glossaryCategoryProperties, - (atlasGlossaryCategory.getParentCategory() == null), - new Date()); - - if (auditLog != null) - { - final String methodName = "createAtlasGlossaryCategoryInEgeria"; - - auditLog.logMessage(methodName, ApacheAtlasAuditCode.SYNC_ATLAS_GLOSSARY_CATEGORY.getMessageDefinition(connectorName, - atlasGlossaryCategory.getName(), - glossaryCategoryProperties.getQualifiedName(), - egeriaCategoryGUID)); - } - - /* - * Save the egeriaCategoryGUID from Egeria in the Atlas Glossary Category's AdditionalAttributes. - */ - Map glossaryAdditionalAttributes = atlasGlossaryCategory.getAdditionalAttributes(); - if (glossaryAdditionalAttributes == null) - { - glossaryAdditionalAttributes = new HashMap<>(); - } - - glossaryAdditionalAttributes.put(egeriaGUIDPropertyName, egeriaCategoryGUID); - glossaryAdditionalAttributes.put(egeriaOwnedPropertyName, false); - atlasGlossaryCategory.setAdditionalAttributes(glossaryAdditionalAttributes); - - atlasClient.saveAtlasGlossaryCategory(atlasGlossaryCategory); - - this.setUpCategoryHierarchyInEgeria(egeriaCategoryGUID, atlasGlossaryCategory); - } - - - /** - * Set up the category hierarchy relationships in the open metadata ecosystem. This only sets up the parent category. - * This means it may take multiple calls to refresh() to full establish the category hierarchy. - * - * @param egeriaCategoryGUID category to work with - * @param atlasGlossaryCategory details from Atlas to copy - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws PropertyServerException problem communicating with Egeria - * @throws UserNotAuthorizedException security problem - */ - private void setUpCategoryHierarchyInEgeria(String egeriaCategoryGUID, - AtlasGlossaryCategoryElement atlasGlossaryCategory) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - GlossaryCategoryElement egeriaParentCategory = glossaryExchangeService.getGlossaryCategoryParent(egeriaCategoryGUID, new Date()); - - if (egeriaParentCategory == null) - { - if (atlasGlossaryCategory.getParentCategory() != null) - { - AtlasGlossaryCategoryElement atlasParentCategory = atlasClient.getAtlasGlossaryCategory(atlasGlossaryCategory.getParentCategory().getCategoryGuid()); - - if (atlasParentCategory != null) - { - String egeriaParentCategoryGUIDFromAtlas = this.getEgeriaGUID(atlasParentCategory); - - if (egeriaParentCategoryGUIDFromAtlas != null) - { - glossaryExchangeService.setupCategoryParent(egeriaParentCategoryGUIDFromAtlas, egeriaCategoryGUID, new Date()); - } - } - } - } - else if (atlasGlossaryCategory.getParentCategory() != null) - { - /* - * Both categories have a parent category ... are they the same? - */ - AtlasGlossaryCategoryElement atlasParentCategory = atlasClient.getAtlasGlossaryCategory(atlasGlossaryCategory.getParentCategory().getCategoryGuid()); - - if (atlasParentCategory != null) - { - String egeriaParentCategoryGUIDFromAtlas = this.getEgeriaGUID(atlasParentCategory); - - if (! egeriaParentCategory.getElementHeader().getGUID().equals(egeriaParentCategoryGUIDFromAtlas)) - { - glossaryExchangeService.clearCategoryParent(egeriaParentCategory.getElementHeader().getGUID(), egeriaCategoryGUID, new Date()); - glossaryExchangeService.setupCategoryParent(egeriaParentCategoryGUIDFromAtlas, egeriaCategoryGUID, new Date()); - } - } - } - else // egeria has parent category but not in atlas - { - if (this.isAtlasOwnedElement(egeriaParentCategory.getElementHeader())) - { - glossaryExchangeService.clearCategoryParent(egeriaParentCategory.getElementHeader().getGUID(), egeriaCategoryGUID, new Date()); - } - } - } - - - /* ====================================== - * Work with Egeria metadata elements - */ - - - /** - * Return an external identifier properties object for an Atlas GUID. - * - * @param atlasGUID guid to encode - * @return properties object - */ - private ExternalIdentifierProperties getExternalIdentifier(String atlasGUID) - { - ExternalIdentifierProperties externalIdentifierProperties = new ExternalIdentifierProperties(); - externalIdentifierProperties.setExternalIdentifier(atlasGUID); - externalIdentifierProperties.setExternalIdentifierName(atlasGUIDPropertyName); - - return externalIdentifierProperties; - } - - - /** - * Check that the Atlas GUID is correct stored in the open metadata element. - * - * @param egeriaElement element to validate and potentially update - * @param atlasGUID Unique identifier from Apache Atlas - * @throws InvalidParameterException invalid parameter - probably a logic error - * @throws UserNotAuthorizedException security problem - * @throws PropertyServerException problem connecting with Egeria - */ - private void ensureAtlasExternalIdentifier(MetadataElement egeriaElement, - String atlasGUID) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException - { - /* - * Check that the Atlas Glossary's GUID is stored as an external identifier. - */ - if (egeriaElement.getCorrelationHeaders() != null) - { - for (MetadataCorrelationHeader header : egeriaElement.getCorrelationHeaders()) - { - if (atlasGUID.equals(header.getExternalIdentifier())) - { - /* - * Atlas GUID is stored as an external identifier. - */ - return; - } - } - } - - /* - * Set up external Identifier - */ - ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGUID); - - myContext.addExternalIdentifier(egeriaElement.getElementHeader().getGUID(), egeriaElement.getElementHeader().getType().getTypeName(), externalIdentifierProperties); - } - - - /** - * Remove the association between an Egeria unique identifier and an Atlas Glossary. - * - * @param atlasGlossaryElement Atlas glossary - * @return updated element - * @throws PropertyServerException problem updating Atlas - */ - private AtlasGlossaryElement clearEgeriaGUIDFromGlossary(AtlasGlossaryElement atlasGlossaryElement) throws PropertyServerException - { - if (atlasGlossaryElement != null) - { - if (atlasGlossaryElement.getAdditionalAttributes() != null) - { - Map additionalAttributes = new HashMap<>(); - - for (String propertyName : atlasGlossaryElement.getAdditionalAttributes().keySet()) - { - if ((! propertyName.equals(egeriaGUIDPropertyName)) && (! propertyName.equals(egeriaOwnedPropertyName))) - { - additionalAttributes.put(propertyName, atlasGlossaryElement.getAdditionalAttributes().get(propertyName)); - } - } - - if (additionalAttributes.isEmpty()) - { - additionalAttributes = null; - } - - atlasGlossaryElement.setAdditionalAttributes(additionalAttributes); - - return atlasClient.saveAtlasGlossary(atlasGlossaryElement); - } - } - - return null; - } - - - /** - * Remove the association between an Egeria unique identifier and an Atlas Glossary Category. - * - * @param atlasGlossaryCategory Atlas glossary category - * @return updated element - * @throws PropertyServerException problem updating Atlas - */ - private AtlasGlossaryCategoryElement clearEgeriaGUIDFromCategory(AtlasGlossaryCategoryElement atlasGlossaryCategory) throws PropertyServerException - { - if (atlasGlossaryCategory != null) - { - if (atlasGlossaryCategory.getAdditionalAttributes() != null) - { - Map additionalAttributes = new HashMap<>(); - - for (String propertyName : atlasGlossaryCategory.getAdditionalAttributes().keySet()) - { - if ((! propertyName.equals(egeriaGUIDPropertyName)) && (! propertyName.equals(egeriaOwnedPropertyName))) - { - additionalAttributes.put(propertyName, atlasGlossaryCategory.getAdditionalAttributes().get(propertyName)); - } - } - - if (additionalAttributes.isEmpty()) - { - additionalAttributes = null; - } - - atlasGlossaryCategory.setAdditionalAttributes(additionalAttributes); - - return atlasClient.saveAtlasGlossaryCategory(atlasGlossaryCategory); - } - } - - return null; - } - - - /** - * Remove the association between an Egeria unique identifier and an Atlas Glossary Term. - * - * @param atlasGlossaryTermElement Atlas glossary term - * @return updated element - * @throws PropertyServerException problem updating Atlas - */ - private AtlasGlossaryTermElement clearEgeriaGUIDFromTerm(AtlasGlossaryTermElement atlasGlossaryTermElement) throws PropertyServerException - { - if (atlasGlossaryTermElement != null) - { - if (atlasGlossaryTermElement.getAdditionalAttributes() != null) - { - Map additionalAttributes = new HashMap<>(); - - for (String propertyName : atlasGlossaryTermElement.getAdditionalAttributes().keySet()) - { - if ((! propertyName.equals(egeriaGUIDPropertyName)) && (! propertyName.equals(egeriaOwnedPropertyName))) - { - additionalAttributes.put(propertyName, atlasGlossaryTermElement.getAdditionalAttributes().get(propertyName)); - } - } - - if (additionalAttributes.isEmpty()) - { - additionalAttributes = null; - } - - atlasGlossaryTermElement.setAdditionalAttributes(additionalAttributes); - - return atlasClient.saveAtlasGlossaryTerm(atlasGlossaryTermElement); - } - } - - return null; - } - - - /** - * Retrieve a specific glossary based on its qualified name. This glossary is expected to be present. - * - * @param glossaryQualifiedName requested glossary - * @param methodName calling method - * @return element or null - * @throws ConnectorCheckedException unexpected exception - */ - private GlossaryElement getGlossaryElement(String glossaryQualifiedName, - String methodName) throws ConnectorCheckedException - { - try - { - List egeriaGlossaries = glossaryExchangeService.getGlossariesByName(glossaryQualifiedName, 0, 0, null); - - if (egeriaGlossaries != null) - { - for (GlossaryElement glossaryElement : egeriaGlossaries) - { - String qualifiedName = glossaryElement.getGlossaryProperties().getQualifiedName(); - - if (glossaryQualifiedName.equals(qualifiedName)) - { - return glossaryElement; - } - } - } - } - catch (Exception error) - { - if (auditLog != null) - { - auditLog.logException(methodName, - ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - methodName, - error.getMessage()), - error); - - - } - - throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, - error.getClass().getName(), - error.getMessage()), - this.getClass().getName(), - methodName, - error); - } - - return null; - } - - - /** - * Copy the properties from an Atlas glossary into the Asset Manager Properties bean. - * - * @param atlasGlossaryElement source element - * @return properties bean - */ - private GlossaryProperties getEgeriaGlossaryProperties(AtlasGlossaryElement atlasGlossaryElement) - { - GlossaryProperties glossaryProperties = new GlossaryProperties(); - - glossaryProperties.setQualifiedName("AtlasGlossary." + atlasGlossaryElement.getQualifiedName()); - glossaryProperties.setDisplayName(atlasGlossaryElement.getName()); - if (atlasGlossaryElement.getShortDescription() != null) - { - glossaryProperties.setDescription(atlasGlossaryElement.getShortDescription() + "\n\n" + atlasGlossaryElement.getLongDescription()); - } - else - { - glossaryProperties.setDescription(atlasGlossaryElement.getLongDescription()); - } - glossaryProperties.setLanguage(atlasGlossaryElement.getLanguage()); - glossaryProperties.setUsage(atlasGlossaryElement.getUsage()); - - return glossaryProperties; - } - - - /** - * Set up the properties from an open metadata glossary into an Apache Atlas glossary properties object. - * - * @param egeriaGlossary open metadata glossary - * @param existingGlossary existing glossary element - may be null - * @return Apache Atlas properties object - */ - AtlasGlossaryElement getAtlasGlossaryProperties(GlossaryElement egeriaGlossary, - AtlasGlossaryElement existingGlossary) - { - AtlasGlossaryElement atlasGlossaryElement = new AtlasGlossaryElement(); - - if (existingGlossary != null) - { - atlasGlossaryElement = existingGlossary; - } - - atlasGlossaryElement.setName(egeriaGlossary.getGlossaryProperties().getDisplayName()); - - if (egeriaGlossary.getGlossaryProperties().getDescription() != null) - { - String[] descriptionSentences = egeriaGlossary.getGlossaryProperties().getDescription().split(Pattern.quote(". ")); - if (descriptionSentences.length > 0) - { - atlasGlossaryElement.setShortDescription(descriptionSentences[0]); - } - } - atlasGlossaryElement.setLongDescription(egeriaGlossary.getGlossaryProperties().getDescription()); - atlasGlossaryElement.setLanguage(egeriaGlossary.getGlossaryProperties().getLanguage()); - atlasGlossaryElement.setUsage(egeriaGlossary.getGlossaryProperties().getUsage()); - - Map additionalAttributes = new HashMap<>(); - - additionalAttributes.put(egeriaGUIDPropertyName, egeriaGlossary.getElementHeader().getGUID()); - additionalAttributes.put(egeriaOwnedPropertyName, true); - - atlasGlossaryElement.setAdditionalAttributes(additionalAttributes); - - return atlasGlossaryElement; - } - - - /** - * Copy the properties from an Atlas glossary term into the Asset Manager Properties bean. - * - * @param atlasGlossaryTermElement source element - * @return properties bean - */ - private GlossaryTermProperties getEgeriaGlossaryTermProperties(AtlasGlossaryTermElement atlasGlossaryTermElement) - { - GlossaryTermProperties glossaryTermProperties = new GlossaryTermProperties(); - - glossaryTermProperties.setQualifiedName("AtlasGlossaryTerm." + atlasGlossaryTermElement.getQualifiedName()); - glossaryTermProperties.setDisplayName(atlasGlossaryTermElement.getName()); - if (atlasGlossaryTermElement.getShortDescription() != null) - { - glossaryTermProperties.setDescription(atlasGlossaryTermElement.getShortDescription() + "\n\n" + atlasGlossaryTermElement.getLongDescription()); - } - else - { - glossaryTermProperties.setDescription(atlasGlossaryTermElement.getLongDescription()); - } - glossaryTermProperties.setAbbreviation(atlasGlossaryTermElement.getAbbreviation()); - glossaryTermProperties.setUsage(atlasGlossaryTermElement.getUsage()); - - return glossaryTermProperties; - } - - - /** - * Set up the properties from an open metadata glossary term into an Apache Atlas glossary term properties object. - * - * @param egeriaGlossaryTerm open metadata glossary term - * @param atlasGlossaryTermGUID unique identifier of glossary term in Atlas - * @param atlasGlossary glossary details to ensure term name is unique in Atlas - * @return Apache Atlas properties object - * @throws PropertyServerException problem calling Atlas - */ - AtlasGlossaryTermElement getAtlasGlossaryTermProperties(GlossaryTermElement egeriaGlossaryTerm, - String atlasGlossaryTermGUID, - AtlasGlossaryElement atlasGlossary) throws PropertyServerException - { - AtlasGlossaryTermElement atlasGlossaryTermElement; - - if (atlasGlossaryTermGUID != null) - { - Map existingTerms = this.getAtlasTermsForGlossary(atlasGlossary); - - atlasGlossaryTermElement = atlasClient.getAtlasGlossaryTerm(atlasGlossaryTermGUID); - - atlasGlossaryTermElement.setName(this.getNameForAtlasTerm(egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), - atlasGlossaryTermGUID, - existingTerms)); - } - else - { - atlasGlossaryTermElement = new AtlasGlossaryTermElement(); - - AtlasGlossaryAnchorElement anchorElement = new AtlasGlossaryAnchorElement(); - anchorElement.setGlossaryGuid(atlasGlossary.getGuid()); - anchorElement.setDisplayText(atlasGlossary.getName()); - - atlasGlossaryTermElement.setAnchor(anchorElement); - atlasGlossaryTermElement.setName(egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName()); - } - - if (egeriaGlossaryTerm.getGlossaryTermProperties().getDescription() != null) - { - String[] descriptionSentences = egeriaGlossaryTerm.getGlossaryTermProperties().getDescription().split(Pattern.quote(". ")); - if (descriptionSentences.length > 0) - { - atlasGlossaryTermElement.setShortDescription(descriptionSentences[0]); - } - } - atlasGlossaryTermElement.setLongDescription(egeriaGlossaryTerm.getGlossaryTermProperties().getDescription()); - atlasGlossaryTermElement.setAbbreviation(egeriaGlossaryTerm.getGlossaryTermProperties().getAbbreviation()); - atlasGlossaryTermElement.setUsage(egeriaGlossaryTerm.getGlossaryTermProperties().getUsage()); - - Map additionalAttributes = new HashMap<>(); - - additionalAttributes.put(egeriaGUIDPropertyName, egeriaGlossaryTerm.getElementHeader().getGUID()); - additionalAttributes.put(egeriaOwnedPropertyName, true); - - atlasGlossaryTermElement.setAdditionalAttributes(additionalAttributes); - - return atlasGlossaryTermElement; - } - - - - /** - * Copy the properties from an Atlas glossary category into the Asset Manager Properties bean. - * - * @param atlasGlossaryCategoryElement source element - * @return properties bean - */ - private GlossaryCategoryProperties getEgeriaGlossaryCategoryProperties(AtlasGlossaryCategoryElement atlasGlossaryCategoryElement) - { - GlossaryCategoryProperties glossaryCategoryProperties = new GlossaryCategoryProperties(); - - glossaryCategoryProperties.setQualifiedName("AtlasGlossaryCategory." + atlasGlossaryCategoryElement.getQualifiedName()); - glossaryCategoryProperties.setDisplayName(atlasGlossaryCategoryElement.getName()); - if (atlasGlossaryCategoryElement.getShortDescription() != null) - { - glossaryCategoryProperties.setDescription(atlasGlossaryCategoryElement.getShortDescription() + "\n\n" + atlasGlossaryCategoryElement.getLongDescription()); - } - else - { - glossaryCategoryProperties.setDescription(atlasGlossaryCategoryElement.getLongDescription()); - } - - return glossaryCategoryProperties; - } - - - /** - * Set up the properties from an open metadata glossary category into an Apache Atlas glossary category properties object. - * - * @param egeriaGlossaryCategory open metadata glossary category - * @return Apache Atlas properties object - * @throws PropertyServerException problem calling Atlas - */ - AtlasGlossaryCategoryElement getAtlasGlossaryCategoryProperties(GlossaryCategoryElement egeriaGlossaryCategory, - String atlasGlossaryCategoryGUID, - AtlasGlossaryElement atlasGlossary) throws PropertyServerException - { - AtlasGlossaryCategoryElement atlasGlossaryCategoryElement; - - if (atlasGlossaryCategoryGUID != null) - { - Map existingCategories = this.getAtlasCategoriesForGlossary(atlasGlossary); - - atlasGlossaryCategoryElement = atlasClient.getAtlasGlossaryCategory(atlasGlossaryCategoryGUID); - - atlasGlossaryCategoryElement.setName(this.getNameForAtlasCategory(egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), - atlasGlossaryCategoryGUID, - existingCategories)); - } - else - { - atlasGlossaryCategoryElement = new AtlasGlossaryCategoryElement(); - - AtlasGlossaryAnchorElement anchorElement = new AtlasGlossaryAnchorElement(); - anchorElement.setGlossaryGuid(atlasGlossary.getGuid()); - anchorElement.setDisplayText(atlasGlossary.getName()); - - atlasGlossaryCategoryElement.setAnchor(anchorElement); - - atlasGlossaryCategoryElement.setName(egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName()); - } - - if (egeriaGlossaryCategory.getGlossaryCategoryProperties().getDescription() != null) - { - String[] descriptionSentences = egeriaGlossaryCategory.getGlossaryCategoryProperties().getDescription().split(Pattern.quote(". ")); - if (descriptionSentences.length > 0) - { - atlasGlossaryCategoryElement.setShortDescription(descriptionSentences[0]); - } - } - atlasGlossaryCategoryElement.setLongDescription(egeriaGlossaryCategory.getGlossaryCategoryProperties().getDescription()); - - Map additionalAttributes = new HashMap<>(); - - additionalAttributes.put(egeriaGUIDPropertyName, egeriaGlossaryCategory.getElementHeader().getGUID()); - additionalAttributes.put(egeriaOwnedPropertyName, true); - - atlasGlossaryCategoryElement.setAdditionalAttributes(additionalAttributes); - - return atlasGlossaryCategoryElement; - } - - - /** - * Calculate the term name to use in Atlas for an open metadata term. It is a 1-1 mapping unless the Egeria glossary has - * multiple terms with the same name. In that case, a bracketed number is added to the end of the term name. - * - * @param egeriaTermName display name from Egeria - * @param atlasTermGUID equivalent term GUID in Atlas (if known) - * @param atlasGlossaryTermElementMap map of known terms in the destination atlas glossary - * @return name to use - */ - private String getNameForAtlasTerm(String egeriaTermName, - String atlasTermGUID, - Map atlasGlossaryTermElementMap) - { - /* - * There are no existing terms so the name from Egeria can be used. - */ - if (atlasGlossaryTermElementMap == null) - { - return egeriaTermName; - } - - if ((atlasTermGUID != null) && (atlasGlossaryTermElementMap.get(atlasTermGUID) != null)) - { - /* - * The term name has already been established in Apache Atlas. Is it still consistent with Egeria? - * Only return the existing name if it is consistent. - */ - String atlasTermName = atlasGlossaryTermElementMap.get(atlasTermGUID).getName(); - if (atlasTermName.startsWith(egeriaTermName)) - { - return atlasTermName; - } - } - int termCount = 0; - - /* - * Step through all the existing terms and determine if the term name from Egeria would be unique in Atlas. - */ - for (AtlasGlossaryTermElement existingAtlasTerm : atlasGlossaryTermElementMap.values()) - { - if (! egeriaTermName.equals(existingAtlasTerm.getName())) - { - /* - * There is no direct name match. Look to see if it is a modified name. - */ - String[] termNameParts = egeriaTermName.split(Pattern.quote(" (")); - if (termNameParts.length > 1) - { - /* - * There is a bracket in the name. This could be a modified name to handle multiple glossary terms within the glossary. - */ - String[] termEndingParts = termNameParts[termNameParts.length - 1].split(Pattern.quote(")")); - - if (termEndingParts.length == 1) - { - try - { - int termIndex = Integer.parseInt(termEndingParts[0]); - - if (termIndex >= termCount) - { - termCount = termIndex + 1; - } - } - catch (NumberFormatException notANumber) - { - // ignore the term - } - } - } - } - else - { - termCount = termCount + 1; - } - } - - if (termCount == 0) - { - return egeriaTermName; - } - else - { - return egeriaTermName + " (" + termCount + ")"; - } - } - - - /** - * Calculate the name to use in Atlas for an open metadata category. It is a 1-1 mapping unless the Egeria glossary has - * multiple categories with the same name. In that case, a bracketed number is added to the end of the category name. - * - * @param egeriaCategoryName display name from Egeria - * @param atlasCategoryGUID equivalent term GUID in Atlas (if known) - * @param atlasGlossaryCategoryElementMap map of known categories in the destination atlas glossary - * @return name to use - */ - private String getNameForAtlasCategory(String egeriaCategoryName, - String atlasCategoryGUID, - Map atlasGlossaryCategoryElementMap) - { - /* - * There are no existing terms so the name from Egeria can be used. - */ - if (atlasGlossaryCategoryElementMap == null) - { - return egeriaCategoryName; - } - - if ((atlasCategoryGUID != null) && (atlasGlossaryCategoryElementMap.get(atlasCategoryGUID) != null)) - { - /* - * The category name has already been established in Apache Atlas. Is it still consistent with Egeria? - * Only return the existing name if it is consistent. - */ - String atlasCategoryName = atlasGlossaryCategoryElementMap.get(atlasCategoryGUID).getName(); - if (atlasCategoryName.startsWith(egeriaCategoryName)) - { - return atlasCategoryName; - } - } - - int categoryCount = 0; - - /* - * Step through all the existing categories and determine if the category name is unique. - */ - for (AtlasGlossaryCategoryElement existingAtlasCategory : atlasGlossaryCategoryElementMap.values()) - { - if (! egeriaCategoryName.equals(existingAtlasCategory.getName())) - { - /* - * There is no direct name match. Look to see if it is a modified name. - */ - String[] categoryNameParts = egeriaCategoryName.split(Pattern.quote(" (")); - if (categoryNameParts.length > 1) - { - /* - * There is a bracket in the name. This could be a modified name to handle multiple glossary categories within the glossary. - */ - String[] categoryEndingParts = categoryNameParts[categoryNameParts.length - 1].split(Pattern.quote(")")); - - if (categoryEndingParts.length == 1) - { - try - { - int categoryIndex = Integer.parseInt(categoryEndingParts[0]); - - if (categoryIndex >= categoryCount) - { - categoryCount = categoryIndex + 1; - } - } - catch (NumberFormatException notANumber) - { - // ignore the term - } - } - } - } - else - { - categoryCount = categoryCount + 1; - } - } - - if (categoryCount == 0) - { - return egeriaCategoryName; - } - else - { - return egeriaCategoryName + " (" + categoryCount + ")"; - } - } - - - /** - * Load the terms from an atlas glossary into a map for processing. - * - * @param atlasGlossary contents of the Apache Atlas glossary - * @throws PropertyServerException problem communicating with Apache Atlas - */ - private Map getAtlasTermsForGlossary(AtlasGlossaryElement atlasGlossary) throws PropertyServerException - { - if (atlasGlossary != null) - { - if ((atlasGlossary.getTerms() != null) && (! atlasGlossary.getTerms().isEmpty())) - { - Map atlasTerms = new HashMap<>(); - - /* - * Load the terms currently stored in Apache Atlas - */ - for (AtlasRelatedTermHeader termHeader : atlasGlossary.getTerms()) - { - AtlasGlossaryTermElement atlasGlossaryTermElement = atlasClient.getAtlasGlossaryTerm(termHeader.getTermGuid()); - - if ((atlasGlossaryTermElement != null) && (atlasGlossaryTermElement.getGuid() != null)) - { - atlasTerms.put(atlasGlossaryTermElement.getGuid(), atlasGlossaryTermElement); - } - } - - return atlasTerms; - } - } - - return null; - } - - - /** - * Load the categories from an atlas glossary into a map for processing. - * - * @param atlasGlossary contents of the Apache Atlas glossary - * @throws PropertyServerException problem communicating with Apache Atlas - */ - private Map getAtlasCategoriesForGlossary(AtlasGlossaryElement atlasGlossary) throws PropertyServerException - { - if (atlasGlossary != null) - { - return getAtlasCategoriesForElement(atlasGlossary.getCategories()); - } - - return null; - } - - - /** - * Load the categories from an atlas glossary into a map for processing. - * - * @param relatedCategories contents of the Apache Atlas glossary - * @throws PropertyServerException problem communicating with Apache Atlas - */ - private Map getAtlasCategoriesForElement(List relatedCategories) throws PropertyServerException - { - if ((relatedCategories != null) && (! relatedCategories.isEmpty())) - { - Map atlasCategories = new HashMap<>(); - - /* - * Load the categories currently stored in Apache Atlas - */ - for (AtlasRelatedCategoryHeader categoryHeader : relatedCategories) - { - AtlasGlossaryCategoryElement atlasGlossaryCategoryElement = atlasClient.getAtlasGlossaryCategory(categoryHeader.getCategoryGuid()); - - if ((atlasGlossaryCategoryElement != null) && (atlasGlossaryCategoryElement.getGuid() != null)) - { - atlasCategories.put(atlasGlossaryCategoryElement.getGuid(), atlasGlossaryCategoryElement); - } - } - - return atlasCategories; - } - - return null; - } -} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationConnector.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationConnector.java index b7e1818ba00..db9eb41ab8a 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationConnector.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationConnector.java @@ -7,7 +7,22 @@ import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules.ApacheKafkaIntegrationModule; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules.AtlasGlossaryIntegrationModule; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules.ApacheHiveIntegrationModule; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules.AtlasLineageIntegrationModule; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules.RDBMSIntegrationModule; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules.RegisteredIntegrationModule; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasAttributeDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasCardinality; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasPropagateTags; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationshipCategory; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationshipDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationshipEndDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasTypesDef; import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.properties.EndpointProperties; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; @@ -25,11 +40,29 @@ */ public class ApacheAtlasIntegrationConnector extends CatalogIntegratorConnector implements AssetManagerEventListener { - private String targetRootURL = null; - private CatalogIntegratorContext myContext = null; + private String targetRootURL = null; + private CatalogIntegratorContext myContext = null; + private ApacheAtlasRESTClient atlasClient = null; + private AtlasLineageIntegrationModule lineageIntegrationModule = null; - private final Map> moduleMap = new HashMap<>(); - private final List moduleList = new ArrayList<>(); + private final Map> moduleMap = new HashMap<>(); + private final List moduleList = new ArrayList<>(); + + + /** + * The type name for the entity that holds the correlation values for corresponding open metadata entity. + */ + public static final String OPEN_METADATA_CORRELATION_TYPE_NAME = "OpenMetadataCorrelation"; + + /** + * The type name for the relationship that links the correlation entity to its associated Apache Atlas entity. + */ + public static final String OPEN_METADATA_CORRELATION_LINK_TYPE_NAME = "OpenMetadataCorrelationLink"; + + /** + * The type name for the relationship that links the correlation entity to its associated Apache Atlas glossary member. + */ + public static final String GLOSSARY_CORRELATION_LINK_TYPE_NAME = "OpenMetadataGlossaryCorrelationLink"; /* ============================================================================== @@ -89,24 +122,61 @@ public void start() throws ConnectorCheckedException /* * Create the client that calls Apache Atlas. */ - ApacheAtlasRESTClient atlasClient = new ApacheAtlasRESTClient(connectorName, - "Apache Atlas", - targetRootURL, - connectionProperties.getUserId(), - connectionProperties.getClearPassword(), - auditLog); + atlasClient = new ApacheAtlasRESTClient(connectorName, + "Apache Atlas", + targetRootURL, + connectionProperties.getUserId(), + connectionProperties.getClearPassword(), + auditLog); + + /* + * Ensure the correlation types are properly defined in Apache Atlas. + */ + setupCorrelationTypes(atlasClient); /* * Set up the processing modules. This is currently static, but the intention is that the modules can be plug-in extensions too * to support privately defined types. */ - this.registerSupportedModule(new ApacheAtlasGlossaryIntegrationModule(connectorName, - connectionProperties, - auditLog, - this.getContext(), - targetRootURL, - atlasClient, - embeddedConnectors)); + this.registerSupportedModule(new AtlasGlossaryIntegrationModule(connectorName, + connectionProperties, + auditLog, + this.getContext(), + targetRootURL, + atlasClient, + embeddedConnectors)); + + this.registerSupportedModule(new ApacheHiveIntegrationModule(connectorName, + connectionProperties, + auditLog, + this.getContext(), + targetRootURL, + atlasClient, + embeddedConnectors)); + + this.registerSupportedModule(new RDBMSIntegrationModule(connectorName, + connectionProperties, + auditLog, + this.getContext(), + targetRootURL, + atlasClient, + embeddedConnectors)); + + this.registerSupportedModule(new ApacheKafkaIntegrationModule(connectorName, + connectionProperties, + auditLog, + this.getContext(), + targetRootURL, + atlasClient, + embeddedConnectors)); + + this.lineageIntegrationModule = new AtlasLineageIntegrationModule(connectorName, + connectionProperties, + auditLog, + this.getContext(), + targetRootURL, + atlasClient, + embeddedConnectors); } catch (Exception error) { @@ -134,17 +204,17 @@ public void start() throws ConnectorCheckedException * * @param supportedModule module */ - private void registerSupportedModule(AtlasIntegrationModuleBase supportedModule) + private void registerSupportedModule(RegisteredIntegrationModule supportedModule) { moduleList.add(supportedModule); - if (supportedModule.getSupportedTypes() != null) + if (supportedModule.getListenForTypes() != null) { - for (String supportedType : supportedModule.getSupportedTypes()) + for (String supportedType : supportedModule.getListenForTypes()) { if (supportedType != null) { - List modulesForTypeName = moduleMap.get(supportedType); + List modulesForTypeName = moduleMap.get(supportedType); if (modulesForTypeName == null) { @@ -164,9 +234,6 @@ private void registerSupportedModule(AtlasIntegrationModuleBase supportedModule * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration * as well as any external REST API calls to explicitly refresh the connector. - *

- * This method performs two sweeps. It first retrieves the glossary elements from Egeria and synchronizes them with Apache Atlas. - * The second sweep works through the glossaries in Apache Atlas and ensures that none have been missed out by the first sweep. * * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. */ @@ -175,11 +242,27 @@ public void refresh() throws ConnectorCheckedException { final String methodName = "refresh"; - for (AtlasIntegrationModuleBase registeredModule : moduleList) + /* + * Step through each registered module - each responsible for synchronizing a collection of Asset types from Atlas. + */ + for (RegisteredIntegrationModule registeredModule : moduleList) { + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.SYNC_INTEGRATION_MODULE.getMessageDefinition(connectorName, + registeredModule.getModuleName())); + } + registeredModule.refresh(); } + /* + * Synchronize the lineage information. This connector will create the discovered processes and connect them to the associated + * assets. It will fill out the lineage graph with any DataSet entities that have not been synchronized by the registered modules. + */ + lineageIntegrationModule.synchronizeLineage(); + /* * Once the connector has completed a single refresh, it registered a listener with open metadata * to handle updates. The delay in registering the listener is for efficiency-sake in that it @@ -245,11 +328,11 @@ public void processEvent(AssetManagerOutTopicEvent event) { if (myContext.isTypeOf(elementHeader, supportedType)) { - List modulesForTypeName = moduleMap.get(supportedType); + List modulesForTypeName = moduleMap.get(supportedType); if (modulesForTypeName != null) { - for (AtlasIntegrationModuleBase registeredModule : modulesForTypeName) + for (RegisteredIntegrationModule registeredModule : modulesForTypeName) { registeredModule.processEvent(event); } @@ -261,7 +344,217 @@ public void processEvent(AssetManagerOutTopicEvent event) /** - * Shutdown glossary monitoring + * This connector uses an entity type called OpenMetadataCorrelation to store information about the + * equivalent open metadata entity. It is linked to the corresponding Apache Atlas entity using the + * OpenMetadataCorrelationLink relationship. These types are not part of the standard Apache Atlas Type system. + * This method queries to see if these types are defined. If they are not then they are created in Apache Atlas. + * + * @param atlasClient client for Apache Atlas + * @throws PropertyServerException unable to connect to Apache Atlas + */ + private void setupCorrelationTypes(ApacheAtlasRESTClient atlasClient) throws PropertyServerException + { + final String serviceType = "open_metadata_ecosystem"; + final String entityDescription = "Information used in synchronizing Apache Atlas metadata with external catalogs via the Open Metadata Ecosystem supported by Egeria."; + final String egeriaQualifiedNamePropertyName = "egeriaQualifiedName"; + final String egeriaQualifiedNameDescription = "Unique name of equivalent open metadata instance in the open metadata ecosystem."; + final String egeriaTypeNamePropertyName = "egeriaTypeName"; + final String egeriaTypeNameDescription = "Type name of equivalent open metadata instance in the open metadata ecosystem."; + final String egeriaGUIDPropertyName = "egeriaGUID"; + final String egeriaGUIDDescription = "Unique identifier of equivalent open metadata instance in the open metadata ecosystem."; + final String egeriaOwnedPropertyName = "egeriaOwned"; + final String egeriaOwnedDescription = "Boolean flag indicating whether the instance originated in the open metadata ecosystem (true) or Apache Atlas (false)."; + final String relationshipDescription = "Relationship to connect a referenceable to correlation information from the open metadata ecosystem."; + final String correlationEndLabel = "openMetadataCorrelation"; + final String associatedElementEndLabel = "associatedElement"; + final String associatedGlossaryEndLabel = "associatedMeaning"; + final String referenceableTypeName = "Referenceable"; + final String internalTypeName = "__internal"; + final String typeVersion = "V1.0"; + + /* + * Check that Apache Atlas is running. Any exceptions are returned. + */ + atlasClient.getAllTypes(); + + /* + * Retrieve the OpenMetadataCorrelation entity type. If an exception occurs then the type is not defined, and it is added. + */ + try + { + atlasClient.getEntityType(OPEN_METADATA_CORRELATION_TYPE_NAME); + } + catch (PropertyServerException notFound) + { + AtlasTypesDef typesDef = new AtlasTypesDef(); + List entityDefs = new ArrayList<>(); + AtlasEntityDef entityDef = new AtlasEntityDef(); + List attributeDefs = new ArrayList<>(); + + entityDef.setName(OPEN_METADATA_CORRELATION_TYPE_NAME); + entityDef.setDescription(entityDescription); + entityDef.setServiceType(serviceType); + entityDef.setTypeVersion(typeVersion); + entityDef.setVersion(1); + + attributeDefs.add(getStringAttributeDef(egeriaQualifiedNamePropertyName, egeriaQualifiedNameDescription)); + attributeDefs.add(getStringAttributeDef(egeriaTypeNamePropertyName, egeriaTypeNameDescription)); + attributeDefs.add(getStringAttributeDef(egeriaGUIDPropertyName, egeriaGUIDDescription)); + attributeDefs.add(getBooleanAttributeDef(egeriaOwnedPropertyName, egeriaOwnedDescription)); + + entityDef.setAttributeDefs(attributeDefs); + entityDefs.add(entityDef); + typesDef.setEntityDefs(entityDefs); + + atlasClient.addNewTypes(typesDef); + } + + + /* + * Retrieve the OpenMetadataCorrelationLink relationship type. If an exception occurs then the type is not defined, and it is added. + */ + try + { + atlasClient.getRelationshipType(OPEN_METADATA_CORRELATION_LINK_TYPE_NAME); + } + catch (PropertyServerException notFound) + { + AtlasTypesDef typesDef = new AtlasTypesDef(); + List relationshipDefs = new ArrayList<>(); + AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef(); + AtlasRelationshipEndDef end1 = new AtlasRelationshipEndDef(); + AtlasRelationshipEndDef end2 = new AtlasRelationshipEndDef(); + + relationshipDef.setName(OPEN_METADATA_CORRELATION_LINK_TYPE_NAME); + relationshipDef.setDescription(relationshipDescription); + relationshipDef.setServiceType(serviceType); + relationshipDef.setTypeVersion(typeVersion); + relationshipDef.setVersion(1); + relationshipDef.setRelationshipCategory(AtlasRelationshipCategory.ASSOCIATION); + relationshipDef.setPropagateTags(AtlasPropagateTags.NONE); + end1.setType(referenceableTypeName); + end1.setName(correlationEndLabel); + end1.setContainer(false); + end1.setCardinality(AtlasCardinality.SINGLE); + end1.setLegacyAttribute(false); + + end2.setType(OPEN_METADATA_CORRELATION_TYPE_NAME); + end2.setName(associatedElementEndLabel); + end2.setContainer(false); + end2.setCardinality(AtlasCardinality.SINGLE); + end2.setLegacyAttribute(false); + + relationshipDef.setEndDef1(end1); + relationshipDef.setEndDef2(end2); + relationshipDefs.add(relationshipDef); + typesDef.setRelationshipDefs(relationshipDefs); + + atlasClient.addNewTypes(typesDef); + } + + + /* + * Retrieve the OpenMetadataCorrelationLink relationship type. If an exception occurs then the type is not defined, and it is added. + */ + try + { + atlasClient.getRelationshipType(GLOSSARY_CORRELATION_LINK_TYPE_NAME); + } + catch (PropertyServerException notFound) + { + AtlasTypesDef typesDef = new AtlasTypesDef(); + List relationshipDefs = new ArrayList<>(); + AtlasRelationshipDef relationshipDef = new AtlasRelationshipDef(); + AtlasRelationshipEndDef end1 = new AtlasRelationshipEndDef(); + AtlasRelationshipEndDef end2 = new AtlasRelationshipEndDef(); + + relationshipDef.setName(GLOSSARY_CORRELATION_LINK_TYPE_NAME); + relationshipDef.setDescription(relationshipDescription); + relationshipDef.setServiceType(serviceType); + relationshipDef.setTypeVersion(typeVersion); + relationshipDef.setVersion(1); + relationshipDef.setRelationshipCategory(AtlasRelationshipCategory.ASSOCIATION); + relationshipDef.setPropagateTags(AtlasPropagateTags.NONE); + end1.setType(internalTypeName); + end1.setName(correlationEndLabel); + end1.setContainer(false); + end1.setCardinality(AtlasCardinality.SINGLE); + end1.setLegacyAttribute(false); + + end2.setType(OPEN_METADATA_CORRELATION_TYPE_NAME); + end2.setName(associatedGlossaryEndLabel); + end2.setContainer(false); + end2.setCardinality(AtlasCardinality.SINGLE); + end2.setLegacyAttribute(false); + + relationshipDef.setEndDef1(end1); + relationshipDef.setEndDef2(end2); + relationshipDefs.add(relationshipDef); + typesDef.setRelationshipDefs(relationshipDefs); + + atlasClient.addNewTypes(typesDef); + } + } + + + /** + * Create an attribute of type string + * + * @param propertyName name of the attribute + * @param propertyDescription description of the attribute + * @return attribute definition + */ + private AtlasAttributeDef getStringAttributeDef(String propertyName, + String propertyDescription) + { + AtlasAttributeDef attributeDef = new AtlasAttributeDef(); + + attributeDef.setName(propertyName); + attributeDef.setDescription(propertyDescription); + attributeDef.setTypeName("string"); + attributeDef.setOptional(false); + attributeDef.setCardinality(AtlasCardinality.SINGLE); + attributeDef.setValuesMinCount(1); + attributeDef.setValuesMaxCount(1); + attributeDef.setUnique(false); + attributeDef.setIndexable(true); + attributeDef.setIncludeInNotification(false); + attributeDef.setSearchWeight(10); + + return attributeDef; + } + + + /** + * Create an attribute of type boolean + * + * @param propertyName name of the attribute + * @param propertyDescription description of the attribute + * @return attribute definition + */ + private AtlasAttributeDef getBooleanAttributeDef(String propertyName, + String propertyDescription) + { + AtlasAttributeDef attributeDef = new AtlasAttributeDef(); + + attributeDef.setName(propertyName); + attributeDef.setDescription(propertyDescription); + attributeDef.setTypeName("boolean"); + attributeDef.setOptional(false); + attributeDef.setCardinality(AtlasCardinality.SINGLE); + attributeDef.setValuesMinCount(1); + attributeDef.setValuesMaxCount(1); + attributeDef.setUnique(false); + attributeDef.setIndexable(false); + attributeDef.setIncludeInNotification(false); + attributeDef.setSearchWeight(10); + + return attributeDef; + } + + + /** + * Shutdown Apache Atlas monitoring * * @throws ConnectorCheckedException something failed in the super class */ diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationProvider.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationProvider.java index 787e5edb419..9a3f9b5f5e0 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationProvider.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasIntegrationProvider.java @@ -44,13 +44,13 @@ public class ApacheAtlasIntegrationProvider extends IntegrationConnectorProvider * The configuration property name used to supply the qualified name of an Egeria glossary to synchronize with * Apache Atlas. If this value is null, all Egeria originated glossaries are copied to Apache Atlas. */ - static final String EGERIA_GLOSSARY_QUALIFIED_NAME_CONFIGURATION_PROPERTY = "egeriaGlossaryQualifiedName"; + public static final String EGERIA_GLOSSARY_QUALIFIED_NAME_CONFIGURATION_PROPERTY = "egeriaGlossaryQualifiedName"; /** * The configuration property name used to supply the name of the Atlas Glossary to copy into the open metadata * ecosystem. If this value is null, all Apache Atlas originated glossaries are copied into the open metadata ecosystem. */ - static final String ATLAS_GLOSSARY_NAME_CONFIGURATION_PROPERTY = "atlasGlossaryName"; + public static final String ATLAS_GLOSSARY_NAME_CONFIGURATION_PROPERTY = "atlasGlossaryName"; /** * Constructor used to initialize the ConnectorProvider with the Java class name of the specific diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasRESTClient.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasRESTClient.java index 9a7d67bd3a0..1482df58576 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasRESTClient.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasRESTClient.java @@ -6,9 +6,22 @@ import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.NameConflictException; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasBusinessMetadataDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasClassificationDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityHeader; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityMutationResponse; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityOperation; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityWithExtInfo; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryCategoryElement; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryElement; import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryTermElement; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasInstanceStatus; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationship; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationshipDef; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasSearchResult; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasTypesDef; import org.odpi.openmetadata.adapters.connectors.restclients.RESTClientConnector; import org.odpi.openmetadata.adapters.connectors.restclients.factory.RESTClientFactory; import org.odpi.openmetadata.adapters.connectors.restclients.spring.SpringRESTClientConnector; @@ -18,8 +31,10 @@ import org.springframework.core.ParameterizedTypeReference; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** @@ -47,12 +62,12 @@ public class ApacheAtlasRESTClient * @throws InvalidParameterException there is a problem creating the client-side components to issue any * REST API calls. */ - protected ApacheAtlasRESTClient(String connectorName, - String serverName, - String baseURL, - String userId, - String password, - AuditLog auditLog) throws InvalidParameterException + ApacheAtlasRESTClient(String connectorName, + String serverName, + String baseURL, + String userId, + String password, + AuditLog auditLog) throws InvalidParameterException { final String methodName = "RESTClient(userId and password)"; @@ -80,6 +95,446 @@ protected ApacheAtlasRESTClient(String connectorName, } + /** + * Return the types registered to Apache Atlas. + * + * @return type definition list from Apache Atlas + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasTypesDef getAllTypes() throws PropertyServerException + { + final String methodName = "getAllTypes()"; + final String url = baseURL + "/api/atlas/v2/types/typedefs"; + + return this.callGetRESTCallNoParams(methodName, AtlasTypesDef.class, url); + } + + + /** + * Return the requested type from Apache Atlas. + * + * @param typeName name of type to retrieve + * @return type definition from Apache Atlas + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasEntityDef getEntityType(String typeName) throws PropertyServerException + { + final String methodName = "getEntityTypes(" + typeName + "}"; + final String url = baseURL + "/api/atlas/v2/types/entitydef/name/" + typeName; + + return this.callNoLogGetRESTCallNoParams(methodName, AtlasEntityDef.class, url); + } + + + /** + * Return the requested type from Apache Atlas. + * + * @param typeName name of type to retrieve + * @return type definition from Apache Atlas + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasRelationshipDef getRelationshipType(String typeName) throws PropertyServerException + { + final String methodName = "getRelationshipTypes(" + typeName + "}"; + final String url = baseURL + "/api/atlas/v2/types/relationshipdef/name/" + typeName; + + return this.callNoLogGetRESTCallNoParams(methodName, AtlasRelationshipDef.class, url); + } + + + /** + * Return the requested type from Apache Atlas. + * + * @param typeName name of type to retrieve + * @return type definition from Apache Atlas + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasClassificationDef getClassificationType(String typeName) throws PropertyServerException + { + final String methodName = "getClassificationType(" + typeName + "}"; + final String url = baseURL + "/api/atlas/v2/types/classificationdef/name/" + typeName; + + return this.callGetRESTCallNoParams(methodName, AtlasClassificationDef.class, url); + } + + + /** + * Return the requested type from Apache Atlas. + * + * @param typeName name of type to retrieve + * @return type definition from Apache Atlas + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasBusinessMetadataDef getBusinessMetadataType(String typeName) throws PropertyServerException + { + final String methodName = "getBusinessMetadataType(" + typeName + "}"; + final String url = baseURL + "/api/atlas/v2/types/businessmetadatadef/name/" + typeName; + + return this.callGetRESTCallNoParams(methodName, AtlasBusinessMetadataDef.class, url); + } + + + /** + * Create new types. The registered types are returned from Apache Atlas. + * + * @param newTypeDefinitions gallery of new types + * @return type definition list from Apache Atlas + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasTypesDef addNewTypes(AtlasTypesDef newTypeDefinitions) throws PropertyServerException + { + final String methodName = "addNewTypes()"; + final String url = baseURL + "/api/atlas/v2/types/typedefs"; + + return this.callPostRESTCallNoParams(methodName, AtlasTypesDef.class, url, newTypeDefinitions); + } + + + /** + * Add an entity. + * + * @param entity description of entity + * @return description of the operation + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public String addEntity(AtlasEntity entity) throws PropertyServerException + { + final String methodName = "addEntity()"; + final String url = baseURL + "/api/atlas/v2/entity"; + + AtlasEntityWithExtInfo atlasEntityWithExtInfo = new AtlasEntityWithExtInfo(); + + atlasEntityWithExtInfo.setEntity(entity); + + AtlasEntityMutationResponse response = this.callPostRESTCallNoParams(methodName, AtlasEntityMutationResponse.class, url, atlasEntityWithExtInfo); + + if ((response != null) && (response.getMutatedEntities() != null)) + { + List returnedEntities = response.getMutatedEntities().get(AtlasEntityOperation.CREATE); + + if ((returnedEntities != null) && (! returnedEntities.isEmpty())) + { + return returnedEntities.get(0).getGuid(); + } + } + + return null; + } + + + /** + * Update an entity's properties. + * + * @param entityWithExtInfo description of entity and any associated entities + * @return updated entity + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasEntityWithExtInfo updateEntity(AtlasEntityWithExtInfo entityWithExtInfo) throws PropertyServerException + { + final String methodName = "updateEntity()"; + final String url = baseURL + "/api/atlas/v2/entity"; + + this.callPostRESTCallNoParams(methodName, AtlasEntityMutationResponse.class, url, entityWithExtInfo); + + return this.getEntityByGUID(entityWithExtInfo.getEntity().getGuid()); + } + + + /** + * Delete an entity. + * + * @param entityGUID unique identifier of entity and any associated entities + * @return description of the operation + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasEntityMutationResponse deleteEntity(String entityGUID) throws PropertyServerException + { + final String methodName = "deleteEntity()"; + final String url = baseURL + "/api/atlas/v2/entity/guid/{0}"; + + return this.callDeleteRESTCall(methodName, AtlasEntityMutationResponse.class, url, entityGUID); + } + + + /** + * Add a relationship. + * + * @param atlasRelationship description of relationship + * @return description of the operation + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasRelationship addRelationship(AtlasRelationship atlasRelationship) throws PropertyServerException + { + final String methodName = "addRelationship()"; + final String url = baseURL + "/api/atlas/v2/relationship"; + + return this.callPostRESTCallNoParams(methodName, AtlasRelationship.class, url, atlasRelationship); + } + + + /** + * Remove a relationship. + * + * @param atlasRelationshipGUID relationship to delete + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public void clearRelationship(String atlasRelationshipGUID) throws PropertyServerException + { + final String methodName = "clearRelationship()"; + final String url = baseURL + "/api/atlas/v2/relationship/" + atlasRelationshipGUID; + + this.callDeleteRESTCall(methodName, url); + } + + + /** + * Check that the entity is ACTIVE - otherwise return null. + * + * @param retrievedEntity entity retrieved from the Apache Atlas repository + * @return retrieved entity or null + */ + private AtlasEntityWithExtInfo validateActiveEntity(AtlasEntityWithExtInfo retrievedEntity) + { + if ((retrievedEntity != null) && + (retrievedEntity.getEntity() != null) && + (retrievedEntity.getEntity().getStatus() == AtlasInstanceStatus.ACTIVE)) + { + return retrievedEntity; + } + + return null; + } + + + /** + * Retrieve a single entity by GUID. + * + * @param guid unique identifier + * @return description of requested entity + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasEntityWithExtInfo getEntityByGUID(String guid) throws PropertyServerException + { + final String methodName = "getEntity(" + guid + ")"; + final String url = baseURL + "/api/atlas/v2/entity/guid/" + guid; + + AtlasEntityWithExtInfo entity = this.callGetRESTCallNoParams(methodName, AtlasEntityWithExtInfo.class, url); + + return validateActiveEntity(entity); + } + + + /** + * Retrieve the entity at the other end of the named relationship. + * + * @param startingEntity entity information detailing the entity proxy for the entity at the far end of a named relationship. + * @param relationshipLabel name of relationship to traverse + * + * @return description of requested entity + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasEntityWithExtInfo getRelatedEntity(AtlasEntityWithExtInfo startingEntity, + String relationshipLabel) throws PropertyServerException + { + if ((startingEntity != null) && + (startingEntity.getEntity() != null)) + { + return getRelatedEntity(startingEntity.getEntity(), relationshipLabel); + } + + return null; + } + + + /** + * Retrieve the named relationship. + * + * @param startingEntity entity information detailing the entity proxy for the entity at the far end of a named relationship. + * @param relationshipLabel name of relationship to traverse + * + * @return description of requested entity + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public String getRelationshipGUID(AtlasEntityWithExtInfo startingEntity, + String relationshipLabel) throws PropertyServerException + { + if ((startingEntity != null) && (startingEntity.getEntity() != null) && (startingEntity.getEntity().getRelationshipAttributes() != null)) + { + Map relationshipAttributes = startingEntity.getEntity().getRelationshipAttributes(); + + Object relatedObject = relationshipAttributes.get(relationshipLabel); + + if (relatedObject instanceof Map relationship) + { + return relationship.get("relationshipGuid").toString(); + } + } + + return null; + } + + + /** + * Retrieve the entity at the other end of the named relationship. + * + * @param startingEntity entity information detailing the entity proxy for the entity at the far end of a named relationship. + * @param relationshipLabel name of relationship to traverse + * + * @return description of requested entity + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public AtlasEntityWithExtInfo getRelatedEntity(AtlasEntity startingEntity, + String relationshipLabel) throws PropertyServerException + { + if ((startingEntity != null) && (startingEntity.getRelationshipAttributes() != null)) + { + Map relationshipAttributes = startingEntity.getRelationshipAttributes(); + + Object relatedObject = relationshipAttributes.get(relationshipLabel); + + if (relatedObject instanceof Map relationship) + { + String relatedEntityGUID = relationship.get("guid").toString(); + + if (relatedEntityGUID != null) + { + return getEntityByGUID(relatedEntityGUID); + } + } + } + + return null; + } + + /** + * Retrieve the entities at the other end of the named relationship and build a map of the relationships. + * + * @param startingEntity entity information detailing the entity proxy for the entity at the far end of a named relationship. + * @param relationshipLabel name of relationship to traverse + * + * @return list of related entity GUIDs mapped to their relationship GUID + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public Map getRelationships(AtlasEntityWithExtInfo startingEntity, + String relationshipLabel) throws PropertyServerException + { + Map guidMap = new HashMap<>(); + + if ((startingEntity != null) && (startingEntity.getEntity().getRelationshipAttributes() != null)) + { + Map relationshipAttributes = startingEntity.getEntity().getRelationshipAttributes(); + + Object relationshipObjects = relationshipAttributes.get(relationshipLabel); + + if (relationshipObjects instanceof List relationshipList) + { + for (Object relationship : relationshipList) + { + if (relationship instanceof Map relationshipMap) + { + String relatedEntityGUID = relationshipMap.get("guid").toString(); + String relationshipGUID = relationshipMap.get("relationshipGuid").toString(); + + if (relatedEntityGUID != null) + { + guidMap.put(relatedEntityGUID, relationshipGUID); + } + } + } + } + } + + return guidMap; + } + + + + /** + * Retrieve the entities at the other end of the named relationship. + * + * @param startingEntity entity information detailing the entity proxy for the entity at the far end of a named relationship. + * @param relationshipLabel name of relationship to traverse + * + * @return list of related entities + * @throws PropertyServerException problem connecting to Apache Atlas + */ + public List getRelatedEntities(AtlasEntityWithExtInfo startingEntity, + String relationshipLabel) throws PropertyServerException + { + List results = new ArrayList<>(); + + if ((startingEntity != null) && + (startingEntity.getEntity() != null) && + (startingEntity.getEntity().getRelationshipAttributes() != null)) + { + Map relationshipAttributes = startingEntity.getEntity().getRelationshipAttributes(); + + Object relatedObjects = relationshipAttributes.get(relationshipLabel); + + if (relatedObjects instanceof List relatedObjectList) + { + for (Object relatedObject : relatedObjectList) + { + if (relatedObject instanceof Map relatedMappedAttributes) + { + String relatedEntityGUID = relatedMappedAttributes.get("guid").toString(); + + if (relatedEntityGUID != null) + { + AtlasEntityWithExtInfo validatedEntity = validateActiveEntity(getEntityByGUID(relatedEntityGUID)); + + if (validatedEntity != null) + { + results.add(validatedEntity); + } + } + } + } + } + } + + return results; + } + + + /** + * Return a list of entities that are of the requested type. + * + * @param typeName name of the type to query + * @param startFrom offset to start results + * @param pageSize max number of results + * @return list of matching entities. List may be empty if no matches + * @throws PropertyServerException problem communicating with Apache Atlas + */ + public List getEntitiesForType(String typeName, + int startFrom, + int pageSize) throws PropertyServerException + { + final String methodName = "getEntity(" + typeName + ")"; + final String url = baseURL + "/api/atlas/v2/search/dsl?typeName=" + typeName + "&offset=" + startFrom + "&limit=" + pageSize; + + + AtlasSearchResult searchResult = this.callGetRESTCallNoParams(methodName, AtlasSearchResult.class, url); + + if ((searchResult != null) && (searchResult.getEntities() != null)) + { + List results = new ArrayList<>(); + + for (AtlasEntityHeader entityHeader : searchResult.getEntities()) + { + if ((entityHeader != null) && (entityHeader.getStatus() == AtlasInstanceStatus.ACTIVE)) + { + results.add(entityHeader); + } + } + + return results; + } + + return null; + } + + /** * Return a glossary based on the paging count. * @@ -88,7 +543,7 @@ protected ApacheAtlasRESTClient(String connectorName, * @throws PropertyServerException problem with the request */ @SuppressWarnings(value = "unchecked") - AtlasGlossaryElement getAtlasGlossary(int glossaryCount) throws PropertyServerException + public AtlasGlossaryElement getAtlasGlossary(int glossaryCount) throws PropertyServerException { final String methodName = "getAtlasGlossary(glossaryCount)"; final String url = baseURL + "/api/atlas/v2/glossary?limit=1&offset=" + glossaryCount + "&sort=ASC"; @@ -114,7 +569,7 @@ AtlasGlossaryElement getAtlasGlossary(int glossaryCount) throws PropertyServerEx * @return glossary or null * @throws PropertyServerException problem with the request */ - AtlasGlossaryElement getAtlasGlossary(String glossaryGUID) throws PropertyServerException + public AtlasGlossaryElement getAtlasGlossary(String glossaryGUID) throws PropertyServerException { final String methodName = "getAtlasGlossary(glossaryGUID)"; final String url = baseURL + "/api/atlas/v2/glossary/" + glossaryGUID; @@ -130,7 +585,7 @@ AtlasGlossaryElement getAtlasGlossary(String glossaryGUID) throws PropertyServer * @return glossaryGUID * @throws PropertyServerException problem with the request */ - String createAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException + public String createAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException { final String methodName = "createAtlasGlossary(glossary)"; final String url = baseURL + "/api/atlas/v2/glossary"; @@ -153,7 +608,7 @@ String createAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerE * @return glossary or null * @throws PropertyServerException problem with the request */ - AtlasGlossaryElement saveAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException + public AtlasGlossaryElement saveAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException { final String methodName = "saveAtlasGlossary(glossary)"; final String url = baseURL + "/api/atlas/v2/glossary/{0}"; @@ -169,7 +624,7 @@ AtlasGlossaryElement saveAtlasGlossary(AtlasGlossaryElement glossary) throws Pro * @param glossary glossary to delete * @throws PropertyServerException problem with the request */ - void deleteAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException + public void deleteAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerException { final String methodName = "deleteAtlasGlossary()"; final String url = baseURL + "/api/atlas/v2/glossary/" + glossary.getGuid(); @@ -185,7 +640,7 @@ void deleteAtlasGlossary(AtlasGlossaryElement glossary) throws PropertyServerExc * @return glossary or null * @throws PropertyServerException problem with the request */ - AtlasGlossaryTermElement getAtlasGlossaryTerm(String glossaryTermGUID) throws PropertyServerException + public AtlasGlossaryTermElement getAtlasGlossaryTerm(String glossaryTermGUID) throws PropertyServerException { final String methodName = "getAtlasGlossaryTerm(glossaryTermGUID)"; final String url = baseURL + "/api/atlas/v2/glossary/term/" + glossaryTermGUID; @@ -202,8 +657,8 @@ AtlasGlossaryTermElement getAtlasGlossaryTerm(String glossaryTermGUID) throws Pr * @throws PropertyServerException problem with the request * @throws NameConflictException the name supplied clashes with another term */ - String createAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException, - NameConflictException + public String createAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException, + NameConflictException { final String methodName = "createAtlasGlossaryTerm()"; final String url = baseURL + "/api/atlas/v2/glossary/term"; @@ -245,7 +700,7 @@ String createAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertySer * @return term or null * @throws PropertyServerException problem with the request */ - AtlasGlossaryTermElement saveAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException + public AtlasGlossaryTermElement saveAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException { final String methodName = "saveAtlasGlossaryTerm()"; final String url = baseURL + "/api/atlas/v2/glossary/term/{0}"; @@ -260,7 +715,7 @@ AtlasGlossaryTermElement saveAtlasGlossaryTerm(AtlasGlossaryTermElement term) th * @param term term to delete * @throws PropertyServerException problem with the request */ - void deleteAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException + public void deleteAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServerException { final String methodName = "deleteAtlasGlossaryTerm()"; final String url = baseURL + "/api/atlas/v2/glossary/term/" + term.getGuid(); @@ -276,7 +731,7 @@ void deleteAtlasGlossaryTerm(AtlasGlossaryTermElement term) throws PropertyServe * @return glossary or null * @throws PropertyServerException problem with the request */ - AtlasGlossaryCategoryElement getAtlasGlossaryCategory(String glossaryCategoryGUID) throws PropertyServerException + public AtlasGlossaryCategoryElement getAtlasGlossaryCategory(String glossaryCategoryGUID) throws PropertyServerException { final String methodName = "getAtlasGlossaryCategory(glossaryCategoryGUID)"; final String url = baseURL + "/api/atlas/v2/glossary/category/" + glossaryCategoryGUID; @@ -293,8 +748,8 @@ AtlasGlossaryCategoryElement getAtlasGlossaryCategory(String glossaryCategoryGUI * @throws PropertyServerException problem with the request * @throws NameConflictException the name supplied clashes with another term */ - String createAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException, - NameConflictException + public String createAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException, + NameConflictException { final String methodName = "createAtlasGlossaryCategory(category)"; final String url = baseURL + "/api/atlas/v2/glossary/category"; @@ -335,7 +790,7 @@ String createAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws * @return glossary category or null * @throws PropertyServerException problem with the request */ - AtlasGlossaryCategoryElement saveAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException + public AtlasGlossaryCategoryElement saveAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException { final String methodName = "saveAtlasGlossaryCategory(glossaryGUID)"; final String url = baseURL + "/api/atlas/v2/glossary/category/{0}"; @@ -350,7 +805,7 @@ AtlasGlossaryCategoryElement saveAtlasGlossaryCategory(AtlasGlossaryCategoryElem * @param category category to create/update * @throws PropertyServerException problem with the request */ - void deleteAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException + public void deleteAtlasGlossaryCategory(AtlasGlossaryCategoryElement category) throws PropertyServerException { final String methodName = "deleteAtlasGlossaryCategory(glossaryGUID)"; final String url = baseURL + "/api/atlas/v2/glossary/category/" + category.getGuid(); @@ -380,7 +835,35 @@ protected T callGetRESTCallNoParams(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); + } + + return null; + } + + + /** + * Issue a GET REST call that returns a response object. + * + * @param return type + * @param methodName name of the method being called. + * @param returnClass class of the response object. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * + * @return response object + * @throws PropertyServerException something went wrong with the REST call stack. + */ + protected T callNoLogGetRESTCallNoParams(String methodName, + Class returnClass, + String urlTemplate) throws PropertyServerException + { + try + { + return clientConnector.callGetRESTCall(methodName, returnClass, urlTemplate); + } + catch (Exception error) + { + logRESTCallException(methodName, true, error); } return null; @@ -410,7 +893,7 @@ protected T callGetRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -440,7 +923,38 @@ protected T callGetRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); + } + + return null; + } + + + /** + * Issue a GET REST call that returns a response object. It's working only with {@link SpringRESTClientConnector} + * + * @param return type + * @param methodName name of the method being called. + * @param responseType class of the response object. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param params a list of parameters that are slotted into the url template. + * + * @return response object + * @throws PropertyServerException something went wrong with the REST call stack. + */ + protected T callNoLogGetRESTCall(String methodName, + ParameterizedTypeReference responseType, + String urlTemplate, + Object... params) throws PropertyServerException + { + try + { + SpringRESTClientConnector clientConnector = (SpringRESTClientConnector) this.clientConnector; + return clientConnector.callGetRESTCall(methodName, responseType, urlTemplate, params); + } + catch (Exception error) + { + logRESTCallException(methodName, false, error); } return null; @@ -471,7 +985,38 @@ protected T callPostRESTCallNoParams(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); + } + + return null; + } + + + /** + * Issue a POST REST call that returns a response object. This is typically a create, update, or find with + * complex parameters. + * + * @param return type + * @param methodName name of the method being called. + * @param returnClass class of the response object. + * @param urlTemplate template of the URL for the REST API call with place-holders for the parameters. + * @param requestBody request body for the request. + * + * @return response object + * @throws PropertyServerException something went wrong with the REST call stack. + */ + protected T callNoLogPostRESTCallNoParams(String methodName, + Class returnClass, + String urlTemplate, + Object requestBody) throws PropertyServerException + { + try + { + return clientConnector.callPostRESTCallNoParams(methodName, returnClass, urlTemplate, requestBody); + } + catch (Exception error) + { + logRESTCallException(methodName, false, error); } return null; @@ -507,7 +1052,7 @@ protected T callPostRESTCallNameConflict(String methodName, */ if (! error.getMessage().contains("org.springframework.web.client.HttpClientErrorException$Conflict")) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } throw new PropertyServerException(ApacheAtlasErrorCode.CLIENT_SIDE_REST_API_ERROR.getMessageDefinition(methodName, @@ -547,7 +1092,7 @@ protected T callPostRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -580,7 +1125,7 @@ protected T callPostRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -611,7 +1156,7 @@ protected T callPutRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -644,7 +1189,7 @@ protected T callPutRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -674,7 +1219,7 @@ protected T callDeleteRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -698,7 +1243,7 @@ protected void callDeleteRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } } @@ -726,7 +1271,7 @@ protected T callDeleteRESTCall(String methodName, } catch (Exception error) { - logRESTCallException(methodName, error); + logRESTCallException(methodName, true, error); } return null; @@ -737,13 +1282,15 @@ protected T callDeleteRESTCall(String methodName, * Provide detailed logging for exceptions. * * @param methodName calling method + * @param logMessage should log message * @param error resulting exception * @throws PropertyServerException wrapping exception */ private void logRESTCallException(String methodName, + boolean logMessage, Exception error) throws PropertyServerException { - if (auditLog != null) + if ((auditLog != null) && (logMessage)) { auditLog.logException(methodName, ApacheAtlasAuditCode.CLIENT_SIDE_REST_API_ERROR.getMessageDefinition(methodName, diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/AtlasIntegrationModuleBase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/AtlasIntegrationModuleBase.java deleted file mode 100644 index 0f0d2b5eee4..00000000000 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/AtlasIntegrationModuleBase.java +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas; - -import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; -import org.odpi.openmetadata.frameworks.auditlog.AuditLog; -import org.odpi.openmetadata.frameworks.connectors.Connector; -import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; -import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; -import org.odpi.openmetadata.frameworks.integration.context.IntegrationContext; -import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * AtlasIntegrationModuleBase defines the interface that classes that support the synchronization of particular types of metadata with Apache Atlas. - */ -public abstract class AtlasIntegrationModuleBase -{ - protected final static String egeriaGUIDPropertyName = "egeriaGUID"; - protected final static String egeriaOwnedPropertyName = "egeriaOwned"; - - protected final AuditLog auditLog; - protected final String connectorName; - protected final ConnectionProperties connectionProperties; - protected final CatalogIntegratorContext myContext; - protected final List embeddedConnectors; - protected final ApacheAtlasRESTClient atlasClient; - private final List supportedTypes; - - protected final String targetRootURL; - - public AtlasIntegrationModuleBase(String connectorName, - ConnectionProperties connectionProperties, - AuditLog auditLog, - CatalogIntegratorContext myContext, - String targetRootURL, - ApacheAtlasRESTClient atlasClient, - List embeddedConnectors, - String[] supportedTypes) - { - this.auditLog = auditLog; - this.connectorName = connectorName; - this.connectionProperties = connectionProperties; - this.myContext = myContext; - this.targetRootURL = targetRootURL; - this.atlasClient = atlasClient; - this.embeddedConnectors = embeddedConnectors; - this.supportedTypes = Arrays.asList(supportedTypes); - } - - - /** - * Return the list of open metadata types that this module supports. - * - * @return list of types - */ - public List getSupportedTypes() - { - return supportedTypes; - } - - - /** - * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. - * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration - * as well as any external REST API calls to explicitly refresh the connector. - * - * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. - */ - public abstract void refresh() throws ConnectorCheckedException; - - - /** - * Process an event that was published by the Asset Manager OMAS. The listener is only registered if metadata is flowing - * from the open metadata ecosystem to Apache Atlas. - * - * @param event event object - */ - public abstract void processEvent(AssetManagerOutTopicEvent event); -} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasAuditCode.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasAuditCode.java index 8e4a0c47f37..8d7da3671dd 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasAuditCode.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasAuditCode.java @@ -268,6 +268,109 @@ public enum ApacheAtlasAuditCode implements AuditLogMessageSet "The connector attempts to add a numerical post-fix to the term name to ensure it has a unique name.", "No action is required. The connector will validate whether it has already created the term on another thread, or it will try the request with a new name."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0035 - The {0} integration connector is calling the {1} integration module + */ + SYNC_INTEGRATION_MODULE("APACHE-ATLAS-INTEGRATION-CONNECTOR-0035", + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector is calling the {1} integration module", + "The connector is calling one of its registered integration modules to refresh the metadata it is responsible for.", + "No action is required. This message is to record that the connector is working it way through the registered integration modules. If an error occurs this message helps to identify which module experienced the error."), + + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0036 - The {0} integration connector can not retrieve the correlation information for {1} open metadata entity {2} linked in Apache Atlas {3} to {4} entity {5} + */ + MISSING_CORRELATION("APACHE-ATLAS-INTEGRATION-CONNECTOR-0036", + OMRSAuditLogRecordSeverity.ERROR, + "The {0} integration connector can not retrieve the correlation information for {1} open metadata entity {2} linked in Apache Atlas {3} to {4} entity {5}", + "The correlation information that should be associated with the open metadata entity is missing and the integration connector is not able to confidently synchronize it with the Apache Atlas entity.", + "Review the audit log to determine if there were errors detected when the open metadata entity was created. The simplest resolution is to delete the open metadata entity. However, if this entity has been enhanced with many attachments and classifications then it is also possible to add the correlation information to the open metadata entity to allow the synchronization to continue."), + + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0040 - The integration connector {0} created open metadata {1} entity {2} match Apache Atlas {3} entity {4} + */ + CREATING_EGERIA_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0040", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} created open metadata {1} entity {2} match Apache Atlas {3} entity {4}", + "The connector is has created the open metadata entity with information from the Apache Atlas entity.", + "No action is required. The connector working to ensure the open metadata ecosystem can store metadata from Apache Atlas."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0041 - The integration connector {0} created Apache Atlas {1} entity {2} match open metadata {3} entity {4} + */ + CREATING_ATLAS_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0041", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} created Apache Atlas {1} entity {2} match open metadata {3} entity {4}", + "The connector is has created the Apache Atlas entity with information from the open metadata entity.", + "No action is required. The connector working to ensure Apache Atlas can store metadata from the open metadata ecosystem."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0042 - The integration connector {0} is synchronizing Apache Atlas {1} entity {2} to {3} open metadata entity {4} + */ + UPDATING_EGERIA_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0042", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} is synchronizing Apache Atlas {1} entity {2} to {3} open metadata entity {4}", + "The connector is updating the open metadata entity with information from the Apache Atlas entity.", + "No action is required. The connector working to keep the Open metadata entity consistent with its Apache Atlas equivalent."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0043 - The integration connector {0} is synchronizing open metadata {1} entity {2} to the {3} Apache Atlas entity {4} + */ + UPDATING_ATLAS_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0043", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} is synchronizing open metadata {1} entity {2} to the {3} Apache Atlas entity {4}", + "The connector is updating the Apache Atlas entity with information from the open metadata entity.", + "No action is required. The connector working to keep the Apache Atlas entity consistent with the open metadata one."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0044 - The integration connector {0} is deleting {1} open metadata entity {2} since Apache Atlas entity {3} has been removed + */ + DELETING_EGERIA_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0044", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} is deleting {1} open metadata entity {2} since Apache Atlas entity {3} has been removed", + "The connector is deleting the open metadata entity because the Apache Atlas entity where its content is sourced from has gone.", + "No action is required. The connector is working to keep the two systems consistent."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0045 - The integration connector {0} is deleting the {1} Apache Atlas entity {2} since the open metadata entity {3} has been removed + */ + DELETING_ATLAS_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0045", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} is deleting the {1} Apache Atlas entity {2} since the open metadata entity {3} has been removed", + "The connector is deleting the Apache Atlas entity because the open metadata entity where its content is sourced from has gone.", + "No action is required. The connector is working to keep the entities in the two systems consistent."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0046 - The integration connector {0} is replacing {1} open metadata entity {2} for Apache Atlas entity {3} since the open metadata entity has been unilaterally removed + */ + REPLACING_EGERIA_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0046", + OMRSAuditLogRecordSeverity.ERROR, + "The integration connector {0} is replacing {1} open metadata entity {2} for Apache Atlas entity {3} since the open metadata entity has been unilaterally removed", + "The connector is creating a new open metadata entity to represent the Apache Atlas entity in the open metadata ecosystem. This is because the entity originated in Apache Atlas and this is the proper place to delete the entity.", + "Investigate why the connector can not retrieve the original open metadata entity. Has it been deleted, archived or moved to a governance zone that is not visible to this connector? Make changes to ensure the open metadata entities synchronized from Apache Atlas are only maintained by this connector."), + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0047 - The integration connector {0} is replacing Apache Atlas {1} entity {2} for open metadata entity {3} since the Apache Atlas entity has been unilaterally removed + */ + REPLACING_ATLAS_ENTITY("APACHE-ATLAS-INTEGRATION-CONNECTOR-0047", + OMRSAuditLogRecordSeverity.ERROR, + "The integration connector {0} is replacing Apache Atlas {1} entity {2} for open metadata entity {3} since the Apache Atlas entity has been unilaterally removed", + "The connector is creating a new Apache Atlas entity to represent the open metadata entity from the open metadata ecosystem. This is because the entity originated in the open metadata ecosystem and this is the proper place to delete the entity.", + "Investigate why the connector can not retrieve the original Apache Atlas. Make changes to ensure the Apache Atlas entities synchronized from the open metadata ecosystem are only maintained by this connector."), + + + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0048 - The integration connector {0} is adding a DataFlow lineage relationship from {1} open metadata entity {2} to {3} open metadata entity {4} + */ + ADDING_LINEAGE("APACHE-ATLAS-INTEGRATION-CONNECTOR-0048", + OMRSAuditLogRecordSeverity.INFO, + "The integration connector {0} is adding a DataFlow lineage relationship from {1} open metadata entity {2} to {3} open metadata entity {4}", + "The connector is creating a new lineage relationship around a process base on a similar relationship in Apache Atlas.", + "No action is required. The connector is working to keep the two systems view of lineage consistent."), + ; private final String logMessageId; diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasErrorCode.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasErrorCode.java index d240639bef0..3db6a96265b 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasErrorCode.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/ApacheAtlasErrorCode.java @@ -73,6 +73,14 @@ public enum ApacheAtlasErrorCode implements ExceptionMessageSet "No action is required. The connector will validate whether it has already created the term on another thread, or it will try the request with a new name."), + /** + * APACHE-ATLAS-INTEGRATION-CONNECTOR-0036 - The {0} integration connector can not retrieve the correlation information for (1} open metadata entity {2} linked in Apache Atlas {3} to {4} entity {5} + */ + MISSING_CORRELATION(404, "APACHE-ATLAS-INTEGRATION-CONNECTOR-404-001", + "The {0} integration connector can not retrieve the correlation information for (1} open metadata entity {2} linked in Apache Atlas {3} to {4} entity {5}", + "The correlation information that should be associated with the open metadata entity is missing and the integration connector is not able to confidently synchronize it with the Apache Atlas entity.", + "Review the audit log to determine if there were errors detected when the open metadata entity was created. The simplest resolution is to delete the open metadata entity. However, if this entity has been enhanced with many attachments and classifications then it is also possible to add the correlation information to the open metadata entity to allow the synchronization to continue."), + /** * APACHE-ATLAS-INTEGRATION-CONNECTOR-500-001 - The {0} integration connector received an unexpected exception {1} during method {2}; the error message was: {3} */ diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/package-info.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/package-info.java index 7e7d09196fe..66527efdc80 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/package-info.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ffdc/package-info.java @@ -2,8 +2,8 @@ /* Copyright Contributors to the ODPi Egeria project. */ /** * FFDC stands for First Failure Data Capture. The classes in this package provide the message definitions and - * descriptions used by the kafka monitor integration connector. AtlasIntegrationConnectorAuditCode contains the - * messages for the audit log and the AtlasIntegrationConnectorErrorCode contains the messages for any exceptions + * descriptions used by the Apache Atlas integration connector. ApacheAtlasAuditCode contains the + * messages for the audit log and the ApacheAtlasErrorCode contains the messages for any exceptions * that are thrown by the connectors. */ package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc; diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/ApacheHiveIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/ApacheHiveIntegrationModule.java new file mode 100644 index 00000000000..f0a84e09728 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/ApacheHiveIntegrationModule.java @@ -0,0 +1,203 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + + +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataAssetProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SchemaAttributeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityWithExtInfo; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * ApacheHiveIntegrationModule manages the cataloguing of Apache Hive entities stored in Apache Atlas into the open metadata ecosystem. + */ +public class ApacheHiveIntegrationModule extends DatabaseIntegrationModuleBase +{ + private static final String hiveModuleName = "Apache Hive Integration Module"; + + private static final String hiveDatabaseTypeName = "hive_db"; + private static final String hiveDatabaseTablesPropertyName = "tables"; + private static final String hiveDatabaseTableTypeName = "hive_table"; + private static final String hiveDatabaseColumnsPropertyName = "columns"; + private static final String hiveDatabaseColumnTypeName = "hive_column"; + + private static final String hiveLocationPathPropertyName = "locationPath"; + private static final String egeriaPathTypeName = "DataFile"; + + + + /** + * Constructor for the module is supplied with the runtime context in order to operate. + * + * @param connectorName name of the connector (for messages) + * @param connectionProperties connection properties used to start the connector + * @param auditLog logging destination + * @param myContext integration context + * @param targetRootURL URL to connect to Apache Atlas + * @param atlasClient client to connect to Apache Atlas + * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector + * @throws UserNotAuthorizedException security problem + */ + public ApacheHiveIntegrationModule(String connectorName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + super(connectorName, + hiveModuleName, + hiveDatabaseTypeName, + hiveDatabaseTablesPropertyName, + hiveDatabaseTableTypeName, + hiveDatabaseColumnsPropertyName, + hiveDatabaseColumnTypeName, + connectionProperties, + auditLog, + myContext, + targetRootURL, + atlasClient, + embeddedConnectors); + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected DataAssetProperties getEgeriaDatabaseProperties(AtlasEntity atlasEntity, + String egeriaTypeName) + { + DataAssetProperties dataAssetProperties = super.getDataAssetProperties(atlasEntity, egeriaTypeName); + + dataAssetProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasAssetProperties)); + + return dataAssetProperties; + } + + + /** + * Allow a subclass to attach additional information to the database. + * + * @param atlasDatabaseEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + @Override + protected void augmentAtlasDatabaseInEgeria(AtlasEntityWithExtInfo atlasDatabaseEntity, + String egeriaDatabaseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + AtlasEntityWithExtInfo hivePathEntity = atlasClient.getRelatedEntity(atlasDatabaseEntity, hiveLocationPathPropertyName); + + if ((hivePathEntity != null) && (hivePathEntity.getEntity() != null)) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(hivePathEntity.getEntity().getGuid(), + hivePathEntity.getEntity().getTypeName(), + hivePathEntity.getEntity().getCreatedBy(), + hivePathEntity.getEntity().getCreateTime(), + hivePathEntity.getEntity().getUpdatedBy(), + hivePathEntity.getEntity().getUpdateTime(), + hivePathEntity.getEntity().getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + DataAssetProperties dataAssetProperties = getEgeriaDataFileProperties(hivePathEntity.getEntity(), + egeriaPathTypeName); + + String dataFileGUID = dataAssetExchangeService.createDataAsset(true, + externalIdentifierProperties, + dataAssetProperties); + setOwner(hivePathEntity, dataFileGUID); + } + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaSchemaAttributeTypeName name of the type used in the open metadata ecosystem + * @param egeriaSchemaTypeTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected SchemaAttributeProperties getEgeriaDatabaseTableProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName) + { + SchemaAttributeProperties schemaAttributeProperties = super.getSchemaAttributeProperties(atlasEntity, + egeriaSchemaAttributeTypeName, + egeriaSchemaTypeTypeName); + + schemaAttributeProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasAssetProperties)); + + return schemaAttributeProperties; + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaSchemaAttributeTypeName name of the type used in the open metadata ecosystem + * @param egeriaSchemaTypeTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected SchemaAttributeProperties getEgeriaDatabaseColumnProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName) + { + final String typeNamePropertyName = "type"; + + /* + * Begin by mapping the common DataSet properties. + */ + SchemaAttributeProperties schemaAttributeProperties = super.getSchemaAttributeProperties(atlasEntity, + egeriaSchemaAttributeTypeName, + egeriaSchemaTypeTypeName); + Map attributes = atlasEntity.getAttributes(); + + String dataTypeName = getAtlasStringProperty(attributes, typeNamePropertyName); + + if (dataTypeName == null) + { + dataTypeName = "string"; + } + + Map extendedProperties = new HashMap<>(); + + extendedProperties.put("dataType", dataTypeName); + schemaAttributeProperties.getSchemaType().setExtendedProperties(extendedProperties); + + List atlasColumnPropertyNames = new ArrayList<>(atlasAssetProperties); + + atlasColumnPropertyNames.add(typeNamePropertyName); + schemaAttributeProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasColumnPropertyNames)); + + return schemaAttributeProperties; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/ApacheKafkaIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/ApacheKafkaIntegrationModule.java new file mode 100644 index 00000000000..4577623db71 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/ApacheKafkaIntegrationModule.java @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + + +import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; + +import java.util.List; + +/** + * ApacheKafkaIntegrationModule maps Apache Kafka resources catalogued in Apache Atlas into the open metadata ecosystem. + */ +public class ApacheKafkaIntegrationModule extends AtlasRegisteredIntegrationModuleBase +{ + private final static String kafkaModuleName = "Apache Kafka Integration Module"; + private final static String egeriaKafkaTypeName = "KafkaTopic"; + private final static String atlasKafkaTypeName = "kafka_topic"; + private final static String egeriaJMSTypeName = "Topic"; + private final static String atlasJMSTypeName = "jms_topic"; + + + /** + * Constructor for the module is supplied with the runtime context in order to operate. + * + * @param connectorName name of the connector (for messages) + * @param connectionProperties connection properties used to start the connector + * @param auditLog logging destination + * @param myContext integration context + * @param targetRootURL URL to connect to Apache Atlas + * @param atlasClient client to connect to Apache Atlas + * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector + * @throws UserNotAuthorizedException security problem + */ + public ApacheKafkaIntegrationModule(String connectorName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + super(connectorName, + kafkaModuleName, + connectionProperties, + auditLog, + myContext, + targetRootURL, + atlasClient, + embeddedConnectors, + new String[]{atlasKafkaTypeName, atlasJMSTypeName}, + null); + } + + + /** + * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. + * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration + * as well as any external REST API calls to explicitly refresh the connector. + * + * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. + */ + @Override + public void refresh() throws ConnectorCheckedException + { + final String methodName = "refresh(" + moduleName + ")"; + + /* + * The configuration can turn off the cataloguing of assets into the open metadata ecosystem. + */ + if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || + (myContext.getPermittedSynchronization() == PermittedSynchronization.TO_THIRD_PARTY)) + { + try + { + /* + * Retrieve the topics catalogued in Apache Atlas. This is turned into an Open Metadata Topic entities. + */ + syncAtlasDataSetsAsDataSets(atlasKafkaTypeName, egeriaKafkaTypeName); + syncAtlasDataSetsAsDataSets(atlasJMSTypeName, egeriaJMSTypeName); + } + catch (Exception error) + { + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); + } + + throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + this.getClass().getName(), + methodName, + error); + } + } + } + + + /** + * Process an event that was published by the Asset Manager OMAS. The listener is only registered if metadata is flowing + * from the open metadata ecosystem to Apache Atlas. + * + * @param event event object + */ + @Override + public void processEvent(AssetManagerOutTopicEvent event) + { + // Ignore events + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasGlossaryIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasGlossaryIntegrationModule.java new file mode 100644 index 00000000000..8134563a494 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasGlossaryIntegrationModule.java @@ -0,0 +1,3013 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + + +import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryCategoryElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryCategoryProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.GlossaryTermProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasIntegrationProvider; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityHeader; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityWithExtInfo; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasObjectId; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationship; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; +import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; +import org.odpi.openmetadata.integrationservices.catalog.connector.GlossaryExchangeService; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + + +/** + * AtlasGlossaryIntegrationModule exchanges glossary terms between Apache Atlas and the open metadata ecosystem. + */ +public class AtlasGlossaryIntegrationModule extends AtlasRegisteredIntegrationModuleBase +{ + private final static String moduleName = "Glossary Integration Module"; + private final static String atlasGlossaryTypeName = "AtlasGlossary"; + private final static String atlasGlossaryCategoriesPropertyName = "categories"; + private final static String atlasGlossaryCategoryTypeName = "AtlasGlossaryCategory"; + private final static String atlasParentCategoryPropertyName = "parentCategory"; + private final static String atlasGlossaryTermsPropertyName = "terms"; + private final static String atlasGlossaryTermTypeName = "AtlasGlossaryTerm"; + private final static String atlasSemanticAssignmentTypeName = "AtlasGlossarySemanticAssignment"; + private final static String atlasTermCategorizationTypeName = "AtlasGlossaryTermCategorization"; + private final static String atlasCategoryHierarchyTypeName = "AtlasGlossaryCategoryHierarchyLink"; + private final static String atlasGlossaryAnchorPropertyName = "anchor"; + private final static String atlasShortDescriptionPropertyName = "shortDescription"; + private final static String atlasLongDescriptionPropertyName = "longDescription"; + private final static String atlasAdditionalAttributesPropertyName = "additionalAttributes"; + private final static String atlasLanguagePropertyName = "language"; + private final static String atlasUsagePropertyName = "usage"; + private final static String atlasExamplesPropertyName = "examples"; + private final static String atlasAbbreviationPropertyName = "abbreviation"; + + private final static String egeriaGlossaryTypeName = "Glossary"; + private final static String egeriaGlossaryCategoryTypeName = "GlossaryCategory"; + private final static String egeriaGlossaryTermTypeName = "GlossaryTerm"; + + private String fixedEgeriaGlossaryQualifiedName = null; + private String fixedEgeriaGlossaryGUID = null; + private String atlasGlossaryName = null; + + private final GlossaryExchangeService glossaryExchangeService; + + /** + * Constructor for the module is supplied with the runtime context in order to operate. + * + * @param connectorName name of the connector (for messages) + * @param connectionProperties connection properties used to start the connector + * @param auditLog logging destination + * @param myContext integration context + * @param targetRootURL URL to connect to Apache Atlas + * @param atlasClient client to connect to Apache Atlas + * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector + * @throws UserNotAuthorizedException security problem + */ + public AtlasGlossaryIntegrationModule(String connectorName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + super(connectorName, + moduleName, + connectionProperties, + auditLog, + myContext, + targetRootURL, + atlasClient, + embeddedConnectors, + new String[]{"Glossary", "GlossaryCategory", "GlossaryTerm"}, + new String[]{"Glossary", "GlossaryCategory", "GlossaryTerm"}); + + final String methodName = "AtlasGlossaryIntegrationModule()"; + + Map configurationProperties = connectionProperties.getConfigurationProperties(); + + if (configurationProperties != null) + { + fixedEgeriaGlossaryQualifiedName = configurationProperties.get(ApacheAtlasIntegrationProvider.EGERIA_GLOSSARY_QUALIFIED_NAME_CONFIGURATION_PROPERTY).toString(); + atlasGlossaryName = configurationProperties.get(ApacheAtlasIntegrationProvider.ATLAS_GLOSSARY_NAME_CONFIGURATION_PROPERTY).toString(); + } + + /* + * Record the configuration + */ + if (auditLog != null) + { + if (fixedEgeriaGlossaryQualifiedName == null) + { + auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_ALL_EGERIA_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL)); + } + else + { + auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_SPECIFIC_EGERIA_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL, + fixedEgeriaGlossaryQualifiedName)); + } + + if (atlasGlossaryName == null) + { + auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_ALL_ATLAS_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL)); + } + else + { + auditLog.logMessage(methodName, ApacheAtlasAuditCode.CONNECTOR_CONFIGURATION_SPECIFIC_ATLAS_GLOSSARIES.getMessageDefinition(connectorName, targetRootURL, atlasGlossaryName)); + } + } + + /* + * The glossaryExchangeService provides access to the open metadata API. + */ + glossaryExchangeService = myContext.getGlossaryExchangeService(); + + /* + * Deduplication is turned off so that the connector works with the entities it created rather than + * entities from other systems that have been linked as duplicates. + */ + glossaryExchangeService.setForDuplicateProcessing(true); + } + + + /* ============================================================================== + * Standard methods that trigger activity. + */ + + /** + * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. + * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration + * as well as any external REST API calls to explicitly refresh the connector. + *

+ * This method performs two sweeps. It first retrieves the glossary elements from Egeria and synchronizes them with Apache Atlas. + * The second sweep works through the glossaries in Apache Atlas and ensures that none have been missed out by the first sweep. + * + * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. + */ + @Override + public void refresh() throws ConnectorCheckedException + { + final String methodName = "refresh"; + + try + { + /* + * Sweep 1 - Egeria to Atlas - but only if the configuration allows the exchange. + */ + if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || + (myContext.getPermittedSynchronization() == PermittedSynchronization.TO_THIRD_PARTY)) + { + if (fixedEgeriaGlossaryQualifiedName == null) + { + /* + * Exchange all glossaries found in the open metadata ecosystem. + */ + List glossaries = glossaryExchangeService.findGlossaries(".*", 0, 0, new Date()); + + if (glossaries != null) + { + for (GlossaryElement glossary : glossaries) + { + this.processGlossaryFromEgeria(glossary); + } + } + } + else + { + /* + * Only exchange the specific named glossary + */ + GlossaryElement glossary = this.getGlossaryByQualifiedName(fixedEgeriaGlossaryQualifiedName, methodName); + + if (glossary != null) + { + this.processGlossaryFromEgeria(glossary); + } + else + { + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UNABLE_TO_RETRIEVE_EGERIA_GLOSSARY.getMessageDefinition(connectorName, + fixedEgeriaGlossaryQualifiedName)); + } + } + } + } + + /* + * Sweep 2 - Atlas to Egeria - assuming metadata synchronization is set up to copy metadata from Apache Atlas to the open metadata ecosystem. + */ + if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || + (myContext.getPermittedSynchronization() == PermittedSynchronization.FROM_THIRD_PARTY)) + { + /* + * The Atlas Glossaries are retrieved one at a time. The aim is to look for new glossaries in Apache Atlas that have no presence in + * the open metadata ecosystem. + */ + boolean requestedAtlasGlossaryMissing = (atlasGlossaryName != null); + + int startFrom = 0; + int pageSize = myContext.getMaxPageSize(); + + List atlasSearchResult = atlasClient.getEntitiesForType(atlasGlossaryTypeName, startFrom, pageSize); + + while ((atlasSearchResult != null) && (! atlasSearchResult.isEmpty())) + { + /* + * Found new databases - process each one in turn. + */ + for (AtlasEntityHeader atlasEntityHeader : atlasSearchResult) + { + String atlasGlossaryGUID = atlasEntityHeader.getGuid(); + + AtlasEntityWithExtInfo atlasGlossaryEntity = atlasClient.getEntityByGUID(atlasGlossaryGUID); + + if (atlasGlossaryName == null) + { + /* + * The connector is configured to synchronize all Atlas glossaries. + */ + this.processGlossaryFromAtlas(atlasGlossaryEntity); + } + else if (atlasGlossaryName.equals(this.getAtlasStringProperty(atlasGlossaryEntity.getEntity().getAttributes(), atlasNamePropertyName))) + { + /* + * The specifically requested glossary has been found. + */ + this.processGlossaryFromAtlas(atlasGlossaryEntity); + requestedAtlasGlossaryMissing = false; + } + + /* + * Retrieve the next page + */ + startFrom = startFrom + pageSize; + atlasSearchResult = atlasClient.getEntitiesForType(atlasGlossaryTypeName, startFrom, pageSize); + } + } + + /* + * This message means that the specifically requested Atlas glossary has not been found. + * The connector will try again on the next refresh. + */ + if (requestedAtlasGlossaryMissing) + { + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UNABLE_TO_RETRIEVE_ATLAS_GLOSSARY.getMessageDefinition(connectorName, + atlasGlossaryName)); + } + } + } + } + catch (Exception error) + { + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); + } + + throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + this.getClass().getName(), + methodName, + error); + } + } + + + /** + * Process an event that was published by the Asset Manager OMAS. This connector is only interested in listening for + * glossaries, glossary categories and glossary terms. The listener that calls this method is only registered if metadata is flowing + * from the open metadata ecosystem to Apache Atlas. + * + * @param event event object + */ + @Override + public void processEvent(AssetManagerOutTopicEvent event) + { + if (! myContext.isRefreshInProgress()) + { + try + { + ElementHeader elementHeader = event.getElementHeader(); + + if ((elementHeader != null) && (! isAtlasOwnedElement(elementHeader))) + { + /* + * Understand the type of the element that has changed to determine if it is of interest. + */ + if (myContext.isTypeOf(elementHeader, "Glossary")) + { + if (validGlossaryElement(elementHeader)) + { + processGlossaryFromEgeria(glossaryExchangeService.getGlossaryByGUID(elementHeader.getGUID(), null)); + } + } + else if (myContext.isTypeOf(elementHeader, "GlossaryTerm")) + { + GlossaryTermElement egeriaGlossaryTerm = glossaryExchangeService.getGlossaryTermByGUID(elementHeader.getGUID(), null); + + if (egeriaGlossaryTerm != null) + { + GlossaryElement egeriaGlossary = glossaryExchangeService.getGlossaryForTerm(elementHeader.getGUID(), null); + + if ((egeriaGlossary != null) && (validGlossaryElement(egeriaGlossary.getElementHeader()))) + { + AtlasEntityWithExtInfo atlasGlossary = this.getAtlasDestinationGlossaryForEgeriaEntity(egeriaGlossary); + + processGlossaryTermFromEgeria(egeriaGlossaryTerm, egeriaGlossary, atlasGlossary); + } + } + } + else if (myContext.isTypeOf(elementHeader, "GlossaryCategory")) + { + GlossaryCategoryElement egeriaGlossaryCategory = glossaryExchangeService.getGlossaryCategoryByGUID(elementHeader.getGUID(), null); + + if (egeriaGlossaryCategory != null) + { + GlossaryElement egeriaGlossary = glossaryExchangeService.getGlossaryForCategory(elementHeader.getGUID(), null); + + if (egeriaGlossary != null) + { + AtlasEntityWithExtInfo atlasGlossary = this.getAtlasDestinationGlossaryForEgeriaEntity(egeriaGlossary); + + processGlossaryCategoryFromEgeria(egeriaGlossaryCategory, atlasGlossary); + } + } + } + } + } + catch (InvalidParameterException error) + { + // Ignore as likely to be a deleted element + } + catch (Exception error) + { + final String methodName = "processEvent"; + + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); + } + } + } + } + + + /* ============================================================================================= + * Extract the guids from elements. If the GUIDs are null then the element needs to be created. + */ + + /** + * Check that the open metadata element is from an appropriate glossary. + * + * @param elementHeader details of the element to check + * @return boolean flag - true means it is ok to process the element + * @throws ConnectorCheckedException unexpected problem connecting to Egeria. + */ + private boolean validGlossaryElement(ElementHeader elementHeader) throws ConnectorCheckedException + { + final String methodName = "validGlossaryElement"; + + if (fixedEgeriaGlossaryQualifiedName != null) + { + String glossaryGUID = elementHeader.getGUID(); + + /* + * Set up the cached glossary GUID if not already set up. + */ + if (fixedEgeriaGlossaryGUID == null) + { + GlossaryElement glossaryElement = this.getGlossaryByQualifiedName(fixedEgeriaGlossaryQualifiedName, methodName); + + if (glossaryElement != null) + { + fixedEgeriaGlossaryGUID = glossaryElement.getElementHeader().getGUID(); + } + } + + return glossaryGUID.equals(fixedEgeriaGlossaryGUID); + } + + return true; + } + + + /** + * Return the unique identifier for the equivalent element in Apache Atlas. + * + * @param metadataElement retrieved metadata element + * @return string guid + */ + private String retryGetAtlasGUID(GlossaryTermElement metadataElement) + { + try + { + GlossaryTermElement refreshedTerm = glossaryExchangeService.getGlossaryTermByGUID(metadataElement.getElementHeader().getGUID(), + null); + + return this.getAtlasGUID(refreshedTerm); + } + catch (Exception notFound) + { + // try again later. + } + + return null; + } + + + /* ===================================================================================== + * Take a specific glossary element and determine which way to synchronize metadata. + */ + + /** + * The connector is about to process a glossary from the open metadata ecosystem. The origin of this element is unknown. + * + * @param egeriaGlossary open metadata glossary + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void processGlossaryFromEgeria(GlossaryElement egeriaGlossary) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "processGlossaryFromEgeria"; + + if (egeriaGlossary != null) + { + /* + * First stage is to ensure the properties of the glossary root element are synchronized. + */ + if (isAtlasOwnedElement(egeriaGlossary.getElementHeader())) + { + /* + * This element originated in Apache Atlas. The element from the open metadata ecosystem is just a copy. Therefore, + * we refresh its content from the Apache Atlas original. + */ + String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); + if (atlasGlossaryGUID != null) + { + AtlasEntityWithExtInfo atlasGlossary = atlasClient.getEntityByGUID(atlasGlossaryGUID); + + updateAtlasGlossaryInEgeria(atlasGlossary, egeriaGlossary.getElementHeader().getGUID()); + + /* + * Once the root element is synchronized, the categories and then the terms are synchronized. + * It is possible that these elements have different ownership to the root glossary element. + */ + processGlossaryCategoriesFromEgeria(egeriaGlossary, atlasGlossary); + processGlossaryTermsFromEgeria(egeriaGlossary, atlasGlossary); + } + else + { + /* + * Something has caused the external identifier for this entity to disappear + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.EGERIA_GUID_MISSING.getMessageDefinition("Glossary", + egeriaGlossary.getElementHeader().getGUID())); + } + } + else + { + /* + * This element originated in the open metadata ecosystem, so it is possible to copy it directly to Apache Atlas. + */ + AtlasEntityWithExtInfo atlasGlossary = syncEgeriaGlossaryInAtlas(egeriaGlossary); + + /* + * Once the root element is synchronized, the categories and then the terms are synchronized. + * It is possible that these elements have different ownership to the root glossary element. + */ + processGlossaryCategoriesFromEgeria(egeriaGlossary, atlasGlossary); + processGlossaryTermsFromEgeria(egeriaGlossary, atlasGlossary); + } + } + } + + + /** + * The connector is processing a glossary from the open metadata ecosystem. It is ready to step through each term in the glossary. + * The origin of each term is unknown. + * + * @param egeriaGlossary open metadata glossary + * @param atlasGlossary equivalent atlas glossary + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void processGlossaryTermsFromEgeria(GlossaryElement egeriaGlossary, + AtlasEntityWithExtInfo atlasGlossary) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + if (egeriaGlossary != null) + { + /* + * Step through the terms in the Egeria Glossary and make sure all term properties are synchronized. + */ + int startFrom = 0; + List egeriaGlossaryTerms = glossaryExchangeService.getTermsForGlossary(egeriaGlossary.getElementHeader().getGUID(), + startFrom, + myContext.getMaxPageSize(), + new Date()); + + while (egeriaGlossaryTerms != null) + { + for (GlossaryTermElement egeriaGlossaryTerm : egeriaGlossaryTerms) + { + this.processGlossaryTermFromEgeria(egeriaGlossaryTerm, egeriaGlossary, atlasGlossary); + } + + startFrom = startFrom + myContext.getMaxPageSize(); + egeriaGlossaryTerms = glossaryExchangeService.getTermsForGlossary(egeriaGlossary.getElementHeader().getGUID(), + startFrom, + myContext.getMaxPageSize(), + new Date()); + } + } + } + + + /** + * Copy the content of open metadata ecosystem glossary term to Apache Atlas. + * + * @param egeriaGlossaryTerm open metadata glossaryTermElement + * @param egeriaGlossary open metadata glossary + * @param atlasGlossary equivalent atlas glossary + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void processGlossaryTermFromEgeria(GlossaryTermElement egeriaGlossaryTerm, + GlossaryElement egeriaGlossary, + AtlasEntityWithExtInfo atlasGlossary) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if (egeriaGlossaryTerm != null) + { + final String methodName = "processGlossaryTermFromEgeria"; + + if (isAtlasOwnedElement(egeriaGlossaryTerm.getElementHeader())) + { + /* + * This element originated in Apache Atlas. The element from the open metadata ecosystem is just a copy. Therefore, + * we refresh its content from the Apache Atlas original. + */ + String atlasGlossaryTermGUID = getAtlasGUID(egeriaGlossaryTerm); + if (atlasGlossaryTermGUID != null) + { + updateAtlasGlossaryTermInEgeria(atlasClient.getEntityByGUID(atlasGlossaryTermGUID), egeriaGlossaryTerm); + } + else if (auditLog != null) + { + /* + * Something has caused the external identifier for this entity to disappear + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.EGERIA_GUID_MISSING.getMessageDefinition(egeriaGlossaryTermTypeName, + egeriaGlossaryTerm.getElementHeader().getGUID())); + } + } + else + { + /* + * This element originated in the open metadata ecosystem, so it is possible to copy it directly to Apache Atlas. + */ + this.syncEgeriaGlossaryTermInAtlas(egeriaGlossaryTerm, atlasGlossary); + } + } + } + + + /** + * The connector is processing a glossary from the open metadata ecosystem. It is ready to step through each category in the glossary. + * The origin of each category is unknown. + * + * @param egeriaGlossary open metadata glossary + * @param atlasGlossary equivalent atlas glossary + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void processGlossaryCategoriesFromEgeria(GlossaryElement egeriaGlossary, + AtlasEntityWithExtInfo atlasGlossary) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + if (egeriaGlossary != null) + { + /* + * Step through the categories in the Egeria Glossary and make sure all category properties are synchronized. + */ + int startFrom = 0; + List egeriaGlossaryCategories = glossaryExchangeService.getCategoriesForGlossary(egeriaGlossary.getElementHeader().getGUID(), + startFrom, + myContext.getMaxPageSize(), + new Date()); + + while (egeriaGlossaryCategories != null) + { + for (GlossaryCategoryElement egeriaGlossaryCategory : egeriaGlossaryCategories) + { + this.processGlossaryCategoryFromEgeria(egeriaGlossaryCategory, atlasGlossary); + } + + startFrom = startFrom + myContext.getMaxPageSize(); + egeriaGlossaryCategories = glossaryExchangeService.getCategoriesForGlossary(egeriaGlossary.getElementHeader().getGUID(), + startFrom, + myContext.getMaxPageSize(), + new Date()); + } + } + } + + + /** + * Copy the content of open metadata ecosystem glossary category to Apache Atlas. + * + * @param glossaryCategoryElement open metadata glossaryCategoryElement + * @param atlasGlossary equivalent atlas glossary + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void processGlossaryCategoryFromEgeria(GlossaryCategoryElement glossaryCategoryElement, + AtlasEntityWithExtInfo atlasGlossary) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "processGlossaryCategoryFromEgeria"; + + if (isAtlasOwnedElement(glossaryCategoryElement.getElementHeader())) + { + /* + * This element originated in Apache Atlas. The element from the open metadata ecosystem is just a copy. Therefore, + * we refresh its content from the Apache Atlas original. + */ + String atlasGlossaryCategoryGUID = getAtlasGUID(glossaryCategoryElement); + if (atlasGlossaryCategoryGUID != null) + { + updateAtlasGlossaryCategoryInEgeria(atlasClient.getEntityByGUID(atlasGlossaryCategoryGUID), + glossaryCategoryElement); + } + else + { + /* + * Something has caused the external identifier for this + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.EGERIA_GUID_MISSING.getMessageDefinition(egeriaGlossaryCategoryTypeName, + glossaryCategoryElement.getElementHeader().getGUID())); + } + } + else + { + /* + * This element originated in the open metadata ecosystem, so it is possible to copy it directly to Apache Atlas. + * It may, or may not exist in Apache Atlas at this time. + */ + syncEgeriaGlossaryCategoryInAtlas(glossaryCategoryElement, atlasGlossary); + } + } + + + /** + * Load glossary that originated in Apache Atlas into the open metadata ecosystem. + * + * @param atlasGlossaryElement glossary retrieved from Apache Atlas + * @throws PropertyServerException problem communicating with Apache Atlas + */ + private void processGlossaryFromAtlas(AtlasEntityWithExtInfo atlasGlossaryElement) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "processGlossaryFromAtlas"; + + String egeriaGlossaryGUID = this.getEgeriaGUID(atlasGlossaryElement); + + if (egeriaGlossaryGUID == null) + { + /* + * Assume the glossary is Atlas-owned because it has not been synchronized with Egeria. + */ + egeriaGlossaryGUID = this.createAtlasGlossaryInEgeria(atlasGlossaryElement); + + GlossaryElement egeriaGlossary = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, null); + + + /* + * The ownership of the categories and terms associated with the glossary is not known. + */ + this.processGlossaryCategoriesFromAtlas(atlasGlossaryElement, egeriaGlossary); + this.processGlossaryTermsFromAtlas(atlasGlossaryElement, egeriaGlossary); + } + else if (this.isEgeriaOwned(atlasGlossaryElement)) + { + GlossaryElement egeriaGlossary = null; + + try + { + egeriaGlossary = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, null); + } + catch (InvalidParameterException missingGlossary) + { + /* + * The Egeria glossary has been unilaterally deleted - so remove the atlas equivalent. + */ + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.EGERIA_GLOSSARY_DELETED.getMessageDefinition(egeriaGlossaryGUID, + this.getAtlasStringProperty(atlasGlossaryElement.getEntity().getAttributes(), + atlasNamePropertyName))); + } + } + + if (egeriaGlossary == null) + { + atlasClient.deleteEntity(atlasGlossaryElement.getEntity().getGuid()); + } + else + { + AtlasEntityWithExtInfo atlasGlossary = this.syncEgeriaGlossaryInAtlas(egeriaGlossary); + this.processGlossaryCategoriesFromEgeria(egeriaGlossary, atlasGlossary); + this.processGlossaryTermsFromEgeria(egeriaGlossary, atlasGlossary); + } + } + else // Atlas Owned + { + GlossaryElement egeriaGlossary = null; + + try + { + egeriaGlossary = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, new Date()); + } + catch (InvalidParameterException missingGlossary) + { + /* + * The Egeria glossary has been unilaterally deleted - so put it back. + * First remove the GUID for the deleted glossary from the Apache Atlas Glossary + * and then make a new copy the Atlas glossary in the open metadata ecosystem. + */ + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_GLOSSARY.getMessageDefinition(egeriaGlossaryGUID, + this.getAtlasStringProperty(atlasGlossaryElement.getEntity().getAttributes(), atlasNamePropertyName), + connectorName)); + } + + this.removeEgeriaGUID(atlasGlossaryElement); + } + + egeriaGlossary = this.syncAtlasGlossaryInEgeria(atlasGlossaryElement); + + if (egeriaGlossary != null) + { + this.processGlossaryCategoriesFromAtlas(atlasGlossaryElement, egeriaGlossary); + this.processGlossaryTermsFromAtlas(atlasGlossaryElement, egeriaGlossary); + } + } + } + + + /** + * Process each glossary term attached to an Atlas glossary. + * + * @param atlasGlossaryElement glossary from Atlas which includes a list of terms for the glossary + * @param egeriaGlossary equivalent glossary in the open metadata ecosystem + * @throws PropertyServerException problem communicating with Egeria or Atlas + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + */ + private void processGlossaryTermsFromAtlas(AtlasEntityWithExtInfo atlasGlossaryElement, + GlossaryElement egeriaGlossary) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if ((atlasGlossaryElement != null) && + (atlasGlossaryElement.getEntity() != null) && + (atlasGlossaryElement.getEntity().getRelationshipAttributes() != null)) + { + List terms = atlasClient.getRelatedEntities(atlasGlossaryElement, atlasGlossaryTermsPropertyName); + if (terms != null) + { + for (AtlasEntityWithExtInfo relatedAtlasTerm : terms) + { + processGlossaryTermFromAtlas(relatedAtlasTerm, atlasGlossaryElement, egeriaGlossary); + } + } + } + } + + + /** + * Process an individual term from an atlas glossary - at this point we do not know if it is owned by Atlas or Egeria. + * + * @param atlasGlossaryTerm term to process + * @param atlasGlossary glossary where it came from + * @param egeriaGlossary equivalent glossary in the open metadata ecosystem + * @throws PropertyServerException problem communicating with Egeria or Atlas + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + */ + private void processGlossaryTermFromAtlas(AtlasEntityWithExtInfo atlasGlossaryTerm, + AtlasEntityWithExtInfo atlasGlossary, + GlossaryElement egeriaGlossary) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "processAtlasGlossaryTerm"; + + String egeriaTermGUID = this.getEgeriaGUID(atlasGlossaryTerm); + + if (egeriaTermGUID == null) + { + /* + * Assume the term is Atlas-owned because it has not been synchronized with Egeria. + */ + this.createAtlasGlossaryTermInEgeria(atlasGlossaryTerm, egeriaGlossary); + } + else if (this.isEgeriaOwned(atlasGlossaryTerm)) + { + GlossaryTermElement egeriaGlossaryTerm = null; + + try + { + egeriaGlossaryTerm = glossaryExchangeService.getGlossaryTermByGUID(egeriaTermGUID, new Date()); + } + catch (InvalidParameterException missingTerm) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.EGERIA_GLOSSARY_TERM_DELETED.getMessageDefinition(egeriaTermGUID, + getAtlasStringProperty(atlasGlossaryTerm.getEntity().getAttributes(), + atlasQualifiedNamePropertyName))); + } + + if (egeriaGlossaryTerm == null) + { + atlasClient.deleteEntity(atlasGlossaryTerm.getEntity().getGuid()); + } + else + { + this.syncEgeriaGlossaryTermInAtlas(egeriaGlossaryTerm, atlasGlossary); + } + } + else // Atlas Owned + { + GlossaryTermElement egeriaGlossaryTerm = null; + + try + { + egeriaGlossaryTerm = glossaryExchangeService.getGlossaryTermByGUID(egeriaTermGUID, new Date()); + } + catch (InvalidParameterException missingTerm) + { + /* + * The Egeria glossary term has been unilaterally deleted - so put it back. + * First remove the GUID for the deleted glossary from the Apache Atlas Glossary + * and then make a new copy the Atlas glossary in the open metadata ecosystem. + */ + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_GLOSSARY_TERM.getMessageDefinition(egeriaTermGUID, + this.getAtlasStringProperty(atlasGlossaryTerm.getEntity().getAttributes(), atlasNamePropertyName), + connectorName)); + } + + this.removeEgeriaGUID(atlasGlossaryTerm); + } + + if (egeriaGlossaryTerm == null) + { + this.createAtlasGlossaryTermInEgeria(atlasGlossaryTerm, egeriaGlossary); + } + else + { + this.updateAtlasGlossaryTermInEgeria(atlasGlossaryTerm, egeriaGlossaryTerm); + } + } + } + + + /** + * Step through all the categories in an Atlas glossary to determine what needs to be synchronized. + * + * @param atlasGlossaryElement atlas glossary to process + * @param egeriaGlossary equivalent glossary in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void processGlossaryCategoriesFromAtlas(AtlasEntityWithExtInfo atlasGlossaryElement, + GlossaryElement egeriaGlossary) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if (atlasGlossaryElement != null) + { + List categories = atlasClient.getRelatedEntities(atlasGlossaryElement, atlasGlossaryCategoriesPropertyName); + if (categories != null) + { + for (AtlasEntityWithExtInfo relatedAtlasCategory : categories) + { + processGlossaryCategoryFromAtlas(relatedAtlasCategory, atlasGlossaryElement, egeriaGlossary); + } + } + } + } + + + /** + * Synchronize a specific category found in Apache Atlas - the origin of this element is not known at the start. + * + * @param atlasGlossaryCategory category of interest + * @param atlasGlossary full list of glossary contents + * @param egeriaGlossary equivalent glossary in the open metadata ecosystem + * @throws PropertyServerException problem communicating with Egeria or Atlas + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + */ + private void processGlossaryCategoryFromAtlas(AtlasEntityWithExtInfo atlasGlossaryCategory, + AtlasEntityWithExtInfo atlasGlossary, + GlossaryElement egeriaGlossary) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + final String methodName = "processGlossaryCategoryFromAtlas"; + + String egeriaCategoryGUID = this.getEgeriaGUID(atlasGlossaryCategory); + + if (egeriaCategoryGUID == null) + { + /* + * Assume the category is Atlas-owned because it has not been synchronized with Egeria. + */ + this.createAtlasGlossaryCategoryInEgeria(atlasGlossaryCategory, egeriaGlossary); + } + else if (this.isEgeriaOwned(atlasGlossaryCategory)) + { + GlossaryCategoryElement egeriaGlossaryCategory = null; + + try + { + egeriaGlossaryCategory = glossaryExchangeService.getGlossaryCategoryByGUID(egeriaCategoryGUID, new Date()); + } + catch (InvalidParameterException missingCategory) + { + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.EGERIA_GLOSSARY_CATEGORY_DELETED.getMessageDefinition(egeriaCategoryGUID, + this.getAtlasStringProperty(atlasGlossaryCategory.getEntity().getAttributes(), atlasNamePropertyName))); + } + } + + if (egeriaGlossaryCategory == null) + { + atlasClient.deleteEntity(atlasGlossaryCategory.getEntity().getGuid()); + } + else + { + this.syncEgeriaGlossaryCategoryInAtlas(egeriaGlossaryCategory, atlasGlossary); + } + } + else // Atlas Owned + { + GlossaryCategoryElement egeriaGlossaryCategory = null; + + try + { + egeriaGlossaryCategory = glossaryExchangeService.getGlossaryCategoryByGUID(egeriaCategoryGUID, new Date()); + } + catch (InvalidParameterException missingCategory) + { + /* + * The Egeria glossary category has been unilaterally deleted - so put it back. + * First remove the GUID for the deleted glossary from the Apache Atlas Glossary + * and then make a new copy the Atlas glossary in the open metadata ecosystem. + */ + if (auditLog != null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_GLOSSARY_CATEGORY.getMessageDefinition(egeriaCategoryGUID, + this.getAtlasStringProperty(atlasGlossaryCategory.getEntity().getAttributes(), atlasNamePropertyName), + connectorName)); + } + + this.removeEgeriaGUID(atlasGlossaryCategory); + } + + if (egeriaGlossaryCategory == null) + { + this.createAtlasGlossaryCategoryInEgeria(atlasGlossaryCategory, egeriaGlossary); + } + else + { + this.updateAtlasGlossaryCategoryInEgeria(atlasGlossaryCategory, egeriaGlossaryCategory); + } + } + } + + + /* ====================================================================== + * Control the exchange of metadata in one direction. Callers have determined the correct direction + * that metadata is flowing. + */ + + /** + * Copy the content of open metadata ecosystem glossary to Apache Atlas. + * + * @param egeriaGlossary open metadata glossary + * @return equivalent atlas glossary + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing Egeria or Apache Atlas + */ + private AtlasEntityWithExtInfo syncEgeriaGlossaryInAtlas(GlossaryElement egeriaGlossary) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + if (egeriaGlossary != null) + { + String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); + + AtlasEntityWithExtInfo atlasGlossary; + + if (atlasGlossaryGUID == null) + { + atlasGlossary = createEgeriaGlossaryInAtlas(egeriaGlossary); + } + else + { + atlasGlossary = atlasClient.getEntityByGUID(atlasGlossaryGUID); + + if (atlasGlossary != null) + { + atlasGlossary = updateEgeriaGlossaryInAtlas(egeriaGlossary, atlasGlossary); + } + else + { + atlasGlossary = createEgeriaGlossaryInAtlas(egeriaGlossary); + } + } + + return atlasGlossary; + } + + return null; + } + + + /** + * Create a copy of an Egeria Glossary in Apache Atlas. + * + * @param egeriaGlossary glossary to copy + * @return Atlas entity that has been created + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing Egeria or Apache Atlas + */ + AtlasEntityWithExtInfo createEgeriaGlossaryInAtlas(GlossaryElement egeriaGlossary) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + final String methodName = "createEgeriaGlossaryInAtlas"; + + AtlasEntityWithExtInfo atlasGlossary = this.prepareGlossaryMemberEntity(null, + atlasGlossaryTypeName, + this.getAtlasGlossaryProperties(egeriaGlossary), + null); + + String atlasGlossaryGUID = atlasClient.addEntity(atlasGlossary.getEntity()); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryTypeName, + egeriaGlossary.getElementHeader().getGUID(), + atlasGlossary.getEntity().getTypeName(), + atlasGlossaryGUID)); + + saveEgeriaGUIDInAtlas(atlasGlossaryGUID, + egeriaGlossary.getElementHeader().getGUID(), + egeriaGlossary.getGlossaryProperties().getQualifiedName(), + egeriaGlossaryTypeName, + true, + true); + + /* + * Retrieve the new glossary with filled out GUID and correlation. + */ + atlasGlossary = atlasClient.getEntityByGUID(atlasGlossaryGUID); + + /* + * Set up external Identifier + */ + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryGUID, + atlasGlossaryTypeName, + super.getAtlasStringProperty(atlasGlossary.getEntity().getAttributes(), atlasNamePropertyName), + egeriaGlossary.getGlossaryProperties().getDisplayName(), + atlasGlossary.getEntity().getCreatedBy(), + atlasGlossary.getEntity().getCreateTime(), + atlasGlossary.getEntity().getUpdatedBy(), + atlasGlossary.getEntity().getUpdateTime(), + atlasGlossary.getEntity().getVersion(), + SynchronizationDirection.TO_THIRD_PARTY); + + myContext.addExternalIdentifier(egeriaGlossary.getElementHeader().getGUID(), + egeriaGlossary.getElementHeader().getType().getTypeName(), + externalIdentifierProperties); + + return atlasGlossary; + } + + + /** + * Copy the latest content of open metadata ecosystem glossary to Apache Atlas. + * + * @param egeriaGlossaryElement open metadata glossary + * @param atlasGlossary glossary retrieved from Apache Atlas + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + private AtlasEntityWithExtInfo updateEgeriaGlossaryInAtlas(GlossaryElement egeriaGlossaryElement, + AtlasEntityWithExtInfo atlasGlossary) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateEgeriaGlossaryInAtlas"; + + if (egeriaGlossaryElement != null) + { + if (atlasUpdateRequired(atlasGlossary.getEntity().getGuid(), + atlasGlossaryTypeName, + egeriaGlossaryElement, + atlasGlossary.getEntity())) + { + /* + * Update the glossary properties in case they have changed. + */ + AtlasEntityWithExtInfo latestAtlasGlossary = this.prepareGlossaryMemberEntity(atlasGlossary.getEntity().getGuid(), + atlasGlossaryTypeName, + this.getAtlasGlossaryProperties(egeriaGlossaryElement), + null); + + latestAtlasGlossary = atlasClient.updateEntity(latestAtlasGlossary); + + + + this.updateExternalIdentifierAfterAtlasUpdate(egeriaGlossaryElement.getElementHeader().getGUID(), + egeriaGlossaryTypeName, + latestAtlasGlossary.getEntity()); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_ATLAS_ENTITY.getMessageDefinition(connectorName, + atlasGlossaryTypeName, + egeriaGlossaryElement.getElementHeader().getGUID(), + atlasGlossary.getEntity().getGuid())); + + return latestAtlasGlossary; + } + else + { + myContext.confirmSynchronization(egeriaGlossaryElement.getElementHeader().getGUID(), + egeriaGlossaryTypeName, + atlasGlossary.getEntity().getGuid()); + } + } + + + return atlasGlossary; + } + + + /** + * Copy the content of open metadata ecosystem glossary term to Apache Atlas. + * This is called when a change is made to a glossary term in the open metadata ecosystem. + * There are lots of strange timing windows with events and so any anomaly found in the open metadata system + * results in the term being ignored. + * + * @param egeriaGlossaryTerm open metadata glossary term + * @param atlasGlossaryDestination the Atlas glossary where the term is to be copied to + * @return equivalent atlas glossary term + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem communicating either with the open metadata access server or Apache Atlas + */ + private AtlasEntityWithExtInfo syncEgeriaGlossaryTermInAtlas(GlossaryTermElement egeriaGlossaryTerm, + AtlasEntityWithExtInfo atlasGlossaryDestination) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if (egeriaGlossaryTerm != null) + { + String atlasGlossaryTermGUID = getAtlasGUID(egeriaGlossaryTerm); + + AtlasEntityWithExtInfo atlasGlossaryTerm; + + if (atlasGlossaryTermGUID == null) + { + atlasGlossaryTerm = createEgeriaGlossaryTermInAtlas(egeriaGlossaryTerm, atlasGlossaryDestination); + } + else + { + atlasGlossaryTerm = atlasClient.getEntityByGUID(atlasGlossaryTermGUID); + + if (atlasGlossaryTerm != null) + { + atlasGlossaryTerm = updateEgeriaGlossaryTermInAtlas(egeriaGlossaryTerm, atlasGlossaryTerm, atlasGlossaryDestination); + } + else + { + atlasGlossaryTerm = createEgeriaGlossaryTermInAtlas(egeriaGlossaryTerm, atlasGlossaryDestination); + } + } + + syncEgeriaGlossaryTermCategoriesInAtlas(egeriaGlossaryTerm, atlasGlossaryTerm); + + return atlasGlossaryTerm; + } + + return null; + } + + + /** + * Create a copy of an Egeria Glossary Term in Apache Atlas. + * + * @param egeriaGlossaryTerm open metadata glossary term + * @param atlasGlossaryDestination the Atlas glossary where the term is to be copied to + * @return Atlas entity that has been created + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing Egeria or Apache Atlas + */ + AtlasEntityWithExtInfo createEgeriaGlossaryTermInAtlas(GlossaryTermElement egeriaGlossaryTerm, + AtlasEntityWithExtInfo atlasGlossaryDestination) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + final String methodName = "createEgeriaGlossaryTermInAtlas"; + + AtlasEntityWithExtInfo atlasGlossaryTerm = this.prepareGlossaryMemberEntity(null, + atlasGlossaryTermTypeName, + this.getAtlasGlossaryTermProperties(egeriaGlossaryTerm, + egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), + null, + null, + atlasGlossaryDestination), + atlasGlossaryDestination); + + String atlasGlossaryTermGUID = atlasClient.addEntity(atlasGlossaryTerm.getEntity()); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryTermTypeName, + egeriaGlossaryTerm.getElementHeader().getGUID(), + atlasGlossaryTerm.getEntity().getTypeName(), + atlasGlossaryTermGUID)); + + saveEgeriaGUIDInAtlas(atlasGlossaryTermGUID, + egeriaGlossaryTerm.getElementHeader().getGUID(), + egeriaGlossaryTerm.getGlossaryTermProperties().getQualifiedName(), + egeriaGlossaryTermTypeName, + true, + true); + + /* + * Retrieve the new glossary with filled out GUID and correlation. + */ + atlasGlossaryTerm = atlasClient.getEntityByGUID(atlasGlossaryTermGUID); + + /* + * Set up external Identifier + */ + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryTermGUID, + atlasGlossaryTermTypeName, + super.getAtlasStringProperty(atlasGlossaryTerm.getEntity().getAttributes(), atlasNamePropertyName), + egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), + atlasGlossaryTerm.getEntity().getCreatedBy(), + atlasGlossaryTerm.getEntity().getCreateTime(), + atlasGlossaryTerm.getEntity().getUpdatedBy(), + atlasGlossaryTerm.getEntity().getUpdateTime(), + atlasGlossaryTerm.getEntity().getVersion(), + SynchronizationDirection.TO_THIRD_PARTY); + + myContext.addExternalIdentifier(egeriaGlossaryTerm.getElementHeader().getGUID(), + egeriaGlossaryTerm.getElementHeader().getType().getTypeName(), + externalIdentifierProperties); + + return atlasGlossaryTerm; + } + + + /** + * Copy the latest content of open metadata ecosystem glossary term to Apache Atlas. + * + * @param egeriaGlossaryTerm open metadata glossary + * @param atlasGlossaryTerm glossary retrieved from Apache Atlas + * @param atlasGlossaryDestination the Atlas glossary where the term is to be copied to + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + private AtlasEntityWithExtInfo updateEgeriaGlossaryTermInAtlas(GlossaryTermElement egeriaGlossaryTerm, + AtlasEntityWithExtInfo atlasGlossaryTerm, + AtlasEntityWithExtInfo atlasGlossaryDestination) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateEgeriaGlossaryTermInAtlas"; + + if (egeriaGlossaryTerm != null) + { + if (atlasUpdateRequired(atlasGlossaryTerm.getEntity().getGuid(), + atlasGlossaryTermTypeName, + egeriaGlossaryTerm, + atlasGlossaryTerm.getEntity())) + { + /* + * Update the glossary properties in case they have changed. + */ + AtlasEntityWithExtInfo latestAtlasGlossaryTerm = this.prepareGlossaryMemberEntity(atlasGlossaryTerm.getEntity().getGuid(), + atlasGlossaryTermTypeName, + this.getAtlasGlossaryTermProperties(egeriaGlossaryTerm, + egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), + atlasGlossaryTerm.getEntity().getGuid(), + atlasGlossaryTerm.getEntity().getTypeName(), + atlasGlossaryTerm), + atlasGlossaryDestination); + + latestAtlasGlossaryTerm = atlasClient.updateEntity(latestAtlasGlossaryTerm); + + + + this.updateExternalIdentifierAfterAtlasUpdate(egeriaGlossaryTerm.getElementHeader().getGUID(), + egeriaGlossaryTermTypeName, + latestAtlasGlossaryTerm.getEntity()); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_ATLAS_ENTITY.getMessageDefinition(connectorName, + atlasGlossaryTermTypeName, + egeriaGlossaryTerm.getElementHeader().getGUID(), + atlasGlossaryTerm.getEntity().getGuid())); + + return latestAtlasGlossaryTerm; + } + else + { + myContext.confirmSynchronization(egeriaGlossaryTerm.getElementHeader().getGUID(), + egeriaGlossaryTermTypeName, + atlasGlossaryTerm.getEntity().getGuid()); + } + } + + + return atlasGlossaryTerm; + } + + + /** + * Copy the categorization relationships of open metadata ecosystem glossary term to Apache Atlas (and delete such relationships in + * Apache Atlas that no longer exist in the open metadata ecosystem). + * This is called when a change is made to a glossary term in the open metadata ecosystem. + * There are lots of strange timing windows with events and so any anomaly found in the open metadata system + * results in the term being ignored. + * + * @param egeriaGlossaryTerm open metadata glossary term + * @param atlasGlossaryTerm the Atlas glossary term where the categories are to be linked from + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem communicating either with the open metadata access server or Apache Atlas + */ + private void syncEgeriaGlossaryTermCategoriesInAtlas(GlossaryTermElement egeriaGlossaryTerm, + AtlasEntityWithExtInfo atlasGlossaryTerm) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if (egeriaGlossaryTerm != null) + { + String egeriaGlossaryTermGUID = egeriaGlossaryTerm.getElementHeader().getGUID(); + String atlasGlossaryTermGUID = atlasGlossaryTerm.getEntity().getGuid(); + + if (atlasGlossaryTermGUID != null) + { + List atlasRelationshipGUIDsToKeep = new ArrayList<>(); + + int startFrom = 0; + List egeriaCategories = glossaryExchangeService.getCategoriesForTerm(egeriaGlossaryTermGUID, + startFrom, + myContext.getMaxPageSize(), + null); + Map relatedAtlasCategoryMap = atlasClient.getRelationships(atlasGlossaryTerm, + atlasGlossaryCategoriesPropertyName); + + while (egeriaCategories != null) + { + for (GlossaryCategoryElement egeriaCategory : egeriaCategories) + { + String atlasCategoryGUID = this.getAtlasGUID(egeriaCategory); + + if (atlasCategoryGUID != null) + { + String matchingAtlasCategoryGUID = null; + + if (! relatedAtlasCategoryMap.isEmpty()) + { + for (String relatedCategoryGUID : relatedAtlasCategoryMap.keySet()) + { + if (relatedCategoryGUID.equals(atlasCategoryGUID)) + { + matchingAtlasCategoryGUID = relatedCategoryGUID; + break; + } + } + } + + if (matchingAtlasCategoryGUID == null) + { + AtlasRelationship atlasRelationship = new AtlasRelationship(); + + atlasRelationship.setTypeName(atlasTermCategorizationTypeName); + + AtlasObjectId end1 = new AtlasObjectId(); + + end1.setGuid(atlasCategoryGUID); + atlasRelationship.setEnd1(end1); + + AtlasObjectId end2 = new AtlasObjectId(); + + end2.setGuid(atlasGlossaryTermGUID); + atlasRelationship.setEnd2(end2); + + atlasClient.addRelationship(atlasRelationship); + } + else + { + atlasRelationshipGUIDsToKeep.add(matchingAtlasCategoryGUID); + } + } + } + + startFrom = startFrom + myContext.getMaxPageSize(); + egeriaCategories = glossaryExchangeService.getCategoriesForTerm(egeriaGlossaryTermGUID, + startFrom, + myContext.getMaxPageSize(), + null); + } + + if (! relatedAtlasCategoryMap.isEmpty()) + { + for (String relatedAtlasCategoryGUID : relatedAtlasCategoryMap.keySet()) + { + if (! atlasRelationshipGUIDsToKeep.contains(relatedAtlasCategoryGUID)) + { + atlasClient.clearRelationship(relatedAtlasCategoryMap.get(relatedAtlasCategoryGUID)); + } + } + } + + } + } + } + + + + /** + * Copy the content of open metadata ecosystem glossary category to Apache Atlas. + * This is called when a change is made to a glossary category in the open metadata ecosystem. + * There are lots of strange timing windows with events and so any anomaly found in the open metadata system + * results in the category being ignored. + * + * @param egeriaGlossaryCategory open metadata glossary category + * @param atlasGlossaryDestination the Atlas glossary where the category is to be copied to + * @return equivalent atlas glossary category + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem communicating either with the open metadata access server or Apache Atlas + */ + private AtlasEntityWithExtInfo syncEgeriaGlossaryCategoryInAtlas(GlossaryCategoryElement egeriaGlossaryCategory, + AtlasEntityWithExtInfo atlasGlossaryDestination) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if (egeriaGlossaryCategory != null) + { + String atlasGlossaryCategoryGUID = getAtlasGUID(egeriaGlossaryCategory); + + AtlasEntityWithExtInfo atlasGlossaryCategory; + + if (atlasGlossaryCategoryGUID == null) + { + atlasGlossaryCategory = createEgeriaGlossaryCategoryInAtlas(egeriaGlossaryCategory, atlasGlossaryDestination); + } + else + { + atlasGlossaryCategory = atlasClient.getEntityByGUID(atlasGlossaryCategoryGUID); + + if (atlasGlossaryCategory != null) + { + atlasGlossaryCategory = updateEgeriaGlossaryCategoryInAtlas(egeriaGlossaryCategory, atlasGlossaryCategory, atlasGlossaryDestination); + } + else + { + atlasGlossaryCategory = createEgeriaGlossaryCategoryInAtlas(egeriaGlossaryCategory, atlasGlossaryDestination); + } + } + + syncEgeriaGlossaryCategoryHierarchyInAtlas(egeriaGlossaryCategory, atlasGlossaryCategory); + + return atlasGlossaryCategory; + } + + return null; + } + + + /** + * Create a copy of an Egeria Glossary Category in Apache Atlas. + * + * @param egeriaGlossaryCategory open metadata glossary category + * @param atlasGlossaryDestination the Atlas glossary where the category is to be copied to + * @return Atlas entity that has been created + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing Egeria or Apache Atlas + */ + AtlasEntityWithExtInfo createEgeriaGlossaryCategoryInAtlas(GlossaryCategoryElement egeriaGlossaryCategory, + AtlasEntityWithExtInfo atlasGlossaryDestination) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + final String methodName = "createEgeriaGlossaryCategoryInAtlas"; + + AtlasEntityWithExtInfo atlasGlossaryCategory = this.prepareGlossaryMemberEntity(null, + atlasGlossaryCategoryTypeName, + this.getAtlasGlossaryCategoryProperties(egeriaGlossaryCategory, + egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), + null, + null, + atlasGlossaryDestination), + atlasGlossaryDestination); + + String atlasGlossaryCategoryGUID = atlasClient.addEntity(atlasGlossaryCategory.getEntity()); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryCategoryTypeName, + egeriaGlossaryCategory.getElementHeader().getGUID(), + atlasGlossaryCategory.getEntity().getTypeName(), + atlasGlossaryCategoryGUID)); + + saveEgeriaGUIDInAtlas(atlasGlossaryCategoryGUID, + egeriaGlossaryCategory.getElementHeader().getGUID(), + egeriaGlossaryCategory.getGlossaryCategoryProperties().getQualifiedName(), + egeriaGlossaryCategoryTypeName, + true, + true); + + /* + * Retrieve the new glossary with filled out GUID and correlation. + */ + atlasGlossaryCategory = atlasClient.getEntityByGUID(atlasGlossaryCategoryGUID); + + /* + * Set up external Identifier + */ + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryCategoryGUID, + atlasGlossaryCategoryTypeName, + super.getAtlasStringProperty(atlasGlossaryCategory.getEntity().getAttributes(), atlasNamePropertyName), + egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), + atlasGlossaryCategory.getEntity().getCreatedBy(), + atlasGlossaryCategory.getEntity().getCreateTime(), + atlasGlossaryCategory.getEntity().getUpdatedBy(), + atlasGlossaryCategory.getEntity().getUpdateTime(), + atlasGlossaryCategory.getEntity().getVersion(), + SynchronizationDirection.TO_THIRD_PARTY); + + myContext.addExternalIdentifier(egeriaGlossaryCategory.getElementHeader().getGUID(), + egeriaGlossaryCategory.getElementHeader().getType().getTypeName(), + externalIdentifierProperties); + + return atlasGlossaryCategory; + } + + + /** + * Copy the latest content of open metadata ecosystem glossary category to Apache Atlas. + * + * @param egeriaGlossaryCategory open metadata glossary category + * @param atlasGlossaryCategory glossary retrieved from Apache Atlas + * @param atlasGlossaryDestination the Atlas glossary where the category is to be copied to + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + private AtlasEntityWithExtInfo updateEgeriaGlossaryCategoryInAtlas(GlossaryCategoryElement egeriaGlossaryCategory, + AtlasEntityWithExtInfo atlasGlossaryCategory, + AtlasEntityWithExtInfo atlasGlossaryDestination) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateEgeriaGlossaryCategoryInAtlas"; + + if (egeriaGlossaryCategory != null) + { + if (atlasUpdateRequired(atlasGlossaryCategory.getEntity().getGuid(), + atlasGlossaryCategoryTypeName, + egeriaGlossaryCategory, + atlasGlossaryCategory.getEntity())) + { + /* + * Update the glossary properties in case they have changed. + */ + AtlasEntityWithExtInfo latestAtlasGlossaryCategory = this.prepareGlossaryMemberEntity(atlasGlossaryCategory.getEntity().getGuid(), + atlasGlossaryCategoryTypeName, + this.getAtlasGlossaryCategoryProperties(egeriaGlossaryCategory, + egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), + atlasGlossaryCategory.getEntity().getGuid(), + atlasGlossaryCategory.getEntity().getTypeName(), + atlasGlossaryCategory), + atlasGlossaryDestination); + + latestAtlasGlossaryCategory = atlasClient.updateEntity(latestAtlasGlossaryCategory); + + + + this.updateExternalIdentifierAfterAtlasUpdate(egeriaGlossaryCategory.getElementHeader().getGUID(), + egeriaGlossaryCategoryTypeName, + latestAtlasGlossaryCategory.getEntity()); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_ATLAS_ENTITY.getMessageDefinition(connectorName, + atlasGlossaryCategoryTypeName, + egeriaGlossaryCategory.getElementHeader().getGUID(), + atlasGlossaryCategory.getEntity().getGuid())); + + return latestAtlasGlossaryCategory; + } + else + { + myContext.confirmSynchronization(egeriaGlossaryCategory.getElementHeader().getGUID(), + egeriaGlossaryCategoryTypeName, + atlasGlossaryCategory.getEntity().getGuid()); + } + } + + + return atlasGlossaryCategory; + } + + + /** + * Copy the category parent relationship of open metadata ecosystem glossary category to Apache Atlas (and delete any relationship in + * Apache Atlas that no longer exist in the open metadata ecosystem). + * This is called when a change is made to a glossary category in the open metadata ecosystem. + * There are lots of strange timing windows with events and so any anomaly found in the open metadata system + * results in the category being ignored. + * + * @param egeriaGlossaryCategory open metadata glossary category + * @param atlasGlossaryCategory the Atlas glossary category where the categories are to be linked from + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem communicating either with the open metadata access server or Apache Atlas + */ + private void syncEgeriaGlossaryCategoryHierarchyInAtlas(GlossaryCategoryElement egeriaGlossaryCategory, + AtlasEntityWithExtInfo atlasGlossaryCategory) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + if (egeriaGlossaryCategory != null) + { + String egeriaGlossaryCategoryGUID = egeriaGlossaryCategory.getElementHeader().getGUID(); + String atlasGlossaryCategoryGUID = atlasGlossaryCategory.getEntity().getGuid(); + + if (atlasGlossaryCategoryGUID != null) + { + GlossaryCategoryElement egeriaParentCategory = glossaryExchangeService.getGlossaryCategoryParent(egeriaGlossaryCategoryGUID, + null); + + AtlasEntityWithExtInfo atlasParentCategory = atlasClient.getRelatedEntity(atlasGlossaryCategory, atlasParentCategoryPropertyName); + + if (egeriaParentCategory != null) + { + if ((atlasParentCategory != null) && (! egeriaParentCategory.getElementHeader().getGUID().equals( + atlasParentCategory.getEntity().getGuid()))) + { + String currentAtlasParentRelationshipGUID = atlasClient.getRelationshipGUID(atlasGlossaryCategory, + atlasParentCategoryPropertyName); + + atlasClient.clearRelationship(currentAtlasParentRelationshipGUID); + + atlasParentCategory = null; + } + + if (atlasParentCategory == null) + { + AtlasRelationship atlasRelationship = new AtlasRelationship(); + + atlasRelationship.setTypeName(atlasCategoryHierarchyTypeName); + + AtlasObjectId end1 = new AtlasObjectId(); + + end1.setGuid(atlasParentCategory.getEntity().getGuid()); + atlasRelationship.setEnd1(end1); + + AtlasObjectId end2 = new AtlasObjectId(); + + end2.setGuid(atlasGlossaryCategoryGUID); + atlasRelationship.setEnd2(end2); + + atlasClient.addRelationship(atlasRelationship); + } + } + else if (atlasParentCategory != null) + { + String currentAtlasParentRelationshipGUID = atlasClient.getRelationshipGUID(atlasGlossaryCategory, + atlasParentCategoryPropertyName); + + atlasClient.clearRelationship(currentAtlasParentRelationshipGUID); + } + } + } + } + + + /** + * Copy the contents of the Atlas glossary entity into open metadata. + * + * @param atlasGlossaryEntity entity retrieved from Apache Atlas + * + * @return equivalent glossary element in open metadata (egeriaDatabaseGUID) + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private GlossaryElement syncAtlasGlossaryInEgeria(AtlasEntityWithExtInfo atlasGlossaryEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "syncAtlasGlossaryInEgeria"; + + if ((atlasGlossaryEntity != null) && (atlasGlossaryEntity.getEntity() != null)) + { + String egeriaGlossaryGUID = super.getEgeriaGUID(atlasGlossaryEntity); + + if (egeriaGlossaryGUID == null) + { + /* + * No record of a previous synchronization with the open metadata ecosystem. + */ + egeriaGlossaryGUID = createAtlasGlossaryInEgeria(atlasGlossaryEntity); + } + else + { + try + { + /* + * Does the matching entity in the open metadata ecosystem still exist. Notice effective time is set to null + * to make sure that this entity is found no matter what its effectivity dates are set to. + */ + glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, null); + + /* + * The Egeria equivalent is still in place. + */ + updateAtlasGlossaryInEgeria(atlasGlossaryEntity, egeriaGlossaryGUID); + } + catch (InvalidParameterException notKnown) + { + /* + * The open metadata ecosystem entity has been deleted - put it back. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryTypeName, + egeriaGlossaryGUID, + atlasGlossaryEntity.getEntity().getGuid())); + removeEgeriaGUID(atlasGlossaryEntity); + egeriaGlossaryGUID = createAtlasGlossaryInEgeria(atlasGlossaryEntity); + } + } + + if (egeriaGlossaryGUID != null) + { + glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, null); + } + } + + return null; + } + + + /** + * Create a new glossary in the open metadata ecosystem that matches a glossary from Atlas. + * + * @param atlasGlossaryEntity glossary from Atlas that is to be copied to Egeria + * @return Atlas glossary updated with GUID from Egeria + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private String createAtlasGlossaryInEgeria(AtlasEntityWithExtInfo atlasGlossaryEntity) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "createAtlasGlossaryInEgeria"; + + if (atlasGlossaryEntity != null) + { + AtlasEntity atlasEntity = atlasGlossaryEntity.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasGlossaryTypeName, + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + GlossaryProperties glossaryProperties = this.getEgeriaGlossaryProperties(atlasGlossaryEntity); + + String egeriaGlossaryGUID = glossaryExchangeService.createGlossary(true, + externalIdentifierProperties, + glossaryProperties); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryTypeName, + egeriaGlossaryGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + /* + * Save the egeriaGlossaryGUID from Egeria in the Atlas Glossary's AdditionalAttributes. + */ + super.saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaGlossaryGUID, + glossaryProperties.getQualifiedName(), + egeriaGlossaryTypeName, + true, + false); + + return egeriaGlossaryGUID; + } + } + + return null; + } + + + /** + * Copy the content of the Apache Atlas glossary to the open metadata ecosystem. + * + * @param atlasGlossaryEntity atlas glossary + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security error + * @throws PropertyServerException problem communicating with Apache Atlas or Egeria + */ + private void updateAtlasGlossaryInEgeria(AtlasEntityWithExtInfo atlasGlossaryEntity, + String egeriaGlossaryGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateAtlasGlossaryInEgeria"; + + /* + * The glossary information is successfully retrieved from Apache Atlas. + */ + if (atlasGlossaryEntity != null) + { + AtlasEntity atlasEntity = atlasGlossaryEntity.getEntity(); + GlossaryElement glossaryElement = glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, null); + + if (atlasEntity == null) + { + if (this.egeriaUpdateRequired(egeriaGlossaryGUID, + egeriaGlossaryTypeName, + glossaryElement, + atlasEntity)) + { + GlossaryProperties egeriaGlossaryProperties = this.getEgeriaGlossaryProperties(atlasGlossaryEntity); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaGlossaryTypeName, + egeriaGlossaryGUID)); + + glossaryExchangeService.updateGlossary(egeriaGlossaryGUID, + atlasEntity.getGuid(), + false, + egeriaGlossaryProperties, + null); + } + } + } + } + + + + /** + * Set up an Atlas glossary in the open metadata ecosystem. + * + * @param atlasGlossaryTerm term retrieved from Apache Atlas + * @param destinationGlossary Glossary in the open metadata ecosystem to create the term in + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void createAtlasGlossaryTermInEgeria(AtlasEntityWithExtInfo atlasGlossaryTerm, + GlossaryElement destinationGlossary) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "createAtlasGlossaryTermInEgeria"; + + if (atlasGlossaryTerm != null) + { + AtlasEntity atlasEntity = atlasGlossaryTerm.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryTerm.getEntity().getGuid(), + atlasGlossaryTermTypeName, + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + GlossaryTermProperties glossaryTermProperties = this.getEgeriaGlossaryTermProperties(atlasGlossaryTerm); + + String egeriaTermGUID = glossaryExchangeService.createGlossaryTerm(destinationGlossary.getElementHeader().getGUID(), + true, + externalIdentifierProperties, + glossaryTermProperties, + null); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryTermTypeName, + egeriaTermGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaTermGUID, + glossaryTermProperties.getQualifiedName(), + egeriaGlossaryTermTypeName, + true, + false); + + + this.setUpTermCategoriesInEgeria(egeriaTermGUID, atlasGlossaryTerm); + this.setUpTermRelationshipsInEgeria(egeriaTermGUID, atlasGlossaryTerm); + } + } + } + + + + /** + * Copy the content of the Apache Atlas glossary term to the open metadata ecosystem. + * + * @param atlasGlossaryTerm atlas glossary term + * @param egeriaGlossaryTerm glossary term to update + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void updateAtlasGlossaryTermInEgeria(AtlasEntityWithExtInfo atlasGlossaryTerm, + GlossaryTermElement egeriaGlossaryTerm) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "syncAtlasGlossaryTermInEgeria"; + + if (atlasGlossaryTerm != null) + { + AtlasEntity atlasEntity = atlasGlossaryTerm.getEntity(); + + if (atlasEntity != null) + { + String egeriaGlossaryTermGUID = egeriaGlossaryTerm.getElementHeader().getGUID(); + + if (this.egeriaUpdateRequired(egeriaGlossaryTermGUID, + egeriaGlossaryTermTypeName, + egeriaGlossaryTerm, + atlasEntity)) + { + GlossaryTermProperties glossaryTermProperties = this.getEgeriaGlossaryTermProperties(atlasGlossaryTerm); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaGlossaryTermTypeName, + egeriaGlossaryTermGUID)); + + glossaryExchangeService.updateGlossaryTerm(egeriaGlossaryTermGUID, + atlasEntity.getGuid(), + false, + glossaryTermProperties, + new Date()); + + this.setUpTermCategoriesInEgeria(egeriaGlossaryTermGUID, atlasGlossaryTerm); + this.setUpTermRelationshipsInEgeria(egeriaGlossaryTermGUID, atlasGlossaryTerm); + } + } + } + } + + + /** + * Return the Egeria glossary that matches the glossary where this Atlas element originates from. + * + * @param atlasGlossaryMember element to determine the glossary for + * @return atlas glossary or null + * @throws PropertyServerException there is a problem communicating with Apache Atlas + */ + private GlossaryElement getEgeriaDestinationGlossaryForAtlasEntity(AtlasEntityWithExtInfo atlasGlossaryMember) throws PropertyServerException + { + if (atlasGlossaryMember != null) + { + AtlasEntityWithExtInfo glossaryAnchorElement = atlasClient.getRelatedEntity(atlasGlossaryMember, atlasGlossaryAnchorPropertyName); + + if (glossaryAnchorElement != null) + { + try + { + AtlasEntityWithExtInfo atlasGlossary = atlasClient.getEntityByGUID(glossaryAnchorElement.getEntity().getGuid()); + + if (atlasGlossary != null) + { + String egeriaGlossaryGUID = getEgeriaGUID(atlasGlossary); + + if (egeriaGlossaryGUID != null) + { + return glossaryExchangeService.getGlossaryByGUID(egeriaGlossaryGUID, new Date()); + } + } + } + catch (Exception notFound) + { + /* + * The glossary is not found - ignore the element for now - it is probably a timing window, and it is about to be deleted. + */ + if (auditLog != null) + { + final String methodName = "getEgeriaDestinationGlossaryForElement"; + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + notFound.getClass().getName(), + methodName, + notFound.getMessage()), + notFound); + } + } + } + } + + return null; + } + + + /** + * Retrieve the up-to-date Atlas Glossary to use to update either a glossary term or category. + * If the Atlas glossary has not yet been created, it is created. If it already exists, it is updated with the latest + * information from Egeria before being returned. + * + * @param egeriaGlossary owning glossary from egeria + * @return atlas glossary element - or null if not possible to synchronize with Apache Atlas + */ + private AtlasEntityWithExtInfo getAtlasDestinationGlossaryForEgeriaEntity(GlossaryElement egeriaGlossary) + { + try + { + if ((egeriaGlossary != null) && (egeriaGlossary.getGlossaryProperties() != null)) + { + String atlasGlossaryGUID = getAtlasGUID(egeriaGlossary); + + if (atlasGlossaryGUID == null) + { + /* + * Need to create the glossary + */ + AtlasEntityWithExtInfo atlasGlossary = this.prepareGlossaryMemberEntity(null, + atlasGlossaryTypeName, + this.getAtlasGlossaryProperties(egeriaGlossary), + null); + + atlasGlossaryGUID = atlasClient.addEntity(atlasGlossary.getEntity()); + + saveEgeriaGUIDInAtlas(atlasGlossaryGUID, + egeriaGlossary.getElementHeader().getGUID(), + egeriaGlossary.getGlossaryProperties().getQualifiedName(), + egeriaGlossaryTypeName, + true, + true); + + this.ensureAtlasExternalIdentifier(egeriaGlossary, + egeriaGlossary.getGlossaryProperties().getDisplayName(), + atlasGlossary.getEntity(), + atlasGlossaryGUID, + atlasGlossaryTypeName, + super.getAtlasStringProperty(atlasGlossary.getEntity().getAttributes(), + atlasNamePropertyName)); + } + + if (atlasGlossaryGUID != null) + { + return atlasClient.getEntityByGUID(atlasGlossaryGUID); + } + } + } + catch (Exception notFound) + { + final String methodName = "getAtlasDestinationGlossaryForEgeriaEntity"; + /* + * The Egeria glossary is not found - ignore the element for now - it is probably a timing window and the term is about to be deleted. + */ + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + notFound.getClass().getName(), + methodName + "(" + egeriaGlossary.getElementHeader().getGUID() + ")", + notFound.getMessage()), + notFound); + } + } + + return null; + } + + + /** + * Set up the relationships between a glossary term and its categories defined in Atlas. + * + * @param egeriaTermGUID glossary term to work with + * @param atlasGlossaryTerm atlas equivalent that includes its categories + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void setUpTermCategoriesInEgeria(String egeriaTermGUID, + AtlasEntityWithExtInfo atlasGlossaryTerm) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + List atlasGlossaryTermCategories = atlasClient.getRelatedEntities(atlasGlossaryTerm, atlasGlossaryCategoriesPropertyName); + List atlasGlossaryTermCategoryGUIDs = new ArrayList<>(); + + if (atlasGlossaryTermCategories != null) + { + for (AtlasEntityWithExtInfo relatedCategory : atlasGlossaryTermCategories) + { + String atlasCategoryGUID = relatedCategory.getEntity().getGuid(); + + atlasGlossaryTermCategoryGUIDs.add(atlasCategoryGUID); + + AtlasEntityWithExtInfo atlasGlossaryCategory = atlasClient.getEntityByGUID(atlasCategoryGUID); + + if (atlasGlossaryCategory != null) + { + String egeriaCategoryGUID = this.getEgeriaGUID(atlasGlossaryCategory); + + if (egeriaCategoryGUID != null) + { + glossaryExchangeService.setupTermCategory(egeriaCategoryGUID, egeriaTermGUID, null, new Date()); + } + } + } + } + + /* + * This next piece ensures that atlas category relationships that have been deleted are no longer represented in the open metadata ecosystem. + */ + int startFrom = 0; + List linkedCategories = glossaryExchangeService.getCategoriesForTerm(egeriaTermGUID, + startFrom, + myContext.getMaxPageSize(), + new Date()); + + while (linkedCategories != null) + { + for (GlossaryCategoryElement egeriaCategory : linkedCategories) + { + if (this.isAtlasOwnedElement(egeriaCategory.getElementHeader())) + { + String atlasCategoryGUID = this.getAtlasGUID(egeriaCategory); + if (! atlasGlossaryTermCategoryGUIDs.contains(atlasCategoryGUID)) + { + /* + * The category relationship has been deleted in Atlas so should be deleted in the open metadata ecosystem + */ + glossaryExchangeService.clearTermCategory(egeriaCategory.getElementHeader().getGUID(), egeriaTermGUID, new Date()); + } + } + } + + startFrom = startFrom + myContext.getMaxPageSize(); + linkedCategories = glossaryExchangeService.getCategoriesForTerm(egeriaTermGUID, + startFrom, + myContext.getMaxPageSize(), + new Date()); + } + } + + + /** + * Set up the term to term relationships in the open metadata ecosystem for a term. + * + * @param egeriaTermGUID term to work with + * @param atlasGlossaryTerm details from Atlas to copy + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void setUpTermRelationshipsInEgeria(String egeriaTermGUID, + AtlasEntityWithExtInfo atlasGlossaryTerm) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + // todo sort out term-to-term relationships + } + + + + /** + * Create a new category in the open metadata ecosystem. + * + * @param atlasGlossaryCategory category details from atlas to copy + * @param destinationGlossary Open metadata glossary to add the category to + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void createAtlasGlossaryCategoryInEgeria(AtlasEntityWithExtInfo atlasGlossaryCategory, + GlossaryElement destinationGlossary) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "createAtlasGlossaryCategoryInEgeria"; + + if (atlasGlossaryCategory != null) + { + AtlasEntity atlasEntity = atlasGlossaryCategory.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGlossaryCategory.getEntity().getGuid(), + atlasGlossaryCategoryTypeName, + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + GlossaryCategoryProperties glossaryCategoryProperties = this.getEgeriaGlossaryCategoryProperties(atlasGlossaryCategory); + + String egeriaCategoryGUID = glossaryExchangeService.createGlossaryCategory(destinationGlossary.getElementHeader().getGUID(), + true, + externalIdentifierProperties, + glossaryCategoryProperties, + isTopLevelCategory(atlasGlossaryCategory), + null); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaGlossaryCategoryTypeName, + egeriaCategoryGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaCategoryGUID, + glossaryCategoryProperties.getQualifiedName(), + egeriaGlossaryCategoryTypeName, + true, + false); + + + this.setUpCategoryHierarchyInEgeria(egeriaCategoryGUID, atlasGlossaryCategory); + } + } + } + + + + /** + * Copy the content of the Apache Atlas glossary category to the open metadata ecosystem. + * + * @param atlasCategory atlas glossary category + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void updateAtlasGlossaryCategoryInEgeria(AtlasEntityWithExtInfo atlasCategory, + GlossaryCategoryElement egeriaCategory) throws PropertyServerException, + InvalidParameterException, + UserNotAuthorizedException + { + final String methodName = "updateAtlasGlossaryCategoryInEgeria"; + + if (atlasCategory != null) + { + AtlasEntity atlasEntity = atlasCategory.getEntity(); + + if (atlasEntity != null) + { + if (this.egeriaUpdateRequired(egeriaCategory.getElementHeader().getGUID(), + egeriaGlossaryCategoryTypeName, + egeriaCategory, + atlasEntity)) + { + GlossaryCategoryProperties glossaryCategoryProperties = this.getEgeriaGlossaryCategoryProperties(atlasCategory); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaGlossaryCategoryTypeName, + egeriaCategory.getElementHeader().getGUID())); + + glossaryExchangeService.updateGlossaryCategory(egeriaCategory.getElementHeader().getGUID(), + atlasCategory.getEntity().getGuid(), + false, + glossaryCategoryProperties, + null); + + this.setUpCategoryHierarchyInEgeria(egeriaCategory.getElementHeader().getGUID(), atlasCategory); + } + } + } + } + + + /** + * Is the category a top-level category - ie one with no parent category. + * + * @param atlasGlossaryCategory atlas category entity + * @return boolean flag + */ + private boolean isTopLevelCategory(AtlasEntityWithExtInfo atlasGlossaryCategory) + { + if ((atlasGlossaryCategory != null) && (atlasGlossaryCategory.getEntity() != null)) + { + Map relationshipAttributes = atlasGlossaryCategory.getEntity().getRelationshipAttributes(); + + if (relationshipAttributes != null) + { + return (relationshipAttributes.get("parentCategory") == null); + } + } + + return true; + } + + + + /** + * Set up the category hierarchy relationships in the open metadata ecosystem. This only sets up the parent category. + * This means it may take multiple calls to refresh() to full establish the category hierarchy. + * + * @param egeriaCategoryGUID category to work with + * @param atlasGlossaryCategory details from Atlas to copy + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws PropertyServerException problem communicating with Egeria + * @throws UserNotAuthorizedException security problem + */ + private void setUpCategoryHierarchyInEgeria(String egeriaCategoryGUID, + AtlasEntityWithExtInfo atlasGlossaryCategory) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + GlossaryCategoryElement egeriaParentCategory = glossaryExchangeService.getGlossaryCategoryParent(egeriaCategoryGUID, null); + AtlasEntityWithExtInfo atlasParentCategory = atlasClient.getRelatedEntity(atlasGlossaryCategory, atlasParentCategoryPropertyName); + + if (egeriaParentCategory == null) + { + /* + * Egeria's category has no parent - what about Atlas? + */ + if (atlasParentCategory != null) + { + String egeriaParentCategoryGUIDFromAtlas = this.getEgeriaGUID(atlasParentCategory); + + if (egeriaParentCategoryGUIDFromAtlas != null) + { + glossaryExchangeService.setupCategoryParent(egeriaParentCategoryGUIDFromAtlas, egeriaCategoryGUID, null); + } + } + } + else if (atlasParentCategory != null) + { + /* + * Both categories have a parent category ... are they the same? + */ + String egeriaParentCategoryGUIDFromAtlas = this.getEgeriaGUID(atlasParentCategory); + + if (! egeriaParentCategory.getElementHeader().getGUID().equals(egeriaParentCategoryGUIDFromAtlas)) + { + glossaryExchangeService.clearCategoryParent(egeriaParentCategory.getElementHeader().getGUID(), egeriaCategoryGUID, null); + glossaryExchangeService.setupCategoryParent(egeriaParentCategoryGUIDFromAtlas, egeriaCategoryGUID, null); + } + } + else // egeria has parent category but not in atlas + { + if (this.isAtlasOwnedElement(egeriaParentCategory.getElementHeader())) + { + glossaryExchangeService.clearCategoryParent(egeriaParentCategory.getElementHeader().getGUID(), egeriaCategoryGUID, null); + } + } + } + + + /** + * Retrieve a specific glossary based on its qualified name. This glossary is expected to be present. + * It is passed in as a configuration property. + * + * @param glossaryQualifiedName requested glossary + * @param methodName calling method + * @return element or null + * @throws ConnectorCheckedException unexpected exception + */ + private GlossaryElement getGlossaryByQualifiedName(String glossaryQualifiedName, + String methodName) throws ConnectorCheckedException + { + try + { + List egeriaGlossaries = glossaryExchangeService.getGlossariesByName(glossaryQualifiedName, 0, 0, null); + + if (egeriaGlossaries != null) + { + for (GlossaryElement glossaryElement : egeriaGlossaries) + { + String qualifiedName = glossaryElement.getGlossaryProperties().getQualifiedName(); + + if (glossaryQualifiedName.equals(qualifiedName)) + { + return glossaryElement; + } + } + } + } + catch (Exception error) + { + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); + + + } + + throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + error.getMessage()), + this.getClass().getName(), + methodName, + error); + } + + return null; + } + + + /* ====================================== + * Transfer properties from one format to another + */ + + + /** + * Copy the properties from an Atlas glossary into the Asset Manager Properties bean. + * + * @param atlasGlossaryElement source element + * @return properties bean + */ + private GlossaryProperties getEgeriaGlossaryProperties(AtlasEntityWithExtInfo atlasGlossaryElement) + { + GlossaryProperties glossaryProperties = new GlossaryProperties(); + Map atlasAttributes = atlasGlossaryElement.getEntity().getAttributes(); + + glossaryProperties.setQualifiedName("AtlasGlossary." + this.getAtlasStringProperty(atlasAttributes, atlasQualifiedNamePropertyName)); + glossaryProperties.setDisplayName(this.getAtlasStringProperty(atlasAttributes, atlasNamePropertyName)); + String shortDescription = this.getAtlasStringProperty(atlasAttributes, atlasShortDescriptionPropertyName); + if (shortDescription != null) + { + glossaryProperties.setDescription(shortDescription + "\n\n" + this.getAtlasStringProperty(atlasAttributes, atlasLongDescriptionPropertyName)); + } + else + { + glossaryProperties.setDescription(this.getAtlasStringProperty(atlasAttributes, atlasLongDescriptionPropertyName)); + } + glossaryProperties.setLanguage(this.getAtlasStringProperty(atlasAttributes, atlasLanguagePropertyName)); + glossaryProperties.setUsage(this.getAtlasStringProperty(atlasAttributes, atlasUsagePropertyName)); + + return glossaryProperties; + } + + + /** + * Set up the properties from an open metadata glossary into an Apache Atlas glossary properties object. + * + * @param egeriaGlossary open metadata glossary + * @return Apache Atlas properties object + */ + Map getAtlasGlossaryProperties(GlossaryElement egeriaGlossary) + { + Map properties = new HashMap<>(); + + properties.put(atlasQualifiedNamePropertyName, egeriaGlossary.getGlossaryProperties().getQualifiedName()); + properties.put(atlasNamePropertyName, egeriaGlossary.getGlossaryProperties().getDisplayName()); + + if (egeriaGlossary.getGlossaryProperties().getDescription() != null) + { + String[] descriptionSentences = egeriaGlossary.getGlossaryProperties().getDescription().split(Pattern.quote(". ")); + if (descriptionSentences.length > 0) + { + properties.put(atlasShortDescriptionPropertyName, descriptionSentences[0]); + } + } + properties.put(atlasLongDescriptionPropertyName,egeriaGlossary.getGlossaryProperties().getDescription()); + properties.put(atlasLanguagePropertyName,egeriaGlossary.getGlossaryProperties().getLanguage()); + properties.put(atlasUsagePropertyName,egeriaGlossary.getGlossaryProperties().getUsage()); + + if (egeriaGlossary.getGlossaryProperties().getAdditionalProperties() != null) + { + properties.put(atlasAdditionalAttributesPropertyName, egeriaGlossary.getGlossaryProperties().getAdditionalProperties()); + } + + return properties; + } + + + /** + * Copy the properties from an Atlas glossary term into the Asset Manager Properties bean. + * + * @param atlasGlossaryTermElement source element + * @return properties bean + */ + private GlossaryTermProperties getEgeriaGlossaryTermProperties(AtlasEntityWithExtInfo atlasGlossaryTermElement) + { + GlossaryTermProperties glossaryTermProperties = new GlossaryTermProperties(); + Map atlasAttributes = atlasGlossaryTermElement.getEntity().getAttributes(); + + glossaryTermProperties.setQualifiedName("AtlasGlossaryTerm." + this.getAtlasStringProperty(atlasAttributes, atlasQualifiedNamePropertyName)); + glossaryTermProperties.setDisplayName(this.getAtlasStringProperty(atlasAttributes, atlasNamePropertyName)); + String shortDescription = this.getAtlasStringProperty(atlasAttributes, atlasShortDescriptionPropertyName); + if (shortDescription != null) + { + glossaryTermProperties.setDescription(shortDescription + "\n\n" + this.getAtlasStringProperty(atlasAttributes, atlasLongDescriptionPropertyName)); + } + else + { + glossaryTermProperties.setDescription(this.getAtlasStringProperty(atlasAttributes, atlasLongDescriptionPropertyName)); + } + glossaryTermProperties.setExamples(this.getAtlasStringProperty(atlasAttributes, atlasExamplesPropertyName)); + glossaryTermProperties.setAbbreviation(this.getAtlasStringProperty(atlasAttributes, atlasAbbreviationPropertyName)); + glossaryTermProperties.setUsage(this.getAtlasStringProperty(atlasAttributes, atlasUsagePropertyName)); + + return glossaryTermProperties; + } + + + /** + * Set up the properties from an open metadata glossary term into an Apache Atlas glossary term properties object. + * + * @param egeriaGlossaryTerm open metadata glossary term + * @param egeriaGlossaryTermLastKnownName the display name that was present on the previous synchronization + * @param atlasGlossaryTermGUID unique identifier from Apache Atlas + * @param atlasGlossaryTermName unique display name from Apache Atlas + * @param atlasGlossary destination glossary in Apache Atlas + * @return Apache Atlas attribute map + * @throws PropertyServerException problem calling Atlas + */ + Map getAtlasGlossaryTermProperties(GlossaryTermElement egeriaGlossaryTerm, + String egeriaGlossaryTermLastKnownName, + String atlasGlossaryTermGUID, + String atlasGlossaryTermName, + AtlasEntityWithExtInfo atlasGlossary) throws PropertyServerException + { + Map properties = new HashMap<>(); + + String name; + + if (atlasGlossaryTermGUID == null) + { + name = this.getUniqueNameForNewAtlasGlossaryMember(egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), + atlasGlossary, + atlasGlossaryTermsPropertyName); + } + else if (egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName().equals(egeriaGlossaryTermLastKnownName)) + { + name = atlasGlossaryTermName; + } + else + { + name = this.getUniqueNameForRenamedAtlasGlossaryMember(egeriaGlossaryTerm.getGlossaryTermProperties().getDisplayName(), + atlasGlossaryTermGUID, + atlasGlossary, + atlasGlossaryTermsPropertyName); + } + + properties.put(atlasQualifiedNamePropertyName, + this.getAtlasStringProperty(atlasGlossary.getEntity().getAttributes(), atlasQualifiedNamePropertyName) + "@" + name); + properties.put(atlasNamePropertyName, name); + + + if (egeriaGlossaryTerm.getGlossaryTermProperties().getDescription() != null) + { + String[] descriptionSentences = egeriaGlossaryTerm.getGlossaryTermProperties().getDescription().split(Pattern.quote(". ")); + if (descriptionSentences.length > 0) + { + properties.put(atlasShortDescriptionPropertyName, descriptionSentences[0]); + } + } + properties.put(atlasLongDescriptionPropertyName,egeriaGlossaryTerm.getGlossaryTermProperties().getDescription()); + properties.put(atlasAbbreviationPropertyName,egeriaGlossaryTerm.getGlossaryTermProperties().getAbbreviation()); + properties.put(atlasUsagePropertyName,egeriaGlossaryTerm.getGlossaryTermProperties().getUsage()); + + if (egeriaGlossaryTerm.getGlossaryTermProperties().getAdditionalProperties() != null) + { + properties.put(atlasAdditionalAttributesPropertyName, egeriaGlossaryTerm.getGlossaryTermProperties().getAdditionalProperties()); + } + + return properties; + } + + + /** + * Copy the properties from an Atlas glossary category into the Asset Manager Properties bean. + * + * @param atlasGlossaryCategory source element + * @return properties bean + */ + private GlossaryCategoryProperties getEgeriaGlossaryCategoryProperties(AtlasEntityWithExtInfo atlasGlossaryCategory) + { + GlossaryCategoryProperties glossaryCategoryProperties = new GlossaryCategoryProperties(); + Map atlasAttributes = atlasGlossaryCategory.getEntity().getAttributes(); + + + glossaryCategoryProperties.setQualifiedName("AtlasGlossaryCategory." + + this.getAtlasStringProperty(atlasAttributes, atlasQualifiedNamePropertyName)); + glossaryCategoryProperties.setDisplayName(this.getAtlasStringProperty(atlasAttributes, atlasNamePropertyName)); + + String shortDescription = this.getAtlasStringProperty(atlasAttributes, atlasShortDescriptionPropertyName); + if (shortDescription != null) + { + glossaryCategoryProperties.setDescription(shortDescription + "\n\n" + this.getAtlasStringProperty(atlasAttributes, atlasLongDescriptionPropertyName)); + } + else + { + glossaryCategoryProperties.setDescription(this.getAtlasStringProperty(atlasAttributes, atlasLongDescriptionPropertyName)); + } + + return glossaryCategoryProperties; + } + + + /** + * Set up the properties from an open metadata glossary category into an Apache Atlas glossary category properties object. + * + * @param egeriaGlossaryCategory open metadata glossary category + * @param egeriaGlossaryCategoryLastKnownName the display name that was present on the previous synchronization + * @param atlasGlossaryCategoryGUID unique identifier from Apache Atlas + * @param atlasGlossaryCategoryName unique display name from Apache Atlas + * @param atlasGlossary destination glossary in Apache Atlas + * @return Apache Atlas attribute map + * @throws PropertyServerException problem calling Atlas + */ + Map getAtlasGlossaryCategoryProperties(GlossaryCategoryElement egeriaGlossaryCategory, + String egeriaGlossaryCategoryLastKnownName, + String atlasGlossaryCategoryGUID, + String atlasGlossaryCategoryName, + AtlasEntityWithExtInfo atlasGlossary) throws PropertyServerException + { + Map properties = new HashMap<>(); + + String name; + + if (atlasGlossaryCategoryGUID == null) + { + name = this.getUniqueNameForNewAtlasGlossaryMember(egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), + atlasGlossary, + atlasGlossaryCategoriesPropertyName); + } + else if (egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName().equals(egeriaGlossaryCategoryLastKnownName)) + { + name = atlasGlossaryCategoryName; + } + else + { + name = this.getUniqueNameForRenamedAtlasGlossaryMember(egeriaGlossaryCategory.getGlossaryCategoryProperties().getDisplayName(), + atlasGlossaryCategoryGUID, + atlasGlossary, + atlasGlossaryCategoriesPropertyName); + } + + properties.put(atlasQualifiedNamePropertyName, + this.getAtlasStringProperty(atlasGlossary.getEntity().getAttributes(), atlasQualifiedNamePropertyName) + "@" + name); + properties.put(atlasNamePropertyName, name); + + + if (egeriaGlossaryCategory.getGlossaryCategoryProperties().getDescription() != null) + { + String[] descriptionSentences = egeriaGlossaryCategory.getGlossaryCategoryProperties().getDescription().split(Pattern.quote(". ")); + if (descriptionSentences.length > 0) + { + properties.put(atlasShortDescriptionPropertyName, descriptionSentences[0]); + } + } + properties.put(atlasLongDescriptionPropertyName,egeriaGlossaryCategory.getGlossaryCategoryProperties().getDescription()); + + if (egeriaGlossaryCategory.getGlossaryCategoryProperties().getAdditionalProperties() != null) + { + properties.put(atlasAdditionalAttributesPropertyName, egeriaGlossaryCategory.getGlossaryCategoryProperties().getAdditionalProperties()); + } + + return properties; + } + + + /** + * Create the Apache Atlas entity structure for a new Glossary Term or Category. + * + * @param memberGUID unique identifier of the Apache Atlas entity (will be null for a create) + * @param memberTypeName Apache Atlas type name for the member + * @param memberAttributes map of attributes for entity + * @param destinationGlossary Apache Atlas glossary where the member resides + * @return Apache Atlas Entity structure used on create or update + */ + AtlasEntityWithExtInfo prepareGlossaryMemberEntity(String memberGUID, + String memberTypeName, + Map memberAttributes, + AtlasEntityWithExtInfo destinationGlossary) + { + AtlasEntityWithExtInfo atlasEntityWithExtInfo = new AtlasEntityWithExtInfo(); + AtlasEntity atlasEntity = new AtlasEntity(); + + atlasEntity.setGuid(memberGUID); + atlasEntity.setTypeName(memberTypeName); + atlasEntity.setAttributes(memberAttributes); + + Map relationshipAttributes = new HashMap<>(); + + if (destinationGlossary != null) + { + relationshipAttributes.put(atlasGlossaryAnchorPropertyName, this.getAnchorAttributes(memberTypeName, destinationGlossary)); + + atlasEntity.setRelationshipAttributes(relationshipAttributes); + } + + atlasEntityWithExtInfo.setEntity(atlasEntity); + + return atlasEntityWithExtInfo; + } + + + /** + * Set up the glossary anchor in an atlas entity for either a glossary term or a glossary category. + * + * @param memberTypeName type of member + * @param destinationGlossary anchor glossary + */ + private Map getAnchorAttributes(String memberTypeName, + AtlasEntityWithExtInfo destinationGlossary) + { + + Map anchorAttributes = new HashMap<>(); + + anchorAttributes.put("guid", destinationGlossary.getEntity().getGuid()); + + if (atlasGlossaryTermTypeName.equals(memberTypeName)) + { + anchorAttributes.put("relationshipType", "AtlasGlossaryTermAnchor"); + } + else + { + anchorAttributes.put("relationshipType", "AtlasGlossaryCategoryAnchor"); + } + + anchorAttributes.put("relationshipStatus", "ACTIVE"); + + return anchorAttributes; + } + + + /** + * Calculate the name to use in Atlas for an open metadata category or term. It is a 1-1 mapping unless the Egeria glossary has + * multiple members with the same name. In that case, a bracketed number is added to the end of the name. + * + * @param egeriaMemberName name for the element from the open metadata ecosystem + * @param atlasGlossary atlas glossary where the member is going + * @param existingEntitiesParameterName name of the parameter in the glossary that identifies the existing members that the name must not match with + * @return name to use for the new member + * @throws PropertyServerException there was a problem communicating with Apache Atlas + */ + private String getUniqueNameForNewAtlasGlossaryMember(String egeriaMemberName, + AtlasEntityWithExtInfo atlasGlossary, + String existingEntitiesParameterName) throws PropertyServerException + { + List existingEntities = atlasClient.getRelatedEntities(atlasGlossary, existingEntitiesParameterName); + + return this.getUniqueNameForAtlasEntity(egeriaMemberName, existingEntities); + } + + + /** + * A glossary member (ie term or category) that originates from the open metadata ecosystem has been renamed. + * This method finds a unique name for the equivalent entity in Apache Atlas, being careful to avoid name clashes. + * + * @param newEgeriaMemberName name for the element from the open metadata ecosystem + * @param atlasMemberGUID unique identifier for the existing Atlas member entity + * @param atlasGlossary atlas glossary where the atlas member came from + * @param existingEntitiesParameterName name of the parameter in the glossary that identifies the existing members that the name must not match with + * @return new name to use for the member in Atlas + * @throws PropertyServerException there was a problem communicating with Apache Atlas + */ + private String getUniqueNameForRenamedAtlasGlossaryMember(String newEgeriaMemberName, + String atlasMemberGUID, + AtlasEntityWithExtInfo atlasGlossary, + String existingEntitiesParameterName) throws PropertyServerException + { + List existingEntities = atlasClient.getRelatedEntities(atlasGlossary, existingEntitiesParameterName); + List otherExistingEntities = null; + + if (existingEntities != null) + { + /* + * Remove the atlas entity that is about to be renamed from the list. + */ + otherExistingEntities = new ArrayList<>(); + + for (AtlasEntityWithExtInfo existingEntity : existingEntities) + { + if ((existingEntity != null) && + (existingEntity.getEntity() != null) && + (! atlasMemberGUID.equals(existingEntity.getEntity().getGuid()))) + { + otherExistingEntities.add(existingEntity); + } + } + } + + /* + * Find a new name. + */ + return this.getUniqueNameForAtlasEntity(newEgeriaMemberName, otherExistingEntities); + } + + + /** + * Calculate the name to use in Atlas for an open metadata glossary member. It is a 1-1 mapping unless Egeria has + * multiple elements with the same name. In that case, a bracketed number is added to the end of the name. + * + * @param egeriaName display name from Egeria + * @param existingEntities map of known entities from Atlas + * @return name to use + */ + private String getUniqueNameForAtlasEntity(String egeriaName, + List existingEntities) + { + /* + * There are no existing elements so the name from Egeria can be used. + */ + if ((existingEntities == null) || (existingEntities.isEmpty())) + { + return egeriaName; + } + + int matchingNameCount = 0; + + /* + * Step through all the existing entities and determine if the name from Egeria would be unique in Atlas. + */ + for (AtlasEntityWithExtInfo existingAtlasEntity : existingEntities) + { + /* + * Extract the name from the existing entity. + */ + String existingEntityName = this.getAtlasStringProperty(existingAtlasEntity.getEntity().getAttributes(), + atlasNamePropertyName); + + if (! egeriaName.equals(existingEntityName)) + { + /* + * There is no direct name match. Look to see if the existing entity has a modified name. + */ + String[] termNameParts = existingEntityName.split(Pattern.quote(" (")); + + if ((termNameParts.length > 1) && // it has a bracket in the existing element's name + (egeriaName.equals(termNameParts[0]))) // the first part of the existing element's name matches the egeria name + { + /* + * There is an open bracket in the name. This could be a modified name to handle multiple glossary terms within the glossary. + * Check for the closing bracket in the last part of the name. + */ + String[] termEndingParts = termNameParts[termNameParts.length - 1].split(Pattern.quote(")")); + + if (termEndingParts.length == 1) // Only one closing bracket - is it a number between the brackets? + { + try + { + int matchingNameIndex = Integer.parseInt(termEndingParts[0]); + + /* + * The entities are not processes in neat numerical order so increment the matching name count beyond the + * index from the modified name if it is the largest index number seen so far. + */ + if (matchingNameIndex >= matchingNameCount) + { + matchingNameCount = matchingNameIndex + 1; + } + } + catch (NumberFormatException notANumber) + { + // Ignore the entity because it does not have one of our modified names + } + } + } + } + else + { + /* + * There is a direct match between the egeria name and an existing entity. + */ + matchingNameCount = matchingNameCount + 1; + } + } + + if (matchingNameCount == 0) + { + /* + * No matches detected + */ + return egeriaName; + } + else + { + /* + * There are matching names - use the next unique name. + */ + return egeriaName + " (" + matchingNameCount + ")"; + } + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasIntegrationModuleBase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasIntegrationModuleBase.java new file mode 100644 index 00000000000..12f6f18978b --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasIntegrationModuleBase.java @@ -0,0 +1,1344 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.DataAssetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataCorrelationHeader; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataAssetProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataStoreProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.KeyPattern; +import org.odpi.openmetadata.accessservices.assetmanager.properties.OwnerProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ProcessProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SchemaAttributeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SchemaTypeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityHeader; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityWithExtInfo; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasGlossaryBaseProperties; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasInstanceStatus; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasObjectId; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasRelationship; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; +import org.odpi.openmetadata.integrationservices.catalog.connector.DataAssetExchangeService; +import org.odpi.openmetadata.integrationservices.catalog.connector.StewardshipExchangeService; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * AtlasIntegrationModuleBase defines the interface that classes that support the synchronization of particular types of metadata with Apache Atlas. + */ +public abstract class AtlasIntegrationModuleBase +{ + protected final static String openMetadataCorrelationTypeName = "OpenMetadataCorrelation"; + protected final static String openMetadataCorrelationLinkTypeName = "OpenMetadataCorrelationLink"; + protected final static String openMetadataGlossaryCorrelationLinkTypeName = "OpenMetadataGlossaryCorrelationLink"; + protected final static String openMetadataCorrelationPropertyName = "openMetadataCorrelation"; + protected final static String egeriaGUIDPropertyName = "egeriaGUID"; + protected final static String egeriaTypeNamePropertyName = "egeriaTypeName"; + protected final static String egeriaQualifiedNamePropertyName = "egeriaQualifiedName"; + protected final static String egeriaOwnedPropertyName = "egeriaOwned"; + + protected final static String atlasOwnerPropertyName = "owner"; + protected final static String egeriaOwnerTypeName = "UserIdentity"; + protected final static String egeriaOwnerPropertyName = "userId"; + + protected final static String atlasQualifiedNamePropertyName = "qualifiedName"; + protected final static String atlasNamePropertyName = "name"; + protected final static String atlasDisplayNamePropertyName = "displayName"; + protected final static String atlasDescriptionPropertyName = "description"; + protected final static String atlasUserDescriptionPropertyName = "userDescription"; + protected final static String atlasPathPropertyName = "path"; + protected final static String atlasCreateTimePropertyName = "createTime"; + protected final static String atlasModifiedTimePropertyName = "modifiedTime"; + + protected final static List atlasAssetProperties = Arrays.asList(atlasQualifiedNamePropertyName, atlasNamePropertyName, + atlasDisplayNamePropertyName, atlasDescriptionPropertyName, + atlasUserDescriptionPropertyName); + protected final static List atlasDataFileProperties = Arrays.asList(atlasQualifiedNamePropertyName, atlasNamePropertyName, + atlasDisplayNamePropertyName, atlasDescriptionPropertyName, + atlasUserDescriptionPropertyName, atlasCreateTimePropertyName, + atlasModifiedTimePropertyName, atlasPathPropertyName); + + + private final static String atlasGUIDPropertyName = "atlasGUID"; + private final static String atlasTypeMappingPropertyName = "atlasType"; + private final static String atlasNameMappingPropertyName = "atlasName"; + private final static String egeriaNameMappingPropertyName = "lastKnownEgeriaDisplayName"; + private final static String modulePropertyName = "originator"; + + protected final AuditLog auditLog; + protected final String connectorName; + protected final String moduleName; + protected final ConnectionProperties connectionProperties; + protected final CatalogIntegratorContext myContext; + protected final List embeddedConnectors; + protected final ApacheAtlasRESTClient atlasClient; + protected final String targetRootURL; + + protected final DataAssetExchangeService dataAssetExchangeService; + protected final StewardshipExchangeService stewardshipExchangeService; + + + + /** + * Initialize the common properties for an integration module. + * + * @param connectorName name of this connector + * @param moduleName name of this module + * @param connectionProperties supplied connector used to configure the connector + * @param auditLog logging destination + * @param myContext integration context assigned to the connector + * @param targetRootURL host name and port of Apache Atlas + * @param atlasClient client to call Apache Atlas + * @param embeddedConnectors any connectors embedded in the connector (such as the secrets connector or Kafka connector) + * @throws UserNotAuthorizedException the data asset service has not been enabled. + */ + public AtlasIntegrationModuleBase(String connectorName, + String moduleName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + this.auditLog = auditLog; + this.connectorName = connectorName; + this.moduleName = moduleName; + this.connectionProperties = connectionProperties; + this.myContext = myContext; + this.targetRootURL = targetRootURL; + this.atlasClient = atlasClient; + this.embeddedConnectors = embeddedConnectors; + + this.dataAssetExchangeService = myContext.getDataAssetExchangeService(); + this.stewardshipExchangeService = myContext.getStewardshipExchangeService(); + + /* + * Deduplication is turned off so that the connector works with the entities it created rather than + * entities from other systems that have been linked as duplicates. + */ + this.dataAssetExchangeService.setForDuplicateProcessing(true); + this.stewardshipExchangeService.setForDuplicateProcessing(true); + } + + + + /* ================================================================ + * Determine which direction that metadata is flowing + */ + + /** + * Return a flag indicating whether an element retrieved from the open metadata ecosystem. + * + * @param elementHeader header from open metadata ecosystem + * @return boolean flag + */ + protected boolean isAtlasOwnedElement(ElementHeader elementHeader) + { + return (elementHeader.getOrigin().getHomeMetadataCollectionId() != null) && + (elementHeader.getOrigin().getHomeMetadataCollectionId().equals(myContext.getAssetManagerGUID())); + } + + + /** + * Return a flag to indicate whether an atlas glossary element is owned by Egeria (open metadata ecosystem) + * or is owned by Apache Atlas. This becomes important around delete scenarios. + * + * @param properties properties of the Atlas element + * @return boolean - true means the element originated in the open metadata ecosystem + */ + protected boolean isEgeriaOwned(AtlasGlossaryBaseProperties properties) + { + Map additionalAttributes = properties.getAdditionalAttributes(); + + return (additionalAttributes != null) && + (additionalAttributes.containsKey(egeriaOwnedPropertyName)) && + ("true".equals(additionalAttributes.get(egeriaOwnedPropertyName).toString())); + } + + + /** + * Return a flag to indicate whether an atlas glossary element is owned by Egeria (open metadata ecosystem) + * or is owned by Apache Atlas. This becomes important around delete scenarios. + * + * @param atlasEntityWithExtInfo properties of the Atlas element + * @return boolean - true means the element originated in the open metadata ecosystem + * @throws PropertyServerException problem communicating with Apache Atlas + */ + protected boolean isEgeriaOwned(AtlasEntityWithExtInfo atlasEntityWithExtInfo) throws PropertyServerException + { + if ((atlasEntityWithExtInfo != null) && (atlasEntityWithExtInfo.getEntity() != null)) + { + return isEgeriaOwned(atlasEntityWithExtInfo.getEntity()); + } + + return false; + } + + + /** + * Return a flag to indicate whether an atlas glossary element is owned by Egeria (open metadata ecosystem) + * or is owned by Apache Atlas. This becomes important around delete scenarios. + * + * @param atlasEntity properties of the Atlas element + * @return boolean - true means the element originated in the open metadata ecosystem + * @throws PropertyServerException problem communicating with Apache Atlas + */ + protected boolean isEgeriaOwned(AtlasEntity atlasEntity) throws PropertyServerException + { + if (atlasEntity != null) + { + AtlasEntityWithExtInfo openMetadataCorrelationEntity = atlasClient.getRelatedEntity(atlasEntity, + openMetadataCorrelationPropertyName); + + if ((openMetadataCorrelationEntity != null) && + (openMetadataCorrelationEntity.getEntity() != null) && + (openMetadataCorrelationEntity.getEntity().getAttributes() != null)) + { + return this.getAtlasBooleanProperty(openMetadataCorrelationEntity.getEntity().getAttributes(), egeriaOwnedPropertyName); + } + } + + return false; + } + + + /** + * Add a new OpenMetadataCorrelation entity to apache atlas and link it to the supplied atlas entity. + * + * @param atlasEntityGUID unique identifier of the atlas element that the open metadata correlation entity should be connected to + * @param egeriaEntityGUID unique identifier from the open metadata ecosystem + * @param egeriaQualifiedName unique name from the open metadata ecosystem + * @param egeriaTypeName name of type from the open metadata ecosystem + * @param isAtlasGlossaryEntity is this a glossary entity? + * @param egeriaOwned is this element owned by Egeria? + * @throws PropertyServerException problems communicating with Apache Atlas. + */ + protected void saveEgeriaGUIDInAtlas(String atlasEntityGUID, + String egeriaEntityGUID, + String egeriaQualifiedName, + String egeriaTypeName, + boolean isAtlasGlossaryEntity, + boolean egeriaOwned) throws PropertyServerException + { + AtlasEntity openMetadataCorrelationEntity = new AtlasEntity(); + Map attributes = new HashMap<>(); + AtlasRelationship openMetadataCorrelationLinkRelationship = new AtlasRelationship(); + + openMetadataCorrelationEntity.setTypeName(openMetadataCorrelationTypeName); + openMetadataCorrelationEntity.setIncomplete(false); + openMetadataCorrelationEntity.setStatus(AtlasInstanceStatus.ACTIVE); + openMetadataCorrelationEntity.setVersion(1L); + + attributes.put(egeriaGUIDPropertyName, egeriaEntityGUID); + attributes.put(egeriaQualifiedNamePropertyName, egeriaQualifiedName); + attributes.put(egeriaTypeNamePropertyName, egeriaTypeName); + attributes.put(egeriaOwnedPropertyName, egeriaOwned); + openMetadataCorrelationEntity.setAttributes(attributes); + + String openMetadataCorrelationEntityGUID = atlasClient.addEntity(openMetadataCorrelationEntity); + + if (openMetadataCorrelationEntityGUID != null) + { + if (isAtlasGlossaryEntity) + { + openMetadataCorrelationLinkRelationship.setTypeName(openMetadataGlossaryCorrelationLinkTypeName); + } + else + { + openMetadataCorrelationLinkRelationship.setTypeName(openMetadataCorrelationLinkTypeName); + } + + AtlasObjectId end1 = new AtlasObjectId(); + + end1.setGuid(atlasEntityGUID); + openMetadataCorrelationLinkRelationship.setEnd1(end1); + + AtlasObjectId end2 = new AtlasObjectId(); + + end2.setGuid(openMetadataCorrelationEntityGUID); + openMetadataCorrelationLinkRelationship.setEnd2(end2); + + atlasClient.addRelationship(openMetadataCorrelationLinkRelationship); + } + } + + + /** + * Return the unique identifier for the equivalent element in Apache Atlas. + * + * @param metadataElement retrieved metadata element + * @return string guid + * @throws InvalidParameterException retrieved element is null + */ + protected String getAtlasGUID(MetadataElement metadataElement) throws InvalidParameterException + { + MetadataCorrelationHeader myMetadataCorrelationHeader = myContext.getMetadataCorrelationHeader(metadataElement); + + if (myMetadataCorrelationHeader != null) + { + return myMetadataCorrelationHeader.getExternalIdentifier(); + } + + return null; + } + + + /** + * Confirm whether there have been changes since the last refresh(). + * + * @param egeriaGUID unique identifier (GUID) of this element in open metadata + * @param egeriaTypeName type name for the open metadata element + * @param egeriaMetadataElement list of external identifiers used to manage metadata exchange + * @param atlasEntity atlas entity that is the source of the metadata + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + protected boolean egeriaUpdateRequired(String egeriaGUID, + String egeriaTypeName, + MetadataElement egeriaMetadataElement, + AtlasEntity atlasEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "egeriaUpdateRequired"; + + MetadataCorrelationHeader metadataCorrelationHeader = myContext.getMetadataCorrelationHeader(egeriaMetadataElement); + + if (metadataCorrelationHeader == null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.MISSING_CORRELATION.getMessageDefinition(connectorName, + egeriaTypeName, + egeriaGUID, + atlasEntity.getGuid(), + atlasEntity.getTypeName())); + throw new PropertyServerException(ApacheAtlasErrorCode.MISSING_CORRELATION.getMessageDefinition(connectorName, + egeriaTypeName, + egeriaGUID, + atlasEntity.getGuid(), + atlasEntity.getTypeName()), + this.getClass().getName(), + methodName); + } + else + { + if (atlasEntity.getUpdateTime() == null) + { + /* + * Entity has only been created - confirm that no updates are needed. + */ + myContext.confirmSynchronization(egeriaGUID, egeriaTypeName, atlasEntity.getGuid()); + } + else if ((metadataCorrelationHeader.getLastSynchronized() == null) || + (atlasEntity.getUpdateTime().after(metadataCorrelationHeader.getLastSynchronized()))) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + myContext.updateExternalIdentifier(egeriaGUID, + egeriaTypeName, + externalIdentifierProperties); + return true; + } + else + { + /* + * No updates have happened since the last know synchronization + */ + myContext.confirmSynchronization(egeriaGUID, egeriaTypeName, atlasEntity.getGuid()); + } + } + + return false; + } + + + /** + * Confirm whether there have been changes since the last synchronization. + * + * @param egeriaGUID unique identifier (GUID) of this element in open metadata + * @param egeriaTypeName type name for the open metadata element + * @param egeriaMetadataElement list of external identifiers used to manage metadata exchange + * @param atlasEntity atlas entity that is the source of the metadata + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws PropertyServerException problem accessing the property server + */ + protected boolean atlasUpdateRequired(String egeriaGUID, + String egeriaTypeName, + MetadataElement egeriaMetadataElement, + AtlasEntity atlasEntity) throws InvalidParameterException, + PropertyServerException + { + final String methodName = "atlasUpdateRequired"; + + MetadataCorrelationHeader metadataCorrelationHeader = myContext.getMetadataCorrelationHeader(egeriaMetadataElement); + + if (metadataCorrelationHeader == null) + { + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.MISSING_CORRELATION.getMessageDefinition(connectorName, + egeriaTypeName, + egeriaGUID, + atlasEntity.getGuid(), + atlasEntity.getTypeName())); + throw new PropertyServerException(ApacheAtlasErrorCode.MISSING_CORRELATION.getMessageDefinition(connectorName, + egeriaTypeName, + egeriaGUID, + atlasEntity.getGuid(), + atlasEntity.getTypeName()), + this.getClass().getName(), + methodName); + } + else if ((egeriaMetadataElement.getElementHeader().getVersions().getUpdateTime() != null) && + ((metadataCorrelationHeader.getLastSynchronized() == null) || + (egeriaMetadataElement.getElementHeader().getVersions().getUpdateTime().after(metadataCorrelationHeader.getLastSynchronized())))) + { + return true; + } + + + return false; + } + + + /** + * Update the correlation properties for an Egeria element after an atlas entity has been updated. + * + * @param egeriaGUID unique identifier (GUID) of this element in open metadata + * @param egeriaTypeName type name for the open metadata element + * @param atlasEntity atlas entity that is the source of the metadata + * + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException user not authorized to issue this request + * @throws PropertyServerException problem accessing the property server + */ + protected void updateExternalIdentifierAfterAtlasUpdate(String egeriaGUID, + String egeriaTypeName, + AtlasEntity atlasEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + myContext.updateExternalIdentifier(egeriaGUID, + egeriaTypeName, + externalIdentifierProperties); + } + + + /** + * Extract the unique identifier for the corresponding open metadata entity to the supplied Apache Atlas entity. A null value + * returned means that an open metadata ecosystem entity has not yet been created. + * + * @param atlasEntity entity retrieved from Apache Atlas + * @return string guid + * @throws PropertyServerException there is a problem calling Apache Atlas + */ + protected String getEgeriaGUID(AtlasEntityWithExtInfo atlasEntity) throws PropertyServerException + { + if (atlasEntity != null) + { + AtlasEntityWithExtInfo openMetadataCorrelationEntity = atlasClient.getRelatedEntity(atlasEntity, + openMetadataCorrelationPropertyName); + + if ((openMetadataCorrelationEntity != null) && + (openMetadataCorrelationEntity.getEntity() != null) && + (openMetadataCorrelationEntity.getEntity().getAttributes() != null)) + { + return this.getAtlasStringProperty(openMetadataCorrelationEntity.getEntity().getAttributes(), egeriaGUIDPropertyName); + } + } + + return null; + } + + + /** + * Remove the requested entity. + * + * @param atlasEntity entity retrieved from Apache Atlas + * @throws PropertyServerException there is a problem calling Apache Atlas + */ + protected void removeEgeriaGUID(AtlasEntityWithExtInfo atlasEntity) throws PropertyServerException + { + if (atlasEntity != null) + { + AtlasEntityWithExtInfo openMetadataCorrelationEntity = atlasClient.getRelatedEntity(atlasEntity, + openMetadataCorrelationPropertyName); + + if ((openMetadataCorrelationEntity != null) && (openMetadataCorrelationEntity.getEntity() != null)) + { + atlasClient.deleteEntity(openMetadataCorrelationEntity.getEntity().getGuid()); + } + } + } + + + /** + * Return an external identifier properties object for an Atlas GUID. + * + * @param atlasGUID guid to encode + * @param atlasTypeName name of the atlas type + * @param externalInstanceCreatedBy the username of the person or process that created the instance in the external system + * @param externalInstanceCreationTime the date/time when the instance in the external system was created + * @param externalInstanceLastUpdatedBy the username of the person or process that last updated the instance in the external system + * @param externalInstanceLastUpdateTime the date/time that the instance in the external system was last updated + * @param externalInstanceVersion the latest version of the element in the external system + * @param synchronizationDirection the permitted synchronization direction + * @return properties object + */ + protected ExternalIdentifierProperties getExternalIdentifier(String atlasGUID, + String atlasTypeName, + String externalInstanceCreatedBy, + Date externalInstanceCreationTime, + String externalInstanceLastUpdatedBy, + Date externalInstanceLastUpdateTime, + long externalInstanceVersion, + SynchronizationDirection synchronizationDirection) + { + return this.getExternalIdentifier(atlasGUID, + atlasTypeName, + null, + null, + externalInstanceCreatedBy, + externalInstanceCreationTime, + externalInstanceLastUpdatedBy, + externalInstanceLastUpdateTime, + externalInstanceVersion, + synchronizationDirection); + } + + + /** + * Return an external identifier properties object for an Atlas GUID. This creates additional mapping properties for + * glossary terms and categories. + * + * @param atlasGUID guid to encode + * @param atlasTypeName name of the atlas type + * @param externalInstanceCreatedBy the username of the person or process that created the instance in the external system + * @param externalInstanceCreationTime the date/time when the instance in the external system was created + * @param externalInstanceLastUpdatedBy the username of the person or process that last updated the instance in the external system + * @param externalInstanceLastUpdateTime the date/time that the instance in the external system was last updated + * @param externalInstanceVersion the latest version of the element in the external system + * @param synchronizationDirection the permitted synchronization direction + * @return properties object + */ + protected ExternalIdentifierProperties getExternalIdentifier(String atlasGUID, + String atlasTypeName, + String atlasName, + String lastKnownEgeriaDisplayName, + String externalInstanceCreatedBy, + Date externalInstanceCreationTime, + String externalInstanceLastUpdatedBy, + Date externalInstanceLastUpdateTime, + long externalInstanceVersion, + SynchronizationDirection synchronizationDirection) + { + ExternalIdentifierProperties externalIdentifierProperties = new ExternalIdentifierProperties(); + externalIdentifierProperties.setExternalIdentifier(atlasGUID); + externalIdentifierProperties.setExternalIdentifierName(atlasGUIDPropertyName); + externalIdentifierProperties.setKeyPattern(KeyPattern.LOCAL_KEY); + externalIdentifierProperties.setExternalIdentifierSource(connectorName); + externalIdentifierProperties.setExternalInstanceCreatedBy(externalInstanceCreatedBy); + externalIdentifierProperties.setExternalInstanceCreationTime(externalInstanceCreationTime); + externalIdentifierProperties.setExternalInstanceLastUpdatedBy(externalInstanceLastUpdatedBy); + externalIdentifierProperties.setExternalInstanceLastUpdateTime(externalInstanceLastUpdateTime); + externalIdentifierProperties.setExternalInstanceVersion(externalInstanceVersion); + externalIdentifierProperties.setSynchronizationDirection(synchronizationDirection); + + Map mappingProperties = new HashMap<>(); + + mappingProperties.put(modulePropertyName, connectorName + ":" + moduleName); + + if (atlasTypeName != null) + { + mappingProperties.put(atlasTypeMappingPropertyName, atlasTypeName); + } + + if (atlasName != null) + { + mappingProperties.put(atlasNameMappingPropertyName, atlasName); + } + + if (lastKnownEgeriaDisplayName != null) + { + mappingProperties.put(egeriaNameMappingPropertyName, lastKnownEgeriaDisplayName); + } + + externalIdentifierProperties.setMappingProperties(mappingProperties); + + return externalIdentifierProperties; + } + + + /** + * Check that the Atlas GUID is correct stored in the open metadata element. + * + * @param egeriaElement element to validate and potentially update + * @param egeriaDisplayName associated display name - used for glossary members + * @param atlasEntity equivalent entity from Apache Atlas + * @param atlasGUID Unique identifier from Apache Atlas + * @param atlasTypeName name of the atlas type + * @param atlasName atlas name property + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem connecting with Egeria + */ + protected void ensureAtlasExternalIdentifier(MetadataElement egeriaElement, + String egeriaDisplayName, + AtlasEntity atlasEntity, + String atlasGUID, + String atlasTypeName, + String atlasName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + /* + * Check that the Atlas Glossary's GUID is stored as an external identifier. + */ + MetadataCorrelationHeader metadataCorrelationHeader = this.myContext.getMetadataCorrelationHeader(egeriaElement); + + if (metadataCorrelationHeader != null) + { + if (atlasGUID.equals(metadataCorrelationHeader.getExternalIdentifier())) + { + /* + * Atlas GUID is stored as an external identifier. + */ + egeriaUpdateRequired(egeriaElement.getElementHeader().getGUID(), + egeriaElement.getElementHeader().getType().getTypeName(), + egeriaElement, + atlasEntity); + // todo check and update external identifier - need to check if update is necessary + return; + } + else + { + myContext.removeExternalIdentifier(egeriaElement.getElementHeader().getGUID(), + egeriaElement.getElementHeader().getType().getTypeName(), + metadataCorrelationHeader.getExternalIdentifier()); + } + } + + /* + * Set up external Identifier + */ + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasGUID, + atlasTypeName, + atlasName, + egeriaDisplayName, + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.TO_THIRD_PARTY); + + myContext.addExternalIdentifier(egeriaElement.getElementHeader().getGUID(), egeriaElement.getElementHeader().getType().getTypeName(), externalIdentifierProperties); + } + + + /** + * Return the list of unique identifiers from a list of entities from Apache Atlas. + * + * @param atlasEntities list of entities retrieved from Apache Atlas + * @return list of guids (or empty list but not null) + */ + protected List getValidAtlasGUIDs(List atlasEntities) + { + List validAtlasGUIDs = new ArrayList<>(); + + if (atlasEntities != null) + { + for (AtlasEntityWithExtInfo atlasEntityWithExtInfo : atlasEntities) + { + if (atlasEntityWithExtInfo != null) + { + AtlasEntity atlasEntity = atlasEntityWithExtInfo.getEntity(); + + if (atlasEntity != null) + { + validAtlasGUIDs.add(atlasEntity.getGuid()); + } + } + } + } + + + return validAtlasGUIDs; + } + + + /** + * Retrieve a string property from and Apache Atlas entity's attributes. + * + * @param attributes attribute map + * @param propertyName name of property to extract + * @return extracted string or null + */ + protected String getAtlasStringProperty(Map attributes, + String propertyName) + { + if (attributes != null) + { + if (attributes.get(propertyName) != null) + { + return attributes.get(propertyName).toString(); + } + } + + return null; + } + + + /** + * Retrieve a boolean property from and Apache Atlas entity's attributes. + * + * @param attributes attribute map + * @param propertyName name of property to extract + * @return extracted boolean or null + */ + protected boolean getAtlasBooleanProperty(Map attributes, + String propertyName) + { + if (attributes != null) + { + if (attributes.get(propertyName) != null) + { + if (attributes.get(propertyName).toString() == "true") + { + return true; + } + } + } + + return false; + } + + + /** + * Retrieve a string property map from and Apache Atlas entity's attributes. + * + * @param attributes attribute map + * @param propertyName name of property to extract + * @return extracted string or null + */ + protected Map getAtlasPropertyMap(Map attributes, + String propertyName) + { + if (attributes != null) + { + if (attributes.get(propertyName) instanceof Map propertyObjectMap) + { + Map propertyMap = new HashMap<>(); + for (Object propertyMapKey : propertyObjectMap.keySet()) + { + if (propertyMapKey != null) + { + String propertyValue = propertyObjectMap.get(propertyMapKey).toString(); + + if (propertyValue != null) + { + propertyMap.put(propertyMapKey.toString(), propertyValue); + } + } + } + + return propertyMap; + } + } + + return null; + } + + + /** + * Retrieve a string array property from and Apache Atlas entity's attributes. + * + * @param attributes attribute map + * @param propertyName name of property to extract + * @return extracted string or null + */ + protected List getAtlasStringArray(Map attributes, + String propertyName) + { + if (attributes != null) + { + if (attributes.get(propertyName) instanceof Map propertyObjectMap) + { + List propertyList = new ArrayList<>(); + for (Object propertyMapKey : propertyObjectMap.keySet()) + { + if (propertyMapKey != null) + { + String propertyValue = propertyObjectMap.get(propertyMapKey).toString(); + + if (propertyValue != null) + { + propertyList.add(propertyValue); + } + } + } + + return propertyList; + } + } + + return null; + } + + + /** + * Add a property from Apache Atlas to Egeria's additionalProperties map since it has nowhere else to go. + * + * @param atlasAttributes all of the attributes retrieved from Apache Atlas + * @param skipPropertyNames names of the properties that have already been extracted + * @return additionalProperties populated with properties from Apache Atlas + */ + protected Map addRemainingPropertiesToAdditionalProperties(Map atlasAttributes, + List skipPropertyNames) + { + if (atlasAttributes != null) + { + Map egeriaAdditionalProperties = new HashMap<>(); + + for (String propertyName : atlasAttributes.keySet()) + { + if (! skipPropertyNames.contains(propertyName)) + { + Object propertyValue = atlasAttributes.get(propertyName); + + if (propertyValue != null) + { + egeriaAdditionalProperties.put(propertyName, propertyValue.toString()); + } + } + } + + if (! egeriaAdditionalProperties.isEmpty()) + { + return egeriaAdditionalProperties; + } + } + + return null; + } + + + /** + * Add a property from Apache Atlas to Egeria's additionalProperties map since it has nowhere else to go. + * Since the property is a map of properties, each entry is added as separate property using a dotted + * notation mapPropertyName.mapPropertyKey.mapPropertyValue. + * + * @param atlasAttributes all of the attributes retrieved from Apache Atlas + * @param propertyName name of the property to extract + * @param egeriaAdditionalProperties additionalProperties to map to populate + */ + protected void addStringArrayToAdditionalProperties(Map atlasAttributes, + String propertyName, + Map egeriaAdditionalProperties) + { + List atlasPropertyList = this.getAtlasStringArray(atlasAttributes, propertyName); + + if ((atlasPropertyList != null) && (! atlasPropertyList.isEmpty())) + { + int index = 0; + for (String propertyValue : atlasPropertyList) + { + if (propertyValue != null) + { + egeriaAdditionalProperties.put(propertyName + "." + index, propertyValue); + index ++; + } + } + } + } + + + /** + * Add a property from Apache Atlas to Egeria's additionalProperties map since it has nowhere else to go. + * Since the property is a map of properties, each entry is added as separate property using a dotted + * notation mapPropertyName.mapPropertyKey.mapPropertyValue. + * + * @param atlasAttributes all of the attributes retrieved from Apache Atlas + * @param propertyName name of the property to extract + * @param egeriaAdditionalProperties additionalProperties to map to populate + */ + protected void addPropertyMapToAdditionalProperties(Map atlasAttributes, + String propertyName, + Map egeriaAdditionalProperties) + { + Map atlasPropertyMap = this.getAtlasPropertyMap(atlasAttributes, propertyName); + + if ((atlasPropertyMap != null) && (! atlasPropertyMap.isEmpty())) + { + for (String propertyKey : atlasPropertyMap.keySet()) + { + String propertyValue = atlasPropertyMap.get(propertyKey); + + if (propertyValue != null) + { + egeriaAdditionalProperties.put(propertyName + "." + propertyKey, propertyValue); + } + } + } + } + + + + /** + * Synchronize all of the data set entities from Apache Atlas to the open metadata ecosystem. + * + * @param atlasTypeName name of the type of entity to synchronize from Apache Atlas + * @param egeriaTypeName name of the type of entity to synchronize to the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected void syncAtlasDataSetsAsDataSets(String atlasTypeName, + String egeriaTypeName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + /* + * Retrieve the data sets catalogued in Apache Atlas. This is turned into an Open Metadata data set entity. + */ + int startFrom = 0; + int pageSize = myContext.getMaxPageSize(); + + List atlasSearchResult = atlasClient.getEntitiesForType(atlasTypeName, startFrom, pageSize); + + while ((atlasSearchResult != null) && (! atlasSearchResult.isEmpty())) + { + /* + * Found new datasets - process each one in turn. + */ + for (AtlasEntityHeader atlasEntityHeader : atlasSearchResult) + { + String atlasDataSetGUID = atlasEntityHeader.getGuid(); + + AtlasEntityWithExtInfo atlasDataSetEntity = atlasClient.getEntityByGUID(atlasDataSetGUID); + + this.syncAtlasDataSetAsDataSet(atlasDataSetEntity, atlasTypeName, egeriaTypeName); + } + + /* + * Retrieve the next page + */ + startFrom = startFrom + pageSize; + atlasSearchResult = atlasClient.getEntitiesForType(atlasTypeName, startFrom, pageSize); + } + } + + + /** + * Copy the contents of the Atlas data set entity into open metadata as a type of DataSet. + * + * @param atlasDataSetEntity entity retrieved from Apache Atlas + * @param atlasTypeName name of the type of entity in Apache Atlas to synchronize + * @param egeriaTypeName name of the type of entity in the open metadata ecosystem to synchronize + * + * @return unique identifier of the data set + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected String syncAtlasDataSetAsDataSet(AtlasEntityWithExtInfo atlasDataSetEntity, + String atlasTypeName, + String egeriaTypeName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "syncAtlasDataSetAsDataSet"; + + if ((atlasDataSetEntity != null) && (atlasDataSetEntity.getEntity() != null)) + { + String egeriaDataSetGUID = this.getEgeriaGUID(atlasDataSetEntity); + + if (egeriaDataSetGUID == null) + { + /* + * No record of a previous synchronization with the open metadata ecosystem. + */ + egeriaDataSetGUID = createAtlasDataSetAsDataSetInEgeria(atlasDataSetEntity, atlasTypeName, egeriaTypeName); + } + else + { + try + { + /* + * Does the matching entity in the open metadata ecosystem still exist. Notice effective time is set to null + * to make sure that this entity is found no matter what its effectivity dates are set to. + */ + dataAssetExchangeService.getDataAssetByGUID(egeriaDataSetGUID, null); + + /* + * The Egeria equivalent is still in place. + */ + updateAtlasDataSetAsDataSetInEgeria(atlasDataSetEntity, egeriaDataSetGUID, atlasTypeName, egeriaTypeName); + } + catch (InvalidParameterException notKnown) + { + /* + * The open metadata ecosystem entity has been deleted - put it back. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaTypeName, + egeriaDataSetGUID, + atlasDataSetEntity.getEntity().getGuid())); + removeEgeriaGUID(atlasDataSetEntity); + egeriaDataSetGUID = createAtlasDataSetAsDataSetInEgeria(atlasDataSetEntity, atlasTypeName, egeriaTypeName); + } + } + + return egeriaDataSetGUID; + } + + return null; + } + + + /** + * Create the data set in the open metadata ecosystem. + * + * @param atlasDataSetEntity entity retrieved from Apache Atlas + * @param atlasTypeName name of the type of entity to synchronize from Apache Atlas + * @param egeriaTypeName name of the type of entity to synchronize to the open metadata ecosystem + * + * @return unique identifier of the data set + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected String createAtlasDataSetAsDataSetInEgeria(AtlasEntityWithExtInfo atlasDataSetEntity, + String atlasTypeName, + String egeriaTypeName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAtlasDataSetAsDataSetInEgeria"; + + if (atlasDataSetEntity != null) + { + AtlasEntity atlasEntity = atlasDataSetEntity.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + DataAssetProperties dataAssetProperties = this.getEgeriaDataSetProperties(atlasEntity, egeriaTypeName); + + String egeriaDataSetGUID = dataAssetExchangeService.createDataAsset(true, + externalIdentifierProperties, + dataAssetProperties); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasTypeName, + egeriaDataSetGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaDataSetGUID, + dataAssetProperties.getQualifiedName(), + egeriaTypeName, + false, + false); + + setOwner(atlasDataSetEntity, egeriaDataSetGUID); + + return egeriaDataSetGUID; + } + } + + return null; + } + + + /** + * Update the properties of an open metadata data set with the current properties from Apache Atlas. + * + * @param atlasDataSetEntity entity retrieved from Apache Atlas + * @param egeriaDataSetGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @param atlasTypeName name of the type of entity to synchronize from Apache Atlas + * @param egeriaTypeName name of the type of entity to synchronize to the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected void updateAtlasDataSetAsDataSetInEgeria(AtlasEntityWithExtInfo atlasDataSetEntity, + String egeriaDataSetGUID, + String atlasTypeName, + String egeriaTypeName) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateAtlasDataSetAsDataSetInEgeria"; + + if (atlasDataSetEntity != null) + { + AtlasEntity atlasEntity = atlasDataSetEntity.getEntity(); + DataAssetElement dataAssetElement = dataAssetExchangeService.getDataAssetByGUID(egeriaDataSetGUID, + null); + + if (atlasEntity != null) + { + if (this.egeriaUpdateRequired(egeriaDataSetGUID, + egeriaTypeName, + dataAssetElement, + atlasEntity)) + { + DataAssetProperties dataAssetProperties = this.getEgeriaDataSetProperties(atlasEntity, egeriaTypeName); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + atlasTypeName, + egeriaDataSetGUID)); + + dataAssetExchangeService.updateDataAsset(egeriaDataSetGUID, + atlasEntity.getGuid(), + false, + dataAssetProperties, + null); + } + } + } + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected DataAssetProperties getEgeriaDataSetProperties(AtlasEntity atlasEntity, + String egeriaTypeName) + { + DataAssetProperties dataAssetProperties = this.getDataAssetProperties(atlasEntity, egeriaTypeName); + + dataAssetProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasAssetProperties)); + + return dataAssetProperties; + } + + /** + * Add the standard properties for an Atlas asset entity into an Egeria DataAssetProperties. This is suitable for a DataSet. + * + * @param atlasEntity asset entity retrieved from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return data asset properties used to maintaining data assets in the open metadata ecosystem + */ + protected DataAssetProperties getDataAssetProperties(AtlasEntity atlasEntity, + String egeriaTypeName) + { + if (atlasEntity != null) + { + DataAssetProperties dataAssetProperties = new DataAssetProperties(); + + Map attributes = atlasEntity.getAttributes(); + + dataAssetProperties.setTypeName(egeriaTypeName); + dataAssetProperties.setDeployedImplementationType(atlasEntity.getTypeName()); + dataAssetProperties.setQualifiedName("Apache Atlas" + ":" + atlasEntity.getTypeName() + ":" + getAtlasStringProperty(attributes, atlasQualifiedNamePropertyName)); + dataAssetProperties.setTechnicalName(getAtlasStringProperty(attributes, atlasNamePropertyName)); + dataAssetProperties.setTechnicalDescription(getAtlasStringProperty(attributes, atlasDescriptionPropertyName)); + dataAssetProperties.setDisplayName(getAtlasStringProperty(attributes, atlasDisplayNamePropertyName)); + dataAssetProperties.setDescription(getAtlasStringProperty(attributes, atlasUserDescriptionPropertyName)); + + return dataAssetProperties; + } + + return null; + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasFSPathEntity retrieve fs_path entity from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected DataAssetProperties getEgeriaDataFileProperties(AtlasEntity atlasFSPathEntity, + String egeriaTypeName) + { + final String pathNamePropertyName = "path"; + + DataStoreProperties dataAssetProperties = new DataStoreProperties(); + + Map attributes = atlasFSPathEntity.getAttributes(); + + dataAssetProperties.setTypeName(egeriaTypeName); + dataAssetProperties.setDeployedImplementationType(atlasFSPathEntity.getTypeName()); + dataAssetProperties.setQualifiedName("Apache Atlas" + ":" + atlasFSPathEntity.getTypeName() + ":" + getAtlasStringProperty(attributes, atlasQualifiedNamePropertyName)); + dataAssetProperties.setTechnicalName(getAtlasStringProperty(attributes, atlasNamePropertyName)); + dataAssetProperties.setTechnicalDescription(getAtlasStringProperty(attributes, atlasDescriptionPropertyName)); + dataAssetProperties.setDisplayName(getAtlasStringProperty(attributes, atlasDisplayNamePropertyName)); + dataAssetProperties.setDescription(getAtlasStringProperty(attributes, atlasUserDescriptionPropertyName)); + + + Map additionalProperties = addRemainingPropertiesToAdditionalProperties(atlasFSPathEntity.getAttributes(), + atlasDataFileProperties); + + dataAssetProperties.setAdditionalProperties(additionalProperties); + + return dataAssetProperties; + } + + + /** + * Add the standard properties for an Atlas asset entity into an Egeria DataAssetProperties. This is suitable for a DataSet. + * + * @param atlasEntity asset entity retrieved from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return data asset properties used to maintaining data assets in the open metadata ecosystem + */ + protected ProcessProperties getProcessProperties(AtlasEntity atlasEntity, + String egeriaTypeName) + { + if (atlasEntity != null) + { + ProcessProperties processProperties = new ProcessProperties(); + + Map attributes = atlasEntity.getAttributes(); + + processProperties.setTypeName(egeriaTypeName); + processProperties.setDeployedImplementationType(atlasEntity.getTypeName()); + processProperties.setQualifiedName("Apache Atlas" + ":" + atlasEntity.getTypeName() + ":" + getAtlasStringProperty(attributes, atlasQualifiedNamePropertyName)); + processProperties.setTechnicalName(getAtlasStringProperty(attributes, atlasNamePropertyName)); + processProperties.setTechnicalDescription(getAtlasStringProperty(attributes, atlasDescriptionPropertyName)); + processProperties.setDisplayName(getAtlasStringProperty(attributes, atlasDisplayNamePropertyName)); + processProperties.setDescription(getAtlasStringProperty(attributes, atlasUserDescriptionPropertyName)); + + return processProperties; + } + + return null; + } + + + /** + * Add the standard properties for an Atlas asset entity into an Egeria SchemaAttributeProperties. + * + * @param atlasEntity asset entity retrieved from Apache Atlas + * @param egeriaSchemaAttributeTypeName type name for the schema attribute + * @param egeriaSchemaTypeTypeName type name for the schema type + * @return data asset properties used to maintaining data assets in the open metadata ecosystem + */ + protected SchemaAttributeProperties getSchemaAttributeProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName) + { + if (atlasEntity != null) + { + SchemaAttributeProperties schemaAttributeProperties = new SchemaAttributeProperties(); + SchemaTypeProperties schemaTypeProperties = new SchemaTypeProperties(); + + Map attributes = atlasEntity.getAttributes(); + + schemaAttributeProperties.setTypeName(egeriaSchemaAttributeTypeName); + schemaAttributeProperties.setQualifiedName("Apache Atlas" + ":" + atlasEntity.getTypeName() + ":" + getAtlasStringProperty(attributes, "qualifiedName")); + + schemaAttributeProperties.setDisplayName(getAtlasStringProperty(attributes, "name") ); + schemaAttributeProperties.setDescription(getAtlasStringProperty(attributes, "description")); + + schemaAttributeProperties.setTypeName(egeriaSchemaTypeTypeName); + schemaTypeProperties.setDisplayName(getAtlasStringProperty(attributes, "displayName")); + schemaTypeProperties.setDescription(getAtlasStringProperty(attributes, "userDescription")); + + schemaAttributeProperties.setSchemaType(schemaTypeProperties); + + return schemaAttributeProperties; + } + + return null; + } + + + /** + * Set up the Ownership classification in open metadata if the Atlas entity has the owner property set. + * + * @param atlasEntityWithExtInfo entity retrieved from Apache Atlas + * @param egeriaGUID unique identifier of the element in open metadata + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem communicating with Egeria. + */ + protected void setOwner(AtlasEntityWithExtInfo atlasEntityWithExtInfo, + String egeriaGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + if ((atlasEntityWithExtInfo != null) && + (atlasEntityWithExtInfo.getEntity() != null) && + (atlasEntityWithExtInfo.getEntity().getAttributes() != null)) + { + String owner = this.getAtlasStringProperty(atlasEntityWithExtInfo.getEntity().getAttributes(), + atlasOwnerPropertyName); + + if (owner != null) + { + OwnerProperties properties = new OwnerProperties(); + + properties.setOwner(owner); + properties.setOwnerTypeName(egeriaOwnerTypeName); + properties.setOwnerPropertyName(egeriaOwnerPropertyName); + + stewardshipExchangeService.addOwnership(egeriaGUID, + atlasEntityWithExtInfo.getEntity().getGuid(), + properties, + null); + } + } + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasLineageIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasLineageIntegrationModule.java new file mode 100644 index 00000000000..eb1cf7ee65c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasLineageIntegrationModule.java @@ -0,0 +1,436 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + + +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.ProcessElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ProcessProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ProcessStatus; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityHeader; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityWithExtInfo; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; +import org.odpi.openmetadata.integrationservices.catalog.connector.LineageExchangeService; + +import java.util.ArrayList; +import java.util.List; + +/** + * AtlasLineageIntegrationModule synchronizes lineage from Apache Atlas to the open metadata ecosystem. + * It is called after the registered integration modules have established the key assets into the open metadata ecosystem. + */ +public class AtlasLineageIntegrationModule extends AtlasIntegrationModuleBase +{ + private static final String lineageModuleName = "Apache Atlas Lineage Integration Module"; + + protected final static String egeriaDataSetTypeName = "DataSet"; + protected final static String egeriaProcessTypeName = "DeployedSoftwareComponent"; + protected final static String atlasProcessTypeName = "Process"; + protected final static String atlasProcessInputsPropertyName = "inputs"; + protected final static String atlasProcessOutputsPropertyName = "outputs"; + + + private final LineageExchangeService lineageExchangeService; + + + + /** + * Constructor for the module is supplied with the runtime context in order to operate. + * + * @param connectorName name of the connector (for messages) + * @param connectionProperties connection properties used to start the connector + * @param auditLog logging destination + * @param myContext integration context + * @param targetRootURL URL to connect to Apache Atlas + * @param atlasClient client to connect to Apache Atlas + * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector + * @throws UserNotAuthorizedException security problem + */ + public AtlasLineageIntegrationModule(String connectorName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + super(connectorName, + lineageModuleName, + connectionProperties, + auditLog, + myContext, + targetRootURL, + atlasClient, + embeddedConnectors); + + this.lineageExchangeService = myContext.getLineageExchangeService(); + + /* + * Deduplication is turned off so that the connector works with the entities it created rather than + * entities from other systems that have been linked as duplicates. + */ + this.lineageExchangeService.setForDuplicateProcessing(true); + } + + + /** + * Retrieves all the processes catalogued in Apache Atlas and creates an equivalent process in the open metadata ecosystem. + * Then establishes DataFlow relationships between the open metadata entities that match to lineage relationships in Apache Atlas. + * It is possible that some DataSets in the lineage flow have not been catalogued by the registered modules. + * A placeholder for each of these data sets is created to ensure the lineage graph is complete. + * + * @throws ConnectorCheckedException problem communicating with Apache Atlas or Egeria. + */ + public void synchronizeLineage() throws ConnectorCheckedException + { + final String methodName = "synchronizeLineage()"; + + /* + * The configuration can turn off the cataloguing of assets into the open metadata ecosystem. + */ + if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || + (myContext.getPermittedSynchronization() == PermittedSynchronization.TO_THIRD_PARTY)) + { + try + { + /* + * Retrieve the processes catalogued in Apache Atlas. This is turned into an Open Metadata DeployedSoftwareComponent. + */ + int startFrom = 0; + int pageSize = myContext.getMaxPageSize(); + + List atlasSearchResult = atlasClient.getEntitiesForType(atlasProcessTypeName, startFrom, pageSize); + + while ((atlasSearchResult != null) && (! atlasSearchResult.isEmpty())) + { + /* + * Found new process - work with each one in turn. + */ + for (AtlasEntityHeader atlasEntityHeader : atlasSearchResult) + { + String atlasProcessGUID = atlasEntityHeader.getGuid(); + + AtlasEntityWithExtInfo atlasProcessEntity = atlasClient.getEntityByGUID(atlasProcessGUID); + + String egeriaProcessGUID = this.syncAtlasProcess(atlasProcessEntity); + + if (egeriaProcessGUID != null) + { + /* + * Synchronize inputs to the process + */ + if ((atlasProcessEntity != null) && + (atlasProcessEntity.getEntity() != null) && + (atlasProcessEntity.getEntity().getRelationshipAttributes() != null) && + (atlasProcessEntity.getEntity().getRelationshipAttributes().get(atlasProcessInputsPropertyName) != null)) + { + List atlasInputDataSets = atlasClient.getRelatedEntities(atlasProcessEntity, + atlasProcessInputsPropertyName); + + if (atlasInputDataSets != null) + { + for (AtlasEntityWithExtInfo atlasInputDataSet : atlasInputDataSets) + { + if ((atlasInputDataSet != null) && (atlasInputDataSet.getEntity() != null)) + { + String egeriaDataSetGUID = syncAtlasDataSetAsDataSet(atlasInputDataSet, + atlasInputDataSet.getEntity().getTypeName(), + egeriaDataSetTypeName); + + /* + * Set up the lineage relationship + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.ADDING_LINEAGE.getMessageDefinition(connectorName, + egeriaDataSetTypeName, + egeriaDataSetGUID, + egeriaProcessTypeName, + egeriaProcessGUID)); + lineageExchangeService.setupDataFlow(true, + egeriaDataSetGUID, + egeriaProcessGUID, + null, + null); + } + } + } + } + + /* + * Synchronize outputs to the process + */ + if ((atlasProcessEntity != null) && + (atlasProcessEntity.getEntity() != null) && + (atlasProcessEntity.getEntity().getRelationshipAttributes() != null) && + (atlasProcessEntity.getEntity().getRelationshipAttributes().get(atlasProcessOutputsPropertyName) != null)) + { + List atlasOutputDataSets = atlasClient.getRelatedEntities(atlasProcessEntity, + atlasProcessOutputsPropertyName); + + if (atlasOutputDataSets != null) + { + for (AtlasEntityWithExtInfo atlasInputDataSet : atlasOutputDataSets) + { + if ((atlasInputDataSet != null) && (atlasInputDataSet.getEntity() != null)) + { + String egeriaDataSetGUID = syncAtlasDataSetAsDataSet(atlasInputDataSet, + atlasInputDataSet.getEntity().getTypeName(), + egeriaDataSetTypeName); + + /* + * Set up the lineage relationship + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.ADDING_LINEAGE.getMessageDefinition(connectorName, + egeriaProcessTypeName, + egeriaProcessGUID, + egeriaDataSetTypeName, + egeriaDataSetGUID)); + lineageExchangeService.setupDataFlow(true, + egeriaProcessGUID, + egeriaDataSetGUID, + null, + null); + } + } + } + } + } + } + + /* + * Retrieve the next page + */ + startFrom = startFrom + pageSize; + atlasSearchResult = atlasClient.getEntitiesForType(atlasProcessTypeName, startFrom, pageSize); + } + } + catch (Exception error) + { + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); + } + + throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + this.getClass().getName(), + methodName, + error); + } + } + } + + + /** + * Copy the contents of the Atlas database entity into open metadata. + * + * @param atlasProcessEntity entity retrieved from Apache Atlas + * + * @return unique identifier of the equivalent element in open metadata (egeriaProcessGUID) + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private String syncAtlasProcess(AtlasEntityWithExtInfo atlasProcessEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "syncAtlasProcess"; + + if ((atlasProcessEntity != null) && (atlasProcessEntity.getEntity() != null)) + { + String egeriaProcessGUID = this.getEgeriaGUID(atlasProcessEntity); + + if (egeriaProcessGUID == null) + { + /* + * No record of a previous synchronization with the open metadata ecosystem. + */ + egeriaProcessGUID = createAtlasProcessInEgeria(atlasProcessEntity); + } + else + { + try + { + /* + * Does the matching entity in the open metadata ecosystem still exist. Notice effective time is set to null + * to make sure that this entity is found no matter what its effectivity dates are set to. + */ + dataAssetExchangeService.getDataAssetByGUID(egeriaProcessGUID, null); + + /* + * The Egeria equivalent is still in place. + */ + updateAtlasProcessInEgeria(atlasProcessEntity, egeriaProcessGUID); + } + catch (InvalidParameterException notKnown) + { + /* + * The open metadata ecosystem entity has been deleted - put it back. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaProcessTypeName, + egeriaProcessGUID, + atlasProcessEntity.getEntity().getGuid())); + removeEgeriaGUID(atlasProcessEntity); + egeriaProcessGUID = createAtlasProcessInEgeria(atlasProcessEntity); + } + } + + return egeriaProcessGUID; + } + + return null; + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @return properties to pass to Egeria + */ + protected ProcessProperties getEgeriaProcessProperties(AtlasEntity atlasEntity) + { + ProcessProperties processProperties = super.getProcessProperties(atlasEntity, egeriaProcessTypeName); + + List excludedProperties = new ArrayList<>(atlasAssetProperties); + + excludedProperties.add(atlasProcessInputsPropertyName); + excludedProperties.add(atlasProcessOutputsPropertyName); + + processProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + excludedProperties)); + + return processProperties; + } + + + + /** + * Create the database in the open metadata ecosystem. + * + * @param atlasProcessEntity entity retrieved from Apache Atlas + * + * @return unique identifier of the database entity in open metadata + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected String createAtlasProcessInEgeria(AtlasEntityWithExtInfo atlasProcessEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAtlasProcessInEgeria"; + + if (atlasProcessEntity != null) + { + AtlasEntity atlasEntity = atlasProcessEntity.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + ProcessProperties processProperties = this.getEgeriaProcessProperties(atlasEntity); + + String egeriaProcessGUID = lineageExchangeService.createProcess(true, + externalIdentifierProperties, + processProperties, + ProcessStatus.ACTIVE); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaProcessTypeName, + egeriaProcessGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaProcessGUID, + processProperties.getQualifiedName(), + egeriaProcessTypeName, + false, + false); + + setOwner(atlasProcessEntity, egeriaProcessGUID); + + return egeriaProcessGUID; + } + } + + return null; + } + + + /** + * Update the properties of an open metadata database with the current properties from Apache Atlas. + * + * @param atlasProcessEntity entity retrieved from Apache Atlas + * @param egeriaProcessGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected void updateAtlasProcessInEgeria(AtlasEntityWithExtInfo atlasProcessEntity, + String egeriaProcessGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateAtlasProcessInEgeria"; + + if (atlasProcessEntity != null) + { + AtlasEntity atlasEntity = atlasProcessEntity.getEntity(); + ProcessElement processElement = lineageExchangeService.getProcessByGUID(egeriaProcessGUID, null); + + if (atlasEntity != null) + { + if (this.egeriaUpdateRequired(egeriaProcessGUID, + egeriaProcessTypeName, + processElement, + atlasEntity)) + { + ProcessProperties processProperties = this.getEgeriaProcessProperties(atlasEntity); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaProcessTypeName, + egeriaProcessGUID)); + + lineageExchangeService.updateProcess(egeriaProcessGUID, atlasEntity.getGuid(), false, processProperties, null); + } + } + } + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasRegisteredIntegrationModuleBase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasRegisteredIntegrationModuleBase.java new file mode 100644 index 00000000000..ec719f776d5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/AtlasRegisteredIntegrationModuleBase.java @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; + +import java.util.Arrays; +import java.util.List; + +/** + * AtlasRegisteredIntegrationModuleBase defines the common classes for integration modules that are working with assets from Apache Atlas. + */ +public abstract class AtlasRegisteredIntegrationModuleBase extends AtlasIntegrationModuleBase implements RegisteredIntegrationModule +{ + private final List supportedEntityTypes; + private final List listenForTypes; + + + + /** + * Initialize the common properties for an integration module. + * + * @param connectorName name of this connector + * @param moduleName name of this module + * @param connectionProperties supplied connector used to configure the connector + * @param auditLog logging destination + * @param myContext integration context assigned to the connector + * @param targetRootURL host name and port of Apache Atlas + * @param atlasClient client to call Apache Atlas + * @param embeddedConnectors any connectors embedded in the connector (such as the secrets connector or Kafka connector) + * @param supportedEntityTypes list of entity types that this module is maintaining + * @param listenForTypes list of types that the module wants to receive events on + * @throws UserNotAuthorizedException the data asset service has not been enabled. + */ + public AtlasRegisteredIntegrationModuleBase(String connectorName, + String moduleName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors, + String[] supportedEntityTypes, + String[] listenForTypes) throws UserNotAuthorizedException + { + super(connectorName, moduleName, connectionProperties, auditLog, myContext, targetRootURL, atlasClient, embeddedConnectors); + + if (supportedEntityTypes == null) + { + this.supportedEntityTypes = null; + } + else + { + this.supportedEntityTypes = Arrays.asList(supportedEntityTypes); + } + + if (listenForTypes == null) + { + this.listenForTypes = null; + } + else + { + this.listenForTypes = Arrays.asList(listenForTypes); + } + } + + + /** + * Return the list of entity types that this module is maintaining. + * + * @return list of type names + */ + @Override + public List getSupportedEntityTypes() + { + return supportedEntityTypes; + } + + + /** + * Return the list of open metadata types that this module supports events for. + * + * @return list of types + */ + public List getListenForTypes() + { + return listenForTypes; + } + + + /** + * Return the name of this module for messages. + * + * @return module name + */ + public String getModuleName() + { + return moduleName; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/DatabaseIntegrationModuleBase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/DatabaseIntegrationModuleBase.java new file mode 100644 index 00000000000..29cdc4a8c97 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/DatabaseIntegrationModuleBase.java @@ -0,0 +1,1069 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + + +import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.DataAssetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.SchemaAttributeElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.SchemaTypeElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataAssetProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SchemaAttributeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SchemaTypeProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasAuditCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ffdc.ApacheAtlasErrorCode; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityHeader; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntityWithExtInfo; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; + +import java.util.List; + +/** + * DatabaseIntegrationModuleBase abstracts the process of synchronizing relational metadata from Apache Atlas, so it is + * independent of the actual Apache Atlas types. The subclasses supply the types. This is because Apache Atlas has multiple type + * definitions for this type of metadata. + */ +public abstract class DatabaseIntegrationModuleBase extends AtlasRegisteredIntegrationModuleBase +{ + protected final static String egeriaDatabaseTypeName = "DeployedDatabaseSchema"; + protected final static String egeriaRootDatabaseSchemaTypeTypeName = "RelationalDBSchemaType"; + protected final static String egeriaDatabaseTableTypeName = "RelationalTable"; + protected final static String egeriaDatabaseTableTypeTypeName = "RelationalTableType"; + protected final static String egeriaDatabaseColumnTypeName = "RelationalColumn"; + protected final static String egeriaDatabaseColumnTypeTypeName = "PrimitiveSchemaType"; + + + private final String atlasDatabaseTypeName; + private final String atlasDatabaseTablesPropertyName; + private final String atlasDatabaseTableTypeName; + private final String atlasDatabaseColumnsPropertyName; + + + /** + * Constructor for the module is supplied with the runtime context in order to operate. + * + * @param connectorName name of the connector (for messages) + * @param moduleName name of this module + * @param atlasDatabaseTypeName name of type in atlas used for the database + * @param atlasDatabaseTablesPropertyName name of the property used to navigate from the database to its tables. + * @param atlasDatabaseTableTypeName name of the type used to represent a database table in atlas + * @param atlasDatabaseColumnsPropertyName name of the property used to navigate from a database table to its columns + * @param atlasDatabaseColumnTypeName name of the type used to represent a database column in atlas + * @param connectionProperties connection properties used to start the connector + * @param auditLog logging destination + * @param myContext integration context + * @param targetRootURL URL to connect to Apache Atlas + * @param atlasClient client to connect to Apache Atlas + * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector + * @throws UserNotAuthorizedException security problem + */ + public DatabaseIntegrationModuleBase(String connectorName, + String moduleName, + String atlasDatabaseTypeName, + String atlasDatabaseTablesPropertyName, + String atlasDatabaseTableTypeName, + String atlasDatabaseColumnsPropertyName, + String atlasDatabaseColumnTypeName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + super(connectorName, + moduleName, + connectionProperties, + auditLog, + myContext, + targetRootURL, + atlasClient, + embeddedConnectors, + new String[]{atlasDatabaseTypeName, atlasDatabaseTableTypeName, atlasDatabaseColumnTypeName}, + null); + + this.atlasDatabaseTypeName = atlasDatabaseTypeName; + this.atlasDatabaseTablesPropertyName = atlasDatabaseTablesPropertyName; + this.atlasDatabaseTableTypeName = atlasDatabaseTableTypeName; + this.atlasDatabaseColumnsPropertyName = atlasDatabaseColumnsPropertyName; + } + + + /** + * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. + * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration + * as well as any external REST API calls to explicitly refresh the connector. + * + * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. + */ + @Override + public void refresh() throws ConnectorCheckedException + { + final String methodName = "refresh(" + moduleName + ")"; + + /* + * The configuration can turn off the cataloguing of assets into the open metadata ecosystem. + */ + if ((myContext.getPermittedSynchronization() == PermittedSynchronization.BOTH_DIRECTIONS) || + (myContext.getPermittedSynchronization() == PermittedSynchronization.TO_THIRD_PARTY)) + { + try + { + /* + * Retrieve the databases catalogued in Apache Atlas. They are turned into an Open Metadata DeployedDatabaseSchema entities. + */ + int startFrom = 0; + int pageSize = myContext.getMaxPageSize(); + + List atlasSearchResult = atlasClient.getEntitiesForType(atlasDatabaseTypeName, startFrom, pageSize); + + while ((atlasSearchResult != null) && (! atlasSearchResult.isEmpty())) + { + /* + * Found new databases - process each one in turn. + */ + for (AtlasEntityHeader atlasEntityHeader : atlasSearchResult) + { + String atlasDatabaseGUID = atlasEntityHeader.getGuid(); + + AtlasEntityWithExtInfo atlasDatabaseEntity = atlasClient.getEntityByGUID(atlasDatabaseGUID); + + String egeriaDatabaseGUID = this.syncAtlasDatabase(atlasDatabaseEntity); + + if (egeriaDatabaseGUID != null) + { + /* + * Synchronize each table in turn + */ + if ((atlasDatabaseEntity != null) && + (atlasDatabaseEntity.getEntity() != null) && + (atlasDatabaseEntity.getEntity().getRelationshipAttributes() != null) && + (atlasDatabaseEntity.getEntity().getRelationshipAttributes().get(atlasDatabaseTablesPropertyName) != null)) + { + List atlasDatabaseTables = atlasClient.getRelatedEntities(atlasDatabaseEntity, + atlasDatabaseTablesPropertyName); + + if (atlasDatabaseTables != null) + { + for (AtlasEntityWithExtInfo atlasDatabaseTable : atlasDatabaseTables) + { + if ((atlasDatabaseTable != null) && (atlasDatabaseTable.getEntity() != null)) + { + String egeriaDatabaseTableGUID = syncAtlasDatabaseTable(atlasDatabaseTable, egeriaDatabaseGUID); + + if (egeriaDatabaseTableGUID != null) + { + /* + * Synchronize each column in turn. + */ + if ((atlasDatabaseTable.getEntity().getRelationshipAttributes() != null) && + (atlasDatabaseTable.getEntity().getRelationshipAttributes().get(atlasDatabaseColumnsPropertyName) != null)) + { + List atlasDatabaseColumns = atlasClient.getRelatedEntities( + atlasDatabaseTable, + atlasDatabaseColumnsPropertyName); + + if (atlasDatabaseColumns != null) + { + for (AtlasEntityWithExtInfo atlasDatabaseColumn : atlasDatabaseColumns) + { + if ((atlasDatabaseColumn != null) && (atlasDatabaseTable.getEntity() != null)) + { + syncAtlasDatabaseColumn(atlasDatabaseColumn, egeriaDatabaseTableGUID); + } + } + + this.checkForAdditionalEgeriaColumns(egeriaDatabaseTableGUID, atlasDatabaseColumns); + } + } + } + } + } + + this.checkForAdditionalEgeriaTables(egeriaDatabaseGUID, atlasDatabaseTables); + } + } + } + } + + /* + * Retrieve the next page + */ + startFrom = startFrom + pageSize; + atlasSearchResult = atlasClient.getEntitiesForType(atlasDatabaseTableTypeName, startFrom, pageSize); + } + } + catch (Exception error) + { + if (auditLog != null) + { + auditLog.logException(methodName, + ApacheAtlasAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + error); + } + + throw new ConnectorCheckedException(ApacheAtlasErrorCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName, + error.getClass().getName(), + methodName, + error.getMessage()), + this.getClass().getName(), + methodName, + error); + } + } + } + + + /** + * Process an event that was published by the Asset Manager OMAS. The listener is only registered if metadata is flowing + * from the open metadata ecosystem to Apache Atlas. + * + * @param event event object + */ + @Override + public void processEvent(AssetManagerOutTopicEvent event) + { + // Ignore events + } + + + + /** + * Return the unique identifier of the database schema type for the requested database. This may or may not have been created already. The + * method issues a query to the open metadata ecosystem. If the database schema type is found, its unique identifier is returned. If it is + * not found, a new database schema type is created and attached to the database entity and the unique identifier of the new database schema type + * is returned. + * + * @param egeriaDatabaseGUID unique identifier of the database in the open metadata ecosystem. + * + * @return unique identifier of the database schema type attached to the database. Tables are attached to this object. + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException problem communicating with Egeria. + */ + protected String getEgeriaDatabaseSchemaType(String egeriaDatabaseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + SchemaTypeElement databaseSchemaType = dataAssetExchangeService.getSchemaTypeForElement(egeriaDatabaseGUID, + egeriaDatabaseTypeName, + null); + + if (databaseSchemaType != null) + { + return databaseSchemaType.getElementHeader().getGUID(); + } + + SchemaTypeProperties schemaTypeProperties = new SchemaTypeProperties(); + + schemaTypeProperties.setTypeName(egeriaRootDatabaseSchemaTypeTypeName); + schemaTypeProperties.setQualifiedName(egeriaRootDatabaseSchemaTypeTypeName + " for " + egeriaDatabaseGUID); + + String databaseSchemaTypeGUID = dataAssetExchangeService.createAnchoredSchemaType(true, + egeriaDatabaseGUID, + null, + schemaTypeProperties); + + if (databaseSchemaTypeGUID != null) + { + dataAssetExchangeService.setupSchemaTypeParent(true, + databaseSchemaTypeGUID, + egeriaDatabaseGUID, + egeriaDatabaseTypeName, + null, + null); + } + + return databaseSchemaTypeGUID; + } + + + /** + * Copy the contents of the Atlas database entity into open metadata. + * + * @param atlasDatabaseEntity entity retrieved from Apache Atlas + * + * @return unique identifier of the equivalent element in open metadata (egeriaDatabaseGUID) + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private String syncAtlasDatabase(AtlasEntityWithExtInfo atlasDatabaseEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "syncAtlasDatabase"; + + if ((atlasDatabaseEntity != null) && (atlasDatabaseEntity.getEntity() != null)) + { + String egeriaDatabaseGUID = super.getEgeriaGUID(atlasDatabaseEntity); + + if (egeriaDatabaseGUID == null) + { + /* + * No record of a previous synchronization with the open metadata ecosystem. + */ + egeriaDatabaseGUID = createAtlasDatabaseInEgeria(atlasDatabaseEntity); + } + else + { + try + { + /* + * Does the matching entity in the open metadata ecosystem still exist. Notice effective time is set to null + * to make sure that this entity is found no matter what its effectivity dates are set to. + */ + dataAssetExchangeService.getDataAssetByGUID(egeriaDatabaseGUID, null); + + /* + * The Egeria equivalent is still in place. + */ + updateAtlasDatabaseInEgeria(atlasDatabaseEntity, egeriaDatabaseGUID); + } + catch (InvalidParameterException notKnown) + { + /* + * The open metadata ecosystem entity has been deleted - put it back. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseTypeName, + egeriaDatabaseGUID, + atlasDatabaseEntity.getEntity().getGuid())); + removeEgeriaGUID(atlasDatabaseEntity); + egeriaDatabaseGUID = createAtlasDatabaseInEgeria(atlasDatabaseEntity); + } + } + + this.augmentAtlasDatabaseInEgeria(atlasDatabaseEntity, egeriaDatabaseGUID); + + return egeriaDatabaseGUID; + } + + return null; + } + + + /** + * Create the database in the open metadata ecosystem. + * + * @param atlasDatabaseEntity entity retrieved from Apache Atlas + * + * @return unique identifier of the database entity in open metadata + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected String createAtlasDatabaseInEgeria(AtlasEntityWithExtInfo atlasDatabaseEntity) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAtlasDatabaseInEgeria"; + + if (atlasDatabaseEntity != null) + { + AtlasEntity atlasEntity = atlasDatabaseEntity.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = super.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + DataAssetProperties dataAssetProperties = this.getEgeriaDatabaseProperties(atlasEntity, egeriaDatabaseTypeName); + + String egeriaDatabaseGUID = dataAssetExchangeService.createDataAsset(true, + externalIdentifierProperties, + dataAssetProperties); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseTypeName, + egeriaDatabaseGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaDatabaseGUID, + dataAssetProperties.getQualifiedName(), + egeriaDatabaseTypeName, + false, + false); + + setOwner(atlasDatabaseEntity, egeriaDatabaseGUID); + + + return egeriaDatabaseGUID; + } + } + + return null; + } + + + /** + * Update the properties of an open metadata database with the current properties from Apache Atlas. + * + * @param atlasDatabaseEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected void updateAtlasDatabaseInEgeria(AtlasEntityWithExtInfo atlasDatabaseEntity, + String egeriaDatabaseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateAtlasDatabaseInEgeria"; + + if (atlasDatabaseEntity != null) + { + AtlasEntity atlasEntity = atlasDatabaseEntity.getEntity(); + DataAssetElement dataAssetElement = dataAssetExchangeService.getDataAssetByGUID(egeriaDatabaseGUID, null); + + if (atlasEntity != null) + { + if (this.egeriaUpdateRequired(egeriaDatabaseGUID, + egeriaDatabaseTypeName, + dataAssetElement, + atlasEntity)) + { + DataAssetProperties dataAssetProperties = this.getEgeriaDatabaseProperties(atlasEntity, egeriaDatabaseTypeName); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaDatabaseTypeName, + egeriaDatabaseGUID)); + + dataAssetExchangeService.updateDataAsset(egeriaDatabaseGUID, atlasEntity.getGuid(), false, dataAssetProperties, null); + } + } + } + } + + + /** + * Allow a subclass to attach additional information to the database. + * + * @param atlasDatabaseEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + @SuppressWarnings(value = "unused") + protected void augmentAtlasDatabaseInEgeria(AtlasEntityWithExtInfo atlasDatabaseEntity, + String egeriaDatabaseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + // Optionally implemented by subclass + } + + + /** + * Copy the contents of the Atlas database table entity into open metadata. + * + * @param atlasDatabaseTableEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseGUID unique identifier of the database in open metadata + * + * @return unique identifier of the equivalent element in open metadata (egeriaDatabaseTableGUID) + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private String syncAtlasDatabaseTable(AtlasEntityWithExtInfo atlasDatabaseTableEntity, + String egeriaDatabaseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "syncAtlasDatabaseTable"; + + if ((atlasDatabaseTableEntity != null) && (atlasDatabaseTableEntity.getEntity() != null)) + { + String egeriaDatabaseTableGUID = super.getEgeriaGUID(atlasDatabaseTableEntity); + + if (egeriaDatabaseTableGUID == null) + { + /* + * No record of a previous synchronization with the open metadata ecosystem. + */ + egeriaDatabaseTableGUID = createAtlasDatabaseTableInEgeria(atlasDatabaseTableEntity, egeriaDatabaseGUID); + } + else + { + try + { + /* + * Does the matching entity in the open metadata ecosystem still exist. Notice effective time is set to null + * to make sure that this entity is found no matter what its effectivity dates are set to. + */ + dataAssetExchangeService.getDataAssetByGUID(egeriaDatabaseTableGUID, null); + + /* + * The Egeria equivalent is still in place. + */ + updateAtlasDatabaseTableInEgeria(atlasDatabaseTableEntity, egeriaDatabaseTableGUID); + } + catch (InvalidParameterException notKnown) + { + /* + * The open metadata ecosystem entity has been deleted - put it back. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseTableTypeName, + egeriaDatabaseTableGUID, + atlasDatabaseTableEntity.getEntity().getGuid())); + + removeEgeriaGUID(atlasDatabaseTableEntity); + + egeriaDatabaseTableGUID = createAtlasDatabaseTableInEgeria(atlasDatabaseTableEntity, egeriaDatabaseGUID); + } + } + + augmentAtlasDatabaseTableInEgeria(atlasDatabaseTableEntity, egeriaDatabaseTableGUID); + + return egeriaDatabaseTableGUID; + } + + return null; + } + + + /** + * Create the database table in the open metadata ecosystem. + * + * @param atlasDatabaseTableEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseGUID unique identifier of the database in the open metadata ecosystem + * + * @return unique identifier of the database entity in open metadata + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected String createAtlasDatabaseTableInEgeria(AtlasEntityWithExtInfo atlasDatabaseTableEntity, + String egeriaDatabaseGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAtlasDatabaseTableInEgeria"; + + if (atlasDatabaseTableEntity != null) + { + AtlasEntity atlasEntity = atlasDatabaseTableEntity.getEntity(); + + if (atlasEntity != null) + { + String egeriaDatabaseSchemaTypeGUID = this.getEgeriaDatabaseSchemaType(egeriaDatabaseGUID); + + if (egeriaDatabaseSchemaTypeGUID != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + SchemaAttributeProperties schemaAttributeProperties = getEgeriaDatabaseTableProperties(atlasEntity, + egeriaDatabaseTableTypeName, + egeriaDatabaseTableTypeTypeName); + + String egeriaDatabaseTableGUID = dataAssetExchangeService.createSchemaAttribute(true, + egeriaDatabaseSchemaTypeGUID, + externalIdentifierProperties, + schemaAttributeProperties, + null); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseTableTypeName, + egeriaDatabaseTableGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaDatabaseGUID, + schemaAttributeProperties.getQualifiedName(), + egeriaDatabaseTableTypeName, + false, + false); + + setOwner(atlasDatabaseTableEntity, egeriaDatabaseTableGUID); + + return egeriaDatabaseTableGUID; + } + } + } + + return null; + } + + + /** + * Update the properties of an open metadata database table with the current properties from Apache Atlas. + * + * @param atlasDatabaseTableEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseTableGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected void updateAtlasDatabaseTableInEgeria(AtlasEntityWithExtInfo atlasDatabaseTableEntity, + String egeriaDatabaseTableGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateAtlasDatabaseTableInEgeria"; + + if (atlasDatabaseTableEntity != null) + { + AtlasEntity atlasEntity = atlasDatabaseTableEntity.getEntity(); + + DataAssetElement dataAssetElement = dataAssetExchangeService.getDataAssetByGUID(egeriaDatabaseTableGUID, + null); + + if (atlasEntity != null) + { + if (this.egeriaUpdateRequired(egeriaDatabaseTableGUID, + egeriaDatabaseTableTypeName, + dataAssetElement, + atlasEntity)) + { + SchemaAttributeProperties databaseTableProperties = this.getEgeriaDatabaseTableProperties(atlasEntity, + egeriaDatabaseTableTypeName, + egeriaDatabaseTableTypeTypeName); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaDatabaseTableTypeName, + egeriaDatabaseTableGUID)); + + dataAssetExchangeService.updateSchemaAttribute(egeriaDatabaseTableGUID, + atlasEntity.getGuid(), + false, + databaseTableProperties, + null); + } + } + } + } + + + /** + * Allow a subclass to attach additional information to the database table. + * + * @param atlasDatabaseTableEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseTableGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + @SuppressWarnings(value = "unused") + protected void augmentAtlasDatabaseTableInEgeria(AtlasEntityWithExtInfo atlasDatabaseTableEntity, + String egeriaDatabaseTableGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + // Optionally implemented by subclass + } + + + /** + * Retrieve the tables attached to the database in Egeria and check that each one is still defined in Apache Atlas. + * + * @param egeriaDatabaseGUID unique identifier of the database in the open metadata ecosystem + * @param atlasDatabaseTables details of the tables that are linked ot the database in Apache Atlas + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private void checkForAdditionalEgeriaTables(String egeriaDatabaseGUID, + List atlasDatabaseTables) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "checkForAdditionalEgeriaTables"; + + if ((atlasDatabaseTables != null) && (! atlasDatabaseTables.isEmpty())) + { + String egeriaDatabaseSchemaTypeGUID = this.getEgeriaDatabaseSchemaType(egeriaDatabaseGUID); + + if (egeriaDatabaseSchemaTypeGUID != null) + { + List validAtlasGUIDs = getValidAtlasGUIDs(atlasDatabaseTables); + + /* + * Retrieve the tables catalogued in Egeria. This is turned into an Open Metadata DeployedDatabaseSchema. + */ + int startFrom = 0; + int pageSize = myContext.getMaxPageSize(); + + List egeriaDatabaseTables = dataAssetExchangeService.getNestedAttributes(egeriaDatabaseSchemaTypeGUID, + startFrom, + pageSize, + null); + + while (egeriaDatabaseTables != null) + { + for (SchemaAttributeElement egeriaDatabaseTable : egeriaDatabaseTables) + { + String atlasDatabaseTableGUID = super.getAtlasGUID(egeriaDatabaseTable); + + if (! validAtlasGUIDs.contains(atlasDatabaseTableGUID)) + { + /* + * The table in Egeria is not matched with an Atlas equivalent. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.DELETING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseTableTypeName, + egeriaDatabaseTable.getElementHeader().getGUID(), + atlasDatabaseTableGUID)); + + dataAssetExchangeService.removeDataAsset(egeriaDatabaseTable.getElementHeader().getGUID(), + atlasDatabaseTableGUID, + null); + } + } + + startFrom = startFrom + pageSize; + egeriaDatabaseTables = dataAssetExchangeService.getNestedAttributes(egeriaDatabaseSchemaTypeGUID, + startFrom, + pageSize, + null); + } + } + } + } + + + /** + * Copy the contents of the Atlas database column entity into open metadata. + * + * @param atlasDatabaseColumnEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseTableGUID unique identifier of the database table to connect column to in open metadata. + * + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private void syncAtlasDatabaseColumn(AtlasEntityWithExtInfo atlasDatabaseColumnEntity, + String egeriaDatabaseTableGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "syncAtlasDatabaseColumn"; + + if (atlasDatabaseColumnEntity != null) + { + String egeriaDatabaseColumnGUID = super.getEgeriaGUID(atlasDatabaseColumnEntity); + + if (egeriaDatabaseColumnGUID == null) + { + /* + * No record of a previous synchronization with the open metadata ecosystem. + */ + egeriaDatabaseColumnGUID = createAtlasDatabaseColumnInEgeria(atlasDatabaseColumnEntity, egeriaDatabaseTableGUID); + } + else + { + try + { + /* + * Does the matching entity in the open metadata ecosystem still exist. Notice effective time is set to null + * to make sure that this entity is found no matter what its effectivity dates are set to. + */ + SchemaAttributeElement egeriaDatabaseColumn = dataAssetExchangeService.getSchemaAttributeByGUID(egeriaDatabaseColumnGUID, null); + + /* + * The Egeria equivalent is still in place. + */ + updateAtlasDatabaseColumnInEgeria(atlasDatabaseColumnEntity, egeriaDatabaseColumnGUID, egeriaDatabaseColumn); + } + catch (InvalidParameterException notKnown) + { + /* + * The open metadata ecosystem entity has been deleted - put it back. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.REPLACING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumnGUID, + atlasDatabaseColumnEntity.getEntity().getGuid())); + removeEgeriaGUID(atlasDatabaseColumnEntity); + egeriaDatabaseColumnGUID = createAtlasDatabaseColumnInEgeria(atlasDatabaseColumnEntity, egeriaDatabaseTableGUID); + } + } + + augmentAtlasDatabaseColumnInEgeria(atlasDatabaseColumnEntity, egeriaDatabaseColumnGUID); + } + } + + + /** + * Create the database in the open metadata ecosystem. + * + * @param atlasDatabaseColumnEntity entity retrieved from Apache Atlas + * + * @return unique identifier of the database entity in open metadata + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected String createAtlasDatabaseColumnInEgeria(AtlasEntityWithExtInfo atlasDatabaseColumnEntity, + String egeriaDatabaseTableGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "createAtlasDatabaseColumnInEgeria"; + + if ((atlasDatabaseColumnEntity != null) && (egeriaDatabaseTableGUID != null)) + { + AtlasEntity atlasEntity = atlasDatabaseColumnEntity.getEntity(); + + if (atlasEntity != null) + { + ExternalIdentifierProperties externalIdentifierProperties = this.getExternalIdentifier(atlasEntity.getGuid(), + atlasEntity.getTypeName(), + atlasEntity.getCreatedBy(), + atlasEntity.getCreateTime(), + atlasEntity.getUpdatedBy(), + atlasEntity.getUpdateTime(), + atlasEntity.getVersion(), + SynchronizationDirection.FROM_THIRD_PARTY); + + SchemaAttributeProperties schemaAttributeProperties = getEgeriaDatabaseColumnProperties(atlasEntity, + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumnTypeTypeName); + + String egeriaDatabaseColumnGUID = dataAssetExchangeService.createSchemaAttribute(true, + egeriaDatabaseTableGUID, + externalIdentifierProperties, + schemaAttributeProperties, + null); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.CREATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumnGUID, + atlasEntity.getTypeName(), + atlasEntity.getGuid())); + + saveEgeriaGUIDInAtlas(atlasEntity.getGuid(), + egeriaDatabaseColumnGUID, + schemaAttributeProperties.getQualifiedName(), + egeriaDatabaseColumnTypeName, + false, + false); + setOwner(atlasDatabaseColumnEntity, egeriaDatabaseColumnGUID); + + return egeriaDatabaseColumnGUID; + } + } + + return null; + } + + + /** + * Update the properties of an open metadata database with the current properties from Apache Atlas. + * + * @param atlasDatabaseColumnEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseColumnGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @param egeriaDatabaseColumn retrieved entity from the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + protected void updateAtlasDatabaseColumnInEgeria(AtlasEntityWithExtInfo atlasDatabaseColumnEntity, + String egeriaDatabaseColumnGUID, + SchemaAttributeElement egeriaDatabaseColumn) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "updateAtlasDatabaseColumnInEgeria"; + + if (atlasDatabaseColumnEntity != null) + { + AtlasEntity atlasEntity = atlasDatabaseColumnEntity.getEntity(); + + if (atlasEntity != null) + { + if (this.egeriaUpdateRequired(egeriaDatabaseColumnGUID, + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumn, + atlasEntity)) + { + SchemaAttributeProperties databaseColumnProperties = this.getEgeriaDatabaseColumnProperties(atlasEntity, + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumnTypeTypeName); + + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.UPDATING_EGERIA_ENTITY.getMessageDefinition(connectorName, + atlasEntity.getTypeName(), + atlasEntity.getGuid(), + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumnGUID)); + + dataAssetExchangeService.updateSchemaAttribute(egeriaDatabaseColumnGUID, + atlasEntity.getGuid(), + false, + databaseColumnProperties, + null); + } + } + } + } + + + /** + * Allow a subclass to attach additional information to the database column. + * + * @param atlasDatabaseColumnEntity entity retrieved from Apache Atlas + * @param egeriaDatabaseColumnGUID unique identifier of the equivalent entity in the open metadata ecosystem + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + @SuppressWarnings(value = "unused") + protected void augmentAtlasDatabaseColumnInEgeria(AtlasEntityWithExtInfo atlasDatabaseColumnEntity, + String egeriaDatabaseColumnGUID) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + // Optionally implemented by subclass + } + + + /** + * Retrieve the columns attached to the database table in Egeria and check that each one is still defined in Apache Atlas. + * + * @param egeriaDatabaseTableGUID unique identifier of the database table in the open metadata ecosystem + * @param atlasDatabaseColumns details of the tables that are linked ot the database in Apache Atlas + * @throws InvalidParameterException invalid parameter - probably a logic error + * @throws UserNotAuthorizedException security problem + * @throws PropertyServerException unable to communicate with Egeria + */ + private void checkForAdditionalEgeriaColumns(String egeriaDatabaseTableGUID, + List atlasDatabaseColumns) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "checkForAdditionalEgeriaColumns"; + + if ((atlasDatabaseColumns != null) && (! atlasDatabaseColumns.isEmpty())) + { + if (egeriaDatabaseTableGUID != null) + { + List validAtlasGUIDs = getValidAtlasGUIDs(atlasDatabaseColumns); + + /* + * Retrieve the columns catalogued in Egeria. + */ + int startFrom = 0; + int pageSize = myContext.getMaxPageSize(); + + List egeriaDatabaseColumns = dataAssetExchangeService.getNestedAttributes(egeriaDatabaseTableGUID, + startFrom, + pageSize, + null); + + while (egeriaDatabaseColumns != null) + { + for (SchemaAttributeElement egeriaDatabaseColumn : egeriaDatabaseColumns) + { + String atlasDatabaseColumnGUID = super.getAtlasGUID(egeriaDatabaseColumn); + + if (! validAtlasGUIDs.contains(atlasDatabaseColumnGUID)) + { + /* + * The table in Egeria is not matched with an Atlas equivalent. + */ + auditLog.logMessage(methodName, + ApacheAtlasAuditCode.DELETING_EGERIA_ENTITY.getMessageDefinition(connectorName, + egeriaDatabaseColumnTypeName, + egeriaDatabaseColumn.getElementHeader().getGUID(), + atlasDatabaseColumnGUID)); + + dataAssetExchangeService.removeDataAsset(egeriaDatabaseColumn.getElementHeader().getGUID(), + atlasDatabaseColumnGUID, + null); + } + } + + startFrom = startFrom + pageSize; + egeriaDatabaseColumns = dataAssetExchangeService.getNestedAttributes(egeriaDatabaseTableGUID, + startFrom, + pageSize, + null); + } + } + } + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected abstract DataAssetProperties getEgeriaDatabaseProperties(AtlasEntity atlasEntity, + String egeriaTypeName); + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaSchemaAttributeTypeName name of the type used in the open metadata ecosystem + * @param egeriaSchemaTypeTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected abstract SchemaAttributeProperties getEgeriaDatabaseTableProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName); + + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaSchemaAttributeTypeName name of the type used in the open metadata ecosystem + * @param egeriaSchemaTypeTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected abstract SchemaAttributeProperties getEgeriaDatabaseColumnProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName); +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/RDBMSIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/RDBMSIntegrationModule.java new file mode 100644 index 00000000000..b2b54f3ad29 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/RDBMSIntegrationModule.java @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + + +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataAssetProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SchemaAttributeProperties; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.ApacheAtlasRESTClient; +import org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties.AtlasEntity; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorContext; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * RDBMSIntegrationModule manages the cataloguing of RDBMS entities stored in Apache Atlas into the open metadata ecosystem. + */ +public class RDBMSIntegrationModule extends DatabaseIntegrationModuleBase +{ + private static final String rdbmsModuleName = "RDBMS Integration Module"; + + private static final String rdbmsDatabaseTypeName = "rdbms_db"; + private static final String rdbmsDatabaseTablesPropertyName = "tables"; + private static final String rdbmsDatabaseTableTypeName = "rdbms_table"; + private static final String rdbmsDatabaseColumnsPropertyName = "columns"; + private static final String rdbmsDatabaseColumnTypeName = "rdbms_column"; + + private static final String rdbmsInstancePropertyName = "instance"; + private static final String egeriaPathTypeName = "DataFile"; + + + + /** + * Constructor for the module is supplied with the runtime context in order to operate. + * + * @param connectorName name of the connector (for messages) + * @param connectionProperties connection properties used to start the connector + * @param auditLog logging destination + * @param myContext integration context + * @param targetRootURL URL to connect to Apache Atlas + * @param atlasClient client to connect to Apache Atlas + * @param embeddedConnectors list of any embedded connectors (such as secrets connector and topic connector + * @throws UserNotAuthorizedException security problem + */ + public RDBMSIntegrationModule(String connectorName, + ConnectionProperties connectionProperties, + AuditLog auditLog, + CatalogIntegratorContext myContext, + String targetRootURL, + ApacheAtlasRESTClient atlasClient, + List embeddedConnectors) throws UserNotAuthorizedException + { + super(connectorName, + rdbmsModuleName, + rdbmsDatabaseTypeName, + rdbmsDatabaseTablesPropertyName, + rdbmsDatabaseTableTypeName, + rdbmsDatabaseColumnsPropertyName, + rdbmsDatabaseColumnTypeName, + connectionProperties, + auditLog, + myContext, + targetRootURL, + atlasClient, + embeddedConnectors); + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected DataAssetProperties getEgeriaDatabaseProperties(AtlasEntity atlasEntity, + String egeriaTypeName) + { + DataAssetProperties dataAssetProperties = super.getDataAssetProperties(atlasEntity, egeriaTypeName); + + dataAssetProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasAssetProperties)); + + return dataAssetProperties; + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaSchemaAttributeTypeName name of the type used in the open metadata ecosystem + * @param egeriaSchemaTypeTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected SchemaAttributeProperties getEgeriaDatabaseTableProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName) + { + SchemaAttributeProperties schemaAttributeProperties = super.getSchemaAttributeProperties(atlasEntity, + egeriaSchemaAttributeTypeName, + egeriaSchemaTypeTypeName); + + schemaAttributeProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasAssetProperties)); + + return schemaAttributeProperties; + } + + + /** + * Map the properties from the entity retrieved from Apache Atlas to the Egeria properties for the open metadata entity. + * + * @param atlasEntity retrieve entity from Apache Atlas + * @param egeriaSchemaAttributeTypeName name of the type used in the open metadata ecosystem + * @param egeriaSchemaTypeTypeName name of the type used in the open metadata ecosystem + * @return properties to pass to Egeria + */ + protected SchemaAttributeProperties getEgeriaDatabaseColumnProperties(AtlasEntity atlasEntity, + String egeriaSchemaAttributeTypeName, + String egeriaSchemaTypeTypeName) + { + final String typeNamePropertyName = "data_type"; + + /* + * Begin by mapping the common DataSet properties. + */ + SchemaAttributeProperties schemaAttributeProperties = super.getSchemaAttributeProperties(atlasEntity, + egeriaSchemaAttributeTypeName, + egeriaSchemaTypeTypeName); + Map attributes = atlasEntity.getAttributes(); + + String dataTypeName = getAtlasStringProperty(attributes, typeNamePropertyName); + + if (dataTypeName == null) + { + dataTypeName = "string"; + } + + Map extendedProperties = new HashMap<>(); + + extendedProperties.put("dataType", dataTypeName); + schemaAttributeProperties.getSchemaType().setExtendedProperties(extendedProperties); + + List atlasColumnPropertyNames = new ArrayList<>(atlasAssetProperties); + + atlasColumnPropertyNames.add(typeNamePropertyName); + schemaAttributeProperties.setAdditionalProperties(addRemainingPropertiesToAdditionalProperties(atlasEntity.getAttributes(), + atlasColumnPropertyNames)); + + return schemaAttributeProperties; + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/RegisteredIntegrationModule.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/RegisteredIntegrationModule.java new file mode 100644 index 00000000000..4fde266bb64 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/RegisteredIntegrationModule.java @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; + +import org.odpi.openmetadata.accessservices.assetmanager.events.AssetManagerOutTopicEvent; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; + +import java.util.List; + +/** + * RegisteredIntegrationModule defines the interface for an integration module that wants to be called to synchronize assets. + */ +public interface RegisteredIntegrationModule +{ + /** + * Return the list of entity types that this module is maintaining. + * + * @return list of type names + */ + List getSupportedEntityTypes(); + + + /** + * Return the list of open metadata types that this module supports events for. + * + * @return list of types + */ + List getListenForTypes(); + + + /** + * Return the name of this module for messages. + * + * @return module name + */ + public String getModuleName(); + + + /** + * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. + * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration + * as well as any external REST API calls to explicitly refresh the connector. + * + * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. + */ + void refresh() throws ConnectorCheckedException; + + + /** + * Process an event that was published by the Asset Manager OMAS. The listener is only registered if metadata is flowing + * from the open metadata ecosystem to Apache Atlas. + * + * @param event event object + */ + void processEvent(AssetManagerOutTopicEvent event); +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/package-info.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/package-info.java new file mode 100644 index 00000000000..66a3857442e --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/modules/package-info.java @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +/** + * The Apache Atlas Integration Modules specialize in exchanging metadata of a particular type between Apache Atlas and the open metadata ecosystem. + */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.modules; \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityExtInfo.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityExtInfo.java new file mode 100644 index 00000000000..eb56ba55670 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityExtInfo.java @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import java.util.Map; + +/** + * AtlasEntityExtInfo contains a map of GUIDs to entity instances. + */ +public class AtlasEntityExtInfo +{ + private Map referredEntities; + + + public AtlasEntityExtInfo() + { + } + + + public Map getReferredEntities() + { + return referredEntities; + } + + + public void setReferredEntities( + Map referredEntities) + { + this.referredEntities = referredEntities; + } + + + @Override + public String toString() + { + return "AtlasEntityExtInfo{" + + "referredEntities=" + referredEntities + + '}'; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityMutationResponse.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityMutationResponse.java new file mode 100644 index 00000000000..f20deb27325 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityMutationResponse.java @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import java.util.List; +import java.util.Map; + +/** + * AtlasEntityMutationResponse returns information of new/updated entities + */ +public class AtlasEntityMutationResponse +{ + private Map> mutatedEntities; + private Map guidAssignments; + + + public AtlasEntityMutationResponse() + { + } + + + public Map> getMutatedEntities() + { + return mutatedEntities; + } + + + public void setMutatedEntities( + Map> mutatedEntities) + { + this.mutatedEntities = mutatedEntities; + } + + + public Map getGuidAssignments() + { + return guidAssignments; + } + + + public void setGuidAssignments(Map guidAssignments) + { + this.guidAssignments = guidAssignments; + } + + + @Override + public String toString() + { + return "AtlasEntityMutationResponse{" + + "mutatedEntities=" + mutatedEntities + + ", guidAssignments=" + guidAssignments + + '}'; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityOperation.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityOperation.java new file mode 100644 index 00000000000..ce2e9d1c5b5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityOperation.java @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +/** + * AtlasEntityOperation describes the change to a collection of entities. + */ +public enum AtlasEntityOperation +{ + /** + * The entity has been created. + */ + CREATE, + + /** + * The entity has been update. + */ + UPDATE, + + /** + * The entity has been partially updated. + */ + PARTIAL_UPDATE, + + /** + * The entity has been deleted. + */ + DELETE, + + /** + * The entity has been purged. + */ + PURGE +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityWithExtInfo.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityWithExtInfo.java new file mode 100644 index 00000000000..4c0ea39a196 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityWithExtInfo.java @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +/** + * AtlasEntityWithExtInfo describes an entity with additional entity elements. + */ +public class AtlasEntityWithExtInfo extends AtlasEntityExtInfo +{ + private AtlasEntity entity = null; + + + public AtlasEntityWithExtInfo() + { + } + + + public AtlasEntity getEntity() + { + return entity; + } + + + public void setEntity(AtlasEntity entity) + { + this.entity = entity; + } + + + @Override + public String toString() + { + return "AtlasEntityWithExtInfo{" + + "entity=" + entity + + ", referredEntities=" + getReferredEntities() + + '}'; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationship.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationship.java index fcf94cd8425..9889daca920 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationship.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationship.java @@ -18,7 +18,7 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class AtlasRelationship +public class AtlasRelationship extends AtlasStruct { public static final String KEY_GUID = "guid"; public static final String KEY_HOME_ID = "homeId"; diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeDefBase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeDefBase.java index 367d021b3c2..b9824c8c437 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeDefBase.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeDefBase.java @@ -91,8 +91,6 @@ public class AtlasTypeDefBase ATLAS_TYPE_OBJECT_ID, }; - public static final String EGERIA_SERVICE_TYPE = "open_metadata_ecosystem"; - private AtlasTypeCategory category = null; private String guid = null; private String createdBy = null; diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/package-info.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/package-info.java new file mode 100644 index 00000000000..40f64cc6cf7 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/package-info.java @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +/** + * These are the beans used on the Apache Atlas REST API calls. + */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/README.md b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/README.md new file mode 100644 index 00000000000..41a0346d8e5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/README.md @@ -0,0 +1,88 @@ + + + +# JDBC Integration Connector + +Catalogs a database via JDBC, extracting catalogs, schemas and the following table types: "TABLE", "VIEW", "FOREIGN TABLE" and "MATERIALIZED VIEW". +It will mark the primary key columns and extract the foreign key relationships. + + +### Configuration + +For more details regarding bellow request, visit [Egeria documentation site](https://egeria-project.org/guides/admin/servers/configuring-an-integration-daemon/#configure-the-integration-services) + +In addition, the integration connector uses an EmbeddedConnection in order to make use of the [JDBC resource connector](https://egeria-project.org/connectors/#databases), which keeps the connection details to target database +``` +POST {{baseURL}}/open-metadata/admin-services/users/{{user}}/servers/{{server}}/integration-services/{{integrationServiceURLMarker}} +``` +Body +``` +{ + "class": "IntegrationServiceRequestBody", + "omagserverPlatformRootURL": "", + "omagserverName": "", + "integrationConnectorConfigs":[ + { + "class": "IntegrationConnectorConfig", + "connectorName": "", + "connection":{ + "class": "VirtualConnection", + "connectorType" : { + "class": "ConnectorType", + "connectorProviderClassName": "org.odpi.openmetadata.adapters.connectors.integration.jdbc.JDBCIntegrationConnectorProvider" + }, + "embeddedConnections":[ + { + "class" : "EmbeddedConnection", + "embeddedConnection" : { + "class" : "Connection", + "userId" : "", + "clearPassword" : "", + "connectorType" : { + "class": "ConnectorType", + "connectorProviderClassName": "org.odpi.openmetadata.adapters.connectors.resource.jdbc.JDBCResourceConnectorProvider" + }, + "endpoint":{ + "class": "Endpoint", + "address" : "" + } + } + } + ], + "configurationProperties": { + "includeSchemaNames": [], + "excludeSchemaNames": [], + "includeTableNames": [], + "excludeTableNames": [], + "includeViewNames": [], + "excludeViewNames": [], + "includeColumnNames": [], + "excludeColumnNames": [] + } + }, + "metadataSourceQualifiedName": "Source", + "refreshTimeInterval": "60", + "usesBlockingCalls": "false", + "permittedSynchronization": "FROM_THIRD_PARTY" + } + ] +} +``` + +**access-service-omag-url** - url of omag server that hosts the paired access service + +**omas-server-name** - name of paired access server + +**connector-name** - this connectors name + +**user** - database user + +**password** - database password + +**jdbc-format-database-address** - database address + +**include/exclude** properties - control which schemas, tables, views and columns, respectively, are imported +if include is set, then the import is restricted to specified entities; +if exclude is set, the import will ignore specified entities; +if both are set, the import will take into account only the property include; + diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/build.gradle b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/build.gradle new file mode 100644 index 00000000000..2279c6cfb3c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/build.gradle @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Contributors to the ODPi Egeria project. + */ + +// Artifact names are taken from the directory by default, set in settings.gradle to override +// The 'name' for the maven artifact, and description are set here + +description = 'Egeria integration connector that uses Generic JDBC resource connector to access the database metadata' + +dependencies { + compileOnly 'org.slf4j:slf4j-api' + compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework') + compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework') + compileOnly project(':open-metadata-implementation:frameworks:governance-action-framework') + compileOnly project(':open-metadata-implementation:frameworks:open-integration-framework') + compileOnly project(':open-metadata-implementation:access-services:data-manager:data-manager-api') + compileOnly project(':open-metadata-implementation:integration-services:database-integrator:database-integrator-api') + compileOnly project(':open-metadata-implementation:repository-services:repository-services-apis') + compileOnly project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector') + + compileOnly 'org.apache.commons:commons-lang3' + compileOnly 'org.apache.commons:commons-collections4' + compileOnly 'com.fasterxml.jackson.core:jackson-annotations' +} + diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/JDBCIntegrationConnector.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/JDBCIntegrationConnector.java new file mode 100644 index 00000000000..0943b2640fc --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/JDBCIntegrationConnector.java @@ -0,0 +1,185 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadataTransfer; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.customization.TransferCustomizations; +import org.odpi.openmetadata.adapters.connectors.resource.jdbc.JDBCResourceConnector; +import org.odpi.openmetadata.frameworks.connectors.Connector; +import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; +import org.odpi.openmetadata.integrationservices.database.connector.DatabaseIntegratorConnector; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_ON_CONTEXT_RETRIEVAL; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXITING_ON_COMPLETE; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXITING_ON_CONNECTION_FAIL; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXITING_ON_INTEGRATION_CONTEXT_FAIL; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXITING_ON_METADATA_TEST; + +/** + * JDBCIntegrationConnector supports the cataloguing of database schema via the JDBC interface. + */ +public class JDBCIntegrationConnector extends DatabaseIntegratorConnector +{ + + private JDBCResourceConnector JDBCResourceConnector; + + /** + * 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 + */ + @Override + public void initializeEmbeddedConnectors(List embeddedConnectors) + { + super.initializeEmbeddedConnectors(embeddedConnectors); + + + JDBCResourceConnector = (JDBCResourceConnector) embeddedConnectors.get(0); + } + + + /** + * Requests that the connector does a comparison of the metadata in the third party technology and open metadata repositories. + * Refresh is called when the integration connector first starts and then at intervals defined in the connector's configuration + * as well as any external REST API calls to explicitly refresh the connector. + */ + @Override + public void refresh() + { + String methodName = "JDBCIntegrationConnector.refresh"; + String exitAction = "Exiting " + methodName; + + Connection connection = connect(); + if (connection == null) + { + auditLog.logMessage(exitAction, EXITING_ON_CONNECTION_FAIL.getMessageDefinition(methodName)); + return; + } + DatabaseMetaData databaseMetaData = getDatabaseMetadata(connection); + if (databaseMetaData == null) + { + auditLog.logMessage(exitAction, EXITING_ON_CONNECTION_FAIL.getMessageDefinition(methodName)); + close(connection); + return; + } + if (!test(databaseMetaData)) + { + auditLog.logMessage(exitAction, EXITING_ON_METADATA_TEST.getMessageDefinition(methodName)); + close(connection); + return; + } + + JdbcMetadataTransfer jdbcMetadataTransfer = createJdbcMetadataTransfer(databaseMetaData); + if (jdbcMetadataTransfer == null) + { + auditLog.logMessage(exitAction, EXITING_ON_INTEGRATION_CONTEXT_FAIL.getMessageDefinition(methodName)); + close(connection); + return; + } + + jdbcMetadataTransfer.execute(); + auditLog.logMessage(exitAction, EXITING_ON_COMPLETE.getMessageDefinition(methodName)); + close(connection); + } + + + private Connection connect() + { + String methodName = "connect"; + try + { + return JDBCResourceConnector.asDataSource().getConnection(); + } + catch (SQLException sqlException) + { + auditLog.logException("Connecting to target database server", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + + return null; + } + + public void close(Connection connection) + { + String methodName = "close"; + try + { + if (!connection.isClosed()) + { + connection.close(); + } + } + catch (SQLException sqlException) + { + auditLog.logException("Closing connection to database server", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + } + + private DatabaseMetaData getDatabaseMetadata(Connection connection) + { + String methodName = "getDatabaseMetadata"; + + try + { + return connection.getMetaData(); + } + catch (SQLException sqlException) + { + auditLog.logException("Extracting database metadata", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + + return null; + } + + private boolean test(DatabaseMetaData databaseMetaData) + { + String methodName = "test"; + try + { + databaseMetaData.getCatalogs(); + return true; + } + catch (SQLException sqlException) + { + auditLog.logException("Extracting database metadata", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return false; + } + + private JdbcMetadataTransfer createJdbcMetadataTransfer(DatabaseMetaData databaseMetaData){ + String methodName = "createJdbcMetadataTransfer"; + try + { + Map configurationProperties = Optional.ofNullable(this.getConnection().getConfigurationProperties()).orElse(new HashMap<>()); + TransferCustomizations transferCustomizations = new TransferCustomizations(configurationProperties); + String connectorTypeQualifiedName = JDBCResourceConnector.getConnection().getConnectorType().getConnectorProviderClassName(); + String address = JDBCResourceConnector.getConnection().getEndpoint().getAddress(); + String catalog = (String)configurationProperties.get("catalog"); + return new JdbcMetadataTransfer(new JdbcMetadata(databaseMetaData), this.getContext(), address, + connectorTypeQualifiedName, catalog, transferCustomizations, auditLog); + } + catch (ConnectorCheckedException e) + { + auditLog.logException("Extracting integration context", + EXCEPTION_ON_CONTEXT_RETRIEVAL.getMessageDefinition(methodName), e); + } + return null; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/JDBCIntegrationConnectorProvider.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/JDBCIntegrationConnectorProvider.java new file mode 100644 index 00000000000..41f76c45fa1 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/JDBCIntegrationConnectorProvider.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.customization.TransferCustomizations; +import org.odpi.openmetadata.frameworks.connectors.ConnectorProviderBase; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType; + +import java.util.ArrayList; +import java.util.List; + +public class JDBCIntegrationConnectorProvider extends ConnectorProviderBase { + + static final String CONNECTOR_TYPE_GUID = "49cd6772-1efd-40bb-a1d9-cc9460962ff6"; + static final String CONNECTOR_TYPE_NAME = "JDBC Database Connector"; + static final String CONNECTOR_TYPE_DESCRIPTION = "Connector supports JDBC Database instance"; + + /** + * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific + * store implementation. + */ + public JDBCIntegrationConnectorProvider(){ + super.setConnectorClassName(JDBCIntegrationConnector.class.getName()); + + ConnectorType connectorType = new ConnectorType(); + connectorType.setType(ConnectorType.getConnectorTypeType()); + connectorType.setGUID(CONNECTOR_TYPE_GUID); + connectorType.setQualifiedName(CONNECTOR_TYPE_NAME); + connectorType.setDisplayName(CONNECTOR_TYPE_NAME); + connectorType.setDescription(CONNECTOR_TYPE_DESCRIPTION); + connectorType.setConnectorProviderClassName(this.getClass().getName()); + + List recognizedConfigurationProperties = new ArrayList<>(); + recognizedConfigurationProperties.add(TransferCustomizations.INCLUDE_SCHEMA_NAMES); + recognizedConfigurationProperties.add(TransferCustomizations.EXCLUDE_SCHEMA_NAMES); + recognizedConfigurationProperties.add(TransferCustomizations.INCLUDE_TABLE_NAMES); + recognizedConfigurationProperties.add(TransferCustomizations.EXCLUDE_TABLE_NAMES); + recognizedConfigurationProperties.add(TransferCustomizations.INCLUDE_COLUMN_NAMES); + recognizedConfigurationProperties.add(TransferCustomizations.EXCLUDE_COLUMN_NAMES); + connectorType.setRecognizedConfigurationProperties(recognizedConfigurationProperties); + + super.connectorTypeBean = connectorType; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/ffdc/JDBCIntegrationConnectorAuditCode.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/ffdc/JDBCIntegrationConnectorAuditCode.java new file mode 100644 index 00000000000..9039ab78c34 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/ffdc/JDBCIntegrationConnectorAuditCode.java @@ -0,0 +1,137 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc; + +import org.odpi.openmetadata.frameworks.auditlog.messagesets.AuditLogMessageDefinition; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.AuditLogMessageSet; +import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLogRecordSeverity; + + +/** + * The JDBCIntegrationConnectorAuditCode is used to define the message content for the Audit Log. + * The 5 fields in the enum are: + *
    + *
  • Log Message Id - to uniquely identify the message
  • + *
  • Severity - is this an event, decision, action, error or exception
  • + *
  • Log Message Text - includes placeholder to allow additional values to be captured
  • + *
  • SystemAction - describes the result of the situation
  • + *
  • UserAction - describes how a user should correct the situation
  • + *
+ */ +public enum JDBCIntegrationConnectorAuditCode implements AuditLogMessageSet +{ + + EXITING_ON_CONNECTION_FAIL("JDBC-INTEGRATION-CONNECTOR-0001", + OMRSAuditLogRecordSeverity.INFO, + "Exiting from method {0} as a result of a failed connection", + "Stopping execution", + "Investigate log for additional details"), + EXITING_ON_COMPLETE("JDBC-INTEGRATION-CONNECTOR-0002", + OMRSAuditLogRecordSeverity.INFO, + "Execution of method {0} is complete", + "Stopping execution", + "No user actions necessary"), + EXITING_ON_INTEGRATION_CONTEXT_FAIL("JDBC-INTEGRATION-CONNECTOR-0004", + OMRSAuditLogRecordSeverity.INFO, + "Exiting from method {0} as a result of a failed integration context retrieval", + "Stopping execution", + "Consult logs for further details"), + EXCEPTION_READING_JDBC("JDBC-INTEGRATION-CONNECTOR-0005", + OMRSAuditLogRecordSeverity.EXCEPTION, + "An SQL exception was received by method {0}. Exception message is: {1}", + "Reading JDBC", + "Take appropriate action to remedy the issue described in the exception message"), + EXCEPTION_WRITING_OMAS("JDBC-INTEGRATION-CONNECTOR-0006", + OMRSAuditLogRecordSeverity.EXCEPTION, + "An exception was received by method {0}. Exception message is: {1}", + "Upserting an entity into the Metadata Access Server failed.", + "Investigate OMAS availability. If it is available then contact the Egeria team for support"), + EXITING_ON_DATABASE_TRANSFER_FAIL("JDBC-INTEGRATION-CONNECTOR-0007", + OMRSAuditLogRecordSeverity.INFO, + "Exiting from method {0} as a result of a failed database transfer", + "Stopping execution", + "Consult logs for further details"), + EXCEPTION_READING_OMAS("JDBC-INTEGRATION-CONNECTOR-0008", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Error reading data from Metadata Access Server in method {0}. Possible message is {1}", + "Reading OMAS information", + "Consult logs for further details"), + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS("JDBC-INTEGRATION-CONNECTOR-0009", + OMRSAuditLogRecordSeverity.INFO, + "Metadata transfer complete for {0} in {1} seconds", + "Transferring metadata information", + "None"), + EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS("JDBC-INTEGRATION-CONNECTOR-0010", + OMRSAuditLogRecordSeverity.INFO, + "Unknown error when removing element from Metadata Access Server with guid {0} and qualified name {1}.", + "Removing element in OMAS", + "Consult logs for further details"), + EXCEPTION_ON_CONTEXT_RETRIEVAL("JDBC-INTEGRATION-CONNECTOR-0011", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Retrieving integration context failed in method {0}", + "Stopping execution", + "Take appropriate action to remedy the issue described in the exception message"), + TRANSFER_COMPLETE_FOR_DB_OBJECT("JDBC-INTEGRATION-CONNECTOR-0012", + OMRSAuditLogRecordSeverity.INFO, + "Transfer complete for {0}", + "Continue execution", + "None"), + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT("JDBC-INTEGRATION-CONNECTOR-0013", + OMRSAuditLogRecordSeverity.INFO, + "Metadata transfer skipped for following {0}: {1}", + "Continue execution", + "None"), + EXITING_ON_METADATA_TEST("JDBC-INTEGRATION-CONNECTOR-00014", + OMRSAuditLogRecordSeverity.INFO, + "Exiting from method {0} as a result of a failed metadata query test", + "Stopping execution", + "Investigate log for additional details"); + + + private final AuditLogMessageDefinition messageDefinition; + + + /** + * The constructor for JDBCIntegrationConnectorAuditCode expects to be passed one of the enumeration rows defined above. + * Example: + * JDBCIntegrationConnectorAuditCode auditCode = JDBCIntegrationConnectorAuditCode.EXCEPTION_COMMITTING_OFFSETS; + * This will expand out to the 4 parameters shown below. + * + * @param messageId unique id for the message + * @param severity severity of the message + * @param message text for the message + * @param systemAction description of the action taken by the system when the condition happened + * @param userAction instructions for resolving the situation, if any + */ + JDBCIntegrationConnectorAuditCode(String messageId, OMRSAuditLogRecordSeverity severity, String message, String systemAction, + String userAction) + { + messageDefinition = new AuditLogMessageDefinition(messageId, severity, message, systemAction, userAction); + } + + + /** + * Retrieve a message definition object for logging. This method is used when there are no message inserts. + * + * @return message definition object. + */ + @Override + public AuditLogMessageDefinition getMessageDefinition() { + return messageDefinition; + } + + + /** + * Retrieve a message definition object for logging. This method is used when there are values to be inserted into the message. + * + * @param params array of parameters (all strings). They are inserted into the message according to the numbering in the message text. + * + * @return message definition object. + */ + @Override + public AuditLogMessageDefinition getMessageDefinition(String... params) + { + messageDefinition.setMessageParameters(params); + return messageDefinition; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ColumnTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ColumnTransfer.java new file mode 100644 index 00000000000..314fa9c87e6 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ColumnTransfer.java @@ -0,0 +1,175 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseColumnProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabasePrimaryKeyProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcColumn; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcPrimaryKey; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.JDBCType; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_COMPLETE_FOR_DB_OBJECT; + +/** + * Transfers metadata of a column + */ +public class ColumnTransfer implements Function { + + private final Omas omas; + private final AuditLog auditLog; + private final List omasColumns; + private final List jdbcPrimaryKeys; + private final DatabaseTableElement omasTable; + + public ColumnTransfer(Omas omas, AuditLog auditLog, List omasColumns, + List jdbcPrimaryKeys, DatabaseTableElement omasTable) { + this.omas = omas; + this.auditLog = auditLog; + this.omasColumns = omasColumns; + this.jdbcPrimaryKeys = jdbcPrimaryKeys; + this.omasTable = omasTable; + } + + /** + * Triggers column metadata transfer + * + * @param jdbcColumn column + * + * @return column + */ + @Override + public DatabaseColumnElement apply(JdbcColumn jdbcColumn) { + DatabaseColumnProperties columnProperties = buildColumnProperties(jdbcColumn, omasTable); + + Optional omasColumn = omasColumns.stream() + .filter(dce -> dce.getDatabaseColumnProperties().getQualifiedName().equals(columnProperties.getQualifiedName())) + .findFirst(); + + if(omasColumn.isPresent()){ + removeForeignKey(omasColumn.get()); + omas.updateColumn(omasColumn.get().getElementHeader().getGUID(), columnProperties); + auditLog.logMessage("Updated column with qualified name " + columnProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("column " + columnProperties.getQualifiedName())); + + this.updateOrRemovePrimaryKey(jdbcPrimaryKeys, jdbcColumn, omasColumn.get().getElementHeader().getGUID(), omasColumn.get().getPrimaryKeyProperties()); + return omasColumn.get(); + } + Optional columnGuid = omas.createColumn(omasTable.getElementHeader().getGUID(), columnProperties); + auditLog.logMessage("Created column with qualified name " + columnProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("column " + columnProperties.getQualifiedName())); + + columnGuid.ifPresent(s -> this.updateOrRemovePrimaryKey(jdbcPrimaryKeys, jdbcColumn, s, null)); + + return null; + } + + /** + * Build column properties + * + * @param jdbcColumn column + * @param omasTable table + * + * @return properties + */ + private DatabaseColumnProperties buildColumnProperties(JdbcColumn jdbcColumn, DatabaseTableElement omasTable){ + Map additionalProperties = new HashMap<>(); + additionalProperties.put(Jdbc.JDBC_CATALOG_KEY, jdbcColumn.getTableCat()); + additionalProperties.put(Jdbc.JDBC_SCHEMA_KEY, jdbcColumn.getTableSchem()); + additionalProperties.put(Jdbc.JDBC_TABLE_KEY, jdbcColumn.getTableName()); + additionalProperties.put(Jdbc.JDBC_COLUMN_KEY, jdbcColumn.getColumnName()); + + DatabaseColumnProperties properties = new DatabaseColumnProperties(); + properties.setDisplayName(jdbcColumn.getColumnName()); + properties.setQualifiedName(omasTable.getDatabaseTableProperties().getQualifiedName() + "::" + jdbcColumn.getColumnName()); + properties.setDataType(extractDataType(jdbcColumn.getDataType())); + properties.setAdditionalProperties(additionalProperties); + + return properties; + } + + /** + * Determines data type. See {@link JDBCType} + * + * @param jdbcDataType data type + * + * @return data type or "" + */ + private String extractDataType(int jdbcDataType){ + String dataType = ""; + try { + dataType = JDBCType.valueOf(jdbcDataType).getName(); + }catch(IllegalArgumentException iae){ + // do nothing + } + return dataType; + } + + /** + * Set primary key + * + * @param jdbcPrimaryKeys jdbc primary keys + * @param jdbcColumn column + * @param columnGuid guid + * @param primaryKeyProperties primary key properties + */ + private void updateOrRemovePrimaryKey(List jdbcPrimaryKeys, JdbcColumn jdbcColumn, String columnGuid, + DatabasePrimaryKeyProperties primaryKeyProperties){ + Optional jdbcPrimaryKey = jdbcPrimaryKeys.stream().filter( + key -> (key.getTableCat() == null ? jdbcColumn.getTableCat() == null : key.getTableCat().equals(jdbcColumn.getTableCat())) + && (key.getTableSchem() == null ? jdbcColumn.getTableSchem() == null : key.getTableSchem().equals(jdbcColumn.getTableSchem())) + && key.getTableName().equals(jdbcColumn.getTableName()) + && key.getColumnName().equals(jdbcColumn.getColumnName()) + ).findFirst(); + if(jdbcPrimaryKey.isEmpty()){ + if(primaryKeyProperties != null) { + omas.removePrimaryKey(columnGuid); + auditLog.logMessage("Primary key removed from column with guid " + columnGuid, null); + } + return; + } + + primaryKeyProperties = buildPrimaryKeyProperties(jdbcPrimaryKey.get()); + omas.setPrimaryKey(columnGuid, primaryKeyProperties); + auditLog.logMessage("Primary key set on column with guid " + columnGuid, null); + } + + /** + * Remove foreign key relationship + * + * @param databaseColumnElement column element + */ + private void removeForeignKey(DatabaseColumnElement databaseColumnElement){ + String foreignKeyGuid = databaseColumnElement.getReferencedColumnGUID(); + if(foreignKeyGuid == null){ + return; + } + String primaryKeyGuid = databaseColumnElement.getElementHeader().getGUID(); + omas.removeForeignKey(primaryKeyGuid, foreignKeyGuid); + } + + /** + * Build primary key properties + * + * @param jdbcPrimaryKey primary key + * + * @return properties + */ + private DatabasePrimaryKeyProperties buildPrimaryKeyProperties(JdbcPrimaryKey jdbcPrimaryKey){ + DatabasePrimaryKeyProperties properties = new DatabasePrimaryKeyProperties(); + properties.setName(jdbcPrimaryKey.getPkName()); + + return properties; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/CreateConnectionStructure.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/CreateConnectionStructure.java new file mode 100644 index 00000000000..e3182340d36 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/CreateConnectionStructure.java @@ -0,0 +1,174 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.apache.commons.lang3.StringUtils; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ConnectionElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ConnectorTypeElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.EndpointElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.ConnectionProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.EndpointProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.List; +import java.util.function.Consumer; + +/** + * If a connector type is stored in the omas, triggers the building of the asset connection structure for provided database. + * This structure consists of a Connection, a ConnectorType and an Endpoint. For further details on how to store a connector + * type consult section + * @see Open Metadata Archives + */ +class CreateConnectionStructure implements Consumer { + + private final Omas omas; + private final Jdbc jdbc; + private final String connectorTypeQualifiedName; + private final AuditLog auditLog; + + CreateConnectionStructure(Omas omas, Jdbc jdbc, String connectorTypeQualifiedName, AuditLog auditLog) { + this.omas = omas; + this.jdbc = jdbc; + this.connectorTypeQualifiedName = connectorTypeQualifiedName; + this.auditLog = auditLog; + } + + /** + * Triggers creation of database connection structure, if all information is readily available. If any part is missing, + * nothing will be created + * + * @param databaseElement database + */ + @Override + public void accept(DatabaseElement databaseElement) { + // determining database guid + String databaseGuid = databaseElement.getElementHeader().getGUID(); + if(StringUtils.isBlank(databaseGuid)){ + auditLog.logMessage("Missing database guid. Skipping database to connection relationship", null); + return; + } + + // determining connection guid + ConnectionProperties connectionProperties = createConnectionProperties(databaseElement); + String connectionGuid = determineConnectionGuid(connectionProperties); + if(StringUtils.isBlank(connectionGuid)){ + auditLog.logMessage("Missing connection guid. Skipping database to connection relationship", null); + return; + } + + // determining endpoint guid + EndpointProperties endpointProperties = createEndpointProperties(connectionProperties); + String endpointGuid = determineEndpointGuid(endpointProperties); + if(StringUtils.isBlank(endpointGuid)){ + auditLog.logMessage("Missing endpoint guid. Skipping connection to endpoint setup", null); + return; + } + + // determining connector type guid + if(StringUtils.isBlank(connectorTypeQualifiedName)){ + auditLog.logMessage("Missing connector type qualified name. Skipping connection to connector type relationship", null); + return; + } + String connectorTypeGuid = determineConnectorTypeGuid(connectorTypeQualifiedName); + if(StringUtils.isBlank(connectorTypeGuid)){ + auditLog.logMessage("Missing connector type guid. Skipping connection to connector type relationship", null); + return; + } + + omas.setupAssetConnection(databaseGuid, databaseElement.getDatabaseProperties().getDescription(), connectionGuid); + omas.setupEndpoint(connectionGuid, endpointGuid); + omas.setupConnectorType(connectionGuid, connectorTypeGuid); + + auditLog.logMessage("Asset connection structure completed", null); + } + + /** + * Create connection properties + * + * @param databaseElement database + * + * @return connection properties + */ + private ConnectionProperties createConnectionProperties(DatabaseElement databaseElement){ + ConnectionProperties connectionProperties = new ConnectionProperties(); + connectionProperties.setDisplayName(databaseElement.getDatabaseProperties().getDisplayName() + " Connection"); + connectionProperties.setQualifiedName(databaseElement.getDatabaseProperties().getQualifiedName() + "::connection"); + connectionProperties.setConfigurationProperties(databaseElement.getDatabaseProperties().getExtendedProperties()); + + return connectionProperties; + } + + /** + * Determine connection guid + * + * @param connectionProperties properties + * + * @return guid otherwise null + */ + private String determineConnectionGuid(ConnectionProperties connectionProperties){ + List connections = omas.getConnectionsByName(connectionProperties.getQualifiedName()); + if(connections.isEmpty()){ + return omas.createConnection(connectionProperties).orElse(""); + }else{ + if(connections.size() == 1){ + return connections.get(0).getElementHeader().getGUID(); + } + } + + return null; + } + + /** + * Determine connector type guid + * + * @param connectorTypeQualifiedName properties + * + * @return guid otherwise null + */ + private String determineConnectorTypeGuid(String connectorTypeQualifiedName){ + List connectorTypes = omas.getConnectorTypesByName(connectorTypeQualifiedName); + if(connectorTypes.size() == 1){ + return connectorTypes.get(0).getElementHeader().getGUID(); + } + return null; + } + + /** + * Create endpoint properties + * + * @param connectionProperties connection properties + * + * @return endpoint properties + */ + private EndpointProperties createEndpointProperties(ConnectionProperties connectionProperties){ + EndpointProperties endpointProperties = new EndpointProperties(); + endpointProperties.setDisplayName(connectionProperties.getDisplayName() + " Endpoint"); + endpointProperties.setQualifiedName(connectionProperties.getQualifiedName()+"::endpoint"); + endpointProperties.setAddress(jdbc.getUrl()); + + return endpointProperties; + } + + /** + * Determine endpoint guid + * + * @param endpointProperties properties + * + * @return guid otherwise null + */ + private String determineEndpointGuid(EndpointProperties endpointProperties){ + List endpoints = omas.findEndpoints(endpointProperties.getQualifiedName()); + if(endpoints.isEmpty()){ + return omas.createEndpoint(endpointProperties).orElse(""); + }else{ + if(endpoints.size() == 1) { + return endpoints.get(0).getElementHeader().getGUID(); + } + } + return null; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/DatabaseTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/DatabaseTransfer.java new file mode 100644 index 00000000000..7ececddb3c6 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/DatabaseTransfer.java @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.apache.commons.lang3.StringUtils; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.List; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_COMPLETE_FOR_DB_OBJECT; + + +/** + * Creates the database root of the metadata structure the follows + */ +public class DatabaseTransfer { + + private final Jdbc jdbc; + private final String databaseManagerName; + private final String address; + private final String catalog; + private final Omas omas; + private final AuditLog auditLog; + + public DatabaseTransfer(Jdbc jdbc, String databaseManagerName, String address, String catalog, Omas omas, AuditLog auditLog) { + this.jdbc = jdbc; + this.databaseManagerName = databaseManagerName; + this.address = address; + this.catalog = catalog; + this.omas = omas; + this.auditLog = auditLog; + } + + /** + * Triggers database metadata transfer + * + * @return database element + */ + public DatabaseElement execute() { + DatabaseProperties databaseProperties = buildDatabaseProperties(); + String multipleDatabasesFoundMessage = "Querying for a database with qualified name " + + databaseProperties.getQualifiedName() + " and found multiple. Expecting only one"; + + List databasesInOmas = omas.getDatabasesByName(databaseProperties.getQualifiedName()); + if (databasesInOmas.isEmpty()) { + omas.createDatabase(databaseProperties); + } else { + if(databasesInOmas.size() > 1){ + auditLog.logMessage(multipleDatabasesFoundMessage, null); + return null; + } + omas.updateDatabase(databasesInOmas.get(0).getElementHeader().getGUID(), databaseProperties); + } + + databasesInOmas = omas.getDatabasesByName(databaseProperties.getQualifiedName()); + if(databasesInOmas.size() == 1){ + auditLog.logMessage("Transferred database with qualified name " + databaseProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("database " + databaseProperties.getQualifiedName())); + return databasesInOmas.get(0); + } + auditLog.logMessage(multipleDatabasesFoundMessage, null); + return null; + } + + /** + * Builds database properties + * + * @return properties + */ + private DatabaseProperties buildDatabaseProperties() { + String driverName = jdbc.getDriverName(); + String databaseProductVersion = jdbc.getDatabaseProductVersion(); + String databaseProductName = jdbc.getDatabaseProductName(); + String url = jdbc.getUrl(); + + DatabaseProperties databaseProperties = new DatabaseProperties(); + databaseProperties.setQualifiedName(databaseManagerName + "::" + address); + databaseProperties.setDisplayName(StringUtils.isBlank(catalog) ? address : catalog); + databaseProperties.setDatabaseInstance(driverName); + databaseProperties.setDatabaseVersion(databaseProductVersion); + databaseProperties.setDatabaseType(databaseProductName); + databaseProperties.setDatabaseImportedFrom(url); + + return databaseProperties; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ForeignKeyTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ForeignKeyTransfer.java new file mode 100644 index 00000000000..e8b194457b5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ForeignKeyTransfer.java @@ -0,0 +1,89 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseForeignKeyProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcForeignKey; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.List; +import java.util.function.Consumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_COMPLETE_FOR_DB_OBJECT; + +/** + * Transfers metadata of a foreign key + */ +public class ForeignKeyTransfer implements Consumer { + + private final Omas omas; + private final AuditLog auditLog; + private final DatabaseElement database; + + public ForeignKeyTransfer(Omas omas, AuditLog auditLog, DatabaseElement database) { + this.omas = omas; + this.auditLog = auditLog; + this.database = database; + } + + /** + * Triggers foreign key metadata transfer + * + * @param jdbcForeignKey foreign key + */ + @Override + public void accept(JdbcForeignKey jdbcForeignKey) { + String databaseQualifiedName = database.getDatabaseProperties().getQualifiedName(); + String pkColumnQualifiedName = databaseQualifiedName + + (jdbcForeignKey.getPkTableSchem() == null ? "" : "::" + jdbcForeignKey.getPkTableSchem() ) + + "::" + jdbcForeignKey.getPkTableName() + "::" + jdbcForeignKey.getPkColumnName(); + String fkColumnQualifiedName = databaseQualifiedName + + ( jdbcForeignKey.getFkTableSchem() == null ? "" : "::" + jdbcForeignKey.getFkTableSchem()) + + "::" + jdbcForeignKey.getFkTableName() + "::" + jdbcForeignKey.getFkColumnName(); + + DatabaseColumnElement pkColumn = determineColumn(omas.findDatabaseColumns(pkColumnQualifiedName)); + DatabaseColumnElement fkColumn = determineColumn(omas.findDatabaseColumns(fkColumnQualifiedName)); + + if(pkColumn == null || fkColumn == null){ + return; + } + + String pkColumnGuid = pkColumn.getElementHeader().getGUID(); + String fkColumnGuid = fkColumn.getElementHeader().getGUID(); + omas.setForeignKey(pkColumnGuid, fkColumnGuid, buildForeignKeyProperties(jdbcForeignKey)); + + auditLog.logMessage("Foreign key set from column with guid " + pkColumnGuid + " to column with guid " + fkColumnGuid, + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("foreign key relationship from " + pkColumnGuid + " to " + fkColumnGuid)); + } + + /** + * Extract item from list + * + * @param columns columns + * + * @return item at index 0 if size is 1 otherwise null + */ + private DatabaseColumnElement determineColumn(List columns){ + if(columns.size() == 1){ + return columns.get(0); + } + return null; + } + + /** + * Build foreign key properties + * + * @param jdbcForeignKey foreign key + * + * @return properties + */ + private DatabaseForeignKeyProperties buildForeignKeyProperties(JdbcForeignKey jdbcForeignKey){ + DatabaseForeignKeyProperties properties = new DatabaseForeignKeyProperties(); + properties.setName(jdbcForeignKey.getPkName() + " - " + jdbcForeignKey.getFkName()); + properties.setSource(database.getDatabaseProperties().getDatabaseImportedFrom()); + return properties; + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/JdbcMetadata.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/JdbcMetadata.java new file mode 100644 index 00000000000..3e2d2c8983a --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/JdbcMetadata.java @@ -0,0 +1,168 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.*; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * JDBCResourceConnector works exclusively with JDBC API to retrieve metadata. It internally manages the connection but specific + * calls to open and close the connection are needed, and in some cases converts the result into specific objects. + *

+ * Generic use case is: + * + * connector.open() + * // connector usage + * connector.getSchemas() + * // more connector usage + * connector.close() + * + */ +public class JdbcMetadata { + + private final DatabaseMetaData databaseMetaData; + + public JdbcMetadata(DatabaseMetaData databaseMetaData) { + this.databaseMetaData = databaseMetaData; + } + + public String getUserName() throws SQLException { + return this.databaseMetaData.getUserName(); + } + + public String getDriverName() throws SQLException { + return this.databaseMetaData.getDriverName(); + } + + public String getDatabaseProductName() throws SQLException { + return this.databaseMetaData.getDatabaseProductName(); + } + + public String getUrl() throws SQLException { + return this.databaseMetaData.getURL(); + } + + public String getDatabaseProductVersion() throws SQLException { + return this.databaseMetaData.getDatabaseProductVersion(); + } + + public List getTableTypes() throws SQLException { + List result = new ArrayList<>(); + + ResultSet tableTypes = this.databaseMetaData.getTableTypes(); + while(tableTypes.next()){ + result.add(tableTypes.getString("TABLE_TYPE")); + } + close(tableTypes); + + return result; + } + + public List getPrimaryKeys(String catalog, String schema, String table) throws SQLException { + List result = new ArrayList<>(); + + ResultSet primaryKeys = this.databaseMetaData.getPrimaryKeys(catalog, schema, table); + while(primaryKeys.next()){ + result.add(JdbcPrimaryKey.create(primaryKeys)); + } + close(primaryKeys); + + return result; + } + + public List getImportedKeys(String catalog, String schema, String table) throws SQLException { + List result = new ArrayList<>(); + + ResultSet foreignKeys = this.databaseMetaData.getImportedKeys(catalog, schema, table); + while(foreignKeys.next()){ + result.add(JdbcForeignKey.create(foreignKeys)); + } + + return result; + } + + public List getExportedKeys(String catalog, String schema, String table) throws SQLException { + List result = new ArrayList<>(); + + ResultSet foreignKeys = this.databaseMetaData.getExportedKeys(catalog, schema, table); + while(foreignKeys.next()){ + result.add(JdbcForeignKey.create(foreignKeys)); + } + + return result; + } + + public List getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { + List result = new ArrayList<>(); + + ResultSet columns = this.databaseMetaData.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern); + while(columns.next()){ + result.add(JdbcColumn.create(columns)); + } + close(columns); + + return result; + } + + public List getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { + List result = new ArrayList<>(); + + ResultSet tables = this.databaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types); + while(tables.next()){ + result.add(JdbcTable.create(tables)); + } + close(tables); + + return result; + } + + public List getSchemas(String catalog, String schemaPattern) throws SQLException { + List result = new ArrayList<>(); + + ResultSet schemas = this.databaseMetaData.getSchemas(catalog, schemaPattern); + while(schemas.next()){ + result.add(JdbcSchema.create(schemas)); + } + close(schemas); + + return result; + } + + public List getSchemas() throws SQLException { + List result = new ArrayList<>(); + + ResultSet schemas = this.databaseMetaData.getSchemas(); + while(schemas.next()){ + result.add(JdbcSchema.create(schemas)); + } + close(schemas); + + return result; + } + + public List getCatalogs() throws SQLException { + List result = new ArrayList<>(); + + ResultSet catalogs = this.databaseMetaData.getCatalogs(); + while(catalogs.next()){ + result.add(JdbcCatalog.create(catalogs)); + } + close(catalogs); + + return result; + } + + private void close(ResultSet resultSet) throws SQLException { + if(resultSet.isClosed()){ + return; + } + resultSet.close(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/JdbcMetadataTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/JdbcMetadataTransfer.java new file mode 100644 index 00000000000..b1cfb545a6e --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/JdbcMetadataTransfer.java @@ -0,0 +1,427 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.apache.commons.lang3.StringUtils; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseSchemaElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseViewElement; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.customization.TransferCustomizations; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcForeignKey; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcPrimaryKey; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXITING_ON_DATABASE_TRANSFER_FAIL; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS; +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_EXCEPTIONS_FOR_DB_OBJECT; + +/** + * Transfers metadata from jdbc in an exploratory way. What can be accessed will be transferred + */ +public class JdbcMetadataTransfer { + + private static final String TABLES_WITH_NO_SCHEMA = "tables with no schema"; + private static final String VIEWS_WITH_NO_SCHEMA = "views with no schema"; + private static final String COLUMNS_OF_TABLES_WITH_NO_SCHEMA = "columns of tables with no schema"; + private static final String SKIPPING = "Skipping "; + private static final String TRANSFERRING = "Transferring "; + private static final String SCHEMAS = "schemas"; + private static final String TABLES = "tables"; + private static final String VIEWS = "views"; + private static final String COLUMNS = "columns"; + private final Jdbc jdbc; + private final Omas omas; + private final String databaseManagerName; + private final String address; + private final String connectorTypeQualifiedName; + private final String catalog; + private final TransferCustomizations transferCustomizations; + + private final AuditLog auditLog; + + public JdbcMetadataTransfer(JdbcMetadata jdbcMetadata, DatabaseIntegratorContext databaseIntegratorContext, String address, + String connectorTypeQualifiedName, String catalog, TransferCustomizations transferCustomizations, + AuditLog auditLog) { + this.jdbc = new Jdbc(jdbcMetadata, auditLog); + this.omas = new Omas(databaseIntegratorContext, auditLog); + this.databaseManagerName = databaseIntegratorContext.getDatabaseManagerName(); + this.address = address; + this.connectorTypeQualifiedName = connectorTypeQualifiedName; + this.catalog = catalog; + this.transferCustomizations = transferCustomizations; + this.auditLog = auditLog; + } + + /** + * Triggers database, schema, table and column metadata transfer. Will do the best it can to transfer as much of the + * metadata as possible. If available will also build the asset (database) connection structure + */ + public void execute() { + String methodName = "JdbcMetadataTransfer.execute"; + + DatabaseElement database = new DatabaseTransfer(jdbc, databaseManagerName, address, catalog, omas, auditLog).execute(); + if (database == null) { + auditLog.logMessage("Verifying database metadata transferred. None found. Stopping transfer", + EXITING_ON_DATABASE_TRANSFER_FAIL.getMessageDefinition(methodName)); + return; + } + + createAssetConnection(database); + + transferTablesWithoutSchema(database); + transferViewsWithoutSchema(database); + transferColumnsOfTablesWithoutSchema(database); + transferForeignKeysIgnoringSchemas(database); + + transferSchemas(database); + List schemas = omas.getSchemas(database.getElementHeader().getGUID()); + if(schemas.isEmpty()){ + return; + } + transferTables(database, schemas); + transferViews(database, schemas); + transferColumns(database, schemas); + transferForeignKeys(database); + } + + /** + * Triggers the transfer of available tables that are not assigned to any schema, depending also on inclusions and + * exclusions + * + * @param databaseElement database element + */ + private void transferTablesWithoutSchema(DatabaseElement databaseElement) { + long start = System.currentTimeMillis(); + + String databaseQualifiedName = databaseElement.getDatabaseProperties().getQualifiedName(); + String databaseGuid = databaseElement.getElementHeader().getGUID(); + + // already known tables by the omas, previously transferred + List omasTables = omas.getTables(databaseGuid); + // a table update will always occur as long as the table is returned by jdbc + List omasTablesUpdated = jdbc.getTables(catalog,"").parallelStream() + .filter(jdbcTable -> jdbcTable.getTableSchem() == null || jdbcTable.getTableSchem().length() < 1 ) + .filter(table -> transferCustomizations.shouldTransferTable(table.getTableName())) + .map(new TableTransfer(omas, auditLog, omasTables, databaseQualifiedName, databaseGuid)) + .collect(Collectors.toList()); + + // will remove all updated tables, and what remains are the ones deleted in jdbc + omasTables.removeAll(omasTablesUpdated); + // remove from omas the tables deleted in jdbc + omasTables.forEach(omas::removeTable); + + String excludedTables = transferCustomizations.getExcludedTables(); + if(StringUtils.isNotEmpty(excludedTables)) { + auditLog.logMessage(SKIPPING + TABLES_WITH_NO_SCHEMA, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(TABLES_WITH_NO_SCHEMA, excludedTables)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage(TRANSFERRING + TABLES_WITH_NO_SCHEMA, + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(TABLES_WITH_NO_SCHEMA, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of available views that are not assigned to any schema, depending also on inclusions and + * exclusions + * + * @param databaseElement database element + */ + private void transferViewsWithoutSchema(DatabaseElement databaseElement) { + long start = System.currentTimeMillis(); + + String databaseQualifiedName = databaseElement.getDatabaseProperties().getQualifiedName(); + String databaseGuid = databaseElement.getElementHeader().getGUID(); + + // already known views by the omas, previously transferred + List omasViews = omas.getViews(databaseGuid); + // a view update will always occur as long as the view is returned by jdbc + List omasViewsUpdated = jdbc.getViews(catalog,"").parallelStream() + .filter(jdbcView -> jdbcView.getTableSchem() == null || jdbcView.getTableSchem().length() < 1 ) + .filter(view -> transferCustomizations.shouldTransferTable(view.getTableName())) + .map(new ViewTransfer(omas, auditLog, omasViews, databaseQualifiedName, databaseGuid)) + .collect(Collectors.toList()); + + // will remove all updated views, and what remains are the ones deleted in jdbc + omasViews.removeAll(omasViewsUpdated); + // remove from omas the tables deleted in jdbc + omasViews.forEach(omas::removeView); + + String excludedViews = transferCustomizations.getExcludedViews(); + if(StringUtils.isNotEmpty(excludedViews)) { + auditLog.logMessage(SKIPPING + VIEWS_WITH_NO_SCHEMA, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(VIEWS_WITH_NO_SCHEMA, excludedViews)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage(TRANSFERRING + VIEWS_WITH_NO_SCHEMA, + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(VIEWS_WITH_NO_SCHEMA, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of columns from tables without schema, depending also on inclusions and exclusions + * + * @param databaseElement database element + */ + private void transferColumnsOfTablesWithoutSchema(DatabaseElement databaseElement){ + long start = System.currentTimeMillis(); + + String databaseGuid = databaseElement.getElementHeader().getGUID(); + + omas.getTables(databaseGuid).parallelStream() + .filter(table -> transferCustomizations.shouldTransferTable(table.getDatabaseTableProperties().getDisplayName())) + .peek(table -> { + String schemaName = ""; + String tableName = table.getDatabaseTableProperties().getDisplayName(); + String tableGuid = table.getElementHeader().getGUID(); + + List jdbcPrimaryKeys = jdbc.getPrimaryKeys(schemaName, tableName); + // already known columns by the omas, previously transferred + List omasColumns = omas.getColumns(tableGuid); + // a column update will always occur as long as the column is returned by jdbc + List omasUpdatedColumns = jdbc.getColumns(catalog, schemaName, tableName).parallelStream() + .filter(column -> transferCustomizations.shouldTransferColumn(column.getColumnName())) + .map(new ColumnTransfer(omas, auditLog, omasColumns, jdbcPrimaryKeys, table)).collect(Collectors.toList()); + + // will remove all updated column, and what remains are the ones deleted in jdbc + omasColumns.removeAll(omasUpdatedColumns); + // remove from omas the columns deleted in jdbc + omasColumns.forEach(omas::removeColumn); + }).collect(Collectors.toList()); + + String excludedColumns = transferCustomizations.getExcludedColumns(); + if(StringUtils.isNotEmpty(excludedColumns)) { + auditLog.logMessage(SKIPPING + COLUMNS_OF_TABLES_WITH_NO_SCHEMA, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(COLUMNS_OF_TABLES_WITH_NO_SCHEMA, excludedColumns)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage(TRANSFERRING + COLUMNS_OF_TABLES_WITH_NO_SCHEMA, + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(COLUMNS_OF_TABLES_WITH_NO_SCHEMA, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of all foreign keys between columns of tables without schemas, depending also on inclusions + * and exclusions + * + * @param databaseElement database element + */ + private void transferForeignKeysIgnoringSchemas(DatabaseElement databaseElement){ + long start = System.currentTimeMillis(); + + Set foreignKeys = Stream.concat( + jdbc.getTables(catalog, "").stream() + .filter(table -> transferCustomizations.shouldTransferTable(table.getTableName())) + .flatMap( t -> jdbc.getImportedKeys(catalog, "", t.getTableName()).stream() ), + jdbc.getTables(catalog, "").stream() + .filter(table -> transferCustomizations.shouldTransferTable(table.getTableName())) + .flatMap( t -> jdbc.getExportedKeys(catalog, "", t.getTableName()).stream() )) + .collect(Collectors.toSet()); + + foreignKeys.forEach(new ForeignKeyTransfer(omas, auditLog, databaseElement)); + + long end = System.currentTimeMillis(); + auditLog.logMessage("Foreign key transfer complete", + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS + .getMessageDefinition("foreign keys between columns of tables without schemas", "" + (end - start)/1000)); + } + + private void createAssetConnection(DatabaseElement databaseElement){ + CreateConnectionStructure createConnectionStructure = new CreateConnectionStructure(omas, jdbc, + connectorTypeQualifiedName, auditLog); + createConnectionStructure.accept(databaseElement); + } + + /** + * Triggers the transfer of all available schemas, depending also on inclusions and exclusions + * + * @param databaseElement database + */ + private void transferSchemas(DatabaseElement databaseElement){ + long start = System.currentTimeMillis(); + + String databaseQualifiedName = databaseElement.getDatabaseProperties().getQualifiedName(); + String databaseGuid = databaseElement.getElementHeader().getGUID(); + + // already known schemas by the omas, previously transferred + List omasSchemas = omas.getSchemas(databaseGuid); + // a schema update will always occur as long as the schema is returned by jdbc + List omasSchemasUpdated = + jdbc.getSchemas(catalog).parallelStream() + .filter(schema -> transferCustomizations.shouldTransferSchema(schema.getTableSchem())) + .map(new SchemaTransfer(omas, auditLog, omasSchemas, databaseQualifiedName, databaseGuid)) + .collect(Collectors.toList()); + + // will remove all updated schemas, and what remains are the ones deleted in jdbc + omasSchemas.removeAll(omasSchemasUpdated); + // remove from omas the schemas deleted in jdbc + omasSchemas.forEach(omas::removeSchema); + + String excludedSchemas = transferCustomizations.getExcludedSchemas(); + if(StringUtils.isNotEmpty(excludedSchemas)) { + auditLog.logMessage(SKIPPING + SCHEMAS, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(SCHEMAS, excludedSchemas)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage("Schema transfer complete", + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(SCHEMAS, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of all available tables, depending also on inclusions and exclusions + * + * @param databaseElement database element + * @param schemas schemas + */ + private void transferTables(DatabaseElement databaseElement, List schemas){ + long start = System.currentTimeMillis(); + + schemas.parallelStream() + .filter(schema -> transferCustomizations.shouldTransferSchema(schema.getDatabaseSchemaProperties().getName())) + .peek(schema -> { + String schemaDisplayName = schema.getDatabaseSchemaProperties().getName(); + String schemaGuid = schema.getElementHeader().getGUID(); + String schemaQualifiedName = schema.getDatabaseSchemaProperties().getQualifiedName(); + + // already known tables by the omas, previously transferred + List omasTables = omas.getTables(schemaGuid); + // a table update will always occur as long as the table is returned by jdbc + List omasTablesUpdated = jdbc.getTables(catalog, schemaDisplayName).parallelStream() + .filter(table -> transferCustomizations.shouldTransferTable(table.getTableName())) + .map(new TableTransfer(omas, auditLog, omasTables, schemaQualifiedName, schemaGuid)) + .collect(Collectors.toList()); + + // will remove all updated tables, and what remains are the ones deleted in jdbc + omasTables.removeAll(omasTablesUpdated); + // remove from omas the tables deleted in jdbc + omasTables.forEach(omas::removeTable); + }).collect(Collectors.toList()); + + String excludedTables = transferCustomizations.getExcludedTables(); + if(StringUtils.isNotEmpty(excludedTables)) { + auditLog.logMessage(SKIPPING + TABLES, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(TABLES, excludedTables)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage("Table transfer complete", + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(TABLES, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of all available views, depending also on inclusions and exclusions + * + * @param databaseElement database element + * @param schemas schemas + */ + private void transferViews(DatabaseElement databaseElement, List schemas){ + long start = System.currentTimeMillis(); + + schemas.parallelStream() + .filter(schema -> transferCustomizations.shouldTransferSchema(schema.getDatabaseSchemaProperties().getName())) + .peek(schema -> { + String schemaDisplayName = schema.getDatabaseSchemaProperties().getName(); + String schemaGuid = schema.getElementHeader().getGUID(); + String schemaQualifiedName = schema.getDatabaseSchemaProperties().getQualifiedName(); + + // already known views by the omas, previously transferred + List omasViews = omas.getViews(schemaGuid); + // a view update will always occur as long as the view is returned by jdbc + List omasViewsUpdated = jdbc.getViews(catalog, schemaDisplayName).parallelStream() + .filter(jdbcView -> transferCustomizations.shouldTransferTable(jdbcView.getTableName())) + .map(new ViewTransfer(omas, auditLog, omasViews, schemaQualifiedName, schemaGuid)) + .collect(Collectors.toList()); + + // will remove all updated tables, and what remains are the ones deleted in jdbc + omasViews.removeAll(omasViewsUpdated); + // remove from omas the tables deleted in jdbc + omasViews.forEach(omas::removeView); + }).collect(Collectors.toList()); + + String excludedViews = transferCustomizations.getExcludedViews(); + if(StringUtils.isNotEmpty(excludedViews)) { + auditLog.logMessage(SKIPPING + VIEWS, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(TABLES, excludedViews)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage("View transfer complete", + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(VIEWS, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of all available columns, depending also on inclusions and exclusions + * + * @param databaseElement database element + * @param schemas schemas + */ + private void transferColumns(DatabaseElement databaseElement, List schemas){ + long start = System.currentTimeMillis(); + + schemas.parallelStream() + .filter(schema -> transferCustomizations.shouldTransferSchema(schema.getDatabaseSchemaProperties().getName())) + .flatMap(s -> omas.getTables(s.getElementHeader().getGUID()).parallelStream()) + .filter(table -> transferCustomizations.shouldTransferTable(table.getDatabaseTableProperties().getDisplayName())) + .peek(table -> { + String schemaName = table.getDatabaseTableProperties().getAdditionalProperties().get(Jdbc.JDBC_SCHEMA_KEY); + String tableName = table.getDatabaseTableProperties().getDisplayName(); + String tableGuid = table.getElementHeader().getGUID(); + + List jdbcPrimaryKeys = jdbc.getPrimaryKeys(schemaName, tableName); + // already known columns by the omas, previously transferred + List omasColumns = omas.getColumns(tableGuid); + // a column update will always occur as long as the column is returned by jdbc + List omasUpdatedColumns = jdbc.getColumns(catalog, schemaName, tableName).parallelStream() + .filter(column -> transferCustomizations.shouldTransferColumn(column.getColumnName())) + .map(new ColumnTransfer(omas, auditLog, omasColumns, jdbcPrimaryKeys, table)).collect(Collectors.toList()); + + // will remove all updated column, and what remains are the ones deleted in jdbc + omasColumns.removeAll(omasUpdatedColumns); + // remove from omas the columns deleted in jdbc + omasColumns.forEach(omas::removeColumn); + }).collect(Collectors.toList()); + + String excludedColumns = transferCustomizations.getExcludedColumns(); + if(StringUtils.isNotEmpty(excludedColumns)) { + auditLog.logMessage(SKIPPING + COLUMNS, + TRANSFER_EXCEPTIONS_FOR_DB_OBJECT.getMessageDefinition(COLUMNS, excludedColumns)); + } + long end = System.currentTimeMillis(); + auditLog.logMessage("Column transfer complete", + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition(COLUMNS, "" + (end - start)/1000)); + } + + /** + * Triggers the transfer of all foreign keys, depending also on inclusions and exclusions. The reason for doing this + * at database level is that a foreign key relationship can exist between columns located in tables in different schemas + * + * @param databaseElement database element + */ + private void transferForeignKeys(DatabaseElement databaseElement){ + long start = System.currentTimeMillis(); + + // all foreign keys as returned by calling getExportedKeys and getImportedKeys on jdbc + Set foreignKeys = Stream.concat( + jdbc.getSchemas(catalog).stream().filter(schema -> transferCustomizations.shouldTransferSchema(schema.getTableSchem())) + .flatMap(s -> jdbc.getTables(catalog, s.getTableSchem()).stream() + .filter(table -> transferCustomizations.shouldTransferTable(table.getTableName()))) + .flatMap(t -> jdbc.getImportedKeys(catalog, t.getTableSchem(), t.getTableName()).stream()), + jdbc.getSchemas(catalog).stream().filter(schema -> transferCustomizations.shouldTransferSchema(schema.getTableSchem())) + .flatMap(s -> jdbc.getTables(catalog, s.getTableSchem()).stream() + .filter(table -> transferCustomizations.shouldTransferTable(table.getTableName()))) + .flatMap(t -> jdbc.getExportedKeys(catalog, t.getTableSchem(), t.getTableName()).stream()) + ).collect(Collectors.toSet()); + + foreignKeys.forEach(new ForeignKeyTransfer(omas, auditLog, databaseElement)); + + long end = System.currentTimeMillis(); + auditLog.logMessage("Foreign key transfer complete", + PARTIAL_TRANSFER_COMPLETE_FOR_DB_OBJECTS.getMessageDefinition("foreign keys", "" + (end - start)/1000)); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/SchemaTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/SchemaTransfer.java new file mode 100644 index 00000000000..a637cf1a24c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/SchemaTransfer.java @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseSchemaElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseSchemaProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcSchema; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_COMPLETE_FOR_DB_OBJECT; + +/** + * Transfers metadata of a schema + */ +public class SchemaTransfer implements Function { + + private final Omas omas; + private final AuditLog auditLog; + private final List omasSchemas; + private final String databaseQualifiedName; + private final String databaseGuid; + + public SchemaTransfer(Omas omas, AuditLog auditLog, List omasSchemas, String databaseQualifiedName, String databaseGuid) { + this.omas = omas; + this.auditLog = auditLog; + this.omasSchemas = omasSchemas; + this.databaseQualifiedName = databaseQualifiedName; + this.databaseGuid = databaseGuid; + } + + /** + * Triggers schema metadata transfer + * + * @param jdbcSchema schema + * + * @return schema element + */ + @Override + public DatabaseSchemaElement apply(JdbcSchema jdbcSchema) { + DatabaseSchemaProperties schemaProperties = buildSchemaProperties(jdbcSchema); + + Optional omasSchema = omasSchemas.stream() + .filter(dse -> dse.getDatabaseSchemaProperties() + .getQualifiedName().equals(schemaProperties.getQualifiedName())) + .findFirst(); + + if (omasSchema.isPresent()) { + omas.updateSchema(omasSchema.get().getElementHeader().getGUID(), schemaProperties); + auditLog.logMessage("Updated schema with qualified name " + schemaProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("schema " + schemaProperties.getQualifiedName())); + return omasSchema.get(); + } + + omas.createSchema(databaseGuid, schemaProperties); + auditLog.logMessage("Created schema with qualified name " + schemaProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("schema " + schemaProperties.getQualifiedName())); + return null; + } + + /** + * Build schema properties + * + * @param jdbcSchema schema + * + * @return properties + */ + private DatabaseSchemaProperties buildSchemaProperties(JdbcSchema jdbcSchema) { + Map additionalProperties = new HashMap<>(); + additionalProperties.put(Jdbc.JDBC_CATALOG_KEY, jdbcSchema.getTableCatalog()); + additionalProperties.put(Jdbc.JDBC_SCHEMA_KEY, jdbcSchema.getTableSchem()); + + DatabaseSchemaProperties jdbcSchemaProperties = new DatabaseSchemaProperties(); + jdbcSchemaProperties.setDisplayName(jdbcSchema.getTableSchem()); + jdbcSchemaProperties.setQualifiedName(databaseQualifiedName + "::" + jdbcSchema.getTableSchem()); + jdbcSchemaProperties.setAdditionalProperties(additionalProperties); + return jdbcSchemaProperties; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/TableTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/TableTransfer.java new file mode 100644 index 00000000000..dc704b3e015 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/TableTransfer.java @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseTableProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcTable; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_COMPLETE_FOR_DB_OBJECT; + +/** + * Transfers metadata of a table. Its parent can be a schema or directly a database, even though it is not explicitly enforced + */ +public class TableTransfer implements Function { + + private final Omas omas; + private final AuditLog auditLog; + private final List omasTables; + private final String parentQualifiedName; + private final String parentGuid; + + public TableTransfer(Omas omas, AuditLog auditLog, List omasTables, String parentQualifiedName, String parentGuid) { + this.omas = omas; + this.auditLog = auditLog; + this.omasTables = omasTables; + this.parentQualifiedName = parentQualifiedName; + this.parentGuid = parentGuid; + } + + /** + * Triggers table metadata transfer + * + * @param jdbcTable table + * + * @return table element + */ + @Override + public DatabaseTableElement apply(JdbcTable jdbcTable) { + DatabaseTableProperties tableProperties = this.buildTableProperties(jdbcTable); + + Optional omasTable = omasTables.stream() + .filter(dte -> dte.getDatabaseTableProperties().getQualifiedName().equals(tableProperties.getQualifiedName())) + .findFirst(); + + if(omasTable.isPresent()){ + omas.updateTable(omasTable.get().getElementHeader().getGUID(), tableProperties); + auditLog.logMessage("Updated table with qualified name " + tableProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("table " + tableProperties.getQualifiedName())); + return omasTable.get(); + } + + omas.createTable(parentGuid, tableProperties); + auditLog.logMessage("Created table with qualified name " + tableProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("table " + tableProperties.getQualifiedName())); + return null; + } + + /** + * Build table properties + * + * @param jdbcTable table + * + * @return properties + */ + private DatabaseTableProperties buildTableProperties(JdbcTable jdbcTable){ + Map additionalProperties = new HashMap<>(); + additionalProperties.put(Jdbc.JDBC_CATALOG_KEY, jdbcTable.getTableCat()); + additionalProperties.put(Jdbc.JDBC_SCHEMA_KEY, jdbcTable.getTableSchem()); + additionalProperties.put(Jdbc.JDBC_TABLE_KEY, jdbcTable.getTableName()); + additionalProperties.put(Jdbc.JDBC_TABLE_TYPE_KEY, jdbcTable.getTableType()); + + DatabaseTableProperties jdbcTableProperties = new DatabaseTableProperties(); + jdbcTableProperties.setDisplayName(jdbcTable.getTableName()); + jdbcTableProperties.setQualifiedName(parentQualifiedName + "::" + jdbcTable.getTableName()); + jdbcTableProperties.setAdditionalProperties(additionalProperties); + return jdbcTableProperties; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ViewTransfer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ViewTransfer.java new file mode 100644 index 00000000000..78fee82fc5b --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/ViewTransfer.java @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseViewElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseViewProperties; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcTable; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Jdbc; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests.Omas; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.TRANSFER_COMPLETE_FOR_DB_OBJECT; + +/** + * Transfers metadata of a view. Its parent can be a schema or directly a database, even though it is not explicitly enforced + */ +public class ViewTransfer implements Function { + + private final Omas omas; + private final AuditLog auditLog; + private final List omasViews; + private final String parentQualifiedName; + private final String parentGuid; + + public ViewTransfer(Omas omas, AuditLog auditLog, List omasViews, String parentQualifiedName, String parentGuid) { + this.omas = omas; + this.auditLog = auditLog; + this.omasViews = omasViews; + this.parentQualifiedName = parentQualifiedName; + this.parentGuid = parentGuid; + } + + /** + * Triggers view metadata transfer + * + * @param jdbcTable view + * + * @return view element + */ + @Override + public DatabaseViewElement apply(JdbcTable jdbcTable) { + DatabaseViewProperties viewProperties = this.buildViewProperties(jdbcTable); + + Optional omasView = omasViews.stream() + .filter(dve -> dve.getDatabaseViewProperties().getQualifiedName().equals(viewProperties.getQualifiedName())) + .findFirst(); + + if(omasView.isPresent()){ + omas.updateView(omasView.get().getElementHeader().getGUID(), viewProperties); + auditLog.logMessage("Updated view with qualified name " + viewProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("view " + viewProperties.getQualifiedName())); + return omasView.get(); + } + + omas.createView(parentGuid, viewProperties); + auditLog.logMessage("Created view with qualified name " + viewProperties.getQualifiedName(), + TRANSFER_COMPLETE_FOR_DB_OBJECT.getMessageDefinition("view " + viewProperties.getQualifiedName())); + return null; + } + + /** + * Build view properties + * + * @param jdbcTable view + * + * @return properties + */ + private DatabaseViewProperties buildViewProperties(JdbcTable jdbcTable){ + Map additionalProperties = new HashMap<>(); + additionalProperties.put(Jdbc.JDBC_CATALOG_KEY, jdbcTable.getTableCat()); + additionalProperties.put(Jdbc.JDBC_SCHEMA_KEY, jdbcTable.getTableSchem()); + additionalProperties.put(Jdbc.JDBC_TABLE_KEY, jdbcTable.getTableName()); + additionalProperties.put(Jdbc.JDBC_TABLE_TYPE_KEY, jdbcTable.getTableType()); + + DatabaseViewProperties jdbcViewProperties = new DatabaseViewProperties(); + jdbcViewProperties.setDisplayName(jdbcTable.getTableName()); + jdbcViewProperties.setQualifiedName(parentQualifiedName + "::" + jdbcTable.getTableName()); + jdbcViewProperties.setAdditionalProperties(additionalProperties); + return jdbcViewProperties; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/customization/TransferCustomizations.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/customization/TransferCustomizations.java new file mode 100644 index 00000000000..03a60e99e7d --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/customization/TransferCustomizations.java @@ -0,0 +1,171 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.customization; + +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TransferCustomizations { + + public static final String INCLUDE_SCHEMA_NAMES = "includeSchemaNames"; + public static final String EXCLUDE_SCHEMA_NAMES = "excludeSchemaNames"; + public static final String INCLUDE_TABLE_NAMES = "includeTableNames"; + public static final String EXCLUDE_TABLE_NAMES = "excludeTableNames"; + public static final String INCLUDE_VIEW_NAMES = "includeViewNames"; + public static final String EXCLUDE_VIEW_NAMES = "excludeViewNames"; + public static final String INCLUDE_COLUMN_NAMES = "includeColumnNames"; + public static final String EXCLUDE_COLUMN_NAMES = "excludeColumnNames"; + + public static final List INCLUSION_AND_EXCLUSION_NAMES = Arrays.asList(INCLUDE_SCHEMA_NAMES, + INCLUDE_TABLE_NAMES, INCLUDE_VIEW_NAMES, INCLUDE_COLUMN_NAMES, EXCLUDE_SCHEMA_NAMES, EXCLUDE_TABLE_NAMES, + EXCLUDE_VIEW_NAMES, EXCLUDE_COLUMN_NAMES); + private static final String DELIMITER = ", "; + + private final Map> customizations = new HashMap<>(); + + public TransferCustomizations(Map configurationProperties) { + for(String customizationKey : TransferCustomizations.INCLUSION_AND_EXCLUSION_NAMES) { + addCustomization(customizationKey, configurationProperties.get(customizationKey)); + } + } + + /** + * Determines if schema should be transferred + * + * @param schemaName the schema name + * @return the boolean + */ + public boolean shouldTransferSchema(String schemaName) { + return shouldTransfer(schemaName, getCustomization(INCLUDE_SCHEMA_NAMES), getCustomization(EXCLUDE_SCHEMA_NAMES)); + } + + /** + * Determines if table should be transferred + * + * @param tableName the table name + * @return the boolean + */ + public boolean shouldTransferTable(String tableName) { + return shouldTransfer(tableName, getCustomization(INCLUDE_TABLE_NAMES), getCustomization(EXCLUDE_TABLE_NAMES)); + } + + /** + * Determines if view should be transferred + * + * @param viewName the view name + * @return the boolean + */ + public boolean shouldTransferView(String viewName) { + return shouldTransfer(viewName, getCustomization(INCLUDE_VIEW_NAMES), getCustomization(EXCLUDE_VIEW_NAMES)); + } + + /** + * Determines if column should be transferred + * + * @param columnName the column name + * @return the boolean + */ + public boolean shouldTransferColumn(String columnName) { + return shouldTransfer(columnName, getCustomization(INCLUDE_COLUMN_NAMES), getCustomization(EXCLUDE_COLUMN_NAMES)); + } + + /** + * Gets excluded schemas, only if took into consideration (inclusion is not present). + * + * @return the excluded schemas + */ + public String getExcludedSchemas() { + if(!CollectionUtils.isEmpty(customizations.get(INCLUDE_SCHEMA_NAMES))) { + return ""; + } + return String.join(DELIMITER, customizations.get(EXCLUDE_SCHEMA_NAMES)); + } + + /** + * Gets excluded tables, only if took into consideration (inclusion is not present). + * + * @return the excluded tables + */ + public String getExcludedTables() { + if(!CollectionUtils.isEmpty(customizations.get(INCLUDE_TABLE_NAMES))) { + return ""; + } + return String.join(DELIMITER, customizations.get(EXCLUDE_TABLE_NAMES)); + } + + /** + * Gets excluded view, only if took into consideration (inclusion is not present). + * + * @return the excluded views + */ + public String getExcludedViews() { + if(!CollectionUtils.isEmpty(customizations.get(INCLUDE_VIEW_NAMES))) { + return ""; + } + return String.join(DELIMITER, customizations.get(EXCLUDE_VIEW_NAMES)); + } + + /** + * Gets excluded columns, only if took into consideration (inclusion is not present). + * + * @return the excluded columns + */ + public String getExcludedColumns() { + if(!CollectionUtils.isEmpty(customizations.get(INCLUDE_COLUMN_NAMES))) { + return ""; + } + return String.join(DELIMITER, customizations.get(EXCLUDE_COLUMN_NAMES)); + } + + /** + * Determines if object should be transferred. If it's present in the inclusions, the exclusions are ignored. + * + * @param objectName the object to be transferred + * @param inclusions the list of objects to be included + * @param exclusions the list of objects to be excluded + * @return the boolean + */ + private boolean shouldTransfer(String objectName, List inclusions, List exclusions) { + if(CollectionUtils.isNotEmpty(inclusions)) { + return inclusions.contains(objectName); + } + + if(CollectionUtils.isNotEmpty(exclusions)) { + return !exclusions.contains(objectName); + } + + return true; + } + + private List getCustomization(String key) { + return customizations.get(key); + } + + private void addCustomization(String key, Object customization) { + if(INCLUSION_AND_EXCLUSION_NAMES.contains(key)) { + List processedCustomization = processCustomization(customization); + customizations.put(key, processedCustomization); + } + } + + private List processCustomization(Object customization) { + List processedCustomization = new ArrayList<>(); + if (customization instanceof String) { + processedCustomization.add((String)customization); + } else if (customization instanceof List) { + List intermediary = (List) customization; + for(Object intermediaryObject : intermediary) { + if(intermediaryObject instanceof String) { + processedCustomization.add((String)intermediaryObject); + } + } + } + return processedCustomization; + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcCatalog.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcCatalog.java new file mode 100644 index 00000000000..468e48cd7f3 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcCatalog.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model; + + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Objects; + +/** + * Represents a catalog as returned by the JDBC api. Fields are the ones described in {@link DatabaseMetaData} + */ +public class JdbcCatalog { + + private final String tableCat; + + private JdbcCatalog(String tableCat){ + this.tableCat = tableCat; + } + + public String getTableCat() { + return tableCat; + } + + public static JdbcCatalog create(ResultSet resultSet) throws SQLException { + String tableCat = resultSet.getString("TABLE_CAT"); + + return new JdbcCatalog(tableCat); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if(!(other instanceof JdbcCatalog)){ + return false; + } + + JdbcCatalog other_ = (JdbcCatalog) other; + return Objects.equals(getTableCat(), other_.getTableCat()); + } + + @Override + public int hashCode() { + return Objects.hashCode(tableCat); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcColumn.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcColumn.java new file mode 100644 index 00000000000..1868ce5a21f --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcColumn.java @@ -0,0 +1,218 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Objects; + +/** + * Represents a column as returned by the JDBC api. Fields are the ones described in {@link DatabaseMetaData} + */ +public class JdbcColumn { + + private final String tableCat; + private final String tableSchem; + private final String tableName; + private final String columnName; + private final int dataType; + private final String typeName; + private final int columnSize; + private final int decimalDigits; + private final int numPrecRadix; + private final int nullable; + private final String remarks; + private final String columnDef; + private final int charOctetLength; + private final int ordinalPosition; + private final String isNullable; + private final String scopeCatalog; + private final String scopeSchema; + private final String scopeTable; + private final short sourceDataType; + private final String isAutoIncrement; + private final String isGeneratedColumn; + + private JdbcColumn(String tableCat, String tableSchem, String tableName, String columnName, int dataType, + String typeName, int columnSize, int decimalDigits, int numPrecRadix, int nullable, + String remarks, String columnDef, int charOctetLength, int ordinalPosition, String isNullable, + String scopeCatalog, String scopeSchema, String scopeTable, short sourceDataType, + String isAutoIncrement, String isGeneratedColumn) { + this.tableCat = tableCat; + this.tableSchem = tableSchem; + this.tableName = tableName; + this.columnName = columnName; + this.dataType = dataType; + this.typeName = typeName; + this.columnSize = columnSize; + this.decimalDigits = decimalDigits; + this.numPrecRadix = numPrecRadix; + this.nullable = nullable; + this.remarks = remarks; + this.columnDef = columnDef; + this.charOctetLength = charOctetLength; + this.ordinalPosition = ordinalPosition; + this.isNullable = isNullable; + this.scopeCatalog = scopeCatalog; + this.scopeSchema = scopeSchema; + this.scopeTable = scopeTable; + this.sourceDataType = sourceDataType; + this.isAutoIncrement = isAutoIncrement; + this.isGeneratedColumn = isGeneratedColumn; + } + + public String getTableCat() { + return tableCat; + } + + public String getTableSchem() { + return tableSchem; + } + + public String getTableName() { + return tableName; + } + + public String getColumnName() { + return columnName; + } + + public int getDataType() { + return dataType; + } + + public String getTypeName() { + return typeName; + } + + public int getColumnSize() { + return columnSize; + } + + public int getDecimalDigits() { + return decimalDigits; + } + + public int getNumPrecRadix() { + return numPrecRadix; + } + + public int getNullable() { + return nullable; + } + + public String getRemarks() { + return remarks; + } + + public String getColumnDef() { + return columnDef; + } + + public int getCharOctetLength() { + return charOctetLength; + } + + public int getOrdinalPosition() { + return ordinalPosition; + } + + public String getIsNullable() { + return isNullable; + } + + public String getScopeCatalog() { + return scopeCatalog; + } + + public String getScopeSchema() { + return scopeSchema; + } + + public String getScopeTable() { + return scopeTable; + } + + public short getSourceDataType() { + return sourceDataType; + } + + public String getIsAutoIncrement() { + return isAutoIncrement; + } + + public String getIsGeneratedColumn() { + return isGeneratedColumn; + } + + public static JdbcColumn create(ResultSet resultSet) throws SQLException { + String tableCat = resultSet.getString("TABLE_CAT"); + String tableSchem = resultSet.getString("TABLE_SCHEM"); + String tableName = resultSet.getString("TABLE_NAME"); + String columnName = resultSet.getString("COLUMN_NAME"); + int dataType = resultSet.getInt("DATA_TYPE"); + String typeName = resultSet.getString("TYPE_NAME"); + int columnSize = resultSet.getInt("COLUMN_SIZE"); + int decimalDigits = resultSet.getInt("DECIMAL_DIGITS"); + int numPrecRadix = resultSet.getInt("NUM_PREC_RADIX"); + int nullable = resultSet.getInt("NULLABLE"); + String remarks = resultSet.getString("REMARKS"); + String columnDef = resultSet.getString("COLUMN_DEF"); + int charOctetLength = resultSet.getInt("CHAR_OCTET_LENGTH"); + int ordinalPosition = resultSet.getInt("ORDINAL_POSITION"); + String isNullable = resultSet.getString("IS_NULLABLE"); + String scopeCatalog = resultSet.getString("SCOPE_CATALOG"); + String scopeSchema = resultSet.getString("SCOPE_SCHEMA"); + String scopeTable = resultSet.getString("SCOPE_TABLE"); + short sourceDataType = resultSet.getShort("SOURCE_DATA_TYPE"); + String isAutoIncrement = resultSet.getString("IS_AUTOINCREMENT"); + String isGeneratedColumn = resultSet.getString("IS_GENERATEDCOLUMN"); + + return new JdbcColumn(tableCat, tableSchem, tableName, columnName, dataType, typeName, columnSize, decimalDigits, + numPrecRadix, nullable, remarks, columnDef, charOctetLength, ordinalPosition, isNullable, scopeCatalog, + scopeSchema, scopeTable, sourceDataType, isAutoIncrement, isGeneratedColumn); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if(!(other instanceof JdbcColumn)){ + return false; + } + + JdbcColumn other_ = (JdbcColumn) other; + return Objects.equals(getTableCat(), other_.getTableCat()) && + Objects.equals(getTableSchem(), other_.getTableSchem()) && + Objects.equals(getTableName(), other_.getTableName()) && + Objects.equals(getColumnName(), other_.getColumnName()) && + Objects.equals(getDataType(), other_.getDataType()) && + Objects.equals(getTypeName(), other_.getTypeName()) && + Objects.equals(getColumnSize(), other_.getColumnSize()) && + Objects.equals(getDecimalDigits(), other_.getDecimalDigits()) && + Objects.equals(getNumPrecRadix(), other_.getNumPrecRadix()) && + Objects.equals(getNullable(), other_.getNullable()) && + Objects.equals(getRemarks(), other_.getRemarks()) && + Objects.equals(getColumnDef(), other_.getColumnDef()) && + Objects.equals(getCharOctetLength(), other_.getCharOctetLength()) && + Objects.equals(getOrdinalPosition(), other_.getOrdinalPosition()) && + Objects.equals(getIsNullable(), other_.getIsNullable()) && + Objects.equals(getScopeCatalog(), other_.getScopeCatalog()) && + Objects.equals(getScopeSchema(), other_.getScopeSchema()) && + Objects.equals(getScopeTable(), other_.getScopeTable()) && + Objects.equals(getSourceDataType(), other_.getSourceDataType()) && + Objects.equals(getIsAutoIncrement(), other_.getIsAutoIncrement()) && + Objects.equals(getIsGeneratedColumn(), other_.getIsGeneratedColumn()); + } + + @Override + public int hashCode() { + return Objects.hash(tableCat, tableSchem, tableName, columnName, dataType, typeName, columnSize, decimalDigits, + numPrecRadix, nullable, remarks, columnDef, charOctetLength, ordinalPosition, isNullable, scopeCatalog, scopeSchema, scopeTable, sourceDataType, isAutoIncrement, isGeneratedColumn); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcForeignKey.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcForeignKey.java new file mode 100644 index 00000000000..e4147c50b40 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcForeignKey.java @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Objects; + +/** + * Represents a foreign key as returned by the JDBC api. Fields are the ones described in {@link DatabaseMetaData} + */ +public class JdbcForeignKey { + + private final String pkTableCat; + private final String pkTableSchem; + private final String pkTableName; + private final String pkColumnName; + private final String fkTableCat; + private final String fkTableSchem; + private final String fkTableName; + private final String fkColumnName; + private final short keySeq; + private final String updateRule; + private final String deleteRule; + private final String fkName; + private final String pkName; + private final short deferrability; + + public JdbcForeignKey(String pkTableCat, String pkTableSchem, String pkTableName, String pkColumnName, String fkTableCat, + String fkTableSchem, String fkTableName, String fkColumnName, short keySeq, String updateRule, + String deleteRule, String fkName, String pkName, short deferrability) { + this.pkTableCat = pkTableCat; + this.pkTableSchem = pkTableSchem; + this.pkTableName = pkTableName; + this.pkColumnName = pkColumnName; + this.fkTableCat = fkTableCat; + this.fkTableSchem = fkTableSchem; + this.fkTableName = fkTableName; + this.fkColumnName = fkColumnName; + this.keySeq = keySeq; + this.updateRule = updateRule; + this.deleteRule = deleteRule; + this.fkName = fkName; + this.pkName = pkName; + this.deferrability = deferrability; + } + + public String getPkTableCat() { + return pkTableCat; + } + + public String getPkTableSchem() { + return pkTableSchem; + } + + public String getPkTableName() { + return pkTableName; + } + + public String getPkColumnName() { + return pkColumnName; + } + + public String getFkTableCat() { + return fkTableCat; + } + + public String getFkTableSchem() { + return fkTableSchem; + } + + public String getFkTableName() { + return fkTableName; + } + + public String getFkColumnName() { + return fkColumnName; + } + + public short getKeySeq() { + return keySeq; + } + + public String getUpdateRule() { + return updateRule; + } + + public String getDeleteRule() { + return deleteRule; + } + + public String getFkName() { + return fkName; + } + + public String getPkName() { + return pkName; + } + + public short getDeferrability() { + return deferrability; + } + + public static JdbcForeignKey create(ResultSet resultSet) throws SQLException { + String pkTableCat = resultSet.getString("PKTABLE_CAT"); + String pkTableSchem = resultSet.getString("PKTABLE_SCHEM"); + String pkTableName = resultSet.getString("PKTABLE_NAME"); + String pkColumnName = resultSet.getString("PKCOLUMN_NAME"); + String fkTableCat = resultSet.getString("FKTABLE_CAT"); + String fkTableSchem = resultSet.getString("FKTABLE_SCHEM"); + String fkTableName = resultSet.getString("FKTABLE_NAME"); + String fkColumnName = resultSet.getString("FKCOLUMN_NAME"); + short keySeq = resultSet.getShort("KEY_SEQ"); + String updateRule = resultSet.getString("UPDATE_RULE"); + String deleteRule = resultSet.getString("DELETE_RULE"); + String fkName = resultSet.getString("FK_NAME"); + String pkName = resultSet.getString("PK_NAME"); + short deferrability = resultSet.getShort("DEFERRABILITY"); + + return new JdbcForeignKey(pkTableCat, pkTableSchem, pkTableName, pkColumnName, fkTableCat, fkTableSchem, fkTableName, + fkColumnName, keySeq, updateRule, deleteRule, fkName, pkName, deferrability); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if(!(other instanceof JdbcForeignKey)){ + return false; + } + + JdbcForeignKey other_ = (JdbcForeignKey) other; + return Objects.equals(getPkTableCat(), other_.getPkTableCat()) && + Objects.equals(getPkTableSchem(), other_.getPkTableSchem()) && + Objects.equals(getPkTableName(), other_.getPkTableName()) && + Objects.equals(getPkColumnName(), other_.getPkColumnName()) && + Objects.equals(getFkTableCat(), other_.getFkTableCat()) && + Objects.equals(getFkTableSchem(), other_.getFkTableSchem()) && + Objects.equals(getFkTableName(), other_.getFkTableName()) && + Objects.equals(getFkColumnName(), other_.getFkColumnName()) && + Objects.equals(getKeySeq(), other_.getKeySeq()) && + Objects.equals(getUpdateRule(), other_.getUpdateRule()) && + Objects.equals(getDeleteRule(), other_.getDeleteRule()) && + Objects.equals(getFkName(), other_.getFkName()) && + Objects.equals(getPkName(), other_.getPkName()) && + Objects.equals(getDeferrability(), other_.getDeferrability()); + } + + @Override + public int hashCode() { + return Objects.hash(pkTableCat, pkTableSchem, pkTableName, pkColumnName, fkTableCat, fkTableSchem, fkTableName, + fkColumnName, keySeq, updateRule, deleteRule, fkName, pkName, deferrability); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcPrimaryKey.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcPrimaryKey.java new file mode 100644 index 00000000000..7e469045901 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcPrimaryKey.java @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Objects; + +/** + * Represents a primary key as returned by the JDBC api. Fields are the ones described in {@link DatabaseMetaData} + */ +public class JdbcPrimaryKey { + + private final String tableCat; + private final String tableSchem; + private final String tableName; + private final String columnName; + private final short keySeq; + private final String pkName; + + private JdbcPrimaryKey(String tableCat, String tableSchem, String tableName, String columnName, short keySeq, + String pkName){ + this.tableCat = tableCat; + this.tableSchem = tableSchem; + this.tableName = tableName; + this.columnName = columnName; + this.keySeq = keySeq; + this.pkName = pkName; + } + + public String getTableCat() { + return tableCat; + } + + public String getTableSchem() { + return tableSchem; + } + + public String getTableName() { + return tableName; + } + + public String getColumnName() { + return columnName; + } + + public short getKeySeq() { + return keySeq; + } + + public String getPkName() { + return pkName; + } + + public static JdbcPrimaryKey create(ResultSet resultSet) throws SQLException { + String tableCat = resultSet.getString("TABLE_CAT"); + String tableSchem = resultSet.getString("TABLE_SCHEM"); + String tableName = resultSet.getString("TABLE_NAME"); + String columnName = resultSet.getString("COLUMN_NAME"); + short keySeq = resultSet.getShort("KEY_SEQ"); + String pkName = resultSet.getString("PK_NAME"); + + return new JdbcPrimaryKey(tableCat, tableSchem, tableName, columnName, keySeq, pkName); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if(!(other instanceof JdbcPrimaryKey)){ + return false; + } + + JdbcPrimaryKey other_ = (JdbcPrimaryKey) other; + return Objects.equals(getTableCat(), other_.getTableCat()) && + Objects.equals(getTableSchem(), other_.getTableSchem()) && + Objects.equals(getTableName(), other_.getTableName()) && + Objects.equals(getColumnName(), other_.getColumnName()) && + Objects.equals(getKeySeq(), other_.getKeySeq()) && + Objects.equals(getPkName(), other_.getPkName()); + } + + @Override + public int hashCode() { + return Objects.hash(tableCat, tableSchem, tableName, columnName, keySeq, pkName); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcSchema.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcSchema.java new file mode 100644 index 00000000000..26a959d46e8 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcSchema.java @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Objects; + +/** + * Represents a schema as returned by the JDBC api. Fields are the ones described in {@link DatabaseMetaData} + */ +public class JdbcSchema { + + private final String tableSchem; + private final String tableCatalog; + + private JdbcSchema(String tableSchem, String tableCatalog){ + this.tableSchem = tableSchem; + this.tableCatalog = tableCatalog; + } + + public String getTableSchem() { + return tableSchem; + } + + public String getTableCatalog() { + return tableCatalog; + } + + public static JdbcSchema create(ResultSet resultSet) throws SQLException { + String tableSchem = resultSet.getString("TABLE_SCHEM"); + String tableCat = resultSet.getString("TABLE_CATALOG"); + + return new JdbcSchema(tableSchem, tableCat); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if(!(other instanceof JdbcSchema)){ + return false; + } + + JdbcSchema other_ = (JdbcSchema) other; + return Objects.equals(getTableCatalog(), other_.getTableCatalog()) && + Objects.equals(getTableSchem(), other_.getTableSchem()); + } + + @Override + public int hashCode() { + return Objects.hash(tableSchem, tableCatalog); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcTable.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcTable.java new file mode 100644 index 00000000000..1c882fef2ad --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/model/JdbcTable.java @@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Objects; + +/** + * Represents a table or a view as returned by the JDBC api. Fields are the ones described in {@link DatabaseMetaData} + */ +public class JdbcTable { + + private final String tableCat; + private final String tableSchem; + private final String tableName; + private final String tableType; + private final String remarks; + private final String typeCat; + private final String typeSchem; + private final String typeName; + private final String selfReferencingColName; + private final String refGeneration; + + private JdbcTable(String tableCat, String tableSchem, String tableName, String tableType, String remarks, String typeCat, + String typeSchem, String typeName, String selfReferencingColName, String refGeneration){ + this.tableCat = tableCat; + this.tableSchem = tableSchem; + this. tableName = tableName; + this.tableType = tableType; + this.remarks = remarks; + this.typeCat = typeCat; + this.typeSchem = typeSchem; + this.typeName = typeName; + this.selfReferencingColName = selfReferencingColName; + this.refGeneration = refGeneration; + } + + public String getTableCat() { + return tableCat; + } + + public String getTableSchem() { + return tableSchem; + } + + public String getTableName() { + return tableName; + } + + public String getTableType() { + return tableType; + } + + public String getRemarks() { + return remarks; + } + + public String getTypeCat() { + return typeCat; + } + + public String getTypeSchem() { + return typeSchem; + } + + public String getTypeName() { + return typeName; + } + + public String getSelfReferencingColName() { + return selfReferencingColName; + } + + public String getRefGeneration() { + return refGeneration; + } + + public static JdbcTable create(ResultSet resultSet) throws SQLException { + String tableCat = resultSet.getString("TABLE_CAT"); + String tableSchem = resultSet.getString("TABLE_SCHEM"); + String tableName = resultSet.getString("TABLE_NAME"); + String tableType = resultSet.getString("TABLE_TYPE"); + String remarks = resultSet.getString("REMARKS"); + // issues with below jdbc fields. defaulting to empty string for now + String typeCat = "";//resultSet.getString("TYPE_CAT"); + String typeSchem = "";//resultSet.getString("TYPE_SCHEM"); + String typeName = "";//resultSet.getString("TYPE_NAME"); + String selfReferencingColName = "";//resultSet.getString("SELF_REFERENCING_COL_NAME"); + String refGeneration = "";//resultSet.getString("REF_GENERATION"); + + return new JdbcTable(tableCat, tableSchem, tableName, tableType, remarks, typeCat, typeSchem, typeName, + selfReferencingColName, refGeneration); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if(!(other instanceof JdbcTable)){ + return false; + } + + JdbcTable other_ = (JdbcTable) other; + return Objects.equals(getTableCat(), other_.getTableCat()) && + Objects.equals(getTableSchem(), other_.getTableSchem()) && + Objects.equals(getTableName(), other_.getTableName()) && + Objects.equals(getTableType(), other_.getTableType()) && + Objects.equals(getRemarks(), other_.getRemarks()) && + Objects.equals(getTypeCat(), other_.getTypeCat()) && + Objects.equals(getTypeSchem(), other_.getTypeSchem()) && + Objects.equals(getTypeName(), other_.getTypeName()) && + Objects.equals(getSelfReferencingColName(), other_.getSelfReferencingColName()) && + Objects.equals(getRefGeneration(), other_.getRefGeneration()); + } + + @Override + public int hashCode() { + return Objects.hash(tableCat, tableSchem, tableName, tableType, remarks, typeCat, typeSchem, typeName, + selfReferencingColName, refGeneration); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/Jdbc.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/Jdbc.java new file mode 100644 index 00000000000..390154c5579 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/Jdbc.java @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcCatalog; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcColumn; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcForeignKey; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcPrimaryKey; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcSchema; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcTable; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.util.List; + +/** + * Utility class that delegates requests to jdbc + */ +public class Jdbc { + + public final static String JDBC_CATALOG_KEY = "jdbc.catalog"; + public final static String JDBC_SCHEMA_KEY = "jdbc.schema"; + public final static String JDBC_TABLE_KEY = "jdbc.table"; + public final static String JDBC_COLUMN_KEY = "jdbc.column"; + public final static String JDBC_TABLE_TYPE_KEY = "jdbc.tableType"; + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + public Jdbc(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get username + * + * @return username + */ + public String getUserName(){ + return new JdbcGetUserName(jdbcMetadata, auditLog).get(); + } + + /** + * Get url + * + * @return url + */ + public String getUrl(){ + return new JdbcGetUrl(jdbcMetadata, auditLog).get(); + } + + /** + * Get driver name + * + * @return driver name + */ + public String getDriverName(){ + return new JdbcGetDriverName(jdbcMetadata, auditLog).get(); + } + + /** + * Get database product version + * + * @return database product version + */ + public String getDatabaseProductVersion(){ + return new JdbcGetDatabaseProductVersion(jdbcMetadata, auditLog).get(); + } + + /** + * Get database product name + * + * @return database product name + */ + public String getDatabaseProductName(){ + return new JdbcGetDatabaseProductName(jdbcMetadata, auditLog).get(); + } + + /** + * Get all tables of a schema + * + * @param schemaName schema name + * + * @return tables + */ + public List getTables(String catalog, String schemaName){ + return new JdbcGetTables(jdbcMetadata, auditLog).apply(catalog, schemaName); + } + + /** + * Get all views of a schema + * + * @param schemaName schema name + * + * @return views + */ + public List getViews(String catalog, String schemaName){ + return new JdbcGetViews(jdbcMetadata, auditLog).apply(catalog, schemaName); + } + + /** + * Get foreign keys as described by the primary key columns referenced by foreign key columns of target table + * + * @param catalog catalog + * @param schemaName schema name + * @param tableName table name + * + * @return foreign keys + */ + public List getImportedKeys(String catalog, String schemaName, String tableName){ + return new JdbcGetImportedKeys(jdbcMetadata, auditLog).apply(catalog, schemaName, tableName); + } + + /** + * Get foreign keys as described by the foreign key columns referenced by primary key columns of target table + * + * @param catalog catalog + * @param schemaName schema name + * @param tableName table name + * + * @return foreign keys + */ + public List getExportedKeys(String catalog, String schemaName, String tableName){ + return new JdbcGetExportedKeys(jdbcMetadata, auditLog).apply(catalog, schemaName, tableName); + } + + /** + * Get table primary keys + * + * @param schemaName schema name + * @param tableName table name + * + * @return primary keys + */ + public List getPrimaryKeys(String schemaName, String tableName){ + return new JdbcGetPrimaryKeys(jdbcMetadata, auditLog).apply(schemaName, tableName); + } + + /** + * Get all column of table + * + * @param schemaName schema name + * @param tableName table name + * + * @return columns + */ + public List getColumns(String catalog, String schemaName, String tableName){ + return new JdbcGetColumns(jdbcMetadata, auditLog).apply(catalog, schemaName, tableName); + } + + /** + * Get all schemas + * + * @return schemas + */ + public List getSchemas(String catalog){ + return new JdbcGetSchemas(jdbcMetadata, auditLog).apply(catalog); + } + + /** + * Get all catalogs + * + * @return schemas + */ + public List getCatalogs(){ + return new JdbcGetCatalogs(jdbcMetadata, auditLog).get(); + } + + /** + * Get supported table types + * + * @return table types + */ + public List getTableTypes(){ + return new JdbcGetTableTypes(jdbcMetadata, auditLog).get(); + } +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetCatalogs.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetCatalogs.java new file mode 100644 index 00000000000..1c4b964b18a --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetCatalogs.java @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcCatalog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getSchemas call to jdbc + */ +class JdbcGetCatalogs implements Supplier> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetCatalogs(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get all schemas + * + * @return schemas + */ + @Override + public List get(){ + String methodName = "JdbcGetCatalogs"; + try { + return Optional.ofNullable(jdbcMetadata.getCatalogs()).orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading catalogs from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetColumns.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetColumns.java new file mode 100644 index 00000000000..3e82868a80c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetColumns.java @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.apache.commons.lang3.function.TriFunction; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcColumn; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getColumns call to jdbc + */ +class JdbcGetColumns implements TriFunction> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetColumns(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get all columns from table + * + * @param schemaName schema + * @param tableName table + * + * @return columns or empty list + * + * See {@link JdbcMetadata#getColumns(String, String, String, String)} + */ + @Override + public List apply(String catalog, String schemaName, String tableName){ + String methodName = "JdbcGetColumns"; + try{ + return Optional.ofNullable( + jdbcMetadata.getColumns(catalog, schemaName, tableName, null)) + .orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading columns from JDBC for schema " + schemaName + " and table " + tableName, + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDatabaseProductName.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDatabaseProductName.java new file mode 100644 index 00000000000..b9d5f05e3ac --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDatabaseProductName.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getDatabaseProductName call to jdbc + */ +class JdbcGetDatabaseProductName implements Supplier { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetDatabaseProductName(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get database product name + * + * @return database product name + */ + @Override + public String get(){ + String methodName = "JdbcGetDatabaseProductName"; + try { + return Optional.ofNullable(jdbcMetadata.getDatabaseProductName()).orElseGet(String::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading database product name from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return ""; + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDatabaseProductVersion.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDatabaseProductVersion.java new file mode 100644 index 00000000000..5e7e74e851f --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDatabaseProductVersion.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getDatabaseProductVersion call to jdbc + */ +class JdbcGetDatabaseProductVersion implements Supplier { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetDatabaseProductVersion(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get database product version + * + * @return database product version + */ + @Override + public String get(){ + String methodName = "JdbcGetDatabaseProductVersion"; + try { + return Optional.ofNullable(jdbcMetadata.getDatabaseProductVersion()).orElseGet(String::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading database product version from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return ""; + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDriverName.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDriverName.java new file mode 100644 index 00000000000..d719be0ee30 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetDriverName.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getDriverName call to jdbc + */ +class JdbcGetDriverName implements Supplier { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetDriverName(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get driver name + * + * @return driver name + */ + @Override + public String get(){ + String methodName = "JdbcGetDriverName"; + try { + return Optional.ofNullable(jdbcMetadata.getDriverName()).orElseGet(String::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading driver name from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return ""; + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetExportedKeys.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetExportedKeys.java new file mode 100644 index 00000000000..81f1ff8a112 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetExportedKeys.java @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.apache.commons.lang3.function.TriFunction; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcForeignKey; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getExportedKeys call to jdbc + */ +class JdbcGetExportedKeys implements TriFunction> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetExportedKeys(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get foreign keys as described by the foreign key columns referenced by primary key columns of target table + * + * @param schemaName schema name + * @param tableName table name + * + * @return foreign keys + */ + @Override + public List apply(String catalog, String schemaName, String tableName) { + String methodName = "JdbcGetExportedKeys"; + try { + return Optional.ofNullable(jdbcMetadata.getExportedKeys(catalog, schemaName, tableName)) + .orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading exported keys from JDBC for catalog " + catalog + ", schema" + schemaName + " and table " + tableName, + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetImportedKeys.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetImportedKeys.java new file mode 100644 index 00000000000..3982152e9d8 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetImportedKeys.java @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.apache.commons.lang3.function.TriFunction; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcForeignKey; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getImportedKeys call to jdbc + */ +class JdbcGetImportedKeys implements TriFunction> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetImportedKeys(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get foreign keys as described by the primary key columns referenced by foreign key columns of target table + * + * @param schemaName schema name + * @param tableName table name + * + * @return foreign keys + */ + @Override + public List apply(String catalog, String schemaName, String tableName) { + String methodName = "JdbcGetImportedKeys"; + try { + return Optional.ofNullable(jdbcMetadata.getImportedKeys(catalog, schemaName, tableName)) + .orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading imported keys from JDBC for catalog " + catalog + ", schema " + schemaName + " and table " + tableName, + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetPrimaryKeys.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetPrimaryKeys.java new file mode 100644 index 00000000000..62002811396 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetPrimaryKeys.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcPrimaryKey; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getPrimaryKeys call to jdbc + */ +class JdbcGetPrimaryKeys implements BiFunction> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetPrimaryKeys(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get table primary keys + * + * @param schemaName schema name + * @param tableName table name + * + * @return primary keys + */ + @Override + public List apply(String schemaName, String tableName){ + String methodName = "JdbcGetPrimaryKeys"; + try{ + return Optional.ofNullable( + jdbcMetadata.getPrimaryKeys(null, schemaName, tableName)) + .orElseGet(ArrayList::new); + }catch (SQLException sqlException){ + auditLog.logException("Reading primary keys from JDBC for schema " + schemaName + " and table " + tableName, + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + + return new ArrayList<>(); + } +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetSchemas.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetSchemas.java new file mode 100644 index 00000000000..756c67bda64 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetSchemas.java @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcSchema; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getSchemas call to jdbc + */ +class JdbcGetSchemas implements Function> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetSchemas(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get all schemas + * + * @return schemas + */ + @Override + public List apply(String catalog){ + String methodName = "JdbcGetSchemas"; + try { + return Optional.ofNullable(jdbcMetadata.getSchemas(catalog, null)).orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading schemas from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetTableTypes.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetTableTypes.java new file mode 100644 index 00000000000..0f3eaccaed5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetTableTypes.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getUrl call to jdbc + */ +class JdbcGetTableTypes implements Supplier> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetTableTypes(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get url + * + * @return url + */ + @Override + public List get(){ + String methodName = "JdbcGetTableTypes"; + try { + return Optional.ofNullable(jdbcMetadata.getTableTypes()).orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading table types from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetTables.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetTables.java new file mode 100644 index 00000000000..c44a50359ed --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetTables.java @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcTable; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getTables call to jdbc to extract tables + */ +public class JdbcGetTables implements BiFunction> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetTables(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get all tables of a schema + * + * @param schemaName schema name + * + * @return tables + */ + @Override + public List apply(String catalog, String schemaName) { + String methodName = "JdbcGetTables"; + try { + return Optional.ofNullable( + jdbcMetadata.getTables(catalog, schemaName, null, new String[]{"TABLE", "FOREIGN TABLE"})) + .orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading tables from JDBC for schema: " + schemaName, + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetUrl.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetUrl.java new file mode 100644 index 00000000000..2e4e25d7650 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetUrl.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getUrl call to jdbc + */ +class JdbcGetUrl implements Supplier { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetUrl(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get url + * + * @return url + */ + @Override + public String get(){ + String methodName = "JdbcGetUrl"; + try { + return Optional.ofNullable(jdbcMetadata.getUrl()).orElseGet(String::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading url from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return ""; + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetUserName.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetUserName.java new file mode 100644 index 00000000000..86202a17c5c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetUserName.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.Optional; +import java.util.function.Supplier; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getUserName call to jdbc + */ +class JdbcGetUserName implements Supplier { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetUserName(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get user name + * + * @return user name + */ + @Override + public String get(){ + String methodName = "JdbcGetUserName"; + try { + return Optional.ofNullable(jdbcMetadata.getUserName()).orElseGet(String::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading user name from JDBC", + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return ""; + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetViews.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetViews.java new file mode 100644 index 00000000000..dc16d0ab947 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/JdbcGetViews.java @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.JdbcMetadata; +import org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.model.JdbcTable; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_JDBC; + +/** + * Manages the getTables call to jdbc to extract views + */ +public class JdbcGetViews implements BiFunction> { + + private final JdbcMetadata jdbcMetadata; + private final AuditLog auditLog; + + JdbcGetViews(JdbcMetadata jdbcMetadata, AuditLog auditLog) { + this.jdbcMetadata = jdbcMetadata; + this.auditLog = auditLog; + } + + /** + * Get all tables of a schema + * + * @param schemaName schema name + * + * @return tables + */ + @Override + public List apply(String catalog, String schemaName) { + String methodName = "JdbcGetViews"; + try { + return Optional.ofNullable( + jdbcMetadata.getTables(catalog, schemaName, null, new String[]{"VIEW", "MATERIALIZED VIEW"})) + .orElseGet(ArrayList::new); + } catch (SQLException sqlException) { + auditLog.logException("Reading views from JDBC for schema: " + schemaName, + EXCEPTION_READING_JDBC.getMessageDefinition(methodName, sqlException.getMessage()), sqlException); + } + return new ArrayList<>(); + } + +} \ No newline at end of file diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/Omas.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/Omas.java new file mode 100644 index 00000000000..1a6919beb25 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/Omas.java @@ -0,0 +1,378 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ConnectionElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ConnectorTypeElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseSchemaElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseViewElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.EndpointElement; +import org.odpi.openmetadata.accessservices.datamanager.properties.ConnectionProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseColumnProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseForeignKeyProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabasePrimaryKeyProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseSchemaProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseTableProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseViewProperties; +import org.odpi.openmetadata.accessservices.datamanager.properties.EndpointProperties; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.List; +import java.util.Optional; + +/** + * Utility class that delegates requests to designated access service + */ +public class Omas { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + public Omas(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get schemas of database + * + * @param databaseGuid database guid + * + * @return schemas + */ + public List getSchemas(String databaseGuid){ + return new OmasGetSchemas(databaseIntegratorContext, auditLog).apply(databaseGuid); + } + + /** + * Get tables + * + * @param assetGuid database or schema guid + * + * @return tables + */ + public List getTables(String assetGuid){ + return new OmasGetTables(databaseIntegratorContext, auditLog).apply(assetGuid); + } + + /** + * Get views + * + * @param assetGuid database or schema guid + * + * @return tables + */ + public List getViews(String assetGuid){ + return new OmasGetViews(databaseIntegratorContext, auditLog).apply(assetGuid); + } + + /** + * Get columns of table + * + * @param tableGuid table guid + * + * @return columns + */ + public List getColumns(String tableGuid){ + return new OmasGetColumns(databaseIntegratorContext, auditLog).apply(tableGuid); + } + + /** + * Create endpoint + * + * @param newEndpointProperties properties + * + * @return guid + */ + public Optional createEndpoint(EndpointProperties newEndpointProperties){ + return new OmasCreateEndpoint(databaseIntegratorContext, auditLog).apply(newEndpointProperties); + } + + /** + * Create connection + * + * @param newConnectionProperties properties + * + * @return guid + */ + public Optional createConnection(ConnectionProperties newConnectionProperties){ + return new OmasCreateConnection(databaseIntegratorContext, auditLog).apply(newConnectionProperties); + } + + /** + * Create database + * + * @param newDatabaseProperties properties + * + * @return guid + */ + public Optional createDatabase(DatabaseProperties newDatabaseProperties){ + return new OmasCreateDatabase(databaseIntegratorContext, auditLog).apply(newDatabaseProperties); + } + + /** + * Create schema in database + * + * @param databaseGuid database guid + * @param newSchemaProperties properties + * + * @return guid + */ + public Optional createSchema(String databaseGuid, DatabaseSchemaProperties newSchemaProperties){ + return new OmasCreateSchema(databaseIntegratorContext, auditLog).apply(databaseGuid, newSchemaProperties); + } + + /** + * Create table + * + * @param schemaGuid schema guid + * @param newTableProperties properties + * + * @return guid + */ + public Optional createTable(String schemaGuid, DatabaseTableProperties newTableProperties){ + return new OmasCreateTable(databaseIntegratorContext, auditLog).apply(schemaGuid, newTableProperties); + } + + /** + * Create view + * + * @param parentGuid parent guid + * @param newViewProperties properties + * + * @return guid + */ + public Optional createView(String parentGuid, DatabaseViewProperties newViewProperties){ + return new OmasCreateView(databaseIntegratorContext, auditLog).apply(parentGuid, newViewProperties); + } + + /** + * Create column in table + * + * @param tableGuid table guid + * @param newColumnProperties properties + * + * @return guid + */ + public Optional createColumn(String tableGuid, DatabaseColumnProperties newColumnProperties){ + return new OmasCreateColumn(databaseIntegratorContext, auditLog).apply(tableGuid, newColumnProperties); + } + + /** + * Remove schema + * + * @param schemaElement schema + */ + public void removeSchema(DatabaseSchemaElement schemaElement) { + new OmasRemoveSchema(databaseIntegratorContext, auditLog).accept(schemaElement); + } + + /** + * Remove table + * + * @param tableElement table + */ + public void removeTable(DatabaseTableElement tableElement) { + new OmasRemoveTable(databaseIntegratorContext, auditLog).accept(tableElement); + } + + /** + * Remove view + * + * @param viewElement view + */ + public void removeView(DatabaseViewElement viewElement) { + new OmasRemoveView(databaseIntegratorContext, auditLog).accept(viewElement); + } + + /** + * Remove column + * + * @param columnElement column + */ + public void removeColumn(DatabaseColumnElement columnElement) { + new OmasRemoveColumn(databaseIntegratorContext, auditLog).accept(columnElement); + } + + /** + * Update database + * + * @param databaseGuid guid + * @param databaseProperties properties + */ + public void updateDatabase(String databaseGuid, DatabaseProperties databaseProperties){ + new OmasUpdateDatabase(databaseIntegratorContext, auditLog).accept(databaseGuid, databaseProperties); + } + + /** + * Update schema + * + * @param schemaGuid guid + * @param schemaProperties properties + */ + public void updateSchema(String schemaGuid, DatabaseSchemaProperties schemaProperties){ + new OmasUpdateSchema(databaseIntegratorContext, auditLog).accept(schemaGuid, schemaProperties); + } + + /** + * Update table + * + * @param tableGuid guid + * @param tableProperties properties + */ + public void updateTable(String tableGuid, DatabaseTableProperties tableProperties){ + new OmasUpdateTable(databaseIntegratorContext, auditLog).accept(tableGuid, tableProperties); + } + + /** + * Update view + * + * @param viewGuid guid + * @param viewProperties properties + */ + public void updateView(String viewGuid, DatabaseViewProperties viewProperties){ + new OmasUpdateView(databaseIntegratorContext, auditLog).accept(viewGuid, viewProperties); + } + + /** + * Update column + * + * @param columnGuid guid + * @param columnProperties properties + */ + public void updateColumn(String columnGuid, DatabaseColumnProperties columnProperties){ + new OmasUpdateColumn(databaseIntegratorContext, auditLog).accept(columnGuid, columnProperties); + } + + /** + * Set primary key + * + * @param columnGuid guid + * @param primaryKeyProperties properties + */ + public void setPrimaryKey(String columnGuid, DatabasePrimaryKeyProperties primaryKeyProperties) { + new OmasSetPrimaryKey(databaseIntegratorContext, auditLog).accept(columnGuid, primaryKeyProperties); + } + + /** + * Remove primary key + * + * @param columnGuid guid + */ + public void removePrimaryKey(String columnGuid) { + new OmasRemovePrimaryKey(databaseIntegratorContext, auditLog).accept(columnGuid); + } + + /** + * Set foreign key + * + * @param primaryKeyColumnGuid guid + * @param foreignKeyColumnGuid guid + * @param foreignKeyProperties properties + */ + public void setForeignKey(String primaryKeyColumnGuid, String foreignKeyColumnGuid, DatabaseForeignKeyProperties foreignKeyProperties) { + new OmasSetForeignKey(databaseIntegratorContext, auditLog).accept(primaryKeyColumnGuid, foreignKeyColumnGuid, foreignKeyProperties); + } + + /** + * Remove foreign key + * + * @param primaryKeyColumnGuid guid + * @param foreignKeyColumnGuid guid + */ + public void removeForeignKey(String primaryKeyColumnGuid, String foreignKeyColumnGuid) { + new OmasRemoveForeignKey(databaseIntegratorContext, auditLog).accept(primaryKeyColumnGuid, foreignKeyColumnGuid); + } + + /** + * Get databases + * + * @param databaseQualifiedName qualified name + * + * @return databases + */ + public List getDatabasesByName(String databaseQualifiedName){ + return new OmasGetDatabasesByName(databaseIntegratorContext, auditLog).apply(databaseQualifiedName); + } + + /** + * Get connector types by name + * + * @param connectorTypeQualifiedName qualified name + * + * @return connector types + */ + public List getConnectorTypesByName(String connectorTypeQualifiedName){ + return new OmasGetConnectorTypesByName(databaseIntegratorContext, auditLog).apply(connectorTypeQualifiedName); + } + + /** + * Get connection by name + * + * @param connectionQualifiedName qualified name + * + * @return connections + */ + public List getConnectionsByName(String connectionQualifiedName){ + return new OmasGetConnectionsByName(databaseIntegratorContext, auditLog).apply(connectionQualifiedName); + } + + /** + * Find endpoints + * + * @param searchBy criteria + * + * @return endpoints + */ + public List findEndpoints(String searchBy){ + return new OmasFindEndpoints(databaseIntegratorContext, auditLog).apply(searchBy); + } + + /** + * Find columns + * + * @param searchBy criteria + * + * @return columns + */ + public List findDatabaseColumns(String searchBy){ + return new OmasFindDatabaseColumns(databaseIntegratorContext, auditLog).apply(searchBy); + } + + /** + * Setup connector type + * + * @param connectionGuid guid + * @param connectorTypeGuid guid + */ + public void setupConnectorType(String connectionGuid, String connectorTypeGuid){ + new OmasSetupConnectorType(databaseIntegratorContext, auditLog).accept(connectionGuid, connectorTypeGuid); + } + + /** + * Setup asset connection + * + * @param assetGuid guid + * @param assetSummary summary + * @param connectionGuid guid + */ + public void setupAssetConnection(String assetGuid, String assetSummary, String connectionGuid){ + new OmasSetupAssetConnection(databaseIntegratorContext, auditLog).accept(assetGuid, assetSummary, connectionGuid); + } + + /** + * Setup endpoint + * + * @param connectionGuid guid + * @param endpointGuid guid + */ + public void setupEndpoint(String connectionGuid, String endpointGuid){ + new OmasSetupEndpoint(databaseIntegratorContext, auditLog).accept(connectionGuid, endpointGuid); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateColumn.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateColumn.java new file mode 100644 index 00000000000..1e639c6f170 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateColumn.java @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseColumnProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createDatabaseColumn call to access service + */ +class OmasCreateColumn implements BiFunction> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateColumn(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create column in table + * + * @param tableGuid table guid + * @param newColumnProperties properties + * + * @return guid + */ + @Override + public Optional apply(String tableGuid, DatabaseColumnProperties newColumnProperties){ + String methodName = "OmasCreateColumn"; + try { + return Optional.ofNullable( + databaseIntegratorContext.createDatabaseColumn(tableGuid, newColumnProperties)); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Creating column with qualified name " + newColumnProperties.getQualifiedName() + + " in table with guid " + tableGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + + + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateConnection.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateConnection.java new file mode 100644 index 00000000000..48ac8106b9a --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateConnection.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.ConnectionProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createConnection call to access service + */ +class OmasCreateConnection implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateConnection(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create connection + * + * @param newConnectionProperties properties + * + * @return guid + */ + @Override + public Optional apply(ConnectionProperties newConnectionProperties){ + String methodName = "OmasCreateConnection"; + try { + return Optional.ofNullable( + databaseIntegratorContext.createConnection(newConnectionProperties)); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Creating connection with qualified name " + newConnectionProperties.getQualifiedName(), + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + + + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateDatabase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateDatabase.java new file mode 100644 index 00000000000..adcb1f72108 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateDatabase.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createDatabase call to access service + */ +class OmasCreateDatabase implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateDatabase(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create database + * + * @param newDatabaseProperties properties + * + * @return guid + */ + @Override + public Optional apply(DatabaseProperties newDatabaseProperties){ + String methodName = "OmasCreateDatabase"; + try { + return Optional.ofNullable( + databaseIntegratorContext.createDatabase(newDatabaseProperties)); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Creating database with qualified name " + newDatabaseProperties.getQualifiedName(), + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + + + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateEndpoint.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateEndpoint.java new file mode 100644 index 00000000000..863c2dcda57 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateEndpoint.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.EndpointProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createEndpoint call to access service + */ +class OmasCreateEndpoint implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateEndpoint(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create endpoint + * + * @param newEndpointProperties properties + * + * @return guid + */ + @Override + public Optional apply(EndpointProperties newEndpointProperties){ + String methodName = "OmasCreateEndpoint"; + try { + return Optional.ofNullable( + databaseIntegratorContext.createEndpoint(newEndpointProperties)); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Creating endpoint with qualified name " + newEndpointProperties.getQualifiedName(), + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + + + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateSchema.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateSchema.java new file mode 100644 index 00000000000..b742a099745 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateSchema.java @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseSchemaProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createDatabaseSchema call to access service + */ +class OmasCreateSchema implements BiFunction> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateSchema(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create schema in database + * + * @param databaseGuid database guid + * @param newSchemaProperties properties + * + * @return guid + */ + @Override + public Optional apply(String databaseGuid, DatabaseSchemaProperties newSchemaProperties){ + String methodName = "OmasCreateSchema"; + try { + return Optional.ofNullable(databaseIntegratorContext.createDatabaseSchema(databaseGuid, newSchemaProperties)); + } catch (InvalidParameterException | PropertyServerException | UserNotAuthorizedException e) { + auditLog.logException("Creating schema with qualified name " + newSchemaProperties.getQualifiedName() + + " in database with guid " + databaseGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateTable.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateTable.java new file mode 100644 index 00000000000..16604164d48 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateTable.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseTableProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createDatabaseTable call to access service + */ +class OmasCreateTable implements BiFunction> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateTable(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create table in schema + * + * @param parentGuid schema guid + * @param newTableProperties properties + * + * @return guid + */ + @Override + public Optional apply(String parentGuid, DatabaseTableProperties newTableProperties){ + String methodName = "OmasCreateTable"; + + try { + return Optional.ofNullable(databaseIntegratorContext.createDatabaseTable(parentGuid, newTableProperties)); + } catch (InvalidParameterException | PropertyServerException | UserNotAuthorizedException e) { + auditLog.logException("Creating table with qualified name " + newTableProperties.getQualifiedName() + + " in parent with guid " + parentGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateView.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateView.java new file mode 100644 index 00000000000..41f5f124b1e --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasCreateView.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseViewProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.Optional; +import java.util.function.BiFunction; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the createDatabaseView call to access service + */ +class OmasCreateView implements BiFunction> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasCreateView(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Create table in schema + * + * @param parentGuid schema guid + * @param newViewProperties properties + * + * @return guid + */ + @Override + public Optional apply(String parentGuid, DatabaseViewProperties newViewProperties){ + String methodName = "OmasCreateView"; + + try { + return Optional.ofNullable(databaseIntegratorContext.createDatabaseView(parentGuid, newViewProperties)); + } catch (InvalidParameterException | PropertyServerException | UserNotAuthorizedException e) { + auditLog.logException("Creating view with qualified name " + newViewProperties.getQualifiedName() + + " in parent with guid " + parentGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return Optional.empty(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasFindDatabaseColumns.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasFindDatabaseColumns.java new file mode 100644 index 00000000000..9552c88a753 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasFindDatabaseColumns.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the findDatabaseColumns call to access service + */ +class OmasFindDatabaseColumns implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasFindDatabaseColumns(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Find columns + * + * @param searchBy criteria + * + * @return columns + */ + @Override + public List apply(String searchBy){ + String methodName = "OmasFindDatabaseColumns"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.findDatabaseColumns(searchBy, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Reading columns with name " + searchBy, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasFindEndpoints.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasFindEndpoints.java new file mode 100644 index 00000000000..4d11bb3fdef --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasFindEndpoints.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.EndpointElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the findEndpoints call to access service + */ +class OmasFindEndpoints implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasFindEndpoints(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Find endpoints + * + * @param searchBy criteria + * + * @return endpoints + */ + @Override + public List apply(String searchBy){ + String methodName = "OmasFindEndpoints"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.findEndpoints(searchBy, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Reading endpoints with name " + searchBy, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetColumns.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetColumns.java new file mode 100644 index 00000000000..82f8eae0847 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetColumns.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getColumnsForDatabaseTable call to access service + */ +class OmasGetColumns implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetColumns(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get columns of table + * + * @param tableGuid table guid + * + * @return columns + */ + @Override + public List apply(String tableGuid){ + String methodName = "OmasGetColumns"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.getColumnsForDatabaseTable(tableGuid, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Reading columns from table with guid " + tableGuid , + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetConnectionsByName.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetConnectionsByName.java new file mode 100644 index 00000000000..3095612674d --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetConnectionsByName.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ConnectionElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getConnectionsByName call to access service + */ +class OmasGetConnectionsByName implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetConnectionsByName(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get connection by name + * + * @param connectionQualifiedName qualified name + * + * @return connections + */ + @Override + public List apply(String connectionQualifiedName){ + String methodName = "OmasGetConnectionsByName"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.getConnectionsByName(connectionQualifiedName, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logMessage("Reading connection with qualified name " + connectionQualifiedName, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage())); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetConnectorTypesByName.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetConnectorTypesByName.java new file mode 100644 index 00000000000..44a669184ee --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetConnectorTypesByName.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ConnectorTypeElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getConnectorTypesByName call to access service + */ +class OmasGetConnectorTypesByName implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetConnectorTypesByName(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get connector types by name + * + * @param connectorTypeQualifiedName qualified name + * + * @return connector types + */ + @Override + public List apply(String connectorTypeQualifiedName){ + String methodName = "OmasGetConnectorTypesByName"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.getConnectorTypesByName(connectorTypeQualifiedName, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logMessage("Reading connector type with qualified name " + connectorTypeQualifiedName, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage())); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetDatabasesByName.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetDatabasesByName.java new file mode 100644 index 00000000000..02d015ae0f5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetDatabasesByName.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getDatabasesByName call to access service + */ +class OmasGetDatabasesByName implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetDatabasesByName(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get databases + * + * @param databaseQualifiedName qualified name + * + * @return databases + */ + @Override + public List apply(String databaseQualifiedName){ + String methodName = "OmasGetDatabasesByName"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.getDatabasesByName(databaseQualifiedName, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logMessage("Reading database with qualified name " + databaseQualifiedName, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage())); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetSchemas.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetSchemas.java new file mode 100644 index 00000000000..6d6275c03e6 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetSchemas.java @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseSchemaElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getSchemasForDatabase call to access service + */ +class OmasGetSchemas implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetSchemas(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get schemas of database + * + * @param databaseGuid database guid + * + * @return schemas + */ + @Override + public List apply(String databaseGuid){ + String methodName = "OmasGetSchemasForDatabase"; + try{ + return Optional.ofNullable( + databaseIntegratorContext.getSchemasForDatabase(databaseGuid, 0, 0)) + .orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Reading schemas from database with guid " + databaseGuid, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetTables.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetTables.java new file mode 100644 index 00000000000..c937346629f --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetTables.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getTablesForDatabaseAsset call to access service + */ +class OmasGetTables implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetTables(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get tables of schema + * + * @param assetGuid database or schema guid + * + * @return tables + */ + @Override + public List apply(String assetGuid){ + String methodName = "OmasGetTables"; + try{ + return Optional.ofNullable(databaseIntegratorContext + .getTablesForDatabaseAsset(assetGuid, 0, 0)).orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Reading tables for assetGuid: " + assetGuid, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetViews.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetViews.java new file mode 100644 index 00000000000..10bef4b045b --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasGetViews.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseViewElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_READING_OMAS; + +/** + * Manages the getViewsForDatabaseAsset call to access service + */ +class OmasGetViews implements Function> { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasGetViews(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Get views of schema + * + * @param assetGuid database or schema guid + * + * @return tables + */ + @Override + public List apply(String assetGuid){ + String methodName = "OmasGetViews"; + try{ + return Optional.ofNullable(databaseIntegratorContext + .getViewsForDatabaseAsset(assetGuid, 0, 0)).orElseGet(ArrayList::new); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Reading views for assetGuid: " + assetGuid, + EXCEPTION_READING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + return new ArrayList<>(); + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveColumn.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveColumn.java new file mode 100644 index 00000000000..971ffddce54 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveColumn.java @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.Consumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS; + +/** + * Manages the removeDatabaseColumn call to access service + */ +class OmasRemoveColumn implements Consumer +{ + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasRemoveColumn(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog) + { + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Remove column + * + * @param columnElement column + */ + @Override + public void accept(DatabaseColumnElement columnElement) + { + String columnGuid = columnElement.getElementHeader().getGUID(); + String columnQualifiedName = columnElement.getDatabaseColumnProperties().getQualifiedName(); + try + { + databaseIntegratorContext.removePrimaryKeyFromColumn(columnGuid); + databaseIntegratorContext.removeDatabaseColumn(columnGuid); + } + catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) + { + auditLog.logMessage("Removing column with guid " + columnGuid + + " and qualified name " + columnQualifiedName, + EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS.getMessageDefinition(columnGuid, columnQualifiedName)); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveForeignKey.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveForeignKey.java new file mode 100644 index 00000000000..8a5637492b5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveForeignKey.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the addForeignKeyRelationship call to access service + */ +class OmasRemoveForeignKey implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasRemoveForeignKey(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Remove foreign key + * + * @param primaryKeyColumnGuid guid + * @param foreignKeyColumnGuid guid + */ + @Override + public void accept(String primaryKeyColumnGuid, String foreignKeyColumnGuid) { + String methodName = "OmasRemoveForeignKey"; + try{ + databaseIntegratorContext.removeForeignKeyRelationship(primaryKeyColumnGuid, foreignKeyColumnGuid); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Removing foreign key in OMAS for primary key column guid " + primaryKeyColumnGuid + + " and foreign key column guid " + foreignKeyColumnGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemovePrimaryKey.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemovePrimaryKey.java new file mode 100644 index 00000000000..1085481b936 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemovePrimaryKey.java @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.Consumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the setPrimaryKeyOnColumn call to access service + */ +class OmasRemovePrimaryKey implements Consumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasRemovePrimaryKey(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Set primary key + * + * @param columnGuid guid + */ + @Override + public void accept(String columnGuid ) { + String methodName = "OmasRemovePrimaryKey"; + try{ + databaseIntegratorContext.removePrimaryKeyFromColumn(columnGuid); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Removing primary key from column with guid " + columnGuid , + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveSchema.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveSchema.java new file mode 100644 index 00000000000..7ab94c270fa --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveSchema.java @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseSchemaElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.List; +import java.util.function.Consumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS; + +/** + * Manages the removeDatabaseSchema call to access service + */ +class OmasRemoveSchema implements Consumer +{ + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasRemoveSchema(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog) + { + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Remove schema + * + * @param schemaElement schema + */ + @Override + public void accept(DatabaseSchemaElement schemaElement) + { + String schemaGuid = schemaElement.getElementHeader().getGUID(); + String schemaQualifiedName = schemaElement.getDatabaseSchemaProperties().getQualifiedName(); + try + { + List tables = new OmasGetTables(databaseIntegratorContext, auditLog).apply(schemaGuid); + tables.forEach(new OmasRemoveTable(databaseIntegratorContext, auditLog)); + + databaseIntegratorContext.removeDatabaseSchema(schemaGuid); + } + catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) + { + auditLog.logMessage("Removing schema with guid " + schemaGuid + + " and qualified name " + schemaQualifiedName, + EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS.getMessageDefinition(schemaGuid, schemaQualifiedName)); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveTable.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveTable.java new file mode 100644 index 00000000000..0eef7af5f57 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveTable.java @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseColumnElement; +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseTableElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.List; +import java.util.function.Consumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS; + +/** + * Manages the removeDatabaseTable call to access service + */ +class OmasRemoveTable implements Consumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasRemoveTable(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Remove table + * + * @param tableElement table + */ + @Override + public void accept(DatabaseTableElement tableElement) { + String tableGuid = tableElement.getElementHeader().getGUID(); + String tableQualifiedName = tableElement.getDatabaseTableProperties().getQualifiedName(); + try { + List columns = databaseIntegratorContext.getColumnsForDatabaseTable(tableGuid, 0, 0); + columns.forEach(new OmasRemoveColumn(databaseIntegratorContext, auditLog)); + + databaseIntegratorContext.removeDatabaseTable(tableGuid); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logMessage("Removing table with guid " + tableGuid + + " and qualified name " + tableQualifiedName, + EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS.getMessageDefinition(tableGuid, tableQualifiedName)); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveView.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveView.java new file mode 100644 index 00000000000..c1e1d810c95 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasRemoveView.java @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.metadataelements.DatabaseViewElement; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.Consumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS; + +/** + * Manages the removeDatabaseTable call to access service + */ +class OmasRemoveView implements Consumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasRemoveView(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Remove table + * + * @param viewElement view + */ + @Override + public void accept(DatabaseViewElement viewElement) { + String viewGuid = viewElement.getElementHeader().getGUID(); + String viewQualifiedName = viewElement.getDatabaseViewProperties().getQualifiedName(); + try { + databaseIntegratorContext.removeDatabaseView(viewGuid); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logMessage("Removing view with guid " + viewGuid + + " and qualified name " + viewQualifiedName, + EXCEPTION_WHEN_REMOVING_ELEMENT_IN_OMAS.getMessageDefinition(viewGuid, viewQualifiedName)); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetForeignKey.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetForeignKey.java new file mode 100644 index 00000000000..2489ca78fb5 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetForeignKey.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseForeignKeyProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the addForeignKeyRelationship call to access service + */ +class OmasSetForeignKey implements TriConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasSetForeignKey(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Set foreign key + * + * @param primaryKeyColumnGuid guid + * @param foreignKeyColumnGuid guid + * @param foreignKeyProperties properties + */ + @Override + public void accept(String primaryKeyColumnGuid, String foreignKeyColumnGuid, DatabaseForeignKeyProperties foreignKeyProperties) { + String methodName = "OmasSetForeignKey"; + try{ + databaseIntegratorContext.addForeignKeyRelationship(primaryKeyColumnGuid, foreignKeyColumnGuid, foreignKeyProperties); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Setting foreign key in OMAS for primary key column guid " + primaryKeyColumnGuid + + " and foreign key column guid " + foreignKeyColumnGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetPrimaryKey.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetPrimaryKey.java new file mode 100644 index 00000000000..5e583b55e5a --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetPrimaryKey.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabasePrimaryKeyProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the setPrimaryKeyOnColumn call to access service + */ +class OmasSetPrimaryKey implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasSetPrimaryKey(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Set primary key + * + * @param columnGuid guid + * @param primaryKeyProperties properties + */ + @Override + public void accept(String columnGuid, DatabasePrimaryKeyProperties primaryKeyProperties) { + String methodName = "OmasSetPrimaryKey"; + try{ + databaseIntegratorContext.setPrimaryKeyOnColumn(columnGuid, primaryKeyProperties); + } catch (UserNotAuthorizedException | InvalidParameterException | PropertyServerException e) { + auditLog.logException("Setting primary key on column with guid " + columnGuid , + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupAssetConnection.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupAssetConnection.java new file mode 100644 index 00000000000..f567a01d2f4 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupAssetConnection.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the setupAssetConnection call to access service + */ +class OmasSetupAssetConnection implements TriConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasSetupAssetConnection(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Setup asset connection + * + * @param assetGuid guid + * @param assetSummary summary + * @param connectionGuid guid + */ + @Override + public void accept(String assetGuid, String assetSummary, String connectionGuid){ + String methodName = "OmasSetupAssetConnection"; + try { + databaseIntegratorContext.setupAssetConnection(assetGuid, assetSummary, connectionGuid); + } catch (InvalidParameterException | PropertyServerException | UserNotAuthorizedException e) { + auditLog.logException("Setting up asset connection for asset with guid " + assetGuid + + ", with summary " + assetSummary + + ", and connection with guid " + connectionGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupConnectorType.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupConnectorType.java new file mode 100644 index 00000000000..0eb9ec3f3b0 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupConnectorType.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the setupConnectorType call to access service + */ +class OmasSetupConnectorType implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasSetupConnectorType(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Setup connector type + * + * @param connectionGuid guid + * @param connectorTypeGuid guid + */ + @Override + public void accept(String connectionGuid, String connectorTypeGuid){ + String methodName = "OmasSetupConnectorType"; + try { + databaseIntegratorContext.setupConnectorType(connectionGuid, connectorTypeGuid); + } catch (InvalidParameterException | PropertyServerException | UserNotAuthorizedException e) { + auditLog.logException("Setting connector type for connection with guid " + connectionGuid + + " and connector type with guid " + connectorTypeGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupEndpoint.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupEndpoint.java new file mode 100644 index 00000000000..298a5a6400c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasSetupEndpoint.java @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the setupEndpoint call to access service + */ +class OmasSetupEndpoint implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasSetupEndpoint(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Setup endpoint + * + * @param connectionGuid guid + * @param endpointGuid guid + */ + @Override + public void accept(String connectionGuid, String endpointGuid){ + String methodName = "OmasSetupEndpoint"; + try { + databaseIntegratorContext.setupEndpoint(connectionGuid, endpointGuid); + } catch (InvalidParameterException | PropertyServerException | UserNotAuthorizedException e) { + auditLog.logException("Setting endpoint for connection with guid " + connectionGuid + + " and endpoint with guid " + endpointGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateColumn.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateColumn.java new file mode 100644 index 00000000000..9a500b3ba0c --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateColumn.java @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseColumnProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the updateDatabaseColumn call to access service + */ +class OmasUpdateColumn implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasUpdateColumn(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Update column + * + * @param columnGuid guid + * @param columnProperties properties + */ + @Override + public void accept(String columnGuid, DatabaseColumnProperties columnProperties){ + String methodName = "OmasUpdateColumn"; + try { + databaseIntegratorContext.updateDatabaseColumn(columnGuid, false, columnProperties); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Updating column with qualifiedName " + columnProperties.getQualifiedName() + + " and guid " + columnGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateDatabase.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateDatabase.java new file mode 100644 index 00000000000..8668203f889 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateDatabase.java @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the updateDatabase call to access service + */ +class OmasUpdateDatabase implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasUpdateDatabase(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + /** + * Update database + * + * @param databaseGuid guid + * @param databaseProperties properties + */ + @Override + public void accept(String databaseGuid, DatabaseProperties databaseProperties){ + String methodName = "OmasUpdateDatabase"; + try { + databaseIntegratorContext.updateDatabase(databaseGuid, false, databaseProperties); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Updating database with qualifiedName " + databaseProperties.getQualifiedName() + + " and guid " + databaseGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateSchema.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateSchema.java new file mode 100644 index 00000000000..53cff33472d --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateSchema.java @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseSchemaProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the updateDatabaseSchema call to access service + */ +class OmasUpdateSchema implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasUpdateSchema(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + @Override + public void accept(String schemaGuid, DatabaseSchemaProperties schemaProperties){ + String methodName = "OmasUpdateSchema"; + try { + databaseIntegratorContext.updateDatabaseSchema(schemaGuid, false, schemaProperties); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Updating schema with qualifiedName " + schemaProperties.getQualifiedName() + + " and guid " + schemaGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateTable.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateTable.java new file mode 100644 index 00000000000..c42fdb3af09 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateTable.java @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseTableProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the updateDatabaseTable call to access service + */ +class OmasUpdateTable implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasUpdateTable(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + @Override + public void accept(String tableGuid, DatabaseTableProperties tableProperties){ + String methodName = "OmasUpdateTable"; + try { + databaseIntegratorContext.updateDatabaseTable(tableGuid, false, tableProperties); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Updating table with qualifiedName " + tableProperties.getQualifiedName() + + " and guid " + tableGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateView.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateView.java new file mode 100644 index 00000000000..2068629145e --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/OmasUpdateView.java @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +import org.odpi.openmetadata.accessservices.datamanager.properties.DatabaseViewProperties; +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.integrationservices.database.connector.DatabaseIntegratorContext; + +import java.util.function.BiConsumer; + +import static org.odpi.openmetadata.adapters.connectors.integration.jdbc.ffdc.JDBCIntegrationConnectorAuditCode.EXCEPTION_WRITING_OMAS; + +/** + * Manages the updateDatabaseView call to access service + */ +class OmasUpdateView implements BiConsumer { + + private final DatabaseIntegratorContext databaseIntegratorContext; + private final AuditLog auditLog; + + OmasUpdateView(DatabaseIntegratorContext databaseIntegratorContext, AuditLog auditLog){ + this.databaseIntegratorContext = databaseIntegratorContext; + this.auditLog = auditLog; + } + + @Override + public void accept(String viewGuid, DatabaseViewProperties viewProperties){ + String methodName = "OmasUpdateView"; + try { + databaseIntegratorContext.updateDatabaseView(viewGuid, false, viewProperties); + } catch (InvalidParameterException | UserNotAuthorizedException | PropertyServerException e) { + auditLog.logException("Updating view with qualifiedName " + viewProperties.getQualifiedName() + + " and guid " + viewGuid, + EXCEPTION_WRITING_OMAS.getMessageDefinition(methodName, e.getMessage()), e); + } + } + +} diff --git a/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/TriConsumer.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/TriConsumer.java new file mode 100644 index 00000000000..70372db49de --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/jdbc-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/jdbc/transfer/requests/TriConsumer.java @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.jdbc.transfer.requests; + +/** + * Consumer that accepts 3 parameters + */ +@FunctionalInterface +public interface TriConsumer { + + void accept(T t, U u, V v); + +} diff --git a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java index eaf1772faef..85226688840 100644 --- a/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java +++ b/open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java @@ -230,6 +230,8 @@ synchronized Map timeWarpRelationshipStore(Date a */ synchronized EntityDetail createEntityInStore(EntityDetail entity) throws RepositoryErrorException { + entity.setGUID(generateGUID(entity.getType().getTypeDefName(), entity.getGUID())); + StoredEntity newStoredEntity = new StoredEntity(entity); /* @@ -241,7 +243,7 @@ synchronized EntityDetail createEntityInStore(EntityDetail entity) throws Reposi while (existingStoredEntity != null) { entityStore.put(entity.getGUID(), existingStoredEntity); - entity.setGUID(UUID.randomUUID().toString()); + entity.setGUID(generateGUID(entity.getType().getTypeDefName(), UUID.randomUUID().toString())); newStoredEntity = new StoredEntity(entity); existingStoredEntity = entityStore.put(entity.getGUID(), newStoredEntity); } @@ -250,6 +252,20 @@ synchronized EntityDetail createEntityInStore(EntityDetail entity) throws Reposi } + /** + * Create a GUID that includes the type name. This is to help with debugging. + * + * @param typeName typeName of element. + * @param guid random UUID. + * @return composite GUID + */ + private String generateGUID(String typeName, + String guid) + { + return typeName + ":" + guid; + } + + /** * Create a new relationship in the relationship store. * @@ -258,6 +274,8 @@ synchronized EntityDetail createEntityInStore(EntityDetail entity) throws Reposi */ synchronized Relationship createRelationshipInStore(Relationship relationship) { + relationship.setGUID(generateGUID(relationship.getType().getTypeDefName(), relationship.getGUID())); + StoredRelationship newStoredRelationship = new StoredRelationship(relationship); /* @@ -269,7 +287,7 @@ synchronized Relationship createRelationshipInStore(Relationship relationship) while (existingStoredRelationship != null) { relationshipStore.put(relationship.getGUID(), existingStoredRelationship); - relationship.setGUID(UUID.randomUUID().toString()); + relationship.setGUID(generateGUID(relationship.getType().getTypeDefName(), UUID.randomUUID().toString())); newStoredRelationship = new StoredRelationship(relationship); existingStoredRelationship = relationshipStore.put(relationship.getGUID(), newStoredRelationship); } diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/CommonServicesDescription.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/CommonServicesDescription.java index 5c0cd308be8..dcf2e09baa1 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/CommonServicesDescription.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/registration/CommonServicesDescription.java @@ -43,9 +43,9 @@ public enum CommonServicesDescription implements Serializable GAF_METADATA_MANAGEMENT (184, ComponentDevelopmentStatus.STABLE, - "Open Metadata Store Services", + "Governance Action Framework Services", "open-metadata-store", - "Provides generic open metadata retrieval and management services for Open Metadata Access Services (OMASs).", + "Support governance action services.", "https://egeria-project.org/services/gaf-metadata-management"), PLATFORM_SERVICES (185, @@ -62,6 +62,21 @@ public enum CommonServicesDescription implements Serializable "Provides operational support for the integration connectors.", "https://egeria-project.org/services/oif-metadata-management"), + SERVER_OPERATIONS (187, + ComponentDevelopmentStatus.STABLE, + "Server Operations", + "server-operations", + "Supports the start up and shutdown of OMAG Servers.", + "https://egeria-project.org/services/server-operations/overview"), + + + OPEN_METADATA_STORE (188, + ComponentDevelopmentStatus.IN_DEVELOPMENT, + "Open Metadata Store Services", + "open-metadata-store", + "Provides generic open metadata retrieval and management services for the Open Frameworks and Open Metadata Access Services (OMASs).", + "https://egeria-project.org/services/oms-metadata-management"), + ; diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierBuilder.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierBuilder.java index 2637fe84826..62ef96fa85a 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierBuilder.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/ExternalIdentifierBuilder.java @@ -17,9 +17,13 @@ */ class ExternalIdentifierBuilder extends ReferenceableBuilder { - private String identifier = null; - private int keyPattern = 0; - + private String identifier = null; + private int keyPattern = 0; + private String externalInstanceCreatedBy = null; + private Date externalInstanceCreationTime = null; + private String externalInstanceLastUpdatedBy = null; + private Date externalInstanceLastUpdateTime = null; + private long externalInstanceVersion = 0L; /** @@ -46,12 +50,22 @@ class ExternalIdentifierBuilder extends ReferenceableBuilder * * @param identifier the identifier from the external technology * @param keyPattern identifier from the external party + * @param externalInstanceCreatedBy the username of the person or process that created the instance in the external system + * @param externalInstanceCreationTime the date/time when the instance in the external system was created + * @param externalInstanceLastUpdatedBy the username of the person or process that last updated the instance in the external system + * @param externalInstanceLastUpdateTime the date/time that the instance in the external system was last updated + * @param externalInstanceVersion the latest version of the element in the external system * @param repositoryHelper helper methods * @param serviceName name of this OMAS * @param serverName name of local server */ ExternalIdentifierBuilder(String identifier, int keyPattern, + String externalInstanceCreatedBy, + Date externalInstanceCreationTime, + String externalInstanceLastUpdatedBy, + Date externalInstanceLastUpdateTime, + long externalInstanceVersion, OMRSRepositoryHelper repositoryHelper, String serviceName, String serverName) @@ -65,6 +79,11 @@ class ExternalIdentifierBuilder extends ReferenceableBuilder this.identifier = identifier; this.keyPattern = keyPattern; + this.externalInstanceCreatedBy = externalInstanceCreatedBy; + this.externalInstanceCreationTime = externalInstanceCreationTime; + this.externalInstanceLastUpdatedBy = externalInstanceLastUpdatedBy; + this.externalInstanceLastUpdateTime = externalInstanceLastUpdateTime; + this.externalInstanceVersion = externalInstanceVersion; } @@ -101,6 +120,35 @@ public InstanceProperties getInstanceProperties(String methodName) throws Inval throw new InvalidParameterException(error, OpenMetadataAPIMapper.KEY_PATTERN_PROPERTY_NAME); } + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.EXT_INSTANCE_CREATED_BY_PROPERTY_NAME, + externalInstanceCreatedBy, + methodName); + + properties = repositoryHelper.addDatePropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.EXT_INSTANCE_CREATION_TIME_PROPERTY_NAME, + externalInstanceCreationTime, + methodName); + + properties = repositoryHelper.addStringPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.EXT_INSTANCE_LAST_UPDATED_BY_PROPERTY_NAME, + externalInstanceLastUpdatedBy, + methodName); + + properties = repositoryHelper.addDatePropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.EXT_INSTANCE_LAST_UPDATE_TIME_PROPERTY_NAME, + externalInstanceLastUpdateTime, + methodName); + + properties = repositoryHelper.addLongPropertyToInstance(serviceName, + properties, + OpenMetadataAPIMapper.EXT_INSTANCE_VERSION_PROPERTY_NAME, + externalInstanceVersion, + methodName); return properties; } @@ -109,7 +157,7 @@ public InstanceProperties getInstanceProperties(String methodName) throws Inval /** * Return the properties that are to be stored in the ExternalIdLink relationship. * - * @param description description of the linkage between the open metadata referenceable (resource) and the external id) + * @param description description of the linkage between the open metadata referenceable (resource) and the external id * @param usage the way that the external identifier should be used. * @param source the description of the source (typically the integration connector name) * @param mappingProperties additional properties to help with the mapping to the external metadata 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 48bee190225..cb9abb50840 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 @@ -27,7 +27,6 @@ * ExternalIdentifierHandler manages ExternalIdentifier objects. These entities represent the identifiers used for metadata * in third party technology. It runs server-side in the OMAG Server Platform and manages ExternalId entities through the OMRSRepositoryConnector * via the repository handler. - * * The ExternalIdentifier is linked to the SoftwareCapability that represents the third party technology * that generated the external identifier. This is referred to as the scope. It is also linked to the element * (or elements) in open metadata that are equivalent to the metadata element(s) in the third party technology. @@ -112,6 +111,11 @@ public ExternalIdentifierHandler(OpenMetadataAPIGenericConverter * @param identifierUsage usage information from the connector/client supplying the identifier * @param identifierSource name of the connector/client supplying the identifier * @param identifierMappingProperties additional properties to help with the synchronization + * @param externalInstanceCreatedBy the username of the person or process that created the instance in the external system + * @param externalInstanceCreationTime the date/time when the instance in the external system was created + * @param externalInstanceLastUpdatedBy the username of the person or process that last updated the instance in the external system + * @param externalInstanceLastUpdateTime the date/time that the instance in the external system was last updated + * @param externalInstanceVersion the latest version of the element in the external system * @param scopeGUID unique identifier of the software capability that represents the third metadata source * @param scopeGUIDParameterName parameter supplying scopeGUID * @param scopeQualifiedName qualified name from the entity that @@ -141,6 +145,11 @@ public void setUpExternalIdentifier(String userId, String identifierUsage, String identifierSource, Map identifierMappingProperties, + String externalInstanceCreatedBy, + Date externalInstanceCreationTime, + String externalInstanceLastUpdatedBy, + Date externalInstanceLastUpdateTime, + long externalInstanceVersion, String scopeGUID, String scopeGUIDParameterName, String scopeQualifiedName, @@ -181,6 +190,11 @@ public void setUpExternalIdentifier(String userId, externalIdGUID = createExternalIdentifier(userId, identifier, identifierKeyPattern, + externalInstanceCreatedBy, + externalInstanceCreationTime, + externalInstanceLastUpdatedBy, + externalInstanceLastUpdateTime, + externalInstanceVersion, scopeGUID, scopeGUIDParameterName, scopeTypeName, @@ -212,6 +226,11 @@ public void setUpExternalIdentifier(String userId, externalIdGUIDParameterName, identifier, identifierKeyPattern, + externalInstanceCreatedBy, + externalInstanceCreationTime, + externalInstanceLastUpdatedBy, + externalInstanceLastUpdateTime, + externalInstanceVersion, forLineage, forDuplicateProcessing, effectiveTime, @@ -800,6 +819,11 @@ private boolean validateExternalIdentifierScope(String userId, * @param userId calling user * @param identifier identifier from the third party technology * @param identifierKeyPattern key pattern that defines the logic used to maintain the identifier + * @param externalInstanceCreatedBy the username of the person or process that created the instance in the external system + * @param externalInstanceCreationTime the date/time when the instance in the external system was created + * @param externalInstanceLastUpdatedBy the username of the person or process that last updated the instance in the external system + * @param externalInstanceLastUpdateTime the date/time that the instance in the external system was last updated + * @param externalInstanceVersion the latest version of the element in the external system * @param scopeGUID unique identifier of the software capability that represents the third metadata source * @param scopeGUIDParameterName parameter supplying scopeGUID * @param scopeTypeName specific type name of the software capability that represents the third party metadata source @@ -822,6 +846,11 @@ private boolean validateExternalIdentifierScope(String userId, private String createExternalIdentifier(String userId, String identifier, int identifierKeyPattern, + String externalInstanceCreatedBy, + Date externalInstanceCreationTime, + String externalInstanceLastUpdatedBy, + Date externalInstanceLastUpdateTime, + long externalInstanceVersion, String scopeGUID, String scopeGUIDParameterName, String scopeTypeName, @@ -841,6 +870,11 @@ private String createExternalIdentifier(String userId, ExternalIdentifierBuilder builder = new ExternalIdentifierBuilder(identifier, identifierKeyPattern, + externalInstanceCreatedBy, + externalInstanceCreationTime, + externalInstanceLastUpdatedBy, + externalInstanceLastUpdateTime, + externalInstanceVersion, repositoryHelper, serviceName, serverName); @@ -894,6 +928,11 @@ private String createExternalIdentifier(String userId, * @param externalIdGUID unique identifier of the * @param identifier identifier from the third party technology * @param identifierKeyPattern key pattern that defines the logic used to maintain the identifier + * @param externalInstanceCreatedBy the username of the person or process that created the instance in the external system + * @param externalInstanceCreationTime the date/time when the instance in the external system was created + * @param externalInstanceLastUpdatedBy the username of the person or process that last updated the instance in the external system + * @param externalInstanceLastUpdateTime the date/time that the instance in the external system was last updated + * @param externalInstanceVersion the latest version of the element in the external system * @param effectiveTime when should the elements be effected for - null is anytime; new Date() is now * @param forLineage return elements marked with the Memento classification? * @param forDuplicateProcessing do not merge elements marked as duplicates? @@ -908,6 +947,11 @@ private void updateExternalIdentifier(String userId, String externalIdGUIDParameterName, String identifier, int identifierKeyPattern, + String externalInstanceCreatedBy, + Date externalInstanceCreationTime, + String externalInstanceLastUpdatedBy, + Date externalInstanceLastUpdateTime, + long externalInstanceVersion, boolean forLineage, boolean forDuplicateProcessing, Date effectiveTime, @@ -917,6 +961,11 @@ private void updateExternalIdentifier(String userId, { ExternalIdentifierBuilder builder = new ExternalIdentifierBuilder(identifier, identifierKeyPattern, + externalInstanceCreatedBy, + externalInstanceCreationTime, + externalInstanceLastUpdatedBy, + externalInstanceLastUpdateTime, + externalInstanceVersion, repositoryHelper, serviceName, serverName); diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/FilesAndFoldersHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/FilesAndFoldersHandler.java index a784eb91e8f..56248d1bf54 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/FilesAndFoldersHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/FilesAndFoldersHandler.java @@ -1304,7 +1304,7 @@ public void moveDataFolderInCatalog(String userId, * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - private List addFileAssetPath(String userId, + public List addFileAssetPath(String userId, String externalSourceGUID, String externalSourceName, String fileAssetGUID, 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 81fea111e51..377a6817a1a 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 @@ -36,7 +36,6 @@ /** * OpenMetadataAPIGenericConverter provides the generic methods for the bean converters used to provide translation between * specific Open Metadata API beans and the repository services API beans. - * * Generic classes have limited knowledge of the classes these are working on and this means creating a new instance of a * class from within a generic is a little involved. This class provides the generic method for creating * and initializing an Open Metadata API bean. @@ -1728,6 +1727,115 @@ protected String removeIdentifier(InstanceProperties instanceProperties) } + /** + * Extract and delete the externalInstanceCreatedBy property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return string text or null + */ + protected String removeExternalInstanceCreatedBy(InstanceProperties instanceProperties) + { + final String methodName = "removeExternalInstanceCreatedBy"; + + if (instanceProperties != null) + { + return repositoryHelper.removeStringProperty(serviceName, + OpenMetadataAPIMapper.EXT_INSTANCE_CREATED_BY_PROPERTY_NAME, + instanceProperties, + methodName); + } + + return null; + } + + + /** + * Extract and delete the externalInstanceCreationTime property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return string text or null + */ + protected Date removeExternalInstanceCreationTime(InstanceProperties instanceProperties) + { + final String methodName = "removeExternalInstanceCreationTime"; + + if (instanceProperties != null) + { + return repositoryHelper.removeDateProperty(serviceName, + OpenMetadataAPIMapper.EXT_INSTANCE_CREATION_TIME_PROPERTY_NAME, + instanceProperties, + methodName); + } + + return null; + } + + + /** + * Extract and delete the externalInstanceLastUpdatedBy property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return string text or null + */ + protected String removeExternalInstanceLastUpdatedBy(InstanceProperties instanceProperties) + { + final String methodName = "removeExternalInstanceLastUpdatedBy"; + + if (instanceProperties != null) + { + return repositoryHelper.removeStringProperty(serviceName, + OpenMetadataAPIMapper.EXT_INSTANCE_LAST_UPDATED_BY_PROPERTY_NAME, + instanceProperties, + methodName); + } + + return null; + } + + + /** + * Extract and delete the externalInstanceLastUpdateTime property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return string text or null + */ + protected Date removeExternalInstanceLastUpdateTime(InstanceProperties instanceProperties) + { + final String methodName = "removeExternalInstanceCreationTime"; + + if (instanceProperties != null) + { + return repositoryHelper.removeDateProperty(serviceName, + OpenMetadataAPIMapper.EXT_INSTANCE_LAST_UPDATE_TIME_PROPERTY_NAME, + instanceProperties, + methodName); + } + + return null; + } + + + /** + * Extract and delete the externalInstanceVersion property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return string text or null + */ + protected long removeExternalInstanceVersion(InstanceProperties instanceProperties) + { + final String methodName = "removeExternalInstanceVersion"; + + if (instanceProperties != null) + { + return repositoryHelper.removeLongProperty(serviceName, + OpenMetadataAPIMapper.EXT_INSTANCE_VERSION_PROPERTY_NAME, + instanceProperties, + methodName); + } + + return 0L; + } + /** * Extract and delete the URL property from the supplied instance properties. * 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 868314ce0c8..3562f91f397 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 @@ -127,10 +127,15 @@ public class OpenMetadataAPIMapper public static final String SEARCH_KEYWORD_TO_RELATED_KEYWORD_TYPE_NAME = "RelatedKeyword"; /* End1 = SearchKeyword; End 2 = SearchKeyword */ - public static final String EXTERNAL_IDENTIFIER_TYPE_GUID = "7c8f8c2c-cc48-429e-8a21-a1f1851ccdb0"; - public static final String EXTERNAL_IDENTIFIER_TYPE_NAME = "ExternalId"; /* from Area 0 */ - - public static final String IDENTIFIER_PROPERTY_NAME = "identifier"; /* from ExternalId entity */ + public static final String EXTERNAL_IDENTIFIER_TYPE_GUID = "7c8f8c2c-cc48-429e-8a21-a1f1851ccdb0"; + public static final String EXTERNAL_IDENTIFIER_TYPE_NAME = "ExternalId"; /* from Area 0 */ + + public static final String IDENTIFIER_PROPERTY_NAME = "identifier"; /* from ExternalId entity */ + public static final String EXT_INSTANCE_CREATED_BY_PROPERTY_NAME = "externalInstanceCreatedBy"; /* from ExternalId entity */ + public static final String EXT_INSTANCE_CREATION_TIME_PROPERTY_NAME = "externalInstanceCreationTime"; /* from ExternalId entity */ + public static final String EXT_INSTANCE_LAST_UPDATED_BY_PROPERTY_NAME = "externalInstanceLastUpdatedBy"; /* from ExternalId entity */ + public static final String EXT_INSTANCE_LAST_UPDATE_TIME_PROPERTY_NAME = "externalInstanceLastUpdateTime"; /* from ExternalId entity */ + public static final String EXT_INSTANCE_VERSION_PROPERTY_NAME = "externalInstanceVersion"; /* from ExternalId entity */ public static final String MAPPING_PROPERTIES_PROPERTY_NAME = "mappingProperties"; /* from ExternalId entity */ public static final String LAST_SYNCHRONIZED_PROPERTY_NAME = "lastSynchronized"; /* from ExternalId entity */ public static final String KEY_PATTERN_PROPERTY_NAME = "keyPattern"; /* from ExternalId entity */ 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 78a8b5fe846..1babd1da8a7 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 @@ -339,7 +339,7 @@ public String createDatabase(String userId, if (databaseGUID != null) { - if ((encodingType != null) || (encodingLanguage != null) || (encodingDescription != null)) + if ((encodingType != null) || (encodingLanguage != null) || (encodingDescription != null) || (encodingProperties != null)) { InstanceProperties classificationProperties = this.getEncodingProperties(encodingType, encodingLanguage, diff --git a/open-metadata-implementation/common-services/multi-tenant/build.gradle b/open-metadata-implementation/common-services/multi-tenant/build.gradle index 7a017bb0c7f..e758f75df7f 100644 --- a/open-metadata-implementation/common-services/multi-tenant/build.gradle +++ b/open-metadata-implementation/common-services/multi-tenant/build.gradle @@ -11,7 +11,7 @@ dependencies { implementation project(':open-metadata-implementation:frameworks:open-integration-framework') implementation project(':open-metadata-implementation:frameworks:governance-action-framework') implementation project(':open-metadata-implementation:common-services:metadata-security:metadata-security-server') - implementation project(':open-metadata-implementation:platform-services:platform-services-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:repository-services:repository-services-apis') implementation project(':open-metadata-implementation:common-services:repository-handler') implementation project(':open-metadata-implementation:common-services:metadata-security:metadata-security-apis') diff --git a/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerInstance.java b/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerInstance.java index 889d9e38c29..f935e5c7a5f 100644 --- a/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerInstance.java +++ b/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerInstance.java @@ -9,7 +9,7 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; -import org.odpi.openmetadata.platformservices.properties.OMAGServerInstanceHistory; +import org.odpi.openmetadata.serveroperations.properties.OMAGServerInstanceHistory; import java.util.*; diff --git a/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerPlatformInstanceMap.java b/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerPlatformInstanceMap.java index d3212b44fb5..e77066ac6d8 100644 --- a/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerPlatformInstanceMap.java +++ b/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerPlatformInstanceMap.java @@ -17,8 +17,8 @@ import org.odpi.openmetadata.governanceservers.integrationdaemonservices.registration.IntegrationServiceRegistry; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataPlatformSecurityVerifier; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; -import org.odpi.openmetadata.platformservices.properties.OMAGServerInstanceHistory; -import org.odpi.openmetadata.platformservices.properties.ServerStatus; +import org.odpi.openmetadata.serveroperations.properties.OMAGServerInstanceHistory; +import org.odpi.openmetadata.serveroperations.properties.ServerStatus; import java.util.*; diff --git a/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerServiceInstance.java b/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerServiceInstance.java index f6e553efbbd..8de194666a9 100644 --- a/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerServiceInstance.java +++ b/open-metadata-implementation/common-services/multi-tenant/src/main/java/org/odpi/openmetadata/commonservices/multitenant/OMAGServerServiceInstance.java @@ -6,7 +6,7 @@ import org.odpi.openmetadata.commonservices.multitenant.ffdc.OMAGServerInstanceErrorCode; import org.odpi.openmetadata.commonservices.multitenant.ffdc.exceptions.NewInstanceException; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; -import org.odpi.openmetadata.platformservices.properties.ServerInstanceStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerInstanceStatus; /** * OMAGServerServiceInstance represents an instance of a service in an OMAG Server. diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/ExternalIdentifierConverter.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/ExternalIdentifierConverter.java index 37e4e471977..f10eca8b4ff 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/ExternalIdentifierConverter.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/converters/ExternalIdentifierConverter.java @@ -6,6 +6,7 @@ import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ExternalIdentifier; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.KeyPattern; 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; @@ -57,10 +58,8 @@ public B getNewBean(Class beanClass, */ B returnBean = beanClass.getDeclaredConstructor().newInstance(); - if (returnBean instanceof ExternalIdentifier) + if (returnBean instanceof ExternalIdentifier bean) { - ExternalIdentifier bean = (ExternalIdentifier) returnBean; - /* * Check that the entity is of the correct type. */ @@ -73,6 +72,13 @@ public B getNewBean(Class beanClass, InstanceProperties instanceProperties = new InstanceProperties(entity.getProperties()); bean.setQualifiedName(this.removeQualifiedName(instanceProperties)); + bean.setIdentifier((this.removeIdentifier(instanceProperties))); + bean.setKeyPattern(this.removeKeyPattern(instanceProperties)); + bean.setExternalInstanceCreatedBy(this.removeExternalInstanceCreatedBy(instanceProperties)); + bean.setExternalInstanceCreationTime(this.removeExternalInstanceCreationTime(instanceProperties)); + bean.setExternalInstanceLastUpdatedBy(this.removeExternalInstanceLastUpdatedBy(instanceProperties)); + bean.setExternalInstanceLastUpdateTime(this.removeExternalInstanceLastUpdateTime(instanceProperties)); + bean.setExternalInstanceVersion(this.removeExternalInstanceVersion(instanceProperties)); bean.setAdditionalProperties(this.removeAdditionalProperties(instanceProperties)); /* @@ -113,4 +119,34 @@ public B getNewBean(Class beanClass, { return this.getNewBean(beanClass, entity, methodName); } + + + /** + * Extract and delete the keyPattern property from the supplied instance properties. + * + * @param instanceProperties properties from entity + * @return KeyPattern enum + */ + KeyPattern removeKeyPattern(InstanceProperties instanceProperties) + { + final String methodName = "removeKeyPattern"; + + if (instanceProperties != null) + { + int ordinal = repositoryHelper.removeEnumPropertyOrdinal(serviceName, + OpenMetadataAPIMapper.KEY_PATTERN_PROPERTY_NAME, + instanceProperties, + methodName); + + for (KeyPattern keyPattern : KeyPattern.values()) + { + if (keyPattern.getOpenTypeOrdinal() == ordinal) + { + return keyPattern; + } + } + } + + return KeyPattern.LOCAL_KEY; + } } diff --git a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ExternalIdentifier.java b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ExternalIdentifier.java index ea498f2d577..e6976023bb2 100644 --- a/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ExternalIdentifier.java +++ b/open-metadata-implementation/frameworks/open-connector-framework/src/main/java/org/odpi/openmetadata/frameworks/connectors/properties/beans/ExternalIdentifier.java @@ -7,6 +7,7 @@ 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; @@ -26,13 +27,18 @@ public class ExternalIdentifier extends Referenceable /* * Attributes of an external identifier */ - protected String identifier = null; - protected String description = null; - protected String usage = null; - protected String source = null; - protected KeyPattern keyPattern = null; - protected Referenceable scope = null; - protected String scopeDescription = null; + protected String identifier = null; + protected String description = null; + protected String usage = null; + protected String source = null; + protected KeyPattern keyPattern = null; + protected String externalInstanceCreatedBy = null; + protected Date externalInstanceCreationTime = null; + protected String externalInstanceLastUpdatedBy = null; + protected Date externalInstanceLastUpdateTime = null; + protected long externalInstanceVersion = 0L; + protected Referenceable scope = null; + protected String scopeDescription = null; /** @@ -47,31 +53,36 @@ public ExternalIdentifier() /** * Copy/clone constructor. * - * @param templateExternalIdentifier element to copy + * @param template element to copy */ - public ExternalIdentifier(ExternalIdentifier templateExternalIdentifier) + public ExternalIdentifier(ExternalIdentifier template) { - super(templateExternalIdentifier); + super(template); - if (templateExternalIdentifier != null) + if (template != null) { /* * Copy the values from the supplied template. */ - identifier = templateExternalIdentifier.getIdentifier(); - description = templateExternalIdentifier.getDescription(); - usage = templateExternalIdentifier.getUsage(); - source = templateExternalIdentifier.getSource(); - keyPattern = templateExternalIdentifier.getKeyPattern(); - - Referenceable templateScope = templateExternalIdentifier.getScope(); + identifier = template.getIdentifier(); + description = template.getDescription(); + usage = template.getUsage(); + source = template.getSource(); + keyPattern = template.getKeyPattern(); + externalInstanceCreatedBy = template.getExternalInstanceCreatedBy(); + externalInstanceCreationTime = template.getExternalInstanceCreationTime(); + externalInstanceLastUpdatedBy = template.getExternalInstanceLastUpdatedBy(); + externalInstanceLastUpdateTime = template.getExternalInstanceLastUpdateTime(); + externalInstanceVersion = template.getExternalInstanceVersion(); + + Referenceable templateScope = template.getScope(); if (templateScope != null) { scope = new Referenceable(templateScope); } - scopeDescription = templateExternalIdentifier.getScopeDescription(); + scopeDescription = template.getScopeDescription(); } } @@ -170,6 +181,117 @@ public void setKeyPattern(KeyPattern keyPattern) } + + /** + * Return the username of the person or process that created the instance in the external system. + * + * @return name + */ + public String getExternalInstanceCreatedBy() + { + return externalInstanceCreatedBy; + } + + + /** + * Set up the username of the person or process that created the instance in the external system. + * + * @param externalInstanceCreatedBy name + */ + public void setExternalInstanceCreatedBy(String externalInstanceCreatedBy) + { + this.externalInstanceCreatedBy = externalInstanceCreatedBy; + } + + + /** + * Return the date/time when the instance in the external system was created. + * + * @return date + */ + public Date getExternalInstanceCreationTime() + { + return externalInstanceCreationTime; + } + + + /** + * Set up the date/time when the instance in the external system was created. + * + * @param externalInstanceCreationTime date + */ + public void setExternalInstanceCreationTime(Date externalInstanceCreationTime) + { + this.externalInstanceCreationTime = externalInstanceCreationTime; + } + + + /** + * Return the username of the person or process that last updated the instance in the external system. + * + * @return name + */ + public String getExternalInstanceLastUpdatedBy() + { + return externalInstanceLastUpdatedBy; + } + + + /** + * Set up the username of the person or process that last updated the instance in the external system. + * + * @param externalInstanceLastUpdatedBy name + */ + public void setExternalInstanceLastUpdatedBy(String externalInstanceLastUpdatedBy) + { + this.externalInstanceLastUpdatedBy = externalInstanceLastUpdatedBy; + } + + + /** + * Return the date/time that the instance in the external system was last updated. + * + * @return date + */ + public Date getExternalInstanceLastUpdateTime() + { + return externalInstanceLastUpdateTime; + } + + + /** + * Set up the date/time that the instance in the external system was last updated. + * + * @param externalInstanceLastUpdateTime date + */ + public void setExternalInstanceLastUpdateTime(Date externalInstanceLastUpdateTime) + { + this.externalInstanceLastUpdateTime = externalInstanceLastUpdateTime; + } + + + /** + * Return the latest version of the element in the external system. + * + * @return long + */ + public long getExternalInstanceVersion() + { + return externalInstanceVersion; + } + + + /** + * Set up the latest version of the element in the external system. + * + * @param externalInstanceVersion long + */ + public void setExternalInstanceVersion(long externalInstanceVersion) + { + this.externalInstanceVersion = externalInstanceVersion; + } + + /** * Return the scope of this external identifier. This depends on the key pattern. It may be a server definition, * a reference data set or glossary term. @@ -229,24 +351,28 @@ public void setScopeDescription(String scopeDescription) public String toString() { return "ExternalIdentifier{" + - "URL='" + getURL() + '\'' + - ", extendedProperties=" + getExtendedProperties() + - ", status=" + getStatus() + - ", type=" + getType() + - ", origin=" + getOrigin() + - ", versions=" + getVersions() + - ", GUID='" + getGUID() + '\'' + - ", classifications=" + getClassifications() + - ", identifier='" + identifier + '\'' + + "identifier='" + identifier + '\'' + ", description='" + description + '\'' + ", usage='" + usage + '\'' + ", source='" + source + '\'' + ", keyPattern=" + keyPattern + + ", externalInstanceCreatedBy='" + externalInstanceCreatedBy + '\'' + + ", externalInstanceCreationTime=" + externalInstanceCreationTime + + ", externalInstanceLastUpdatedBy='" + externalInstanceLastUpdatedBy + '\'' + + ", externalInstanceLastUpdateTime='" + externalInstanceLastUpdateTime + '\'' + + ", externalInstanceVersion=" + externalInstanceVersion + ", scope=" + scope + ", scopeDescription='" + scopeDescription + '\'' + - ", headerVersion=" + getHeaderVersion() + ", qualifiedName='" + getQualifiedName() + '\'' + ", additionalProperties=" + getAdditionalProperties() + + ", URL='" + getURL() + '\'' + + ", extendedProperties=" + getExtendedProperties() + + ", GUID='" + getGUID() + '\'' + + ", classifications=" + getClassifications() + + ", status=" + getStatus() + + ", type=" + getType() + + ", origin=" + getOrigin() + + ", versions=" + getVersions() + '}'; } diff --git a/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContext.java b/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContext.java index 0f8c6579433..49e8670c0e8 100644 --- a/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContext.java +++ b/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContext.java @@ -33,6 +33,7 @@ public class IntegrationContext protected final String externalSourceGUID; protected final String externalSourceName; protected boolean externalSourceIsHome = true; + protected final String connectorName; protected final String integrationConnectorGUID; protected final PermittedSynchronization permittedSynchronization; @@ -76,6 +77,7 @@ public IntegrationContext(String connectorId, this.openMetadataStoreClient = openMetadataStoreClient; this.permittedSynchronization = permittedSynchronization; this.userId = connectorUserId; + this.connectorName = connectorName; this.externalSourceGUID = externalSourceGUID; this.externalSourceName = externalSourceName; this.integrationConnectorGUID = integrationConnectorGUID; diff --git a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/build.gradle b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/build.gradle index f0462df3b68..d6c9907c402 100644 --- a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/build.gradle +++ b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/build.gradle @@ -13,7 +13,7 @@ dependencies { implementation project(':open-metadata-implementation:framework-services:ocf-metadata-management:ocf-metadata-client') implementation project(':open-metadata-implementation:access-services:governance-engine:governance-engine-api') implementation project(':open-metadata-implementation:access-services:governance-engine:governance-engine-client') - implementation project(':open-metadata-implementation:platform-services:platform-services-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation 'org.slf4j:slf4j-api' implementation project(':open-metadata-implementation:governance-servers:engine-host-services:engine-host-services-api') diff --git a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/server/EngineHostOperationalServices.java b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/server/EngineHostOperationalServices.java index 1a81410eb3d..757eb736c4a 100644 --- a/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/server/EngineHostOperationalServices.java +++ b/open-metadata-implementation/governance-servers/engine-host-services/engine-host-services-server/src/main/java/org/odpi/openmetadata/governanceservers/enginehostservices/server/EngineHostOperationalServices.java @@ -13,8 +13,8 @@ import org.odpi.openmetadata.adminservices.configuration.registration.GovernanceServicesDescription; import org.odpi.openmetadata.adminservices.configuration.registration.ServiceOperationalStatus; import org.odpi.openmetadata.adminservices.ffdc.exception.OMAGConfigurationErrorException; -import org.odpi.openmetadata.platformservices.properties.OMAGServerServiceStatus; -import org.odpi.openmetadata.platformservices.properties.ServerActiveStatus; +import org.odpi.openmetadata.serveroperations.properties.OMAGServerServiceStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerActiveStatus; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; diff --git a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/build.gradle b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/build.gradle index e0a85f1578f..e5fd55ac9ea 100644 --- a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/build.gradle +++ b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/build.gradle @@ -5,7 +5,7 @@ dependencies { - implementation project(':open-metadata-implementation:platform-services:platform-services-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation project(':open-metadata-implementation:access-services:governance-engine:governance-engine-api') implementation project(':open-metadata-implementation:access-services:governance-engine:governance-engine-client') diff --git a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/server/IntegrationDaemonOperationalServices.java b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/server/IntegrationDaemonOperationalServices.java index 6121b809385..898f9653773 100644 --- a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/server/IntegrationDaemonOperationalServices.java +++ b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/server/IntegrationDaemonOperationalServices.java @@ -10,8 +10,6 @@ import org.odpi.openmetadata.adminservices.configuration.properties.IntegrationServiceConfig; import org.odpi.openmetadata.adminservices.configuration.registration.GovernanceServicesDescription; import org.odpi.openmetadata.adminservices.ffdc.exception.OMAGConfigurationErrorException; -import org.odpi.openmetadata.platformservices.properties.OMAGServerServiceStatus; -import org.odpi.openmetadata.platformservices.properties.ServerActiveStatus; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.integration.contextmanager.IntegrationContextManager; @@ -24,6 +22,8 @@ import org.odpi.openmetadata.governanceservers.integrationdaemonservices.registration.IntegrationServiceRegistry; import org.odpi.openmetadata.governanceservers.integrationdaemonservices.threads.GroupConfigurationRefreshThread; import org.odpi.openmetadata.governanceservers.integrationdaemonservices.threads.IntegrationDaemonThread; +import org.odpi.openmetadata.serveroperations.properties.OMAGServerServiceStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerActiveStatus; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/CatalogIntegratorContext.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/CatalogIntegratorContext.java index 87b48355406..6e50bd6dc90 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/CatalogIntegratorContext.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/CatalogIntegratorContext.java @@ -16,6 +16,8 @@ import org.odpi.openmetadata.accessservices.assetmanager.client.exchange.LineageExchangeClient; import org.odpi.openmetadata.accessservices.assetmanager.client.exchange.StewardshipExchangeClient; import org.odpi.openmetadata.accessservices.assetmanager.client.exchange.ValidValuesExchangeClient; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataCorrelationHeader; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.MetadataElement; import org.odpi.openmetadata.accessservices.assetmanager.properties.ExternalIdentifierProperties; import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; @@ -443,6 +445,48 @@ public boolean isListenerRegistered() */ + /** + * Retrieve the correlation header from the retrieved element that matches this asset manager. + * + * @param retrievedElement element retrieved from the metadata repository + * @return metadata correlation header or null if the element does not have a matching correlation header + * @throws InvalidParameterException the element passed is null + */ + public MetadataCorrelationHeader getMetadataCorrelationHeader(MetadataElement retrievedElement) throws InvalidParameterException + { + final String methodName = "getMetadataCorrelationHeader"; + final String parameterName = "retrievedElement"; + + if (retrievedElement == null) + { + throw new InvalidParameterException(CatalogIntegratorErrorCode.NULL_ELEMENT_PASSED.getMessageDefinition(connectorName, + methodName, + parameterName), + this.getClass().getName(), + methodName, + parameterName); + } + else if ((retrievedElement.getCorrelationHeaders() == null) || (assetManagerName == null)) + { + return null; + } + else + { + for (MetadataCorrelationHeader metadataCorrelationHeader : retrievedElement.getCorrelationHeaders()) + { + if (assetManagerName.equals(metadataCorrelationHeader.getAssetManagerName())) + { + return metadataCorrelationHeader; + } + } + + /* + * None of the correlation headers match this asset manager. + */ + return null; + } + } + /** * Add a new external identifier to an existing open metadata element. @@ -525,7 +569,7 @@ public void removeExternalIdentifier(String openMetadataElementGUID, /** * Confirm that the values of a particular metadata element have been synchronized. This is important - * from an audit points of view, and to allow bidirectional updates of metadata using optimistic locking. + * from an audit point of view, and to allow bidirectional updates of metadata using optimistic locking. * * @param openMetadataGUID unique identifier (GUID) of this element in open metadata * @param openMetadataElementTypeName type name for the open metadata element diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ConnectionExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ConnectionExchangeService.java index f14a71cbd76..4fe7ca2462e 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ConnectionExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/ConnectionExchangeService.java @@ -183,9 +183,6 @@ public String createConnectionFromTemplate(boolean external /** * Update the metadata element representing an connection. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectionGUID unique identifier of the metadata element to update * @param connectionExternalIdentifier unique identifier of the connection in the external source * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? @@ -196,10 +193,7 @@ public String createConnectionFromTemplate(boolean external * @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 updateConnection(String userId, - String externalSourceGUID, - String externalSourceName, - String connectionGUID, + public void updateConnection(String connectionGUID, String connectionExternalIdentifier, boolean isMergeUpdate, ConnectionProperties connectionProperties, @@ -238,7 +232,6 @@ public void updateConnection(String userId, /** * Create a relationship between a connection and a connector type. * - * @param userId calling user * @param externalSourceIsHome ensure that only the asset manager can update this relationship * @param connectionGUID unique identifier of the connection in the external asset manager * @param connectorTypeGUID unique identifier of the connector type in the external asset manager @@ -250,8 +243,7 @@ public void updateConnection(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void setupConnectorType(String userId, - boolean externalSourceIsHome, + public void setupConnectorType(boolean externalSourceIsHome, String connectionGUID, String connectorTypeGUID, Date effectiveFrom, @@ -292,9 +284,6 @@ public void setupConnectorType(String userId, /** * Remove a relationship between a connection and a connector type. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectionGUID unique identifier of the connection in the external asset manager * @param connectorTypeGUID unique identifier of the connector type in the external asset manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -303,10 +292,7 @@ public void setupConnectorType(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void clearConnectorType(String userId, - String externalSourceGUID, - String externalSourceName, - String connectionGUID, + public void clearConnectorType(String connectionGUID, String connectorTypeGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -341,9 +327,6 @@ public void clearConnectorType(String userId, /** * Create a relationship between a connection and an endpoint. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param externalSourceIsHome ensure that only the asset manager can update this relationship * @param connectionGUID unique identifier of the connection in the external asset manager * @param endpointGUID unique identifier of the endpoint in the external asset manager @@ -355,10 +338,7 @@ public void clearConnectorType(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void setupEndpoint(String userId, - String externalSourceGUID, - String externalSourceName, - boolean externalSourceIsHome, + public void setupEndpoint(boolean externalSourceIsHome, String connectionGUID, String endpointGUID, Date effectiveFrom, @@ -399,9 +379,6 @@ public void setupEndpoint(String userId, /** * Remove a relationship between a connection and an endpoint. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectionGUID unique identifier of the connection in the external asset manager * @param endpointGUID unique identifier of the endpoint in the external asset manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -410,10 +387,7 @@ public void setupEndpoint(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void clearEndpoint(String userId, - String externalSourceGUID, - String externalSourceName, - String connectionGUID, + public void clearEndpoint(String connectionGUID, String endpointGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -448,9 +422,6 @@ public void clearEndpoint(String userId, /** * Create a relationship between a virtual connection and an embedded connection. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param externalSourceIsHome ensure that only the asset manager can update this relationship * @param connectionGUID unique identifier of the virtual connection in the external asset manager * @param embeddedConnectionGUID unique identifier of the embedded connection in the external asset manager @@ -463,10 +434,7 @@ public void clearEndpoint(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void setupEmbeddedConnection(String userId, - String externalSourceGUID, - String externalSourceName, - boolean externalSourceIsHome, + public void setupEmbeddedConnection(boolean externalSourceIsHome, String connectionGUID, String embeddedConnectionGUID, EmbeddedConnectionProperties properties, @@ -505,9 +473,6 @@ public void setupEmbeddedConnection(String userId, /** * Remove a relationship between a virtual connection and an embedded connection. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectionGUID unique identifier of the virtual connection in the external asset manager * @param embeddedConnectionGUID unique identifier of the embedded connection in the external asset manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -516,10 +481,7 @@ public void setupEmbeddedConnection(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void clearEmbeddedConnection(String userId, - String externalSourceGUID, - String externalSourceName, - String connectionGUID, + public void clearEmbeddedConnection(String connectionGUID, String embeddedConnectionGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -554,9 +516,6 @@ public void clearEmbeddedConnection(String userId, /** * Create a relationship between an asset and its connection. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param externalSourceIsHome ensure that only the asset manager can update this relationship * @param assetGUID unique identifier of the asset * @param properties summary of the asset that is stored in the relationship between the asset and the connection. @@ -567,10 +526,7 @@ public void clearEmbeddedConnection(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void setupAssetConnection(String userId, - String externalSourceGUID, - String externalSourceName, - boolean externalSourceIsHome, + public void setupAssetConnection(boolean externalSourceIsHome, String assetGUID, String connectionGUID, AssetConnectionProperties properties, @@ -609,9 +565,6 @@ public void setupAssetConnection(String userId, /** * Remove a relationship between an asset and its connection. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param assetGUID unique identifier of the asset * @param connectionGUID unique identifier of the connection * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -620,10 +573,7 @@ public void setupAssetConnection(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void clearAssetConnection(String userId, - String externalSourceGUID, - String externalSourceName, - String assetGUID, + public void clearAssetConnection(String assetGUID, String connectionGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -659,9 +609,6 @@ public void clearAssetConnection(String userId, * Remove the metadata element representing a connection. This will delete the connection and all anchored * elements such as schema and comments. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectionGUID unique identifier of the metadata element to remove * @param connectionExternalIdentifier unique identifier of the connection in the external source * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -670,10 +617,7 @@ public void clearAssetConnection(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void removeConnection(String userId, - String externalSourceGUID, - String externalSourceName, - String connectionGUID, + public void removeConnection(String connectionGUID, String connectionExternalIdentifier, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -727,7 +671,14 @@ public List findConnections(String searchString, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.findConnections(userId, externalSourceGUID, externalSourceName, searchString, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.findConnections(userId, + externalSourceGUID, + externalSourceName, + searchString, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -754,7 +705,14 @@ public List getConnectionsByName(String name, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getConnectionsByName(userId, externalSourceGUID, externalSourceName, name, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.getConnectionsByName(userId, + externalSourceGUID, + externalSourceName, + name, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -778,7 +736,13 @@ public List getConnectionsForAssetManager(int startFrom, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getConnectionsForAssetManager(userId, externalSourceGUID, externalSourceName, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.getConnectionsForAssetManager(userId, + externalSourceGUID, + externalSourceName, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -786,9 +750,6 @@ public List getConnectionsForAssetManager(int startFrom, /** * Retrieve the connection metadata element with the supplied unique identifier. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectionGUID unique identifier of the requested metadata element * @param effectiveTime when should the elements be effected for - null is anytime; new Date() is now * @@ -798,15 +759,17 @@ public List getConnectionsForAssetManager(int startFrom, * @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 ConnectionElement getConnectionByGUID(String userId, - String externalSourceGUID, - String externalSourceName, - String connectionGUID, + public ConnectionElement getConnectionByGUID(String connectionGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getConnectionByGUID(userId, externalSourceGUID, externalSourceName, connectionGUID, effectiveTime, forLineage, + return connectionExchangeClient.getConnectionByGUID(userId, + externalSourceGUID, + externalSourceName, + connectionGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -904,9 +867,6 @@ public String createEndpointFromTemplate(boolean externalSo /** * Update the metadata element representing an endpoint. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectorTypeGUID unique identifier of the metadata element to update * @param endpointExternalIdentifier unique identifier of the endpoint in the external source * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? @@ -917,10 +877,7 @@ public String createEndpointFromTemplate(boolean externalSo * @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 updateEndpoint(String userId, - String externalSourceGUID, - String externalSourceName, - String connectorTypeGUID, + public void updateEndpoint(String connectorTypeGUID, String endpointExternalIdentifier, boolean isMergeUpdate, EndpointProperties endpointProperties, @@ -960,9 +917,6 @@ public void updateEndpoint(String userId, * Remove the metadata element representing a connector type. This will delete the endpoint and all anchored * elements such as schema and comments. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectorTypeGUID unique identifier of the metadata element to remove * @param endpointExternalIdentifier unique identifier of the endpoint in the external source * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -971,10 +925,7 @@ public void updateEndpoint(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void removeEndpoint(String userId, - String externalSourceGUID, - String externalSourceName, - String connectorTypeGUID, + public void removeEndpoint(String connectorTypeGUID, String endpointExternalIdentifier, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -1028,7 +979,14 @@ public List findEndpoints(String searchString, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.findEndpoints(userId, externalSourceGUID, externalSourceName, searchString, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.findEndpoints(userId, + externalSourceGUID, + externalSourceName, + searchString, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1055,7 +1013,14 @@ public List getEndpointsByName(String name, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getEndpointsByName(userId, externalSourceGUID, externalSourceName, name, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.getEndpointsByName(userId, + externalSourceGUID, + externalSourceName, + name, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1079,7 +1044,13 @@ public List getEndpointsForAssetManager(int startFrom, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getEndpointsForAssetManager(userId, externalSourceGUID, externalSourceName, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.getEndpointsForAssetManager(userId, + externalSourceGUID, + externalSourceName, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1087,9 +1058,6 @@ public List getEndpointsForAssetManager(int startFrom, /** * Retrieve the endpoint metadata element with the supplied unique identifier. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param endpointGUID unique identifier of the requested metadata element * @param effectiveTime when should the elements be effected for - null is anytime; new Date() is now * @@ -1099,15 +1067,17 @@ public List getEndpointsForAssetManager(int startFrom, * @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 EndpointElement getEndpointByGUID(String userId, - String externalSourceGUID, - String externalSourceName, - String endpointGUID, + public EndpointElement getEndpointByGUID(String endpointGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getEndpointByGUID(userId, externalSourceGUID, externalSourceName, endpointGUID, effectiveTime, forLineage, + return connectionExchangeClient.getEndpointByGUID(userId, + externalSourceGUID, + externalSourceName, + endpointGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1205,9 +1175,6 @@ public String createConnectorTypeFromTemplate(boolean exter /** * Update the metadata element representing a connector type. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectorTypeGUID unique identifier of the metadata element to update * @param connectorTypeExternalIdentifier unique identifier of the connectorType in the external connectorType manager * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? @@ -1218,10 +1185,7 @@ public String createConnectorTypeFromTemplate(boolean exter * @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 updateConnectorType(String userId, - String externalSourceGUID, - String externalSourceName, - String connectorTypeGUID, + public void updateConnectorType(String connectorTypeGUID, String connectorTypeExternalIdentifier, boolean isMergeUpdate, ConnectorTypeProperties connectorTypeProperties, @@ -1261,9 +1225,6 @@ public void updateConnectorType(String userId, * Remove the metadata element representing a connector type. This will delete the connectorType and all anchored * elements such as schema and comments. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param connectorTypeGUID unique identifier of the metadata element to remove * @param connectorTypeExternalIdentifier unique identifier of the connectorType in the external connectorType manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -1272,10 +1233,7 @@ public void updateConnectorType(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void removeConnectorType(String userId, - String externalSourceGUID, - String externalSourceName, - String connectorTypeGUID, + public void removeConnectorType(String connectorTypeGUID, String connectorTypeExternalIdentifier, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -1329,7 +1287,14 @@ public List findConnectorTypes(String searchString, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.findConnectorTypes(userId, externalSourceGUID, externalSourceName, searchString, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.findConnectorTypes(userId, + externalSourceGUID, + externalSourceName, + searchString, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1380,7 +1345,13 @@ public List getConnectorTypesForAssetManager(int startFro UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getConnectorTypesForAssetManager(userId, externalSourceGUID, externalSourceName, startFrom, pageSize, effectiveTime, forLineage, + return connectionExchangeClient.getConnectorTypesForAssetManager(userId, + externalSourceGUID, + externalSourceName, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -1388,9 +1359,6 @@ public List getConnectorTypesForAssetManager(int startFro /** * Retrieve the connectorType metadata element with the supplied unique identifier. * - * @param userId calling user - * @param externalSourceGUID unique identifier of software server capability representing the caller - * @param externalSourceName unique name of software server capability representing the caller * @param dataAssetGUID unique identifier of the requested metadata element * @param effectiveTime when should the elements be effected for - null is anytime; new Date() is now * @@ -1400,15 +1368,17 @@ public List getConnectorTypesForAssetManager(int startFro * @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 ConnectorTypeElement getConnectorTypeByGUID(String userId, - String externalSourceGUID, - String externalSourceName, - String dataAssetGUID, + public ConnectorTypeElement getConnectorTypeByGUID(String dataAssetGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - return connectionExchangeClient.getConnectorTypeByGUID(userId, externalSourceGUID, externalSourceName, dataAssetGUID, effectiveTime, forLineage, + return connectionExchangeClient.getConnectorTypeByGUID(userId, + externalSourceGUID, + externalSourceName, + dataAssetGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } } diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/DataAssetExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/DataAssetExchangeService.java index 80090dade1a..555bf720785 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/DataAssetExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/DataAssetExchangeService.java @@ -147,7 +147,6 @@ public String createDataAssetFromTemplate(boolean assetMana /** * Update the metadata element representing an asset. * - * @param userId calling user * @param assetGUID unique identifier of the metadata element to update * @param assetExternalIdentifier unique identifier of the asset in the external asset manager * @param isMergeUpdate should the new properties be merged with existing properties (true) or completely replace them (false)? @@ -158,8 +157,7 @@ public String createDataAssetFromTemplate(boolean assetMana * @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 updateDataAsset(String userId, - String assetGUID, + public void updateDataAsset(String assetGUID, String assetExternalIdentifier, boolean isMergeUpdate, DataAssetProperties assetProperties, @@ -200,7 +198,6 @@ public void updateDataAsset(String userId, * (The zones are set to the list of zones in the publishedZones option configured for each * instance of the Asset Manager OMAS). * - * @param userId calling user * @param assetGUID unique identifier of the metadata element to publish * @param effectiveTime optional date for effective time of the query. Null means any effective time * @@ -208,8 +205,7 @@ public void updateDataAsset(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void publishDataAsset(String userId, - String assetGUID, + public void publishDataAsset(String assetGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException @@ -244,7 +240,6 @@ public void publishDataAsset(String userId, * (The zones are set to the list of zones in the defaultZones option configured for each * instance of the Asset Manager OMAS. This is the setting when the database is first created). * - * @param userId calling user * @param assetGUID unique identifier of the metadata element to withdraw * @param effectiveTime optional date for effective time of the query. Null means any effective time * @@ -252,8 +247,7 @@ public void publishDataAsset(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void withdrawDataAsset(String userId, - String assetGUID, + public void withdrawDataAsset(String assetGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException @@ -287,7 +281,6 @@ public void withdrawDataAsset(String userId, * Remove the metadata element representing an asset. This will delete the asset and all anchored * elements such as schema and comments. * - * @param userId calling user * @param assetGUID unique identifier of the metadata element to remove * @param assetExternalIdentifier unique identifier of the asset in the external asset manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -296,8 +289,7 @@ public void withdrawDataAsset(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void removeDataAsset(String userId, - String assetGUID, + public void removeDataAsset(String assetGUID, String assetExternalIdentifier, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -332,7 +324,6 @@ public void removeDataAsset(String userId, /** * Classify the asset to indicate that it can be used as reference data. * - * @param userId calling user * @param assetGUID unique identifier of the metadata element to update * @param assetExternalIdentifier unique identifier of the asset in the external asset manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -341,8 +332,7 @@ public void removeDataAsset(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void setDataAssetAsReferenceData(String userId, - String assetGUID, + public void setDataAssetAsReferenceData(String assetGUID, String assetExternalIdentifier, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -377,7 +367,6 @@ public void setDataAssetAsReferenceData(String userId, /** * Remove the reference data designation from the asset. * - * @param userId calling user * @param assetGUID unique identifier of the metadata element to update * @param assetExternalIdentifier unique identifier of the asset in the external asset manager * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -386,8 +375,7 @@ public void setDataAssetAsReferenceData(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void clearDataAssetAsReferenceData(String userId, - String assetGUID, + public void clearDataAssetAsReferenceData(String assetGUID, String assetExternalIdentifier, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, @@ -423,7 +411,6 @@ public void clearDataAssetAsReferenceData(String userId, * Link two asset together. * Use information from the relationship type definition to ensure the fromAssetGUID and toAssetGUID are the right way around. * - * @param userId calling user * @param assetManagerIsHome ensure that only the process manager can update this process * @param relationshipTypeName type name of relationship to create * @param fromAssetGUID unique identifier of the asset at end 1 of the relationship @@ -437,8 +424,7 @@ public void clearDataAssetAsReferenceData(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public String setupRelatedDataAsset(String userId, - boolean assetManagerIsHome, + public String setupRelatedDataAsset(boolean assetManagerIsHome, String relationshipTypeName, String fromAssetGUID, String toAssetGUID, @@ -479,7 +465,6 @@ public String setupRelatedDataAsset(String userId, /** * Retrieve the relationship between two elements. * - * @param userId calling user * @param relationshipTypeName type name of relationship to create * @param fromAssetGUID unique identifier of the asset at end 1 of the relationship * @param toAssetGUID unique identifier of the asset at end 2 of the relationship @@ -491,8 +476,7 @@ public String setupRelatedDataAsset(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public RelationshipElement getAssetRelationship(String userId, - String relationshipTypeName, + public RelationshipElement getAssetRelationship(String relationshipTypeName, String fromAssetGUID, String toAssetGUID, Date effectiveTime) throws InvalidParameterException, @@ -514,7 +498,6 @@ public RelationshipElement getAssetRelationship(String userId, /** * Update relationship between two elements. * - * @param userId calling user * @param relationshipTypeName type name of relationship to update * @param relationshipGUID unique identifier of the relationship * @param relationshipProperties description and/or purpose of the relationship @@ -525,8 +508,7 @@ public RelationshipElement getAssetRelationship(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void updateAssetRelationship(String userId, - String relationshipTypeName, + public void updateAssetRelationship(String relationshipTypeName, String relationshipGUID, boolean isMergeUpdate, RelationshipProperties relationshipProperties, @@ -565,7 +547,6 @@ public void updateAssetRelationship(String userId, /** * Remove the relationship between two elements. * - * @param userId calling user * @param relationshipTypeName type name of relationship to delete * @param relationshipGUID unique identifier of the relationship * @param effectiveTime optional date for effective time of the query. Null means any effective time @@ -574,12 +555,11 @@ public void updateAssetRelationship(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public void clearAssetRelationship(String userId, - String relationshipTypeName, + public void clearAssetRelationship(String relationshipTypeName, String relationshipGUID, Date effectiveTime) throws InvalidParameterException, - UserNotAuthorizedException, - PropertyServerException + UserNotAuthorizedException, + PropertyServerException { final String methodName = "clearAssetRelationship"; @@ -610,7 +590,6 @@ public void clearAssetRelationship(String userId, /** * Retrieve the requested relationships linked from a specific element at end 2. * - * @param userId calling user * @param relationshipTypeName type name of relationship to delete * @param fromAssetGUID unique identifier of the asset at end 1 of the relationship * @param startingFrom start position for results @@ -623,8 +602,7 @@ public void clearAssetRelationship(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public List getRelatedAssetsAtEnd2(String userId, - String relationshipTypeName, + public List getRelatedAssetsAtEnd2(String relationshipTypeName, String fromAssetGUID, int startingFrom, int pageSize, @@ -632,7 +610,15 @@ public List getRelatedAssetsAtEnd2(String userId, UserNotAuthorizedException, PropertyServerException { - return dataAssetExchangeClient.getRelatedAssetsAtEnd2(userId, assetManagerGUID, assetManagerName, relationshipTypeName, fromAssetGUID, startingFrom, pageSize, effectiveTime, forLineage, + return dataAssetExchangeClient.getRelatedAssetsAtEnd2(userId, + assetManagerGUID, + assetManagerName, + relationshipTypeName, + fromAssetGUID, + startingFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -640,7 +626,6 @@ public List getRelatedAssetsAtEnd2(String userId, /** * Retrieve the relationships linked from a specific element at end 2 of the relationship. * - * @param userId calling user * @param relationshipTypeName type name of relationship to delete * @param toAssetGUID unique identifier of the asset at end 2 of the relationship * @param startingFrom start position for results @@ -653,8 +638,7 @@ public List getRelatedAssetsAtEnd2(String userId, * @throws UserNotAuthorizedException the user is not authorized to issue this request * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ - public List getRelatedAssetsAtEnd1(String userId, - String relationshipTypeName, + public List getRelatedAssetsAtEnd1(String relationshipTypeName, String toAssetGUID, int startingFrom, int pageSize, @@ -662,7 +646,15 @@ public List getRelatedAssetsAtEnd1(String userId, UserNotAuthorizedException, PropertyServerException { - return dataAssetExchangeClient.getRelatedAssetsAtEnd1(userId, assetManagerGUID, assetManagerName, relationshipTypeName, toAssetGUID, startingFrom, pageSize, effectiveTime, forLineage, + return dataAssetExchangeClient.getRelatedAssetsAtEnd1(userId, + assetManagerGUID, + assetManagerName, + relationshipTypeName, + toAssetGUID, + startingFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -690,7 +682,14 @@ public List findDataAssets(String searchString, UserNotAuthorizedException, PropertyServerException { - return dataAssetExchangeClient.findDataAssets(userId, assetManagerGUID, assetManagerName, searchString, startFrom, pageSize, effectiveTime, forLineage, + return dataAssetExchangeClient.findDataAssets(userId, + assetManagerGUID, + assetManagerName, + searchString, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -717,7 +716,14 @@ public List getDataAssetsByName(String name, UserNotAuthorizedException, PropertyServerException { - return dataAssetExchangeClient.getDataAssetsByName(userId, assetManagerGUID, assetManagerName, name, startFrom, pageSize, effectiveTime, forLineage, + return dataAssetExchangeClient.getDataAssetsByName(userId, + assetManagerGUID, + assetManagerName, + name, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -741,7 +747,13 @@ public List getDataAssetsForAssetManager(int startFrom, UserNotAuthorizedException, PropertyServerException { - return dataAssetExchangeClient.getDataAssetsForAssetManager(userId, assetManagerGUID, assetManagerName, startFrom, pageSize, effectiveTime, forLineage, + return dataAssetExchangeClient.getDataAssetsForAssetManager(userId, + assetManagerGUID, + assetManagerName, + startFrom, + pageSize, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -749,9 +761,6 @@ public List getDataAssetsForAssetManager(int startFrom, /** * Retrieve the asset 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 dataAssetGUID unique identifier of the requested metadata element * @param effectiveTime the time that the retrieved elements must be effective for (null for any time, new Date() for now) * @@ -761,15 +770,17 @@ public List getDataAssetsForAssetManager(int startFrom, * @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 DataAssetElement getDataAssetByGUID(String userId, - String assetManagerGUID, - String assetManagerName, - String dataAssetGUID, + public DataAssetElement getDataAssetByGUID(String dataAssetGUID, Date effectiveTime) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - return dataAssetExchangeClient.getDataAssetByGUID(userId, assetManagerGUID, assetManagerName, dataAssetGUID, effectiveTime, forLineage, + return dataAssetExchangeClient.getDataAssetByGUID(userId, + assetManagerGUID, + assetManagerName, + dataAssetGUID, + effectiveTime, + forLineage, forDuplicateProcessing); } } diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java index 60671862c86..de63dca8fcc 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/GlossaryExchangeService.java @@ -1235,9 +1235,6 @@ public String createGlossaryTerm(String glossaryGUID, /** * Create a new metadata element to represent a glossary term whose lifecycle is managed through a controlled workflow. * - * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller * @param assetManagerIsHome ensure that only the asset manager can update this element * @param glossaryGUID unique identifier of the glossary where the term is located * @param externalIdentifierProperties optional properties used to define an external identifier @@ -1251,10 +1248,7 @@ public String createGlossaryTerm(String glossaryGUID, * @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 createControlledGlossaryTerm(String userId, - String assetManagerGUID, - String assetManagerName, - boolean assetManagerIsHome, + public String createControlledGlossaryTerm(boolean assetManagerIsHome, String glossaryGUID, ExternalIdentifierProperties externalIdentifierProperties, GlossaryTermProperties glossaryTermProperties, @@ -1400,9 +1394,6 @@ public void updateGlossaryTerm(String glossaryTermGUID, * Update the status of the metadata element representing a glossary term. This is only valid on * a controlled glossary term. * - * @param userId calling user - * @param assetManagerGUID unique identifier of software server capability representing the caller - * @param assetManagerName unique name of software server capability representing the caller * @param glossaryTermGUID unique identifier of the glossary term to update * @param glossaryTermExternalIdentifier unique identifier of the glossary term in the external asset manager * @param glossaryTermStatus new properties for the glossary term @@ -1412,10 +1403,7 @@ public void updateGlossaryTerm(String glossaryTermGUID, * @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 updateGlossaryTermStatus(String userId, - String assetManagerGUID, - String assetManagerName, - String glossaryTermGUID, + public void updateGlossaryTermStatus(String glossaryTermGUID, String glossaryTermExternalIdentifier, GlossaryTermStatus glossaryTermStatus, Date effectiveTime) throws InvalidParameterException, diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/LineageExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/LineageExchangeService.java index 4215bc135f3..e27a9b713c0 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/LineageExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/LineageExchangeService.java @@ -2101,9 +2101,6 @@ public void setupLineageMapping(String sourceElementGUID, * is more than one relationship between these two elements since it is used to disambiguate * the request. This is often used in conjunction with update. * - * @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 sourceElementGUID unique identifier of the element that is making the call * @param destinationElementGUID unique identifier of the element that is processing the call * @param qualifiedName unique identifier for this relationship @@ -2117,10 +2114,7 @@ public void setupLineageMapping(String sourceElementGUID, * @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 LineageMappingElement getLineageMapping(String userId, - String assetManagerGUID, - String assetManagerName, - String sourceElementGUID, + public LineageMappingElement getLineageMapping(String sourceElementGUID, String destinationElementGUID, String qualifiedName, Date effectiveTime, diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/OpenMetadataGovernanceService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/OpenMetadataGovernanceService.java index 905592a74f4..4fc4177c864 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/OpenMetadataGovernanceService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/OpenMetadataGovernanceService.java @@ -450,7 +450,6 @@ public ValidMetadataValue getValidMetadataValue(String typeName, /** * Retrieve details of a specific valid name for a map property. * - * @param userId caller's userId * @param typeName type name if this is valid value is specific for a type, or null if this valid value if for the property name for all types * @param propertyName name of property that this valid value applies * @param preferredValue valid value to match @@ -461,8 +460,7 @@ public ValidMetadataValue getValidMetadataValue(String typeName, * @throws UserNotAuthorizedException the service is not able to create/access the element * @throws PropertyServerException there is a problem accessing the metadata store */ - public ValidMetadataValue getValidMetadataMapName(String userId, - String typeName, + public ValidMetadataValue getValidMetadataMapName(String typeName, String propertyName, String preferredValue) throws InvalidParameterException, UserNotAuthorizedException, diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/SchemaExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/SchemaExchangeService.java index 532433c6078..1e76955d44f 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/SchemaExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/SchemaExchangeService.java @@ -167,6 +167,39 @@ public String createSchemaType(boolean assetManagerIsHome, } + /** + * Create a new metadata element to represent a schema type. + * + * @param assetManagerIsHome ensure that only the asset manager can update this schema element + * @param anchorGUID unique identifier of the intended anchor of the schema type + * @param externalIdentifierProperties optional properties used to define an external identifier + * @param schemaTypeProperties properties about the schema type to store + * + * @return unique identifier of the new schema type + * + * @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 createAnchoredSchemaType(boolean assetManagerIsHome, + String anchorGUID, + ExternalIdentifierProperties externalIdentifierProperties, + SchemaTypeProperties schemaTypeProperties) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return schemaExchangeClient.createAnchoredSchemaType(userId, + assetManagerGUID, + assetManagerName, + assetManagerIsHome, + anchorGUID, + externalIdentifierProperties, + forLineage, + forDuplicateProcessing, + schemaTypeProperties); + } + + /** * Create a new metadata element to represent a schema type using an existing metadata element as a template. * @@ -548,7 +581,13 @@ public SchemaTypeElement getSchemaTypeForElement(String parentElementGUID, UserNotAuthorizedException, PropertyServerException { - return schemaExchangeClient.getSchemaTypeForElement(userId, assetManagerGUID, assetManagerName, parentElementGUID, parentElementTypeName, effectiveTime, forLineage, + return schemaExchangeClient.getSchemaTypeForElement(userId, + assetManagerGUID, + assetManagerName, + parentElementGUID, + parentElementTypeName, + effectiveTime, + forLineage, forDuplicateProcessing); } @@ -876,9 +915,6 @@ public void clearSchemaElementAsCalculatedValue(String schemaElementGUID, /** * Classify the column schema attribute to indicate that it describes a primary key. * - * @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 assetManagerIsHome ensure that only the asset manager can update this classification * @param schemaAttributeGUID unique identifier of the metadata element to update * @param schemaAttributeExternalIdentifier unique identifier of the schema attribute in the external asset manager @@ -890,10 +926,7 @@ public void clearSchemaElementAsCalculatedValue(String schemaElementGUID, * @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 setupColumnAsPrimaryKey(String userId, - String assetManagerGUID, - String assetManagerName, - boolean assetManagerIsHome, + public void setupColumnAsPrimaryKey(boolean assetManagerIsHome, String schemaAttributeGUID, String schemaAttributeExternalIdentifier, String primaryKeyName, @@ -1026,9 +1059,6 @@ public void setupForeignKeyRelationship(boolean assetManagerIsHome, /** * Update the relationship properties for the query target. * - * @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 primaryKeyGUID unique identifier of the derived schema element * @param foreignKeyGUID unique identifier of the query target schema element * @param foreignKeyProperties properties for the foreign key relationship @@ -1038,10 +1068,7 @@ public void setupForeignKeyRelationship(boolean assetManagerIsHome, * @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 updateForeignKeyRelationship(String userId, - String assetManagerGUID, - String assetManagerName, - String primaryKeyGUID, + public void updateForeignKeyRelationship(String primaryKeyGUID, String foreignKeyGUID, ForeignKeyProperties foreignKeyProperties, Date effectiveTime) throws InvalidParameterException, diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/StewardshipExchangeService.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/StewardshipExchangeService.java index bda5d8cd4ff..e4d675ec5fc 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/StewardshipExchangeService.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/connector/StewardshipExchangeService.java @@ -4,8 +4,30 @@ package org.odpi.openmetadata.integrationservices.catalog.connector; import org.odpi.openmetadata.accessservices.assetmanager.client.exchange.StewardshipExchangeClient; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.AssetElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GlossaryTermElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.GovernanceDefinitionElement; +import org.odpi.openmetadata.accessservices.assetmanager.metadataelements.RelatedElement; +import org.odpi.openmetadata.accessservices.assetmanager.properties.AssetOriginProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataFieldQueryProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.DataFieldValuesProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.FindAssetOriginProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.GovernanceClassificationProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.OwnerProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.RetentionClassificationProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SecurityTagsProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SemanticAssignmentProperties; +import org.odpi.openmetadata.accessservices.assetmanager.properties.SubjectAreaMemberProperties; import org.odpi.openmetadata.accessservices.assetmanager.properties.SynchronizationDirection; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementStub; +import org.odpi.openmetadata.integrationservices.catalog.ffdc.CatalogIntegratorErrorCode; + +import java.util.Date; +import java.util.List; /** @@ -53,8 +75,6 @@ public class StewardshipExchangeService } - - /* ======================================================== * Set up the forLineage flag */ @@ -107,4 +127,1212 @@ public void setForDuplicateProcessing(boolean forDuplicateProcessing) } + /* ======================================= + * Specialized interface begins + */ + + /** + * Classify the element to indicate that it describes a data field and supply + * properties that describe the characteristics of the data values found within. + * + * @param elementGUID unique identifier of the metadata element to update + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties descriptive properties for the data field + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 setElementAsDataField(String elementGUID, + String externalIdentifier, + DataFieldValuesProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setElementAsDataField"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.setElementAsDataField(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the data field designation from the element. + * + * @param elementGUID unique identifier of the metadata element to update + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 clearElementAsDataField(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearElementAsDataField"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearElementAsDataField(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the elements classified with the DataField classification. + * + * @param properties values to match on + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getDataFieldClassifiedElements(DataFieldQueryProperties properties, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getDataFieldClassifiedElements(userId, assetManagerGUID, assetManagerName, properties, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Classify/reclassify the element (typically an asset) to indicate the level of confidence that the organization + * has that the data is complete, accurate and up-to-date. The level of confidence is expressed by the + * levelIdentifier property. + * + * @param elementGUID unique identifier of the metadata element to classify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the classification + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 setConfidenceClassification(String elementGUID, + String externalIdentifier, + GovernanceClassificationProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setConfidenceClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.setConfidenceClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the confidence classification from the element. This normally occurs when the organization has lost track of the level of + * confidence to assign to the element. + * + * @param elementGUID unique identifier of the metadata element to unclassify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 clearConfidenceClassification(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearConfidenceClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearConfidenceClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the elements classified with the confidence classification. + * + * @param returnSpecificLevel should the results be filtered by levelIdentifier? + * @param levelIdentifier the identifier to filter by (if returnSpecificLevel=true) + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getConfidenceClassifiedElements(boolean returnSpecificLevel, + int levelIdentifier, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getConfidenceClassifiedElements(userId, assetManagerGUID, assetManagerName, returnSpecificLevel, levelIdentifier, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Classify/reclassify the element (typically an asset) to indicate how critical the element (or associated resource) + * is to the organization. The level of criticality is expressed by the levelIdentifier property. + * + * @param elementGUID unique identifier of the metadata element to classify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the classification + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 setCriticalityClassification(String elementGUID, + GovernanceClassificationProperties properties, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setCriticalityClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.setCriticalityClassification(userId, assetManagerGUID, assetManagerName, elementGUID, properties, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the criticality classification from the element. This normally occurs when the organization has lost track of the level of + * criticality to assign to the element. + * + * @param elementGUID unique identifier of the metadata element to unclassify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 clearCriticalityClassification(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearCriticalityClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearCriticalityClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the elements classified with the criticality classification. + * + * @param returnSpecificLevel should the results be filtered by levelIdentifier? + * @param levelIdentifier the identifier to filter by (if returnSpecificLevel=true) + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getCriticalityClassifiedElements(boolean returnSpecificLevel, + int levelIdentifier, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getCriticalityClassifiedElements(userId, assetManagerGUID, assetManagerName, returnSpecificLevel, levelIdentifier, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Classify/reclassify the element (typically a data field, schema attribute or glossary term) to indicate the level of confidentiality + * that any data associated with the element should be given. If the classification is attached to a glossary term, the level + * of confidentiality is a suggestion for any element linked to the glossary term via the SemanticAssignment classification. + * The level of confidence is expressed by the levelIdentifier property. + * + * @param elementGUID unique identifier of the metadata element to classify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the classification + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 setConfidentialityClassification(String elementGUID, + String externalIdentifier, + GovernanceClassificationProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setConfidentialityClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.setConfidentialityClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the confidence classification from the element. This normally occurs when the organization has lost track of the level of + * confidentiality to assign to the element. + * + * @param elementGUID unique identifier of the metadata element to unclassify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 clearConfidentialityClassification(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearConfidentialityClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearConfidentialityClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the elements classified with the confidentiality classification. + * + * @param returnSpecificLevel should the results be filtered by levelIdentifier? + * @param levelIdentifier the identifier to filter by (if returnSpecificLevel=true) + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getConfidentialityClassifiedElements(boolean returnSpecificLevel, + int levelIdentifier, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getConfidentialityClassifiedElements(userId, assetManagerGUID, assetManagerName, returnSpecificLevel, levelIdentifier, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Classify/reclassify the element (typically an asset) to indicate how long the element (or associated resource) + * is to be retained by the organization. The policy to apply to the element/resource is captured by the retentionBasis + * property. The dates after which the element/resource is archived and then deleted are specified in the archiveAfter and deleteAfter + * properties respectively. + * + * @param elementGUID unique identifier of the metadata element to classify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the classification + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 setRetentionClassification(String elementGUID, + String externalIdentifier, + RetentionClassificationProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setRetentionClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.setRetentionClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the retention classification from the element. This normally occurs when the organization has lost track of, or no longer needs to + * track the retention period to assign to the element. + * + * @param elementGUID unique identifier of the metadata element to unclassify + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 clearRetentionClassification(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearRetentionClassification"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearRetentionClassification(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the elements classified with the retention classification. + * + * @param returnSpecificBasisIdentifier should the results be filtered by basisIdentifier? + * @param basisIdentifier the identifier to filter by (if returnSpecificBasisIdentifier=true) + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getRetentionClassifiedElements(boolean returnSpecificBasisIdentifier, + int basisIdentifier, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getRetentionClassifiedElements(userId, assetManagerGUID, assetManagerName, returnSpecificBasisIdentifier, basisIdentifier, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + + /** + * Add or replace the security tags for an element. + * + * @param elementGUID element to link it to - its type must inherit from Referenceable. + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the security tags + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @throws InvalidParameterException element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void addSecurityTags(String elementGUID, + String externalIdentifier, + SecurityTagsProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "addSecurityTags"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.addSecurityTags(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the security tags classification from an element. + * + * @param elementGUID element where the security tags need to be removed. + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @throws InvalidParameterException asset or element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void clearSecurityTags(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearSecurityTags"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearSecurityTags(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the contents of a subject area such as the glossaries, reference data sets and quality definitions. + * + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getSecurityTaggedElements(int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getSecurityTaggedElements(userId, assetManagerGUID, assetManagerName, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Add or replace the ownership classification for an element. + * + * @param elementGUID element to link it to - its type must inherit from Referenceable. + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the ownership + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @throws InvalidParameterException element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void addOwnership(String elementGUID, + String externalIdentifier, + OwnerProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "addOwnership"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.addOwnership(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the ownership classification from an element. + * + * @param elementGUID element where the classification needs to be removed. + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @throws InvalidParameterException asset or element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void clearOwnership(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearOwnership"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearOwnership(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the contents of a subject area such as the glossaries, reference data sets and quality definitions. + * + * @param owner unique identifier for the owner + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getOwnersElements(String owner, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getOwnersElements(userId, assetManagerGUID, assetManagerName, owner, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Add or replace the origin classification for an asset. + * + * @param assetGUID element to link it to - its type must inherit from Asset. + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties details of the origin + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @throws InvalidParameterException element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void addAssetOrigin(String assetGUID, + String externalIdentifier, + AssetOriginProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "addAssetOrigin"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.addAssetOrigin(userId, assetManagerGUID, assetManagerName, assetGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the origin classification from an asset. + * + * @param assetGUID element where the classification needs to be removed + * @param externalIdentifier optional matching identifier from an external system + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @throws InvalidParameterException asset or element not known, null userId or guid + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public void clearAssetOrigin(String assetGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearAssetOrigin"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearAssetOrigin(userId, assetManagerGUID, assetManagerName, assetGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the assets from a specific origin. + * + * @param properties values to search on - null means any value + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of the assets + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getAssetsByOrigin(FindAssetOriginProperties properties, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getAssetsByOrigin(userId, assetManagerGUID, assetManagerName, properties, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Classify the element to assert that the definitions it represents are part of a subject area definition. + * + * @param elementGUID unique identifier of the metadata element to update + * @param externalIdentifier unique identifier of the element in the external asset manager + * @param properties qualified name of subject area + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 addElementToSubjectArea(String elementGUID, + String externalIdentifier, + SubjectAreaMemberProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "addElementToSubjectArea"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.addElementToSubjectArea(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the subject area designation from the identified element. + * + * @param elementGUID unique identifier of the metadata element to update + * @param externalIdentifier unique identifier of the equivalent element in the external asset manager + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 removeElementFromSubjectArea(String elementGUID, + String externalIdentifier, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "removeElementFromSubjectArea"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.removeElementFromSubjectArea(userId, assetManagerGUID, assetManagerName, elementGUID, externalIdentifier, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Return information about the contents of a subject area such as the glossaries, reference data sets and quality definitions. + * + * @param subjectAreaName unique identifier for the subject area + * @param startFrom paging start point + * @param pageSize maximum results that can be returned + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of element stubs + * + * @throws InvalidParameterException qualifiedName or userId is null + * @throws PropertyServerException problem accessing property server + * @throws UserNotAuthorizedException security access problem + */ + public List getMembersOfSubjectArea(String subjectAreaName, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getMembersOfSubjectArea(userId, assetManagerGUID, assetManagerName, subjectAreaName, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Create a semantic assignment relationship between a glossary term and an element (normally a schema attribute, data field or asset). + * This relationship indicates that the data associated with the element meaning matches the description in the glossary term. + * + * @param elementGUID unique identifier of the element that is being assigned to the glossary term + * @param glossaryTermGUID unique identifier of the glossary term that provides the meaning + * @param properties properties for the relationship + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 setupSemanticAssignment(String elementGUID, + String glossaryTermGUID, + SemanticAssignmentProperties properties, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "setupSemanticAssignment"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.setupSemanticAssignment(userId, assetManagerGUID, assetManagerName, elementGUID, glossaryTermGUID, properties, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove a semantic assignment relationship between an element and its glossary term. + * + * @param elementGUID unique identifier of the element that is being assigned to the glossary term + * @param glossaryTermGUID unique identifier of the glossary term that provides the meaning + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 clearSemanticAssignment(String elementGUID, + String glossaryTermGUID, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "clearSemanticAssignment"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.clearSemanticAssignment(userId, assetManagerGUID, assetManagerName, elementGUID, glossaryTermGUID, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Retrieve the glossary terms linked via a "SemanticAssignment" relationship to the requested element. + * + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of related elements + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getMeanings(String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getMeanings(userId, assetManagerGUID, assetManagerName, elementGUID, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Retrieve the elements linked via a "SemanticAssignment" relationship to the requested glossary term. + * + * @param glossaryTermGUID unique identifier of the glossary term that the returned elements are linked to + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of related elements + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getSemanticAssignees(String glossaryTermGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getSemanticAssignees(userId, assetManagerGUID, assetManagerName, glossaryTermGUID, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + + /** + * Link a governance definition to an element using the GovernedBy relationship. + * + * @param definitionGUID identifier of the governance definition to link + * @param elementGUID unique identifier of the metadata element to link + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 addGovernanceDefinitionToElement(String definitionGUID, + String elementGUID, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "addGovernanceDefinitionToElement"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.addGovernanceDefinitionToElement(userId, assetManagerGUID, assetManagerName, definitionGUID, elementGUID, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Remove the GovernedBy relationship between a governance definition and an element. + * + * @param definitionGUID identifier of the governance definition to link + * @param elementGUID unique identifier of the metadata element to update + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @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 removeGovernanceDefinitionFromElement(String definitionGUID, + String elementGUID, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + final String methodName = "removeGovernanceDefinitionFromElement"; + + if (synchronizationDirection != SynchronizationDirection.TO_THIRD_PARTY) + { + stewardshipExchangeClient.removeGovernanceDefinitionFromElement(userId, assetManagerGUID, assetManagerName, definitionGUID, elementGUID, effectiveTime, forLineage, forDuplicateProcessing); + } + else + { + throw new UserNotAuthorizedException(CatalogIntegratorErrorCode.NOT_PERMITTED_SYNCHRONIZATION.getMessageDefinition( + synchronizationDirection.getName(), + connectorName, + methodName), + this.getClass().getName(), + methodName, + userId); + } + } + + + /** + * Retrieve the governance definitions linked via a "GovernedBy" relationship to the requested element. + * + * @param elementGUID unique identifier of the element + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of related elements + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getGovernedByDefinitions(String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getGovernedByDefinitions(userId, assetManagerGUID, assetManagerName, elementGUID, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Retrieve the elements linked via a "GovernedBy" relationship to the requested governance definition. + * + * @param governanceDefinitionGUID unique identifier of the glossary term that the returned elements are linked to + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of related elements + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getGovernedElements(String governanceDefinitionGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getGovernedElements(userId, assetManagerGUID, assetManagerName, governanceDefinitionGUID, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Retrieve the elements linked via a "SourceFrom" relationship to the requested element. + * The elements returned were used to create the requested element. Typically only one element is returned. + * + * @param elementGUID unique identifier of the glossary term that the returned elements are linked to + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of related elements + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getSourceElements(String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getSourceElements(userId, assetManagerGUID, assetManagerName, elementGUID, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } + + + /** + * Retrieve the elements linked via a "SourceFrom" relationship to the requested element. + * The elements returned were created using the requested element as a template. + * + * @param elementGUID unique identifier of the glossary term that the returned elements are linked to + * @param startFrom index of the list to start from (0 for start) + * @param pageSize maximum number of elements to return. + * @param effectiveTime the time that the retrieved elements must be effective for + * + * @return list of related elements + * @throws InvalidParameterException one of the parameters is invalid + * @throws UserNotAuthorizedException the user is not authorized to issue this request + * @throws PropertyServerException there is a problem reported in the open metadata server(s) + */ + public List getElementsSourceFrom(String elementGUID, + int startFrom, + int pageSize, + Date effectiveTime) throws InvalidParameterException, + UserNotAuthorizedException, + PropertyServerException + { + return stewardshipExchangeClient.getElementsSourceFrom(userId, assetManagerGUID, assetManagerName, elementGUID, startFrom, pageSize, effectiveTime, forLineage, forDuplicateProcessing); + } } diff --git a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/ffdc/CatalogIntegratorErrorCode.java b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/ffdc/CatalogIntegratorErrorCode.java index 1ec5fb067e2..02ea2211552 100644 --- a/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/ffdc/CatalogIntegratorErrorCode.java +++ b/open-metadata-implementation/integration-services/catalog-integrator/catalog-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/catalog/ffdc/CatalogIntegratorErrorCode.java @@ -64,6 +64,18 @@ public enum CatalogIntegratorErrorCode implements ExceptionMessageSet "The access service has not been passed valid configuration .", "Correct the value of the failing configuration property and restart the server."), + + + + /** + * OMIS-CATALOG-INTEGRATOR-400-006 - Integration connector {0} has passed a null element to {1} + */ + NULL_ELEMENT_PASSED(400,"OMIS-CATALOG-INTEGRATOR-400-006", + "Integration connector {0} has passed a null element to {1} in parameter {2}", + "The integration connector called the method with a null element. This means it has a logic error because the element should not be null.", + "Gather information about the connector's configuration, the types of metadata it was integrating, the audit log messages " + + "from the integration daemon and its partner metadata server. Look at the logic and path through the code and correct the error."), + /** * OMIS-CATALOG-INTEGRATOR-500-001 - Integration connector {0} has a null context */ diff --git a/open-metadata-implementation/integration-services/display-integrator/display-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/display/connector/DisplayIntegratorContext.java b/open-metadata-implementation/integration-services/display-integrator/display-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/display/connector/DisplayIntegratorContext.java index 2ee2941bd78..bf076091fe8 100644 --- a/open-metadata-implementation/integration-services/display-integrator/display-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/display/connector/DisplayIntegratorContext.java +++ b/open-metadata-implementation/integration-services/display-integrator/display-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/display/connector/DisplayIntegratorContext.java @@ -506,9 +506,6 @@ public void withdrawReport(String reportGUID) throws InvalidParameterException, /** * Remove the metadata element representing a report. * - * @param userId calling user - * @param applicationGUID unique identifier of software server capability representing the event broker - * @param applicationName unique name of software server capability representing the event broker * @param reportGUID unique identifier of the metadata element to remove * @param qualifiedName unique name of the metadata element to remove * @@ -516,15 +513,12 @@ public void withdrawReport(String reportGUID) throws InvalidParameterException, * @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 removeReport(String userId, - String applicationGUID, - String applicationName, - String reportGUID, + public void removeReport(String reportGUID, String qualifiedName) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - client.removeReport(userId, applicationGUID, applicationName, reportGUID, qualifiedName); + client.removeReport(userId, externalSourceGUID, externalSourceName, reportGUID, qualifiedName); if (integrationReportWriter != null) { @@ -767,9 +761,6 @@ public void withdrawQuery(String queryGUID) throws InvalidParameterException, /** * Remove the metadata element representing a query. * - * @param userId calling user - * @param applicationGUID unique identifier of software server capability representing the event broker - * @param applicationName unique name of software server capability representing the event broker * @param queryGUID unique identifier of the metadata element to remove * @param qualifiedName unique name of the metadata element to remove * @@ -777,15 +768,12 @@ public void withdrawQuery(String queryGUID) throws InvalidParameterException, * @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 removeQuery(String userId, - String applicationGUID, - String applicationName, - String queryGUID, + public void removeQuery(String queryGUID, String qualifiedName) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - client.removeQuery(userId, applicationGUID, applicationName, queryGUID, qualifiedName); + client.removeQuery(userId, externalSourceGUID, externalSourceName, queryGUID, qualifiedName); if (integrationReportWriter != null) { @@ -1040,7 +1028,6 @@ public List findDataContainers(String typeName, /** * Return the data container associated with a specific open metadata element (data asset, process or port). * - * @param userId calling user * @param parentElementGUID unique identifier of the open metadata element that this data container is connected to * @param startFrom paging start point * @param pageSize maximum results that can be returned @@ -1051,8 +1038,7 @@ public List findDataContainers(String typeName, * @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 getDataContainersForElement(String userId, - String parentElementGUID, + public List getDataContainersForElement(String parentElementGUID, int startFrom, int pageSize) throws InvalidParameterException, UserNotAuthorizedException, @@ -1259,23 +1245,17 @@ public void updateDataField(String dataFieldGUID, /** * Remove the metadata element representing a data field. * - * @param userId calling user - * @param applicationGUID unique identifier of software server capability representing the event broker - * @param applicationName unique name of software server capability representing the event broker * @param dataFieldGUID unique identifier of the metadata element to remove * * @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 removeDataField(String userId, - String applicationGUID, - String applicationName, - String dataFieldGUID) throws InvalidParameterException, + public void removeDataField(String dataFieldGUID) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - client.removeDataField(userId, applicationGUID, applicationName, dataFieldGUID); + client.removeDataField(userId, externalSourceGUID, externalSourceName, dataFieldGUID); if (integrationReportWriter != null) { @@ -1358,7 +1338,6 @@ public List getDataFieldsByName(String name, /** * Retrieve the data field metadata element with the supplied unique identifier. * - * @param userId calling user * @param guid unique identifier of the requested metadata element * * @return requested metadata element @@ -1367,8 +1346,7 @@ public List getDataFieldsByName(String name, * @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 DataFieldElement getDataFieldByGUID(String userId, - String guid) throws InvalidParameterException, + public DataFieldElement getDataFieldByGUID(String guid) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { diff --git a/open-metadata-implementation/integration-services/infrastructure-integrator/infrastructure-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/infrastructure/connector/InfrastructureIntegratorContext.java b/open-metadata-implementation/integration-services/infrastructure-integrator/infrastructure-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/infrastructure/connector/InfrastructureIntegratorContext.java index e383e05e1d7..eba7c812307 100644 --- a/open-metadata-implementation/integration-services/infrastructure-integrator/infrastructure-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/infrastructure/connector/InfrastructureIntegratorContext.java +++ b/open-metadata-implementation/integration-services/infrastructure-integrator/infrastructure-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/infrastructure/connector/InfrastructureIntegratorContext.java @@ -66,7 +66,7 @@ public class InfrastructureIntegratorContext extends IntegrationContext private final ServerManagerClient serverManagerClient; private final ITInfrastructureEventClient eventClient; - private boolean infrastructureManagerIsHome = true; + private boolean externalSourceIsHome = true; static final String assetTypeName = "Asset"; @@ -158,11 +158,11 @@ public InfrastructureIntegratorContext(String connectorId, /** * Set up the flag that controls the ownership of metadata created for this infrastructure manager. Default is true. * - * @param infrastructureManagerIsHome should the metadata be marked as owned by the infrastructure manager so others can not update? + * @param externalSourceIsHome should the metadata be marked as owned by the infrastructure manager so others can not update? */ - public void setInfrastructureManagerIsHome(boolean infrastructureManagerIsHome) + public void setInfrastructureManagerIsHome(boolean externalSourceIsHome) { - this.infrastructureManagerIsHome = infrastructureManagerIsHome; + this.externalSourceIsHome = externalSourceIsHome; } @@ -214,7 +214,7 @@ public String createHost(HostProperties hostProperties) throws InvalidParameterE UserNotAuthorizedException, PropertyServerException { - return hostManagerClient.createHost(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, hostProperties); + return hostManagerClient.createHost(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, hostProperties); } @@ -235,7 +235,7 @@ public String createHostFromTemplate(String templateGUID, UserNotAuthorizedException, PropertyServerException { - return hostManagerClient.createHostFromTemplate(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, templateGUID, templateProperties); + return hostManagerClient.createHostFromTemplate(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, templateGUID, templateProperties); } @@ -279,7 +279,7 @@ public void setupClusterMember(String hostGUID, UserNotAuthorizedException, PropertyServerException { - hostManagerClient.setupClusterMember(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, hostGUID, clusterMemberGUID, effectiveFrom, effectiveTo); + hostManagerClient.setupClusterMember(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, hostGUID, clusterMemberGUID, effectiveFrom, effectiveTo); } @@ -502,7 +502,7 @@ public String createSoftwareServerPlatform(SoftwareServerPlatformProperties plat UserNotAuthorizedException, PropertyServerException { - return platformManagerClient.createSoftwareServerPlatform(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, platformProperties); + return platformManagerClient.createSoftwareServerPlatform(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, platformProperties); } @@ -523,7 +523,7 @@ public String createSoftwareServerPlatformFromTemplate(String templa UserNotAuthorizedException, PropertyServerException { - return platformManagerClient.createSoftwareServerPlatformFromTemplate(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, templateGUID, templateProperties); + return platformManagerClient.createSoftwareServerPlatformFromTemplate(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, templateGUID, templateProperties); } @@ -724,7 +724,7 @@ public String createSoftwareServer(SoftwareServerProperties softwareServerProper UserNotAuthorizedException, PropertyServerException { - return serverManagerClient.createSoftwareServer(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, softwareServerProperties); + return serverManagerClient.createSoftwareServer(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, softwareServerProperties); } @@ -746,7 +746,7 @@ public String createSoftwareServerFromTemplate(String templateGUID, PropertyServerException { - return serverManagerClient.createSoftwareServerFromTemplate(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, templateGUID, templateProperties); + return serverManagerClient.createSoftwareServerFromTemplate(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, templateGUID, templateProperties); } @@ -949,7 +949,7 @@ public void addServerPurpose(String itAssetGUID, UserNotAuthorizedException, PropertyServerException { - serverManagerClient.addServerPurpose(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, itAssetGUID, classificationName, effectiveFrom, effectiveTo, classificationProperties); + serverManagerClient.addServerPurpose(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, itAssetGUID, classificationName, effectiveFrom, effectiveTo, classificationProperties); } @@ -1019,7 +1019,7 @@ public void deployITAsset(String itAssetGUID, UserNotAuthorizedException, PropertyServerException { - serverManagerClient.deployITAsset(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, itAssetGUID, destinationGUID, deploymentProperties); + serverManagerClient.deployITAsset(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, itAssetGUID, destinationGUID, deploymentProperties); } @@ -1137,7 +1137,7 @@ public String createSoftwareCapability(String classificati UserNotAuthorizedException, PropertyServerException { - return capabilityManagerClient.createSoftwareCapability(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, classificationName, capabilityProperties); + return capabilityManagerClient.createSoftwareCapability(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, classificationName, capabilityProperties); } @@ -1158,7 +1158,7 @@ public String createSoftwareCapabilityFromTemplate(String templateGU UserNotAuthorizedException, PropertyServerException { - return capabilityManagerClient.createSoftwareCapabilityFromTemplate(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, templateGUID, templateProperties); + return capabilityManagerClient.createSoftwareCapabilityFromTemplate(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, templateGUID, templateProperties); } @@ -1202,7 +1202,7 @@ public void deployCapability(String capabilityGUID, UserNotAuthorizedException, PropertyServerException { - capabilityManagerClient.deployCapability(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, capabilityGUID, infrastructureAssetGUID, deploymentProperties); + capabilityManagerClient.deployCapability(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, capabilityGUID, infrastructureAssetGUID, deploymentProperties); } @@ -1436,7 +1436,7 @@ public String createServerAssetUse(String capabilityGUID, UserNotAuthorizedException, PropertyServerException { - return capabilityManagerClient.createServerAssetUse(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, capabilityGUID, assetGUID, properties); + return capabilityManagerClient.createServerAssetUse(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, capabilityGUID, assetGUID, properties); } @@ -1601,7 +1601,7 @@ public String createDataAsset(DataAssetProperties dataAssetProperties) throws In UserNotAuthorizedException, PropertyServerException { - return dataAssetManagerClient.createDataAsset(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, dataAssetProperties); + return dataAssetManagerClient.createDataAsset(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, dataAssetProperties); } @@ -1624,7 +1624,7 @@ public String createDataAssetFromTemplate(String templateGUID, PropertyServerException { - return dataAssetManagerClient.createDataAssetFromTemplate(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, templateGUID, templateProperties); + return dataAssetManagerClient.createDataAssetFromTemplate(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, templateGUID, templateProperties); } @@ -1869,7 +1869,7 @@ public String createProcess(ProcessStatus processStatus, UserNotAuthorizedException, PropertyServerException { - return processManagerClient.createProcess(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, processStatus, processProperties); + return processManagerClient.createProcess(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, processStatus, processProperties); } @@ -1891,7 +1891,7 @@ public String createProcessFromTemplate(String templateGUID, PropertyServerException { - return processManagerClient.createProcessFromTemplate(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, templateGUID, templateProperties); + return processManagerClient.createProcessFromTemplate(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, templateGUID, templateProperties); } @@ -1957,7 +1957,7 @@ public void setupProcessParent(String parentProcessGUID, UserNotAuthorizedException, PropertyServerException { - processManagerClient.setupProcessParent(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, parentProcessGUID, childProcessGUID, containmentType, effectiveFrom, effectiveTo); + processManagerClient.setupProcessParent(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, parentProcessGUID, childProcessGUID, containmentType, effectiveFrom, effectiveTo); } @@ -2249,7 +2249,7 @@ public String setupDataFlow(String dataSupplierGUID, PropertyServerException { - return processManagerClient.setupDataFlow(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, dataSupplierGUID, dataConsumerGUID, properties, effectiveTime); + return processManagerClient.setupDataFlow(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, dataSupplierGUID, dataConsumerGUID, properties, effectiveTime); } @@ -2397,7 +2397,7 @@ public String setupControlFlow(String currentStepGUID, PropertyServerException { - return processManagerClient.setupControlFlow(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, currentStepGUID, nextStepGUID, properties, effectiveTime); + return processManagerClient.setupControlFlow(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, currentStepGUID, nextStepGUID, properties, effectiveTime); } @@ -2545,7 +2545,7 @@ public String setupProcessCall(String callerGUID, PropertyServerException { - return processManagerClient.setupProcessCall(userId, externalSourceGUID, externalSourceName, infrastructureManagerIsHome, callerGUID, calledGUID, properties, effectiveTime); + return processManagerClient.setupProcessCall(userId, externalSourceGUID, externalSourceName, externalSourceIsHome, callerGUID, calledGUID, properties, effectiveTime); } @@ -3491,9 +3491,6 @@ public ConnectorTypeElement getConnectorTypeByGUID(String connectorTypeGUID) thr * profile describes using the ITInfrastructureProfile relationship. If the itUserId is specified, a UserIdentity for that userId is * found/created and connected to the new IT profile. * - * @param userId calling user - * @param infrastructureManagerGUID guid of the software server capability entity that represented the external source - null for local - * @param infrastructureManagerName name of the software server capability entity that represented the external source * @param itInfrastructureGUID unique identifier of the piece of IT infrastructure that is described by the new IT profile. * @param itUserId userId used by the IT Infrastructure * @param properties properties for an IT profile @@ -3504,25 +3501,19 @@ public ConnectorTypeElement getConnectorTypeByGUID(String connectorTypeGUID) thr * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - public String createITProfile(String userId, - String infrastructureManagerGUID, - String infrastructureManagerName, - String itInfrastructureGUID, + public String createITProfile(String itInfrastructureGUID, String itUserId, ITProfileProperties properties) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - return itProfileManagerClient.createITProfile(userId, infrastructureManagerGUID, infrastructureManagerName, itInfrastructureGUID, itUserId, properties); + return itProfileManagerClient.createITProfile(userId, externalSourceGUID, externalSourceName, itInfrastructureGUID, itUserId, properties); } /** * Update the definition of an IT profile. * - * @param userId calling user - * @param infrastructureManagerGUID guid of the software server capability entity that represented the external source - null for local - * @param infrastructureManagerName name of the software server capability entity that represented the external source * @param itProfileGUID unique identifier of IT profile * @param isMergeUpdate are unspecified properties unchanged (true) or replaced with null? * @param properties properties to change @@ -3531,48 +3522,36 @@ public String createITProfile(String userId, * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - public void updateITProfile(String userId, - String infrastructureManagerGUID, - String infrastructureManagerName, - String itProfileGUID, + public void updateITProfile(String itProfileGUID, boolean isMergeUpdate, ITProfileProperties properties) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - itProfileManagerClient.updateITProfile(userId, infrastructureManagerGUID, infrastructureManagerName, itProfileGUID, isMergeUpdate, properties); + itProfileManagerClient.updateITProfile(userId, externalSourceGUID, externalSourceName, itProfileGUID, isMergeUpdate, properties); } /** * Remove the definition of an IT profile. * - * @param userId calling user - * @param infrastructureManagerGUID guid of the software server capability entity that represented the external source - null for local - * @param infrastructureManagerName name of the software server capability entity that represented the external source * @param itProfileGUID unique identifier of IT profile * * @throws InvalidParameterException guid or userId is null; guid is not known * @throws PropertyServerException problem accessing property server * @throws UserNotAuthorizedException security access problem */ - public void deleteITProfile(String userId, - String infrastructureManagerGUID, - String infrastructureManagerName, - String itProfileGUID) throws InvalidParameterException, + public void deleteITProfile(String itProfileGUID) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - itProfileManagerClient.deleteITProfile(userId, infrastructureManagerGUID, infrastructureManagerName, itProfileGUID); + itProfileManagerClient.deleteITProfile(userId, externalSourceGUID, externalSourceName, itProfileGUID); } /** * Add a new contact method to the profile. * - * @param userId the name of the calling user. - * @param infrastructureManagerGUID guid of the software server capability entity that represented the external source - null for local - * @param infrastructureManagerName name of the software server capability entity that represented the external source * @param itProfileGUID identifier of the profile to update. * @param properties properties of contact method. * @@ -3582,38 +3561,29 @@ public void deleteITProfile(String userId, * @throws PropertyServerException there is a problem retrieving information from the property server(s). * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. */ - public String addContactMethod(String userId, - String infrastructureManagerGUID, - String infrastructureManagerName, - String itProfileGUID, + public String addContactMethod(String itProfileGUID, ContactMethodProperties properties) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { - return itProfileManagerClient.addContactMethod(userId, infrastructureManagerGUID, infrastructureManagerName, itProfileGUID, properties); + return itProfileManagerClient.addContactMethod(userId, externalSourceGUID, externalSourceName, itProfileGUID, properties); } /** * Remove an obsolete contact method from the profile. * - * @param userId the name of the calling user. - * @param infrastructureManagerGUID guid of the software server capability entity that represented the external source - null for local - * @param infrastructureManagerName name of the software server capability entity that represented the external source * @param contactMethodGUID unique identifier (guid) for the obsolete contact method. * * @throws InvalidParameterException the userId is null or invalid. Another property is invalid. * @throws PropertyServerException there is a problem retrieving information from the property server(s). * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. */ - public void deleteContactMethod(String userId, - String infrastructureManagerGUID, - String infrastructureManagerName, - String contactMethodGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public void deleteContactMethod(String contactMethodGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { - itProfileManagerClient.deleteContactMethod(userId, infrastructureManagerGUID, infrastructureManagerName, contactMethodGUID); + itProfileManagerClient.deleteContactMethod(userId, externalSourceGUID, externalSourceName, contactMethodGUID); } diff --git a/open-metadata-implementation/integration-services/lineage-integrator/lineage-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/lineage/connector/LineageIntegratorContext.java b/open-metadata-implementation/integration-services/lineage-integrator/lineage-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/lineage/connector/LineageIntegratorContext.java index 2166a910877..341f26961f5 100644 --- a/open-metadata-implementation/integration-services/lineage-integrator/lineage-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/lineage/connector/LineageIntegratorContext.java +++ b/open-metadata-implementation/integration-services/lineage-integrator/lineage-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/lineage/connector/LineageIntegratorContext.java @@ -1700,9 +1700,9 @@ public void updateProcessStatus(String processGUID, /** * Create a parent-child relationship between two processes. No longer use this method. Use following method instead. * - * @param userId value from context used - * @param externalSourceGUID value from context used - * @param externalSourceName value from context used + * @param userId calling user + * @param externalSourceGUID unique identifier of software server capability representing the caller + * @param externalSourceName unique name of software server capability representing the caller * @param assetManagerIsHome ensure that only the asset manager can update this asset * @param parentProcessGUID unique identifier of the process in the external asset manager that is to be the parent process * @param childProcessGUID unique identifier of the process in the external asset manager that is to be the nested sub-process @@ -1714,6 +1714,7 @@ public void updateProcessStatus(String processGUID, * @throws PropertyServerException there is a problem reported in the open metadata server(s) */ @Deprecated + @SuppressWarnings(value = "unused") public void setupProcessParent(String userId, String externalSourceGUID, String externalSourceName, diff --git a/open-metadata-implementation/integration-services/security-integrator/security-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/security/connector/SecurityIntegratorContext.java b/open-metadata-implementation/integration-services/security-integrator/security-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/security/connector/SecurityIntegratorContext.java index 8bbbdf2bca9..2d8ee083292 100644 --- a/open-metadata-implementation/integration-services/security-integrator/security-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/security/connector/SecurityIntegratorContext.java +++ b/open-metadata-implementation/integration-services/security-integrator/security-integrator-api/src/main/java/org/odpi/openmetadata/integrationservices/security/connector/SecurityIntegratorContext.java @@ -465,7 +465,6 @@ public List getActorProfileByName(String name, /** * Retrieve the list of matching profiles for the search string. * - * @param userId the name of the calling user. * @param searchString RegEx string to search for * @param startFrom index of the list to start from (0 for start) * @param pageSize maximum number of elements to return. @@ -476,8 +475,7 @@ public List getActorProfileByName(String name, * @throws PropertyServerException the server is not available. * @throws UserNotAuthorizedException the calling user is not authorized to issue the call. */ - public List findActorProfile(String userId, - String searchString, + public List findActorProfile(String searchString, int startFrom, int pageSize) throws InvalidParameterException, PropertyServerException, diff --git a/open-metadata-implementation/platform-chassis/platform-chassis-spring/build.gradle b/open-metadata-implementation/platform-chassis/platform-chassis-spring/build.gradle index 43930b20bfe..4a2fe0dac2f 100644 --- a/open-metadata-implementation/platform-chassis/platform-chassis-spring/build.gradle +++ b/open-metadata-implementation/platform-chassis/platform-chassis-spring/build.gradle @@ -23,8 +23,8 @@ dependencies { implementation 'org.springframework:spring-core' implementation 'org.springframework:spring-context' implementation project(':open-metadata-implementation:frameworks:open-connector-framework') - implementation project(':open-metadata-implementation:platform-services:platform-services-api') - implementation project(':open-metadata-implementation:platform-services:platform-services-server') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-server') implementation project(':open-metadata-implementation:admin-services:admin-services-server') implementation project(':open-metadata-implementation:common-services:metadata-security:metadata-security-server') compileOnly project(':open-metadata-implementation:common-services:ffdc-services') diff --git a/open-metadata-implementation/platform-chassis/platform-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java b/open-metadata-implementation/platform-chassis/platform-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java index d20cf323c89..15923b9d7fd 100644 --- a/open-metadata-implementation/platform-chassis/platform-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java +++ b/open-metadata-implementation/platform-chassis/platform-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerPlatform.java @@ -11,10 +11,10 @@ import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Endpoint; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataPlatformSecurityVerifier; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; import org.odpi.openmetadata.http.HttpHelper; import org.odpi.openmetadata.http.HttpRequestHeadersFilter; -import org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; @@ -105,7 +105,7 @@ public class OMAGServerPlatform private ApplicationEventPublisher applicationEventPublisher; private boolean triggeredRuntimeHalt = false; - private String startupMessage = ""; + private String startupMessage = ""; private final OMAGServerOperationalServices operationalServices = new OMAGServerOperationalServices(); private final OMAGServerAdminStoreServices configStoreServices = new OMAGServerAdminStoreServices(); diff --git a/open-metadata-implementation/platform-services/platform-services-client/build.gradle b/open-metadata-implementation/platform-services/platform-services-client/build.gradle index 2636a573894..963bc8e8232 100644 --- a/open-metadata-implementation/platform-services/platform-services-client/build.gradle +++ b/open-metadata-implementation/platform-services/platform-services-client/build.gradle @@ -6,6 +6,7 @@ dependencies { implementation 'org.slf4j:slf4j-api' + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:platform-services:platform-services-api') implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation project(':open-metadata-implementation:frameworks:audit-log-framework') diff --git a/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesClient.java b/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesClient.java index 1f684f3e54c..a3028151920 100644 --- a/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesClient.java +++ b/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesClient.java @@ -15,13 +15,13 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType; -import org.odpi.openmetadata.platformservices.properties.ServerServicesStatus; -import org.odpi.openmetadata.platformservices.properties.ServerStatus; -import org.odpi.openmetadata.platformservices.rest.OMAGServerStatusResponse; +import org.odpi.openmetadata.serveroperations.properties.ServerServicesStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerStatus; import org.odpi.openmetadata.platformservices.rest.ServerListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerServicesListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerStatusResponse; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.rest.OMAGServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerServicesListResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; import java.util.List; diff --git a/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesRESTClient.java b/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesRESTClient.java index e53dae8f8a5..1f160a40301 100644 --- a/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesRESTClient.java +++ b/open-metadata-implementation/platform-services/platform-services-client/src/main/java/org/odpi/openmetadata/platformservices/client/PlatformServicesRESTClient.java @@ -14,11 +14,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.platformservices.rest.OMAGServerStatusResponse; import org.odpi.openmetadata.platformservices.rest.ServerListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerServicesListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerStatusResponse; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.rest.OMAGServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerServicesListResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; /** diff --git a/open-metadata-implementation/platform-services/platform-services-server/build.gradle b/open-metadata-implementation/platform-services/platform-services-server/build.gradle index ef36c1331ba..480aacfe0e9 100644 --- a/open-metadata-implementation/platform-services/platform-services-server/build.gradle +++ b/open-metadata-implementation/platform-services/platform-services-server/build.gradle @@ -7,6 +7,8 @@ dependencies { implementation 'org.slf4j:slf4j-api' implementation project(':open-metadata-implementation:platform-services:platform-services-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-server') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:common-services:multi-tenant') implementation project(':open-metadata-implementation:frameworks:open-connector-framework') implementation project(':open-metadata-implementation:frameworks:audit-log-framework') diff --git a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformActiveServices.java b/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformActiveServices.java index 689c59053c0..80936859525 100644 --- a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformActiveServices.java +++ b/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformActiveServices.java @@ -11,10 +11,10 @@ import org.odpi.openmetadata.commonservices.multitenant.OMAGServerPlatformInstanceMap; import org.odpi.openmetadata.frameworks.connectors.ConnectorProvider; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType; -import org.odpi.openmetadata.platformservices.properties.ServerStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerStatus; import org.odpi.openmetadata.platformservices.rest.ServerListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerServicesListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerServicesListResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerStatusResponse; import org.slf4j.LoggerFactory; diff --git a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformOperationalServices.java b/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformOperationalServices.java new file mode 100644 index 00000000000..3f4453d202c --- /dev/null +++ b/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerPlatformOperationalServices.java @@ -0,0 +1,202 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.platformservices.server; + + +import org.odpi.openmetadata.adminservices.configuration.registration.CommonServicesDescription; +import org.odpi.openmetadata.adminservices.ffdc.exception.OMAGNotAuthorizedException; +import org.odpi.openmetadata.adminservices.server.OMAGServerErrorHandler; +import org.odpi.openmetadata.adminservices.server.OMAGServerExceptionHandler; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallLogger; +import org.odpi.openmetadata.commonservices.ffdc.RESTCallToken; +import org.odpi.openmetadata.commonservices.ffdc.exceptions.PropertyServerException; +import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; +import org.odpi.openmetadata.commonservices.multitenant.OMAGServerPlatformInstanceMap; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalInstanceHandler; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * OMAGServerPlatformOperationalServices will provide support to start, manage and stop services in the OMAG Server. + */ +public class OMAGServerPlatformOperationalServices +{ + private final OMAGServerOperationalInstanceHandler instanceHandler = new OMAGServerOperationalInstanceHandler(CommonServicesDescription.PLATFORM_SERVICES.getServiceName()); + private final OMAGServerOperationalServices serverOperationalServices = new OMAGServerOperationalServices(); + + private final OMAGServerPlatformInstanceMap platformInstanceMap = new OMAGServerPlatformInstanceMap(); + + private final OMAGServerErrorHandler errorHandler = new OMAGServerErrorHandler(); + private final OMAGServerExceptionHandler exceptionHandler = new OMAGServerExceptionHandler(); + + private final static RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(OMAGServerPlatformOperationalServices.class), + CommonServicesDescription.PLATFORM_SERVICES.getServiceName()); + + /* + * ============================================================= + * Platform unique shutdown services + */ + + + /** + * Temporarily deactivate any open metadata and governance services for all running servers. + * + * @param userId user that is issuing the request + * @return void response or + * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or + * OMAGInvalidParameterException the serverName is invalid. + */ + public VoidResponse shutdownAllServers(String userId) + { + final String methodName = "shutdownServer"; + final String serverName = ""; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + + try + { + errorHandler.validateUserId(userId, serverName, methodName); + + List activeServers = platformInstanceMap.getActiveServerList(userId); + + if (activeServers != null) + { + for (String activeServerName : activeServers) + { + serverOperationalServices.deactivateRunningServiceInstances(userId, + activeServerName, + methodName, + instanceHandler.getServerServiceInstance(userId, activeServerName, methodName), + false); + } + } + } + catch (InvalidParameterException error) + { + exceptionHandler.captureInvalidParameterException(response, error); + } + catch (UserNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + } + catch (OMAGNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + } + catch (Exception error) + { + exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } + + + /** + * Terminate any running open metadata and governance services, remove the server from any open metadata cohorts + * and delete the server's configuration. + * + * @param userId user that is issuing the request + * @return void response or + * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or + * OMAGInvalidParameterException the serverName is invalid. + */ + public VoidResponse shutdownAndUnregisterAllServers(String userId) + { + final String methodName = "shutdownAndUnregisterAllServers"; + final String serverName = ""; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + + try + { + errorHandler.validateUserId(userId, serverName, methodName); + + List activeServers = platformInstanceMap.getActiveServerList(userId); + + if (activeServers != null) + { + for (String activeServerName : activeServers) + { + serverOperationalServices.deactivateRunningServiceInstances(userId, + activeServerName, + methodName, + instanceHandler.getServerServiceInstance(userId, activeServerName, methodName), + true); + } + } + } + catch (InvalidParameterException error) + { + exceptionHandler.captureInvalidParameterException(response, error); + } + catch (UserNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + } + catch (OMAGNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + } + catch (PropertyServerException error) + { + exceptionHandler.capturePropertyServerException(response, error); + } + catch (Exception error) + { + exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Terminate this platform. + * + * @param userId user that is issuing the request + * @return void response or + * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or + * OMAGInvalidParameterException the serverName is invalid. + */ + public VoidResponse shutdownPlatform(String userId) + { + final String methodName = "shutdownPlatform"; + final String serverName = ""; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + VoidResponse response = new VoidResponse(); + + try + { + errorHandler.validateUserId(userId, serverName, methodName); + + Runtime.getRuntime().exit(1); + } + catch (OMAGNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + } + catch (Exception error) + { + exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + +} diff --git a/open-metadata-implementation/platform-services/platform-services-spring/build.gradle b/open-metadata-implementation/platform-services/platform-services-spring/build.gradle index f1b98f58c66..aeecca0f062 100644 --- a/open-metadata-implementation/platform-services/platform-services-spring/build.gradle +++ b/open-metadata-implementation/platform-services/platform-services-spring/build.gradle @@ -7,6 +7,8 @@ dependencies { implementation project(':open-metadata-implementation:platform-services:platform-services-server') implementation project(':open-metadata-implementation:platform-services:platform-services-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-server') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:common-services:ffdc-services') implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation project(':open-metadata-implementation:frameworks:open-connector-framework') diff --git a/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerOperationResource.java b/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerOperationResource.java index 83f754908ec..4b77174ba54 100644 --- a/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerOperationResource.java +++ b/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerOperationResource.java @@ -7,11 +7,12 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig; import org.odpi.openmetadata.adminservices.rest.OMAGServerConfigResponse; -import org.odpi.openmetadata.platformservices.rest.OMAGServerStatusResponse; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection; -import org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices; +import org.odpi.openmetadata.platformservices.server.OMAGServerPlatformOperationalServices; +import org.odpi.openmetadata.serveroperations.rest.OMAGServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -35,7 +36,8 @@ public class OMAGServerOperationResource { - private final OMAGServerOperationalServices operationalServices = new OMAGServerOperationalServices(); + private final OMAGServerOperationalServices serverOperationalServices = new OMAGServerOperationalServices(); + private final OMAGServerPlatformOperationalServices platformOperationalServices = new OMAGServerPlatformOperationalServices(); /* * ======================================================================================== @@ -62,7 +64,7 @@ public class OMAGServerOperationResource public SuccessMessageResponse activateWithStoredConfig(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.activateWithStoredConfig(userId, serverName); + return serverOperationalServices.activateWithStoredConfig(userId, serverName); } @@ -90,7 +92,7 @@ public SuccessMessageResponse activateWithSuppliedConfig(@PathVariable String @PathVariable String serverName, @RequestBody OMAGServerConfig configuration) { - return operationalServices.activateWithSuppliedConfig(userId, serverName, configuration); + return serverOperationalServices.activateWithSuppliedConfig(userId, serverName, configuration); } @@ -111,7 +113,7 @@ public SuccessMessageResponse activateWithSuppliedConfig(@PathVariable String public VoidResponse shutdownServer(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.shutdownServer(userId, serverName); + return serverOperationalServices.shutdownServer(userId, serverName); } @@ -130,7 +132,7 @@ public VoidResponse shutdownServer(@PathVariable String userId, public VoidResponse shutdownAllServers(@PathVariable String userId) { - return operationalServices.shutdownAllServers(userId); + return platformOperationalServices.shutdownAllServers(userId); } @@ -153,7 +155,7 @@ public VoidResponse shutdownAllServers(@PathVariable String userId) public VoidResponse shutdownAndUnregisterServer(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.shutdownAndUnregisterServer(userId, serverName); + return serverOperationalServices.shutdownAndUnregisterServer(userId, serverName); } @@ -174,7 +176,7 @@ public VoidResponse shutdownAndUnregisterServer(@PathVariable String userId, public VoidResponse shutdownAndUnregisterAllServers(@PathVariable String userId) { - return operationalServices.shutdownAndUnregisterAllServers(userId); + return platformOperationalServices.shutdownAndUnregisterAllServers(userId); } @@ -193,7 +195,7 @@ public VoidResponse shutdownAndUnregisterAllServers(@PathVariable String userId public VoidResponse shutdownPlatform(@PathVariable String userId) { - return operationalServices.shutdownPlatform(userId); + return platformOperationalServices.shutdownPlatform(userId); } @@ -227,7 +229,7 @@ public VoidResponse shutdownPlatform(@PathVariable String userId) public OMAGServerConfigResponse getActiveConfiguration(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.getActiveConfiguration(userId, serverName); + return serverOperationalServices.getActiveConfiguration(userId, serverName); } @@ -257,7 +259,7 @@ public OMAGServerConfigResponse getActiveConfiguration(@PathVariable String public OMAGServerStatusResponse getActiveServerStatus(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.getActiveServerStatus(userId, serverName); + return serverOperationalServices.getActiveServerStatus(userId, serverName); } @@ -284,7 +286,7 @@ public VoidResponse addOpenMetadataArchiveFile(@PathVariable String userId, @PathVariable String serverName, @RequestBody String fileName) { - return operationalServices.addOpenMetadataArchiveFile(userId, serverName, fileName); + return serverOperationalServices.addOpenMetadataArchiveFile(userId, serverName, fileName); } @@ -311,6 +313,6 @@ public VoidResponse addOpenMetadataArchive(@PathVariable String userId, @PathVariable String serverName, @RequestBody Connection connection) { - return operationalServices.addOpenMetadataArchive(userId, serverName, connection); + return serverOperationalServices.addOpenMetadataArchive(userId, serverName, connection); } } diff --git a/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerPlatformActiveResource.java b/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerPlatformActiveResource.java index cc4a28e14d3..387abee9afa 100644 --- a/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerPlatformActiveResource.java +++ b/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OMAGServerPlatformActiveResource.java @@ -14,8 +14,8 @@ import org.odpi.openmetadata.commonservices.ffdc.rest.ConnectorTypeResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.RegisteredOMAGServicesResponse; import org.odpi.openmetadata.platformservices.rest.ServerListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerServicesListResponse; -import org.odpi.openmetadata.platformservices.rest.ServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerServicesListResponse; +import org.odpi.openmetadata.serveroperations.rest.ServerStatusResponse; import org.odpi.openmetadata.platformservices.server.OMAGServerPlatformActiveServices; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; diff --git a/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OldOperationalServicesResource.java b/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OldOperationalServicesResource.java index 87c80a2daa3..02144e4c4f4 100644 --- a/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OldOperationalServicesResource.java +++ b/open-metadata-implementation/platform-services/platform-services-spring/src/main/java/org/odpi/openmetadata/platformservices/server/spring/OldOperationalServicesResource.java @@ -5,9 +5,9 @@ import io.swagger.v3.oas.annotations.ExternalDocumentation; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import org.odpi.openmetadata.platformservices.rest.OMAGServerStatusResponse; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; -import org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices; +import org.odpi.openmetadata.serveroperations.rest.OMAGServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig; import org.odpi.openmetadata.adminservices.rest.OMAGServerConfigResponse; import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse; @@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*; /** - * OldOperationalServicesResource provides the REST API for controlling the start up, management and + * OldOperationalServicesResource provides the REST API for controlling the start-up, management and * shutdown of services in the OMAG Server. */ @RestController @@ -29,7 +29,7 @@ @Deprecated public class OldOperationalServicesResource { - private final OMAGServerOperationalServices operationalServices = new OMAGServerOperationalServices(); + private final OMAGServerOperationalServices serverOperationalServices = new OMAGServerOperationalServices(); /* * ======================================================================================== @@ -56,7 +56,7 @@ public class OldOperationalServicesResource public SuccessMessageResponse activateWithStoredConfig(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.activateWithStoredConfig(userId, serverName); + return serverOperationalServices.activateWithStoredConfig(userId, serverName); } @@ -84,7 +84,7 @@ public SuccessMessageResponse activateWithSuppliedConfig(@PathVariable String @PathVariable String serverName, @RequestBody OMAGServerConfig configuration) { - return operationalServices.activateWithSuppliedConfig(userId, serverName, configuration); + return serverOperationalServices.activateWithSuppliedConfig(userId, serverName, configuration); } @@ -105,7 +105,7 @@ public SuccessMessageResponse activateWithSuppliedConfig(@PathVariable String public VoidResponse deactivateTemporarily(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.shutdownServer(userId, serverName); + return serverOperationalServices.shutdownServer(userId, serverName); } @@ -128,7 +128,7 @@ public VoidResponse deactivateTemporarily(@PathVariable String userId, public VoidResponse deactivatePermanently(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.shutdownAndUnregisterServer(userId, serverName); + return serverOperationalServices.shutdownAndUnregisterServer(userId, serverName); } @@ -162,7 +162,7 @@ public VoidResponse deactivatePermanently(@PathVariable String userId, public OMAGServerConfigResponse getActiveConfiguration(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.getActiveConfiguration(userId, serverName); + return serverOperationalServices.getActiveConfiguration(userId, serverName); } @@ -192,7 +192,7 @@ public OMAGServerConfigResponse getActiveConfiguration(@PathVariable String public OMAGServerStatusResponse getActiveServerStatus(@PathVariable String userId, @PathVariable String serverName) { - return operationalServices.getActiveServerStatus(userId, serverName); + return serverOperationalServices.getActiveServerStatus(userId, serverName); } @@ -219,7 +219,7 @@ public VoidResponse addOpenMetadataArchiveFile(@PathVariable String userId, @PathVariable String serverName, @RequestBody String fileName) { - return operationalServices.addOpenMetadataArchiveFile(userId, serverName, fileName); + return serverOperationalServices.addOpenMetadataArchiveFile(userId, serverName, fileName); } @@ -246,6 +246,6 @@ public VoidResponse addOpenMetadataArchive(@PathVariable String userId, @PathVariable String serverName, @RequestBody Connection connection) { - return operationalServices.addOpenMetadataArchive(userId, serverName, connection); + return serverOperationalServices.addOpenMetadataArchive(userId, serverName, connection); } } diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/admin/OMRSOperationalServices.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/admin/OMRSOperationalServices.java index 1f54deb5a56..faa4fb33815 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/admin/OMRSOperationalServices.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/admin/OMRSOperationalServices.java @@ -196,7 +196,6 @@ public OMRSRepositoryConnector getEnterpriseOMRSRepositoryConnector(String cal * Return the enterprise connector manager. This is used by the conformance suite to get access to connectors * to registered members of the cohorts that this server is connected to. That way it can exercise their * APIs and compare them with the events being received over the cohort topic. - * * This method is called after the OMRS is initialized. The enterprise connector manager is created whether * there are OMASs activated or not. * diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentValidator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentValidator.java index dec7982552e..d20f8a1e2d3 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentValidator.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/localrepository/repositorycontentmanager/OMRSRepositoryContentValidator.java @@ -3679,6 +3679,7 @@ else if (instancePropertyValue.getInstancePropertyCategory() == InstanceProperty * @throws InvalidParameterException invalid search criteria */ @Override + @SuppressWarnings(value="fallthrough") public int countMatchingPropertyValues(InstanceProperties matchProperties, InstanceProperties instanceProperties) throws InvalidParameterException { diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle b/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle index 68f31c70208..70c65fe2359 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle @@ -39,8 +39,8 @@ dependencies { implementation project(':open-metadata-implementation:frameworks:open-connector-framework') implementation project(':open-metadata-implementation:adapters:authentication-plugins:http-helper') implementation project(':open-metadata-implementation:admin-services:admin-services-api') - implementation project(':open-metadata-implementation:platform-services:platform-services-api') - implementation project(':open-metadata-implementation:platform-services:platform-services-server') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-server') implementation project(path: ':open-metadata-implementation:adapters:open-connectors:connector-configuration-factory') implementation project(path: ':open-metadata-implementation:repository-services:repository-services-implementation') diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServer.java b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServer.java index 6c18e212104..73ea2a35f23 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServer.java +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServer.java @@ -3,8 +3,8 @@ package org.odpi.openmetadata.serverchassis.springboot; import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; -import org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; import org.odpi.openmetadata.serverchassis.springboot.config.OMAGConfigHelper; import org.odpi.openmetadata.serverchassis.springboot.exception.OMAGServerActivationError; import org.slf4j.Logger; @@ -38,9 +38,9 @@ public class OMAGServer implements ApplicationRunner { */ @Autowired - public OMAGServer(ConfigurableApplicationContext ctx, OMAGConfigHelper configHelper, OMAGServerOperationalServices omagServerOperationalServices) { + public OMAGServer(ConfigurableApplicationContext ctx, OMAGConfigHelper configHelper, OMAGServerOperationalServices serverOperationalServices) { this.context = ctx; - this.operationalServices = omagServerOperationalServices; + this.operationalServices = serverOperationalServices; this.configHelper = configHelper; } diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServerProperties.java b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServerProperties.java index 177e0241edf..3a2c13260e2 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServerProperties.java +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServerProperties.java @@ -32,7 +32,6 @@ public class OMAGServerProperties { /** * Configures the default user parameter used to activate the OMAG server instance using platform operational services. - * @see org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices#activateWithSuppliedConfig(String, String, OMAGServerConfig) */ @Value("${omag.server-user:${omag.server.user:system}}") private String defaultUser; diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServicesConfiguration.java b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServicesConfiguration.java index 2bc19a4b107..262689ba806 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServicesConfiguration.java +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/java/org/odpi/openmetadata/serverchassis/springboot/config/OMAGServicesConfiguration.java @@ -2,8 +2,8 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.serverchassis.springboot.config; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; import org.odpi.openmetadata.adapters.repositoryservices.ConnectorConfigurationFactory; -import org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices; import org.odpi.openmetadata.repositoryservices.admin.OMRSConfigurationFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -20,11 +20,11 @@ public class OMAGServicesConfiguration { * Provides singleton bean instance of OMAGServerOperationalServices * * @return OMAGServerOperationalServices instance - * @see org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices + * @see OMAGServerOperationalServices */ @Primary - @Bean(name = {"platformOperationalServices"}) - public OMAGServerOperationalServices platformOperationalServices(){ + @Bean(name = {"serverOperationalServices"}) + public OMAGServerOperationalServices serverOperationalServices(){ return new OMAGServerOperationalServices(); } diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/resources/application-dev.properties b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/resources/application-dev.properties index 6a0da195aee..8751012b447 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/resources/application-dev.properties +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/main/resources/application-dev.properties @@ -15,8 +15,8 @@ management.endpoint.health.show-details=always management.endpoint.metrics.enabled=true management.endpoints.web.exposure.include=metrics,health -#omag.server-config-file=classpath:samples/metadata-access-server.json -omag.server-config-file=classpath:samples/metadata-repository-server.yml +omag.server-config-file=classpath:samples/metadata-access-server.json +#omag.server-config-file=classpath:samples/metadata-repository-server.yml default.omag.server.user=omag-system diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerTests.java b/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerTests.java index d94e7e3cea7..02481f5eea8 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerTests.java +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/OMAGServerTests.java @@ -4,12 +4,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; -import org.odpi.openmetadata.platformservices.server.OMAGServerOperationalServices; import org.odpi.openmetadata.serverchassis.springboot.config.OMAGServerProperties; import org.odpi.openmetadata.serverchassis.springboot.config.SSLEnvironmentConfiguration; +import org.odpi.openmetadata.serveroperations.server.OMAGServerOperationalServices; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; @@ -23,11 +22,11 @@ class OMAGServerTests { @Autowired ObjectMapper objectMapper; @Autowired - SSLEnvironmentConfiguration initializingBeanConfig; + SSLEnvironmentConfiguration initializingBeanConfig; @Autowired OMAGServerOperationalServices operationalServices; @Autowired - OMAGServerProperties omagServerProperties; + OMAGServerProperties omagServerProperties; @Test void contextLoads() { diff --git a/open-metadata-implementation/server-operations/README.md b/open-metadata-implementation/server-operations/README.md new file mode 100644 index 00000000000..56643f20f78 --- /dev/null +++ b/open-metadata-implementation/server-operations/README.md @@ -0,0 +1,19 @@ + + + +![Released](../../images/egeria-content-status-released.png#pagewidth) + +# Platform Services + +The platform services provides the APIs for querying the +[Open Metadata and Governance (OMAG) Server Platform](https://egeria-project.org/concepts/omag-server-platform/) +and discovering information about the OMAG Servers that it is hosting, starting and stopping them. + +* [Documentation](https://egeria-project.org/services/platform-services/overview) + +---- +Return to [open-metadata-implementation](..). + +---- +License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), +Copyright Contributors to the ODPi Egeria project. \ No newline at end of file diff --git a/open-metadata-implementation/server-operations/server-operations-api/build.gradle b/open-metadata-implementation/server-operations/server-operations-api/build.gradle new file mode 100644 index 00000000000..620dfd6890b --- /dev/null +++ b/open-metadata-implementation/server-operations/server-operations-api/build.gradle @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Contributors to the ODPi Egeria project. + */ + + +dependencies { + compileOnly 'com.fasterxml.jackson.core:jackson-annotations' + implementation project(':open-metadata-implementation:common-services:ffdc-services') +} + +description = 'Server Operations Common API elements' + +java { + withJavadocJar() +} diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/OMAGServerInstanceHistory.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/OMAGServerInstanceHistory.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/OMAGServerInstanceHistory.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/OMAGServerInstanceHistory.java index c1fa404c079..bcdecd7c4bc 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/OMAGServerInstanceHistory.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/OMAGServerInstanceHistory.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.properties; +package org.odpi.openmetadata.serveroperations.properties; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/OMAGServerServiceStatus.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/OMAGServerServiceStatus.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/OMAGServerServiceStatus.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/OMAGServerServiceStatus.java index fc5dde66fdd..8af047ca461 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/OMAGServerServiceStatus.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/OMAGServerServiceStatus.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.properties; +package org.odpi.openmetadata.serveroperations.properties; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerActiveStatus.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerActiveStatus.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerActiveStatus.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerActiveStatus.java index fb2aa64fcad..5854988099a 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerActiveStatus.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerActiveStatus.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.properties; +package org.odpi.openmetadata.serveroperations.properties; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerInstanceStatus.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerInstanceStatus.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerInstanceStatus.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerInstanceStatus.java index b45918b237e..e2ac37695fa 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerInstanceStatus.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerInstanceStatus.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.properties; +package org.odpi.openmetadata.serveroperations.properties; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerServicesStatus.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerServicesStatus.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerServicesStatus.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerServicesStatus.java index e9811209636..531cd7abeb9 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerServicesStatus.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerServicesStatus.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.properties; +package org.odpi.openmetadata.serveroperations.properties; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerStatus.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerStatus.java similarity index 99% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerStatus.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerStatus.java index 5cc78423b4a..4286c3e263f 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/properties/ServerStatus.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/properties/ServerStatus.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.properties; +package org.odpi.openmetadata.serveroperations.properties; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/OMAGServerStatusResponse.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/OMAGServerStatusResponse.java similarity index 97% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/OMAGServerStatusResponse.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/OMAGServerStatusResponse.java index 72b7757184f..7c819cf1dc7 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/OMAGServerStatusResponse.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/OMAGServerStatusResponse.java @@ -1,12 +1,12 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.rest; +package org.odpi.openmetadata.serveroperations.rest; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.commonservices.ffdc.rest.FFDCResponseBase; -import org.odpi.openmetadata.platformservices.properties.ServerServicesStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerServicesStatus; import java.util.Arrays; import java.util.Objects; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/ServerServicesListResponse.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/ServerServicesListResponse.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/ServerServicesListResponse.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/ServerServicesListResponse.java index dd9bab66074..cec6b5b9c30 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/ServerServicesListResponse.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/ServerServicesListResponse.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.rest; +package org.odpi.openmetadata.serveroperations.rest; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/ServerStatusResponse.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/ServerStatusResponse.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/ServerStatusResponse.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/ServerStatusResponse.java index e696904e1aa..4cf9b5be9ad 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/ServerStatusResponse.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/ServerStatusResponse.java @@ -1,12 +1,12 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.rest; +package org.odpi.openmetadata.serveroperations.rest; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import org.odpi.openmetadata.commonservices.ffdc.rest.FFDCResponseBase; -import org.odpi.openmetadata.platformservices.properties.OMAGServerInstanceHistory; +import org.odpi.openmetadata.serveroperations.properties.OMAGServerInstanceHistory; import java.util.*; diff --git a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/SuccessMessageResponse.java b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/SuccessMessageResponse.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/SuccessMessageResponse.java rename to open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/SuccessMessageResponse.java index cb987544a47..1edbee0ff74 100644 --- a/open-metadata-implementation/platform-services/platform-services-api/src/main/java/org/odpi/openmetadata/platformservices/rest/SuccessMessageResponse.java +++ b/open-metadata-implementation/server-operations/server-operations-api/src/main/java/org/odpi/openmetadata/serveroperations/rest/SuccessMessageResponse.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.rest; +package org.odpi.openmetadata.serveroperations.rest; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/open-metadata-implementation/server-operations/server-operations-server/build.gradle b/open-metadata-implementation/server-operations/server-operations-server/build.gradle new file mode 100644 index 00000000000..831fe838173 --- /dev/null +++ b/open-metadata-implementation/server-operations/server-operations-server/build.gradle @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Contributors to the ODPi Egeria project. + */ + + +dependencies { + implementation 'org.slf4j:slf4j-api' + implementation project(':open-metadata-implementation:server-operations:server-operations-api') + implementation project(':open-metadata-implementation:common-services:multi-tenant') + implementation project(':open-metadata-implementation:frameworks:open-connector-framework') + implementation project(':open-metadata-implementation:frameworks:audit-log-framework') + implementation project(':open-metadata-implementation:adapters:open-connectors:connector-configuration-factory') + implementation project(':open-metadata-implementation:common-services:ffdc-services') + implementation project(':open-metadata-implementation:admin-services:admin-services-api') + implementation project(':open-metadata-implementation:admin-services:admin-services-server') + implementation project(':open-metadata-implementation:admin-services:admin-services-registration') + implementation project(':open-metadata-implementation:common-services:metadata-security:metadata-security-apis') + implementation project(':open-metadata-implementation:common-services:metadata-security:metadata-security-server') + implementation project(':open-metadata-implementation:repository-services:repository-services-apis') + implementation project(':open-metadata-implementation:repository-services:repository-services-implementation') + implementation project(':open-metadata-implementation:framework-services:ocf-metadata-management:ocf-metadata-server') + implementation project(':open-metadata-implementation:framework-services:oif-metadata-management:oif-metadata-server') + implementation project(':open-metadata-implementation:framework-services:gaf-metadata-management:gaf-metadata-server') + implementation project(':open-metadata-conformance-suite:open-metadata-conformance-suite-server') + implementation project(':open-metadata-implementation:governance-servers:integration-daemon-services:integration-daemon-services-registration') + implementation project(':open-metadata-implementation:governance-servers:integration-daemon-services:integration-daemon-services-server') + implementation project(':open-metadata-implementation:governance-servers:engine-host-services:engine-host-services-registration') + implementation project(':open-metadata-implementation:governance-servers:engine-host-services:engine-host-services-server') + implementation project(':open-metadata-implementation:governance-servers:open-lineage-services:open-lineage-services-server') + implementation project(':open-metadata-implementation:governance-servers:data-engine-proxy-services:data-engine-proxy-services-server') + compileOnly 'com.fasterxml.jackson.core:jackson-annotations' + +} + +description = 'Server Operations Server-side' + +java { + withJavadocJar() +} diff --git a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGOperationalServicesInstance.java b/open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGOperationalServicesInstance.java similarity index 98% rename from open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGOperationalServicesInstance.java rename to open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGOperationalServicesInstance.java index a7ee41f3252..bf364b777fa 100644 --- a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGOperationalServicesInstance.java +++ b/open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGOperationalServicesInstance.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.server; +package org.odpi.openmetadata.serveroperations.server; import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig; import org.odpi.openmetadata.adminservices.registration.AccessServiceAdmin; @@ -15,9 +15,9 @@ import org.odpi.openmetadata.governanceservers.enginehostservices.server.EngineHostOperationalServices; import org.odpi.openmetadata.governanceservers.integrationdaemonservices.server.IntegrationDaemonOperationalServices; import org.odpi.openmetadata.governanceservers.openlineage.admin.OpenLineageServerOperationalServices; -import org.odpi.openmetadata.platformservices.properties.OMAGServerServiceStatus; -import org.odpi.openmetadata.platformservices.properties.ServerActiveStatus; -import org.odpi.openmetadata.platformservices.properties.ServerServicesStatus; +import org.odpi.openmetadata.serveroperations.properties.OMAGServerServiceStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerActiveStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerServicesStatus; import org.odpi.openmetadata.repositoryservices.admin.OMRSOperationalServices; import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; diff --git a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerOperationalInstanceHandler.java b/open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGServerOperationalInstanceHandler.java similarity index 97% rename from open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerOperationalInstanceHandler.java rename to open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGServerOperationalInstanceHandler.java index e4105a91490..ec35fd95343 100644 --- a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerOperationalInstanceHandler.java +++ b/open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGServerOperationalInstanceHandler.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.server; +package org.odpi.openmetadata.serveroperations.server; import org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException; import org.odpi.openmetadata.commonservices.ffdc.exceptions.PropertyServerException; diff --git a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerOperationalServices.java b/open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGServerOperationalServices.java similarity index 94% rename from open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerOperationalServices.java rename to open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGServerOperationalServices.java index 98905a48abf..ee4469f4c1b 100644 --- a/open-metadata-implementation/platform-services/platform-services-server/src/main/java/org/odpi/openmetadata/platformservices/server/OMAGServerOperationalServices.java +++ b/open-metadata-implementation/server-operations/server-operations-server/src/main/java/org/odpi/openmetadata/serveroperations/server/OMAGServerOperationalServices.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.platformservices.server; +package org.odpi.openmetadata.serveroperations.server; import org.odpi.openmetadata.adapters.repositoryservices.ConnectorConfigurationFactory; @@ -15,7 +15,7 @@ import org.odpi.openmetadata.adminservices.registration.AccessServiceAdmin; import org.odpi.openmetadata.adminservices.registration.ViewServiceAdmin; import org.odpi.openmetadata.adminservices.rest.OMAGServerConfigResponse; -import org.odpi.openmetadata.platformservices.rest.OMAGServerStatusResponse; +import org.odpi.openmetadata.serveroperations.rest.OMAGServerStatusResponse; import org.odpi.openmetadata.adminservices.server.OMAGServerAdminStoreServices; import org.odpi.openmetadata.adminservices.server.OMAGServerErrorHandler; import org.odpi.openmetadata.adminservices.server.OMAGServerExceptionHandler; @@ -36,8 +36,8 @@ import org.odpi.openmetadata.governanceservers.dataengineproxy.admin.DataEngineProxyOperationalServices; import org.odpi.openmetadata.governanceservers.openlineage.admin.OpenLineageServerOperationalServices; import org.odpi.openmetadata.metadatasecurity.server.OpenMetadataServerSecurityVerifier; -import org.odpi.openmetadata.platformservices.properties.ServerActiveStatus; -import org.odpi.openmetadata.platformservices.rest.SuccessMessageResponse; +import org.odpi.openmetadata.serveroperations.properties.ServerActiveStatus; +import org.odpi.openmetadata.serveroperations.rest.SuccessMessageResponse; import org.odpi.openmetadata.repositoryservices.admin.OMRSOperationalServices; import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; import org.odpi.openmetadata.repositoryservices.connectors.omrstopic.OMRSTopicConnector; @@ -53,7 +53,7 @@ */ public class OMAGServerOperationalServices { - private final OMAGServerOperationalInstanceHandler instanceHandler = new OMAGServerOperationalInstanceHandler(CommonServicesDescription.PLATFORM_SERVICES.getServiceName()); + private final OMAGServerOperationalInstanceHandler instanceHandler = new OMAGServerOperationalInstanceHandler(CommonServicesDescription.SERVER_OPERATIONS.getServiceName()); private final OMAGServerPlatformInstanceMap platformInstanceMap = new OMAGServerPlatformInstanceMap(); @@ -62,7 +62,7 @@ public class OMAGServerOperationalServices private final OMAGServerExceptionHandler exceptionHandler = new OMAGServerExceptionHandler(); private final static RESTCallLogger restCallLogger = new RESTCallLogger(LoggerFactory.getLogger(OMAGServerOperationalServices.class), - CommonServicesDescription.PLATFORM_SERVICES.getServiceName()); + CommonServicesDescription.SERVER_OPERATIONS.getServiceName()); /* * ============================================================= @@ -215,6 +215,10 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId */ ServerTypeClassifier serverTypeClassifier = new ServerTypeClassifier(serverName, configuration); ServerTypeClassification serverTypeClassification = serverTypeClassifier.getServerType(); + if (configuration.getLocalServerType() == null) + { + configuration.setLocalServerType(serverTypeClassification.getServerTypeName()); + } /* * Validate that the server is not running already. If it is running it should be shutdown. @@ -231,7 +235,7 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId */ instance = new OMAGOperationalServicesInstance(serverName, serverTypeClassification, - CommonServicesDescription.PLATFORM_SERVICES.getServiceName(), + CommonServicesDescription.SERVER_OPERATIONS.getServiceName(), configuration.getMaxPageSize()); instance.setServerActiveStatus(ServerActiveStatus.STARTING); @@ -274,11 +278,11 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId * immature subsystems that have not yet developed their logging and error handling. */ OMRSAuditLog auditLog = operationalRepositoryServices.getAuditLog( - CommonServicesDescription.PLATFORM_SERVICES.getServiceCode(), - CommonServicesDescription.PLATFORM_SERVICES.getServiceDevelopmentStatus(), - CommonServicesDescription.PLATFORM_SERVICES.getServiceName(), - CommonServicesDescription.PLATFORM_SERVICES.getServiceDescription(), - CommonServicesDescription.PLATFORM_SERVICES.getServiceWiki()); + CommonServicesDescription.SERVER_OPERATIONS.getServiceCode(), + CommonServicesDescription.SERVER_OPERATIONS.getServiceDevelopmentStatus(), + CommonServicesDescription.SERVER_OPERATIONS.getServiceName(), + CommonServicesDescription.SERVER_OPERATIONS.getServiceDescription(), + CommonServicesDescription.SERVER_OPERATIONS.getServiceWiki()); instance.setAuditLog(auditLog); /* @@ -1191,7 +1195,7 @@ private void cleanUpRunningServiceInstances(String user * @throws InvalidParameterException one of the services detected an invalid parameter * @throws PropertyServerException one of the services had problems shutting down */ - private void deactivateRunningServiceInstances(String userId, + public void deactivateRunningServiceInstances(String userId, String serverName, String methodName, OMAGOperationalServicesInstance instance, @@ -1468,64 +1472,6 @@ public VoidResponse shutdownServer(String userId, } - /** - * Temporarily deactivate any open metadata and governance services for all running servers. - * - * @param userId user that is issuing the request - * @return void response or - * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or - * OMAGInvalidParameterException the serverName is invalid. - */ - public VoidResponse shutdownAllServers(String userId) - { - final String methodName = "shutdownServer"; - final String serverName = ""; - - RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); - - VoidResponse response = new VoidResponse(); - - try - { - errorHandler.validateUserId(userId, serverName, methodName); - - List activeServers = platformInstanceMap.getActiveServerList(userId); - - if (activeServers != null) - { - for (String activeServerName : activeServers) - { - deactivateRunningServiceInstances(userId, - activeServerName, - methodName, - instanceHandler.getServerServiceInstance(userId, activeServerName, methodName), - false); - } - } - } - catch (InvalidParameterException error) - { - exceptionHandler.captureInvalidParameterException(response, error); - } - catch (UserNotAuthorizedException error) - { - exceptionHandler.captureNotAuthorizedException(response, error); - } - catch (OMAGNotAuthorizedException error) - { - exceptionHandler.captureNotAuthorizedException(response, error); - } - catch (Exception error) - { - exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); - } - - restCallLogger.logRESTCallReturn(token, response.toString()); - - return response; - } - - /** * Terminate any running open metadata and governance services, remove the server from any open metadata cohorts. * @@ -1585,105 +1531,6 @@ public VoidResponse shutdownAndUnregisterServer(String userId, } - /** - * Terminate any running open metadata and governance services, remove the server from any open metadata cohorts - * and delete the server's configuration. - * - * @param userId user that is issuing the request - * @return void response or - * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or - * OMAGInvalidParameterException the serverName is invalid. - */ - public VoidResponse shutdownAndUnregisterAllServers(String userId) - { - final String methodName = "shutdownAndUnregisterAllServers"; - final String serverName = ""; - - RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); - - VoidResponse response = new VoidResponse(); - - try - { - errorHandler.validateUserId(userId, serverName, methodName); - - List activeServers = platformInstanceMap.getActiveServerList(userId); - - if (activeServers != null) - { - for (String activeServerName : activeServers) - { - deactivateRunningServiceInstances(userId, - activeServerName, - methodName, - instanceHandler.getServerServiceInstance(userId, activeServerName, methodName), - true); - } - } - } - catch (InvalidParameterException error) - { - exceptionHandler.captureInvalidParameterException(response, error); - } - catch (UserNotAuthorizedException error) - { - exceptionHandler.captureNotAuthorizedException(response, error); - } - catch (OMAGNotAuthorizedException error) - { - exceptionHandler.captureNotAuthorizedException(response, error); - } - catch (PropertyServerException error) - { - exceptionHandler.capturePropertyServerException(response, error); - } - catch (Exception error) - { - exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); - } - - restCallLogger.logRESTCallReturn(token, response.toString()); - return response; - } - - - /** - * Terminate this platform. - * - * @param userId user that is issuing the request - * @return void response or - * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or - * OMAGInvalidParameterException the serverName is invalid. - */ - public VoidResponse shutdownPlatform(String userId) - { - final String methodName = "shutdownPlatform"; - final String serverName = ""; - - RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); - - VoidResponse response = new VoidResponse(); - - try - { - errorHandler.validateUserId(userId, serverName, methodName); - - Runtime.getRuntime().exit(1); - } - catch (OMAGNotAuthorizedException error) - { - exceptionHandler.captureNotAuthorizedException(response, error); - } - catch (Exception error) - { - exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); - } - - restCallLogger.logRESTCallReturn(token, response.toString()); - return response; - } - - /* * ============================================================= * Services on running instances @@ -1693,7 +1540,6 @@ public VoidResponse shutdownPlatform(String userId) * Query current configuration and status */ - /** * Return the complete set of configuration properties in use by the server. * diff --git a/open-metadata-implementation/view-services/dino-view/dino-view-api/build.gradle b/open-metadata-implementation/view-services/dino-view/dino-view-api/build.gradle index 2c734273f75..32e153e4481 100644 --- a/open-metadata-implementation/view-services/dino-view/dino-view-api/build.gradle +++ b/open-metadata-implementation/view-services/dino-view/dino-view-api/build.gradle @@ -8,6 +8,7 @@ dependencies { implementation project(':open-metadata-implementation:frameworks:audit-log-framework') implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation project(':open-metadata-implementation:repository-services:repository-services-apis') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:platform-services:platform-services-api') implementation project(':open-metadata-implementation:common-services:ffdc-services') implementation project(':open-metadata-implementation:access-services:governance-engine:governance-engine-api') diff --git a/open-metadata-implementation/view-services/dino-view/dino-view-api/src/main/java/org/odpi/openmetadata/viewservices/dino/api/properties/ServerOverview.java b/open-metadata-implementation/view-services/dino-view/dino-view-api/src/main/java/org/odpi/openmetadata/viewservices/dino/api/properties/ServerOverview.java index bd4e2867f9d..40828320489 100644 --- a/open-metadata-implementation/view-services/dino-view/dino-view-api/src/main/java/org/odpi/openmetadata/viewservices/dino/api/properties/ServerOverview.java +++ b/open-metadata-implementation/view-services/dino-view/dino-view-api/src/main/java/org/odpi/openmetadata/viewservices/dino/api/properties/ServerOverview.java @@ -9,7 +9,7 @@ import org.odpi.openmetadata.adminservices.configuration.properties.ResourceEndpointConfig; import org.odpi.openmetadata.adminservices.rest.ServerTypeClassificationSummary; import org.odpi.openmetadata.commonservices.ffdc.rest.RegisteredOMAGService; -import org.odpi.openmetadata.platformservices.properties.ServerStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerStatus; import java.util.List; import java.util.Map; diff --git a/open-metadata-implementation/view-services/dino-view/dino-view-server/build.gradle b/open-metadata-implementation/view-services/dino-view/dino-view-server/build.gradle index 52bced3db2b..e0234563616 100644 --- a/open-metadata-implementation/view-services/dino-view/dino-view-server/build.gradle +++ b/open-metadata-implementation/view-services/dino-view/dino-view-server/build.gradle @@ -9,6 +9,7 @@ dependencies { implementation project(':open-metadata-implementation:repository-services:repository-services-apis') implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation project(':open-metadata-implementation:admin-services:admin-services-client') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:platform-services:platform-services-api') implementation project(':open-metadata-implementation:platform-services:platform-services-client') implementation project(':open-metadata-implementation:common-services:ffdc-services') diff --git a/open-metadata-implementation/view-services/dino-view/dino-view-server/src/main/java/org/odpi/openmetadata/viewservices/dino/handlers/DinoViewHandler.java b/open-metadata-implementation/view-services/dino-view/dino-view-server/src/main/java/org/odpi/openmetadata/viewservices/dino/handlers/DinoViewHandler.java index 87707a673c8..71051f112a9 100644 --- a/open-metadata-implementation/view-services/dino-view/dino-view-server/src/main/java/org/odpi/openmetadata/viewservices/dino/handlers/DinoViewHandler.java +++ b/open-metadata-implementation/view-services/dino-view/dino-view-server/src/main/java/org/odpi/openmetadata/viewservices/dino/handlers/DinoViewHandler.java @@ -30,7 +30,7 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.platformservices.client.PlatformServicesClient; -import org.odpi.openmetadata.platformservices.properties.ServerStatus; +import org.odpi.openmetadata.serveroperations.properties.ServerStatus; import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLogReport; import org.odpi.openmetadata.repositoryservices.clients.AuditLogServicesClient; import org.odpi.openmetadata.repositoryservices.clients.MetadataHighwayServicesClient; diff --git a/open-metadata-implementation/view-services/server-author-view/server-author-view-api/build.gradle b/open-metadata-implementation/view-services/server-author-view/server-author-view-api/build.gradle index cfcef3a23f6..489ff14cbd8 100644 --- a/open-metadata-implementation/view-services/server-author-view/server-author-view-api/build.gradle +++ b/open-metadata-implementation/view-services/server-author-view/server-author-view-api/build.gradle @@ -9,6 +9,7 @@ dependencies { implementation project(':open-metadata-implementation:admin-services:admin-services-api') implementation project(':open-metadata-implementation:repository-services:repository-services-apis') implementation project(':open-metadata-implementation:platform-services:platform-services-api') + implementation project(':open-metadata-implementation:server-operations:server-operations-api') implementation project(':open-metadata-implementation:common-services:ffdc-services') implementation project(':open-metadata-implementation:access-services:governance-engine:governance-engine-api') implementation project(':open-metadata-implementation:frameworks:open-connector-framework') diff --git a/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/SimpleCatalogArchiveHelper.java b/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/SimpleCatalogArchiveHelper.java index 12d59382e07..b467d23d845 100644 --- a/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/SimpleCatalogArchiveHelper.java +++ b/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/SimpleCatalogArchiveHelper.java @@ -140,6 +140,7 @@ public class SimpleCatalogArchiveHelper private static final String GLOSSARY_TYPE_NAME = "Glossary"; private static final String CANONICAL_VOCABULARY_TYPE_NAME = "CanonicalVocabulary"; private static final String GLOSSARY_CATEGORY_TYPE_NAME = "GlossaryCategory"; + private static final String ROOT_CATEGORY_CLASSIFICATION_NAME = "RootCategory"; private static final String CATEGORY_ANCHOR_TYPE_NAME = "CategoryAnchor"; private static final String CATEGORY_HIERARCHY_LINK_TYPE_NAME = "CategoryHierarchyLink"; private static final String GLOSSARY_TERM_TYPE_NAME = "GlossaryTerm"; @@ -4454,7 +4455,7 @@ public String addGlossary(String qualifiedName, /** - * Add a glossary category to the archive and connect it to glossary. + * Add a glossary category to the archive and connect it to its glossary. * * @param glossaryGUID identifier of the glossary. * @param qualifiedName unique name for the category. @@ -4470,12 +4471,12 @@ public String addCategory(String glossaryGUID, String description, String subjectArea) { - return addCategory(glossaryGUID, qualifiedName, displayName, description, subjectArea, null); + return addCategory(glossaryGUID, false, qualifiedName, displayName, description, subjectArea, null); } /** - * Add a glossary category to the archive and connect it to glossary. + * Add a glossary category to the archive and connect it to its glossary. * * @param glossaryGUID identifier of the glossary. * @param qualifiedName unique name for the category. @@ -4492,6 +4493,32 @@ public String addCategory(String glossaryGUID, String description, String subjectArea, Map additionalProperties) + { + return addCategory(glossaryGUID, false, qualifiedName, displayName, description, subjectArea, additionalProperties); + + } + + + /** + * Add a glossary category to the archive and connect it to its glossary. + * + * @param glossaryGUID identifier of the glossary. + * @param isRootCategory is this the top-level category for the glossary + * @param qualifiedName unique name for the category. + * @param displayName display name for the category. + * @param description description of the category. + * @param subjectArea name of the subject area if this category contains terms for the subject area. + * @param additionalProperties any other properties. + * + * @return identifier of the category + */ + public String addCategory(String glossaryGUID, + boolean isRootCategory, + String qualifiedName, + String displayName, + String description, + String subjectArea, + Map additionalProperties) { final String methodName = "addCategory"; @@ -4500,7 +4527,7 @@ public String addCategory(String glossaryGUID, properties = archiveHelper.addStringPropertyToInstance(archiveRootName, properties, DESCRIPTION_PROPERTY, description, methodName); properties = archiveHelper.addStringMapPropertyToInstance(archiveRootName, properties, ADDITIONAL_PROPERTIES_PROPERTY, additionalProperties, methodName); - List classifications = null; + List classifications = new ArrayList<>(); if (subjectArea != null) { @@ -4512,10 +4539,24 @@ public String addCategory(String glossaryGUID, methodName), InstanceStatus.ACTIVE); - classifications = new ArrayList<>(); classifications.add(subjectAreaClassification); } + if (isRootCategory) + { + Classification rootCategoryClassification = archiveHelper.getClassification(ROOT_CATEGORY_CLASSIFICATION_NAME, + null, + InstanceStatus.ACTIVE); + + classifications.add(rootCategoryClassification); + } + + + if (classifications.isEmpty()) + { + classifications = null; + } + EntityDetail categoryEntity = archiveHelper.getEntityDetail(GLOSSARY_CATEGORY_TYPE_NAME, idToGUIDMap.getGUID(qualifiedName), properties, diff --git a/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/package-info.java b/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/package-info.java new file mode 100644 index 00000000000..78c424cd1ee --- /dev/null +++ b/open-metadata-resources/open-metadata-archives/content-pack-helpers/src/main/java/org/odpi/openmetadata/samples/archiveutilities/package-info.java @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +/** + * The helper classes build metadata instances of specific types. + */ +package org.odpi.openmetadata.samples.archiveutilities; \ No newline at end of file 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 d98cf3b88b0..b1df4d44e14 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 @@ -7,17 +7,8 @@ import org.odpi.openmetadata.repositoryservices.archiveutilities.OMRSArchiveHelper; import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchive; import org.odpi.openmetadata.repositoryservices.connectors.stores.archivestore.properties.OpenMetadataArchiveType; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationDef; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationPropagationRule; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.EntityDef; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.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.TypeDefAttributeStatus; 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; @@ -47,7 +38,7 @@ public class OpenMetadataTypesArchive private static final String archiveName = "Open Metadata Types"; private static final String archiveDescription = "Standard types for open metadata repositories."; private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; - private static final String archiveVersion = "4.2"; + private static final String archiveVersion = "4.3"; private static final String originatorName = "Egeria"; private static final String originatorLicense = "Apache-2.0"; private static final Date creationDate = new Date(1588261366992L); @@ -155,7 +146,7 @@ public OpenMetadataArchive getOpenMetadataArchive() */ public void getOriginalTypes() { - OpenMetadataTypesArchive4_1 previousTypes = new OpenMetadataTypesArchive4_1(archiveBuilder); + OpenMetadataTypesArchive4_2 previousTypes = new OpenMetadataTypesArchive4_2(archiveBuilder); /* * Pull the types from previous releases. @@ -165,7 +156,13 @@ public void getOriginalTypes() /* * Add the type updates */ - update0021Collections(); + update0010Base(); + update0017ExternalIdentifiers(); + update0035Hosts(); + update0210DataStores(); + update0212APIs(); + update0215SoftwareComponents(); + update0223Events(); } @@ -173,18 +170,18 @@ public void getOriginalTypes() * ------------------------------------------------------------------------------------------------------- */ - private void update0021Collections() + private void update0010Base() { - this.archiveBuilder.addTypeDefPatch(updateCollectionMembershipRelationship()); + this.archiveBuilder.addTypeDefPatch(updateDataSet()); } - private TypeDefPatch updateCollectionMembershipRelationship() + private TypeDefPatch updateDataSet() { /* * Create the Patch */ - final String typeName = "CollectionMembership"; + final String typeName = "DataSet"; TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); @@ -197,34 +194,311 @@ private TypeDefPatch updateCollectionMembershipRelationship() List properties = new ArrayList<>(); TypeDefAttribute property; - final String attribute1Name = "userDefinedStatus"; - final String attribute1Description = "Extend or replace the valid instance statuses with additional statuses controlled through valid metadata values."; + final String attribute1Name = "deployedImplementationType"; + final String attribute1Description = "Name of the technology used to implement this data set."; final String attribute1DescriptionGUID = null; - final String attribute5Name = "notes"; - final String attribute5Description = "Information relating to the classification."; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0017ExternalIdentifiers() + { + this.archiveBuilder.addTypeDefPatch(updateExternalId()); + } + + + private TypeDefPatch updateExternalId() + { + /* + * Create the Patch + */ + final String typeName = "ExternalId"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "externalInstanceCreatedBy"; + final String attribute1Description = "The username of the person or process that created the instance in the external system."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "externalInstanceCreationTime"; + final String attribute2Description = "The date/time when the instance in the external system was created."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "externalInstanceLastUpdatedBy"; + final String attribute3Description = "The username of the person or process that last updated the instance in the external system."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "externalInstanceLastUpdateTime"; + final String attribute4Description = "The date/time when the instance in the external system was last updated."; + final String attribute4DescriptionGUID = null; + final String attribute5Name = "externalInstanceVersion"; + final String attribute5Description = "The latest version of the element in the external system."; final String attribute5DescriptionGUID = null; - final String attribute6Name = "stewardTypeName"; - final String attribute6Description = "Type of element used to identify the steward."; - final String attribute6DescriptionGUID = null; - final String attribute7Name = "stewardPropertyName"; - final String attribute7Description = "Name of property used to identify the steward."; - final String attribute7DescriptionGUID = null; property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute5Name, - attribute5Description, - attribute5DescriptionGUID); + property = archiveHelper.getDateTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, + attribute3Description, + attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getDateTypeDefAttribute(attribute4Name, + attribute4Description, + attribute4DescriptionGUID); + properties.add(property); + property = archiveHelper.getLongTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0035Hosts() + { + this.archiveBuilder.addTypeDefPatch(updateHostClusterMemberRelationship()); + } + + + private TypeDefPatch updateHostClusterMemberRelationship() + { + /* + * Create the Patch + */ + final String typeName = "HostClusterMember"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "memberRole"; + final String attribute1Description = "The role of the member in the host cluster. This value is typically defined by the technology of the host cluster."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "additionalProperties"; + final String attribute2Description = "Additional properties that define the configuration and properties of the member."; + final String attribute2DescriptionGUID = null; + + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getMapStringStringTypeDefAttribute(attribute2Name, + attribute2Description, + attribute2DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0210DataStores() + { + this.archiveBuilder.addTypeDefPatch(updateDataStore()); + } + + + private TypeDefPatch updateDataStore() + { + /* + * Create the Patch + */ + final String typeName = "DataStore"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "deployedImplementationType"; + final String attribute1Description = "Name of the technology used to implement this data store."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0212APIs() + { + this.archiveBuilder.addTypeDefPatch(updateDeployedAPI()); + } + + + private TypeDefPatch updateDeployedAPI() + { + /* + * Create the Patch + */ + final String typeName = "DeployedAPI"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "deployedImplementationType"; + final String attribute1Description = "Name of the technology used to implement this API."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute6Name, - attribute6Description, - attribute6DescriptionGUID); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0215SoftwareComponents() + { + this.archiveBuilder.addTypeDefPatch(updateDeployedSoftwareComponent()); + } + + + private TypeDefPatch updateDeployedSoftwareComponent() + { + /* + * Create the Patch + */ + final String typeName = "DeployedSoftwareComponent"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "deployedImplementationType"; + final String attribute1Description = "Name of the technology used to implement this component."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); properties.add(property); - property = archiveHelper.getStringTypeDefAttribute(attribute7Name, - attribute7Description, - attribute7DescriptionGUID); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0223Events() + { + this.archiveBuilder.addTypeDefPatch(updateDataFeed()); + } + + + private TypeDefPatch updateDataFeed() + { + /* + * Create the Patch + */ + final String typeName = "DataFeed"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "deployedImplementationType"; + final String attribute1Description = "Name of the technology used to implement this data feed."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); properties.add(property); typeDefPatch.setPropertyDefinitions(properties); @@ -232,6 +506,7 @@ private TypeDefPatch updateCollectionMembershipRelationship() return typeDefPatch; } + /* * ------------------------------------------------------------------------------------------------------- */ diff --git a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive2_4.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive2_4.java index 4d5e21e2349..c408f51cdb5 100644 --- a/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive2_4.java +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive2_4.java @@ -49,8 +49,8 @@ public class OpenMetadataTypesArchive2_4 private static final String versionName = "1.0"; - private OMRSArchiveBuilder archiveBuilder; - private OMRSArchiveHelper archiveHelper; + private final OMRSArchiveBuilder archiveBuilder; + private final OMRSArchiveHelper archiveHelper; /** * Default constructor sets up the archive builder. This in turn sets up the header for the archive. @@ -2957,17 +2957,6 @@ private TypeDefPatch updateGraphStoreEntity() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed graph store."; - final String attribute2DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); return typeDefPatch; } @@ -3007,8 +2996,8 @@ private TypeDefPatch updateLogFileEntity() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed log file."; + final String attribute2Name = "purpose"; + final String attribute2Description = "Use of the log file."; final String attribute2DescriptionGUID = null; property = archiveHelper.getStringTypeDefAttribute(attribute2Name, @@ -3057,16 +3046,6 @@ private TypeDefPatch updateDatabaseEntity() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed database."; - final String attribute2DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - - properties.add(property); - final String attribute3Name = "version"; final String attribute3Description = "Deprecated attribute. Use the databaseVersion attribute to define the version number of database."; final String attribute3DescriptionGUID = null; @@ -3129,16 +3108,6 @@ private TypeDefPatch updateDatabaseServerClassification() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed database server."; - final String attribute2DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - - properties.add(property); - final String attribute3Name = "version"; final String attribute3Description = "Deprecated attribute. Use the softwareVersion attribute to define the version number of database server software."; final String attribute3DescriptionGUID = null; @@ -3201,17 +3170,6 @@ private TypeDefPatch updateMetadataRepositoryEntity() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed metadata repository."; - final String attribute2DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); return typeDefPatch; } @@ -3251,17 +3209,6 @@ private TypeDefPatch updateMetadataServerClassification() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed metadata server."; - final String attribute2DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - - properties.add(property); - - typeDefPatch.setPropertyDefinitions(properties); return typeDefPatch; } @@ -3301,17 +3248,6 @@ private TypeDefPatch updateRepositoryProxyClassification() property.setReplacedByAttribute(attribute1ReplacedBy); properties.add(property); - final String attribute2Name = "deployedImplementationType"; - final String attribute2Description = "Type of implemented or deployed repository proxy."; - final String attribute2DescriptionGUID = null; - - property = archiveHelper.getStringTypeDefAttribute(attribute2Name, - attribute2Description, - attribute2DescriptionGUID); - - 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/OpenMetadataTypesArchive4_2.java b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive4_2.java new file mode 100644 index 00000000000..b5d867ec049 --- /dev/null +++ b/open-metadata-resources/open-metadata-archives/open-metadata-types/src/main/java/org/odpi/openmetadata/opentypes/OpenMetadataTypesArchive4_2.java @@ -0,0 +1,230 @@ +/* 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.TypeDefAttribute; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefPatch; +import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode; +import org.odpi.openmetadata.repositoryservices.ffdc.exception.OMRSLogicErrorException; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * OpenMetadataTypesArchive builds an open metadata archive containing all the standard open metadata types. + * These types have hardcoded dates and guids so that however many times this archive is rebuilt, it will + * produce the same content. + *

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

+ *

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

+ */ +public class OpenMetadataTypesArchive4_2 +{ + /* + * This is the header information for the archive. + */ + private static final String archiveGUID = "bce3b0a0-662a-4f87-b8dc-844078a11a6e"; + private static final String archiveName = "Open Metadata Types"; + private static final String archiveDescription = "Standard types for open metadata repositories."; + private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; + private static final String archiveVersion = "4.2"; + private static final String originatorName = "Egeria"; + private static final String originatorLicense = "Apache-2.0"; + private static final Date creationDate = new Date(1588261366992L); + + /* + * Specific values for initializing TypeDefs + */ + private static final long versionNumber = 1L; + private static final String versionName = "1.0"; + + + private final OMRSArchiveBuilder archiveBuilder; + private final OMRSArchiveHelper archiveHelper; + + /** + * Default constructor sets up the archive builder. This in turn sets up the header for the archive. + */ + public OpenMetadataTypesArchive4_2() + { + this.archiveBuilder = new OMRSArchiveBuilder(archiveGUID, + archiveName, + archiveDescription, + archiveType, + archiveVersion, + originatorName, + originatorLicense, + creationDate, + null); + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); + } + + + /** + * Chained constructor sets up the archive builder. This in turn sets up the header for the archive. + * + * @param archiveBuilder accumulator for types + */ + public OpenMetadataTypesArchive4_2(OMRSArchiveBuilder archiveBuilder) + { + this.archiveBuilder = archiveBuilder; + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); + } + + + /** + * Return the unique identifier for this archive. + * + * @return String guid + */ + public String getArchiveGUID() + { + return archiveGUID; + } + + + /** + * Returns the open metadata type archive containing all the standard open metadata types. + * + * @return populated open metadata archive object + */ + public OpenMetadataArchive getOpenMetadataArchive() + { + final String methodName = "getOpenMetadataArchive"; + + if (this.archiveBuilder != null) + { + /* + * Build the type archive. + */ + this.getOriginalTypes(); + + /* + * The completed archive is ready to be packaged up and returned + */ + return this.archiveBuilder.getOpenMetadataArchive(); + } + else + { + /* + * This is a logic error since it means the creation of the archive builder threw an exception + * in the constructor and so this object should not be used. + */ + throw new OMRSLogicErrorException(OMRSErrorCode.ARCHIVE_UNAVAILABLE.getMessageDefinition(), + this.getClass().getName(), + methodName); + } + } + + + /** + * Add the types from this archive to the archive builder supplied in the + * constructor. + */ + public void getOriginalTypes() + { + OpenMetadataTypesArchive4_1 previousTypes = new OpenMetadataTypesArchive4_1(archiveBuilder); + + /* + * Pull the types from previous releases. + */ + previousTypes.getOriginalTypes(); + + /* + * Add the type updates + */ + update0021Collections(); + } + + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + private void update0021Collections() + { + this.archiveBuilder.addTypeDefPatch(updateCollectionMembershipRelationship()); + } + + + private TypeDefPatch updateCollectionMembershipRelationship() + { + /* + * Create the Patch + */ + final String typeName = "CollectionMembership"; + + TypeDefPatch typeDefPatch = archiveBuilder.getPatchForType(typeName); + + typeDefPatch.setUpdatedBy(originatorName); + typeDefPatch.setUpdateTime(creationDate); + + /* + * Build the attributes + */ + List properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "userDefinedStatus"; + final String attribute1Description = "Extend or replace the valid instance statuses with additional statuses controlled through valid metadata values."; + final String attribute1DescriptionGUID = null; + final String attribute5Name = "notes"; + final String attribute5Description = "Information relating to the classification."; + final String attribute5DescriptionGUID = null; + final String attribute6Name = "stewardTypeName"; + final String attribute6Description = "Type of element used to identify the steward."; + final String attribute6DescriptionGUID = null; + final String attribute7Name = "stewardPropertyName"; + final String attribute7Description = "Name of property used to identify the steward."; + final String attribute7DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, + attribute1Description, + attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute5Name, + attribute5Description, + attribute5DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute6Name, + attribute6Description, + attribute6DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute7Name, + attribute7Description, + attribute7DescriptionGUID); + properties.add(property); + + typeDefPatch.setPropertyDefinitions(properties); + + return typeDefPatch; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ +} + diff --git a/settings.gradle b/settings.gradle index a47e0c032be..1da7c98383e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -53,8 +53,10 @@ include(':open-metadata-implementation:adapters:open-connectors:data-store-conne include(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector') include(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:avro-file-connector') include(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector') +include(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector') include(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector') include(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors') +include(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector') include(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector') include(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector') include(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors') @@ -266,6 +268,8 @@ include(':open-metadata-implementation:admin-services:admin-services-registratio include(':open-metadata-implementation:admin-services:admin-services-client') include(':open-metadata-implementation:admin-services:admin-services-server') include(':open-metadata-implementation:admin-services:admin-services-spring') +include(':open-metadata-implementation:server-operations:server-operations-api') +include(':open-metadata-implementation:server-operations:server-operations-server') include(':open-metadata-implementation:platform-services:platform-services-api') include(':open-metadata-implementation:platform-services:platform-services-client') include(':open-metadata-implementation:platform-services:platform-services-server')