public class ClassificationMapping extends InstanceAuditHeaderMapping
Maps the properties of Classifications between persistence and objects. The idea is to map Classifications into a XTDB data model that flattens their structure into the EntitySummary structure itself (so they are always retrieved with the EntitySummary document), using the following convention: { ... :classifications.Confidentiality/type :type/(GUID) :classifications.Confidentiality/instanceLicense "" :classifications.Confidentiality/createTime #inst "2021-01-26T16:35:37.504-00:00" :classifications.Confidentiality.classificationProperties/level ... ... :classifications.AnotherClassification/type :type/(GUID) :classifications.AnotherClassification/createTime #inst "2021-01-26T16:30:37.504-00:00" :classifications.AnotherClassification.classificationProperties/property ... ... } In this way, each classification can be kept separate from other classifications, and a single classification's value remains mutually-exclusive with any other values for that classification (due to the unique reference name of the properties of that classification).
  • Field Details

    • CLASSIFICATION_PROPERTIES_NS

      public static final String CLASSIFICATION_PROPERTIES_NS
      See Also:
    • N_LAST_CLASSIFICATION_CHANGE

      public static final String N_LAST_CLASSIFICATION_CHANGE
      See Also:
    • LAST_CLASSIFICATION_CHANGE

      public static final String LAST_CLASSIFICATION_CHANGE
  • Constructor Details

    • ClassificationMapping

      public ClassificationMapping(XTDBOMRSRepositoryConnector xtdbConnector, List<Classification> classifications)
      Construct a mapping from a Classification (to map to a XTDB representation).
      Parameters:
      xtdbConnector - connectivity to XTDB
      classifications - from which to map
    • ClassificationMapping

      public ClassificationMapping(XTDBOMRSRepositoryConnector xtdbConnector, xtdb.api.XtdbDocument xtdbDoc)
      Construct a mapping from a XTDB map (to map to an Egeria representation).
      Parameters:
      xtdbConnector - connectivity to XTDB
      xtdbDoc - from which to map
  • Method Details

    • isKnownBaseProperty

      public static boolean isKnownBaseProperty(String property)
      Check whether the specified property is a known base-level Classification property.
      Parameters:
      property - to check
      Returns:
      boolean
    • addToXtdbDoc

      public void addToXtdbDoc(xtdb.api.XtdbDocument.Builder builder)
      Add the details of the mapping to the provided XtdbDocument builder.
      Parameters:
      builder - into which to add the classification details
    • addToMap

      public static clojure.lang.IPersistentMap addToMap(clojure.lang.IPersistentMap doc, Classification classification) throws IOException, InvalidParameterException
      Add the details of the provided classification to the XTDB document map.
      Parameters:
      doc - document map into which to add the classification details
      classification - to add into the doc
      Returns:
      IPersistentMap the updated document map
      Throws:
      IOException - on any error serializing the classification
      InvalidParameterException - on any type-related property error
    • removeFromMap

      public static clojure.lang.IPersistentMap removeFromMap(clojure.lang.IPersistentMap doc, String classificationName) throws ClassificationErrorException
      Remove all details of the provided classification name from the XTDB document map.
      Parameters:
      doc - document map from which to remove the classification details
      classificationName - to remove from the doc
      Returns:
      IPersistentMap the updated document map
      Throws:
      ClassificationErrorException - if the provided document map does not contain the specified classification
    • validateHasClassification

      public static void validateHasClassification(clojure.lang.IPersistentMap instance, String classificationName, String className, String methodName) throws ClassificationErrorException
      Validates that the provided metadata instance possesses the specified classification.
      Parameters:
      instance - to confirm possesses the classification
      classificationName - to confirm the instance possesses
      className - class called
      methodName - method called
      Throws:
      ClassificationErrorException - if the instance does not possess the classification
    • toEgeria

      public List<Classification> toEgeria()
      Map from XTDB to Egeria.
      Returns:
      List<Classification>
      See Also:
    • fromDoc

      protected List<Classification> fromDoc()
      Translate the provided XTDB representation into an Egeria representation.
      Returns:
      List<Classification>
    • fromMap

      public static List<Classification> fromMap(clojure.lang.IPersistentMap doc) throws IOException, InvalidParameterException
      Translate the provided XTDB representation into an Egeria representation.
      Parameters:
      doc - from which to map
      Returns:
      List<Classification>
      Throws:
      IOException - on any issue deserializing values
      InvalidParameterException - for any unmapped properties
    • getNamespaceForClassification

      public static String getNamespaceForClassification(String root, String classificationName)
      Given a classification name and qualifying namespace, convert into a qualified name that can be used for the classification-specific namespace.
      Parameters:
      root - namespace
      classificationName - of the classification
      Returns:
      String qualified namespace
    • getClassificationNameFromNamespace

      public static String getClassificationNameFromNamespace(String root, String qualifiedNamespace)
      Given a fully-qualified classification namespace and a root, parse out the name of the classification.
      Parameters:
      root - namespace
      qualifiedNamespace - fully-qualified classification namespace
      Returns:
      String classification name
    • getNamespaceForClassification

      public static String getNamespaceForClassification(String classificationName)
      Given a classification name (on its own), convert it into a qualified name that can be used for the namespace.
      Parameters:
      classificationName - to translate
      Returns:
      String qualified namespace
    • getClassificationOriginFromSymbolicName

      public static ClassificationOrigin getClassificationOriginFromSymbolicName(XTDBOMRSRepositoryConnector xtdbConnector, String symbolicName)
      Convert the provided symbolic name into its ClassificationOrigin.
      Parameters:
      xtdbConnector - connectivity to the repository
      symbolicName - to convert
      Returns:
      ClassificationOrigin
    • getClassificationOriginFromSymbolicName

      public static ClassificationOrigin getClassificationOriginFromSymbolicName(String symbolicName) throws InvalidParameterException
      Convert the provided symbolic name into its ClassificationOrigin.
      Parameters:
      symbolicName - to convert
      Returns:
      ClassificationOrigin
      Throws:
      InvalidParameterException - if there is no such symbolic name
    • getSymbolicNameForClassificationOrigin

      public static String getSymbolicNameForClassificationOrigin(ClassificationOrigin co)
      Convert the provided ClassificationOrigin into its symbolic name.
      Parameters:
      co - to convert
      Returns:
      String
    • getNamespaceForProperties

      public static String getNamespaceForProperties(String qualifiedRoot)
      Retrieve the namespace for properties of the classification
      Parameters:
      qualifiedRoot - the classification-qualified root for the namespace
      Returns:
      String