Class ClassificationMapping


  • 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 Detail

      • LAST_CLASSIFICATION_CHANGE

        public static final String LAST_CLASSIFICATION_CHANGE
    • Constructor Detail

      • ClassificationMapping

        public ClassificationMapping​(XtdbOMRSRepositoryConnector xtdbConnector,
                                     List<org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.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 Detail

      • 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,
                                                           org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification classification)
                                                    throws IOException,
                                                           org.odpi.openmetadata.repositoryservices.ffdc.exception.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
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - on any type-related property error
      • removeFromMap

        public static clojure.lang.IPersistentMap removeFromMap​(clojure.lang.IPersistentMap doc,
                                                                String classificationName)
                                                         throws org.odpi.openmetadata.repositoryservices.ffdc.exception.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:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.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 org.odpi.openmetadata.repositoryservices.ffdc.exception.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:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.ClassificationErrorException - if the instance does not possess the classification
      • fromDoc

        protected List<org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification> fromDoc()
        Translate the provided XTDB representation into an Egeria representation.
        Returns:
        List<Classification>
      • fromMap

        public static List<org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification> fromMap​(clojure.lang.IPersistentMap doc)
                                                                                                                                                    throws IOException,
                                                                                                                                                           org.odpi.openmetadata.repositoryservices.ffdc.exception.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
        org.odpi.openmetadata.repositoryservices.ffdc.exception.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 org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.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 org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ClassificationOrigin getClassificationOriginFromSymbolicName​(String symbolicName)
                                                                                                                                                                                    throws org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException
        Convert the provided symbolic name into its ClassificationOrigin.
        Parameters:
        symbolicName - to convert
        Returns:
        ClassificationOrigin
        Throws:
        org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - if there is no such symbolic name
      • getSymbolicNameForClassificationOrigin

        public static String getSymbolicNameForClassificationOrigin​(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.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