java.lang.Object
org.odpi.openmetadata.frameworks.integration.bitol.mapping.BitolMapperBase
Direct Known Subclasses:
DataContractMapper, DataProductMapper

public abstract class BitolMapperBase extends Object
BitolMapperBase holds the mapping logic that is shared by the Open Data Contract Standard (ODCS) and Open Data Product Standard (ODPS) mappers: the fundamentals of a document (identity, status, description, tags), custom properties, authoritative definitions, support channels and teams. The mappers work through the connector context clients so that they can run inside an integration connector (through the IntegrationContext) or inside a view service that builds a ConnectorContextBase for the calling user.

Every element created from a document has a deterministic qualifiedName built from the document's identifier and version, so that republishing a document updates the existing elements rather than duplicating them, and each version of a document is a distinct element. The document identifier is also recorded as an ExternalId shared by all versions.
  • Field Details

    • ADDITIONAL_PROPERTY_PREFIX

      public static final String ADDITIONAL_PROPERTY_PREFIX
      Prefix used in additionalProperties for values that have no home in the open metadata types.
      See Also:
    • CUSTOM_PROPERTIES_JSON

      public static final String CUSTOM_PROPERTIES_JSON
      Name of the additional property that holds the full custom properties list as JSON when an entry carries a vendor, description or id.
      See Also:
    • CONTEXT_JSON

      public static final String CONTEXT_JSON
      Name of the additional property that holds the AI context block as JSON.
      See Also:
    • SYNONYMS_JSON

      public static final String SYNONYMS_JSON
      Name of the additional property that holds the synonyms as JSON.
      See Also:
    • DEPRECATED

      public static final String DEPRECATED
      Name of the additional property that records that an element is deprecated.
      See Also:
    • SEPARATOR

      public static final String SEPARATOR
      See Also:
    • context

      protected final ConnectorContextBase context
  • Constructor Details

    • BitolMapperBase

      protected BitolMapperBase(ConnectorContextBase context)
      Constructor.
      Parameters:
      context - connector context providing access to the open metadata clients
  • Method Details

    • getDocumentQualifiedName

      public static String getDocumentQualifiedName(String kind, String id, String version)
      Build the qualified name for the element that represents a document version.
      Parameters:
      kind - kind of document
      id - document identifier
      version - document version (may be null)
      Returns:
      qualified name
    • getExternalIdQualifiedName

      public static String getExternalIdQualifiedName(String kind, String id)
      Build the qualified name for the ExternalId that carries a document identifier. It is shared by all versions.
      Parameters:
      kind - kind of document
      id - document identifier
      Returns:
      qualified name
    • findElementGUID

      Return the unique identifier of the element with the supplied qualified name, or null if there is none.
      Parameters:
      qualifiedName - qualified name to look for
      Returns:
      guid or null
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • findElementsByDocumentId

      Return the elements identified by a document identifier, found through the ExternalId that all versions of the document share.
      Parameters:
      kind - kind of document
      id - document identifier
      Returns:
      list of elements (empty if none)
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • getLatestVersion

      protected OpenMetadataRootElement getLatestVersion(List<OpenMetadataRootElement> elements)
      Return the element with the highest version identifier from the supplied list. Versions are compared as dot-separated numbers where possible, otherwise as strings.
      Parameters:
      elements - candidate elements
      Returns:
      chosen element or null if the list is empty
    • fillFundamentals

      protected void fillFundamentals(BitolDocument document, AuthoredReferenceableProperties properties, String qualifiedName)
      Copy the fundamentals of a document into the properties of the element that represents it.
      Parameters:
      document - document
      properties - properties to fill
      qualifiedName - qualified name for the element
    • setContentStatus

      protected void setContentStatus(String status, AuthoredReferenceableProperties properties)
      Map a Bitol status onto the content status of an element. Values outside the standard set are recorded as OTHER with the original value in userDefinedContentStatus.
      Parameters:
      status - status from the document
      properties - properties to update
    • isRetired

      protected boolean isRetired(BitolDocument document)
      Return whether the document has been retired, in which case its element is deleted rather than maintained.
      Parameters:
      document - document
      Returns:
      boolean
    • addDescriptionDetails

      protected void addDescriptionDetails(BitolDescription description, Map<String,String> additionalProperties)
      Copy the limitations and usage of a description into additional properties.
      Parameters:
      description - description structure (may be null)
      additionalProperties - map to add to
    • addCustomProperties

      protected void addCustomProperties(List<BitolCustomProperty> customProperties, Map<String,String> additionalProperties)
      Copy custom properties into additional properties. Values that are not simple strings are rendered with toString so that lists and structures are still visible.
      Parameters:
      customProperties - custom properties from the document (may be null)
      additionalProperties - map to add to
    • canonical

      protected static <E extends Enum<E>> String canonical(String value, E standard)
      Return the standard spelling of a vocabulary value when it is one of the standard values, otherwise the value as written in the document. The enumerations are also registered as valid metadata values by the Core Content Pack, so a standard value stored this way matches the valid value exactly.
      Type Parameters:
      E - enumeration type
      Parameters:
      value - value from the document (may be null)
      standard - the enumeration matched from the value, or null if it is not a standard value
      Returns:
      canonical value or the original
    • putIfPresent

      protected static void putIfPresent(Map<String,String> additionalProperties, String name, String value)
      Add a value to the additional properties under the bitol prefix if it is present.
      Parameters:
      additionalProperties - map to add to
      name - property name (without prefix)
      value - value (may be null)
    • toJSON

      protected String toJSON(Object bean)
      Format a bean (or list of beans) from a document as a JSON fragment for an additional property, so that it can be regenerated without loss.
      Parameters:
      bean - bean (may be null)
      Returns:
      json text or null
    • toStringValue

      protected String toStringValue(Object value)
      Return a value from a document as a string for additionalProperties.
      Parameters:
      value - value (may be null)
      Returns:
      string or null
    • linkExternalId

      protected void linkExternalId(String kind, String id, String elementGUID, String source) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException
      Record the document identifier as an ExternalId linked to the element. The ExternalId is shared by all versions of the document, so it is created once and linked to each version's element.
      Parameters:
      kind - kind of document
      id - document identifier
      elementGUID - element representing this version
      source - description of where the document came from
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • addSearchKeywords

      protected void addSearchKeywords(List<String> tags, String elementGUID) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException
      Attach the document's tags to the element as search keywords.
      Parameters:
      tags - tags from the document (may be null)
      elementGUID - element to tag
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • linkTenantOrganization

      protected void linkTenantOrganization(String tenant, String elementGUID) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException
      Link the element to the organization named as the document's tenant, creating the organization profile if it is not already known. The element is scoped by the organization.
      Parameters:
      tenant - tenant from the document (may be null)
      elementGUID - element to link
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • linkAuthoritativeDefinitions

      protected void linkAuthoritativeDefinitions(List<BitolAuthoritativeDefinition> authoritativeDefinitions, String elementGUID) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException
      Link the element to external references for the document's authoritative definitions, creating each reference if its URL is not already known.
      Parameters:
      authoritativeDefinitions - definitions from the document (may be null)
      elementGUID - element to link
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • linkSupportChannels

      protected void linkSupportChannels(List<BitolSupportChannel> supportChannels, String elementGUID, String elementQualifiedName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException
      Create contact details for each of the document's support channels and link them to the element. The contact details are anchored to the element so they are removed with it.
      Parameters:
      supportChannels - channels from the document (may be null)
      elementGUID - element to link
      elementQualifiedName - qualified name of the element (used to build the contact details' names)
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • getContactMethodType

      protected ContactMethodType getContactMethodType(String tool)
      Map a Bitol support tool onto a contact method type.
      Parameters:
      tool - tool from the document (may be null)
      Returns:
      enum
    • linkTeam

      protected void linkTeam(BitolTeam team, String elementGUID, String elementQualifiedName, BitolMappingResult result) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException
      Create the team and the roles for the team members described in the document. The team is a Team profile named from the document; each member becomes a PersonRole scoped to the element (ScopedBy). Where the member's username is known to Egeria as a user identity with a profile, the profile is appointed to the role; otherwise the username and name are recorded on the role's additional properties and reported as a warning.
      Parameters:
      team - team from the document (may be null)
      elementGUID - element that the roles are scoped to
      elementQualifiedName - qualified name of the element (used to build the roles' names)
      result - result to record warnings in
      Throws:
      InvalidParameterException - invalid parameter
      PropertyServerException - problem with the metadata store
      UserNotAuthorizedException - security problem
    • parseDate

      protected Date parseDate(String value)
      Parse an ISO date (yyyy-MM-dd) from the document.
      Parameters:
      value - date string (may be null)
      Returns:
      date or null if missing or malformed