java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.xtdb.repositoryconnector.mapping.AbstractMapping
org.odpi.openmetadata.adapters.repositoryservices.xtdb.repositoryconnector.mapping.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 Details

    • InstancePropertyValueMapping

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

    • getValueForComparison

      public static Object getValueForComparison(XTDBOMRSRepositoryConnector xtdbConnector, InstancePropertyValue ipv)
      Convert the provided Egeria value into a XTDB comparable form.
      Parameters:
      xtdbConnector - connectivity to the repository
      ipv - Egeria value to translate to XTDB-comparable value
      Returns:
      Object value that XTDB can compare
    • getValueForComparison

      public static Object getValueForComparison(InstancePropertyValue ipv) throws InvalidParameterException
      Convert the provided Egeria value into a XTDB comparable form.
      Parameters:
      ipv - Egeria value to translate to XTDB-comparable value
      Returns:
      Object value that XTDB can compare
      Throws:
      InvalidParameterException - if the value cannot be persisted
    • addInstancePropertyValueToDoc

      public static clojure.lang.IPersistentMap addInstancePropertyValueToDoc(clojure.lang.IPersistentMap doc, PropertyKeywords propertyKeywords, InstancePropertyValue value) throws InvalidParameterException, IOException
      Add a single property value to the provided XTDB representation.
      Parameters:
      doc - the XTDB map to which to add the property
      propertyKeywords - the property whose value should be set
      value - of the property
      Returns:
      IPersistentMap containing the updated value
      Throws:
      InvalidParameterException - if the value cannot be persisted
      IOException - on any error serializing the value
    • getKeywordsForProperty

      public static Set<clojure.lang.Keyword> getKeywordsForProperty(XTDBOMRSRepositoryConnector xtdbConnector, String propertyName, String namespace, Set<String> limitToTypes, 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:
      xtdbConnector - 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