Class CustomMetadataCache

All Implemented Interfaces:
Closeable, AutoCloseable

public class CustomMetadataCache extends AbstractMassCache<CustomMetadataDef>
Lazily-loaded cache for translating between Atlan-internal ID strings and human-readable names for custom metadata (including attributes).
  • Constructor Details

    • CustomMetadataCache

      public CustomMetadataCache(AtlanClient client)
  • Method Details

    • refreshCache

      protected void refreshCache() throws AtlanException
      Logic to refresh a specific cache en-masse (must be implemented).
      Specified by:
      refreshCache in class AbstractMassCache<CustomMetadataDef>
      Throws:
      AtlanException - on any error communicating with Atlan to refresh the cache of objects
    • lookupByName

      protected void lookupByName(String name)
      Logic to look up a single object for the cache.
      Specified by:
      lookupByName in class AbstractMassCache<CustomMetadataDef>
      Parameters:
      name - unique name for the object
    • lookupById

      protected void lookupById(String id)
      Logic to look up a single object for the cache.
      Specified by:
      lookupById in class AbstractMassCache<CustomMetadataDef>
      Parameters:
      id - unique internal identifier for the object
    • getAllCustomAttributes

      public Map<String,List<AttributeDef>> getAllCustomAttributes() throws AtlanException
      Retrieve all the (active) custom metadata attributes. The map will be keyed by custom metadata set name, and the value will be a listing of all the (active) attributes within that set (with all the details of each of those attributes).
      Returns:
      a map from custom metadata set name to all details about all its active attributes
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getAllCustomAttributes

      public Map<String,List<AttributeDef>> getAllCustomAttributes(boolean includeDeleted) throws AtlanException
      Retrieve all the custom metadata attributes. The map will be keyed by custom metadata set name, and the value will be a listing of all the attributes within that set (with all the details of each of those attributes).
      Parameters:
      includeDeleted - if true, include the archived (deleted) custom attributes; otherwise only include active custom attributes
      Returns:
      a map from custom metadata set name to all details about all its attributes
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getAllCustomAttributes

      public Map<String,List<AttributeDef>> getAllCustomAttributes(boolean includeDeleted, boolean forceRefresh) throws AtlanException
      Retrieve all the custom metadata attributes. The map will be keyed by custom metadata set name, and the value will be a listing of all the attributes within that set (with all the details of each of those attributes).
      Parameters:
      includeDeleted - if true, include the archived (deleted) custom attributes; otherwise only include active custom attributes
      forceRefresh - if true, will refresh the custom metadata cache; if false, will only refresh the cache if it is empty
      Returns:
      a map from custom metadata set name to all details about all its attributes
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getAttrIdForName

      public String getAttrIdForName(String setName, String attributeName) throws AtlanException
      Translate the provided human-readable custom metadata set and attribute names to the Atlan-internal ID string for the attribute.
      Parameters:
      setName - human-readable name of the custom metadata set
      attributeName - human-readable name of the attribute
      Returns:
      Atlan-internal ID string for the attribute
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
      NotFoundException - if the custom metadata cannot be found (does not exist) in Atlan
      InvalidRequestException - if no name was provided for the custom metadata to retrieve
    • getAttrIdForName

      public String getAttrIdForName(String setName, String attributeName, boolean allowRefresh) throws AtlanException
      Translate the provided human-readable custom metadata set and attribute names to the Atlan-internal ID string for the attribute.
      Parameters:
      setName - human-readable name of the custom metadata set
      attributeName - human-readable name of the attribute
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      Atlan-internal ID string for the attribute
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
      NotFoundException - if the custom metadata cannot be found (does not exist) in Atlan
      InvalidRequestException - if no name was provided for the custom metadata to retrieve
    • getAttributeForSearchResults

      public String getAttributeForSearchResults(String setName, String attributeName) throws AtlanException
      Retrieve a single custom attribute name to include on search results.
      Parameters:
      setName - human-readable name of the custom metadata set for which to retrieve the custom metadata attribute name
      attributeName - human-readable name of the attribute
      Returns:
      the attribute name, strictly useful for inclusion in search results
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
      NotFoundException - if the custom metadata cannot be found (does not exist) in Atlan
      InvalidRequestException - if no name was provided for the custom metadata to retrieve
      See Also:
    • getAttributeForSearchResults

      public String getAttributeForSearchResults(String setName, String attributeName, boolean allowRefresh) throws AtlanException
      Retrieve a single custom attribute name to include on search results.
      Parameters:
      setName - human-readable name of the custom metadata set for which to retrieve the custom metadata attribute name
      attributeName - human-readable name of the attribute
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      the attribute name, strictly useful for inclusion in search results
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
      NotFoundException - if the custom metadata cannot be found (does not exist) in Atlan
      InvalidRequestException - if no name was provided for the custom metadata to retrieve
      See Also:
    • getAttributesForSearchResults

      public Set<String> getAttributesForSearchResults(String setName) throws AtlanException
      Retrieve the full set of custom attributes to include on search results.
      Parameters:
      setName - human-readable name of the custom metadata set for which to retrieve a set of attribute names
      Returns:
      a set of the attribute names, strictly useful for inclusion in search results
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
      NotFoundException - if the custom metadata cannot be found (does not exist) in Atlan
      InvalidRequestException - if no name was provided for the custom metadata to retrieve
      See Also:
    • getAttributesForSearchResults

      public Set<String> getAttributesForSearchResults(String setName, boolean allowRefresh) throws AtlanException
      Retrieve the full set of custom attributes to include on search results.
      Parameters:
      setName - human-readable name of the custom metadata set for which to retrieve a set of attribute names
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      a set of the attribute names, strictly useful for inclusion in search results
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
      NotFoundException - if the custom metadata cannot be found (does not exist) in Atlan
      InvalidRequestException - if no name was provided for the custom metadata to retrieve
      See Also:
    • getAttributeDef

      public AttributeDef getAttributeDef(String attributeId) throws AtlanException
      Retrieve a specific custom metadata attribute definition by its unique Atlan-internal ID string.
      Parameters:
      attributeId - Atlan-internal ID string for the custom metadata attribute
      Returns:
      attribute definition for the custom metadata attribute
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getAttributeDef

      public AttributeDef getAttributeDef(String attributeId, boolean allowRefresh) throws AtlanException
      Retrieve a specific custom metadata attribute definition by its unique Atlan-internal ID string.
      Parameters:
      attributeId - Atlan-internal ID string for the custom metadata attribute
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      attribute definition for the custom metadata attribute
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getEmptyAttributes

      public Map<String,Object> getEmptyAttributes(String customMetadataName) throws AtlanException
      Construct a full set of attributes for the given custom metadata, but where all the values are null.
      Parameters:
      customMetadataName - for which to construct the empty map
      Returns:
      a map from custom metadata attribute name (human-readable) to null values
      Throws:
      AtlanException - on any API issues
    • getEmptyAttributes

      public Map<String,Object> getEmptyAttributes(String customMetadataName, boolean allowRefresh) throws AtlanException
      Construct a full set of attributes for the given custom metadata, but where all the values are null.
      Parameters:
      customMetadataName - for which to construct the empty map
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      a map from custom metadata attribute name (human-readable) to null values
      Throws:
      AtlanException - on any API issues
    • getBusinessAttributesFromCustomMetadata

      public void getBusinessAttributesFromCustomMetadata(Map<String,CustomMetadataAttributes> customMetadata, Map<String,Map<String,Object>> businessAttributes) throws AtlanException
      Translate the provided custom metadata object into a business attributes object. We receive the businessAttributes object (rather than creating a new one) to initialize it with any existing business attributes.
      Parameters:
      customMetadata - custom metadata object
      businessAttributes - business attributes object, which will be changed
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getBusinessAttributesFromCustomMetadata

      public void getBusinessAttributesFromCustomMetadata(Map<String,CustomMetadataAttributes> customMetadata, Map<String,Map<String,Object>> businessAttributes, boolean allowRefresh) throws AtlanException
      Translate the provided custom metadata object into a business attributes object. We receive the businessAttributes object (rather than creating a new one) to initialize it with any existing business attributes.
      Parameters:
      customMetadata - custom metadata object
      businessAttributes - business attributes object, which will be changed
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getAttributesFromCustomMetadata

      public void getAttributesFromCustomMetadata(String cmId, String cmName, CustomMetadataAttributes cma, Map<String,Object> attributes) throws AtlanException
      Translate the provided custom metadata attributes object into a hashed-string ID map of attributes and values. We receive the attributes object (rather than creating a new one) to initialize it with any existing attributes.
      Parameters:
      cmId - hashed-string ID of the custom metadata set (structure)
      cmName - human-readable name of the custom metadata set (structure)
      cma - custom metadata attributes in human-readable form
      attributes - map of custom metadata attributes keyed by hashed-string ID of the attribute
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getAttributesFromCustomMetadata

      public void getAttributesFromCustomMetadata(String cmId, String cmName, CustomMetadataAttributes cma, Map<String,Object> attributes, boolean allowRefresh) throws AtlanException
      Translate the provided custom metadata attributes object into a hashed-string ID map of attributes and values. We receive the attributes object (rather than creating a new one) to initialize it with any existing attributes.
      Parameters:
      cmId - hashed-string ID of the custom metadata set (structure)
      cmName - human-readable name of the custom metadata set (structure)
      cma - custom metadata attributes in human-readable form
      attributes - map of custom metadata attributes keyed by hashed-string ID of the attribute
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getIdMapFromNameMap

      public void getIdMapFromNameMap(String customMetadataName, Map<String,Object> nameToValue, Map<String,Object> idToValue) throws AtlanException
      Translate the provided map keyed by human-readable attribute name into a map of keyed by attribute id. We receive the idToValue map (rather than creating a new one) to initialize it with any existing business attributes.
      Parameters:
      customMetadataName - human-readable name of the custom metadata
      nameToValue - the attributes and their values for the custom metadata
      idToValue - the business metadata to map into
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getIdMapFromNameMap

      public void getIdMapFromNameMap(String customMetadataName, Map<String,Object> nameToValue, Map<String,Object> idToValue, boolean allowRefresh) throws AtlanException
      Translate the provided map keyed by human-readable attribute name into a map of keyed by attribute id. We receive the idToValue map (rather than creating a new one) to initialize it with any existing business attributes.
      Parameters:
      customMetadataName - human-readable name of the custom metadata
      nameToValue - the attributes and their values for the custom metadata
      idToValue - the business metadata to map into
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getCustomMetadataFromBusinessAttributes

      public Map<String,CustomMetadataAttributes> getCustomMetadataFromBusinessAttributes(com.fasterxml.jackson.databind.JsonNode businessAttributes) throws AtlanException
      Translate the provided business attributes object into a custom metadata object.
      Parameters:
      businessAttributes - business attributes object
      Returns:
      custom metadata object
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getCustomMetadataFromBusinessAttributes

      public Map<String,CustomMetadataAttributes> getCustomMetadataFromBusinessAttributes(com.fasterxml.jackson.databind.JsonNode businessAttributes, boolean allowRefresh) throws AtlanException
      Translate the provided business attributes object into a custom metadata object.
      Parameters:
      businessAttributes - business attributes object
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      custom metadata object
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getCustomMetadataAttributes

      public CustomMetadataAttributes getCustomMetadataAttributes(String cmId, com.fasterxml.jackson.databind.JsonNode attributes) throws AtlanException
      Translate the provided attributes structure into a human-readable map of attribute names to values.
      Parameters:
      cmId - custom metadata hashed-string ID
      attributes - embedded attributes structure with hashed-string IDs
      Returns:
      deserialized CustomMetadataAttributes object
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getCustomMetadataAttributes

      public CustomMetadataAttributes getCustomMetadataAttributes(String cmId, com.fasterxml.jackson.databind.JsonNode attributes, boolean allowRefresh) throws AtlanException
      Translate the provided attributes structure into a human-readable map of attribute names to values.
      Parameters:
      cmId - custom metadata hashed-string ID
      attributes - embedded attributes structure with hashed-string IDs
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      deserialized CustomMetadataAttributes object
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getCustomMetadataFromSearchResult

      public Map<String,CustomMetadataAttributes> getCustomMetadataFromSearchResult(Map<String,com.fasterxml.jackson.databind.JsonNode> embeddedAttributes) throws AtlanException
      Translate the provided search result-embedded custom metadata into a custom metadata object.
      Parameters:
      embeddedAttributes - map of custom metadata that was embedded in search result attributes, keyed by <cmId>.<attrId> with the value of that custom attribute
      Returns:
      custom metadata object
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • getCustomMetadataFromSearchResult

      public Map<String,CustomMetadataAttributes> getCustomMetadataFromSearchResult(Map<String,com.fasterxml.jackson.databind.JsonNode> embeddedAttributes, boolean allowRefresh) throws AtlanException
      Translate the provided search result-embedded custom metadata into a custom metadata object.
      Parameters:
      embeddedAttributes - map of custom metadata that was embedded in search result attributes, keyed by <cmId>.<attrId> with the value of that custom attribute
      allowRefresh - whether to allow a refresh of the cache (true) or not (false)
      Returns:
      custom metadata object
      Throws:
      AtlanException - on any API communication problem if the cache needs to be refreshed
    • deserializePrimitive

      public static Object deserializePrimitive(com.fasterxml.jackson.databind.JsonNode jsonValue) throws LogicException
      Throws:
      LogicException