http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java new file mode 100644 index 0000000..c12752a --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java @@ -0,0 +1,453 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events; + +import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1; +import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1TypeDefSection; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; + +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class OMRSTypeDefEvent extends OMRSEvent +{ + /* + * The type of the TypeDef event that defines how the rest of the values should be interpreted. + */ + private OMRSTypeDefEventType typeDefEventType = OMRSTypeDefEventType.UNKNOWN_TYPEDEF_EVENT; + + /* + * TypeDef specific properties. + */ + private AttributeTypeDef attributeTypeDef = null; + private TypeDef typeDef = null; + private String typeDefGUID = null; + private String typeDefName = null; + private TypeDefPatch typeDefPatch = null; + + /* + * TypeDef specific properties for events related to correcting conflicts in the open metadata repository + * cohort. + */ + private TypeDefSummary originalTypeDefSummary = null; + private AttributeTypeDef originalAttributeTypeDef = null; + + /* + * Specific variables only used in error reporting. It defines the subset of error codes from OMRSEvent + * that are specific to TypeDef events. + */ + private OMRSTypeDefEventErrorCode errorCode = OMRSTypeDefEventErrorCode.NOT_IN_USE; + + + private static final Logger log = LoggerFactory.getLogger(OMRSTypeDefEvent.class); + + /** + * Inbound event constructor that takes the object created by the Jackson JSON mapper and unpacks the + * properties into the instance event. + * + * @param inboundEvent - incoming Event. + */ + public OMRSTypeDefEvent(OMRSEventV1 inboundEvent) + { + super(inboundEvent); + + OMRSEventV1TypeDefSection typeDefSection = inboundEvent.getTypeDefEventSection(); + + if (typeDefSection != null) + { + this.typeDefEventType = typeDefSection.getTypeDefEventType(); + this.attributeTypeDef = typeDefSection.getAttributeTypeDef(); + this.typeDef = typeDefSection.getTypeDef(); + this.typeDefGUID = typeDefSection.getTypeDefGUID(); + this.typeDefName = typeDefSection.getTypeDefName(); + this.typeDefPatch = typeDefSection.getTypeDefPatch(); + this.originalTypeDefSummary = typeDefSection.getOriginalTypeDefSummary(); + this.originalAttributeTypeDef = typeDefSection.getOriginalAttributeTypeDef(); + } + + if (super.genericErrorCode != null) + { + switch(genericErrorCode) + { + case CONFLICTING_TYPEDEFS: + errorCode = OMRSTypeDefEventErrorCode.CONFLICTING_TYPEDEFS; + break; + + case CONFLICTING_ATTRIBUTE_TYPEDEFS: + errorCode = OMRSTypeDefEventErrorCode.CONFLICTING_ATTRIBUTE_TYPEDEFS; + + case TYPEDEF_PATCH_MISMATCH: + errorCode = OMRSTypeDefEventErrorCode.TYPEDEF_PATCH_MISMATCH; + break; + + default: + errorCode = OMRSTypeDefEventErrorCode.UNKNOWN_ERROR_CODE; + break; + } + } + } + + /** + * Outbound event constructor for events such as newTypeDef. + * + * @param typeDefEventType - type of event + * @param typeDef - Complete details of the TypeDef that is the subject of the event. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType, + TypeDef typeDef) + { + super(OMRSEventCategory.TYPEDEF); + + this.typeDefEventType = typeDefEventType; + this.typeDef = typeDef; + } + + + /** + * Outbound event constructor for events such as newAttributeTypeDef. + * + * @param typeDefEventType - type of event + * @param attributeTypeDef - Complete details of the AttributeTypeDef that is the subject of the event. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType, + AttributeTypeDef attributeTypeDef) + { + super(OMRSEventCategory.TYPEDEF); + + this.typeDefEventType = typeDefEventType; + this.attributeTypeDef = attributeTypeDef; + } + + + /** + * Outbound event constructor for events such as updates. + * + * @param typeDefEventType - type of event + * @param typeDefPatch - Complete details of the TypeDef that is the subject of the event. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType, + TypeDefPatch typeDefPatch) + { + super(OMRSEventCategory.TYPEDEF); + + this.typeDefEventType = typeDefEventType; + this.typeDefPatch = typeDefPatch; + } + + + /** + * Outbound event constructor for events such as deletes. + * + * @param typeDefEventType - type of event + * @param typeDefGUID - Unique identifier of the TypeDef that is the subject of the event. + * @param typeDefName - Unique name of the TypeDef that is the subject of the event. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType, + String typeDefGUID, + String typeDefName) + { + super(OMRSEventCategory.TYPEDEF); + + this.typeDefEventType = typeDefEventType; + this.typeDefGUID = typeDefGUID; + this.typeDefName = typeDefName; + } + + + /** + * Outbound event constructor for changing the identifiers associated with TypeDefs. + * + * @param typeDefEventType - type of event + * @param originalTypeDefSummary - description of the original TypeDef that is the subject of the event. + * @param typeDef - updated TypeDef with new identifiers + */ + public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType, + TypeDefSummary originalTypeDefSummary, + TypeDef typeDef) + { + super(OMRSEventCategory.TYPEDEF); + + this.typeDefEventType = typeDefEventType; + this.originalTypeDefSummary = originalTypeDefSummary; + this.typeDef = typeDef; + } + + + /** + * Outbound event constructor for changing the identifiers associated with AttributeTypeDefs. + * + * @param typeDefEventType - type of event + * @param originalAttributeTypeDef - description of the original AttributeTypeDef that is the subject of the event. + * @param attributeTypeDef - updated AttributeTypeDef with new identifiers + */ + public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType, + AttributeTypeDef originalAttributeTypeDef, + AttributeTypeDef attributeTypeDef) + { + super(OMRSEventCategory.TYPEDEF); + + this.typeDefEventType = typeDefEventType; + this.originalAttributeTypeDef = originalAttributeTypeDef; + this.attributeTypeDef = attributeTypeDef; + } + + + /** + * Outbound event constructor for conflicting typedef errors. + * + * @param errorCode - code enum indicating the cause of the error. + * @param errorMessage - descriptive message about the error. + * @param targetMetadataCollectionId - identifier of the cohort member that issued the event in error. + * @param targetTypeDefSummary - details of the TypeDef in the remote repository. + * @param otherTypeDefSummary - details of the TypeDef in the local repository. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventErrorCode errorCode, + String errorMessage, + String targetMetadataCollectionId, + TypeDefSummary targetTypeDefSummary, + TypeDefSummary otherTypeDefSummary) + { + super(OMRSEventCategory.TYPEDEF, + errorCode.getErrorCodeEncoding(), + errorMessage, + targetMetadataCollectionId, + targetTypeDefSummary, + otherTypeDefSummary); + + this.typeDefEventType = OMRSTypeDefEventType.TYPEDEF_ERROR_EVENT; + } + + + /** + * Outbound event constructor for conflicting attribute typedef errors. + * + * @param errorCode - code enum indicating the cause of the error. + * @param errorMessage - descriptive message about the error. + * @param targetMetadataCollectionId - identifier of the cohort member that issued the event in error. + * @param targetAttributeTypeDef - details of the TypeDef in the remote repository. + * @param otherAttributeTypeDef - details of the TypeDef in the local repository. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventErrorCode errorCode, + String errorMessage, + String targetMetadataCollectionId, + AttributeTypeDef targetAttributeTypeDef, + AttributeTypeDef otherAttributeTypeDef) + { + super(OMRSEventCategory.TYPEDEF, + errorCode.getErrorCodeEncoding(), + errorMessage, + targetMetadataCollectionId, + targetAttributeTypeDef, + targetAttributeTypeDef); + + this.typeDefEventType = OMRSTypeDefEventType.TYPEDEF_ERROR_EVENT; + } + + + + /** + * Outbound event constructor for typedef mismatch errors. + * + * @param errorCode - code enum indicating the cause of the error. + * @param errorMessage - descriptive message about the error. + * @param targetMetadataCollectionId - identifier of the cohort member that issued the event in error. + * @param targetTypeDefSummary - details of the TypeDef in the remote repository. + * @param otherTypeDef - details of the TypeDef in the local repository. + */ + public OMRSTypeDefEvent(OMRSTypeDefEventErrorCode errorCode, + String errorMessage, + String targetMetadataCollectionId, + TypeDefSummary targetTypeDefSummary, + TypeDef otherTypeDef) + { + super(OMRSEventCategory.TYPEDEF, + errorCode.getErrorCodeEncoding(), + errorMessage, + targetMetadataCollectionId, + targetTypeDefSummary, + otherTypeDef); + + this.typeDefEventType = OMRSTypeDefEventType.TYPEDEF_ERROR_EVENT; + } + + + /** + * Return the code for this event's type. + * + * @return OMRSTypeDefEventType enum + */ + public OMRSTypeDefEventType getTypeDefEventType() + { + return typeDefEventType; + } + + + /** + * Return the complete TypeDef object. + * + * @return TypeDef object + */ + public TypeDef getTypeDef() + { + return typeDef; + } + + + /** + * Return the complete AttributeTypeDef object. + * + * @return AttributeTypeDef object + */ + public AttributeTypeDef getAttributeTypeDef() + { + return attributeTypeDef; + } + + /** + * Return the unique id of the TypeDef. + * + * @return String guid + */ + public String getTypeDefGUID() + { + return typeDefGUID; + } + + + /** + * Return the unique name of the TypeDef. + * + * @return String name + */ + public String getTypeDefName() + { + return typeDefName; + } + + + /** + * Return a patch for the TypeDef. + * + * @return TypeDefPatch object + */ + public TypeDefPatch getTypeDefPatch() + { + return typeDefPatch; + } + + + /** + * Return the details of the TypeDef before it was changed. + * + * @return TypeDefSummary containing identifiers, category and version + */ + public TypeDefSummary getOriginalTypeDefSummary() + { + return originalTypeDefSummary; + } + + + /** + * Return the details of the AttributeTypeDef before it was changed. + * + * @return AttributeTypeDef object + */ + public AttributeTypeDef getOriginalAttributeTypeDef() + { + return originalAttributeTypeDef; + } + + /** + * Return the TypeDef error code for error events. + * + * @return OMRSTypeDefEventErrorCode enum + */ + public OMRSTypeDefEventErrorCode getErrorCode() + { + return errorCode; + } + + + /** + * Returns an OMRSEvent populated with details from this TypeDefEvent + * + * @return OMRSEvent (Version 1) object + */ + public OMRSEventV1 getOMRSEventV1() + { + OMRSEventV1 omrsEvent = super.getOMRSEventV1(); + + OMRSEventV1TypeDefSection typeDefSection = new OMRSEventV1TypeDefSection(); + + typeDefSection.setTypeDefEventType(this.typeDefEventType); + typeDefSection.setTypeDef(this.typeDef); + typeDefSection.setAttributeTypeDef(this.attributeTypeDef); + typeDefSection.setTypeDefPatch(this.typeDefPatch); + typeDefSection.setTypeDefGUID(this.typeDefGUID); + typeDefSection.setTypeDefName(this.typeDefName); + typeDefSection.setOriginalTypeDefSummary(this.originalTypeDefSummary); + typeDefSection.setOriginalAttributeTypeDef(this.originalAttributeTypeDef); + + omrsEvent.setTypeDefEventSection(typeDefSection); + + return omrsEvent; + } + + + /** + * Standard toString method. + * + * @return JSON style description of variables. + */ + @Override + public String toString() + { + return "OMRSTypeDefEvent{" + + "typeDefEventType=" + typeDefEventType + + ", attributeTypeDef=" + attributeTypeDef + + ", typeDef=" + typeDef + + ", typeDefGUID='" + typeDefGUID + '\'' + + ", typeDefName='" + typeDefName + '\'' + + ", typeDefPatch=" + typeDefPatch + + ", originalTypeDefSummary=" + originalTypeDefSummary + + ", originalAttributeTypeDef=" + originalAttributeTypeDef + + ", errorCode=" + errorCode + + ", eventTimestamp=" + eventTimestamp + + ", eventDirection=" + eventDirection + + ", eventCategory=" + eventCategory + + ", eventOriginator=" + eventOriginator + + ", genericErrorCode=" + genericErrorCode + + ", errorMessage='" + errorMessage + '\'' + + ", targetMetadataCollectionId='" + targetMetadataCollectionId + '\'' + + ", targetRemoteConnection=" + targetRemoteConnection + + ", targetTypeDefSummary=" + targetTypeDefSummary + + ", targetAttributeTypeDef=" + targetAttributeTypeDef + + ", targetInstanceGUID='" + targetInstanceGUID + '\'' + + ", otherOrigin=" + otherOrigin + + ", otherMetadataCollectionId='" + otherMetadataCollectionId + '\'' + + ", otherTypeDefSummary=" + otherTypeDefSummary + + ", otherTypeDef=" + otherTypeDef + + ", otherAttributeTypeDef=" + otherAttributeTypeDef + + ", otherInstanceGUID='" + otherInstanceGUID + '\'' + + '}'; + } +}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.java new file mode 100644 index 0000000..fd36108 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events; + +import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode; + +/** + * OMRSTypeDefEventErrorCode defines the list of error codes that are used to record errors in the TypeDef + * synchronization process that is used by the repository connectors within the open metadata repository cluster. + * <ul> + * <li> + * NOT_IN_USE - There has been no error detected and so the error code is not in use. + * </li> + * </ul> + */ +public enum OMRSTypeDefEventErrorCode +{ + NOT_IN_USE (0, "No Error", + "There has been no error detected and so the error code is not in use.", + null), + CONFLICTING_TYPEDEFS (1, "ConflictingTypeDefs", + "There are conflicting type definitions (TypeDefs) detected between two " + + "repositories in the open metadata repository cohort.", + OMRSEventErrorCode.CONFLICTING_TYPEDEFS), + CONFLICTING_ATTRIBUTE_TYPEDEFS (2, "ConflictingAttributeTypeDefs", + "There are conflicting attribute type definitions (AttributeTypeDefs) detected between two " + + "repositories in the open metadata repository cohort.", + OMRSEventErrorCode.CONFLICTING_ATTRIBUTE_TYPEDEFS), + TYPEDEF_PATCH_MISMATCH (3, "TypeDefPatchMismatch", + "There are different versions of a TypeDef in use in the cohort", + OMRSEventErrorCode.TYPEDEF_PATCH_MISMATCH), + UNKNOWN_ERROR_CODE (99, "Unknown Error Code", + "Unrecognized error code from incoming event.", + null); + + + private int errorCodeId; + private String errorCodeName; + private String errorCodeDescription; + private OMRSEventErrorCode errorCodeEncoding; + + + /** + * Default constructor sets up the values for this enum instance. + * + * @param errorCodeId - int identifier for the enum, used for indexing arrays etc with the enum. + * @param errorCodeName - String name for the enum, used for message content. + * @param errorCodeDescription - String default description for the enum, used when there is not natural + * language resource bundle available. + * @param errorCodeEncoding - code value to use in OMRSEvents + */ + OMRSTypeDefEventErrorCode(int errorCodeId, + String errorCodeName, + String errorCodeDescription, + OMRSEventErrorCode errorCodeEncoding) + { + this.errorCodeId = errorCodeId; + this.errorCodeName = errorCodeName; + this.errorCodeDescription = errorCodeDescription; + this.errorCodeEncoding = errorCodeEncoding; + } + + + /** + * Return the identifier for the enum, used for indexing arrays etc with the enum. + * + * @return int identifier + */ + public int getErrorCodeId() + { + return errorCodeId; + } + + + /** + * Return the name for the enum, used for message content. + * + * @return String name + */ + public String getErrorCodeName() + { + return errorCodeName; + } + + + /** + * Return the default description for the enum, used when there is not natural + * language resource bundle available. + * + * @return String default description + */ + public String getErrorCodeDescription() + { + return errorCodeDescription; + } + + + /** + * Return the encoding to use in OMRSEvents. + * + * @return String OMRSEvent encoding for this errorCode + */ + public OMRSEventErrorCode getErrorCodeEncoding() + { + return errorCodeEncoding; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java new file mode 100644 index 0000000..7cb2338 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java @@ -0,0 +1,262 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events; + +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +/** + * OMRSTypeDefEventProcessor is an interface implemented by a component that is able to process incoming + * TypeDef events for an Open Metadata Repository. TypeDef events are used to synchronize TypeDefs across + * an Open Metadata Repository Cohort. + */ +public interface OMRSTypeDefEventProcessor +{ + /** + * A new TypeDef has been defined in an open metadata repository. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDef - details of the new TypeDef. + */ + void processNewTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + TypeDef typeDef); + + + /** + * A new AttributeTypeDef has been defined in an open metadata repository. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param attributeTypeDef - details of the new AttributeTypeDef. + */ + void processNewAttributeTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + AttributeTypeDef attributeTypeDef); + + + /** + * An existing TypeDef has been updated in an open metadata repository. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefPatch - details of the new version of the TypeDef + */ + void processUpdatedTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + TypeDefPatch typeDefPatch); + + + /** + * An existing TypeDef has been deleted in an open metadata repository. Both the name and the + * GUID are provided to ensure the right TypeDef is deleted in other cohort member repositories. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param typeDefGUID - unique identifier of the TypeDef + * @param typeDefName - unique name of the TypeDef + */ + void processDeletedTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String typeDefGUID, + String typeDefName); + + + /** + * An existing AttributeTypeDef has been deleted in an open metadata repository. Both the name and the + * GUID are provided to ensure the right AttributeTypeDef is deleted in other cohort member repositories. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param attributeTypeDefGUID - unique identifier of the AttributeTypeDef + * @param attributeTypeDefName - unique name of the AttributeTypeDef + */ + void processDeletedAttributeTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String attributeTypeDefGUID, + String attributeTypeDefName); + + + /** + * Process an event that changes either the name or guid of a TypeDef. It is resolving a Conflicting TypeDef Error. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalTypeDef - description of original TypeDef + * @param typeDef - updated TypeDef with new identifiers inside. + */ + void processReIdentifiedTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + TypeDefSummary originalTypeDef, + TypeDef typeDef); + + + /** + * Process an event that changes either the name or guid of an AttributeTypeDef. + * It is resolving a Conflicting AttributeTypeDef Error. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originalAttributeTypeDef - description of original AttributeTypeDef + * @param attributeTypeDef - updated AttributeTypeDef with new identifiers inside. + */ + void processReIdentifiedAttributeTypeDefEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + AttributeTypeDef originalAttributeTypeDef, + AttributeTypeDef attributeTypeDef); + + + /** + * Process a detected conflict in the type definitions (TypeDefs) used in the cohort. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originatorTypeDef- description of the TypeDef in the event originator. + * @param otherMetadataCollectionId - the metadataCollection using the conflicting TypeDef. + * @param conflictingTypeDef - description of the TypeDef in the other metadata collection. + * @param errorMessage - details of the error that occurs when the connection is used. + */ + void processTypeDefConflictEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + TypeDefSummary originatorTypeDef, + String otherMetadataCollectionId, + TypeDefSummary conflictingTypeDef, + String errorMessage); + + + /** + * Process a detected conflict in the attribute type definitions (AttributeTypeDefs) used in the cohort. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param originatorAttributeTypeDef- description of the AttributeTypeDef in the event originator. + * @param otherMetadataCollectionId - the metadataCollection using the conflicting AttributeTypeDef. + * @param conflictingAttributeTypeDef - description of the AttributeTypeDef in the other metadata collection. + * @param errorMessage - details of the error that occurs when the connection is used. + */ + void processAttributeTypeDefConflictEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + AttributeTypeDef originatorAttributeTypeDef, + String otherMetadataCollectionId, + AttributeTypeDef conflictingAttributeTypeDef, + String errorMessage); + + + /** + * A TypeDef from another member in the cohort is at a different version than the local repository. This may + * create some inconsistencies in the different copies of instances of this type in different members of the + * cohort. The recommended action is to update all TypeDefs to the latest version. + * + * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the + * local repository, or event mapper name. + * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that + * sent the event. + * @param originatorServerName - name of the server that the event came from. + * @param originatorServerType - type of server that the event came from. + * @param originatorOrganizationName - name of the organization that owns the server that sent the event. + * @param targetMetadataCollectionId - identifier of the metadata collection that is reporting a TypeDef at a + * different level to the reporting repository. + * @param targetTypeDef - details of the TypeDef in the target repository. + * @param otherTypeDef - details of the TypeDef in the other repository. + * @param errorMessage - details of the error that occurs when the connection is used. + */ + void processTypeDefPatchMismatchEvent(String sourceName, + String originatorMetadataCollectionId, + String originatorServerName, + String originatorServerType, + String originatorOrganizationName, + String targetMetadataCollectionId, + TypeDefSummary targetTypeDef, + TypeDef otherTypeDef, + String errorMessage); +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java new file mode 100644 index 0000000..e1db23d --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events; + +/** + * OMRSTypeDefEventType defines the different types of TypeDef events in the open metadata repository services + * protocol: + * <ul> + * <li> + * UNKNOWN_TYPEDEF_EVENT - the event is not recognized by this local server, probably because it is back-level + * from other servers in the cluster. It is logged in the audit log and then ignored. The metadata exchange + * protocol should evolve so that new message types can be ignored by back-level servers without damage + * to the cluster's integrity. + * </li> + * <li> + * NEW_TYPEDEF - A new TypeDef has been defined. + * </li> + * <li> + * UPDATED_TYPEDEF - An existing TypeDef has been updated. + * </li> + * <li> + * DELETED_TYPEDEF_EVENT - An existing TypeDef has been deleted. + * </li> + * <li> + * RE_IDENTIFIED_TYPEDEF_EVENT - the guid has been changed for a TypeDef. + * </li> + * </ul> + */ +public enum OMRSTypeDefEventType +{ + UNKNOWN_TYPEDEF_EVENT (0, "UnknownTypeDefEvent", "An TypeDef event that is not recognized by the local server."), + NEW_TYPEDEF_EVENT (1, "NewTypeDef", "A new TypeDef has been defined."), + NEW_ATTRIBUTE_TYPEDEF_EVENT (2, "NewAttributeTypeDef", "A new AttributeTypeDef has been defined."), + UPDATED_TYPEDEF_EVENT (3, "UpdatedTypeDef", "An existing TypeDef has been updated."), + DELETED_TYPEDEF_EVENT (4, "DeletedTypeDef", "An existing TypeDef has been deleted."), + DELETED_ATTRIBUTE_TYPEDEF_EVENT (5, "DeletedAttributeTypeDef", "An existing AttributeTypeDef has been deleted."), + RE_IDENTIFIED_TYPEDEF_EVENT (6, "ReIdentifiedTypeDef", "An existing TypeDef has changed either it guid or its name."), + RE_IDENTIFIED_ATTRIBUTE_TYPEDEF_EVENT (7, "ReIdentifiedAttributeTypeDef", "An existing AttributeTypeDef has changed either it guid or its name."), + TYPEDEF_ERROR_EVENT (99, "InstanceErrorEvent", + "An error has been detected in the exchange of TypeDefs between members of the cohort."); + + + private int eventTypeCode; + private String eventTypeName; + private String eventTypeDescription; + + + /** + * Default Constructor - sets up the specific values for this instance of the enum. + * + * @param eventTypeCode - int identifier used for indexing based on the enum. + * @param eventTypeName - string name used for messages that include the enum. + * @param eventTypeDescription - default description for the enum value - used when natural resource + * bundle is not available. + */ + OMRSTypeDefEventType(int eventTypeCode, String eventTypeName, String eventTypeDescription) + { + this.eventTypeCode = eventTypeCode; + this.eventTypeName = eventTypeName; + this.eventTypeDescription = eventTypeDescription; + } + + + /** + * Return the int identifier used for indexing based on the enum. + * + * @return int identifier code + */ + public int getTypeDefEventTypeCode() + { + return eventTypeCode; + } + + + /** + * Return the string name used for messages that include the enum. + * + * @return String name + */ + public String getTypeDefEventTypeName() + { + return eventTypeName; + } + + + /** + * Return the default description for the enum value - used when natural resource + * bundle is not available. + * + * @return String default description + */ + public String getTypeDefEventTypeDescription() + { + return eventTypeDescription; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java new file mode 100644 index 0000000..8d20042 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events.v1; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import org.apache.atlas.omrs.eventmanagement.events.OMRSEventCategory; +import org.apache.atlas.omrs.eventmanagement.events.OMRSEventOriginator; + + +import java.io.Serializable; +import java.util.Date; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; + + +/** + * OMRSEventV1 is the OMRSEvent payload for versionName 1 of the open metadata and governance message exchange. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) +public class OMRSEventV1 implements Serializable +{ + private static final long serialVersionUID = 1L; + + private final String protocolVersionId = "OMRS V1.0"; + private Date timestamp = null; + private OMRSEventOriginator originator = null; + private OMRSEventCategory eventCategory = null; + private OMRSEventV1RegistrySection registryEventSection = null; + private OMRSEventV1TypeDefSection typeDefEventSection = null; + private OMRSEventV1InstanceSection instanceEventSection = null; + private OMRSEventV1ErrorSection errorSection = null; + + public OMRSEventV1() + { + } + + public String getProtocolVersionId() + { + return protocolVersionId; + } + + public Date getTimestamp() + { + return timestamp; + } + + public void setTimestamp(Date timestamp) + { + this.timestamp = timestamp; + } + + public OMRSEventOriginator getOriginator() + { + return originator; + } + + public void setOriginator(OMRSEventOriginator originator) + { + this.originator = originator; + } + + public OMRSEventCategory getEventCategory() + { + return eventCategory; + } + + public void setEventCategory(OMRSEventCategory eventCategory) + { + this.eventCategory = eventCategory; + } + + public OMRSEventV1RegistrySection getRegistryEventSection() + { + return registryEventSection; + } + + public void setRegistryEventSection(OMRSEventV1RegistrySection registryEventSection) + { + this.registryEventSection = registryEventSection; + } + + public OMRSEventV1TypeDefSection getTypeDefEventSection() + { + return typeDefEventSection; + } + + public void setTypeDefEventSection(OMRSEventV1TypeDefSection typeDefEventSection) + { + this.typeDefEventSection = typeDefEventSection; + } + + public OMRSEventV1InstanceSection getInstanceEventSection() + { + return instanceEventSection; + } + + public void setInstanceEventSection(OMRSEventV1InstanceSection instanceEventSection) + { + this.instanceEventSection = instanceEventSection; + } + + public OMRSEventV1ErrorSection getErrorSection() + { + return errorSection; + } + + public void setErrorSection(OMRSEventV1ErrorSection errorSection) + { + this.errorSection = errorSection; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java new file mode 100644 index 0000000..8926491 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events.v1; + +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode; +import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefCategory; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.io.Serializable; + +/** + * OMRSEventV1ErrorSection describes the properties used to record errors detected by one of the members of the + * open metadata repository cohort. + */ +public class OMRSEventV1ErrorSection implements Serializable +{ + private static final long serialVersionUID = 1L; + + private OMRSEventErrorCode errorCode = null; + private String errorMessage = null; + private String targetMetadataCollectionId = null; + private Connection targetRemoteConnection = null; + private TypeDefSummary targetTypeDefSummary = null; + private AttributeTypeDef targetAttributeTypeDef = null; + private String targetInstanceGUID = null; + private InstanceProvenanceType otherOrigin = null; + private String otherMetadataCollectionId = null; + private TypeDefSummary otherTypeDefSummary = null; + private TypeDef otherTypeDef = null; + private AttributeTypeDef otherAttributeTypeDef = null; + private String otherInstanceGUID = null; + + public OMRSEventV1ErrorSection() + { + } + + public OMRSEventErrorCode getErrorCode() + { + return errorCode; + } + + public void setErrorCode(OMRSEventErrorCode errorCode) + { + this.errorCode = errorCode; + } + + public String getErrorMessage() + { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) + { + this.errorMessage = errorMessage; + } + + public String getTargetMetadataCollectionId() + { + return targetMetadataCollectionId; + } + + public void setTargetMetadataCollectionId(String targetMetadataCollectionId) + { + this.targetMetadataCollectionId = targetMetadataCollectionId; + } + + public Connection getTargetRemoteConnection() + { + return targetRemoteConnection; + } + + public void setTargetRemoteConnection(Connection targetRemoteConnection) + { + this.targetRemoteConnection = targetRemoteConnection; + } + + public TypeDefSummary getTargetTypeDefSummary() + { + return targetTypeDefSummary; + } + + public void setTargetTypeDefSummary(TypeDefSummary targetTypeDefSummary) + { + this.targetTypeDefSummary = targetTypeDefSummary; + } + + public AttributeTypeDef getTargetAttributeTypeDef() + { + return targetAttributeTypeDef; + } + + public void setTargetAttributeTypeDef(AttributeTypeDef targetAttributeTypeDef) + { + this.targetAttributeTypeDef = targetAttributeTypeDef; + } + + public String getTargetInstanceGUID() + { + return targetInstanceGUID; + } + + public void setTargetInstanceGUID(String targetInstanceGUID) + { + this.targetInstanceGUID = targetInstanceGUID; + } + + public InstanceProvenanceType getOtherOrigin() + { + return otherOrigin; + } + + public void setOtherOrigin(InstanceProvenanceType otherOrigin) + { + this.otherOrigin = otherOrigin; + } + + public String getOtherMetadataCollectionId() + { + return otherMetadataCollectionId; + } + + public void setOtherMetadataCollectionId(String otherMetadataCollectionId) + { + this.otherMetadataCollectionId = otherMetadataCollectionId; + } + + public TypeDefSummary getOtherTypeDefSummary() { return otherTypeDefSummary; } + + public void setOtherTypeDefSummary(TypeDefSummary otherTypeDefSummary) + { + this.otherTypeDefSummary = otherTypeDefSummary; + } + + public TypeDef getOtherTypeDef() + { + return otherTypeDef; + } + + public void setOtherTypeDef(TypeDef otherTypeDef) + { + this.otherTypeDef = otherTypeDef; + } + + public AttributeTypeDef getOtherAttributeTypeDef() + { + return otherAttributeTypeDef; + } + + public void setOtherAttributeTypeDef(AttributeTypeDef otherAttributeTypeDef) + { + this.otherAttributeTypeDef = otherAttributeTypeDef; + } + + public String getOtherInstanceGUID() + { + return otherInstanceGUID; + } + + public void setOtherInstanceGUID(String otherInstanceGUID) + { + this.otherInstanceGUID = otherInstanceGUID; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java new file mode 100644 index 0000000..f5d55fa --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events.v1; + +import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventType; +import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; +import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.io.Serializable; + +/** + * OMRSEventV1InstanceSection describes the properties specific to instance events + */ +public class OMRSEventV1InstanceSection implements Serializable +{ + private static final long serialVersionUID = 1L; + + private OMRSInstanceEventType eventType = null; + + private String typeDefGUID = null; + private String typeDefName = null; + private String instanceGUID = null; + private EntityDetail entity = null; + private Relationship relationship = null; + private String homeMetadataCollectionId = null; + private String originalHomeMetadataCollectionId = null; + private TypeDefSummary originalTypeDefSummary = null; + private String originalInstanceGUID = null; + + public OMRSEventV1InstanceSection() + { + } + + public OMRSInstanceEventType getEventType() + { + return eventType; + } + + public void setEventType(OMRSInstanceEventType eventType) + { + this.eventType = eventType; + } + + public String getTypeDefGUID() + { + return typeDefGUID; + } + + public void setTypeDefGUID(String typeDefGUID) + { + this.typeDefGUID = typeDefGUID; + } + + public String getTypeDefName() + { + return typeDefName; + } + + public void setTypeDefName(String typeDefName) + { + this.typeDefName = typeDefName; + } + + public String getInstanceGUID() + { + return instanceGUID; + } + + public void setInstanceGUID(String instanceGUID) + { + this.instanceGUID = instanceGUID; + } + + public EntityDetail getEntity() + { + return entity; + } + + public void setEntity(EntityDetail entity) + { + this.entity = entity; + } + + public Relationship getRelationship() + { + return relationship; + } + + public void setRelationship(Relationship relationship) + { + this.relationship = relationship; + } + + public String getHomeMetadataCollectionId() + { + return homeMetadataCollectionId; + } + + public void setHomeMetadataCollectionId(String homeMetadataCollectionId) + { + this.homeMetadataCollectionId = homeMetadataCollectionId; + } + + public String getOriginalHomeMetadataCollectionId() + { + return originalHomeMetadataCollectionId; + } + + public void setOriginalHomeMetadataCollectionId(String originalHomeMetadataCollectionId) + { + this.originalHomeMetadataCollectionId = originalHomeMetadataCollectionId; + } + + public TypeDefSummary getOriginalTypeDefSummary() + { + return originalTypeDefSummary; + } + + public void setOriginalTypeDefSummary(TypeDefSummary originalTypeDefSummary) + { + this.originalTypeDefSummary = originalTypeDefSummary; + } + + public String getOriginalInstanceGUID() + { + return originalInstanceGUID; + } + + public void setOriginalInstanceGUID(String originalInstanceGUID) + { + this.originalInstanceGUID = originalInstanceGUID; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java new file mode 100644 index 0000000..0fb5f6c --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events.v1; + +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.eventmanagement.events.OMRSRegistryEventType; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; + +/** + * OMRSEventV1RegistrySection describes properties that are used exclusively for registry events. + */ +public class OMRSEventV1RegistrySection implements Serializable +{ + private static final long serialVersionUID = 1L; + + private OMRSRegistryEventType registryEventType = null; + private Date registrationTimestamp = null; + private Connection remoteConnection = null; + private ArrayList<TypeDefSummary> TypeDefList = null; + + public OMRSEventV1RegistrySection() + { + } + + public OMRSRegistryEventType getRegistryEventType() + { + return registryEventType; + } + + public void setRegistryEventType(OMRSRegistryEventType registryEventType) + { + this.registryEventType = registryEventType; + } + + public Date getRegistrationTimestamp() + { + return registrationTimestamp; + } + + public void setRegistrationTimestamp(Date registrationTimestamp) + { + this.registrationTimestamp = registrationTimestamp; + } + + public Connection getRemoteConnection() + { + return remoteConnection; + } + + public void setRemoteConnection(Connection remoteConnection) + { + this.remoteConnection = remoteConnection; + } + + public ArrayList<TypeDefSummary> getTypeDefList() + { + return TypeDefList; + } + + public void setTypeDefList(ArrayList<TypeDefSummary> typeDefList) + { + TypeDefList = typeDefList; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java new file mode 100644 index 0000000..fc75df5 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.events.v1; + +import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventType; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; + +import java.io.Serializable; + +/** + * OMRSEventV1TypeDefSection describes the properties specific to TypeDef related events + */ +public class OMRSEventV1TypeDefSection implements Serializable +{ + private static final long serialVersionUID = 1L; + + private OMRSTypeDefEventType typeDefEventType = null; + private String typeDefGUID = null; + private String typeDefName = null; + private AttributeTypeDef attributeTypeDef = null; + private TypeDef typeDef = null; + private TypeDefPatch typeDefPatch = null; + private TypeDefSummary originalTypeDefSummary = null; + private AttributeTypeDef originalAttributeTypeDef = null; + + public OMRSEventV1TypeDefSection() + { + } + + public OMRSTypeDefEventType getTypeDefEventType() + { + return typeDefEventType; + } + + public void setTypeDefEventType(OMRSTypeDefEventType typeDefEventType) + { + this.typeDefEventType = typeDefEventType; + } + + public String getTypeDefGUID() + { + return typeDefGUID; + } + + public void setTypeDefGUID(String typeDefGUID) + { + this.typeDefGUID = typeDefGUID; + } + + public String getTypeDefName() + { + return typeDefName; + } + + public void setTypeDefName(String typeDefName) + { + this.typeDefName = typeDefName; + } + + public AttributeTypeDef getAttributeTypeDef() + { + return attributeTypeDef; + } + + public void setAttributeTypeDef(AttributeTypeDef attributeTypeDef) + { + this.attributeTypeDef = attributeTypeDef; + } + + public TypeDef getTypeDef() + { + return typeDef; + } + + public void setTypeDef(TypeDef typeDef) + { + this.typeDef = typeDef; + } + + public TypeDefPatch getTypeDefPatch() + { + return typeDefPatch; + } + + public void setTypeDefPatch(TypeDefPatch typeDefPatch) + { + this.typeDefPatch = typeDefPatch; + } + + public TypeDefSummary getOriginalTypeDefSummary() + { + return originalTypeDefSummary; + } + + public void setOriginalTypeDefSummary(TypeDefSummary originalTypeDefSummary) + { + this.originalTypeDefSummary = originalTypeDefSummary; + } + + public AttributeTypeDef getOriginalAttributeTypeDef() + { + return originalAttributeTypeDef; + } + + public void setOriginalAttributeTypeDef(AttributeTypeDef originalAttributeTypeDef) + { + this.originalAttributeTypeDef = originalAttributeTypeDef; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java new file mode 100644 index 0000000..99a8569 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper; + +import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; + +/** + * OMRSRepositoryEventMapper is the interface to a connector that is converting events received from + * a non-native local metadata repository into OMRS compliant repository events. It is used when the Open Metadata + * and Governance Server is being used as a RepositoryProxy, or if the local metadata repository has + * additional APIs that mean metadata can be changed without going through the OMRS Repository Connectors. + */ +public interface OMRSRepositoryEventMapper +{ + /** + * Pass additional information to the connector needed to process events. + * + * @param repositoryEventMapperName - repository event mapper name used for the source of the OMRS events. + * @param repositoryConnector - this is the connector to the local repository that the event mapper is processing + * events from. The repository connector is used to retrieve additional information + * necessary to fill out the OMRS Events. + * @param repositoryHelper - provides helper methods for building TypeDefs and metadata instances such as + * entities and relationships. + * @param localMetadataCollectionId - unique identifier for the local repository's metadata collection. + * @param localServerName - name of the local server. + * @param localServerType - type of local repository/server. + * @param localOrganizationName - name of the organization that owns the local metadata repository. + */ + void initialize(String repositoryEventMapperName, + OMRSRepositoryConnector repositoryConnector, + OMRSRepositoryHelper repositoryHelper, + String localMetadataCollectionId, + String localServerName, + String localServerType, + String localOrganizationName); + + + /** + * Set up the repository event processor for this connector to use. The connector should pass + * each typeDef or instance metadata change reported by its metadata repository's metadata on to the + * repository event processor. + * + * @param repositoryEventProcessor - listener responsible for distributing notifications of local + * changes to metadata types and instances to the rest of the + * open metadata repository cohort. + */ + void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor); +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java new file mode 100644 index 0000000..4d9db96 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper; + +import org.apache.atlas.ocf.ConnectorBase; +import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; + +/** + * OMRSRepositoryEventMapperBase provides a base class for implementors of OMRSRepositoryEventMapper. + */ +public abstract class OMRSRepositoryEventMapperBase extends ConnectorBase implements OMRSRepositoryEventMapper +{ + protected OMRSRepositoryEventProcessor repositoryEventProcessor = null; + protected String repositoryEventMapperName = null; + protected OMRSRepositoryConnector repositoryConnector = null; + protected OMRSRepositoryHelper repositoryHelper = null; + protected String localMetadataCollectionId = null; + protected String localServerName = null; + protected String localServerType = null; + protected String localOrganizationName = null; + + /** + * Default constructor for OCF ConnectorBase. + */ + public OMRSRepositoryEventMapperBase() + { + super(); + } + + + /** + * Set up the repository event listener for this connector to use. The connector should pass + * each type or instance metadata change reported by its metadata repository's metadata on to the + * repository event listener. + * + * @param repositoryEventProcessor - listener responsible for distributing notifications of local + * changes to metadata types and instances to the rest of the + * open metadata repository cluster. + */ + public void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor) + { + this.repositoryEventProcessor = repositoryEventProcessor; + } + + + /** + * Pass additional information to the connector needed to process events. + * + * @param repositoryEventMapperName - repository event mapper name used for the source of the OMRS events. + * @param repositoryConnector - ths is the connector to the local repository that the event mapper is processing + * events from. The repository connector is used to retrieve additional information + * necessary to fill out the OMRS Events. + * @param repositoryHelper - the TypeDef helper is used to create metadata instances that are + * @param localMetadataCollectionId - unique identifier for the local repository's metadata collection. + * @param localServerName - name of the local server. + * @param localServerType - type of local repository/server. + * @param localOrganizationName - name of the organization that owns the local metadata repository. + */ + public void initialize(String repositoryEventMapperName, + OMRSRepositoryConnector repositoryConnector, + OMRSRepositoryHelper repositoryHelper, + String localMetadataCollectionId, + String localServerName, + String localServerType, + String localOrganizationName) + { + this.repositoryEventMapperName = repositoryEventMapperName; + this.repositoryConnector = repositoryConnector; + this.repositoryHelper = repositoryHelper; + this.localMetadataCollectionId = localMetadataCollectionId; + this.localServerName = localServerName; + this.localServerType = localServerType; + this.localOrganizationName = localOrganizationName; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java new file mode 100644 index 0000000..b4895b1 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper; + +import org.apache.atlas.ocf.ConnectorProviderBase; + +/** + * OMRSRepositoryEventMapperProviderBase provides a base class for the connector provider supporting + * OMRSRepositoryEventMapper connectors. It extends ConnectorProviderBase which does the creation of connector instances. + * + * The subclasses of OMRSRepositoryEventMapperProviderBase must initialize ConnectorProviderBase with the Java class + * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)). + * Then the connector provider will work. + */ +public abstract class OMRSRepositoryEventMapperProviderBase extends ConnectorProviderBase +{ + /** + * Default Constructor + */ + public OMRSRepositoryEventMapperProviderBase() + { + /* + * Nothing to do + */ + } +}
