http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java index b8aa172..62842a2 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java @@ -20,28 +20,27 @@ package org.apache.atlas.omrs.archivemanager.opentypes; import org.apache.atlas.omrs.archivemanager.OMRSArchiveBuilder; +import org.apache.atlas.omrs.archivemanager.OMRSArchiveHelper; import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive; import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveType; import org.apache.atlas.omrs.ffdc.OMRSErrorCode; import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException; -import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*; import java.util.ArrayList; import java.util.Date; -import java.util.Map; /** * OpenMetadataTypesArchive builds an open metadata archive containing all of the standard open metadata types. * These types have hardcoded dates and guids so that however many times this archive is rebuilt, it will * produce the same content. * <p> - * Details of the open metadata types are documented on the wiki: - * <a href="https://cwiki.apache.org/confluence/display/ATLAS/Building+out+the+Open+Metadata+Typesystem">Building out the Open Metadata Typesystem</a> + * Details of the open metadata types are documented on the wiki: + * <a href="https://cwiki.apache.org/confluence/display/ATLAS/Building+out+the+Open+Metadata+Typesystem">Building out the Open Metadata Typesystem</a> * </p> * <p> - * There are 8 areas, each covering a different topic area of metadata. The module breaks down the process of creating - * the models into the areas and then the individual models to simplify the maintenance of this class + * There are 8 areas, each covering a different topic area of metadata. The module breaks down the process of creating + * the models into the areas and then the individual models to simplify the maintenance of this class * </p> */ public class OpenMetadataTypesArchive @@ -49,22 +48,22 @@ public class OpenMetadataTypesArchive /* * This is the header information for the archive. */ - private static final String archiveGUID = "bce3b0a0-662a-4f87-b8dc-844078a11a6e"; - private static final String archiveName = "Open Metadata Types"; - private static final String archiveDescription = "Standard types for open metadata repositories."; - private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; - private static final String originatorName = "Apache Atlas (OMRS)"; - private static final Date creationDate = new Date(1516313040008L); + private static final String archiveGUID = "bce3b0a0-662a-4f87-b8dc-844078a11a6e"; + private static final String archiveName = "Open Metadata Types"; + private static final String archiveDescription = "Standard types for open metadata repositories."; + private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK; + private static final String originatorName = "Apache Atlas (OMRS)"; + private static final Date creationDate = new Date(1516313040008L); /* * Specific values for initializing TypeDefs */ - private static final long versionNumber = 1L; - private static final String versionName = "1.0"; + private static final long versionNumber = 1L; + private static final String versionName = "1.0"; - - private OMRSArchiveBuilder archiveBuilder; + private OMRSArchiveBuilder archiveBuilder; + private OMRSArchiveHelper archiveHelper; /** @@ -72,14 +71,20 @@ public class OpenMetadataTypesArchive */ public OpenMetadataTypesArchive() { - OMRSArchiveBuilder newArchiveBuilder = new OMRSArchiveBuilder(archiveGUID, - archiveName, - archiveDescription, - archiveType, - originatorName, - creationDate, - null); - this.archiveBuilder = newArchiveBuilder; + this.archiveBuilder = new OMRSArchiveBuilder(archiveGUID, + archiveName, + archiveDescription, + archiveType, + originatorName, + creationDate, + null); + + this.archiveHelper = new OMRSArchiveHelper(archiveBuilder, + archiveGUID, + originatorName, + creationDate, + versionNumber, + versionName); } @@ -108,6 +113,7 @@ public class OpenMetadataTypesArchive * Call each of the methods to systematically add the contents of the archive. */ this.addStandardPrimitiveDefs(); + this.addStandardCollectionDefs(); this.addArea0Types(); this.addArea1Types(); this.addArea2Types(); @@ -128,8 +134,8 @@ public class OpenMetadataTypesArchive * This is a logic error since it means the creation of the archive builder threw an exception * in the constructor and so this object should not be used. */ - OMRSErrorCode errorCode = OMRSErrorCode.ARCHIVE_UNAVAILABLE; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + OMRSErrorCode errorCode = OMRSErrorCode.ARCHIVE_UNAVAILABLE; + String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), this.getClass().getName(), @@ -152,356 +158,70 @@ public class OpenMetadataTypesArchive */ private void addStandardPrimitiveDefs() { - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BOOLEAN)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BYTE)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_CHAR)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_SHORT)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_INT)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_LONG)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_FLOAT)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DOUBLE)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BIGINTEGER)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BIGDECIMAL)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING)); - this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DATE)); - } - - - /** - * Set up an individual primitive definition - * - * @param primitiveDefCategory - category of the primitive def defines the unique - * information about this primitive type. - * @return initialized PrimitiveDef object ready for the archive - */ - private PrimitiveDef getPrimitiveDef(PrimitiveDefCategory primitiveDefCategory) - { - PrimitiveDef primitiveDef = new PrimitiveDef(primitiveDefCategory); - - primitiveDef.setGUID(primitiveDefCategory.getGUID()); - primitiveDef.setName(primitiveDefCategory.getName()); - - return primitiveDef; - } - - - /** - * Create a CollectionDef. A new CollectionDef is required for each combination of primitive types - * used to initialize the collection. Each CollectionDef has its own unique identifier (guid) and - * its name is a combination of the collection type and the primitives use to initialize it. - * - * @param guid - unique identifier for the CollectionDef - * @param name - unique name for the CollectionDef - * @param collectionDefCategory - category of the collection. - * @return Filled out CollectionDef - */ - private CollectionDef getCollectionDef(String guid, - String name, - CollectionDefCategory collectionDefCategory) - { - CollectionDef collectionDef = new CollectionDef(collectionDefCategory); - - collectionDef.setGUID(guid); - collectionDef.setName(name); - - return collectionDef; - } - - - /** - * Create an EnumDef that has no valid values defined. These are added by the caller. - * - * @param guid - unique identifier for the CollectionDef - * @param name - unique name for the CollectionDef - * @param description - short default description of the enum type - * @param descriptionGUID - guid of the glossary term describing this enum type - * @return basic EnumDef without valid values - */ - private EnumDef getEmptyEnumDef(String guid, - String name, - String description, - String descriptionGUID) - { - EnumDef enumDef = new EnumDef(); - - enumDef.setGUID(guid); - enumDef.setName(name); - enumDef.setDescription(description); - enumDef.setDescriptionGUID(descriptionGUID); - enumDef.setDefaultValue(null); - - return enumDef; - } - - - /** - * Create an EnumElementDef that carries one of the valid values for an Enum. - * - * @param ordinal - code number - * @param value - name - * @param description - short description - * @param descriptionGUID - guid of the glossary term describing this enum element - * @return Fully filled out EnumElementDef - */ - private EnumElementDef getEnumElementDef(int ordinal, - String value, - String description, - String descriptionGUID) - { - EnumElementDef enumElementDef = new EnumElementDef(); - - enumElementDef.setOrdinal(ordinal); - enumElementDef.setValue(value); - enumElementDef.setDescription(description); - enumElementDef.setDescriptionGUID(descriptionGUID); - - return enumElementDef; - } - - - /** - * Sets up a default EntityDef. Calling methods can override the default values. This EntityDef - * has no attribute defined. - * - * @param guid - unique identifier for the entity - * @param name - name of the entity - * @param superType - Super type for this entity (null for top-level) - * @param description - short description of the entity - * @param descriptionGUID - guid of the glossary term describing this entity type - * @return Initialized EntityDef - */ - EntityDef getDefaultEntityDef(String guid, - String name, - TypeDefLink superType, - String description, - String descriptionGUID) - { - EntityDef entityDef = new EntityDef(); - - /* - * Set up the parameters supplied by the caller. - */ - entityDef.setGUID(guid); - entityDef.setName(name); - entityDef.setSuperType(superType); - entityDef.setDescription(description); - entityDef.setDescriptionGUID(descriptionGUID); - - /* - * Set up the defaults - */ - entityDef.setOrigin(archiveGUID); - entityDef.setCreatedBy(originatorName); - entityDef.setCreateTime(creationDate); - entityDef.setVersion(versionNumber); - entityDef.setVersionName(versionName); - - /* - * Set default valid instance statuses - */ - ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>(); - validInstanceStatusList.add(InstanceStatus.ACTIVE); - validInstanceStatusList.add(InstanceStatus.DELETED); - entityDef.setValidInstanceStatusList(validInstanceStatusList); - - return entityDef; + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_UNKNOWN)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BOOLEAN)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BYTE)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_CHAR)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_SHORT)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_INT)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_LONG)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_FLOAT)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DOUBLE)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BIGINTEGER)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BIGDECIMAL)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING)); + this.archiveBuilder.addPrimitiveDef(archiveHelper.getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DATE)); } /** - * Return an attribute with the supplied name and description that is of type String. It is set up to be optional, - * indexable (useful for searches) but the value does not need to be unique. - * These are the typical values used for most open metadata attribute. - * They can be changed by the caller once the TypeDefAttribute is returned. - * - * @param attributeName - name of the attribute - * @param attributeDescription - short description for the attribute - * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute. - * @return Optional TypeDefAttribute of type string + * Add the standard collection types to the archive builder. */ - TypeDefAttribute getStringTypeDefAttribute(String attributeName, - String attributeDescription, - String attributeDescriptionGUID) + private void addStandardCollectionDefs() { - TypeDefAttribute attribute = new TypeDefAttribute(); + this.archiveBuilder.addCollectionDef(getMapStringStringCollectionDef()); + this.archiveBuilder.addCollectionDef(getArrayStringCollectionDef()); - attribute.setAttributeName(attributeName); - attribute.setAttributeDescription(attributeDescription); - attribute.setAttributeDescriptionGUID(attributeDescriptionGUID); - attribute.setAttributeType(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING)); - attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE); - attribute.setValuesMinCount(0); - attribute.setValuesMaxCount(1); - attribute.setIndexable(true); - attribute.setUnique(false); - attribute.setDefaultValue(null); - attribute.setExternalStandardMappings(null); - - return attribute; } /** - * Returns a basic RelationshipDef without any attributes or ends set up. - * The caller is responsible for adding the attributes and ends definition. + * Defines the "map<string, string>" type. * - * @param guid - unique identifier for the relationship - * @param name - name of the relationship - * @param superType - Super type for this relationship (null for top-level) - * @param description - short default description of the relationship - * @param descriptionGUID - guid of the glossary term that describes this relationship - * @param relationshipCategory - is this an association, aggregation or composition? - * @param propagationRule - should classifications propagate over this relationship? - * @return RelationshipDef with no ends defined. + * @return CollectionDef for this type */ - private RelationshipDef getBasicRelationshipDef(String guid, - String name, - TypeDefLink superType, - String description, - String descriptionGUID, - RelationshipCategory relationshipCategory, - ClassificationPropagationRule propagationRule) + private CollectionDef getMapStringStringCollectionDef() { - RelationshipDef relationshipDef = new RelationshipDef(); - - /* - * Set up the parameters supplied by the caller. - */ - relationshipDef.setGUID(guid); - relationshipDef.setName(name); - relationshipDef.setSuperType(superType); - relationshipDef.setDescription(description); - relationshipDef.setDescriptionGUID(descriptionGUID); - - /* - * Set up the defaults - */ - relationshipDef.setOrigin(archiveGUID); - relationshipDef.setCreatedBy(originatorName); - relationshipDef.setCreateTime(creationDate); - relationshipDef.setVersion(versionNumber); - relationshipDef.setVersionName(versionName); - - /* - * Set default valid instance statuses - */ - ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>(); - validInstanceStatusList.add(InstanceStatus.ACTIVE); - validInstanceStatusList.add(InstanceStatus.DELETED); - relationshipDef.setValidInstanceStatusList(validInstanceStatusList); - - /* - * Set up the category of relationship - */ - relationshipDef.setRelationshipCategory(relationshipCategory); - - if ((relationshipCategory == RelationshipCategory.AGGREGATION) || - (relationshipCategory == RelationshipCategory.COMPOSITION)) - { - /* - * By convention, end 1 is the container end in the open metadata model. - */ - relationshipDef.setRelationshipContainerEnd(RelationshipContainerEnd.END1); - } - else - { - relationshipDef.setRelationshipContainerEnd(RelationshipContainerEnd.NOT_APPLICABLE); - } - - /* - * Use the supplied propagation rule. - */ - relationshipDef.setPropagationRule(propagationRule); + final String guid = "005c7c14-ac84-4136-beed-959401b041f8"; + final String description = "A map from String to String."; + final String descriptionGUID = null; - return relationshipDef; + return archiveHelper.getMapCollectionDef(guid, + description, + descriptionGUID, + PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING, + PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); } /** - * Returns a RelationshipEndDef object that sets up details of an entity at one end of a relationship. + * Define the "array<string>" type. * - * @param entityType - details of the type of entity connected to this end. - * @param attributeName - name of the attribute that the entity at the other end uses to refer to this entity. - * @param attributeDescription - description of this attribute - * @param attributeDescriptionGUID - unique identifier of the glossary term describing this attribute. - * @param attributeCardinality - cardinality of this end of the relationship. - * @return the definition of one end of a Relationship. + * @return CollectionDef for this object */ - private RelationshipEndDef getRelationshipEndDef(TypeDefLink entityType, - String attributeName, - String attributeDescription, - String attributeDescriptionGUID, - AttributeCardinality attributeCardinality) + private CollectionDef getArrayStringCollectionDef() { - RelationshipEndDef relationshipEndDef = new RelationshipEndDef(); - - relationshipEndDef.setEntityType(entityType); - relationshipEndDef.setAttributeName(attributeName); - relationshipEndDef.setAttributeDescription(attributeDescription); - relationshipEndDef.setAttributeDescriptionGUID(attributeDescriptionGUID); - relationshipEndDef.setAttributeCardinality(attributeCardinality); + final String guid = "0428b5d3-f824-459c-b7f5-f8151de59707"; + final String description = "An array of Strings."; + final String descriptionGUID = null; - return relationshipEndDef; + return archiveHelper.getArrayCollectionDef(guid, + description, + descriptionGUID, + PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); } - /** - * Returns a basic ClassificationDef without any attributes. The caller is responsible for adding the - * attribute definitions. - * - * @param guid - unique identifier for the classification - * @param name - name of the classification - * @param superType - Super type for this classification (null for top-level) - * @param description - short description of the classification - * @param descriptionGUID - unique identifier of the glossary term that describes this classification. - * @param validEntityDefs - which entities can this classification be linked to. - * @param propagatable - can the classification propagate over relationships? - * @return ClassificationDef with no attributes defined. - */ - private ClassificationDef getClassificationDef(String guid, - String name, - TypeDefLink superType, - String description, - String descriptionGUID, - ArrayList<TypeDefLink> validEntityDefs, - boolean propagatable) - { - ClassificationDef classificationDef = new ClassificationDef(); - - /* - * Set up the parameters supplied by the caller. - */ - classificationDef.setGUID(guid); - classificationDef.setName(name); - classificationDef.setSuperType(superType); - classificationDef.setDescription(description); - classificationDef.setDescriptionGUID(descriptionGUID); - - /* - * Set up the defaults - */ - classificationDef.setOrigin(archiveGUID); - classificationDef.setCreatedBy(originatorName); - classificationDef.setCreateTime(creationDate); - classificationDef.setVersion(versionNumber); - classificationDef.setVersionName(versionName); - - /* - * Set default valid instance statuses - */ - ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>(); - validInstanceStatusList.add(InstanceStatus.ACTIVE); - validInstanceStatusList.add(InstanceStatus.DELETED); - classificationDef.setValidInstanceStatusList(validInstanceStatusList); - - /* - * Set up the supplied validEntityTypes and propagatable flag. - */ - classificationDef.setValidEntityDefs(validEntityDefs); - classificationDef.setPropagatable(propagatable); - - return classificationDef; - } /* @@ -559,16 +279,16 @@ public class OpenMetadataTypesArchive /* * Build the Entity */ - final String guid = "005c7c14-ac84-4136-beed-959401b041f8"; + final String guid = "a32316b8-dc8c-48c5-b12b-71c1b2a080bf"; final String name = "Referenceable"; final String description = "An open metadata entity that has a unique identifier."; final String descriptionGUID = null; - EntityDef entityDef = getDefaultEntityDef(guid, - name, - null, - description, - descriptionGUID); + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + null, + description, + descriptionGUID); /* * Build the attributes @@ -576,14 +296,18 @@ public class OpenMetadataTypesArchive ArrayList<TypeDefAttribute> properties = new ArrayList<>(); TypeDefAttribute property; - final String attributeName = "qualifiedName"; - final String attributeDescription = "Unique identifier for the entity."; - final String attributeDescriptionGUID = null; - + final String attribute1Name = "qualifiedName"; + final String attribute1Description = "Unique identifier for the entity."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "additionalProperties"; + final String attribute2Description = "Additional properties for the element."; + final String attribute2DescriptionGUID = null; - property = getStringTypeDefAttribute(attributeName, attributeDescription, attributeDescriptionGUID); + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); property.setUnique(true); properties.add(property); + property = archiveHelper.getMapStringStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); + properties.add(property); entityDef.setPropertiesDefinition(properties); @@ -607,11 +331,11 @@ public class OpenMetadataTypesArchive final String descriptionGUID = null; final String superTypeName = "Referenceable"; - EntityDef entityDef = getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); /* * Build the attributes @@ -619,22 +343,22 @@ public class OpenMetadataTypesArchive ArrayList<TypeDefAttribute> properties = new ArrayList<>(); TypeDefAttribute property; - final String attribute1Name = "name"; - final String attribute1Description = "Display name for the asset."; + final String attribute1Name = "name"; + final String attribute1Description = "Display name for the asset."; final String attribute1DescriptionGUID = null; - final String attribute2Name = "description"; - final String attribute2Description = "Description of the asset."; + final String attribute2Name = "description"; + final String attribute2Description = "Description of the asset."; final String attribute2DescriptionGUID = null; - final String attribute3Name = "owner"; - final String attribute3Description = "User name of the person or process that owns the asset."; + final String attribute3Name = "owner"; + final String attribute3Description = "User name of the person or process that owns the asset."; final String attribute3DescriptionGUID = null; - property = getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); properties.add(property); - property = getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); properties.add(property); - property = getStringTypeDefAttribute(attribute3Name, attribute3Description, attribute3DescriptionGUID); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, attribute3Description, attribute3DescriptionGUID); properties.add(property); entityDef.setPropertiesDefinition(properties); @@ -654,19 +378,17 @@ public class OpenMetadataTypesArchive /* * Build the Entity */ - final String guid = "c19746ac-b3ec-49ce-af4b-83348fc55e07"; - final String name = "Infrastructure"; - final String description = "Physical infrastructure or software platform."; + final String guid = "c19746ac-b3ec-49ce-af4b-83348fc55e07"; + final String name = "Infrastructure"; + final String description = "Physical infrastructure or software platform."; final String descriptionGUID = null; final String superTypeName = "Asset"; - EntityDef entityDef = getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - - return entityDef; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); } @@ -680,19 +402,17 @@ public class OpenMetadataTypesArchive /* * Build the Entity */ - final String guid = "d8f33bd7-afa9-4a11-a8c7-07dcec83c050"; - final String name = "Process"; - final String description = "Well-defined sequence of activities performed by people or software components."; + final String guid = "d8f33bd7-afa9-4a11-a8c7-07dcec83c050"; + final String name = "Process"; + final String description = "Well-defined sequence of activities performed by people or software components."; final String descriptionGUID = null; final String superTypeName = "Asset"; - EntityDef entityDef = getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - - return entityDef; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); } @@ -706,19 +426,17 @@ public class OpenMetadataTypesArchive /* * Build the Entity */ - final String guid = "1449911c-4f44-4c22-abc0-7540154feefb"; - final String name = "DataSet"; - final String description = "Collection of related data."; + final String guid = "1449911c-4f44-4c22-abc0-7540154feefb"; + final String name = "DataSet"; + final String description = "Collection of related data."; final String descriptionGUID = null; final String superTypeName = "Asset"; - EntityDef entityDef = getDefaultEntityDef(guid, - name, - this.archiveBuilder.getEntityDef(superTypeName), - description, - descriptionGUID); - - return entityDef; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); } @@ -732,37 +450,38 @@ public class OpenMetadataTypesArchive /* * Build the relationship */ - final String guid = "9a6583c4-7419-4d5a-a6e5-26b0033fa349"; - final String name = "ProcessInput"; - final String description = "The DataSets passed into a Process."; - final String descriptionGUID = null; + final String guid = "9a6583c4-7419-4d5a-a6e5-26b0033fa349"; + final String name = "ProcessInput"; + final String description = "The DataSets passed into a Process."; + final String descriptionGUID = null; + final RelationshipCategory relationshipCategory = RelationshipCategory.AGGREGATION; final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - RelationshipDef relationshipDef = getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - relationshipCategory, - classificationPropagationRule); + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); - RelationshipEndDef relationshipEndDef; + RelationshipEndDef relationshipEndDef; /* * Set up end 1. */ final String end1EntityType = "Process"; final String end1AttributeName = "consumedByProcess"; - final String end1AttributeDescription = "Processes that consume this DataSet"; + final String end1AttributeDescription = "Processes that consume this DataSet."; final String end1AttributeDescriptionGUID = null; final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; - relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); relationshipDef.setEndDef1(relationshipEndDef); @@ -771,15 +490,15 @@ public class OpenMetadataTypesArchive */ final String end2EntityType = "DataSet"; final String end2AttributeName = "processInputData"; - final String end2AttributeDescription = "DataSets consumed by this Process"; + final String end2AttributeDescription = "DataSets consumed by this Process."; final String end2AttributeDescriptionGUID = null; final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; - relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); relationshipDef.setEndDef2(relationshipEndDef); @@ -804,30 +523,30 @@ public class OpenMetadataTypesArchive final RelationshipCategory relationshipCategory = RelationshipCategory.AGGREGATION; final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - RelationshipDef relationshipDef = getBasicRelationshipDef(guid, - name, - null, - description, - descriptionGUID, - relationshipCategory, - classificationPropagationRule); + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); - RelationshipEndDef relationshipEndDef; + RelationshipEndDef relationshipEndDef; /* * Set up end 1. */ final String end1EntityType = "Process"; final String end1AttributeName = "producedByProcess"; - final String end1AttributeDescription = "Processes that produce this DataSet"; + final String end1AttributeDescription = "Processes that produce this DataSet."; final String end1AttributeDescriptionGUID = null; final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; - relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), - end1AttributeName, - end1AttributeDescription, - end1AttributeDescriptionGUID, - end1Cardinality); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); relationshipDef.setEndDef1(relationshipEndDef); @@ -836,15 +555,15 @@ public class OpenMetadataTypesArchive */ final String end2EntityType = "DataSet"; final String end2AttributeName = "processOutputData"; - final String end2AttributeDescription = "DataSets produced by this Process"; + final String end2AttributeDescription = "DataSets produced by this Process."; final String end2AttributeDescriptionGUID = null; final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; - relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), - end2AttributeName, - end2AttributeDescription, - end2AttributeDescriptionGUID, - end2Cardinality); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); relationshipDef.setEndDef2(relationshipEndDef); @@ -863,25 +582,30 @@ public class OpenMetadataTypesArchive */ private void add0015LinkedMediaTypes() { - this.archiveBuilder.addEnumDef(getMediaUsageEnum()); + this.archiveBuilder.addEnumDef(getMediaUsageTypeEnum()); this.archiveBuilder.addEntityDef(getExternalReferenceEntity()); this.archiveBuilder.addEntityDef(getRelatedMediaEntity()); + this.archiveBuilder.addEntityDef(getMediaUsageEntity()); + this.archiveBuilder.addRelationshipDef(getExternalReferenceLinkRelationship()); this.archiveBuilder.addRelationshipDef(getMediaReferenceRelationship()); + this.archiveBuilder.addRelationshipDef(getMediaUsageGuidanceRelationship()); + } - private EnumDef getMediaUsageEnum() + + private EnumDef getMediaUsageTypeEnum() { - final String guid = "c6861a72-7485-48c9-8040-876f6c342b61"; - final String name = "MediaUsage"; - final String description = "Defines how a related media reference should be used."; + final String guid = "c6861a72-7485-48c9-8040-876f6c342b61"; + final String name = "MediaUsageType"; + final String description = "Defines how a related media reference should be used."; final String descriptionGUID = null; - EnumDef enumDef = getEmptyEnumDef(guid, name, description, descriptionGUID); + EnumDef enumDef = archiveHelper.getEmptyEnumDef(guid, name, description, descriptionGUID); - ArrayList<EnumElementDef> elementDefs = new ArrayList(); + ArrayList<EnumElementDef> elementDefs = new ArrayList<>(); EnumElementDef elementDef; final int element1Ordinal = 0; @@ -889,7 +613,7 @@ public class OpenMetadataTypesArchive final String element1Description = "Provides a small image to represent the asset in tree views and graphs."; final String element1DescriptionGUID = null; - elementDef = getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID); elementDefs.add(elementDef); final int element2Ordinal = 1; @@ -897,7 +621,7 @@ public class OpenMetadataTypesArchive final String element2Description = "Provides a small image about the asset that can be used in lists."; final String element2DescriptionGUID = null; - elementDef = getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID); elementDefs.add(elementDef); final int element3Ordinal = 2; @@ -905,7 +629,7 @@ public class OpenMetadataTypesArchive final String element3Description = "Illustrates how the asset works or what it contains. It is complementary to the asset's description."; final String element3DescriptionGUID = null; - elementDef = getEnumElementDef(element3Ordinal, element3Value, element3Description, element3DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element3Ordinal, element3Value, element3Description, element3DescriptionGUID); elementDefs.add(elementDef); final int element4Ordinal = 3; @@ -913,7 +637,7 @@ public class OpenMetadataTypesArchive final String element4Description = "Provides guidance to a person on how to use the asset."; final String element4DescriptionGUID = null; - elementDef = getEnumElementDef(element4Ordinal, element4Value, element4Description, element4DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element4Ordinal, element4Value, element4Description, element4DescriptionGUID); elementDefs.add(elementDef); final int element5Ordinal = 99; @@ -921,7 +645,7 @@ public class OpenMetadataTypesArchive final String element5Description = "Another usage."; final String element5DescriptionGUID = null; - elementDef = getEnumElementDef(element5Ordinal, element5Value, element5Description, element5DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element5Ordinal, element5Value, element5Description, element5DescriptionGUID); elementDefs.add(elementDef); enumDef.setElementDefs(elementDefs); @@ -929,134 +653,405 @@ public class OpenMetadataTypesArchive return enumDef; } - private EntityDef getExternalReferenceEntity() + + private EntityDef getExternalReferenceEntity() { - final String guid = "af536f20-062b-48ef-9c31-1ddd05b04c56"; + final String guid = "af536f20-062b-48ef-9c31-1ddd05b04c56"; final String name = "ExternalReference"; final String description = "A link to more information."; final String descriptionGUID = null; - // TODO - return null; + final String superTypeName = "Referenceable"; + + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "displayName"; + final String attribute1Description = "Consumable name for reports and user interfaces."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "url"; + final String attribute2Description = "Location of the external reference."; + final String attribute2DescriptionGUID = null; + final String attribute3Name = "version"; + final String attribute3Description = "Version number of the external reference."; + final String attribute3DescriptionGUID = null; + final String attribute4Name = "description"; + final String attribute4Description = "Description of the external reference."; + final String attribute4DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute3Name, attribute3Description, attribute3DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute4Name, attribute4Description, attribute4DescriptionGUID); + properties.add(property); + + entityDef.setPropertiesDefinition(properties); + + return entityDef; } - private EntityDef getRelatedMediaEntity() + + private EntityDef getRelatedMediaEntity() { - final String guid = "747f8b86-fe7c-4c9b-ba75-979e093cc307"; + final String guid = "747f8b86-fe7c-4c9b-ba75-979e093cc307"; final String name = "RelatedMedia"; final String description = "Images, video or sound media."; final String descriptionGUID = null; - // TODO - return null; - } - - private RelationshipDef getExternalReferenceLinkRelationship() - { - final String guid = "7d818a67-ab45-481c-bc28-f6b1caf12f06"; - final String name = "ExternalReferenceLink"; - final String description = "Link to more information."; - final String descriptionGUID = null; + final String superTypeName = "ExternalReference"; - // TODO - return null; + return archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); } - private RelationshipDef getMediaReferenceRelationship() + + private EntityDef getMediaUsageEntity() { - final String guid = "1353400f-b0ab-4ab9-ab09-3045dd8a7140"; - final String name = "MediaReference"; - final String description = "Link to related media such as images, videos and audio."; + final String guid = "b9599da3-ce7e-4981-b25e-86d03340da0b"; + final String name = "MediaUsage"; + final String description = "Guidance on a particular way a specific piece of media could be used."; final String descriptionGUID = null; - // TODO - return null; - } + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + null, + description, + descriptionGUID); - /* - * ------------------------------------------------------------------------------------------------------- - */ + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; + final String attribute1Name = "mediaUsageType"; + final String attribute1Description = "Type of media usage."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "guidance"; + final String attribute2Description = "Advice on how the media should be used in this context."; + final String attribute2DescriptionGUID = null; - /** - * 0017 External Identifiers define identifiers used to identify this entity in other systems. - */ - private void add0017ExternalIdentifiers() - { - this.archiveBuilder.addEnumDef(getKeyPatternEnum()); + property = archiveHelper.getEnumTypeDefAttribute("MediaUsageType", attribute1Name, attribute1Description, attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); + properties.add(property); - this.archiveBuilder.addEntityDef(getExternalIdEntity()); + entityDef.setPropertiesDefinition(properties); - this.archiveBuilder.addRelationshipDef(getExternalIdScopeRelationship()); - this.archiveBuilder.addRelationshipDef(getExternalIdLinkRelationship()); + return entityDef; } - private EnumDef getKeyPatternEnum() + + private RelationshipDef getExternalReferenceLinkRelationship() { - final String guid = "8904df8f-1aca-4de8-9abd-1ef2aadba300"; - final String name = "KeyPattern"; - final String description = "Defines the type of identifier used for an asset."; + final String guid = "7d818a67-ab45-481c-bc28-f6b1caf12f06"; + final String name = "ExternalReferenceLink"; + final String description = "Link to more information."; final String descriptionGUID = null; - EnumDef enumDef = getEmptyEnumDef(guid, name, description, descriptionGUID); + final RelationshipCategory relationshipCategory = RelationshipCategory.ASSOCIATION; + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; - ArrayList<EnumElementDef> elementDefs = new ArrayList(); - EnumElementDef elementDef; + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); - final int element1Ordinal = 0; - final String element1Value = "Local Key"; - final String element1Description = "Unique key allocated and used within the scope of a single system."; - final String element1DescriptionGUID = null; + RelationshipEndDef relationshipEndDef; - elementDef = getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID); - elementDefs.add(elementDef); + /* + * Set up end 1. + */ + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "relatedItem"; + final String end1AttributeDescription = "Item that is referencing this work."; + final String end1AttributeDescriptionGUID = null; + final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; - final int element2Ordinal = 1; - final String element2Value = "Recycled Key"; - final String element2Description = "Key allocated and used within the scope of a single system that is periodically reused for different records."; - final String element2DescriptionGUID = null; + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); - elementDef = getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID); - elementDefs.add(elementDef); - final int element3Ordinal = 2; - final String element3Value = "Natural Key"; - final String element3Description = "Key derived from an attribute of the entity, such as email address, passport number."; - final String element3DescriptionGUID = null; + /* + * Set up end 2. + */ + final String end2EntityType = "ExternalReference"; + final String end2AttributeName = "externalReference"; + final String end2AttributeDescription = "Link to more information from an external source."; + final String end2AttributeDescriptionGUID = null; + final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; - elementDef = getEnumElementDef(element3Ordinal, element3Value, element3Description, element3DescriptionGUID); - elementDefs.add(elementDef); + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); - final int element4Ordinal = 3; - final String element4Value = "Mirror Key"; - final String element4Description = "Key value copied from another system."; - final String element4DescriptionGUID = null; + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; - elementDef = getEnumElementDef(element4Ordinal, element4Value, element4Description, element4DescriptionGUID); - elementDefs.add(elementDef); + final String attribute1Name = "referenceId"; + final String attribute1Description = "Local identifier for the reference."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "description"; + final String attribute2Description = "Description of the relevance of this reference to the linked item."; + final String attribute2DescriptionGUID = null; - final int element5Ordinal = 4; - final String element5Value = "Aggregate Key"; - final String element5Description = "Key formed by combining keys from multiple systems."; - final String element5DescriptionGUID = null; + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); + properties.add(property); - elementDef = getEnumElementDef(element5Ordinal, element5Value, element5Description, element5DescriptionGUID); - elementDefs.add(elementDef); + relationshipDef.setPropertiesDefinition(properties); - final int element6Ordinal = 5; - final String element6Value = "Caller's Key"; - final String element6Description = "Key from another system can bey used if system name provided."; - final String element6DescriptionGUID = null; + return relationshipDef; + } - elementDef = getEnumElementDef(element6Ordinal, element6Value, element6Description, element6DescriptionGUID); - elementDefs.add(elementDef); - final int element7Ordinal = 6; + private RelationshipDef getMediaReferenceRelationship() + { + final String guid = "1353400f-b0ab-4ab9-ab09-3045dd8a7140"; + final String name = "MediaReference"; + final String description = "Link to related media such as images, videos and audio."; + final String descriptionGUID = null; + + final RelationshipCategory relationshipCategory = RelationshipCategory.ASSOCIATION; + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "consumingItem"; + final String end1AttributeDescription = "Item that is referencing this work."; + final String end1AttributeDescriptionGUID = null; + final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "RelatedMedia"; + final String end2AttributeName = "relatedMedia"; + final String end2AttributeDescription = "Link to external media."; + final String end2AttributeDescriptionGUID = null; + final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "mediaId"; + final String attribute1Description = "Local identifier for the media."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "description"; + final String attribute2Description = "Description of the relevance of this media to the linked item."; + final String attribute2DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID); + properties.add(property); + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; + } + + + private RelationshipDef getMediaUsageGuidanceRelationship() + { + final String guid = "952b5c8b-42fb-4ff2-a15f-a9eebb82d2ca"; + final String name = "MediaUsageGuidance"; + final String description = "Link to information on how a specific piece of media could be used."; + final String descriptionGUID = null; + + final RelationshipCategory relationshipCategory = RelationshipCategory.COMPOSITION; + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "RelatedMedia"; + final String end1AttributeName = "parentMedia"; + final String end1AttributeDescription = "Parent media that this guidance is for."; + final String end1AttributeDescriptionGUID = null; + final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "MediaUsage"; + final String end2AttributeName = "usageRecommendation"; + final String end2AttributeDescription = "Link to guidance on how related media should be used."; + final String end2AttributeDescriptionGUID = null; + final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + return relationshipDef; + } + + /* + * ------------------------------------------------------------------------------------------------------- + */ + + + /** + * 0017 External Identifiers define identifiers used to identify this entity in other systems. + */ + private void add0017ExternalIdentifiers() + { + this.archiveBuilder.addEnumDef(getKeyPatternEnum()); + + this.archiveBuilder.addEntityDef(getExternalIdEntity()); + + this.archiveBuilder.addRelationshipDef(getExternalIdScopeRelationship()); + this.archiveBuilder.addRelationshipDef(getExternalIdLinkRelationship()); + } + + + private EnumDef getKeyPatternEnum() + { + final String guid = "8904df8f-1aca-4de8-9abd-1ef2aadba300"; + final String name = "KeyPattern"; + final String description = "Defines the type of identifier used for an asset."; + final String descriptionGUID = null; + + EnumDef enumDef = archiveHelper.getEmptyEnumDef(guid, name, description, descriptionGUID); + + ArrayList<EnumElementDef> elementDefs = new ArrayList<>(); + EnumElementDef elementDef; + + final int element1Ordinal = 0; + final String element1Value = "Local Key"; + final String element1Description = "Unique key allocated and used within the scope of a single system."; + final String element1DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID); + elementDefs.add(elementDef); + + final int element2Ordinal = 1; + final String element2Value = "Recycled Key"; + final String element2Description = "Key allocated and used within the scope of a single system that is periodically reused for different records."; + final String element2DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID); + elementDefs.add(elementDef); + + final int element3Ordinal = 2; + final String element3Value = "Natural Key"; + final String element3Description = "Key derived from an attribute of the entity, such as email address, passport number."; + final String element3DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element3Ordinal, element3Value, element3Description, element3DescriptionGUID); + elementDefs.add(elementDef); + + final int element4Ordinal = 3; + final String element4Value = "Mirror Key"; + final String element4Description = "Key value copied from another system."; + final String element4DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element4Ordinal, element4Value, element4Description, element4DescriptionGUID); + elementDefs.add(elementDef); + + final int element5Ordinal = 4; + final String element5Value = "Aggregate Key"; + final String element5Description = "Key formed by combining keys from multiple systems."; + final String element5DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element5Ordinal, element5Value, element5Description, element5DescriptionGUID); + elementDefs.add(elementDef); + + final int element6Ordinal = 5; + final String element6Value = "Caller's Key"; + final String element6Description = "Key from another system can bey used if system name provided."; + final String element6DescriptionGUID = null; + + elementDef = archiveHelper.getEnumElementDef(element6Ordinal, element6Value, element6Description, element6DescriptionGUID); + elementDefs.add(elementDef); + + final int element7Ordinal = 6; final String element7Value = "Stable Key"; final String element7Description = "Key value will remain active even if records are merged."; final String element7DescriptionGUID = null; - elementDef = getEnumElementDef(element7Ordinal, element7Value, element7Description, element7DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element7Ordinal, element7Value, element7Description, element7DescriptionGUID); elementDefs.add(elementDef); final int element8Ordinal = 99; @@ -1064,45 +1059,209 @@ public class OpenMetadataTypesArchive final String element8Description = "Another key pattern."; final String element8DescriptionGUID = null; - elementDef = getEnumElementDef(element8Ordinal, element8Value, element8Description, element8DescriptionGUID); + elementDef = archiveHelper.getEnumElementDef(element8Ordinal, element8Value, element8Description, element8DescriptionGUID); elementDefs.add(elementDef); + enumDef.setElementDefs(elementDefs); + return enumDef; } - private EntityDef getExternalIdEntity() + + private EntityDef getExternalIdEntity() { - final String guid = "7c8f8c2c-cc48-429e-8a21-a1f1851ccdb0"; + final String guid = "7c8f8c2c-cc48-429e-8a21-a1f1851ccdb0"; final String name = "ExternalId"; final String description = "Alternative identifier used in another system."; final String descriptionGUID = null; - // TODO - return null; + final String superTypeName = "Referenceable"; + + EntityDef entityDef = archiveHelper.getDefaultEntityDef(guid, + name, + this.archiveBuilder.getEntityDef(superTypeName), + description, + descriptionGUID); + + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "identifier"; + final String attribute1Description = "Identifier used in an external system."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "keyPattern"; + final String attribute2Description = "Management pattern associated with the identifier."; + final String attribute2DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); + properties.add(property); + property = archiveHelper.getEnumTypeDefAttribute("KeyPattern", attribute2Name, attribute2Description, attribute2DescriptionGUID); + properties.add(property); + + entityDef.setPropertiesDefinition(properties); + + return entityDef; } - private RelationshipDef getExternalIdScopeRelationship() + + private RelationshipDef getExternalIdScopeRelationship() { - final String guid = "8c5b1415-2d1f-4190-ba6c-1fdd47f03269"; + final String guid = "8c5b1415-2d1f-4190-ba6c-1fdd47f03269"; final String name = "ExternalIdScope"; final String description = "Places where an external identifier is recognized."; final String descriptionGUID = null; - // TODO - return null; + final RelationshipCategory relationshipCategory = RelationshipCategory.ASSOCIATION; + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "scopedTo"; + final String end1AttributeDescription = "Identifies where this external identifier is known."; + final String end1AttributeDescriptionGUID = null; + final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "ExternalId"; + final String end2AttributeName = "managedResources"; + final String end2AttributeDescription = "Link to details of a resource that this component manages."; + final String end2AttributeDescriptionGUID = null; + final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "description"; + final String attribute1Description = "Description of the relationship between the resources and the managing component."; + final String attribute1DescriptionGUID = null; + + property = archiveHelper.getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID); + properties.add(property); + + + relationshipDef.setPropertiesDefinition(properties); + + return relationshipDef; } - private RelationshipDef getExternalIdLinkRelationship() + + private RelationshipDef getExternalIdLinkRelationship() { - final String guid = "28ab0381-c662-4b6d-b787-5d77208de126"; + final String guid = "28ab0381-c662-4b6d-b787-5d77208de126"; final String name = "ExternalIdLink"; - final String description = "Link between an external identifier and an asset."; + final String description = "Link between an external identifier and an asset or related item."; final String descriptionGUID = null; - // TODO - return null; + final RelationshipCategory relationshipCategory = RelationshipCategory.ASSOCIATION; + final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE; + + RelationshipDef relationshipDef = archiveHelper.getBasicRelationshipDef(guid, + name, + null, + description, + descriptionGUID, + relationshipCategory, + classificationPropagationRule); + + RelationshipEndDef relationshipEndDef; + + /* + * Set up end 1. + */ + final String end1EntityType = "Referenceable"; + final String end1AttributeName = "resource"; + final String end1AttributeDescription = "Resource being identified."; + final String end1AttributeDescriptionGUID = null; + final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType), + end1AttributeName, + end1AttributeDescription, + end1AttributeDescriptionGUID, + end1Cardinality); + relationshipDef.setEndDef1(relationshipEndDef); + + + /* + * Set up end 2. + */ + final String end2EntityType = "ExternalId"; + final String end2AttributeName = "alsoKnownAs"; + final String end2AttributeDescription = "Identifier used in an external system."; + final String end2AttributeDescriptionGUID = null; + final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED; + + relationshipEndDef = archiveHelper.getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType), + end2AttributeName, + end2AttributeDescription, + end2AttributeDescriptionGUID, + end2Cardinality); + relationshipDef.setEndDef2(relationshipEndDef); + + /* + * Build the attributes + */ + ArrayList<TypeDefAttribute> properties = new ArrayList<>(); + TypeDefAttribute property; + + final String attribute1Name = "description"; + final String attribute1Description = "Description of how the external identifier relates to the resource."; + final String attribute1DescriptionGUID = null; + final String attribute2Name = "usage"; + final String attribute2Description = "Description of how the exter
<TRUNCATED>