Class InstancePropertyValueMapping

  • Direct Known Subclasses:
    ArrayPropertyValueMapping, EnumPropertyValueMapping, MapPropertyValueMapping, PrimitivePropertyValueMapping, StructPropertyValueMapping

    public abstract class InstancePropertyValueMapping
    extends AbstractMapping
    Maps singular InstancePropertyValues between persistence and objects. These cannot simply be serialized to JSON as that would impact the ability to search their values correctly, so we must break apart the values and the types for each property. In general, we will store the complete value into the '.json' portion, but we will also store just the value alone (without any type details) into the '.value' portion. This will allow us to quickly pull back the complete value from a JSON-serialized form (from '.json') while also providing a reliable search point at the '.value'. This class and its subclasses must be responsible for ensuring that these two properties are kept aligned with each other at all times. Furthermore, the naming for the '.value' point used for searching must retain within its overall property name the qualification of which TypeDef defined that property. This is to ensure that different TypeDefinitions that use the same property name, but which have different types (eg. position being a string vs an integer) can be distinguished. This is necessary at a minimum because otherwise we will hit ClassCastExceptions in Clojure due to trying to compare the same property with fundamentally different values (string vs int) if the property name is not qualified with the type in which it is defined. (The '.json' value does not need to be qualified since we do not compare it but only use it for fast-access serde purposes.) See the subclasses of this class, which handle mappings for the various subtypes of InstancePropertyValue for details of each '.value' representation.
    • Constructor Detail

      • InstancePropertyValueMapping

        protected InstancePropertyValueMapping()
        Necessary default constructor to ensure we can use the static objectMapper of the base class.
    • Method Detail

      • getValueForComparison

        public static Object getValueForComparison​(CruxOMRSRepositoryConnector cruxConnector,
                                                   org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue ipv)
        Convert the provided Egeria value into a Crux comparable form.
        Parameters:
        cruxConnector - connectivity to the repository
        ipv - Egeria value to translate to Crux-comparable value
        Returns:
        Object value that Crux can compare
      • getInstancePropertyValueFromDoc

        public static org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue getInstancePropertyValueFromDoc​(CruxOMRSRepositoryConnector cruxConnector,
                                                                                                                                                                                    crux.api.CruxDocument cruxDoc,
                                                                                                                                                                                    String namespace,
                                                                                                                                                                                    String propertyName)
        Retrieve a single property value from the provided Crux representation.
        Parameters:
        cruxConnector - connectivity to the repository
        cruxDoc - from which to retrieve the value
        namespace - by which the property is qualified
        propertyName - of the property
        Returns:
        InstancePropertyValue giving Egeria representation of the value
      • addInstancePropertyValueToDoc

        public static void addInstancePropertyValueToDoc​(CruxOMRSRepositoryConnector cruxConnector,
                                                         org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType instanceType,
                                                         crux.api.CruxDocument.Builder builder,
                                                         String propertyName,
                                                         String namespace,
                                                         org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue value)
        Add a single property value to the provided Crux representation.
        Parameters:
        cruxConnector - connectivity to the repository
        instanceType - describing the instance to which this property applies
        builder - through which to add the property
        propertyName - of the property to add / replace
        namespace - by which the property should be qualified
        value - of the property
      • getSerializedPropertyKeyword

        protected static String getSerializedPropertyKeyword​(String namespace,
                                                             String propertyName)
        Retrieve the keyword to use to store the serialized value of the property.
        Parameters:
        namespace - by which to qualify the property
        propertyName - of the property
        Returns:
        String giving the qualified keyword
      • getPropertyValueKeyword

        protected static String getPropertyValueKeyword​(CruxOMRSRepositoryConnector cruxConnector,
                                                        org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType instanceType,
                                                        String propertyName,
                                                        String namespace)
        Retrieve the qualified Crux name for the value of the property.
        Parameters:
        cruxConnector - connectivity to the repository
        instanceType - of the instance for which this property applies
        propertyName - of the property
        namespace - by which to qualify the property
        Returns:
        String
      • getNamesForProperty

        public static Set<String> getNamesForProperty​(CruxOMRSRepositoryConnector cruxConnector,
                                                      String propertyName,
                                                      String namespace,
                                                      Set<String> limitToTypes,
                                                      org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue value)
        Retrieve the fully-qualified names for the provided property, everywhere it could appear within a given type. Note that generally the returned Set will only have a single element, however if requested from a sufficiently abstract type (eg. Referenceable) under which different subtypes have the same property defined, the Set will contain a property reference for each of those subtypes' properties.
        Parameters:
        cruxConnector - connectivity to the repository
        propertyName - of the property for which to qualify type-specific references
        namespace - under which to qualify the properties
        limitToTypes - limit the type-specific qualifications to only properties that are applicable to these types
        value - that will be used for comparison, to limit the properties to include based on their type
        Returns:
        Set<String> of the property references
      • getKeywordsForProperty

        public static Set<clojure.lang.Keyword> getKeywordsForProperty​(CruxOMRSRepositoryConnector cruxConnector,
                                                                       String propertyName,
                                                                       String namespace,
                                                                       Set<String> limitToTypes,
                                                                       org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstancePropertyValue value)
        Retrieve the fully-qualified names for the provided property, everywhere it could appear within a given type. Note that generally the returned Set will only have a single element, however if requested from a sufficiently abstract type (eg. Referenceable) under which different subtypes have the same property defined, the Set will contain a property reference for each of those subtypes' properties.
        Parameters:
        cruxConnector - connectivity to the repository
        propertyName - of the property for which to qualify type-specific references
        namespace - under which to qualify the properties
        limitToTypes - limit the type-specific qualifications to only properties that are applicable to these types
        value - that will be used for comparison, to limit the properties to include based on their type
        Returns:
        Set<Keyword> of the property references
      • getEndsWithPropertyNameForMatching

        public static String getEndsWithPropertyNameForMatching​(String propertyName)
        Retrieve a partially-qualified property name that can be used to compare a Lucene match using ends-with.
        Parameters:
        propertyName - of the property to reference
        Returns:
        String match-able ending to the property (without any type qualification)