From 0e11ffbf173f8756181ce99ad18297bb7366a8d4 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 24 Jul 2023 09:48:27 +0100 Subject: [PATCH 1/5] Add testEntityTypes option to repository workbench config Signed-off-by: Mandy Chessell --- .../build.gradle | 3 + ...penMetadataConformanceProfilePriority.java | 15 +- .../beans/OpenMetadataConformanceStatus.java | 27 +- ...enMetadataConformanceTestEvidenceType.java | 41 ++- ...enMetadataConformanceWorkbenchWorkPad.java | 23 +- .../beans/TechnologyUnderTestWorkPad.java | 51 +-- .../ffdc}/ConformanceSuiteAuditCode.java | 113 +++---- .../ffdc/ConformanceSuiteErrorCode.java | 111 ++---- .../ConformanceSuiteRuntimeException.java | 320 ++++++++++++++---- .../exception/InvalidParameterException.java | 136 -------- .../exception/PropertyServerException.java | 75 ---- .../exception/UserNotAuthorizedException.java | 138 -------- .../build.gradle | 1 + .../OpenMetadataConformanceTestReport.java | 153 +++++---- .../conformance/client/RESTClient.java | 31 +- .../client/RESTExceptionHandler.java | 12 +- .../ConformanceSuiteOperationalServices.java | 46 +-- .../ConformanceSuiteTestLabServices.java | 51 +-- .../OpenMetadataPerformanceTestCase.java | 62 ++-- .../OpenMetadataPlatformTestCase.java | 59 ++-- .../RepositoryConformanceTestCase.java | 62 ++-- ...estClassificationHasSupportedEntities.java | 9 - .../TestSupportedEntityProxyLifecycle.java | 55 ++- ...SupportedEntityReferenceCopyLifecycle.java | 42 +-- ...tedRelationshipReferenceCopyLifecycle.java | 91 +++-- .../types/TestFindTypeDefsByCategory.java | 89 +---- .../types/TestGetTypeDefGallery.java | 244 ++++++++++++- .../performance/PerformanceWorkPad.java | 8 +- .../performance/PerformanceWorkbench.java | 293 ++++------------ .../PerformanceSuiteConnectorConsumer.java | 91 ++--- .../PlatformConformanceWorkbench.java | 53 +-- .../RepositoryConformanceWorkPad.java | 25 +- .../RepositoryConformanceWorkbench.java | 76 ++--- .../ConformanceSuiteConnectorConsumer.java | 84 ++--- .../properties/AtlasEntityStatus.java | 9 - 35 files changed, 1146 insertions(+), 1553 deletions(-) rename open-metadata-conformance-suite/{open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/auditlog => open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc}/ConformanceSuiteAuditCode.java (80%) delete mode 100644 open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/InvalidParameterException.java delete mode 100644 open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/PropertyServerException.java delete mode 100644 open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/UserNotAuthorizedException.java delete mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityStatus.java diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/build.gradle b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/build.gradle index 5b179376c0c..407f096ad94 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/build.gradle +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/build.gradle @@ -5,6 +5,9 @@ dependencies { + compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework') + compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework') + implementation project(':open-metadata-implementation:repository-services:repository-services-apis') implementation 'org.slf4j:slf4j-api' compileOnly 'com.fasterxml.jackson.core:jackson-annotations' } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceProfilePriority.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceProfilePriority.java index 6b7f4878356..1cd542ca05c 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceProfilePriority.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceProfilePriority.java @@ -19,16 +19,23 @@ @JsonIgnoreProperties(ignoreUnknown=true) public enum OpenMetadataConformanceProfilePriority implements Serializable { + /** + * This profile must be supported for the technology under test to be compliant. + */ MANDATORY_PROFILE (0, "Mandatory Profile", "This profile must be supported for the technology under test to be compliant."), + + /** + * This profile must either be supported, or a conformant response is required to signal that the feature is not supported. + */ OPTIONAL_PROFILE (1, "Optional Profile", - "This profile must either be supported, or a conformant response is required."); + "This profile must either be supported, or a conformant response is required to signal that the feature is not supported."); private static final long serialVersionUID = 1L; - private int ordinal; - private String name; - private String description; + private final int ordinal; + private final String name; + private final String description; diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceStatus.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceStatus.java index a67b39f3072..60f816f3061 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceStatus.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceStatus.java @@ -21,22 +21,41 @@ @JsonIgnoreProperties(ignoreUnknown=true) public enum OpenMetadataConformanceStatus implements Serializable { + /** + * There is not enough evidence to determine the conformance of the technology under test. + */ UNKNOWN_STATUS (0, "Unknown status", "There is not enough evidence to determine the conformance of the technology under test."), + + /** + * The technology provides correctly functioning support for all features in this profile. + */ CONFORMANT_FULL_SUPPORT (1, "Conformant with full support", "The technology provides correctly functioning support for all features in this profile."), + + /** + * The technology provides correctly functioning support for some of the features in this profile and responds appropriately for features it does not support. + */ CONFORMANT_PARTIAL_SUPPORT (2, "Conformant with partial support", "The technology provides correctly functioning support for some of the features in this profile and responds appropriately for features it does not support."), + + /** + * The technology provides correctly functioning responses that indicate it has no support for the features in this profile. + */ CONFORMANT_NO_SUPPORT (3, "Conformant with no support", "The technology provides correctly functioning responses that indicate it has no support for the features in this profile."), + + /** + * The technology is not functioning according to the open metadata specifications. + */ NOT_CONFORMANT (4, "Not Conformant", - "The technology is not functioning according to the open metadata specifications."); + "The technology is not functioning according to the open metadata specifications."); private static final long serialVersionUID = 1L; - private int ordinal; - private String name; - private String description; + private final int ordinal; + private final String name; + private final String description; /** diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceTestEvidenceType.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceTestEvidenceType.java index e0f468e6e2a..9420caaafa7 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceTestEvidenceType.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceTestEvidenceType.java @@ -11,24 +11,47 @@ */ public enum OpenMetadataConformanceTestEvidenceType implements Serializable { + /** + * Unknown - No data available at this time. + */ NO_DATA_AVAILABLE (0, "Unknown", - "No data available at this time."), + "No data available at this time."), + + /** + * The test case condition is true. + */ SUCCESSFUL_ASSERTION (0, "Successful assertion", - "The test case condition is true."), + "The test case condition is true."), + + /** + * The test case condition is false. + */ UNSUCCESSFUL_ASSERTION (1, "Unsuccessful assertion", - "The test case condition is false."), + "The test case condition is false."), + + /** + * The test case has discovered a property. + */ DISCOVERED_PROPERTY (2, "Discovered property", - "The test case has discovered a property."), + "The test case has discovered a property."), + + /** + * The test case reports a correct response for a non-supported function. + */ NOT_SUPPORTED_FUNCTION (3, "Not supported function", - "The test case reports a correct response for a non supported function."), + "The test case reports a correct response for a non-supported function."), + + /** + * An exception occurred where it should not. + */ UNEXPECTED_EXCEPTION (4, "Unexpected exception", - "An exception occurred where it should not."); + "An exception occurred where it should not."); private static final long serialVersionUID = 1L; - private int ordinal; - private String name; - private String description; + private final int ordinal; + private final String name; + private final String description; /** diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java index ed86221f2d9..87bdeb79981 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/OpenMetadataConformanceWorkbenchWorkPad.java @@ -4,7 +4,7 @@ import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteErrorCode; import org.odpi.openmetadata.conformance.ffdc.exception.ConformanceSuiteRuntimeException; -import org.odpi.openmetadata.conformance.ffdc.exception.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import java.util.*; @@ -195,18 +195,11 @@ synchronized void registerTestCase(OpenMetadataTestCase testCase) relatedProperties.put("Existing TestCase", duplicateTestCase); relatedProperties.put("New TestCase", testCase); - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.DUPLICATE_TEST_CASE; - String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(tutName, - tutType, - testCase.getTestCaseId()); - - throw new ConformanceSuiteRuntimeException(errorCode.getHTTPErrorCode(), + throw new ConformanceSuiteRuntimeException(ConformanceSuiteErrorCode.DUPLICATE_TEST_CASE.getMessageDefinition(tutName, + tutType, + testCase.getTestCaseId()), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), relatedProperties); } } @@ -591,15 +584,9 @@ synchronized OpenMetadataTestCaseResult getTestCaseResult(String testCaseId) return testCase.getResult(); } - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.UNKNOWN_TEST_CASE_ID; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(testCaseId); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + throw new InvalidParameterException(ConformanceSuiteErrorCode.UNKNOWN_TEST_CASE_ID.getMessageDefinition(testCaseId), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), parameterName); } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/TechnologyUnderTestWorkPad.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/TechnologyUnderTestWorkPad.java index 00a469e6894..5ca460c696c 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/TechnologyUnderTestWorkPad.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/beans/TechnologyUnderTestWorkPad.java @@ -3,7 +3,7 @@ package org.odpi.openmetadata.conformance.beans; import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteErrorCode; -import org.odpi.openmetadata.conformance.ffdc.exception.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import java.util.ArrayList; import java.util.Date; @@ -12,14 +12,13 @@ /** * TechnologyUnderTestWorkPad is the class used to aggregate information about a technology (typically a metadata * repository) that is being tested by the ODPi Egeria Conformance Suite. - * * It is responsible for accumulating the results from the different test workbenches as they probe the REST API * and validate the events being published by the technology under test (TUT). */ public class TechnologyUnderTestWorkPad { - private OpenMetadataConformanceTestLabResults testLabResults = new OpenMetadataConformanceTestLabResults(); - private List workbenchWorkPads; + private final OpenMetadataConformanceTestLabResults testLabResults = new OpenMetadataConformanceTestLabResults(); + private final List workbenchWorkPads; /** @@ -105,16 +104,10 @@ public OpenMetadataConformanceProfileResults getProfileReport(String profileName /* * None of the workbenches know about this profile name. */ - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.UNKNOWN_PROFILE_NAME; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(profileName); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), - parameterName); + throw new InvalidParameterException(ConformanceSuiteErrorCode.UNKNOWN_PROFILE_NAME.getMessageDefinition(profileName), + this.getClass().getName(), + methodName, + parameterName); } @@ -154,15 +147,9 @@ public OpenMetadataTestCaseResult getTestCaseReport(String testCaseId) throws /* * None of the workbenches know about this test case. */ - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.UNKNOWN_TEST_CASE_ID; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(testCaseId); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + throw new InvalidParameterException(ConformanceSuiteErrorCode.UNKNOWN_TEST_CASE_ID.getMessageDefinition(testCaseId), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), parameterName); } @@ -230,15 +217,9 @@ public OpenMetadataConformanceWorkbenchResults getWorkbenchReport(String workb } } - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.UNKNOWN_WORKBENCH_ID; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(workbenchId); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + throw new InvalidParameterException(ConformanceSuiteErrorCode.UNKNOWN_WORKBENCH_ID.getMessageDefinition(workbenchId), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), parameterName); } @@ -268,16 +249,10 @@ public OpenMetadataConformanceWorkbenchStatus getWorkbenchStatus(String workbe } } - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.UNKNOWN_WORKBENCH_ID; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(workbenchId); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), - parameterName); + throw new InvalidParameterException(ConformanceSuiteErrorCode.UNKNOWN_WORKBENCH_ID.getMessageDefinition(workbenchId), + this.getClass().getName(), + methodName, + parameterName); } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/auditlog/ConformanceSuiteAuditCode.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteAuditCode.java similarity index 80% rename from open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/auditlog/ConformanceSuiteAuditCode.java rename to open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteAuditCode.java index 11a33e0615c..cd72e39af68 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/auditlog/ConformanceSuiteAuditCode.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteAuditCode.java @@ -1,20 +1,16 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.conformance.auditlog; +package org.odpi.openmetadata.conformance.ffdc; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.AuditLogMessageDefinition; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.AuditLogMessageSet; import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLogRecordSeverity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.text.MessageFormat; -import java.util.Arrays; /** * The ConformanceSuiteAuditCode is used to define the message content for the OMRS Audit Log. - * * The 5 fields in the enum are: *
    - *
  • Log Message Id - to uniquely identify the message
  • + *
  • 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
  • *
  • Additional Information - further parameters and data relating to the audit message (optional)
  • @@ -22,7 +18,7 @@ *
  • UserAction - describes how a user should correct the situation
  • *
*/ -public enum ConformanceSuiteAuditCode +public enum ConformanceSuiteAuditCode implements AuditLogMessageSet { SERVICE_INITIALIZING("CONFORMANCE-SUITE-0001", OMRSAuditLogRecordSeverity.INFO, @@ -97,13 +93,13 @@ public enum ConformanceSuiteAuditCode "No action is required. This is part of the normal operation of the service."), TEST_CASE_COMPLETED("CONFORMANCE-SUITE-0013", - OMRSAuditLogRecordSeverity.INFO, + OMRSAuditLogRecordSeverity.DECISION, "The Open Metadata Conformance Test Case {0} has completed with {1} successful assertions, {2} unsuccessful assertions, {3} unexpected exceptions and {4} discovered properties.", "The Open Metadata Conformance Test Case has completed running its tests. Retrieve the report to find out more details.", "No action is required. This is part of the normal operation of the service."), TEST_CASE_COMPLETED_SUCCESSFULLY("CONFORMANCE-SUITE-0014", - OMRSAuditLogRecordSeverity.INFO, + OMRSAuditLogRecordSeverity.DECISION, "The Open Metadata Conformance Test Case {0} has completed with {1} successful assertions, {2} unsuccessful assertions, {3} unexpected exceptions and {4} discovered properties. The message on completion was: {5}", "The Open Metadata Conformance Test Case has completed running its tests. Retrieve the report to find out more details.", "No action is required. This is part of the normal operation of the service."), @@ -152,24 +148,22 @@ public enum ConformanceSuiteAuditCode ; - private String logMessageId; - private OMRSAuditLogRecordSeverity severity; - private String logMessage; - private String systemAction; - private String userAction; - - private static final Logger log = LoggerFactory.getLogger(ConformanceSuiteAuditCode.class); + private final String logMessageId; + private final OMRSAuditLogRecordSeverity severity; + private final String logMessage; + private final String systemAction; + private final String userAction; /** * The constructor for ConformanceSuiteAuditCode expects to be passed one of the enumeration rows defined in * ConformanceSuiteAuditCode above. For example: - * + *

* ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.SERVER_NOT_AVAILABLE; - * + *

* This will expand out to the 5 parameters shown below. * - * @param messageId unique Id for the message + * @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 @@ -188,67 +182,54 @@ public enum ConformanceSuiteAuditCode this.userAction = userAction; } - /** - * Returns the unique identifier for the error message. + * Retrieve a message definition object for logging. This method is used when there are no message inserts. * - * @return logMessageId + * @return message definition object. */ - public String getLogMessageId() + @Override + public AuditLogMessageDefinition getMessageDefinition() { - return logMessageId; + return new AuditLogMessageDefinition(logMessageId, + severity, + logMessage, + systemAction, + userAction); } /** - * Return the severity of the audit log record. + * Retrieve a message definition object for logging. This method is used when there are values to be inserted into the message. * - * @return OMRSAuditLogRecordSeverity enum + * @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. */ - public OMRSAuditLogRecordSeverity getSeverity() + @Override + public AuditLogMessageDefinition getMessageDefinition(String ...params) { - return severity; + AuditLogMessageDefinition messageDefinition = new AuditLogMessageDefinition(logMessageId, + severity, + logMessage, + systemAction, + userAction); + messageDefinition.setMessageParameters(params); + return messageDefinition; } /** - * Returns the log message with the placeholders filled out with the supplied parameters. - * - * @param params - strings that plug into the placeholders in the logMessage - * @return logMessage (formatted with supplied parameters) - */ - public String getFormattedLogMessage(String... params) - { - log.debug(String.format("<== Conformance Suite Audit Code.getMessage(%s)", Arrays.toString(params))); - - MessageFormat mf = new MessageFormat(logMessage); - String result = mf.format(params); - - log.debug(String.format("==> Conformance Suite Audit Code.getMessage(%s): %s", Arrays.toString(params), result)); - - return result; - } - - - - /** - * Returns a description of the action taken by the system when the condition that caused this exception was - * detected. - * - * @return systemAction String - */ - public String getSystemAction() - { - return systemAction; - } - - - /** - * Returns instructions of how to resolve the issue reported in this exception. + * JSON-style toString * - * @return userAction String + * @return string of property names and values for this enum */ - public String getUserAction() + @Override + public String toString() { - return userAction; + return "ConformanceSuiteAuditCode{" + + "logMessageId='" + logMessageId + '\'' + + ", severity=" + severity + + ", logMessage='" + logMessage + '\'' + + ", systemAction='" + systemAction + '\'' + + ", userAction='" + userAction + '\'' + + '}'; } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteErrorCode.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteErrorCode.java index b8432d09d1f..8726fb41607 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteErrorCode.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/ConformanceSuiteErrorCode.java @@ -2,17 +2,13 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.ffdc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.text.MessageFormat; -import java.util.Arrays; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageSet; /** * The ConformanceSuiteErrorCode is used to define first failure data capture (FFDC) for errors that occur within the * Open Metadata Conformance Suite * It is used in conjunction with conformance suite exceptions, both Checked and Runtime (unchecked). - * * The 5 fields in the enum are: *
    *
  • HTTP Error Code - for translating between REST and JAVA - Typically the numbers used are:
  • @@ -32,7 +28,7 @@ *
  • UserAction - describes how a user should correct the error
  • *
*/ -public enum ConformanceSuiteErrorCode +public enum ConformanceSuiteErrorCode implements ExceptionMessageSet { NULL_LOCAL_SERVER_NAME(400, "CONFORMANCE-SUITE-400-001 ", "OMAG server has been called with a null local server name", @@ -173,106 +169,73 @@ public enum ConformanceSuiteErrorCode "The error message should indicate the cause of the error. Otherwise look for errors in the remote server's audit log and console to understand and correct the source of the error.") ; - private final int httpErrorCode; - private final String errorMessageId; - private final String errorMessage; - private final String systemAction; - private final String userAction; - private static final Logger log = LoggerFactory.getLogger(ConformanceSuiteErrorCode.class); private static final long serialVersionUID = 1L; + private final ExceptionMessageDefinition messageDefinition; + /** * The constructor for OMRSErrorCode expects to be passed one of the enumeration rows defined in * OMRSErrorCode above. For example: - * + *

* OMRSErrorCode errorCode = OMRSErrorCode.SERVER_NOT_AVAILABLE; - * + *

* This will expand out to the 5 parameters shown below. * - * @param newHTTPErrorCode error code to use over REST calls - * @param newErrorMessageId unique Id for the message - * @param newErrorMessage text for the message - * @param newSystemAction description of the action taken by the system when the error condition happened - * @param newUserAction instructions for resolving the error - */ - ConformanceSuiteErrorCode(int newHTTPErrorCode, String newErrorMessageId, String newErrorMessage, String newSystemAction, String newUserAction) - { - this.httpErrorCode = newHTTPErrorCode; - this.errorMessageId = newErrorMessageId; - this.errorMessage = newErrorMessage; - this.systemAction = newSystemAction; - this.userAction = newUserAction; - } - - - public int getHTTPErrorCode() - { - return httpErrorCode; - } - - - /** - * Returns the unique identifier for the error message. - * - * @return errorMessageId + * @param httpErrorCode error code to use over REST calls + * @param errorMessageId unique identifier for the message + * @param errorMessage text for the message + * @param systemAction description of the action taken by the system when the error condition happened + * @param userAction instructions for resolving the error */ - public String getErrorMessageId() + ConformanceSuiteErrorCode(int httpErrorCode, String errorMessageId, String errorMessage, String systemAction, String userAction) { - return errorMessageId; + this.messageDefinition = new ExceptionMessageDefinition(httpErrorCode, + errorMessageId, + errorMessage, + systemAction, + userAction); } /** - * Returns the error message with placeholders for specific details. + * Retrieve a message definition object for an exception. This method is used when there are no message inserts. * - * @return errorMessage (unformatted) + * @return message definition object. */ - public String getUnformattedErrorMessage() + @Override + public ExceptionMessageDefinition getMessageDefinition() { - return errorMessage; + return messageDefinition; } /** - * Returns the error message with the placeholders filled out with the supplied parameters. + * Retrieve a message definition object for an exception. This method is used when there are values to be inserted into the message. * - * @param params strings that plug into the placeholders in the errorMessage - * @return errorMessage (formatted with supplied parameters) + * @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. */ - public String getFormattedErrorMessage(String... params) + @Override + public ExceptionMessageDefinition getMessageDefinition(String... params) { - log.debug(String.format("<== ConformanceSuiteErrorCode.getMessage(%s)", Arrays.toString(params))); - - MessageFormat mf = new MessageFormat(errorMessage); - String result = mf.format(params); - - log.debug(String.format("==> ConformanceSuiteErrorCode.getMessage(%s): %s", Arrays.toString(params), result)); - - return result; - } - + messageDefinition.setMessageParameters(params); - /** - * Returns a description of the action taken by the system when the condition that caused this exception was - * detected. - * - * @return systemAction - */ - public String getSystemAction() - { - return systemAction; + return messageDefinition; } /** - * Returns instructions of how to resolve the issue reported in this exception. + * JSON-style toString * - * @return userAction + * @return string of property names and values for this enum */ - public String getUserAction() + @Override + public String toString() { - return userAction; + return "ApacheAtlasErrorCode{" + + "messageDefinition=" + messageDefinition + + '}'; } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/ConformanceSuiteRuntimeException.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/ConformanceSuiteRuntimeException.java index d26531bab1c..6cda6d912a6 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/ConformanceSuiteRuntimeException.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/ConformanceSuiteRuntimeException.java @@ -2,6 +2,13 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.ffdc.exception; +import org.odpi.openmetadata.frameworks.auditlog.MessageFormatter; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serial; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -12,18 +19,124 @@ */ public class ConformanceSuiteRuntimeException extends RuntimeException { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; + private static final Logger log = LoggerFactory.getLogger(ConformanceSuiteRuntimeException.class); + + private static final MessageFormatter messageFormatter = new MessageFormatter(); + + private final int reportedHTTPCode; + private final String reportingClassName; + private final String reportingActionDescription; + private final String reportedErrorMessage; + private String reportedErrorMessageId; + private String[] reportedErrorMessageParameters; + private final String reportedSystemAction; + private final String reportedUserAction; + private Throwable reportedCaughtException = null; + private String reportedCaughtExceptionClassName = null; + private Map relatedProperties = null; + + + /** + * This is the typical constructor used for creating an exception. + * + * @param messageDefinition content of the message + * @param className name of class reporting error + * @param actionDescription description of function it was performing when error detected + */ + public ConformanceSuiteRuntimeException(ExceptionMessageDefinition messageDefinition, + String className, + String actionDescription) + { + this(messageDefinition, className, actionDescription, (Map)null); + } + + + /** + * This is the typical constructor used for creating an exception. + * The properties allow additional information to be associated with the exception. + * + * @param messageDefinition content of the message + * @param className name of class reporting error + * @param actionDescription description of function it was performing when error detected + * @param relatedProperties arbitrary properties that may help with diagnosing the problem. + */ + public ConformanceSuiteRuntimeException(ExceptionMessageDefinition messageDefinition, + String className, + String actionDescription, + Map relatedProperties) + { + super(messageFormatter.getFormattedMessage(messageDefinition)); + + this.reportedHTTPCode = messageDefinition.getHttpErrorCode(); + this.reportingClassName = className; + this.reportingActionDescription = actionDescription; + this.reportedErrorMessage = messageFormatter.getFormattedMessage(messageDefinition); + this.reportedErrorMessageId = messageDefinition.getMessageId(); + this.reportedErrorMessageParameters = messageDefinition.getMessageParams(); + this.reportedSystemAction = messageDefinition.getSystemAction(); + this.reportedUserAction = messageDefinition.getUserAction(); + this.relatedProperties = relatedProperties; + + this.validateCoreProperties(); + + log.debug("{}, {}, {}", messageDefinition, className, actionDescription); + } + + + /** + * This is the constructor used for creating an exception when an unexpected error has been caught. + * The properties allow additional information to be associated with the exception. + * + * @param messageDefinition content of the message + * @param className name of class reporting error + * @param actionDescription description of function it was performing when error detected + * @param caughtError previous error causing this exception + */ + public ConformanceSuiteRuntimeException(ExceptionMessageDefinition messageDefinition, + String className, + String actionDescription, + Throwable caughtError) + { + this(messageDefinition, className, actionDescription, caughtError, null); + } - private int reportedHTTPCode; - private String reportingClassName; - private String reportingActionDescription; - private String reportedErrorMessage; - private String reportedSystemAction; - private String reportedUserAction; - private Map relatedProperties; - private Exception reportedCaughtException = null; + /** + * This is the constructor used for creating an exception when an unexpected error has been caught. + * The properties allow additional information to be associated with the exception. + * + * @param messageDefinition content of the message + * @param className name of class reporting error + * @param actionDescription description of function it was performing when error detected + * @param caughtError previous error causing this exception + * @param relatedProperties arbitrary properties that may help with diagnosing the problem. + */ + public ConformanceSuiteRuntimeException(ExceptionMessageDefinition messageDefinition, + String className, + String actionDescription, + Throwable caughtError, + Map relatedProperties) + { + super(messageFormatter.getFormattedMessage(messageDefinition), caughtError); + this.reportedHTTPCode = messageDefinition.getHttpErrorCode(); + this.reportingClassName = className; + this.reportingActionDescription = actionDescription; + this.reportedErrorMessage = messageFormatter.getFormattedMessage(messageDefinition); + this.reportedErrorMessageId = messageDefinition.getMessageId(); + this.reportedErrorMessageParameters = messageDefinition.getMessageParams(); + this.reportedSystemAction = messageDefinition.getSystemAction(); + this.reportedUserAction = messageDefinition.getUserAction(); + this.reportedCaughtException = caughtError; + this.reportedCaughtExceptionClassName = caughtError.getClass().getName(); + this.relatedProperties = relatedProperties; + + this.validateCoreProperties(); + + log.debug("{}, {}, {}, {}", messageDefinition, className, actionDescription, caughtError); + } /** * This is the typical constructor used for creating an exception. @@ -89,6 +202,48 @@ public ConformanceSuiteRuntimeException(int httpCode, } + /** + * Check that essential details of the exception are populated. + */ + private void validateCoreProperties() + { + if (reportedHTTPCode == 0) + { + log.error("Zero HTTP code passed to an exception"); + } + + if (reportedErrorMessage == null) + { + log.error("Null error message passed to an exception"); + } + + if (reportedErrorMessageId == null) + { + log.error("Null error message Identifier passed to an exception"); + } + + if (reportedSystemAction == null) + { + log.error("Null system action passed to an exception"); + } + + if (reportedUserAction == null) + { + log.error("Null user action passed to an exception"); + } + + if (reportingActionDescription == null) + { + log.error("Null action description passed to an exception"); + } + + if (reportingClassName == null) + { + log.error("Null class name passed to an exception"); + } + } + + /** * Return the HTTP response code to use with this exception. * @@ -99,6 +254,7 @@ public int getReportedHTTPCode() return reportedHTTPCode; } + /** * The class that created this exception. * @@ -124,14 +280,54 @@ public String getReportingActionDescription() /** * A formatted short description of the cause of the condition that resulted in this exception. + * It includes the message id and is formatted with the message parameters. The message is defined in En_US. + * The method is deprecated because it is inconsistent in its naming compared with other methods. * - * @return reportedErrorMessage + * @return string message */ + @Deprecated public String getErrorMessage() { return reportedErrorMessage; } + /** + * A formatted short description of the cause of the condition that resulted in this exception. + * It includes the message id and is formatted with the message parameters. The message is defined in En_US. + * + * @return string message + */ + public String getReportedErrorMessage() + { + return reportedErrorMessage; + } + + + /** + * Return the formal message identifier for the error message. This is incorporated in the error message. + * This is provided both for automated processing and to enable the error message to be reformatted + * in a different language. + * + * @return string message id + */ + public String getReportedErrorMessageId() + { + return reportedErrorMessageId; + } + + + /** + * Return the parameters that were inserted in the error message. + * These are provided both for automated processing and to enable the error message to be reformatted + * in a different language. + * + * @return list of parameter values + */ + public String[] getReportedErrorMessageParameters() + { + return reportedErrorMessageParameters; + } + /** * A description of the action that the system took as a result of the error condition. @@ -157,13 +353,23 @@ public String getReportedUserAction() /** * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is - * newly created and not the result of a previous exception. + * either newly created and not the result of a previous exception or the exception occurred in a remote + * server. If the second situation is true then reportedCaughtExceptionClassName is set. * - * @return reportedCaughtException + * @return reportedCaughtException Throwable object */ - public Exception getReportedCaughtException() + public Throwable getReportedCaughtException() { return reportedCaughtException; } + + + /** + * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is + * the result of a newly detected error and not caused by another exception. + * + * @return full class name of the original exception + */ + public String getReportedCaughtExceptionClassName() { - return reportedCaughtException; + return reportedCaughtExceptionClassName; } @@ -190,31 +396,10 @@ else if (relatedProperties.isEmpty()) /** - * JSON-style toString + * Compare the values of the supplied object with those stored in the current object. * - * @return string of property names and values for this enum - */ - @Override - public String toString() - { - return "ConformanceSuiteRuntimeException{" + - "reportedHTTPCode=" + reportedHTTPCode + - ", reportingClassName='" + reportingClassName + '\'' + - ", reportingActionDescription='" + reportingActionDescription + '\'' + - ", reportedErrorMessage='" + reportedErrorMessage + '\'' + - ", reportedSystemAction='" + reportedSystemAction + '\'' + - ", reportedUserAction='" + reportedUserAction + '\'' + - ", reportedCaughtException=" + reportedCaughtException + - ", relatedProperties=" + relatedProperties + - '}'; - } - - - /** - * Return comparison result based on the content of the properties. - * - * @param objectToCompare test object - * @return result of comparison + * @param objectToCompare supplied object + * @return boolean result of comparison */ @Override public boolean equals(Object objectToCompare) @@ -223,39 +408,58 @@ public boolean equals(Object objectToCompare) { return true; } - if (!(objectToCompare instanceof ConformanceSuiteRuntimeException)) + if (objectToCompare == null || getClass() != objectToCompare.getClass()) { return false; } ConformanceSuiteRuntimeException that = (ConformanceSuiteRuntimeException) objectToCompare; - return getReportedHTTPCode() == that.getReportedHTTPCode() && - Objects.equals(getReportingClassName(), that.getReportingClassName()) && - Objects.equals(getReportingActionDescription(), that.getReportingActionDescription()) && - Objects.equals(getErrorMessage(), that.getErrorMessage()) && - Objects.equals(getReportedSystemAction(), that.getReportedSystemAction()) && - Objects.equals(getReportedUserAction(), that.getReportedUserAction()) && - Objects.equals(getRelatedProperties(), that.getRelatedProperties()) && - Objects.equals(getReportedCaughtException(), that.getReportedCaughtException()); + return reportedHTTPCode == that.reportedHTTPCode && + Objects.equals(reportingClassName, that.reportingClassName) && + Objects.equals(reportingActionDescription, that.reportingActionDescription) && + Objects.equals(reportedErrorMessage, that.reportedErrorMessage) && + Objects.equals(reportedErrorMessageId, that.reportedErrorMessageId) && + Arrays.equals(reportedErrorMessageParameters, that.reportedErrorMessageParameters) && + Objects.equals(reportedSystemAction, that.reportedSystemAction) && + Objects.equals(reportedUserAction, that.reportedUserAction) && + Objects.equals(reportedCaughtException, that.reportedCaughtException) && + Objects.equals(relatedProperties, that.relatedProperties); } - /** - * Return hash code for this object + * Provide a common implementation of hashCode for all OCF Exception objects. * - * @return int hash code + * @return integer hash code based on the values in the attributes */ @Override public int hashCode() { - return Objects.hash(getReportedHTTPCode(), - getReportingClassName(), - getReportingActionDescription(), - getErrorMessage(), - getReportedSystemAction(), - getReportedUserAction(), - getRelatedProperties(), - getReportedCaughtException()); + int result = Objects.hash(reportedHTTPCode, reportingClassName, reportingActionDescription, reportedErrorMessage, reportedErrorMessageId, + reportedSystemAction, reportedUserAction, reportedCaughtException, relatedProperties); + result = 31 * result + Arrays.hashCode(reportedErrorMessageParameters); + return result; } + /** + * Standard toString method. + * + * @return print out of variables in a JSON-style + */ + @Override + public String toString() + { + return "ConformanceSuiteRuntimeException{" + + "reportedHTTPCode=" + reportedHTTPCode + + ", reportingClassName='" + reportingClassName + '\'' + + ", reportingActionDescription='" + reportingActionDescription + '\'' + + ", reportedErrorMessage='" + reportedErrorMessage + '\'' + + ", reportedErrorMessageId='" + reportedErrorMessageId + '\'' + + ", reportedErrorMessageParameters=" + Arrays.toString(reportedErrorMessageParameters) + + ", reportedSystemAction='" + reportedSystemAction + '\'' + + ", reportedUserAction='" + reportedUserAction + '\'' + + ", reportedCaughtException=" + reportedCaughtException + + ", reportedCaughtExceptionClassName='" + reportedCaughtExceptionClassName + '\'' + + ", relatedProperties=" + relatedProperties + + '}'; + } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/InvalidParameterException.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/InvalidParameterException.java deleted file mode 100644 index 881da57fd52..00000000000 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/InvalidParameterException.java +++ /dev/null @@ -1,136 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.conformance.ffdc.exception; - -import java.util.Objects; - -/** - * The InvalidParameterException is thrown by the conformance suite when a parameter is null or an invalid value. - */ -public class InvalidParameterException extends ConformanceSuiteCheckedExceptionBase -{ - private static final long serialVersionUID = 1L; - - private String parameterName; - - /** - * This is the typical constructor used for creating an exception. - * - * @param httpCode http response code to use if this exception flows over a rest call - * @param className name of class reporting error - * @param actionDescription description of function it was performing when error detected - * @param errorMessage description of error - * @param systemAction actions of the system as a result of the error - * @param userAction instructions for correcting the error - * @param parameterName name of the invalid parameter if known - */ - public InvalidParameterException(int httpCode, - String className, - String actionDescription, - String errorMessage, - String systemAction, - String userAction, - String parameterName) - { - super(httpCode, className, actionDescription, errorMessage, systemAction, userAction); - - this.parameterName = parameterName; - } - - - /** - * This is the constructor used for creating an exception that resulted from a previous error. - * - * @param httpCode http response code to use if this exception flows over a rest call - * @param className name of class reporting error - * @param actionDescription description of function it was performing when error detected - * @param errorMessage description of error - * @param systemAction actions of the system as a result of the error - * @param userAction instructions for correcting the error - * @param caughtError the error that resulted in this exception. - * @param parameterName name of the invalid parameter if known - */ - public InvalidParameterException(int httpCode, - String className, - String actionDescription, - String errorMessage, - String systemAction, - String userAction, - Exception caughtError, - String parameterName) - { - super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError); - - this.parameterName = parameterName; - } - - - /** - * Return the invalid parameter's name, if known. - * - * @return string name - */ - public String getParameterName() - { - return parameterName; - } - - - /** - * JSON-style toString - * - * @return string of property names and values for this enum - */ - @Override - public String toString() - { - return "InvalidParameterException{" + - "parameterName='" + parameterName + '\'' + - ", reportedHTTPCode=" + getReportedHTTPCode() + - ", reportingClassName='" + getReportingClassName() + '\'' + - ", reportingActionDescription='" + getReportingActionDescription() + '\'' + - ", errorMessage='" + getErrorMessage() + '\'' + - ", reportedSystemAction='" + getReportedSystemAction() + '\'' + - ", reportedUserAction='" + getReportedUserAction() + '\'' + - ", reportedCaughtException=" + getReportedCaughtException() + - '}'; - } - - - /** - * Return comparison result based on the content of the properties. - * - * @param objectToCompare test object - * @return result of comparison - */ - @Override - public boolean equals(Object objectToCompare) - { - if (this == objectToCompare) - { - return true; - } - if (!(objectToCompare instanceof InvalidParameterException)) - { - return false; - } - if (!super.equals(objectToCompare)) - { - return false; - } - InvalidParameterException that = (InvalidParameterException) objectToCompare; - return Objects.equals(getParameterName(), that.getParameterName()); - } - - - /** - * Return hash code for this object - * - * @return int hash code - */ - @Override - public int hashCode() - { - return Objects.hash(super.hashCode(), getParameterName()); - } -} diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/PropertyServerException.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/PropertyServerException.java deleted file mode 100644 index 0030c4273cb..00000000000 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/PropertyServerException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.conformance.ffdc.exception; - -/** - * The PropertyServerException is thrown by the conformance suite when it is not able to communicate with the - * property server. - */ -public class PropertyServerException extends ConformanceSuiteCheckedExceptionBase -{ - private static final long serialVersionUID = 1L; - - /** - * This is the typical constructor used for creating an exception. - * - * @param httpCode http response code to use if this exception flows over a rest call - * @param className name of class reporting error - * @param actionDescription description of function it was performing when error detected - * @param errorMessage description of error - * @param systemAction actions of the system as a result of the error - * @param userAction instructions for correcting the error - */ - public PropertyServerException(int httpCode, - String className, - String actionDescription, - String errorMessage, - String systemAction, - String userAction) - { - super(httpCode, className, actionDescription, errorMessage, systemAction, userAction); - } - - - /** - * This is the constructor used for creating an exception that resulted from a previous error. - * - * @param httpCode http response code to use if this exception flows over a rest call - * @param className name of class reporting error - * @param actionDescription description of function it was performing when error detected - * @param errorMessage description of error - * @param systemAction actions of the system as a result of the error - * @param userAction instructions for correcting the error - * @param caughtError the error that resulted in this exception. - * */ - public PropertyServerException(int httpCode, - String className, - String actionDescription, - String errorMessage, - String systemAction, - String userAction, - Exception caughtError) - { - super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError); - } - - - /** - * JSON-style toString - * - * @return string of property names and values for this enum - */ - @Override - public String toString() - { - return "PropertyServerException{" + - "reportedHTTPCode=" + getReportedHTTPCode() + - ", reportingClassName='" + getReportingClassName() + '\'' + - ", reportingActionDescription='" + getReportingActionDescription() + '\'' + - ", errorMessage='" + getErrorMessage() + '\'' + - ", reportedSystemAction='" + getReportedSystemAction() + '\'' + - ", reportedUserAction='" + getReportedUserAction() + '\'' + - ", reportedCaughtException=" + getReportedCaughtException() + - '}'; - } -} diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/UserNotAuthorizedException.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/UserNotAuthorizedException.java deleted file mode 100644 index 45cb39b58b2..00000000000 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-api/src/main/java/org/odpi/openmetadata/conformance/ffdc/exception/UserNotAuthorizedException.java +++ /dev/null @@ -1,138 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.conformance.ffdc.exception; - - -import java.util.Objects; - -/** - * The UserNotAuthorizedException is thrown by the conformance suite when a userId passed on a request is not - * authorized to perform the requested action. - */ -public class UserNotAuthorizedException extends ConformanceSuiteCheckedExceptionBase -{ - private static final long serialVersionUID = 1L; - - private String userId; - - /** - * This is the typical constructor used for creating an exception. - * - * @param httpCode http response code to use if this exception flows over a rest call - * @param className name of class reporting error - * @param actionDescription description of function it was performing when error detected - * @param errorMessage description of error - * @param systemAction actions of the system as a result of the error - * @param userAction instructions for correcting the error - * @param userId calling user - */ - public UserNotAuthorizedException(int httpCode, - String className, - String actionDescription, - String errorMessage, - String systemAction, - String userAction, - String userId) - { - super(httpCode, className, actionDescription, errorMessage, systemAction, userAction); - - this.userId = userId; - } - - - /** - * This is the constructor used for creating an exception that resulted from a previous error. - * - * @param httpCode http response code to use if this exception flows over a rest call - * @param className name of class reporting error - * @param actionDescription description of function it was performing when error detected - * @param errorMessage description of error - * @param systemAction actions of the system as a result of the error - * @param userAction instructions for correcting the error - * @param caughtError the error that resulted in this exception. - * @param userId calling user - */ - public UserNotAuthorizedException(int httpCode, - String className, - String actionDescription, - String errorMessage, - String systemAction, - String userAction, - Exception caughtError, - String userId) - { - super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError); - - this.userId = userId; - } - - - /** - * Return the userId passed on the request. - * - * @return string user id - */ - public String getUserId() - { - return userId; - } - - - /** - * JSON-style toString - * - * @return string of property names and values for this enum - */ - @Override - public String toString() - { - return "UserNotAuthorizedException{" + - "userId='" + userId + '\'' + - ", reportedHTTPCode=" + getReportedHTTPCode() + - ", reportingClassName='" + getReportingClassName() + '\'' + - ", reportingActionDescription='" + getReportingActionDescription() + '\'' + - ", errorMessage='" + getErrorMessage() + '\'' + - ", reportedSystemAction='" + getReportedSystemAction() + '\'' + - ", reportedUserAction='" + getReportedUserAction() + '\'' + - ", reportedCaughtException=" + getReportedCaughtException() + - '}'; - } - - - /** - * Return comparison result based on the content of the properties. - * - * @param objectToCompare test object - * @return result of comparison - */ - @Override - public boolean equals(Object objectToCompare) - { - if (this == objectToCompare) - { - return true; - } - if (!(objectToCompare instanceof UserNotAuthorizedException)) - { - return false; - } - if (!super.equals(objectToCompare)) - { - return false; - } - UserNotAuthorizedException that = (UserNotAuthorizedException) objectToCompare; - return Objects.equals(getUserId(), that.getUserId()); - } - - - /** - * Return hash code for this object - * - * @return int hash code - */ - @Override - public int hashCode() - { - return Objects.hash(super.hashCode(), getUserId()); - } -} diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/build.gradle b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/build.gradle index c491b376b40..de822e9c12b 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/build.gradle +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/build.gradle @@ -12,6 +12,7 @@ dependencies { implementation project(':open-metadata-conformance-suite:open-metadata-conformance-suite-api') implementation project(':open-metadata-implementation:adapters:open-connectors:rest-client-connectors:rest-client-connectors-api') implementation project(':open-metadata-implementation:adapters:open-connectors:rest-client-connectors:rest-client-factory') + compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework') compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework') implementation project(':open-metadata-implementation:adapters:authentication-plugins:http-helper') implementation 'com.fasterxml.jackson.core:jackson-databind' diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/OpenMetadataConformanceTestReport.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/OpenMetadataConformanceTestReport.java index 1c458b85617..b1cc1b5c68c 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/OpenMetadataConformanceTestReport.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/OpenMetadataConformanceTestReport.java @@ -8,10 +8,10 @@ import org.odpi.openmetadata.adapters.connectors.restclients.ffdc.exceptions.RESTConfigurationException; import org.odpi.openmetadata.adapters.connectors.restclients.ffdc.exceptions.RESTServerException; import org.odpi.openmetadata.conformance.beans.*; -import org.odpi.openmetadata.conformance.ffdc.exception.InvalidParameterException; -import org.odpi.openmetadata.conformance.ffdc.exception.PropertyServerException; -import org.odpi.openmetadata.conformance.ffdc.exception.UserNotAuthorizedException; import org.odpi.openmetadata.conformance.rest.*; +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.http.HttpHelper; import java.io.File; @@ -29,12 +29,12 @@ public class OpenMetadataConformanceTestReport private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT); private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writer(); - private String serverName; /* Initialized in constructor */ - private String serverURLRoot; /* Initialized in constructor */ - private String testClientUserId; /* Initialized in constructor */ - private RESTClient restClient; /* Initialized in constructor */ + private final String serverName; /* Initialized in constructor */ + private final String serverURLRoot; /* Initialized in constructor */ + private final String testClientUserId; /* Initialized in constructor */ + private final RESTClient restClient; /* Initialized in constructor */ - private RESTExceptionHandler exceptionHandler = new RESTExceptionHandler(); + private final RESTExceptionHandler exceptionHandler = new RESTExceptionHandler(); /** * Constructor to create a test lab object that is initialized with the server to test. @@ -81,14 +81,14 @@ private OpenMetadataConformanceTestReport(String serverName, /** * Request each registered workbench runs its tests. * - * @return combined results from all of the workbenches. + * @return combined results from all the workbenches. * @throws InvalidParameterException the server to test is not a member of the cohort. * @throws PropertyServerException the conformance test server is not reachable. * @throws UserNotAuthorizedException the test user is not authorized to run the tests. */ private OpenMetadataConformanceTestLabSummary getConformanceSummary() throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + PropertyServerException, + UserNotAuthorizedException { final String methodName = "getConformanceSummary"; final String urlTemplate = "/servers/{0}/open-metadata/conformance-suite/users/{1}/report/summary"; @@ -96,9 +96,9 @@ private OpenMetadataConformanceTestLabSummary getConformanceSummary() throws Inv try { TestLabSummaryResponse restResult = restClient.callSummaryGetRESTCall(methodName, - serverURLRoot + urlTemplate, - serverName, - testClientUserId); + serverURLRoot + urlTemplate, + serverName, + testClientUserId); exceptionHandler.detectAndThrowInvalidParameterException(methodName, restResult); exceptionHandler.detectAndThrowUserNotAuthorizedException(methodName, restResult); @@ -109,12 +109,15 @@ private OpenMetadataConformanceTestLabSummary getConformanceSummary() throws Inv catch (RESTServerException error) { throw new PropertyServerException(error.getReportedHTTPCode(), - error.getReportingClassName(), - error.getReportingActionDescription(), - error.getErrorMessage(), - error.getReportedSystemAction(), - error.getReportedUserAction(), - error); + error.getReportingClassName(), + error.getReportingActionDescription(), + error.getErrorMessage(), + null, + null, + error.getReportedSystemAction(), + error.getReportedUserAction(), + error.getClass().getName(), + null); } } @@ -128,8 +131,8 @@ private OpenMetadataConformanceTestLabSummary getConformanceSummary() throws Inv * @throws UserNotAuthorizedException the test user is not authorized to run the tests. */ private List getProfileNames() throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + PropertyServerException, + UserNotAuthorizedException { final String methodName = "getProfileNames"; final String urlTemplate = "/servers/{0}/open-metadata/conformance-suite/users/{1}/report/profiles"; @@ -137,9 +140,9 @@ private List getProfileNames() throws InvalidParameterException, try { ProfileNameListResponse restResult = restClient.callProfilesListREST(methodName, - serverURLRoot + urlTemplate, - serverName, - testClientUserId); + serverURLRoot + urlTemplate, + serverName, + testClientUserId); exceptionHandler.detectAndThrowInvalidParameterException(methodName, restResult); exceptionHandler.detectAndThrowUserNotAuthorizedException(methodName, restResult); @@ -150,12 +153,15 @@ private List getProfileNames() throws InvalidParameterException, catch (RESTServerException error) { throw new PropertyServerException(error.getReportedHTTPCode(), - error.getReportingClassName(), - error.getReportingActionDescription(), - error.getErrorMessage(), - error.getReportedSystemAction(), - error.getReportedUserAction(), - error); + error.getReportingClassName(), + error.getReportingActionDescription(), + error.getErrorMessage(), + null, + null, + error.getReportedSystemAction(), + error.getReportedUserAction(), + error.getClass().getName(), + null); } } @@ -170,8 +176,8 @@ private List getProfileNames() throws InvalidParameterException, * @throws UserNotAuthorizedException the test user is not authorized to run the tests. */ private OpenMetadataConformanceProfileResults getProfile(String name) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + PropertyServerException, + UserNotAuthorizedException { final String methodName = "getProfile"; final String urlTemplate = "/servers/{0}/open-metadata/conformance-suite/users/{1}/report/profiles/{2}"; @@ -179,10 +185,10 @@ private OpenMetadataConformanceProfileResults getProfile(String name) throws Inv try { ProfileReportResponse restResult = restClient.callProfileGetREST(methodName, - serverURLRoot + urlTemplate, - serverName, - testClientUserId, - name); + serverURLRoot + urlTemplate, + serverName, + testClientUserId, + name); exceptionHandler.detectAndThrowInvalidParameterException(methodName, restResult); exceptionHandler.detectAndThrowUserNotAuthorizedException(methodName, restResult); @@ -193,12 +199,15 @@ private OpenMetadataConformanceProfileResults getProfile(String name) throws Inv catch (RESTServerException error) { throw new PropertyServerException(error.getReportedHTTPCode(), - error.getReportingClassName(), - error.getReportingActionDescription(), - error.getErrorMessage(), - error.getReportedSystemAction(), - error.getReportedUserAction(), - error); + error.getReportingClassName(), + error.getReportingActionDescription(), + error.getErrorMessage(), + null, + null, + error.getReportedSystemAction(), + error.getReportedUserAction(), + error.getClass().getName(), + null); } } @@ -212,8 +221,8 @@ private OpenMetadataConformanceProfileResults getProfile(String name) throws Inv * @throws UserNotAuthorizedException the test user is not authorized to run the tests. */ private List getTestCaseIds() throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + PropertyServerException, + UserNotAuthorizedException { final String methodName = "getTestCaseIds"; final String urlTemplate = "/servers/{0}/open-metadata/conformance-suite/users/{1}/report/test-cases"; @@ -221,9 +230,9 @@ private List getTestCaseIds() throws InvalidParameterException, try { TestCaseListResponse restResult = restClient.callTestCasesListREST(methodName, - serverURLRoot + urlTemplate, - serverName, - testClientUserId); + serverURLRoot + urlTemplate, + serverName, + testClientUserId); exceptionHandler.detectAndThrowInvalidParameterException(methodName, restResult); exceptionHandler.detectAndThrowUserNotAuthorizedException(methodName, restResult); @@ -234,12 +243,15 @@ private List getTestCaseIds() throws InvalidParameterException, catch (RESTServerException error) { throw new PropertyServerException(error.getReportedHTTPCode(), - error.getReportingClassName(), - error.getReportingActionDescription(), - error.getErrorMessage(), - error.getReportedSystemAction(), - error.getReportedUserAction(), - error); + error.getReportingClassName(), + error.getReportingActionDescription(), + error.getErrorMessage(), + null, + null, + error.getReportedSystemAction(), + error.getReportedUserAction(), + error.getClass().getName(), + null); } } @@ -254,8 +266,8 @@ private List getTestCaseIds() throws InvalidParameterException, * @throws UserNotAuthorizedException the test user is not authorized to run the tests. */ private OpenMetadataTestCaseResult getTestCase(String id) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + PropertyServerException, + UserNotAuthorizedException { final String methodName = "getTestCase"; final String urlTemplate = "/servers/{0}/open-metadata/conformance-suite/users/{1}/report/test-cases/{2}"; @@ -263,10 +275,10 @@ private OpenMetadataTestCaseResult getTestCase(String id) throws InvalidParamete try { TestCaseReportResponse restResult = restClient.callTestCaseGetREST(methodName, - serverURLRoot + urlTemplate, - serverName, - testClientUserId, - id); + serverURLRoot + urlTemplate, + serverName, + testClientUserId, + id); exceptionHandler.detectAndThrowInvalidParameterException(methodName, restResult); exceptionHandler.detectAndThrowUserNotAuthorizedException(methodName, restResult); @@ -277,12 +289,15 @@ private OpenMetadataTestCaseResult getTestCase(String id) throws InvalidParamete catch (RESTServerException error) { throw new PropertyServerException(error.getReportedHTTPCode(), - error.getReportingClassName(), - error.getReportingActionDescription(), - error.getErrorMessage(), - error.getReportedSystemAction(), - error.getReportedUserAction(), - error); + error.getReportingClassName(), + error.getReportingActionDescription(), + error.getErrorMessage(), + null, + null, + error.getReportedSystemAction(), + error.getReportedUserAction(), + error.getClass().getName(), + null); } } @@ -370,19 +385,19 @@ public static void main(String[] args) catch (InvalidParameterException error) { System.out.println("The server " + serverName + " is not a conformance suite server"); - System.out.println("Returned error message is " + error.getErrorMessage() + "."); + System.out.println("Returned error message is " + error.getReportedErrorMessage() + "."); System.out.println(); } catch (PropertyServerException error) { System.out.println("The OMAG server platform at " + serverURLRoot + " is not contactable or the conformance suite server " + serverName + " has not been started."); - System.out.println("Returned error message is " + error.getErrorMessage() + "."); + System.out.println("Returned error message is " + error.getReportedErrorMessage() + "."); System.out.println(); } catch (UserNotAuthorizedException error) { System.out.println("The userId " + userId + " is not authorized to call the conformance suite tests."); - System.out.println("Returned error message is " + error.getErrorMessage() + "."); + System.out.println("Returned error message is " + error.getReportedErrorMessage() + "."); System.out.println(); } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTClient.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTClient.java index 7c38b15a0be..21be9e2c67b 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTClient.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTClient.java @@ -9,6 +9,8 @@ import org.odpi.openmetadata.adapters.connectors.restclients.factory.RESTClientFactory; import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteErrorCode; import org.odpi.openmetadata.conformance.rest.*; +import org.odpi.openmetadata.frameworks.auditlog.MessageFormatter; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition; /** @@ -16,7 +18,9 @@ */ class RESTClient { - private RESTClientConnector clientConnector; /* Initialized in constructor */ + private static final MessageFormatter messageFormatter = new MessageFormatter(); + + private final RESTClientConnector clientConnector; /* Initialized in constructor */ /** @@ -40,16 +44,16 @@ class RESTClient } catch (Exception error) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NULL_LOCAL_SERVER_NAME; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(serverName, error.getMessage()); + ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NULL_LOCAL_SERVER_NAME; + ExceptionMessageDefinition messageDefinition = errorCode.getMessageDefinition(serverName, error.getMessage()); - throw new RESTConfigurationException(errorCode.getHTTPErrorCode(), + throw new RESTConfigurationException(messageDefinition.getHttpErrorCode(), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), + messageFormatter.getFormattedMessage(messageDefinition), + messageDefinition.getSystemAction(), + messageDefinition.getUserAction(), error); } } @@ -83,16 +87,15 @@ class RESTClient } catch (Exception error) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NULL_LOCAL_SERVER_NAME; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(serverName, error.getMessage()); - + ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NULL_LOCAL_SERVER_NAME; + ExceptionMessageDefinition messageDefinition = errorCode.getMessageDefinition(serverName, error.getMessage()); - throw new RESTConfigurationException(errorCode.getHTTPErrorCode(), + throw new RESTConfigurationException(messageDefinition.getHttpErrorCode(), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), + messageFormatter.getFormattedMessage(messageDefinition), + messageDefinition.getSystemAction(), + messageDefinition.getUserAction(), error); } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTExceptionHandler.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTExceptionHandler.java index 680bffd420a..ec59d17e9e6 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTExceptionHandler.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-client/src/main/java/org/odpi/openmetadata/conformance/client/RESTExceptionHandler.java @@ -2,10 +2,10 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.client; -import org.odpi.openmetadata.conformance.ffdc.exception.InvalidParameterException; -import org.odpi.openmetadata.conformance.ffdc.exception.PropertyServerException; -import org.odpi.openmetadata.conformance.ffdc.exception.UserNotAuthorizedException; import org.odpi.openmetadata.conformance.rest.ConformanceServicesAPIResponse; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import java.util.Map; @@ -81,8 +81,12 @@ void detectAndThrowPropertyServerException(String method this.getClass().getName(), methodName, restResult.getExceptionErrorMessage(), + null, + null, restResult.getExceptionSystemAction(), - restResult.getExceptionUserAction()); + restResult.getExceptionUserAction(), + null, + null); } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteOperationalServices.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteOperationalServices.java index 4dca1b28821..af870e3fbb4 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteOperationalServices.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteOperationalServices.java @@ -78,56 +78,22 @@ public void initialize(ConformanceSuiteConfig conformanceSuiteConfig, if (enterpriseTopicConnector == null) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NO_ENTERPRISE_TOPIC; - String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(localServerName); - String[] errorMessageParameters = { localServerName }; - - throw new OMAGConfigurationErrorException(errorCode.getHTTPErrorCode(), + throw new OMAGConfigurationErrorException(ConformanceSuiteErrorCode.NO_ENTERPRISE_TOPIC.getMessageDefinition(localServerName), this.getClass().getName(), - methodName, - errorMessage, - errorCode.getErrorMessageId(), - errorMessageParameters, - errorCode.getSystemAction(), - errorCode.getUserAction(), - null, - null); + methodName); } if (enterpriseConnectorManager == null) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NO_ENTERPRISE_CONNECTOR_MANAGER; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(localServerName); - String[] errorMessageParameters = { localServerName }; - - throw new OMAGConfigurationErrorException(errorCode.getHTTPErrorCode(), + throw new OMAGConfigurationErrorException(ConformanceSuiteErrorCode.NO_ENTERPRISE_CONNECTOR_MANAGER.getMessageDefinition(localServerName), this.getClass().getName(), - methodName, - errorMessage, - errorCode.getErrorMessageId(), - errorMessageParameters, - errorCode.getSystemAction(), - errorCode.getUserAction(), - null, - null); + methodName); } else if (! enterpriseConnectorManager.isEnterpriseAccessEnabled()) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NO_ENTERPRISE_ACCESS; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(localServerName); - String[] errorMessageParameters = { localServerName }; - - throw new OMAGConfigurationErrorException(errorCode.getHTTPErrorCode(), + throw new OMAGConfigurationErrorException(ConformanceSuiteErrorCode.NO_ENTERPRISE_ACCESS.getMessageDefinition(localServerName), this.getClass().getName(), - methodName, - errorMessage, - errorCode.getErrorMessageId(), - errorMessageParameters, - errorCode.getSystemAction(), - errorCode.getUserAction(), - null, - null); + methodName); } /* diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteTestLabServices.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteTestLabServices.java index 8ccafb365e4..37db0127633 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteTestLabServices.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/server/ConformanceSuiteTestLabServices.java @@ -3,18 +3,20 @@ package org.odpi.openmetadata.conformance.server; import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteErrorCode; -import org.odpi.openmetadata.conformance.ffdc.exception.ConformanceSuiteCheckedExceptionBase; -import org.odpi.openmetadata.conformance.ffdc.exception.InvalidParameterException; -import org.odpi.openmetadata.conformance.ffdc.exception.PropertyServerException; import org.odpi.openmetadata.conformance.rest.*; import org.odpi.openmetadata.conformance.beans.TechnologyUnderTestWorkPad; +import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; +import org.odpi.openmetadata.frameworks.connectors.ffdc.OCFCheckedExceptionBase; +import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.Map; - +/** + * ConformanceSuiteTestLabServices supports the REST API for the CTS. + */ public class ConformanceSuiteTestLabServices { private static final ConformanceServicesInstanceMap instanceMap = new ConformanceServicesInstanceMap(); @@ -87,16 +89,16 @@ public ProfileReportResponse getProfileReport(String userId, TechnologyUnderTestWorkPad workPad = getWorkPad(serverName, methodName); response.setProfileResult(workPad.getProfileReport(profileName)); } - catch (PropertyServerException error) + catch (PropertyServerException error) { capturePropertyServerException(response, error); } - catch (InvalidParameterException error) + catch (InvalidParameterException error) { captureInvalidParameterException(response, error); } - log.debug("Returning from method: " + methodName + " with response: " + response.toString()); + log.debug("Returning from method: " + methodName + " with response: " + response); return response; } @@ -393,16 +395,9 @@ private void validateUserId(String userId, String methodName) throws InvalidPara { if (userId == null) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NULL_USER_ID; - String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(methodName); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + throw new InvalidParameterException(ConformanceSuiteErrorCode.NULL_USER_ID.getMessageDefinition(methodName), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), "userId"); } } @@ -430,15 +425,9 @@ private TechnologyUnderTestWorkPad getWorkPad(String serverName, } else { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.SERVICE_NOT_INITIALIZED; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(serverName, methodName); - - throw new PropertyServerException(errorCode.getHTTPErrorCode(), + throw new PropertyServerException(ConformanceSuiteErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(serverName, methodName), this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); + methodName); } } @@ -463,15 +452,9 @@ private ConformanceServicesInstance validateServerName(String serverName, */ if (serverName == null) { - ConformanceSuiteErrorCode errorCode = ConformanceSuiteErrorCode.NULL_LOCAL_SERVER_NAME; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); - - throw new InvalidParameterException(errorCode.getHTTPErrorCode(), + throw new InvalidParameterException(ConformanceSuiteErrorCode.NULL_LOCAL_SERVER_NAME.getMessageDefinition(), this.getClass().getName(), methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction(), serverNameParameter); } else @@ -489,12 +472,12 @@ private ConformanceServicesInstance validateServerName(String serverName, * @param exceptionClassName class name of the exception to recreate */ private void captureCheckedException(ConformanceServicesAPIResponse response, - ConformanceSuiteCheckedExceptionBase error, + OCFCheckedExceptionBase error, String exceptionClassName) { response.setRelatedHTTPCode(error.getReportedHTTPCode()); response.setExceptionClassName(exceptionClassName); - response.setExceptionErrorMessage(error.getErrorMessage()); + response.setExceptionErrorMessage(error.getReportedErrorMessage()); response.setExceptionSystemAction(error.getReportedSystemAction()); response.setExceptionUserAction(error.getReportedUserAction()); } @@ -509,13 +492,13 @@ private void captureCheckedException(ConformanceServicesAPIResponse respon * @param exceptionProperties map of properties stored in the exception to help with diagnostics */ private void captureCheckedException(ConformanceServicesAPIResponse response, - ConformanceSuiteCheckedExceptionBase error, + OCFCheckedExceptionBase error, String exceptionClassName, Map exceptionProperties) { response.setRelatedHTTPCode(error.getReportedHTTPCode()); response.setExceptionClassName(exceptionClassName); - response.setExceptionErrorMessage(error.getErrorMessage()); + response.setExceptionErrorMessage(error.getReportedErrorMessage()); response.setExceptionSystemAction(error.getReportedSystemAction()); response.setExceptionUserAction(error.getReportedUserAction()); response.setExceptionProperties(exceptionProperties); diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/performance/OpenMetadataPerformanceTestCase.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/performance/OpenMetadataPerformanceTestCase.java index b097553b424..1c109dc01ff 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/performance/OpenMetadataPerformanceTestCase.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/performance/OpenMetadataPerformanceTestCase.java @@ -2,11 +2,11 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.performance; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase; import org.odpi.openmetadata.conformance.workbenches.performance.PerformanceWorkPad; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue; @@ -90,17 +90,11 @@ protected void logTestStart(String methodName) { if (workPad != null) { - OMRSAuditLog auditLog = performanceWorkPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_INITIALIZING; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - testCaseDescriptionURL), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = performanceWorkPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_INITIALIZING.getMessageDefinition(testCaseId, + testCaseDescriptionURL)); } } @@ -114,7 +108,7 @@ protected void logTestEnd(String methodName) { if (workPad != null) { - Integer exceptionCount; + int exceptionCount; if (exceptionBean == null) { @@ -125,38 +119,26 @@ protected void logTestEnd(String methodName) exceptionCount = 1; } - OMRSAuditLog auditLog = performanceWorkPad.getAuditLog(); + AuditLog auditLog = performanceWorkPad.getAuditLog(); if (successMessage == null) { - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_COMPLETED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - Integer.toString(successfulAssertions.size()), - Integer.toString(unsuccessfulAssertions.size()), - Integer.toString(exceptionCount), - Integer.toString(discoveredProperties.size())), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_COMPLETED.getMessageDefinition(testCaseId, + Integer.toString(successfulAssertions.size()), + Integer.toString(unsuccessfulAssertions.size()), + Integer.toString(exceptionCount), + Integer.toString(discoveredProperties.size()))); } else { - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_COMPLETED_SUCCESSFULLY; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - Integer.toString(successfulAssertions.size()), - Integer.toString(unsuccessfulAssertions.size()), - Integer.toString(exceptionCount), - Integer.toString(discoveredProperties.size()), - successMessage), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_COMPLETED_SUCCESSFULLY.getMessageDefinition(testCaseId, + Integer.toString(successfulAssertions.size()), + Integer.toString(unsuccessfulAssertions.size()), + Integer.toString(exceptionCount), + Integer.toString(discoveredProperties.size()), + successMessage)); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/platform/OpenMetadataPlatformTestCase.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/platform/OpenMetadataPlatformTestCase.java index 2eceb3ecb05..2b16af44219 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/platform/OpenMetadataPlatformTestCase.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/platform/OpenMetadataPlatformTestCase.java @@ -2,10 +2,11 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.platform; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase; import org.odpi.openmetadata.conformance.workbenches.platform.PlatformConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.platform.PlatformConformanceWorkPad; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; /** @@ -46,17 +47,11 @@ protected void logTestStart(String methodName) { if (workPad != null) { - OMRSAuditLog auditLog = platformConformanceWorkPad.getAuditLog(); + AuditLog auditLog = platformConformanceWorkPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_INITIALIZING; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - testCaseDescriptionURL), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_INITIALIZING.getMessageDefinition(testCaseId, + testCaseDescriptionURL)); } } @@ -70,7 +65,7 @@ protected void logTestEnd(String methodName) { if (workPad != null) { - Integer exceptionCount; + int exceptionCount; if (exceptionBean == null) { @@ -81,38 +76,26 @@ protected void logTestEnd(String methodName) exceptionCount = 1; } - OMRSAuditLog auditLog = platformConformanceWorkPad.getAuditLog(); + AuditLog auditLog = platformConformanceWorkPad.getAuditLog(); if (successMessage == null) { - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_COMPLETED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - Integer.toString(successfulAssertions.size()), - Integer.toString(unsuccessfulAssertions.size()), - Integer.toString(exceptionCount), - Integer.toString(discoveredProperties.size())), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_COMPLETED.getMessageDefinition(testCaseId, + Integer.toString(successfulAssertions.size()), + Integer.toString(unsuccessfulAssertions.size()), + Integer.toString(exceptionCount), + Integer.toString(discoveredProperties.size()))); } else { - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_COMPLETED_SUCCESSFULLY; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - Integer.toString(successfulAssertions.size()), - Integer.toString(unsuccessfulAssertions.size()), - Integer.toString(exceptionCount), - Integer.toString(discoveredProperties.size()), - successMessage), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_COMPLETED_SUCCESSFULLY.getMessageDefinition(testCaseId, + Integer.toString(successfulAssertions.size()), + Integer.toString(unsuccessfulAssertions.size()), + Integer.toString(exceptionCount), + Integer.toString(discoveredProperties.size()), + successMessage)); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java index 4f331f1e015..6c308d4d743 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/RepositoryConformanceTestCase.java @@ -2,11 +2,11 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy; @@ -99,17 +99,11 @@ protected void logTestStart(String methodName) { if (workPad != null) { - OMRSAuditLog auditLog = repositoryConformanceWorkPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_INITIALIZING; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - testCaseDescriptionURL), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = repositoryConformanceWorkPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_INITIALIZING.getMessageDefinition(testCaseId, + testCaseDescriptionURL)); } } @@ -123,7 +117,7 @@ protected void logTestEnd(String methodName) { if (workPad != null) { - Integer exceptionCount; + int exceptionCount; if (exceptionBean == null) { @@ -134,38 +128,26 @@ protected void logTestEnd(String methodName) exceptionCount = 1; } - OMRSAuditLog auditLog = repositoryConformanceWorkPad.getAuditLog(); + AuditLog auditLog = repositoryConformanceWorkPad.getAuditLog(); if (successMessage == null) { - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_COMPLETED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - Integer.toString(successfulAssertions.size()), - Integer.toString(unsuccessfulAssertions.size()), - Integer.toString(exceptionCount), - Integer.toString(discoveredProperties.size())), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_COMPLETED.getMessageDefinition(testCaseId, + Integer.toString(successfulAssertions.size()), + Integer.toString(unsuccessfulAssertions.size()), + Integer.toString(exceptionCount), + Integer.toString(discoveredProperties.size()))); } else { - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TEST_CASE_COMPLETED_SUCCESSFULLY; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(testCaseId, - Integer.toString(successfulAssertions.size()), - Integer.toString(unsuccessfulAssertions.size()), - Integer.toString(exceptionCount), - Integer.toString(discoveredProperties.size()), - successMessage), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TEST_CASE_COMPLETED_SUCCESSFULLY.getMessageDefinition(testCaseId, + Integer.toString(successfulAssertions.size()), + Integer.toString(unsuccessfulAssertions.size()), + Integer.toString(exceptionCount), + Integer.toString(discoveredProperties.size()), + successMessage)); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java index 2ab3ea9173c..e0678f1c9f0 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestClassificationHasSupportedEntities.java @@ -93,15 +93,6 @@ protected void run() throws Exception testTypeName + assertionMsg2 + classificationDef.getName(), RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getProfileId(), RepositoryConformanceProfileRequirement.CONSISTENT_TYPES.getRequirementId()); - - } - else - { - super.addNotSupportedAssertion(assertion2, - testTypeName + assertionMsg2 + classificationDef.getName(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getProfileId(), - RepositoryConformanceProfileRequirement.ENTITY_LIFECYCLE.getRequirementId()); - } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java index bb47abcf61d..4745ba65dce 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityProxyLifecycle.java @@ -2,7 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; @@ -353,27 +353,26 @@ protected void run() throws Exception * Retrieve the ref copy from the TUT - if it does not exist, assert that ref copies are not a discovered property * Have to be prepared to wait until event has propagated and TUT has created a reference copy of the entity. */ - try { + try + { Integer remainingCount = this.pollCount; - while (entity1Ref == null && remainingCount > 0) { + while (entity1Ref == null && remainingCount > 0) + { entity1Ref = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), entity1.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } - if (entity1Ref == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + if (entity1Ref == null && remainingCount == 0) + { workPad.getAuditLog() - .logRecord(assertion2, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion2, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -394,7 +393,8 @@ protected void run() throws Exception * This test needs to eliminate the reference copy - so that a proxy of E1 can be created at the TUT. */ - if (entity1Ref != null) { + if (entity1Ref != null) + { /* * If we retrieved the reference copy of the entity - we must purge it. @@ -402,11 +402,14 @@ protected void run() throws Exception * If there is no reference copy it may be because the TUT does not support ref copies - that's OK, we can continue with the test of proxy support */ - try { + try + { metadataCollection.purgeEntityReferenceCopy(workPad.getLocalServerUserId(), entity1Ref); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any other exceptions from this method call. Log and fail the test. */ @@ -556,15 +559,9 @@ protected void run() throws Exception if (entity2Ref == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() - .logRecord(assertion2, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion2, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } } catch (Exception exc) @@ -1327,15 +1324,9 @@ protected void run() throws Exception if (entity1Ref == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() - .logRecord(assertion8, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion8, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } } catch (Exception exc) diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java index fb0a203f13b..9d76840ee1b 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedEntityReferenceCopyLifecycle.java @@ -2,7 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; @@ -266,15 +266,9 @@ protected void run() throws Exception } if (refEntity == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() - .logRecord(assertion1, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion1, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } } catch (Exception exc) @@ -830,18 +824,15 @@ protected void run() throws Exception Thread.sleep(this.pollPeriod); remainingCount--; } - if (refreshedEntityRefCopy == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + if (refreshedEntityRefCopy == null && remainingCount == 0) + { workPad.getAuditLog() - .logRecord(assertion12, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion12, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -951,16 +942,11 @@ protected void run() throws Exception Thread.sleep(this.pollPeriod); remainingCount--; } while (survivingEntRefCopy != null && remainingCount > 0); - if (survivingEntRefCopy == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + if (survivingEntRefCopy == null && remainingCount == 0) + { workPad.getAuditLog() - .logRecord(assertion14, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion14, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } } catch (Exception exc) diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java index aa11aa1f632..eeee4ee15f2 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/instances/TestSupportedRelationshipReferenceCopyLifecycle.java @@ -2,7 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.tests.repository.instances; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.ffdc.exception.AssertionFailureException; import org.odpi.openmetadata.conformance.tests.repository.RepositoryConformanceTestCase; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceProfileRequirement; @@ -374,27 +374,26 @@ protected void run() throws Exception EntityDetail refCopyEntityTwo = null; - try { + try + { Integer remainingCount = this.pollCount; - while (refCopyEntityOne == null && remainingCount > 0) { + while (refCopyEntityOne == null && remainingCount > 0) + { refCopyEntityOne = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), entityOne.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } - if (refCopyEntityOne == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + if (refCopyEntityOne == null && remainingCount == 0) + { workPad.getAuditLog() - .logRecord(assertion1 + "-" + entityOne.getGUID(), - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion1 + "-" + entityOne.getGUID(), + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } if (refCopyEntityOne != null) createdEntityRefCopiesTUT.add(refCopyEntityOne); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -410,28 +409,27 @@ protected void run() throws Exception } - try { + try + { Integer remainingCount = this.pollCount; - while (refCopyEntityTwo == null && remainingCount > 0) { + while (refCopyEntityTwo == null && remainingCount > 0) + { refCopyEntityTwo = metadataCollection.isEntityKnown(workPad.getLocalServerUserId(), entityTwo.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } - if (refCopyEntityTwo == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + if (refCopyEntityTwo == null && remainingCount == 0) + { workPad.getAuditLog() - .logRecord(assertion1 + "-" + entityTwo.getGUID(), - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion1 + "-" + entityTwo.getGUID(), + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } if (refCopyEntityTwo != null) createdEntityRefCopiesTUT.add(refCopyEntityTwo); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -454,27 +452,26 @@ protected void run() throws Exception Relationship refRelationship = null; - try { + try + { Integer remainingCount = this.pollCount; - while (refRelationship == null && remainingCount > 0) { + while (refRelationship == null && remainingCount > 0) + { refRelationship = metadataCollection.isRelationshipKnown(workPad.getLocalServerUserId(), newRelationship.getGUID()); Thread.sleep(this.pollPeriod); remainingCount--; } - if (refRelationship == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; + if (refRelationship == null && remainingCount == 0) + { workPad.getAuditLog() - .logRecord(assertion1 + "-" + newRelationship.getGUID(), - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion1 + "-" + newRelationship.getGUID(), + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } if (refRelationship != null) createdRelationshipRefCopiesTUT.add(refRelationship); - } catch (Exception exc) { + } + catch (Exception exc) + { /* * We are not expecting any exceptions from this method call. Log and fail the test. */ @@ -943,15 +940,9 @@ protected void run() throws Exception } if (refreshedRelationshipRefCopy == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() - .logRecord(assertion10, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion10, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } } catch (Exception exc) @@ -1067,15 +1058,9 @@ protected void run() throws Exception if (survivingRelRefCopy == null && remainingCount == 0) { - ConformanceSuiteAuditCode overflow = ConformanceSuiteAuditCode.POLLING_OVERFLOW; workPad.getAuditLog() - .logRecord(assertion12, - overflow.getLogMessageId(), - overflow.getSeverity(), - overflow.getFormattedLogMessage(pollCount.toString(), pollPeriod.toString()), - null, - overflow.getSystemAction(), - overflow.getUserAction()); + .logMessage(assertion12, + ConformanceSuiteAuditCode.POLLING_OVERFLOW.getMessageDefinition(pollCount.toString(), pollPeriod.toString())); } } catch (Exception exc) diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestFindTypeDefsByCategory.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestFindTypeDefsByCategory.java index 41f6250fff6..626a949465e 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestFindTypeDefsByCategory.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestFindTypeDefsByCategory.java @@ -32,10 +32,10 @@ public class TestFindTypeDefsByCategory extends RepositoryConformanceTestCase private static final String discoveredProperty_numberOfClassificationDefs = "Number of supported ClassificationDefs"; private static final String discoveredProperty_classificationDefs = "Supported ClassificationDefs"; - private List allTypeDefs; - private Map entityDefs = new HashMap<>(); - private List relationshipDefs = new ArrayList<>(); - private List classificationDefs = new ArrayList<>(); + private final List allTypeDefs; + private final Map entityDefs = new HashMap<>(); + private final List relationshipDefs = new ArrayList<>(); + private final List classificationDefs = new ArrayList<>(); /** @@ -57,61 +57,6 @@ public TestFindTypeDefsByCategory(RepositoryConformanceWorkPad workPad, } - - /** - * Return the list of entity definitions returned by the repository. - * - * @return map of EntityDef name to EntityDefs - */ - public Map getEntityDefs() - { - if (entityDefs.isEmpty()) - { - return null; - } - else - { - return entityDefs; - } - } - - - /** - * Return the list of relationship definitions returned by the repository. - * - * @return list of RelationshipDefs - */ - public List getRelationshipDefs() - { - if (relationshipDefs.isEmpty()) - { - return null; - } - else - { - return relationshipDefs; - } - } - - - /** - * Return the list of classification definitions returned by the repository. - * - * @return list of classifications - */ - public List getClassificationDefs() - { - if (classificationDefs.isEmpty()) - { - return null; - } - else - { - return classificationDefs; - } - } - - /** * Method implemented by the actual test case. * @@ -121,9 +66,9 @@ protected void run() throws Exception { OMRSMetadataCollection metadataCollection = super.getMetadataCollection(); - List typeDefGallery = metadataCollection.findTypeDefsByCategory(workPad.getLocalServerUserId(), TypeDefCategory.ENTITY_DEF); + List typeDefList = metadataCollection.findTypeDefsByCategory(workPad.getLocalServerUserId(), TypeDefCategory.ENTITY_DEF); - if (typeDefGallery == null) + if (typeDefList == null) { super.addDiscoveredProperty(discoveredProperty_numberOfEntityDefs, 0, @@ -133,13 +78,13 @@ protected void run() throws Exception else { super.addDiscoveredProperty(discoveredProperty_numberOfEntityDefs, - typeDefGallery.size(), + typeDefList.size(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); List supportedTypes = new ArrayList<>(); - for (TypeDef typeDef : typeDefGallery) + for (TypeDef typeDef : typeDefList) { this.entityDefs.put(typeDef.getName(), (EntityDef)typeDef); supportedTypes.add(typeDef.getName()); @@ -152,9 +97,9 @@ protected void run() throws Exception } - typeDefGallery = metadataCollection.findTypeDefsByCategory(workPad.getLocalServerUserId(), TypeDefCategory.RELATIONSHIP_DEF); + typeDefList = metadataCollection.findTypeDefsByCategory(workPad.getLocalServerUserId(), TypeDefCategory.RELATIONSHIP_DEF); - if (typeDefGallery == null) + if (typeDefList == null) { super.addDiscoveredProperty(discoveredProperty_numberOfRelationshipDefs, 0, @@ -164,13 +109,13 @@ protected void run() throws Exception else { super.addDiscoveredProperty(discoveredProperty_numberOfRelationshipDefs, - typeDefGallery.size(), + typeDefList.size(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); List supportedTypes = new ArrayList<>(); - for (TypeDef typeDef : typeDefGallery) + for (TypeDef typeDef : typeDefList) { this.relationshipDefs.add((RelationshipDef) typeDef); supportedTypes.add(typeDef.getName()); @@ -183,10 +128,10 @@ protected void run() throws Exception } - typeDefGallery = metadataCollection.findTypeDefsByCategory(workPad.getLocalServerUserId(), - TypeDefCategory.CLASSIFICATION_DEF); + typeDefList = metadataCollection.findTypeDefsByCategory(workPad.getLocalServerUserId(), + TypeDefCategory.CLASSIFICATION_DEF); - if (typeDefGallery == null) + if (typeDefList == null) { super.addDiscoveredProperty(discoveredProperty_numberOfClassificationDefs, 0, @@ -196,13 +141,13 @@ protected void run() throws Exception else { super.addDiscoveredProperty(discoveredProperty_numberOfClassificationDefs, - typeDefGallery.size(), + typeDefList.size(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); List supportedTypes = new ArrayList<>(); - for (TypeDef typeDef : typeDefGallery) + for (TypeDef typeDef : typeDefList) { this.classificationDefs.add((ClassificationDef) typeDef); supportedTypes.add(typeDef.getName()); diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestGetTypeDefGallery.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestGetTypeDefGallery.java index f1eea0e43be..0c199641acf 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestGetTypeDefGallery.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/tests/repository/types/TestGetTypeDefGallery.java @@ -7,12 +7,21 @@ import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.AttributeTypeDef; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.ClassificationDef; +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.TypeDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefGallery; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefLink; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +/** + * Discover the types supported by the system under test. + */ public class TestGetTypeDefGallery extends RepositoryConformanceTestCase { private static final String testCaseId = "repository-get-typedef-gallery"; @@ -27,9 +36,22 @@ public class TestGetTypeDefGallery extends RepositoryConformanceTestCase private static final String discoveredProperty_numberOfTypeDefs = "Number of supported TypeDefs"; private static final String discoveredProperty_typeDefs = "Supported TypeDefs"; - List attributeTypeDefs = null; - List typeDefs = null; + private List attributeTypeDefs = null; + /* + * These type defs are used to test the types + */ + private List allTypeDefs = null; + + /* + * These type defs are used to test instances. + */ + private List typesForInstanceTesting = new ArrayList<>(); + private final Map entityDefs = new HashMap<>(); + private final List relationshipDefs = new ArrayList<>(); + private final List classificationDefs = new ArrayList<>(); + + RepositoryConformanceWorkPad repositoryConformanceWorkPad; /** * Typical constructor sets up superclass @@ -43,6 +65,8 @@ public TestGetTypeDefGallery(RepositoryConformanceWorkPad workPad) testCaseName, RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); + + this.repositoryConformanceWorkPad = workPad; } @@ -81,8 +105,8 @@ protected void run() throws Exception { attributeTypeDefs = typeDefGallery.getAttributeTypeDefs(); repositoryConformanceWorkPad.setSupportedAttributeTypeDefsFromRESTAPI(attributeTypeDefs); - typeDefs = typeDefGallery.getTypeDefs(); - repositoryConformanceWorkPad.setSupportedTypeDefsFromRESTAPI(typeDefs); + allTypeDefs = typeDefGallery.getTypeDefs(); + repositoryConformanceWorkPad.setSupportedTypeDefsFromRESTAPI(allTypeDefs); if (attributeTypeDefs == null) { @@ -111,7 +135,7 @@ protected void run() throws Exception RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); } - if (typeDefs == null) + if (allTypeDefs == null) { super.addDiscoveredProperty(discoveredProperty_numberOfTypeDefs, 0, @@ -121,14 +145,14 @@ protected void run() throws Exception else { super.addDiscoveredProperty(discoveredProperty_numberOfTypeDefs, - typeDefs.size(), + allTypeDefs.size(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getProfileId(), RepositoryConformanceProfileRequirement.SUPPORTED_TYPE_QUERIES.getRequirementId()); List supportedTypes = new ArrayList<>(); - for (TypeDef typeDef : typeDefs) + for (TypeDef typeDef : allTypeDefs) { supportedTypes.add(typeDef.getName()); } @@ -140,10 +164,139 @@ protected void run() throws Exception } } + /* + * Split up the retrieved types. + */ + if ((repositoryConformanceWorkPad.getTestEntityTypes() == null) || + (repositoryConformanceWorkPad.getTestEntityTypes().isEmpty())) + { + /* + * Test all types. + */ + typesForInstanceTesting = allTypeDefs; + splitUpTypeDefsForInstanceTests(allTypeDefs); + } + else + { + /* + * Test requested types. + */ + typesForInstanceTesting = determineTypeDefsForInstanceTests(allTypeDefs); + splitUpTypeDefsForInstanceTests(typesForInstanceTesting); + } + super.setSuccessMessage(testCaseSuccessMessage); } + /** + * Take the list of typeDefs for instance testing and split up into entity, relationship and classification types. + * + * @param typeDefs list of typedefs to test + */ + private void splitUpTypeDefsForInstanceTests(List typeDefs) + { + /* + * Map the known types for easy retrieval + */ + for (TypeDef knownTypeDef : typeDefs) + { + if (knownTypeDef instanceof EntityDef entityDef) + { + entityDefs.put(entityDef.getName(), entityDef); + } + else if (knownTypeDef instanceof RelationshipDef relationshipDef) + { + relationshipDefs.add(relationshipDef); + } + else if (knownTypeDef instanceof ClassificationDef classificationDef) + { + classificationDefs.add(classificationDef); + } + } + } + + + /** + * Take the configured list of entity typeDefs for instance testing and add the matching relationships and classifications. + * + * @param typeDefs list of typedefs to test + * @return list of requested types + */ + private List determineTypeDefsForInstanceTests(List typeDefs) + { + Map knownTypeDefMap = new HashMap<>(); + Map matchingTypes = new HashMap<>(); + + /* + * Map the known types ofr easy retrieval + */ + for (TypeDef knownTypeDef : typeDefs) + { + knownTypeDefMap.put(knownTypeDef.getName(), knownTypeDef); + } + + /* + * Add the matching EntityDefs (including their super types.) + */ + for (TypeDef knownTypeDef : typeDefs) + { + if (repositoryConformanceWorkPad.getTestEntityTypes().contains(knownTypeDef.getName())) + { + matchingTypes.put(knownTypeDef.getName(), knownTypeDef); + + String superTypeName = knownTypeDef.getSuperType().getName(); + while (superTypeName != null) + { + TypeDef superType = knownTypeDefMap.get(superTypeName); + matchingTypes.put(superTypeName, superType); + + if (superType.getSuperType() == null) + { + superTypeName = null; + } + else + { + superTypeName = superType.getSuperType().getName(); + } + } + } + } + + List matchingEntityNames = new ArrayList<>(matchingTypes.keySet()); + + /* + * Add the matching RelationshipDefs and ClassificationDefs + */ + for (TypeDef knownTypeDef : typeDefs) + { + if (knownTypeDef instanceof RelationshipDef relationshipDef) + { + /* + * Both ends need to match + */ + if ((matchingEntityNames.contains(relationshipDef.getEndDef1().getEntityType().getName())) && + (matchingEntityNames.contains(relationshipDef.getEndDef2().getEntityType().getName()))) + { + matchingTypes.put(knownTypeDef.getName(), knownTypeDef); + } + } + else if (knownTypeDef instanceof ClassificationDef classificationDef) + { + for (TypeDefLink validEntityDef : classificationDef.getValidEntityDefs()) + { + if (matchingEntityNames.contains(validEntityDef.getName())) + { + matchingTypes.put(knownTypeDef.getName(), knownTypeDef); + } + } + } + } + + return new ArrayList<>(matchingTypes.values()); + } + + /** * Return the list of retrieved attribute type definitions. * @@ -156,12 +309,83 @@ public List getAttributeTypeDefs() /** - * Return the list of retrieved type definitions. + * Return the list of retrieved type definitions used to guide the testing of types. + * + * @return list of TypeDefs + */ + public List getAllTypeDefs() + { + return allTypeDefs; + } + + + /** + * Return the list of retrieved type definitions used to guide the testing of instances. * * @return list of TypeDefs */ - public List getTypeDefs() + public List getInstanceTestTypeDefs() { - return typeDefs; + if (typesForInstanceTesting.isEmpty()) + { + return null; + } + + return typesForInstanceTesting; + } + + + + /** + * Return the list of entity definitions returned by the repository. + * + * @return map of EntityDef name to EntityDefs + */ + public Map getEntityDefs() + { + if (entityDefs.isEmpty()) + { + return null; + } + else + { + return entityDefs; + } + } + + + /** + * Return the list of relationship definitions returned by the repository. + * + * @return list of RelationshipDefs + */ + public List getRelationshipDefs() + { + if (relationshipDefs.isEmpty()) + { + return null; + } + else + { + return relationshipDefs; + } + } + + + /** + * Return the list of classification definitions returned by the repository. + * + * @return list of classifications + */ + public List getClassificationDefs() + { + if (classificationDefs.isEmpty()) + { + return null; + } + else + { + return classificationDefs; + } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkPad.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkPad.java index ac1224809e5..f0f73513fa2 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkPad.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkPad.java @@ -4,7 +4,7 @@ import org.odpi.openmetadata.adminservices.configuration.properties.RepositoryPerformanceWorkbenchConfig; import org.odpi.openmetadata.conformance.beans.*; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector; import java.util.*; @@ -21,7 +21,7 @@ public class PerformanceWorkPad extends OpenMetadataConformanceWorkbenchWorkPad private static final String workbenchDocURL = "https://egeria-project.org/guides/cts/" + workbenchId; private static final String tutType = "Open Metadata Repository"; - private OMRSAuditLog auditLog; + private final AuditLog auditLog; private String tutServerName = null; private String tutMetadataCollectionId = null; @@ -58,7 +58,7 @@ public class PerformanceWorkPad extends OpenMetadataConformanceWorkbenchWorkPad public PerformanceWorkPad(String localServerUserId, String localServerPassword, int maxPageSize, - OMRSAuditLog auditLog, + AuditLog auditLog, RepositoryPerformanceWorkbenchConfig configuration) { super(workbenchId, @@ -89,7 +89,7 @@ public PerformanceWorkPad(String localServerUserI * * @return audit log object. */ - public OMRSAuditLog getAuditLog() + public AuditLog getAuditLog() { return auditLog; } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkbench.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkbench.java index 5fc137e71ec..ec460afca6a 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkbench.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/PerformanceWorkbench.java @@ -2,7 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.workbenches.performance; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.tests.performance.classify.TestEntityClassification; import org.odpi.openmetadata.conformance.tests.performance.classify.TestEntityDeclassification; import org.odpi.openmetadata.conformance.tests.performance.create.TestEntityCreation; @@ -31,7 +31,7 @@ import org.odpi.openmetadata.conformance.tests.performance.update.TestEntityUpdate; import org.odpi.openmetadata.conformance.tests.performance.update.TestRelationshipUpdate; import org.odpi.openmetadata.conformance.workbenches.OpenMetadataConformanceWorkbench; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.*; import org.slf4j.Logger; @@ -59,24 +59,19 @@ public class PerformanceWorkbench extends OpenMetadataConformanceWorkbench public PerformanceWorkbench(PerformanceWorkPad workPad) { super(workPad.getWorkbenchId(), - workPad.getWorkbenchName(), - workPad.getWorkbenchVersionNumber(), - workPad.getWorkbenchDocURL()); + workPad.getWorkbenchName(), + workPad.getWorkbenchVersionNumber(), + workPad.getWorkbenchDocURL()); final String methodName = "performanceWorkbenchThread.constructor"; this.workPad = workPad; - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.WORKBENCH_INITIALIZING; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workbenchId, workbenchDocumentationURL), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_INITIALIZING.getMessageDefinition(workbenchId, + workbenchDocumentationURL)); } /** @@ -126,13 +121,8 @@ private void runTests() throws Exception testEntityCreation.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000L); } @@ -155,13 +145,8 @@ private void runTests() throws Exception testRelationshipCreation.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -184,13 +169,8 @@ private void runTests() throws Exception testEntityClassification.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -216,13 +196,8 @@ private void runTests() throws Exception testEntityUpdate.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -235,13 +210,8 @@ private void runTests() throws Exception testRelationshipUpdate.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -254,13 +224,8 @@ private void runTests() throws Exception testClassificationUpdate.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -276,13 +241,8 @@ private void runTests() throws Exception testEntityUndo.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -295,13 +255,8 @@ private void runTests() throws Exception testRelationshipUndo.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -379,13 +334,8 @@ private void runTests() throws Exception testEntityReHome.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -398,13 +348,8 @@ private void runTests() throws Exception testRelationshipReHome.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -417,13 +362,8 @@ private void runTests() throws Exception testEntityDeclassification.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -438,13 +378,8 @@ private void runTests() throws Exception nullProperties.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); // 23b. re-type to subtype @@ -454,13 +389,8 @@ private void runTests() throws Exception retypeSub.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); // 23c. re-type to supertype @@ -470,13 +400,8 @@ private void runTests() throws Exception retypeSuper.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -490,13 +415,8 @@ private void runTests() throws Exception testRelationshipRetype.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -509,13 +429,8 @@ private void runTests() throws Exception testEntityReIdentify.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -528,13 +443,8 @@ private void runTests() throws Exception testRelationshipReIdentify.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -547,13 +457,8 @@ private void runTests() throws Exception testRelationshipDelete.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -566,13 +471,8 @@ private void runTests() throws Exception testEntityDelete.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -585,13 +485,8 @@ private void runTests() throws Exception testEntityRestore.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -604,13 +499,8 @@ private void runTests() throws Exception testRelationshipRestore.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); } @@ -625,13 +515,8 @@ private void runTests() throws Exception testRelationshipPurge.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); // 31b. purge relationships @@ -654,13 +539,8 @@ private void runTests() throws Exception testEntityPurge.executeTest(); } - workPad.getAuditLog().logRecord(methodName, - waiting.getLogMessageId(), - waiting.getSeverity(), - waiting.getFormattedLogMessage("" + workPad.getWaitBetweenScenarios()), - null, - waiting.getSystemAction(), - waiting.getUserAction()); + workPad.getAuditLog().logMessage(methodName, + waiting.getMessageDefinition("" + workPad.getWaitBetweenScenarios())); Thread.sleep(workPad.getWaitBetweenScenarios() * 1000); // 32b. purge entities @@ -689,17 +569,10 @@ public void run() if (workPad != null) { long retryCount = 0; - OMRSAuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode; - - auditCode = ConformanceSuiteAuditCode.WORKBENCH_INITIALIZED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_INITIALIZED.getMessageDefinition(workPad.getWorkbenchId())); while (super.isRunning() && (workPad.getTutRepositoryConnector() == null)) { @@ -716,15 +589,8 @@ public void run() { if (retryCount == 0) { - auditCode = ConformanceSuiteAuditCode.WORKBENCH_WAITING_TO_START; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId(), - workPad.getTutServerName()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_WAITING_TO_START.getMessageDefinition(workPad.getWorkbenchId(), workPad.getTutServerName())); } retryCount++; } @@ -741,15 +607,9 @@ public void run() stopRunning(); log.error("Unexpected error.", error); - auditCode = ConformanceSuiteAuditCode.WORKBENCH_FAILURE; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId(), - error.getMessage()), - error.toString(), - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_FAILURE.getMessageDefinition(workPad.getWorkbenchId(), error.getMessage()), + error.toString()); } } @@ -763,29 +623,18 @@ public void run() { log.error("Unexpected error.", error); stopRunning(); - auditCode = ConformanceSuiteAuditCode.WORKBENCH_FAILURE; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId(), - error.getMessage()), - error.toString(), - auditCode.getSystemAction(), - auditCode.getUserAction()); - } + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_FAILURE.getMessageDefinition(workPad.getWorkbenchId(), + error.getMessage()), + error.toString()); + } } workPad.setWorkbenchComplete(); - auditCode = ConformanceSuiteAuditCode.WORKBENCH_SYNC_COMPLETED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_SYNC_COMPLETED.getMessageDefinition(workPad.getWorkbenchId())); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/connectorconsumer/PerformanceSuiteConnectorConsumer.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/connectorconsumer/PerformanceSuiteConnectorConsumer.java index f569e73d284..3141dd4d547 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/connectorconsumer/PerformanceSuiteConnectorConsumer.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/performance/connectorconsumer/PerformanceSuiteConnectorConsumer.java @@ -2,10 +2,9 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.workbenches.performance.connectorconsumer; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.workbenches.performance.PerformanceWorkPad; -import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector; import org.odpi.openmetadata.repositoryservices.enterprise.connectormanager.OMRSConnectorConsumer; import org.odpi.openmetadata.repositoryservices.localrepository.repositoryconnector.LocalOMRSRepositoryConnector; @@ -23,10 +22,10 @@ */ public class PerformanceSuiteConnectorConsumer implements OMRSConnectorConsumer { - private Map connectorMap = new HashMap<>(); + private final Map connectorMap = new HashMap<>(); - private String tutServerName; - private PerformanceWorkPad workPad; + private final String tutServerName; + private final PerformanceWorkPad workPad; /** @@ -52,16 +51,10 @@ public void setLocalConnector(String metadataCollectionId, { final String methodName = "setLocalConnector"; - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.LOCAL_CONNECTOR_IN_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(metadataCollectionId), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.LOCAL_CONNECTOR_IN_COHORT.getMessageDefinition(metadataCollectionId)); workPad.setLocalMetadataCollectionId(metadataCollectionId); workPad.setLocalRepositoryConnector(localConnector); @@ -85,34 +78,22 @@ public void addRemoteConnector(String metadataCollectionId, if (tutServerName.equals(remoteConnector.getServerName())) { - OMRSAuditLog auditLog = workPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TUT_CONNECTED_TO_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(tutServerName, - metadataCollectionId), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TUT_CONNECTED_TO_COHORT.getMessageDefinition(tutServerName, + metadataCollectionId)); workPad.setTutMetadataCollectionId(metadataCollectionId); workPad.setTutRepositoryConnector(remoteConnector); } else { - OMRSAuditLog auditLog = workPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.ANOTHER_CONNECTED_TO_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(remoteConnector.getServerName(), - metadataCollectionId, - tutServerName), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.ANOTHER_CONNECTED_TO_COHORT.getMessageDefinition(remoteConnector.getServerName(), + metadataCollectionId, + tutServerName)); } } } @@ -133,34 +114,22 @@ public void removeRemoteConnector(String metadataCollectionId) { if (tutServerName.equals(repositoryConnector.getServerName())) { - OMRSAuditLog auditLog = workPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TUT_LEFT_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(tutServerName, - metadataCollectionId), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TUT_LEFT_COHORT.getMessageDefinition(tutServerName, + metadataCollectionId)); workPad.setTutRepositoryConnector(null); } else { - OMRSAuditLog auditLog = workPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.ANOTHER_LEFT_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(repositoryConnector.getServerName(), - metadataCollectionId, - tutServerName), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.ANOTHER_LEFT_COHORT.getMessageDefinition(repositoryConnector.getServerName(), + metadataCollectionId, + tutServerName)); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/platform/PlatformConformanceWorkbench.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/platform/PlatformConformanceWorkbench.java index fe3abe76a1f..4408aac4834 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/platform/PlatformConformanceWorkbench.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/platform/PlatformConformanceWorkbench.java @@ -2,11 +2,11 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.workbenches.platform; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.tests.platform.OpenMetadataPlatformTestCase; import org.odpi.openmetadata.conformance.tests.platform.origin.TestOpenMetadataOrigin; import org.odpi.openmetadata.conformance.workbenches.OpenMetadataConformanceWorkbench; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,16 +41,10 @@ public PlatformConformanceWorkbench(PlatformConformanceWorkPad workPad) this.workPad = workPad; - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.WORKBENCH_INITIALIZING; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workbenchId, workbenchDocumentationURL), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_INITIALIZING.getMessageDefinition(workbenchId, workbenchDocumentationURL)); } /** @@ -78,17 +72,10 @@ public void run() if (workPad != null) { - OMRSAuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode; - - auditCode = ConformanceSuiteAuditCode.WORKBENCH_INITIALIZED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_INITIALIZED.getMessageDefinition(workPad.getWorkbenchId())); try { @@ -109,25 +96,13 @@ public void run() { log.error(String.format("Unexpected error: %s", error.getMessage()), error); - auditCode = ConformanceSuiteAuditCode.WORKBENCH_FAILURE; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId(), - error.getMessage()), - error.toString(), - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_FAILURE.getMessageDefinition(workPad.getWorkbenchId(), error.getMessage()), + error.toString()); } - auditCode = ConformanceSuiteAuditCode.WORKBENCH_COMPLETED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_COMPLETED.getMessageDefinition(workPad.getWorkbenchId())); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java index c6d853c7c64..038250da162 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkPad.java @@ -4,7 +4,7 @@ import org.odpi.openmetadata.adminservices.configuration.properties.RepositoryConformanceWorkbenchConfig; import org.odpi.openmetadata.conformance.beans.*; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.AttributeTypeDef; @@ -25,13 +25,14 @@ public class RepositoryConformanceWorkPad extends OpenMetadataConformanceWorkben private static final String workbenchDocURL = "https://egeria-project.org/guides/cts/" + workbenchId; private static final String tutType = "Open Metadata Repository"; - private final OMRSAuditLog auditLog; + private final AuditLog auditLog; private String tutServerName = null; private String tutMetadataCollectionId = null; private String tutServerType = null; private String tutOrganization = null; private int maxSearchResults = 50; + private List testEntityTypes = null; private OMRSRepositoryConnector tutRepositoryConnector = null; @@ -68,7 +69,7 @@ public class RepositoryConformanceWorkPad extends OpenMetadataConformanceWorkben public RepositoryConformanceWorkPad(String localServerUserId, String localServerPassword, int maxPageSize, - OMRSAuditLog auditLog, + AuditLog auditLog, RepositoryConformanceWorkbenchConfig configuration) { super(workbenchId, @@ -86,6 +87,7 @@ public RepositoryConformanceWorkPad(String localS { this.tutServerName = configuration.getTutRepositoryServerName(); this.maxSearchResults = configuration.getMaxSearchResults(); + this.testEntityTypes = configuration.getTestEntityTypes(); super.tutName = this.tutServerName; } } @@ -95,7 +97,7 @@ public RepositoryConformanceWorkPad(String localS * * @return audit log object. */ - public OMRSAuditLog getAuditLog() + public AuditLog getAuditLog() { return auditLog; } @@ -122,6 +124,21 @@ public int getMaxSearchResults() return maxSearchResults; } + + + /** + * Return the list of entity types to test. If the value is null then all known entities will be used. + * The names of the entities are used to drive the spawning of tests since the repository workbench aims to test + * each permutation of types. + * + * @return list of entity type names + */ + public List getTestEntityTypes() + { + return testEntityTypes; + } + + /** * Return the server type of the technology under test. This is extracted from the registration * events. diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java index 36c0a22c3e7..1b34104a331 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/RepositoryConformanceWorkbench.java @@ -2,14 +2,14 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.workbenches.repository; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.beans.OpenMetadataTestCase; import org.odpi.openmetadata.conformance.tests.repository.connector.TestMetadataCollectionId; import org.odpi.openmetadata.conformance.tests.repository.connector.TestRepositoryServerIds; import org.odpi.openmetadata.conformance.tests.repository.instances.*; import org.odpi.openmetadata.conformance.tests.repository.types.*; import org.odpi.openmetadata.conformance.workbenches.OpenMetadataConformanceWorkbench; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.*; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; @@ -54,16 +54,10 @@ public RepositoryConformanceWorkbench(RepositoryConformanceWorkPad workPad) this.workPad = workPad; - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.WORKBENCH_INITIALIZING; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workbenchId, workbenchDocumentationURL), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_INITIALIZING.getMessageDefinition(workbenchId, workbenchDocumentationURL)); } @@ -96,7 +90,7 @@ private void runTests() List typeDefTestCases = new ArrayList<>(); List attributeTypeDefs = typeDefGalleryTestCase.getAttributeTypeDefs(); - List typeDefs = typeDefGalleryTestCase.getTypeDefs(); + List typeDefs = typeDefGalleryTestCase.getAllTypeDefs(); if (attributeTypeDefs != null) { @@ -142,8 +136,8 @@ private void runTests() /* * Retrieve the attribute type definitions by category. */ - TestFindAttributeTypeDefsByCategory - testFindAttributeTypeDefsByCategory = new TestFindAttributeTypeDefsByCategory(workPad, attributeTypeDefs); + TestFindAttributeTypeDefsByCategory testFindAttributeTypeDefsByCategory = new TestFindAttributeTypeDefsByCategory(workPad, + attributeTypeDefs); testFindAttributeTypeDefsByCategory.executeTest(); @@ -190,9 +184,9 @@ private void runTests() List entitySearchTestCases = new ArrayList<>(); List relationshipSearchTestCases = new ArrayList<>(); - Map entityDefs = testFindTypeDefsByCategory.getEntityDefs(); - List relationshipDefs = testFindTypeDefsByCategory.getRelationshipDefs(); - List classificationDefs = testFindTypeDefsByCategory.getClassificationDefs(); + Map entityDefs = typeDefGalleryTestCase.getEntityDefs(); + List relationshipDefs = typeDefGalleryTestCase.getRelationshipDefs(); + List classificationDefs = typeDefGalleryTestCase.getClassificationDefs(); /* * Resolve the entity inheritance tree to list all subtypes of each entity type. @@ -519,17 +513,10 @@ public void run() if (workPad != null) { long retryCount = 0; - OMRSAuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode; - - auditCode = ConformanceSuiteAuditCode.WORKBENCH_INITIALIZED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_INITIALIZED.getMessageDefinition(workPad.getWorkbenchId())); while (super.isRunning() && (workPad.getTutRepositoryConnector() == null)) { @@ -546,15 +533,8 @@ public void run() { if (retryCount == 0) { - auditCode = ConformanceSuiteAuditCode.WORKBENCH_WAITING_TO_START; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId(), - workPad.getTutServerName()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_WAITING_TO_START.getMessageDefinition(workPad.getWorkbenchId(), workPad.getTutServerName())); } retryCount++; } @@ -571,15 +551,9 @@ public void run() stopRunning(); log.error(String.format("Unexpected error: %s", error.getMessage()), error); - auditCode = ConformanceSuiteAuditCode.WORKBENCH_FAILURE; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId(), - error.getMessage()), - error.toString(), - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_FAILURE.getMessageDefinition(workPad.getWorkbenchId(), error.getMessage()), + error.toString()); } } @@ -590,14 +564,8 @@ public void run() workPad.setWorkbenchComplete(); - auditCode = ConformanceSuiteAuditCode.WORKBENCH_SYNC_COMPLETED; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(workPad.getWorkbenchId()), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.WORKBENCH_SYNC_COMPLETED.getMessageDefinition(workPad.getWorkbenchId())); } } } diff --git a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/connectorconsumer/ConformanceSuiteConnectorConsumer.java b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/connectorconsumer/ConformanceSuiteConnectorConsumer.java index cb0dbc2e556..c6e6b9ff783 100644 --- a/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/connectorconsumer/ConformanceSuiteConnectorConsumer.java +++ b/open-metadata-conformance-suite/open-metadata-conformance-suite-server/src/main/java/org/odpi/openmetadata/conformance/workbenches/repository/connectorconsumer/ConformanceSuiteConnectorConsumer.java @@ -2,9 +2,9 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.conformance.workbenches.repository.connectorconsumer; -import org.odpi.openmetadata.conformance.auditlog.ConformanceSuiteAuditCode; +import org.odpi.openmetadata.conformance.ffdc.ConformanceSuiteAuditCode; import org.odpi.openmetadata.conformance.workbenches.repository.RepositoryConformanceWorkPad; -import org.odpi.openmetadata.repositoryservices.auditlog.OMRSAuditLog; +import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector; import org.odpi.openmetadata.repositoryservices.enterprise.connectormanager.OMRSConnectorConsumer; import org.odpi.openmetadata.repositoryservices.localrepository.repositoryconnector.LocalOMRSRepositoryConnector; @@ -22,10 +22,10 @@ */ public class ConformanceSuiteConnectorConsumer implements OMRSConnectorConsumer { - private Map connectorMap = new HashMap<>(); + private final Map connectorMap = new HashMap<>(); - private String tutServerName; - private RepositoryConformanceWorkPad workPad; + private final String tutServerName; + private final RepositoryConformanceWorkPad workPad; /** @@ -51,16 +51,10 @@ public void setLocalConnector(String metadataCollectionId, { final String methodName = "setLocalConnector"; - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.LOCAL_CONNECTOR_IN_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(metadataCollectionId), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.LOCAL_CONNECTOR_IN_COHORT.getMessageDefinition(metadataCollectionId)); workPad.setLocalMetadataCollectionId(metadataCollectionId); workPad.setLocalRepositoryConnector(localConnector); @@ -84,34 +78,22 @@ public void addRemoteConnector(String metadataCollectionId, if (tutServerName.equals(remoteConnector.getServerName())) { - OMRSAuditLog auditLog = workPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TUT_CONNECTED_TO_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(tutServerName, - metadataCollectionId), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TUT_CONNECTED_TO_COHORT.getMessageDefinition(tutServerName, + metadataCollectionId)); workPad.setTutMetadataCollectionId(metadataCollectionId); workPad.setTutRepositoryConnector(remoteConnector); } else { - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.ANOTHER_CONNECTED_TO_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(remoteConnector.getServerName(), + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.ANOTHER_CONNECTED_TO_COHORT.getMessageDefinition(remoteConnector.getServerName(), metadataCollectionId, - tutServerName), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + tutServerName)); } } } @@ -132,34 +114,22 @@ public void removeRemoteConnector(String metadataCollectionId) { if (tutServerName.equals(repositoryConnector.getServerName())) { - OMRSAuditLog auditLog = workPad.getAuditLog(); - - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.TUT_LEFT_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(tutServerName, - metadataCollectionId), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + AuditLog auditLog = workPad.getAuditLog(); + + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.TUT_LEFT_COHORT.getMessageDefinition(tutServerName, + metadataCollectionId)); workPad.setTutRepositoryConnector(null); } else { - OMRSAuditLog auditLog = workPad.getAuditLog(); + AuditLog auditLog = workPad.getAuditLog(); - ConformanceSuiteAuditCode auditCode = ConformanceSuiteAuditCode.ANOTHER_LEFT_COHORT; - auditLog.logRecord(methodName, - auditCode.getLogMessageId(), - auditCode.getSeverity(), - auditCode.getFormattedLogMessage(repositoryConnector.getServerName(), - metadataCollectionId, - tutServerName), - null, - auditCode.getSystemAction(), - auditCode.getUserAction()); + auditLog.logMessage(methodName, + ConformanceSuiteAuditCode.ANOTHER_LEFT_COHORT.getMessageDefinition(repositoryConnector.getServerName(), + metadataCollectionId, + tutServerName)); } } } 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/AtlasEntityStatus.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityStatus.java deleted file mode 100644 index e67e2b5d939..00000000000 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityStatus.java +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; - -public enum AtlasEntityStatus -{ - ACTIVE, - DELETED -} From ef66dabd667a02890b178b20d3cc4f3d25360a77 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 24 Jul 2023 09:51:25 +0100 Subject: [PATCH 2/5] Allow Atlas connector to ignore events during refresh() Signed-off-by: Mandy Chessell --- .../docs/atlas-types.drawio | 647 +++- .../ApacheAtlasGlossaryIntegrationModule.java | 2806 +++++++++++++++++ .../ApacheAtlasIntegrationConnector.java | 2776 +--------------- .../AtlasIntegrationModuleBase.java | 83 + .../properties/AtlasAttributeDef.java | 271 ++ .../AtlasAttributeSearchResult.java | 64 + .../properties/AtlasAuditEventV2.java | 147 + .../properties/AtlasAuditOperation.java | 88 + .../properties/AtlasBusinessMetadataDef.java | 23 + .../properties/AtlasCardinality.java | 34 + .../properties/AtlasClassification.java | 95 +- .../AtlasClassificationAssociateRequest.java | 92 + .../properties/AtlasClassificationDef.java | 93 + .../properties/AtlasCondition.java | 21 + .../properties/AtlasConstraintDef.java | 67 + .../properties/AtlasElementDef.java | 78 + .../apacheatlas/properties/AtlasEntity.java | 305 ++ .../properties/AtlasEntityDef.java | 115 + .../properties/AtlasEntityHeader.java | 164 + .../properties/AtlasEntityHeaders.java | 49 + .../apacheatlas/properties/AtlasEnumDef.java | 74 + .../properties/AtlasFilterCriteria.java | 106 + .../properties/AtlasFullTextResult.java | 61 + .../properties/AtlasGlossaryTermElement.java | 236 ++ .../properties/AtlasIndexType.java | 22 + .../properties/AtlasInstanceStatus.java | 34 + .../properties/AtlasLineageDirection.java | 34 + .../properties/AtlasLineageInfo.java | 148 + .../properties/AtlasLineageInfoOnDemand.java | 133 + .../AtlasLineageOnDemandConstraints.java | 89 + .../properties/AtlasLineageRelationship.java | 75 + .../apacheatlas/properties/AtlasObjectId.java | 81 + .../apacheatlas/properties/AtlasOperator.java | 83 + .../properties/AtlasPropagateTags.java | 39 + .../properties/AtlasQueryType.java | 27 + .../properties/AtlasRelatedObjectId.java | 139 + .../properties/AtlasRelationship.java | 263 ++ .../AtlasRelationshipAttributeDef.java | 78 + .../properties/AtlasRelationshipCategory.java | 34 + .../properties/AtlasRelationshipDef.java | 145 + .../properties/AtlasRelationshipEndDef.java | 122 + .../properties/AtlasRelationshipHeader.java | 119 + .../properties/AtlasSearchParameters.java | 307 ++ .../properties/AtlasSearchResult.java | 206 ++ .../properties/AtlasSortOrder.java | 22 + .../apacheatlas/properties/AtlasStruct.java | 66 + .../properties/AtlasStructDef.java | 60 + .../properties/AtlasTermAssignmentHeader.java | 187 ++ .../properties/AtlasTermAssignmentStatus.java | 87 + .../AtlasTermRelationshipStatus.java | 77 + .../properties/AtlasTimeBoundary.java | 77 + .../properties/AtlasTypeCategory.java | 49 + .../properties/AtlasTypeDefBase.java | 247 ++ .../apacheatlas/properties/AtlasTypesDef.java | 120 + .../context/IntegrationContext.java | 25 +- .../IntegrationContextRefreshProxy.java | 34 + 56 files changed, 8951 insertions(+), 2773 deletions(-) create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasGlossaryIntegrationModule.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/AtlasIntegrationModuleBase.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAttributeDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAttributeSearchResult.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAuditEventV2.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAuditOperation.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasBusinessMetadataDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasCardinality.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassificationAssociateRequest.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassificationDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasCondition.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasConstraintDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasElementDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntity.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityHeader.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityHeaders.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEnumDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasFilterCriteria.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasFullTextResult.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasIndexType.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasInstanceStatus.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageDirection.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageInfo.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageInfoOnDemand.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageOnDemandConstraints.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageRelationship.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasObjectId.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasOperator.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasPropagateTags.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasQueryType.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelatedObjectId.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationship.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipAttributeDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipCategory.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipEndDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipHeader.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasSearchParameters.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasSearchResult.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasSortOrder.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasStruct.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasStructDef.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTermAssignmentHeader.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTermAssignmentStatus.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTermRelationshipStatus.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTimeBoundary.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeCategory.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeDefBase.java create mode 100644 open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypesDef.java create mode 100644 open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContextRefreshProxy.java 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 0870a7d3961..2f88963995b 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,6 +1,6 @@ - + - + @@ -99,14 +99,14 @@ - + - - + + @@ -134,14 +134,14 @@ - + - - + + @@ -155,8 +155,8 @@ - - + + @@ -184,16 +184,16 @@ - + - + - + - - + + @@ -204,42 +204,569 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + @@ -249,84 +776,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -336,30 +863,30 @@ - + - + - + - + - + - + - + - + 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 new file mode 100644 index 00000000000..55ea0a23c9b --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/ApacheAtlasGlossaryIntegrationModule.java @@ -0,0 +1,2806 @@ +/* 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 3416cc7de73..b7e1818ba00 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 @@ -3,46 +3,21 @@ package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas; - import org.odpi.openmetadata.accessservices.assetmanager.api.AssetManagerEventListener; 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.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.EndpointProperties; import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; import org.odpi.openmetadata.integrationservices.catalog.connector.CatalogIntegratorConnector; 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; /** @@ -50,18 +25,11 @@ */ public class ApacheAtlasIntegrationConnector extends CatalogIntegratorConnector implements AssetManagerEventListener { - private final static String egeriaGUIDPropertyName = "egeriaGUID"; - private final static String egeriaOwnedPropertyName = "egeriaOwned"; - private final static String atlasGUIDPropertyName = "atlasGUID"; - - private String fixedEgeriaGlossaryQualifiedName = null; - private String fixedEgeriaGlossaryGUID = null; - private String atlasGlossaryName = null; - private String targetRootURL = null; - + private String targetRootURL = null; private CatalogIntegratorContext myContext = null; - private GlossaryExchangeService glossaryExchangeService = null; - private ApacheAtlasRESTClient atlasClient = null; + + private final Map> moduleMap = new HashMap<>(); + private final List moduleList = new ArrayList<>(); /* ============================================================================== @@ -107,38 +75,6 @@ public void start() throws ConnectorCheckedException methodName); } - 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)); - } - } if (myContext.getAssetManagerName() == null) { @@ -147,22 +83,30 @@ public void start() throws ConnectorCheckedException methodName); } - /* - * Create the client that calls Apache Atlas. - */ + try { - atlasClient = new ApacheAtlasRESTClient(connectorName, - "Apache Atlas", - targetRootURL, - connectionProperties.getUserId(), - connectionProperties.getClearPassword(), - auditLog); + /* + * Create the client that calls Apache Atlas. + */ + ApacheAtlasRESTClient atlasClient = new ApacheAtlasRESTClient(connectorName, + "Apache Atlas", + targetRootURL, + connectionProperties.getUserId(), + connectionProperties.getClearPassword(), + auditLog); /* - * The glossaryExchangeService provides access to the open metadata API. + * 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. */ - glossaryExchangeService = myContext.getGlossaryExchangeService(); + this.registerSupportedModule(new ApacheAtlasGlossaryIntegrationModule(connectorName, + connectionProperties, + auditLog, + this.getContext(), + targetRootURL, + atlasClient, + embeddedConnectors)); } catch (Exception error) { @@ -186,145 +130,54 @@ public void start() throws ConnectorCheckedException /** - * 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. + * Populate the moduleList and moduleMap with details of a supported module. * - * @throws ConnectorCheckedException there is a problem with the connector. It is not able to refresh the metadata. + * @param supportedModule module */ - @Override - public void refresh() throws ConnectorCheckedException + private void registerSupportedModule(AtlasIntegrationModuleBase supportedModule) { - final String methodName = "refresh"; + moduleList.add(supportedModule); - try + if (supportedModule.getSupportedTypes() != null) { - /* - * 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)) + for (String supportedType : supportedModule.getSupportedTypes()) { - if (fixedEgeriaGlossaryQualifiedName == null) + if (supportedType != null) { - /* - * Exchange all glossaries found in the open metadata ecosystem. - */ - List glossaries = glossaryExchangeService.findGlossaries(".*", 0, 0, new Date()); + List modulesForTypeName = moduleMap.get(supportedType); - if (glossaries != null) + if (modulesForTypeName == null) { - for (GlossaryElement glossary : glossaries) - { - this.processEgeriaGlossary(glossary); - } + modulesForTypeName = new ArrayList<>(); } - } - 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)); - } - } + modulesForTypeName.add(supportedModule); + + moduleMap.put(supportedType, modulesForTypeName); } } + } + } - /* - * 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++); - } + /** + * 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"; - /* - * 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) + for (AtlasIntegrationModuleBase registeredModule : moduleList) { - 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); + registeredModule.refresh(); } /* @@ -370,63 +223,40 @@ else if (atlasGlossaryName.equals(atlasGlossary.getName())) /** * 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 oen metadata ecosystem to Apache Atlas. + * from the open metadata ecosystem to Apache Atlas. * * @param event event object */ @Override public void processEvent(AssetManagerOutTopicEvent event) { - try + /* + * Only process events if refresh() is not running because the refresh() process creates lots of events and proceeding with event processing + * at this time causes elements to be processed multiple times. + */ + if (! myContext.isRefreshInProgress()) { + /* + * Call the appropriate registered module that matches the type. Notice that multiple modules can be registered for the same type. + */ ElementHeader elementHeader = event.getElementHeader(); - if ((elementHeader != null) && (! isAtlasOwnedElement(elementHeader))) + for (String supportedType : moduleMap.keySet()) { - /* - * 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 (myContext.isTypeOf(elementHeader, supportedType)) { - if (validCategoryElement(elementHeader)) + List modulesForTypeName = moduleMap.get(supportedType); + + if (modulesForTypeName != null) { - processEgeriaGlossaryCategory(glossaryExchangeService.getGlossaryCategoryByGUID(elementHeader.getGUID(), null)); + for (AtlasIntegrationModuleBase registeredModule : modulesForTypeName) + { + registeredModule.processEvent(event); + } } } } } - 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); - } - } } @@ -447,2466 +277,4 @@ public void disconnect() throws ConnectorCheckedException super.disconnect(); } - - - /* ============================================================================================= - * 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/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 new file mode 100644 index 00000000000..0f0d2b5eee4 --- /dev/null +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/AtlasIntegrationModuleBase.java @@ -0,0 +1,83 @@ +/* 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/properties/AtlasAttributeDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAttributeDef.java new file mode 100644 index 00000000000..3daf4ad4521 --- /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/AtlasAttributeDef.java @@ -0,0 +1,271 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + + +/** + * AtlasAttributeDef describes a single attribute of an Apache Atlas type definition. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasAttributeDef +{ + public static final int DEFAULT_SEARCH_WEIGHT = - 1; + public static final String SEARCH_WEIGHT_ATTR_NAME = "searchWeight"; + public static final String INDEX_TYPE_ATTR_NAME = "indexType"; + public static final String ATTR_DEF_OPTION_SOFT_REFERENCE = "isSoftReference"; + public static final String ATTR_DEF_OPTION_APPEND_ON_PARTIAL_UPDATE = "isAppendOnPartialUpdate"; + public static final int COUNT_NOT_SET = -1; + + private final String STRING_TRUE = "true"; + + + private String name = null; + private String typeName = null; + private boolean isOptional = true; + private AtlasCardinality cardinality = null; + private int valuesMinCount = COUNT_NOT_SET; + private int valuesMaxCount = COUNT_NOT_SET; + private boolean isUnique = false; + private boolean isIndexable = false; + private boolean includeInNotification = false; + private String defaultValue = null; + private String description = null; + private int searchWeight = DEFAULT_SEARCH_WEIGHT; + private AtlasIndexType indexType = null; + private List constraints = null; + private Map options = null; + private String displayName = null; + + + public AtlasAttributeDef() + { + } + + + public String getName() + { + return name; + } + + + public void setName(String name) + { + this.name = name; + } + + + public String getTypeName() + { + return typeName; + } + + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + + public boolean isOptional() + { + return isOptional; + } + + + public void setOptional(boolean optional) + { + isOptional = optional; + } + + + public AtlasCardinality getCardinality() + { + return cardinality; + } + + + public void setCardinality(AtlasCardinality cardinality) + { + this.cardinality = cardinality; + } + + + public int getValuesMinCount() + { + return valuesMinCount; + } + + + public void setValuesMinCount(int valuesMinCount) + { + this.valuesMinCount = valuesMinCount; + } + + + public int getValuesMaxCount() + { + return valuesMaxCount; + } + + + public void setValuesMaxCount(int valuesMaxCount) + { + this.valuesMaxCount = valuesMaxCount; + } + + + public boolean isUnique() + { + return isUnique; + } + + + public void setUnique(boolean unique) + { + isUnique = unique; + } + + + public boolean isIndexable() + { + return isIndexable; + } + + + public void setIndexable(boolean indexable) + { + isIndexable = indexable; + } + + + public boolean isIncludeInNotification() + { + return includeInNotification; + } + + + public void setIncludeInNotification(boolean includeInNotification) + { + this.includeInNotification = includeInNotification; + } + + + public String getDefaultValue() + { + return defaultValue; + } + + + public void setDefaultValue(String defaultValue) + { + this.defaultValue = defaultValue; + } + + + public String getDescription() + { + return description; + } + + + public void setDescription(String description) + { + this.description = description; + } + + + public int getSearchWeight() + { + return searchWeight; + } + + + public void setSearchWeight(int searchWeight) + { + this.searchWeight = searchWeight; + } + + + public AtlasIndexType getIndexType() + { + return indexType; + } + + + public void setIndexType(AtlasIndexType indexType) + { + this.indexType = indexType; + } + + + public List getConstraints() + { + return constraints; + } + + + public void setConstraints(List constraints) + { + this.constraints = constraints; + } + + + public Map getOptions() + { + return options; + } + + + public void setOptions(Map options) + { + this.options = options; + } + + + public String getDisplayName() + { + return displayName; + } + + + public void setDisplayName(String displayName) + { + this.displayName = displayName; + } + + + @Override + public String toString() + { + return "AtlasAttributeDef{" + + "name='" + name + '\'' + + ", typeName='" + typeName + '\'' + + ", isOptional=" + isOptional + + ", cardinality=" + cardinality + + ", valuesMinCount=" + valuesMinCount + + ", valuesMaxCount=" + valuesMaxCount + + ", isUnique=" + isUnique + + ", isIndexable=" + isIndexable + + ", includeInNotification=" + includeInNotification + + ", defaultValue='" + defaultValue + '\'' + + ", description='" + description + '\'' + + ", searchWeight=" + searchWeight + + ", indexType=" + indexType + + ", constraints=" + constraints + + ", options=" + options + + ", displayName='" + displayName + '\'' + + '}'; + } +} 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/AtlasAttributeSearchResult.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAttributeSearchResult.java new file mode 100644 index 00000000000..222c2b6c16c --- /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/AtlasAttributeSearchResult.java @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasAttributeSearchResult describes matching attributes. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasAttributeSearchResult +{ + private List name = null; + private List> values = null; + + + public AtlasAttributeSearchResult() + { + } + + + public List getName() + { + return name; + } + + + public void setName(List name) + { + this.name = name; + } + + + public List> getValues() + { + return values; + } + + + public void setValues(List> values) + { + this.values = values; + } + + + @Override + public String toString() + { + return "AtlasAttributeSearchResult{" + + "name=" + name + + ", values=" + values + + '}'; + } +} 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/AtlasAuditEventV2.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAuditEventV2.java new file mode 100644 index 00000000000..ad5192cff3c --- /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/AtlasAuditEventV2.java @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Date; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasAuditEventV2 describes the structure of an audit event + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasAuditEventV2 +{ + private String userName = null; + private AtlasAuditOperation operation = null; + private String params = null; + private Date startTime = null; + private Date endTime = null; + private String clientId = null; + private String result = null; + private long resultCount = 0L; + + + public AtlasAuditEventV2() + { + } + + + public String getUserName() + { + return userName; + } + + + public void setUserName(String userName) + { + this.userName = userName; + } + + + public AtlasAuditOperation getOperation() + { + return operation; + } + + + public void setOperation(AtlasAuditOperation operation) + { + this.operation = operation; + } + + + public String getParams() + { + return params; + } + + + public void setParams(String params) + { + this.params = params; + } + + + public Date getStartTime() + { + return startTime; + } + + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + + public Date getEndTime() + { + return endTime; + } + + + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + + public String getClientId() + { + return clientId; + } + + + public void setClientId(String clientId) + { + this.clientId = clientId; + } + + + public String getResult() + { + return result; + } + + + public void setResult(String result) + { + this.result = result; + } + + + public long getResultCount() + { + return resultCount; + } + + + public void setResultCount(long resultCount) + { + this.resultCount = resultCount; + } + + + @Override + public String toString() + { + return "AtlasAuditEventV2{" + + "userName='" + userName + '\'' + + ", operation=" + operation + + ", params='" + params + '\'' + + ", startTime=" + startTime + + ", endTime=" + endTime + + ", clientId='" + clientId + '\'' + + ", result='" + result + '\'' + + ", resultCount=" + resultCount + + '}'; + } +} 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/AtlasAuditOperation.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasAuditOperation.java new file mode 100644 index 00000000000..793fc26c337 --- /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/AtlasAuditOperation.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.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasAuditOperation describes the operation that an audit event describes. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasAuditOperation +{ + /** + * An instance has been purged. + */ + PURGE("PURGE"), + + /** + * Instances have been exported. + */ + EXPORT("EXPORT"), + + /** + * Instances have been imported. + */ + IMPORT("IMPORT"), + + /** + * Import delete replica? + */ + IMPORT_DELETE_REPL("IMPORT_DELETE_REPL"), + + /** + * New type created + */ + TYPE_DEF_CREATE("TYPE_DEF_CREATE"), + + /** + * Existing type updated. + */ + TYPE_DEF_UPDATE("TYPE_DEF_UPDATE"), + + /** + * A type has been deleted. + */ + TYPE_DEF_DELETE("TYPE_DEF_DELETE"), + + /** + * Atlas has started. + */ + SERVER_START("SERVER_START"), + + /** + * Atlas is active + */ + SERVER_STATE_ACTIVE("SERVER_STATE_ACTIVE"); + + private final String type; + + + /** + * Constructor. + * + * @param type name + */ + AtlasAuditOperation(String type) + { + this.type = type; + } + + + /** + * Return the string name of the operation. + * + * @return name + */ + public String getType() + { + return type; + } +} 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/AtlasBusinessMetadataDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasBusinessMetadataDef.java new file mode 100644 index 00000000000..69c70a0f03e --- /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/AtlasBusinessMetadataDef.java @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasBusinessMetadataDef describes the properties of a business metadata type. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasBusinessMetadataDef extends AtlasStructDef +{ + public static final String ATTR_OPTION_APPLICABLE_ENTITY_TYPES = "applicableEntityTypes"; + public static final String ATTR_MAX_STRING_LENGTH = "maxStrLength"; + public static final String ATTR_VALID_PATTERN = "validPattern"; +} 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/AtlasCardinality.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasCardinality.java new file mode 100644 index 00000000000..5a74c2072e8 --- /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/AtlasCardinality.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; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasCardinality describes the cardinality of an attribute or relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasCardinality +{ + /** + * One instance of element + */ + SINGLE, + + /** + * A set of elements + */ + SET, + + /** + * A list of elements + */ + LIST +} 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/AtlasClassification.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassification.java index 7bb9af47877..1d6edc4b58f 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassification.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassification.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; import java.util.Map; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -17,13 +18,91 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) -public class AtlasClassification +public class AtlasClassification extends AtlasStruct { - private String typeName = null; - private Map attributes = null; - private String entityGuid = null; - private AtlasEntityStatus entityStatus = null; - // private boolean propagate = false; - // private List validityPeriods = null; - // private boolean removePropagationsOnEntityDelete = false; + private String entityGuid = null; + private AtlasInstanceStatus entityStatus = AtlasInstanceStatus.ACTIVE; + private boolean propagate = false; + private List validityPeriods = null; + private Boolean removePropagationsOnEntityDelete = null; + + + public AtlasClassification() + { + } + + + public String getEntityGuid() + { + return entityGuid; + } + + + public void setEntityGuid(String entityGuid) + { + this.entityGuid = entityGuid; + } + + + public AtlasInstanceStatus getEntityStatus() + { + return entityStatus; + } + + + public void setEntityStatus(AtlasInstanceStatus entityStatus) + { + this.entityStatus = entityStatus; + } + + + public boolean getPropagate() + { + return propagate; + } + + + public void setPropagate(boolean propagate) + { + this.propagate = propagate; + } + + + public List getValidityPeriods() + { + return validityPeriods; + } + + + public void setValidityPeriods(List validityPeriods) + { + this.validityPeriods = validityPeriods; + } + + + public Boolean getRemovePropagationsOnEntityDelete() + { + return removePropagationsOnEntityDelete; + } + + + public void setRemovePropagationsOnEntityDelete(Boolean removePropagationsOnEntityDelete) + { + this.removePropagationsOnEntityDelete = removePropagationsOnEntityDelete; + } + + + @Override + public String toString() + { + return "AtlasClassification{" + + "entityGuid='" + entityGuid + '\'' + + ", entityStatus=" + entityStatus + + ", propagate=" + propagate + + ", validityPeriods=" + validityPeriods + + ", removePropagationsOnEntityDelete=" + removePropagationsOnEntityDelete + + ", typeName='" + getTypeName() + '\'' + + ", attributes=" + getAttributes() + + '}'; + } } 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/AtlasClassificationAssociateRequest.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassificationAssociateRequest.java new file mode 100644 index 00000000000..3590a0eef40 --- /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/AtlasClassificationAssociateRequest.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.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasClassificationAssociateRequest seems to be used to do a bulk update of entities with a classification. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasClassificationAssociateRequest +{ + private AtlasClassification classification; + private List entityGuids; + private List> entitiesUniqueAttributes; + private String entityTypeName; + + + public AtlasClassificationAssociateRequest() + { + } + + + public AtlasClassification getClassification() + { + return classification; + } + + + public void setClassification(AtlasClassification classification) + { + this.classification = classification; + } + + + public List getEntityGuids() + { + return entityGuids; + } + + + public void setEntityGuids(List entityGuids) + { + this.entityGuids = entityGuids; + } + + + public List> getEntitiesUniqueAttributes() + { + return entitiesUniqueAttributes; + } + + + public void setEntitiesUniqueAttributes(List> entitiesUniqueAttributes) + { + this.entitiesUniqueAttributes = entitiesUniqueAttributes; + } + + + public String getEntityTypeName() + { + return entityTypeName; + } + + + public void setEntityTypeName(String entityTypeName) + { + this.entityTypeName = entityTypeName; + } + + + @Override + public String toString() + { + return "AtlasClassificationAssociateRequest{" + + "classification=" + classification + + ", entityGuids=" + entityGuids + + ", entitiesUniqueAttributes=" + entitiesUniqueAttributes + + ", entityTypeName='" + entityTypeName + '\'' + + '}'; + } +} 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/AtlasClassificationDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasClassificationDef.java new file mode 100644 index 00000000000..13fb475d3f7 --- /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/AtlasClassificationDef.java @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasClassificationDef describes a type of tag. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasClassificationDef extends AtlasStructDef +{ + private Set entityTypes = null; + + private Set superTypes = null; + + // subTypes field below is derived from 'superTypes' specified in all AtlasClassificationDef + // this value is ignored during create & update operations + private Set subTypes = null; + + + public AtlasClassificationDef() + { + } + + + public Set getSuperTypes() + { + return superTypes; + } + + + public void setSuperTypes(Set superTypes) + { + this.superTypes = superTypes; + } + + + public Set getSubTypes() + { + return subTypes; + } + + + public void setSubTypes(Set subTypes) + { + this.subTypes = subTypes; + } + + + public Set getEntityTypes() + { + return entityTypes; + } + + + public void setEntityTypes(Set entityTypes) + { + this.entityTypes = entityTypes; + } + + + @Override + public String toString() + { + return "AtlasClassificationDef{" + + "superTypes=" + superTypes + + ", subTypes=" + subTypes + + ", entityTypes=" + entityTypes + + ", attributeDefs=" + getAttributeDefs() + + ", category=" + getCategory() + + ", guid='" + getGuid() + '\'' + + ", createdBy='" + getCreatedBy() + '\'' + + ", updateBy='" + getUpdateBy() + '\'' + + ", createTime=" + getCreateTime() + + ", updateTime=" + getUpdateTime() + + ", version=" + getVersion() + + ", name='" + getName() + '\'' + + ", description='" + getDescription() + '\'' + + ", typeVersion='" + getTypeVersion() + '\'' + + ", serviceType='" + getServiceType() + '\'' + + '}'; + } +} 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/AtlasCondition.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasCondition.java new file mode 100644 index 00000000000..06503c33fcd --- /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/AtlasCondition.java @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasCondition is used in forming queries. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasCondition +{ + AND, OR +} 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/AtlasConstraintDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasConstraintDef.java new file mode 100644 index 00000000000..1cc261409a1 --- /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/AtlasConstraintDef.java @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasConstraintDef captures details of a constraint. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasConstraintDef +{ + public static final String CONSTRAINT_TYPE_OWNED_REF = "ownedRef"; + public static final String CONSTRAINT_TYPE_INVERSE_REF = "inverseRef"; + public static final String CONSTRAINT_PARAM_ATTRIBUTE = "attribute"; + + private String type = null; // foreignKey/mappedFromRef/valueInRange + private Map params = null; // onDelete=cascade/refAttribute=attr2/min=0,max=23 + + + public AtlasConstraintDef() + { + } + + + public String getType() + { + return type; + } + + + public void setType(String type) + { + this.type = type; + } + + + public Map getParams() + { + return params; + } + + + public void setParams(Map params) + { + this.params = params; + } + + + @Override + public String toString() + { + return "AtlasConstraintDef{" + + "type='" + type + '\'' + + ", params=" + params + + '}'; + } +} 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/AtlasElementDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasElementDef.java new file mode 100644 index 00000000000..37ef6549df0 --- /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/AtlasElementDef.java @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasElementDef describes a single valid value in an EnumDef. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasElementDef +{ + private String value = null; + private String description = null; + private int ordinal = 0; + + + /** + * Default constructor + */ + public AtlasElementDef() + { + } + + + public String getValue() + { + return value; + } + + + public void setValue(String value) + { + this.value = value; + } + + + public String getDescription() + { + return description; + } + + + public void setDescription(String description) + { + this.description = description; + } + + + public int getOrdinal() + { + return ordinal; + } + + + public void setOrdinal(int ordinal) + { + this.ordinal = ordinal; + } + + + @Override + public String toString() + { + return "AtlasElementDef{" + + "value='" + value + '\'' + + ", description='" + description + '\'' + + ", ordinal=" + ordinal + + '}'; + } +} 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/AtlasEntity.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntity.java new file mode 100644 index 00000000000..ad6826da41b --- /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/AtlasEntity.java @@ -0,0 +1,305 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasEntity describes an entity instance. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasEntity extends AtlasStruct +{ + public static final String KEY_GUID = "guid"; + public static final String KEY_HOME_ID = "homeId"; + public static final String KEY_IS_PROXY = "isProxy"; + public static final String KEY_IS_INCOMPLETE = "isIncomplete"; + public static final String KEY_PROVENANCE_TYPE = "provenanceType"; + public static final String KEY_STATUS = "status"; + public static final String KEY_CREATED_BY = "createdBy"; + public static final String KEY_UPDATED_BY = "updatedBy"; + public static final String KEY_CREATE_TIME = "createTime"; + public static final String KEY_UPDATE_TIME = "updateTime"; + public static final String KEY_VERSION = "version"; + + + private String guid = null; + private String homeId = null; + private boolean isProxy = false; + private boolean isIncomplete = false; + private Integer provenanceType = 0; + private AtlasInstanceStatus status = AtlasInstanceStatus.ACTIVE; + private String createdBy = null; + private String updatedBy = null; + private Date createTime = null; + private Date updateTime = null; + private Long version = 0L; + private Map relationshipAttributes = null; + private List classifications = null; + private List meanings = null; + private Map customAttributes = null; + private Map> businessAttributes = null; + private Set labels = null; + private Set pendingTasks = null; // read-only field i.e. value provided is ignored during entity create/update + + + public AtlasEntity() + { + } + + + public String getGuid() + { + return guid; + } + + + public void setGuid(String guid) + { + this.guid = guid; + } + + + public String getHomeId() + { + return homeId; + } + + + public void setHomeId(String homeId) + { + this.homeId = homeId; + } + + + public boolean getProxy() + { + return isProxy; + } + + + public void setProxy(boolean proxy) + { + isProxy = proxy; + } + + + public boolean getIncomplete() + { + return isIncomplete; + } + + + public void setIncomplete(boolean incomplete) + { + isIncomplete = incomplete; + } + + + public Integer getProvenanceType() + { + return provenanceType; + } + + + public void setProvenanceType(Integer provenanceType) + { + this.provenanceType = provenanceType; + } + + + public AtlasInstanceStatus getStatus() + { + return status; + } + + + public void setStatus(AtlasInstanceStatus status) + { + this.status = status; + } + + + public String getCreatedBy() + { + return createdBy; + } + + + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + + public String getUpdatedBy() + { + return updatedBy; + } + + + public void setUpdatedBy(String updatedBy) + { + this.updatedBy = updatedBy; + } + + + public Date getCreateTime() + { + return createTime; + } + + + public void setCreateTime(Date createTime) + { + this.createTime = createTime; + } + + + public Date getUpdateTime() + { + return updateTime; + } + + + public void setUpdateTime(Date updateTime) + { + this.updateTime = updateTime; + } + + + public Long getVersion() + { + return version; + } + + + public void setVersion(Long version) + { + this.version = version; + } + + + public Map getRelationshipAttributes() + { + return relationshipAttributes; + } + + + public void setRelationshipAttributes(Map relationshipAttributes) + { + this.relationshipAttributes = relationshipAttributes; + } + + + public List getClassifications() + { + return classifications; + } + + + public void setClassifications(List classifications) + { + this.classifications = classifications; + } + + + public List getMeanings() + { + return meanings; + } + + + public void setMeanings(List meanings) + { + this.meanings = meanings; + } + + + public Map getCustomAttributes() + { + return customAttributes; + } + + + public void setCustomAttributes(Map customAttributes) + { + this.customAttributes = customAttributes; + } + + + public Map> getBusinessAttributes() + { + return businessAttributes; + } + + + public void setBusinessAttributes(Map> businessAttributes) + { + this.businessAttributes = businessAttributes; + } + + + public Set getLabels() + { + return labels; + } + + + public void setLabels(Set labels) + { + this.labels = labels; + } + + + public Set getPendingTasks() + { + return pendingTasks; + } + + + public void setPendingTasks(Set pendingTasks) + { + this.pendingTasks = pendingTasks; + } + + + @Override + public String toString() + { + return "AtlasEntity{" + + "guid='" + guid + '\'' + + ", homeId='" + homeId + '\'' + + ", isProxy=" + isProxy + + ", isIncomplete=" + isIncomplete + + ", provenanceType=" + provenanceType + + ", status=" + status + + ", createdBy='" + createdBy + '\'' + + ", updatedBy='" + updatedBy + '\'' + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", version=" + version + + ", relationshipAttributes=" + relationshipAttributes + + ", classifications=" + classifications + + ", meanings=" + meanings + + ", customAttributes=" + customAttributes + + ", businessAttributes=" + businessAttributes + + ", labels=" + labels + + ", pendingTasks=" + pendingTasks + + ", typeName='" + getTypeName() + '\'' + + ", attributes=" + getAttributes() + + '}'; + } +} 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/AtlasEntityDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityDef.java new file mode 100644 index 00000000000..f35b85078ce --- /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/AtlasEntityDef.java @@ -0,0 +1,115 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasEntityDef describes the type definition for an entity. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasEntityDef extends AtlasStructDef +{ + public static final String OPTION_DISPLAY_TEXT_ATTRIBUTE = "displayTextAttribute"; + + private Set superTypes = null; + + // this is a read-only field, any value provided during create & update operation is ignored + // the value of this field is derived from 'superTypes' specified in all AtlasEntityDef + private Set subTypes = null; + + // this is a read-only field, any value provided during create & update operation is ignored + // the value of this field is derived from all the relationshipDefs this entityType is referenced in + private List relationshipAttributeDefs; + + // this is a read-only field, any value provided during create & update operation is ignored + // the value of this field is derived from all the businessMetadataDefs this entityType is referenced in + private Map> businessAttributeDefs; + + public AtlasEntityDef() + { + } + + + public Set getSuperTypes() + { + return superTypes; + } + + + public void setSuperTypes(Set superTypes) + { + this.superTypes = superTypes; + } + + + public Set getSubTypes() + { + return subTypes; + } + + + public void setSubTypes(Set subTypes) + { + this.subTypes = subTypes; + } + + + public List getRelationshipAttributeDefs() + { + return relationshipAttributeDefs; + } + + + public void setRelationshipAttributeDefs(List relationshipAttributeDefs) + { + this.relationshipAttributeDefs = relationshipAttributeDefs; + } + + + public Map> getBusinessAttributeDefs() + { + return businessAttributeDefs; + } + + + public void setBusinessAttributeDefs(Map> businessAttributeDefs) + { + this.businessAttributeDefs = businessAttributeDefs; + } + + + @Override + public String toString() + { + return "AtlasEntityDef{" + + "superTypes=" + superTypes + + ", subTypes=" + subTypes + + ", relationshipAttributeDefs=" + relationshipAttributeDefs + + ", businessAttributeDefs=" + businessAttributeDefs + + ", attributeDefs=" + getAttributeDefs() + + ", category=" + getCategory() + + ", guid='" + getGuid() + '\'' + + ", createdBy='" + getCreatedBy() + '\'' + + ", updateBy='" + getUpdateBy() + '\'' + + ", createTime=" + getCreateTime() + + ", updateTime=" + getUpdateTime() + + ", version=" + getVersion() + + ", name='" + getName() + '\'' + + ", description='" + getDescription() + '\'' + + ", typeVersion='" + getTypeVersion() + '\'' + + ", serviceType='" + getServiceType() + '\'' + + '}'; + } +} 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/AtlasEntityHeader.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityHeader.java new file mode 100644 index 00000000000..9129f3f2f4a --- /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/AtlasEntityHeader.java @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasEntityHeader provides the summary information about an entity instance. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasEntityHeader extends AtlasStruct +{ + private String guid = null; + private AtlasInstanceStatus status = AtlasInstanceStatus.ACTIVE; + private String displayText = null; + private List classificationNames = null; + private List classifications = null; + private List meaningNames = null; + private List meanings = null; + private boolean isIncomplete = false; + private Set labels = null; + + + public AtlasEntityHeader() + { + } + + + public String getGuid() + { + return guid; + } + + + public void setGuid(String guid) + { + this.guid = guid; + } + + + public AtlasInstanceStatus getStatus() + { + return status; + } + + + public void setStatus(AtlasInstanceStatus status) + { + this.status = status; + } + + + public String getDisplayText() + { + return displayText; + } + + + public void setDisplayText(String displayText) + { + this.displayText = displayText; + } + + + public List getClassificationNames() + { + return classificationNames; + } + + + public void setClassificationNames(List classificationNames) + { + this.classificationNames = classificationNames; + } + + + public List getClassifications() + { + return classifications; + } + + + public void setClassifications(List classifications) + { + this.classifications = classifications; + } + + + public List getMeaningNames() + { + return meaningNames; + } + + + public void setMeaningNames(List meaningNames) + { + this.meaningNames = meaningNames; + } + + + public List getMeanings() + { + return meanings; + } + + + public void setMeanings(List meanings) + { + this.meanings = meanings; + } + + + public boolean getIncomplete() + { + return isIncomplete; + } + + + public void setIncomplete(boolean incomplete) + { + isIncomplete = incomplete; + } + + + public Set getLabels() + { + return labels; + } + + + public void setLabels(Set labels) + { + this.labels = labels; + } + + + @Override + public String toString() + { + return "AtlasEntityHeader{" + + "guid='" + guid + '\'' + + ", status=" + status + + ", displayText='" + displayText + '\'' + + ", classificationNames=" + classificationNames + + ", classifications=" + classifications + + ", meaningNames=" + meaningNames + + ", meanings=" + meanings + + ", isIncomplete=" + isIncomplete + + ", labels=" + labels + + ", typeName='" + getTypeName() + '\'' + + ", attributes=" + getAttributes() + + '}'; + } +} 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/AtlasEntityHeaders.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEntityHeaders.java new file mode 100644 index 00000000000..3243ce554bf --- /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/AtlasEntityHeaders.java @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasEntityHeaders defines a map of GUID to Atlas entities + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasEntityHeaders +{ + private Map guidHeaderMap = null; + + + public AtlasEntityHeaders() + { + } + + + public Map getGuidHeaderMap() + { + return guidHeaderMap; + } + + + public void setGuidHeaderMap(Map guidHeaderMap) + { + this.guidHeaderMap = guidHeaderMap; + } + + + @Override + public String toString() + { + return "AtlasEntityHeaders{" + + "guidHeaderMap=" + guidHeaderMap + + '}'; + } +} 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/AtlasEnumDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasEnumDef.java new file mode 100644 index 00000000000..ecd2056e60c --- /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/AtlasEnumDef.java @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasEnumDef describes the structure of an EnumDef. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasEnumDef extends AtlasTypeDefBase +{ + private List elementDefs = null; + private String defaultValue = null; + + + public AtlasEnumDef() + { + } + + + public List getElementDefs() + { + return elementDefs; + } + + + public void setElementDefs(List elementDefs) + { + this.elementDefs = elementDefs; + } + + + public String getDefaultValue() + { + return defaultValue; + } + + + public void setDefaultValue(String defaultValue) + { + this.defaultValue = defaultValue; + } + + + @Override + public String toString() + { + return "AtlasEnumDef{" + + "elementDefs=" + elementDefs + + ", defaultValue='" + defaultValue + '\'' + + ", category=" + getCategory() + + ", guid='" + getGuid() + '\'' + + ", createdBy='" + getCreatedBy() + '\'' + + ", updateBy='" + getUpdateBy() + '\'' + + ", createTime=" + getCreateTime() + + ", updateTime=" + getUpdateTime() + + ", version=" + getVersion() + + ", name='" + getName() + '\'' + + ", description='" + getDescription() + '\'' + + ", typeVersion='" + getTypeVersion() + '\'' + + ", serviceType='" + getServiceType() + '\'' + + '}'; + } +} 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/AtlasFilterCriteria.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasFilterCriteria.java new file mode 100644 index 00000000000..7284c99306e --- /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/AtlasFilterCriteria.java @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasFilterCriteria can represent a single condition or group of conditions. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasFilterCriteria +{ + private String attributeName = null; + private AtlasOperator operator = null; + private String attributeValue = null; + private AtlasCondition condition = null; + private List criterion = null; + + + public AtlasFilterCriteria() + { + } + + + public String getAttributeName() + { + return attributeName; + } + + + public void setAttributeName(String attributeName) + { + this.attributeName = attributeName; + } + + + public AtlasOperator getOperator() + { + return operator; + } + + + public void setOperator(AtlasOperator operator) + { + this.operator = operator; + } + + + public String getAttributeValue() + { + return attributeValue; + } + + + public void setAttributeValue(String attributeValue) + { + this.attributeValue = attributeValue; + } + + + public AtlasCondition getCondition() + { + return condition; + } + + + public void setCondition(AtlasCondition condition) + { + this.condition = condition; + } + + + public List getCriterion() + { + return criterion; + } + + + public void setCriterion(List criterion) + { + this.criterion = criterion; + } + + + @Override + public String toString() + { + return "AtlasFilterCriteria{" + + "attributeName='" + attributeName + '\'' + + ", operator=" + operator + + ", attributeValue='" + attributeValue + '\'' + + ", condition=" + condition + + ", criterion=" + criterion + + '}'; + } +} 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/AtlasFullTextResult.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasFullTextResult.java new file mode 100644 index 00000000000..e42cb9a1793 --- /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/AtlasFullTextResult.java @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasFullTextResult returns search for entity results with match score. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasFullTextResult +{ + private AtlasEntityHeader entity = null; + private Double score = null; + + + public AtlasFullTextResult() + { + } + + + public AtlasEntityHeader getEntity() + { + return entity; + } + + + public void setEntity(AtlasEntityHeader entity) + { + this.entity = entity; + } + + + public Double getScore() + { + return score; + } + + + public void setScore(Double score) + { + this.score = score; + } + + + @Override + public String toString() + { + return "AtlasFullTextResult{" + + "entity=" + entity + + ", score=" + score + + '}'; + } +} 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/AtlasGlossaryTermElement.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasGlossaryTermElement.java index e0c42eb8608..5885a106430 100644 --- a/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasGlossaryTermElement.java +++ b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasGlossaryTermElement.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import java.util.List; +import java.util.Set; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; @@ -23,6 +24,38 @@ public class AtlasGlossaryTermElement extends AtlasGlossaryMemberBaseProperties private String usage = null; private List classifications = null; private List categories = null; + private List examples = null; + + private Set seeAlso = null; + + // Term Synonyms + private Set synonyms = null; + + // Term antonyms + private Set antonyms = null; + + // Term preference + private Set preferredTerms = null; + private Set preferredToTerms = null; + + // Term replacements + private Set replacementTerms = null; + private Set replacedBy = null; + + // Term translations + private Set translationTerms = null; + private Set translatedTerms = null; + + // Term classification + private Set isA = null; + private Set classifies = null; + + // Values for terms + private Set validValues = null; + private Set validValuesFor = null; + + private boolean hasTerms = false; + /** @@ -101,12 +134,215 @@ public void setCategories(List categories) } + public List getExamples() + { + return examples; + } + + + public void setExamples(List examples) + { + this.examples = examples; + } + + + public Set getSeeAlso() + { + return seeAlso; + } + + + public void setSeeAlso(Set seeAlso) + { + this.seeAlso = seeAlso; + } + + + public Set getSynonyms() + { + return synonyms; + } + + + public void setSynonyms(Set synonyms) + { + this.synonyms = synonyms; + } + + + public Set getAntonyms() + { + return antonyms; + } + + + public void setAntonyms(Set antonyms) + { + this.antonyms = antonyms; + } + + + public Set getPreferredTerms() + { + return preferredTerms; + } + + + public void setPreferredTerms( + Set preferredTerms) + { + this.preferredTerms = preferredTerms; + } + + + public Set getPreferredToTerms() + { + return preferredToTerms; + } + + + public void setPreferredToTerms( + Set preferredToTerms) + { + this.preferredToTerms = preferredToTerms; + } + + + public Set getReplacementTerms() + { + return replacementTerms; + } + + + public void setReplacementTerms( + Set replacementTerms) + { + this.replacementTerms = replacementTerms; + } + + + public Set getReplacedBy() + { + return replacedBy; + } + + + public void setReplacedBy(Set replacedBy) + { + this.replacedBy = replacedBy; + } + + + public Set getTranslationTerms() + { + return translationTerms; + } + + + public void setTranslationTerms( + Set translationTerms) + { + this.translationTerms = translationTerms; + } + + + public Set getTranslatedTerms() + { + return translatedTerms; + } + + + public void setTranslatedTerms( + Set translatedTerms) + { + this.translatedTerms = translatedTerms; + } + + + public Set getIsA() + { + return isA; + } + + + public void setIsA(Set isA) + { + this.isA = isA; + } + + + public Set getClassifies() + { + return classifies; + } + + + public void setClassifies(Set classifies) + { + this.classifies = classifies; + } + + + public Set getValidValues() + { + return validValues; + } + + + public void setValidValues(Set validValues) + { + this.validValues = validValues; + } + + + public Set getValidValuesFor() + { + return validValuesFor; + } + + + public void setValidValuesFor( + Set validValuesFor) + { + this.validValuesFor = validValuesFor; + } + + + public boolean getHasTerms() + { + return hasTerms; + } + + + public void setHasTerms(boolean hasTerms) + { + this.hasTerms = hasTerms; + } + + @Override public String toString() { return "AtlasGlossaryTermElement{" + "abbreviation='" + abbreviation + '\'' + ", usage='" + usage + '\'' + + ", classifications=" + classifications + + ", categories=" + categories + + ", examples=" + examples + + ", seeAlso=" + seeAlso + + ", synonyms=" + synonyms + + ", antonyms=" + antonyms + + ", preferredTerms=" + preferredTerms + + ", preferredToTerms=" + preferredToTerms + + ", replacementTerms=" + replacementTerms + + ", replacedBy=" + replacedBy + + ", translationTerms=" + translationTerms + + ", translatedTerms=" + translatedTerms + + ", isA=" + isA + + ", classifies=" + classifies + + ", validValues=" + validValues + + ", validValuesFor=" + validValuesFor + + ", hasTerms=" + hasTerms + ", anchor=" + getAnchor() + ", guid='" + getGuid() + '\'' + ", qualifiedName='" + getQualifiedName() + '\'' + 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/AtlasIndexType.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasIndexType.java new file mode 100644 index 00000000000..95aef2f7802 --- /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/AtlasIndexType.java @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasIndexType describes the data type of the indexable value. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasIndexType +{ + DEFAULT, + STRING +} 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/AtlasInstanceStatus.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasInstanceStatus.java new file mode 100644 index 00000000000..633862392fe --- /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/AtlasInstanceStatus.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; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasInstanceStatus describes the different status values for instances in Apache Atlas. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasInstanceStatus +{ + /** + * Normal active instance. + */ + ACTIVE, + + /** + * An instance that has been soft-deleted + */ + DELETED, + + /** + * An instance that has been complete removed from the Apache Atlas repository. + */ + PURGED +} 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/AtlasLineageDirection.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageDirection.java new file mode 100644 index 00000000000..6a98c169921 --- /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/AtlasLineageDirection.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; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasLineageDirection describes the direction of lineage flow. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasLineageDirection +{ + /** + * Incoming data to the entity + */ + INPUT, + + /** + * Data consumed from the entity + */ + OUTPUT, + + /** + * Both directions. + */ + BOTH +} 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/AtlasLineageInfo.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageInfo.java new file mode 100644 index 00000000000..4d5641fda81 --- /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/AtlasLineageInfo.java @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Map; +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasLineageInfo captures lineage for an entity instance like hive_table. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasLineageInfo +{ + private String baseEntityGuid = null; + private AtlasLineageDirection lineageDirection = null; + private int lineageDepth = 0; + private Map guidEntityMap = null; + private Set relations = null; + private Set visitedEdges = null; + private Map relationsOnDemand = null; + private Map lineageOnDemandPayload = null; + + + public AtlasLineageInfo() + { + } + + + public String getBaseEntityGuid() + { + return baseEntityGuid; + } + + + public void setBaseEntityGuid(String baseEntityGuid) + { + this.baseEntityGuid = baseEntityGuid; + } + + + public AtlasLineageDirection getLineageDirection() + { + return lineageDirection; + } + + + public void setLineageDirection(AtlasLineageDirection lineageDirection) + { + this.lineageDirection = lineageDirection; + } + + + public int getLineageDepth() + { + return lineageDepth; + } + + + public void setLineageDepth(int lineageDepth) + { + this.lineageDepth = lineageDepth; + } + + + public Map getGuidEntityMap() + { + return guidEntityMap; + } + + + public void setGuidEntityMap(Map guidEntityMap) + { + this.guidEntityMap = guidEntityMap; + } + + + public Set getRelations() + { + return relations; + } + + + public void setRelations(Set relations) + { + this.relations = relations; + } + + + public Set getVisitedEdges() + { + return visitedEdges; + } + + + public void setVisitedEdges(Set visitedEdges) + { + this.visitedEdges = visitedEdges; + } + + + public Map getRelationsOnDemand() + { + return relationsOnDemand; + } + + + public void setRelationsOnDemand(Map relationsOnDemand) + { + this.relationsOnDemand = relationsOnDemand; + } + + + public Map getLineageOnDemandPayload() + { + return lineageOnDemandPayload; + } + + + public void setLineageOnDemandPayload(Map lineageOnDemandPayload) + { + this.lineageOnDemandPayload = lineageOnDemandPayload; + } + + + @Override + public String toString() + { + return "AtlasLineageInfo{" + + "baseEntityGuid='" + baseEntityGuid + '\'' + + ", lineageDirection=" + lineageDirection + + ", lineageDepth=" + lineageDepth + + ", guidEntityMap=" + guidEntityMap + + ", relations=" + relations + + ", visitedEdges=" + visitedEdges + + ", relationsOnDemand=" + relationsOnDemand + + ", lineageOnDemandPayload=" + lineageOnDemandPayload + + '}'; + } +} 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/AtlasLineageInfoOnDemand.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageInfoOnDemand.java new file mode 100644 index 00000000000..c3659127589 --- /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/AtlasLineageInfoOnDemand.java @@ -0,0 +1,133 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasLineageInfoOnDemand controls dynamic lineage queries. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasLineageInfoOnDemand +{ + private boolean hasMoreInputs = false; + private boolean hasMoreOutputs = false; + private int inputRelationsCount = 0; + private int outputRelationsCount = 0; + private boolean isInputRelationsReachedLimit = false; + private boolean isOutputRelationsReachedLimit = false; + private AtlasLineageOnDemandConstraints onDemandConstraints = null; + + + public AtlasLineageInfoOnDemand() + { + } + + + public boolean getHasMoreInputs() + { + return hasMoreInputs; + } + + + public void setHasMoreInputs(boolean hasMoreInputs) + { + this.hasMoreInputs = hasMoreInputs; + } + + + public boolean getHasMoreOutputs() + { + return hasMoreOutputs; + } + + + public void setHasMoreOutputs(boolean hasMoreOutputs) + { + this.hasMoreOutputs = hasMoreOutputs; + } + + + public int getInputRelationsCount() + { + return inputRelationsCount; + } + + + public void setInputRelationsCount(int inputRelationsCount) + { + this.inputRelationsCount = inputRelationsCount; + } + + + public int getOutputRelationsCount() + { + return outputRelationsCount; + } + + + public void setOutputRelationsCount(int outputRelationsCount) + { + this.outputRelationsCount = outputRelationsCount; + } + + + public boolean getInputRelationsReachedLimit() + { + return isInputRelationsReachedLimit; + } + + + public void setInputRelationsReachedLimit(boolean inputRelationsReachedLimit) + { + isInputRelationsReachedLimit = inputRelationsReachedLimit; + } + + + public boolean isOutputRelationsReachedLimit() + { + return isOutputRelationsReachedLimit; + } + + + public void setOutputRelationsReachedLimit(boolean outputRelationsReachedLimit) + { + isOutputRelationsReachedLimit = outputRelationsReachedLimit; + } + + + public AtlasLineageOnDemandConstraints getOnDemandConstraints() + { + return onDemandConstraints; + } + + + public void setOnDemandConstraints(AtlasLineageOnDemandConstraints onDemandConstraints) + { + this.onDemandConstraints = onDemandConstraints; + } + + + @Override + public String toString() + { + return "AtlasLineageInfoOnDemand{" + + "hasMoreInputs=" + hasMoreInputs + + ", hasMoreOutputs=" + hasMoreOutputs + + ", inputRelationsCount=" + inputRelationsCount + + ", outputRelationsCount=" + outputRelationsCount + + ", isInputRelationsReachedLimit=" + isInputRelationsReachedLimit + + ", isOutputRelationsReachedLimit=" + isOutputRelationsReachedLimit + + ", onDemandConstraints=" + onDemandConstraints + + ", inputRelationsReachedLimit=" + getInputRelationsReachedLimit() + + ", outputRelationsReachedLimit=" + isOutputRelationsReachedLimit() + + '}'; + } +} 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/AtlasLineageOnDemandConstraints.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageOnDemandConstraints.java new file mode 100644 index 00000000000..7c1b6528280 --- /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/AtlasLineageOnDemandConstraints.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.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasLineageOnDemandConstraints provides constraints for lineage on demand. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasLineageOnDemandConstraints +{ + private AtlasLineageDirection direction = null; + private int inputRelationsLimit = 0; + private int outputRelationsLimit = 0; + private int depth = 0; + + + public AtlasLineageOnDemandConstraints() + { + } + + + public AtlasLineageDirection getDirection() + { + return direction; + } + + + public void setDirection(AtlasLineageDirection direction) + { + this.direction = direction; + } + + + public int getInputRelationsLimit() + { + return inputRelationsLimit; + } + + + public void setInputRelationsLimit(int inputRelationsLimit) + { + this.inputRelationsLimit = inputRelationsLimit; + } + + + public int getOutputRelationsLimit() + { + return outputRelationsLimit; + } + + + public void setOutputRelationsLimit(int outputRelationsLimit) + { + this.outputRelationsLimit = outputRelationsLimit; + } + + + public int getDepth() + { + return depth; + } + + + public void setDepth(int depth) + { + this.depth = depth; + } + + + @Override + public String toString() + { + return "AtlasLineageOnDemandConstraints{" + + "direction=" + direction + + ", inputRelationsLimit=" + inputRelationsLimit + + ", outputRelationsLimit=" + outputRelationsLimit + + ", depth=" + depth + + '}'; + } +} 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/AtlasLineageRelationship.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasLineageRelationship.java new file mode 100644 index 00000000000..24bbe96a269 --- /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/AtlasLineageRelationship.java @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasLineageRelationship describes a lineage relationship between two entities. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasLineageRelationship +{ + private String fromEntityId = null; + private String toEntityId = null; + private String relationshipId = null; + + + public AtlasLineageRelationship() + { + } + + + public String getFromEntityId() + { + return fromEntityId; + } + + + public void setFromEntityId(String fromEntityId) + { + this.fromEntityId = fromEntityId; + } + + + public String getToEntityId() + { + return toEntityId; + } + + + public void setToEntityId(String toEntityId) + { + this.toEntityId = toEntityId; + } + + + public String getRelationshipId() + { + return relationshipId; + } + + + public void setRelationshipId(String relationshipId) + { + this.relationshipId = relationshipId; + } + + + @Override + public String toString() + { + return "AtlasLineageRelationship{" + + "fromEntityId='" + fromEntityId + '\'' + + ", toEntityId='" + toEntityId + '\'' + + ", relationshipId='" + relationshipId + '\'' + + '}'; + } +} 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/AtlasObjectId.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasObjectId.java new file mode 100644 index 00000000000..57840bfddde --- /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/AtlasObjectId.java @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasObjectId describes a reference to an Atlas entity instance. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasObjectId +{ + public static final String KEY_GUID = "guid"; + public static final String KEY_TYPENAME = "typeName"; + public static final String KEY_UNIQUE_ATTRIBUTES = "uniqueAttributes"; + + private String guid; + private String typeName; + private Map uniqueAttributes; + + + public AtlasObjectId() + { + } + + + public String getGuid() + { + return guid; + } + + + public void setGuid(String guid) + { + this.guid = guid; + } + + + public String getTypeName() + { + return typeName; + } + + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + + public Map getUniqueAttributes() + { + return uniqueAttributes; + } + + + public void setUniqueAttributes(Map uniqueAttributes) + { + this.uniqueAttributes = uniqueAttributes; + } + + + @Override + public String toString() + { + return "AtlasObjectId{" + + "guid='" + guid + '\'' + + ", typeName='" + typeName + '\'' + + ", uniqueAttributes=" + uniqueAttributes + + '}'; + } +} 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/AtlasOperator.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasOperator.java new file mode 100644 index 00000000000..2b1de56f8a9 --- /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/AtlasOperator.java @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.HashMap; +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasOperator is used in the formulations of queries. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasOperator +{ + LT(new String[]{"<", "lt"}), + GT(new String[]{">", "gt"}), + LTE(new String[]{"<=", "lte"}), + GTE(new String[]{">=", "gte"}), + EQ(new String[]{"=", "eq"}), + NEQ(new String[]{"!=", "neq"}), + IN(new String[]{"in", "IN"}), + LIKE(new String[]{"like", "LIKE"}), + STARTS_WITH(new String[]{"startsWith", "STARTSWITH", "begins_with", "BEGINS_WITH"}), + ENDS_WITH(new String[]{"endsWith", "ENDSWITH", "ends_with", "ENDS_WITH"}), + CONTAINS(new String[]{"contains", "CONTAINS"}), + NOT_CONTAINS(new String[]{"not_contains", "NOT_CONTAINS"}), + CONTAINS_ANY(new String[]{"containsAny", "CONTAINSANY", "contains_any", "CONTAINS_ANY"}), + CONTAINS_ALL(new String[]{"containsAll", "CONTAINSALL", "contains_all", "CONTAINS_ALL"}), + IS_NULL(new String[]{"isNull", "ISNULL", "is_null", "IS_NULL"}), + NOT_NULL(new String[]{"notNull", "NOTNULL", "not_null", "NOT_NULL"}), + TIME_RANGE(new String[]{"timerange", "TIMERANGE", "time_range", "TIME_RANGE"}), + NOT_EMPTY(new String[]{"notEmpty", "NOTEMPTY", "not_empty", "NOT_EMPTY"}) + ; + + static final Map operatorsMap = new HashMap<>(); + + private final String[] symbols; + + static { + for (AtlasOperator operator : AtlasOperator.values()) + { + for (String s : operator.symbols) + { + operatorsMap.put(s, operator); + } + } + } + + AtlasOperator(String[] symbols) + { + this.symbols = symbols; + } + + public static AtlasOperator fromString(String symbol) + { + return operatorsMap.get(symbol); + } + + public String getSymbol() + { + return symbols[0]; + } + + public String[] getSymbols() + { + return symbols; + } + + @Override + public String toString() + { + return getSymbol(); + } + +} 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/AtlasPropagateTags.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasPropagateTags.java new file mode 100644 index 00000000000..93749e16ea6 --- /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/AtlasPropagateTags.java @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasPropagateTags defines whether tags (Atlas classifications) are propagated along a relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasPropagateTags +{ + /** + * Do not propagate tags through relationship + */ + NONE, + + /** + * Propagate tags found on the entity at end1 to the entity found at end2. + */ + ONE_TO_TWO, + + /** + * Propagate tags found on the entity at end2 to the entity found at end1. + */ + TWO_TO_ONE, + + /** + * Propagate tags in both directions. + */ + BOTH +} 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/AtlasQueryType.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasQueryType.java new file mode 100644 index 00000000000..e1174dcf8fc --- /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/AtlasQueryType.java @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasQueryType describes the different types of query interfaces provided by Apache Atlas. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasQueryType +{ + DSL, + FULL_TEXT, + GREMLIN, + BASIC, + ATTRIBUTE, + RELATIONSHIP; +} 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/AtlasRelatedObjectId.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelatedObjectId.java new file mode 100644 index 00000000000..60e2471272c --- /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/AtlasRelatedObjectId.java @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelatedObjectId describes an entity related by a relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasRelatedObjectId extends AtlasObjectId +{ + public static final String KEY_RELATIONSHIP_TYPE = "relationshipType"; + public static final String KEY_RELATIONSHIP_GUID = "relationshipGuid"; + public static final String KEY_RELATIONSHIP_STATUS = "relationshipStatus"; + public static final String KEY_RELATIONSHIP_ATTRIBUTES = "relationshipAttributes"; + + private AtlasInstanceStatus entityStatus = null; + private String displayText = null; + private String relationshipType = null; + private String relationshipGuid = null; + private AtlasInstanceStatus relationshipStatus = null; + private AtlasStruct relationshipAttributes = null; + private String qualifiedName = null; + + + public AtlasRelatedObjectId() + { + } + + + public AtlasInstanceStatus getEntityStatus() + { + return entityStatus; + } + + + public void setEntityStatus(AtlasInstanceStatus entityStatus) + { + this.entityStatus = entityStatus; + } + + + public String getDisplayText() + { + return displayText; + } + + + public void setDisplayText(String displayText) + { + this.displayText = displayText; + } + + + public String getRelationshipType() + { + return relationshipType; + } + + + public void setRelationshipType(String relationshipType) + { + this.relationshipType = relationshipType; + } + + + public String getRelationshipGuid() + { + return relationshipGuid; + } + + + public void setRelationshipGuid(String relationshipGuid) + { + this.relationshipGuid = relationshipGuid; + } + + + public AtlasInstanceStatus getRelationshipStatus() + { + return relationshipStatus; + } + + + public void setRelationshipStatus(AtlasInstanceStatus relationshipStatus) + { + this.relationshipStatus = relationshipStatus; + } + + + public AtlasStruct getRelationshipAttributes() + { + return relationshipAttributes; + } + + + public void setRelationshipAttributes(AtlasStruct relationshipAttributes) + { + this.relationshipAttributes = relationshipAttributes; + } + + + public String getQualifiedName() + { + return qualifiedName; + } + + + public void setQualifiedName(String qualifiedName) + { + this.qualifiedName = qualifiedName; + } + + + @Override + public String toString() + { + return "AtlasRelatedObjectId{" + + "entityStatus=" + entityStatus + + ", displayText='" + displayText + '\'' + + ", relationshipType='" + relationshipType + '\'' + + ", relationshipGuid='" + relationshipGuid + '\'' + + ", relationshipStatus=" + relationshipStatus + + ", relationshipAttributes=" + relationshipAttributes + + ", qualifiedName='" + qualifiedName + '\'' + + ", guid='" + getGuid() + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", uniqueAttributes=" + getUniqueAttributes() + + '}'; + } +} 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 new file mode 100644 index 00000000000..fcf94cd8425 --- /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/AtlasRelationship.java @@ -0,0 +1,263 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Date; +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelationship describes a relationship instance in Apache Atlas. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasRelationship +{ + public static final String KEY_GUID = "guid"; + public static final String KEY_HOME_ID = "homeId"; + public static final String KEY_PROVENANCE_TYPE = "provenanceType"; + public static final String KEY_STATUS = "status"; + public static final String KEY_CREATED_BY = "createdBy"; + public static final String KEY_UPDATED_BY = "updatedBy"; + public static final String KEY_CREATE_TIME = "createTime"; + public static final String KEY_UPDATE_TIME = "updateTime"; + public static final String KEY_VERSION = "version"; + public static final String KEY_END1 = "end1"; + public static final String KEY_END2 = "end2"; + public static final String KEY_LABEL = "label"; + public static final String KEY_PROPAGATE_TAGS = "propagateTags"; + + public static final String KEY_BLOCKED_PROPAGATED_CLASSIFICATIONS = "blockedPropagatedClassifications"; + public static final String KEY_PROPAGATED_CLASSIFICATIONS = "propagatedClassifications"; + + private String guid = null; + private String homeId = null; + private Integer provenanceType = null; + private AtlasObjectId end1 = null; + private AtlasObjectId end2 = null; + private String label = null; + private AtlasPropagateTags propagateTags = AtlasPropagateTags.NONE; + private AtlasInstanceStatus status = AtlasInstanceStatus.ACTIVE; + private String createdBy = null; + private String updatedBy = null; + private Date createTime = null; + private Date updateTime = null; + private long version = 0L; + private Set propagatedClassifications = null; + private Set blockedPropagatedClassifications = null; + + + public AtlasRelationship() + { + } + + + public String getGuid() + { + return guid; + } + + + public void setGuid(String guid) + { + this.guid = guid; + } + + + public String getHomeId() + { + return homeId; + } + + + public void setHomeId(String homeId) + { + this.homeId = homeId; + } + + + public Integer getProvenanceType() + { + return provenanceType; + } + + + public void setProvenanceType(Integer provenanceType) + { + this.provenanceType = provenanceType; + } + + + public AtlasObjectId getEnd1() + { + return end1; + } + + + public void setEnd1(AtlasObjectId end1) + { + this.end1 = end1; + } + + + public AtlasObjectId getEnd2() + { + return end2; + } + + + public void setEnd2(AtlasObjectId end2) + { + this.end2 = end2; + } + + + public String getLabel() + { + return label; + } + + + public void setLabel(String label) + { + this.label = label; + } + + + public AtlasPropagateTags getPropagateTags() + { + return propagateTags; + } + + + public void setPropagateTags(AtlasPropagateTags propagateTags) + { + this.propagateTags = propagateTags; + } + + + public AtlasInstanceStatus getStatus() + { + return status; + } + + + public void setStatus(AtlasInstanceStatus status) + { + this.status = status; + } + + + public String getCreatedBy() + { + return createdBy; + } + + + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + + public String getUpdatedBy() + { + return updatedBy; + } + + + public void setUpdatedBy(String updatedBy) + { + this.updatedBy = updatedBy; + } + + + public Date getCreateTime() + { + return createTime; + } + + + public void setCreateTime(Date createTime) + { + this.createTime = createTime; + } + + + public Date getUpdateTime() + { + return updateTime; + } + + + public void setUpdateTime(Date updateTime) + { + this.updateTime = updateTime; + } + + + public long getVersion() + { + return version; + } + + + public void setVersion(long version) + { + this.version = version; + } + + + public Set getPropagatedClassifications() + { + return propagatedClassifications; + } + + + public void setPropagatedClassifications(Set propagatedClassifications) + { + this.propagatedClassifications = propagatedClassifications; + } + + + public Set getBlockedPropagatedClassifications() + { + return blockedPropagatedClassifications; + } + + + public void setBlockedPropagatedClassifications(Set blockedPropagatedClassifications) + { + this.blockedPropagatedClassifications = blockedPropagatedClassifications; + } + + + @Override + public String toString() + { + return "AtlasRelationship{" + + "guid='" + guid + '\'' + + ", homeId='" + homeId + '\'' + + ", provenanceType=" + provenanceType + + ", end1=" + end1 + + ", end2=" + end2 + + ", label='" + label + '\'' + + ", propagateTags=" + propagateTags + + ", status=" + status + + ", createdBy='" + createdBy + '\'' + + ", updatedBy='" + updatedBy + '\'' + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", version=" + version + + ", propagatedClassifications=" + propagatedClassifications + + ", blockedPropagatedClassifications=" + blockedPropagatedClassifications + + '}'; + } +} 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/AtlasRelationshipAttributeDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipAttributeDef.java new file mode 100644 index 00000000000..f0d0b8dbfd6 --- /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/AtlasRelationshipAttributeDef.java @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelationshipAttributeDef describes an attribute introduced to an entity via a relationshipDef + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasRelationshipAttributeDef extends AtlasAttributeDef +{ + private String relationshipTypeName; + private boolean isLegacyAttribute; + + + public AtlasRelationshipAttributeDef() + { + } + + + public String getRelationshipTypeName() + { + return relationshipTypeName; + } + + + public void setRelationshipTypeName(String relationshipTypeName) + { + this.relationshipTypeName = relationshipTypeName; + } + + + public boolean isLegacyAttribute() + { + return isLegacyAttribute; + } + + + public void setLegacyAttribute(boolean legacyAttribute) + { + isLegacyAttribute = legacyAttribute; + } + + + @Override + public String toString() + { + return "AtlasRelationshipAttributeDef{" + + "relationshipTypeName='" + relationshipTypeName + '\'' + + ", isLegacyAttribute=" + isLegacyAttribute + + ", legacyAttribute=" + isLegacyAttribute() + + ", name='" + getName() + '\'' + + ", typeName='" + getTypeName() + '\'' + + ", optional=" + isOptional() + + ", cardinality=" + getCardinality() + + ", valuesMinCount=" + getValuesMinCount() + + ", valuesMaxCount=" + getValuesMaxCount() + + ", unique=" + isUnique() + + ", indexable=" + isIndexable() + + ", includeInNotification=" + isIncludeInNotification() + + ", defaultValue='" + getDefaultValue() + '\'' + + ", description='" + getDescription() + '\'' + + ", searchWeight=" + getSearchWeight() + + ", indexType=" + getIndexType() + + ", constraints=" + getConstraints() + + ", options=" + getOptions() + + ", displayName='" + getDisplayName() + '\'' + + '}'; + } +} 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/AtlasRelationshipCategory.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipCategory.java new file mode 100644 index 00000000000..06f58a46973 --- /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/AtlasRelationshipCategory.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; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelationshipCategory describes any implied lifecycle relationship between entities linked via a relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasRelationshipCategory +{ + /** + * Composition (part of) relationship + */ + COMPOSITION, + + /** + * Aggregation relationship + */ + AGGREGATION, + + /** + * Association relationship + */ + ASSOCIATION +} 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/AtlasRelationshipDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipDef.java new file mode 100644 index 00000000000..8be66b2e6f1 --- /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/AtlasRelationshipDef.java @@ -0,0 +1,145 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelationshipDef describes a relationship between two entities. + *

+ * As with other typeDefs the AtlasRelationshipDef has a name. Once created the RelationshipDef has a guid. + * The name and the guid are the 2 ways that the RelationshipDef is identified. + *

+ * RelationshipDefs have 2 ends, each of which specify cardinality, an EntityDef type name and name and optionally + * whether the end is a container. + *

+ * RelationshipDefs can have AttributeDefs - though only primitive types are allowed.
+ * RelationshipDefs have an AtlasRelationshipCategory specifying the UML type of relationship required
+ * RelationshipDefs also have an AtlasPropagateTag - indicating which way tags could flow over the relationships. + *

+ * The way EntityDefs and RelationshipDefs are intended to be used is that EntityDefs will define AttributeDefs these AttributeDefs + * will not specify an EntityDef type name as their types. + *

+ * RelationshipDefs introduce new attributes to the entity instances. For example + *

+ * EntityDef A might have attributes attr1,attr2,attr3
+ * EntityDef B might have attributes attr4,attr5,attr6
+ * RelationshipDef AtoB might define 2 ends
+ * + *

+ *   end1:  type A, name attr7
+ *   end2:  type B, name attr8  
+ * + *

+ * When an instance of EntityDef A is created, it will have attributes attr1,attr2,attr3,attr7
+ * When an instance of EntityDef B is created, it will have attributes attr4,attr5,attr6,attr8 + *

+ * In this way relationshipDefs can be authored separately from entityDefs and can inject relationship attributes into + * the entity instances. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasRelationshipDef extends AtlasTypeDefBase +{ + private AtlasRelationshipCategory relationshipCategory = null; + private String relationshipLabel = null; + private AtlasPropagateTags propagateTags = null; + private AtlasRelationshipEndDef endDef1 = null; + private AtlasRelationshipEndDef endDef2 = null; + + + public AtlasRelationshipDef() + { + } + + + public AtlasRelationshipCategory getRelationshipCategory() + { + return relationshipCategory; + } + + + public void setRelationshipCategory( + AtlasRelationshipCategory relationshipCategory) + { + this.relationshipCategory = relationshipCategory; + } + + + public String getRelationshipLabel() + { + return relationshipLabel; + } + + + public void setRelationshipLabel(String relationshipLabel) + { + this.relationshipLabel = relationshipLabel; + } + + + public AtlasPropagateTags getPropagateTags() + { + return propagateTags; + } + + + public void setPropagateTags(AtlasPropagateTags propagateTags) + { + this.propagateTags = propagateTags; + } + + + public AtlasRelationshipEndDef getEndDef1() + { + return endDef1; + } + + + public void setEndDef1(AtlasRelationshipEndDef endDef1) + { + this.endDef1 = endDef1; + } + + + public AtlasRelationshipEndDef getEndDef2() + { + return endDef2; + } + + + public void setEndDef2(AtlasRelationshipEndDef endDef2) + { + this.endDef2 = endDef2; + } + + + @Override + public String toString() + { + return "AtlasRelationshipDef{" + + "relationshipCategory=" + relationshipCategory + + ", relationshipLabel='" + relationshipLabel + '\'' + + ", propagateTags=" + propagateTags + + ", endDef1=" + endDef1 + + ", endDef2=" + endDef2 + + ", category=" + getCategory() + + ", guid='" + getGuid() + '\'' + + ", createdBy='" + getCreatedBy() + '\'' + + ", updateBy='" + getUpdateBy() + '\'' + + ", createTime=" + getCreateTime() + + ", updateTime=" + getUpdateTime() + + ", version=" + getVersion() + + ", name='" + getName() + '\'' + + ", description='" + getDescription() + '\'' + + ", typeVersion='" + getTypeVersion() + '\'' + + ", serviceType='" + getServiceType() + '\'' + + '}'; + } +} 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/AtlasRelationshipEndDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipEndDef.java new file mode 100644 index 00000000000..43173e05d01 --- /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/AtlasRelationshipEndDef.java @@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelationshipEndDef describes the entity at one end of a relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasRelationshipEndDef +{ + /** + * The type associated with the end. + */ + private String type = null; + /** + * The name of the attribute for this end + */ + private String name = null; + + /** + * When set this indicates that this end is the container end + */ + private boolean isContainer = false; + /** + * This is the cardinality of the end + */ + private AtlasCardinality cardinality = null; + /** + * When set this indicates that this end is a legacy attribute + */ + private boolean isLegacyAttribute = false; + /** + * Description of the end + */ + private String description = null; + + + public AtlasRelationshipEndDef() + { + } + + + public String getType() + { + return type; + } + + + public void setType(String type) + { + this.type = type; + } + + + public String getName() + { + return name; + } + + + public void setName(String name) + { + this.name = name; + } + + + public boolean isContainer() + { + return isContainer; + } + + + public void setContainer(boolean container) + { + isContainer = container; + } + + + public AtlasCardinality getCardinality() + { + return cardinality; + } + + + public void setCardinality(AtlasCardinality cardinality) + { + this.cardinality = cardinality; + } + + + public boolean isLegacyAttribute() + { + return isLegacyAttribute; + } + + + public void setLegacyAttribute(boolean legacyAttribute) + { + isLegacyAttribute = legacyAttribute; + } + + + public String getDescription() + { + return description; + } + + + public void setDescription(String description) + { + this.description = description; + } +} 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/AtlasRelationshipHeader.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasRelationshipHeader.java new file mode 100644 index 00000000000..d25da2d7eb3 --- /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/AtlasRelationshipHeader.java @@ -0,0 +1,119 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasRelationshipHeader contains a summary of a relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasRelationshipHeader extends AtlasStruct +{ + private String guid = null; + private AtlasInstanceStatus status = AtlasInstanceStatus.ACTIVE; + private AtlasPropagateTags propagateTags = AtlasPropagateTags.NONE; + private String label = null; + private AtlasObjectId end1 = null; + private AtlasObjectId end2 = null; + + + public AtlasRelationshipHeader() + { + } + + + public String getGuid() + { + return guid; + } + + + public void setGuid(String guid) + { + this.guid = guid; + } + + + public AtlasInstanceStatus getStatus() + { + return status; + } + + + public void setStatus(AtlasInstanceStatus status) + { + this.status = status; + } + + + public AtlasPropagateTags getPropagateTags() + { + return propagateTags; + } + + + public void setPropagateTags(AtlasPropagateTags propagateTags) + { + this.propagateTags = propagateTags; + } + + + public String getLabel() + { + return label; + } + + + public void setLabel(String label) + { + this.label = label; + } + + + public AtlasObjectId getEnd1() + { + return end1; + } + + + public void setEnd1(AtlasObjectId end1) + { + this.end1 = end1; + } + + + public AtlasObjectId getEnd2() + { + return end2; + } + + + public void setEnd2(AtlasObjectId end2) + { + this.end2 = end2; + } + + + @Override + public String toString() + { + return "AtlasRelationshipHeader{" + + "guid='" + guid + '\'' + + ", status=" + status + + ", propagateTags=" + propagateTags + + ", label='" + label + '\'' + + ", end1=" + end1 + + ", end2=" + end2 + + ", typeName='" + getTypeName() + '\'' + + ", attributes=" + getAttributes() + + '}'; + } +} 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/AtlasSearchParameters.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasSearchParameters.java new file mode 100644 index 00000000000..5c88a17479e --- /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/AtlasSearchParameters.java @@ -0,0 +1,307 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Set; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasSearchParameters describes a query request to Apache Atlas. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasSearchParameters +{ + public static final String WILDCARD_CLASSIFICATIONS = "*"; + public static final String ALL_CLASSIFICATIONS = "_CLASSIFIED"; + public static final String NO_CLASSIFICATIONS = "_NOT_CLASSIFIED"; + public static final String ALL_ENTITY_TYPES = "_ALL_ENTITY_TYPES"; + public static final String ALL_CLASSIFICATION_TYPES = "_ALL_CLASSIFICATION_TYPES"; + + private String query = null; + private String typeName = null; + private String classification = null; + private String relationshipName = null; + private String termName = null; + private String sortBy = null; + private boolean excludeDeletedEntities = true; + private boolean includeClassificationAttributes = false; + private boolean includeSubTypes = true; + private boolean includeSubClassifications = true; + private boolean excludeHeaderAttributes = false; + private int limit = 0; + private int offset = 0; + private String marker = null; + private AtlasFilterCriteria entityFilters = null; + private AtlasFilterCriteria tagFilters = null; + private AtlasFilterCriteria relationshipFilters = null; + private Set attributes = null; + private AtlasSortOrder sortOrder = null; + + + public AtlasSearchParameters() + { + } + + + public String getQuery() + { + return query; + } + + + public void setQuery(String query) + { + this.query = query; + } + + + public String getTypeName() + { + return typeName; + } + + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + + public String getClassification() + { + return classification; + } + + + public void setClassification(String classification) + { + this.classification = classification; + } + + + public String getRelationshipName() + { + return relationshipName; + } + + + public void setRelationshipName(String relationshipName) + { + this.relationshipName = relationshipName; + } + + + public String getTermName() + { + return termName; + } + + + public void setTermName(String termName) + { + this.termName = termName; + } + + + public String getSortBy() + { + return sortBy; + } + + + public void setSortBy(String sortBy) + { + this.sortBy = sortBy; + } + + + public boolean isExcludeDeletedEntities() + { + return excludeDeletedEntities; + } + + + public void setExcludeDeletedEntities(boolean excludeDeletedEntities) + { + this.excludeDeletedEntities = excludeDeletedEntities; + } + + + public boolean isIncludeClassificationAttributes() + { + return includeClassificationAttributes; + } + + + public void setIncludeClassificationAttributes(boolean includeClassificationAttributes) + { + this.includeClassificationAttributes = includeClassificationAttributes; + } + + + public boolean isIncludeSubTypes() + { + return includeSubTypes; + } + + + public void setIncludeSubTypes(boolean includeSubTypes) + { + this.includeSubTypes = includeSubTypes; + } + + + public boolean isIncludeSubClassifications() + { + return includeSubClassifications; + } + + + public void setIncludeSubClassifications(boolean includeSubClassifications) + { + this.includeSubClassifications = includeSubClassifications; + } + + + public boolean isExcludeHeaderAttributes() + { + return excludeHeaderAttributes; + } + + + public void setExcludeHeaderAttributes(boolean excludeHeaderAttributes) + { + this.excludeHeaderAttributes = excludeHeaderAttributes; + } + + + public int getLimit() + { + return limit; + } + + + public void setLimit(int limit) + { + this.limit = limit; + } + + + public int getOffset() + { + return offset; + } + + + public void setOffset(int offset) + { + this.offset = offset; + } + + + public String getMarker() + { + return marker; + } + + + public void setMarker(String marker) + { + this.marker = marker; + } + + + public AtlasFilterCriteria getEntityFilters() + { + return entityFilters; + } + + + public void setEntityFilters(AtlasFilterCriteria entityFilters) + { + this.entityFilters = entityFilters; + } + + + public AtlasFilterCriteria getTagFilters() + { + return tagFilters; + } + + + public void setTagFilters(AtlasFilterCriteria tagFilters) + { + this.tagFilters = tagFilters; + } + + + public AtlasFilterCriteria getRelationshipFilters() + { + return relationshipFilters; + } + + + public void setRelationshipFilters(AtlasFilterCriteria relationshipFilters) + { + this.relationshipFilters = relationshipFilters; + } + + + public Set getAttributes() + { + return attributes; + } + + + public void setAttributes(Set attributes) + { + this.attributes = attributes; + } + + + public AtlasSortOrder getSortOrder() + { + return sortOrder; + } + + + public void setSortOrder(AtlasSortOrder sortOrder) + { + this.sortOrder = sortOrder; + } + + + @Override + public String toString() + { + return "AtlasSearchParameters{" + + "query='" + query + '\'' + + ", typeName='" + typeName + '\'' + + ", classification='" + classification + '\'' + + ", relationshipName='" + relationshipName + '\'' + + ", termName='" + termName + '\'' + + ", sortBy='" + sortBy + '\'' + + ", excludeDeletedEntities=" + excludeDeletedEntities + + ", includeClassificationAttributes=" + includeClassificationAttributes + + ", includeSubTypes=" + includeSubTypes + + ", includeSubClassifications=" + includeSubClassifications + + ", excludeHeaderAttributes=" + excludeHeaderAttributes + + ", limit=" + limit + + ", offset=" + offset + + ", marker='" + marker + '\'' + + ", entityFilters=" + entityFilters + + ", tagFilters=" + tagFilters + + ", relationshipFilters=" + relationshipFilters + + ", attributes=" + attributes + + ", sortOrder=" + sortOrder + + '}'; + } +} 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/AtlasSearchResult.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasSearchResult.java new file mode 100644 index 00000000000..23dd9e085a6 --- /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/AtlasSearchResult.java @@ -0,0 +1,206 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasSearchResult describes the response structure for an Atlas search request. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasSearchResult +{ + private AtlasQueryType queryType = null; + private AtlasSearchParameters searchParameters = null; + private String queryText = null; + private String type = null; + private String classification = null; + private List entities = null; + private List relations = null; + private AtlasAttributeSearchResult attributes = null; + private List fullTextResult = null; + private Map referredEntities = null; + private long approximateCount = - 1; + private String nextMarker = null; + + + public AtlasSearchResult() + { + } + + + public AtlasQueryType getQueryType() + { + return queryType; + } + + + public void setQueryType(AtlasQueryType queryType) + { + this.queryType = queryType; + } + + + public AtlasSearchParameters getSearchParameters() + { + return searchParameters; + } + + + public void setSearchParameters(AtlasSearchParameters searchParameters) + { + this.searchParameters = searchParameters; + } + + + public String getQueryText() + { + return queryText; + } + + + public void setQueryText(String queryText) + { + this.queryText = queryText; + } + + + public String getType() + { + return type; + } + + + public void setType(String type) + { + this.type = type; + } + + + public String getClassification() + { + return classification; + } + + + public void setClassification(String classification) + { + this.classification = classification; + } + + + public List getEntities() + { + return entities; + } + + + public void setEntities(List entities) + { + this.entities = entities; + } + + + public List getRelations() + { + return relations; + } + + + public void setRelations(List relations) + { + this.relations = relations; + } + + + public AtlasAttributeSearchResult getAttributes() + { + return attributes; + } + + + public void setAttributes(AtlasAttributeSearchResult attributes) + { + this.attributes = attributes; + } + + + public List getFullTextResult() + { + return fullTextResult; + } + + + public void setFullTextResult( + List fullTextResult) + { + this.fullTextResult = fullTextResult; + } + + + public Map getReferredEntities() + { + return referredEntities; + } + + + public void setReferredEntities( + Map referredEntities) + { + this.referredEntities = referredEntities; + } + + + public long getApproximateCount() + { + return approximateCount; + } + + + public void setApproximateCount(long approximateCount) + { + this.approximateCount = approximateCount; + } + + + public String getNextMarker() + { + return nextMarker; + } + + + public void setNextMarker(String nextMarker) + { + this.nextMarker = nextMarker; + } + + + @Override + public String toString() + { + return "AtlasSearchResult{" + + "queryType=" + queryType + + ", searchParameters=" + searchParameters + + ", queryText='" + queryText + '\'' + + ", type='" + type + '\'' + + ", classification='" + classification + '\'' + + ", entities=" + entities + + ", relations=" + relations + + ", attributes=" + attributes + + ", fullTextResult=" + fullTextResult + + ", referredEntities=" + referredEntities + + ", approximateCount=" + approximateCount + + ", nextMarker='" + nextMarker + '\'' + + '}'; + } +} 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/AtlasSortOrder.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasSortOrder.java new file mode 100644 index 00000000000..f40864c8ba5 --- /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/AtlasSortOrder.java @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasSortOder defines the order of results returned from a query. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasSortOrder +{ + ASCENDING, + DESCENDING +} 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/AtlasStruct.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasStruct.java new file mode 100644 index 00000000000..d70816b909b --- /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/AtlasStruct.java @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.Map; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Provides the common properties for an Apache Atlas instance. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasStruct +{ + public static final String KEY_TYPENAME = "typeName"; + public static final String KEY_ATTRIBUTES = "attributes"; + + private String typeName = null; + private Map attributes = null; + + + public AtlasStruct() + { + } + + + public String getTypeName() + { + return typeName; + } + + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + + public Map getAttributes() + { + return attributes; + } + + + public void setAttributes(Map attributes) + { + this.attributes = attributes; + } + + + @Override + public String toString() + { + return "AtlasStruct{" + + "typeName='" + typeName + '\'' + + ", attributes=" + attributes + + '}'; + } +} 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/AtlasStructDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasStructDef.java new file mode 100644 index 00000000000..53e6a8b03fc --- /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/AtlasStructDef.java @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasStructDef describes a struct type and also acts as a base class for most type defs. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasStructDef extends AtlasTypeDefBase +{ + private List attributeDefs = null; + + + public AtlasStructDef() + { + } + + + public List getAttributeDefs() + { + return attributeDefs; + } + + + public void setAttributeDefs(List attributeDefs) + { + this.attributeDefs = attributeDefs; + } + + + @Override + public String toString() + { + return "AtlasStructDef{" + + "attributeDefs=" + attributeDefs + + ", category=" + getCategory() + + ", guid='" + getGuid() + '\'' + + ", createdBy='" + getCreatedBy() + '\'' + + ", updateBy='" + getUpdateBy() + '\'' + + ", createTime=" + getCreateTime() + + ", updateTime=" + getUpdateTime() + + ", version=" + getVersion() + + ", name='" + getName() + '\'' + + ", description='" + getDescription() + '\'' + + ", typeVersion='" + getTypeVersion() + '\'' + + ", serviceType='" + getServiceType() + '\'' + + '}'; + } +} 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/AtlasTermAssignmentHeader.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTermAssignmentHeader.java new file mode 100644 index 00000000000..54020e98031 --- /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/AtlasTermAssignmentHeader.java @@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTermAssignmentHeader describes a glossary term that is linked to an instance via a semantic assignment. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasTermAssignmentHeader +{ + private String termGuid = null; + private String relationGuid = null; + private String description = null; + private String displayText = null; + private String expression = null; + private String createdBy = null; + private String steward = null; + private String source = null; + private int confidence = 0; + private AtlasTermAssignmentStatus status = null; + private String qualifiedName = null; + + + public AtlasTermAssignmentHeader() + { + } + + + public String getTermGuid() + { + return termGuid; + } + + + public void setTermGuid(String termGuid) + { + this.termGuid = termGuid; + } + + + public String getRelationGuid() + { + return relationGuid; + } + + + public void setRelationGuid(String relationGuid) + { + this.relationGuid = relationGuid; + } + + + public String getDescription() + { + return description; + } + + + public void setDescription(String description) + { + this.description = description; + } + + + public String getDisplayText() + { + return displayText; + } + + + public void setDisplayText(String displayText) + { + this.displayText = displayText; + } + + + public String getExpression() + { + return expression; + } + + + public void setExpression(String expression) + { + this.expression = expression; + } + + + public String getCreatedBy() + { + return createdBy; + } + + + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + + public String getSteward() + { + return steward; + } + + + public void setSteward(String steward) + { + this.steward = steward; + } + + + public String getSource() + { + return source; + } + + + public void setSource(String source) + { + this.source = source; + } + + + public int getConfidence() + { + return confidence; + } + + + public void setConfidence(int confidence) + { + this.confidence = confidence; + } + + + public AtlasTermAssignmentStatus getStatus() + { + return status; + } + + + public void setStatus(AtlasTermAssignmentStatus status) + { + this.status = status; + } + + + public String getQualifiedName() + { + return qualifiedName; + } + + + public void setQualifiedName(String qualifiedName) + { + this.qualifiedName = qualifiedName; + } + + + @Override + public String toString() + { + return "AtlasTermAssignmentHeader{" + + "termGuid='" + termGuid + '\'' + + ", relationGuid='" + relationGuid + '\'' + + ", description='" + description + '\'' + + ", displayText='" + displayText + '\'' + + ", expression='" + expression + '\'' + + ", createdBy='" + createdBy + '\'' + + ", steward='" + steward + '\'' + + ", source='" + source + '\'' + + ", confidence=" + confidence + + ", status=" + status + + ", qualifiedName='" + qualifiedName + '\'' + + '}'; + } +} 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/AtlasTermAssignmentStatus.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTermAssignmentStatus.java new file mode 100644 index 00000000000..2c6048b1083 --- /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/AtlasTermAssignmentStatus.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.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTermAssignmentStatus describes the status of a semantic assignment relationship. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasTermAssignmentStatus +{ + /** + * The assignment has been discovered by an automated process. + */ + DISCOVERED(0), + + /** + * The assignment has been proposed by a consumer. + */ + PROPOSED(1), + + /** + * The assignment has been imported from an external system. + */ + IMPORTED(2), + + /** + * The assignment has been validated by a subject-matter expert, + */ + VALIDATED(3), + + /** + * The assignment has been deprecated and should not be used. + */ + DEPRECATED(4), + + /** + * The assignment must not be used. + */ + OBSOLETE(5), + + /** + * Another assignment status. + */ + OTHER(6); + + private final int value; + + + /** + * Constructor. + * + * @param value integer value for the status. + */ + AtlasTermAssignmentStatus(final int value) + { + this.value = value; + } + + + /** + * Retrieve the value. + * + * @return int + */ + public int getValue() + { + return value; + } + + + @Override + public String toString() + { + return "AtlasTermAssignmentStatus{" + + "value=" + value + + '}'; + } +} 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/AtlasTermRelationshipStatus.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTermRelationshipStatus.java new file mode 100644 index 00000000000..05f50513242 --- /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/AtlasTermRelationshipStatus.java @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTermRelationshipStatus describes the status of a relationship between terms. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasTermRelationshipStatus +{ + /** + * The relationship has been proposed. + */ + DRAFT(0), + + /** + * The relationship is in use. + */ + ACTIVE(1), + + /** + * The relationship has been deprecated and should not be used. + */ + DEPRECATED(2), + + /** + * The relationship must not be used. + */ + OBSOLETE(3), + + /** + * Another relationship status. + */ + OTHER(99); + + private final int value; + + + /** + * Constructor. + * + * @param value integer value for the status. + */ + AtlasTermRelationshipStatus(final int value) + { + this.value = value; + } + + + /** + * Retrieve the value. + * + * @return int + */ + public int getValue() + { + return value; + } + + + @Override + public String toString() + { + return "AtlasTermRelationshipStatus{" + + "value=" + value + + '}'; + } +} 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/AtlasTimeBoundary.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTimeBoundary.java new file mode 100644 index 00000000000..8a0e7f475eb --- /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/AtlasTimeBoundary.java @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTimeBoundary describes the effective time for an Atlas entity. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasTimeBoundary +{ + public static final String TIME_FORMAT = "yyyy/MM/dd HH:mm:ss"; + + private String startTime; + private String endTime; + private String timeZone; // null for local-time; or a valid ID for TimeZone.getTimeZone(id) + + + public AtlasTimeBoundary() + { + } + + + public String getStartTime() + { + return startTime; + } + + + public void setStartTime(String startTime) + { + this.startTime = startTime; + } + + + public String getEndTime() + { + return endTime; + } + + + public void setEndTime(String endTime) + { + this.endTime = endTime; + } + + + public String getTimeZone() + { + return timeZone; + } + + + public void setTimeZone(String timeZone) + { + this.timeZone = timeZone; + } + + + @Override + public String toString() + { + return "AtlasTimeBoundary{" + + "startTime='" + startTime + '\'' + + ", endTime='" + endTime + '\'' + + ", timeZone='" + timeZone + '\'' + + '}'; + } +} 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/AtlasTypeCategory.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypeCategory.java new file mode 100644 index 00000000000..749f21a260f --- /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/AtlasTypeCategory.java @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTypeCategory describes the different categories of type definition supported by Apache Atlas. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public enum AtlasTypeCategory +{ + /** + * An enumeration type (EnumDef). + */ + ENUM, + + /** + * A structure - list of attribute types (StructDef) + */ + STRUCT, + + /** + * A tag with a list or map of attributes (ClassificationDef) + */ + CLASSIFICATION, + + /** + * An entity (EntityDef) + */ + ENTITY, + + /** + * A relationship between two entities (RelationshipDef) + */ + RELATIONSHIP, + + /** + * A collection of attributes to provide context to an entity. + */ + BUSINESS_METADATA +} 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 new file mode 100644 index 00000000000..367d021b3c2 --- /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/AtlasTypeDefBase.java @@ -0,0 +1,247 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTypeDefBase provides the common attributes found in all type definitions. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasTypeDefBase +{ + public static final String ATLAS_TYPE_BOOLEAN = "boolean"; + public static final String ATLAS_TYPE_BYTE = "byte"; + public static final String ATLAS_TYPE_SHORT = "short"; + public static final String ATLAS_TYPE_INT = "int"; + public static final String ATLAS_TYPE_LONG = "long"; + public static final String ATLAS_TYPE_FLOAT = "float"; + public static final String ATLAS_TYPE_DOUBLE = "double"; + public static final String ATLAS_TYPE_BIGINTEGER = "biginteger"; + public static final String ATLAS_TYPE_BIGDECIMAL = "bigdecimal"; + public static final String ATLAS_TYPE_STRING = "string"; + public static final String ATLAS_TYPE_DATE = "date"; + public static final String ATLAS_TYPE_OBJECT_ID = "objectid"; + + public static final String ATLAS_TYPE_ARRAY_PREFIX = "array<"; + public static final String ATLAS_TYPE_ARRAY_SUFFIX = ">"; + public static final String ATLAS_TYPE_MAP_PREFIX = "map<"; + public static final String ATLAS_TYPE_MAP_KEY_VAL_SEP = ","; + public static final String ATLAS_TYPE_MAP_SUFFIX = ">"; + + public static final String ATLAS_TYPE_PROCESS = "Process"; + public static final String ATLAS_TYPE_DATASET = "DataSet"; + public static final String ATLAS_TYPE_ASSET = "Asset"; + public static final String ATLAS_TYPE_INFRASTRUCTURE = "Infrastructure"; + + public static final String TYPEDEF_OPTION_SUPPORTS_SCHEMA = "supportsSchema"; + public static final String TYPEDEF_OPTION_SUPPORTS_PROFILE = "supportsProfile"; + + public static final String[] ATLAS_PRIMITIVE_TYPES = { + ATLAS_TYPE_BOOLEAN, + ATLAS_TYPE_BYTE, + ATLAS_TYPE_SHORT, + ATLAS_TYPE_INT, + ATLAS_TYPE_LONG, + ATLAS_TYPE_FLOAT, + ATLAS_TYPE_DOUBLE, + ATLAS_TYPE_BIGINTEGER, + ATLAS_TYPE_BIGDECIMAL, + ATLAS_TYPE_STRING, + }; + + /** + * The list of types that are valid for relationships. These are the + * primitive attributes and date. + */ + public static final String[] ATLAS_RELATIONSHIP_ATTRIBUTE_TYPES = { ATLAS_TYPE_BOOLEAN, + ATLAS_TYPE_BYTE, + ATLAS_TYPE_SHORT, + ATLAS_TYPE_INT, + ATLAS_TYPE_LONG, + ATLAS_TYPE_FLOAT, + ATLAS_TYPE_DOUBLE, + ATLAS_TYPE_BIGINTEGER, + ATLAS_TYPE_BIGDECIMAL, + ATLAS_TYPE_STRING, + ATLAS_TYPE_DATE + }; + + public static final String[] ATLAS_BUILTIN_TYPES = { + ATLAS_TYPE_BOOLEAN, + ATLAS_TYPE_BYTE, + ATLAS_TYPE_SHORT, + ATLAS_TYPE_INT, + ATLAS_TYPE_LONG, + ATLAS_TYPE_FLOAT, + ATLAS_TYPE_DOUBLE, + ATLAS_TYPE_BIGINTEGER, + ATLAS_TYPE_BIGDECIMAL, + ATLAS_TYPE_STRING, + + ATLAS_TYPE_DATE, + 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; + private String updateBy = null; + private long createTime = 0L; + private long updateTime = 0L; + private long version = 0L; + private String name = null; + private String description = null; + private String typeVersion = null; + private String serviceType = null; + + + /** + * Default constructor + */ + public AtlasTypeDefBase() + { + } + + + public AtlasTypeCategory getCategory() + { + return category; + } + + + public void setCategory(AtlasTypeCategory category) + { + this.category = category; + } + + + public String getGuid() + { + return guid; + } + + + public void setGuid(String guid) + { + this.guid = guid; + } + + + public String getCreatedBy() + { + return createdBy; + } + + + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + + public String getUpdateBy() + { + return updateBy; + } + + + public void setUpdateBy(String updateBy) + { + this.updateBy = updateBy; + } + + + public long getCreateTime() + { + return createTime; + } + + + public void setCreateTime(long createTime) + { + this.createTime = createTime; + } + + + public long getUpdateTime() + { + return updateTime; + } + + + public void setUpdateTime(long updateTime) + { + this.updateTime = updateTime; + } + + + public long getVersion() + { + return version; + } + + + public void setVersion(long version) + { + this.version = version; + } + + + public String getName() + { + return name; + } + + + public void setName(String name) + { + this.name = name; + } + + + public String getDescription() + { + return description; + } + + + public void setDescription(String description) + { + this.description = description; + } + + + public String getTypeVersion() + { + return typeVersion; + } + + + public void setTypeVersion(String typeVersion) + { + this.typeVersion = typeVersion; + } + + + public String getServiceType() + { + return serviceType; + } + + + public void setServiceType(String serviceType) + { + this.serviceType = serviceType; + } +} 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/AtlasTypesDef.java b/open-metadata-implementation/adapters/open-connectors/integration-connectors/atlas-integration-connector/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/apacheatlas/properties/AtlasTypesDef.java new file mode 100644 index 00000000000..9a6b12b711a --- /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/AtlasTypesDef.java @@ -0,0 +1,120 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.adapters.connectors.integration.apacheatlas.properties; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * AtlasTypesDef describes the gallery of types sent and returned to Apache Atlas. It is used to create now types, retrieve them and delete them. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class AtlasTypesDef +{ + private List enumDefs = null; + private List structDefs = null; + private List classificationDefs = null; + private List entityDefs = null; + private List relationshipDefs = null; + private List businessMetadataDefs = null; + + + public AtlasTypesDef() + { + } + + + public List getEnumDefs() + { + return enumDefs; + } + + + public void setEnumDefs(List enumDefs) + { + this.enumDefs = enumDefs; + } + + + public List getStructDefs() + { + return structDefs; + } + + + public void setStructDefs(List structDefs) + { + this.structDefs = structDefs; + } + + + public List getClassificationDefs() + { + return classificationDefs; + } + + + public void setClassificationDefs( + List classificationDefs) + { + this.classificationDefs = classificationDefs; + } + + + public List getEntityDefs() + { + return entityDefs; + } + + + public void setEntityDefs(List entityDefs) + { + this.entityDefs = entityDefs; + } + + + public List getRelationshipDefs() + { + return relationshipDefs; + } + + + public void setRelationshipDefs(List relationshipDefs) + { + this.relationshipDefs = relationshipDefs; + } + + + public List getBusinessMetadataDefs() + { + return businessMetadataDefs; + } + + + public void setBusinessMetadataDefs(List businessMetadataDefs) + { + this.businessMetadataDefs = businessMetadataDefs; + } + + + @Override + public String toString() + { + return "AtlasTypesDef{" + + "enumDefs=" + enumDefs + + ", structDefs=" + structDefs + + ", classificationDefs=" + classificationDefs + + ", entityDefs=" + entityDefs + + ", relationshipDefs=" + relationshipDefs + + ", businessMetadataDefs=" + businessMetadataDefs + + '}'; + } +} 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 28716ad8de2..0f8c6579433 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 @@ -23,7 +23,6 @@ * IntegrationContext is the base class for the integration context provided to the integration connector to provide access to open metadata * services. Each integration service specializes this class to provide the method appropriate for the particular type of technology it * is supporting. - * * This base class supports the common methods available to all types of integration connectors. */ public class IntegrationContext @@ -42,6 +41,7 @@ public class IntegrationContext protected final int maxPageSize; + private boolean isRefreshInProgress = false; /** * Constructor handles standard values for all integration contexts. @@ -324,6 +324,29 @@ public void publishReport() throws InvalidParameterException, } + /** + * Return whether there is a refresh in progress. This method is used in processEvent() to enable to connector to ignore + * events while it is running refresh() since many of the events are caused by the refresh process. Using this flag + * prevents the connector from processing the same elements multiple times. + * + * @return boolean flag + */ + public boolean isRefreshInProgress() + { + return isRefreshInProgress; + } + + + /** + * Set up whether the refresh is in progress or not. + * + * @param refreshInProgress boolean flag + */ + void setRefreshInProgress(boolean refreshInProgress) + { + isRefreshInProgress = refreshInProgress; + } + /** * Retrieve the anchorGUID from the Anchors classification. diff --git a/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContextRefreshProxy.java b/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContextRefreshProxy.java new file mode 100644 index 00000000000..2600237412f --- /dev/null +++ b/open-metadata-implementation/frameworks/open-integration-framework/src/main/java/org/odpi/openmetadata/frameworks/integration/context/IntegrationContextRefreshProxy.java @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.frameworks.integration.context; + +/** + * IntegrationContextRefreshProxy is used to provide a protected mechanism for the integration daemon to set + * isRefreshInProcess. + */ +public class IntegrationContextRefreshProxy +{ + private final IntegrationContext integrationContext; + + + /** + * Create the refresh proxy for an integration context. + * + * @param integrationContext context to support + */ + public IntegrationContextRefreshProxy(IntegrationContext integrationContext) + { + this.integrationContext = integrationContext; + } + + + /** + * Set up whether the refresh is in progress or not. + * + * @param refreshInProgress boolean flag + */ + public void setRefreshInProgress(boolean refreshInProgress) + { + this.integrationContext.setRefreshInProgress(refreshInProgress); + } +} From 2153c4c7b42ab889925124c53beeef272f916376 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 24 Jul 2023 09:52:11 +0100 Subject: [PATCH 3/5] Extend CTS repository workbench config Signed-off-by: Mandy Chessell --- .../IntegrationViewServiceConfig.java | 8 +++-- .../RepositoryConformanceWorkbenchConfig.java | 36 +++++++++++++++++-- .../properties/SolutionViewServiceConfig.java | 9 +++-- .../properties/ViewServiceConfig.java | 4 ++- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/IntegrationViewServiceConfig.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/IntegrationViewServiceConfig.java index 8553d2ffd54..58b349039d5 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/IntegrationViewServiceConfig.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/IntegrationViewServiceConfig.java @@ -8,13 +8,14 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import org.odpi.openmetadata.adminservices.configuration.registration.ViewServiceRegistrationEntry; +import java.io.Serial; import java.util.List; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; -/* +/** * The IntegrationViewServiceConfig class is a specialization of ViewServiceConfig for integration-level view services */ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @@ -25,7 +26,10 @@ include = JsonTypeInfo.As.PROPERTY, property = "class") -public class IntegrationViewServiceConfig extends ViewServiceConfig { +public class IntegrationViewServiceConfig extends ViewServiceConfig +{ + @Serial + private static final long serialVersionUID = 1L; private List resourceEndpoints; diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/RepositoryConformanceWorkbenchConfig.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/RepositoryConformanceWorkbenchConfig.java index 6a95cead359..f967ec97ff7 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/RepositoryConformanceWorkbenchConfig.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/RepositoryConformanceWorkbenchConfig.java @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serial; +import java.util.List; import java.util.Objects; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; @@ -21,10 +23,12 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class RepositoryConformanceWorkbenchConfig extends AdminServicesConfigHeader { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; - private String tutRepositoryServerName = null; - private int maxSearchResults = 50; + private String tutRepositoryServerName = null; + private int maxSearchResults = 50; + private List testEntityTypes = null; /** @@ -99,6 +103,32 @@ public void setMaxSearchResults(int maxSearchResults) } + /** + * Return the list of entity types to test. If the value is null then all known entities will be used. + * The names of the entities are used to drive the spawning of tests since the repository workbench aims to test + * each permutation of types. + * + * @return list of entity type names + */ + public List getTestEntityTypes() + { + return testEntityTypes; + } + + + /** + * Return the list of entity types to test. If the value is null then all known entities will be used. + * The names of the entities are used to drive the spawning of tests since the repository workbench aims to test + * each permutation of types. + * + * @param testEntityTypes list of entity type names (or null to test all types) + */ + public void setTestEntityTypes(List testEntityTypes) + { + this.testEntityTypes = testEntityTypes; + } + + /** * Standard toString method. * diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/SolutionViewServiceConfig.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/SolutionViewServiceConfig.java index 8d9d2f59569..e1f52ea4df7 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/SolutionViewServiceConfig.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/SolutionViewServiceConfig.java @@ -4,12 +4,16 @@ import org.odpi.openmetadata.adminservices.configuration.registration.ViewServiceRegistrationEntry; +import java.io.Serial; import java.util.Objects; -/* +/** * The SolutionViewServiceConfig class is a specialization of ViewServiceConfig for solution-level view services */ -public class SolutionViewServiceConfig extends ViewServiceConfig { +public class SolutionViewServiceConfig extends ViewServiceConfig +{ + @Serial + private static final long serialVersionUID = 1L; /* There are no additional properties yet */ @@ -20,6 +24,7 @@ public SolutionViewServiceConfig() { super(); } + /** * Copy/clone constructor * diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/ViewServiceConfig.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/ViewServiceConfig.java index c8ac5033cc2..e259d01018a 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/ViewServiceConfig.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/configuration/properties/ViewServiceConfig.java @@ -11,6 +11,7 @@ import org.odpi.openmetadata.adminservices.configuration.registration.ViewServiceRegistrationEntry; import org.odpi.openmetadata.frameworks.auditlog.ComponentDevelopmentStatus; +import java.io.Serial; import java.util.Map; import java.util.Objects; @@ -33,7 +34,8 @@ }) public class ViewServiceConfig extends OMAGServerClientConfig { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; private int viewServiceId = 0; private ComponentDevelopmentStatus viewServiceDevelopmentStatus = null; From 8deed8540e78835a04050168e47ec6f2579e8a27 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 24 Jul 2023 09:53:02 +0100 Subject: [PATCH 4/5] Update javadoc Signed-off-by: Mandy Chessell --- .../adminservices/rest/OMAGServerStatusResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/rest/OMAGServerStatusResponse.java b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/rest/OMAGServerStatusResponse.java index 3fe942d1e60..a0bf8bd0492 100644 --- a/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/rest/OMAGServerStatusResponse.java +++ b/open-metadata-implementation/admin-services/admin-services-api/src/main/java/org/odpi/openmetadata/adminservices/rest/OMAGServerStatusResponse.java @@ -19,9 +19,9 @@ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown=true) +@Deprecated public class OMAGServerStatusResponse extends AdminServicesAPIResponse { - private static final long serialVersionUID = 1L; private ServerServicesStatus serverServicesStatus = null; From b4a187444adab1ed622065404ea8c2476f61894d Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 24 Jul 2023 09:53:44 +0100 Subject: [PATCH 5/5] Notify context when refresh is running Signed-off-by: Mandy Chessell --- .../handlers/IntegrationConnectorHandler.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java index b8e96905abe..374d7adf95e 100644 --- a/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java +++ b/open-metadata-implementation/governance-servers/integration-daemon-services/integration-daemon-services-server/src/main/java/org/odpi/openmetadata/governanceservers/integrationdaemonservices/handlers/IntegrationConnectorHandler.java @@ -13,6 +13,7 @@ import org.odpi.openmetadata.frameworks.integration.connectors.IntegrationConnector; import org.odpi.openmetadata.frameworks.integration.connectors.IntegrationConnectorBase; import org.odpi.openmetadata.frameworks.integration.context.IntegrationContext; +import org.odpi.openmetadata.frameworks.integration.context.IntegrationContextRefreshProxy; import org.odpi.openmetadata.frameworks.integration.contextmanager.IntegrationContextManager; import org.odpi.openmetadata.frameworks.integration.contextmanager.PermittedSynchronization; import org.odpi.openmetadata.governanceservers.integrationdaemonservices.ffdc.IntegrationDaemonServicesAuditCode; @@ -47,13 +48,17 @@ public class IntegrationConnectorHandler private boolean needDedicatedThread; private long minMinutesBetweenRefresh; private final IntegrationContextManager contextManager; - private IntegrationContext integrationContext = null; private final AuditLog auditLog; + + + /* * These values change as the connector handler operates */ + private IntegrationContext integrationContext = null; + private IntegrationContextRefreshProxy integrationContextRefreshProxy = null; private Connector genericConnector = null; private IntegrationConnector integrationConnector = null; private IntegrationConnectorDedicatedThread integrationConnectorDedicatedThread = null; @@ -368,6 +373,8 @@ public synchronized void reinitializeConnector(String actionDescription) generateIntegrationReport, metadataSourceQualifiedName); + this.integrationContextRefreshProxy = new IntegrationContextRefreshProxy(this.integrationContext); + this.updateStatus(IntegrationConnectorStatus.INITIALIZED); } catch (Exception error) @@ -546,7 +553,9 @@ public synchronized void refreshConnector(String actionDescription, } integrationContext.startRecording(); + integrationContextRefreshProxy.setRefreshInProgress(true); integrationConnector.refresh(); + integrationContextRefreshProxy.setRefreshInProgress(false); integrationContext.publishReport(); if (auditLog != null)