java.lang.Object
org.odpi.openmetadata.frameworks.governanceaction.search.PropertyHelper

public class PropertyHelper extends Object
PropertyHelper is used by the governance actions services to manage the contents of the ElementProperties structure. It is a stateless object and so there are no threading concerns with declaring it as a static variable.
  • Constructor Details

    • PropertyHelper

      public PropertyHelper()
  • Method Details

    • validateGUID

      public void validateGUID(String guid, String guidParameter, String methodName) throws InvalidParameterException
      Throw an exception if the supplied GUID is null
      Parameters:
      guid - unique identifier to validate
      guidParameter - name of the parameter that passed the guid.
      methodName - name of the method making the call.
      Throws:
      InvalidParameterException - the guid is null
    • validateMandatoryName

      public void validateMandatoryName(String name, String nameParameter, String methodName) throws InvalidParameterException
      Throw an exception if the supplied name is null
      Parameters:
      name - unique name to validate
      nameParameter - name of the parameter that passed the name.
      methodName - name of the method making the call.
      Throws:
      InvalidParameterException - the name is null
    • isTypeOf

      public boolean isTypeOf(ElementControlHeader elementControlHeader, String expectedType)
      Test the type of the element to determine if it matches the desired type. This method works for all categories of elements, ie entities, relationships and classifications.
      Parameters:
      elementControlHeader - header of the element to test
      expectedType - expected type - nul means any type
      Returns:
      boolean result
    • getSearchPropertiesByName

      public SearchProperties getSearchPropertiesByName(List<String> propertyNames, String name)
      Return the search properties that requests elements with an exactly matching name in any of the listed property names.
      Parameters:
      propertyNames - list of property names
      name - name to match on
      Returns:
      search properties
    • addStringProperty

      public ElementProperties addStringProperty(ElementProperties properties, String propertyName, String propertyValue)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      propertyValue - value of property
      Returns:
      element properties object.
    • addIntProperty

      public ElementProperties addIntProperty(ElementProperties properties, String propertyName, int propertyValue)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      propertyValue - value of property
      Returns:
      resulting element properties object
    • addLongProperty

      public ElementProperties addLongProperty(ElementProperties properties, String propertyName, long propertyValue)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add. Property may be null.
      propertyName - name of property
      propertyValue - value of property
      Returns:
      resulting element properties object
    • addFloatProperty

      public ElementProperties addFloatProperty(ElementProperties properties, String propertyName, float propertyValue)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add. Property may be null.
      propertyName - name of property
      propertyValue - value of property
      Returns:
      resulting element properties object
    • addDateProperty

      public ElementProperties addDateProperty(ElementProperties properties, String propertyName, Date propertyValue)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add. Property may be null.
      propertyName - name of property
      propertyValue - value of property
      Returns:
      resulting element properties object
    • addBooleanProperty

      public ElementProperties addBooleanProperty(ElementProperties properties, String propertyName, boolean propertyValue)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      propertyValue - value of property
      Returns:
      resulting element properties object
    • addEnumProperty

      public ElementProperties addEnumProperty(ElementProperties properties, String propertyName, String propertyType, String symbolicName)
      Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      propertyType - type of enum
      symbolicName - symbol name value of property
      Returns:
      resulting element properties object
    • addStringArrayProperty

      public ElementProperties addStringArrayProperty(ElementProperties properties, String propertyName, List<String> arrayValues)
      Add the supplied array property to an element properties object. The supplied array is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      arrayValues - contents of the array
      Returns:
      resulting element properties object
    • addMapProperty

      public ElementProperties addMapProperty(ElementProperties properties, String propertyName, Map<String,Object> mapValues)
      Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addPropertyMap

      public ElementProperties addPropertyMap(ElementProperties properties, Map<String,Object> mapValues)
      Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      mapValues - contents of the map
      Returns:
      instance properties object.
    • addStringMapProperty

      public ElementProperties addStringMapProperty(ElementProperties properties, String propertyName, Map<String,String> mapValues)
      Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addBooleanMapProperty

      public ElementProperties addBooleanMapProperty(ElementProperties properties, String propertyName, Map<String,Boolean> mapValues)
      Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addIntMapProperty

      public ElementProperties addIntMapProperty(ElementProperties properties, String propertyName, Map<String,Integer> mapValues)
      Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addLongMapProperty

      public ElementProperties addLongMapProperty(ElementProperties properties, String propertyName, Map<String,Long> mapValues)
      Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      propertyName - name of property
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addStringPropertyMap

      public ElementProperties addStringPropertyMap(ElementProperties properties, Map<String,String> mapValues)
      Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addIntPropertyMap

      public ElementProperties addIntPropertyMap(ElementProperties properties, Map<String,Integer> mapValues)
      Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addLongPropertyMap

      public ElementProperties addLongPropertyMap(ElementProperties properties, Map<String,Long> mapValues)
      Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • addBooleanPropertyMap

      public ElementProperties addBooleanPropertyMap(ElementProperties properties, Map<String,Boolean> mapValues)
      Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
      Parameters:
      properties - properties object to add property to, may be null.
      mapValues - contents of the map
      Returns:
      resulting element properties object
    • removeStringProperty

      public String removeStringProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or null if property is not found. If the property is found, it is removed from the InstanceProperties structure. If the property is not a string property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • removeEnumProperty

      public String removeEnumProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Retrieve the ordinal value from an enum property.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      symbolic name
    • removeStringMapFromProperty

      public Map<String,String> removeStringMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. If the property is found, it is removed from the InstanceProperties structure. If the property is not a map property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • removeIntProperty

      public int removeIntProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or 0 if property is not found. If the property is found, it is removed from the InstanceProperties structure. If the property is not an int property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • removeDateProperty

      public Date removeDateProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or null if property is not found. If the property is found, it is removed from the InstanceProperties structure. If the property is not a date property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • removeBooleanProperty

      public boolean removeBooleanProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or false if property is not found. If the property is found, it is removed from the InstanceProperties structure. If the property is not a boolean property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • removeLongProperty

      public long removeLongProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or 0 if property is not found. If the property is found, it is removed from the InstanceProperties structure. If the property is not a long property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • removeStringArrayProperty

      public List<String> removeStringArrayProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a string array property and extracts its values. If the property is found, it is removed from the InstanceProperties structure. If the property is not an array property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - all the properties of the instance
      methodName - method of caller
      Returns:
      array property value or null
    • removeMapFromProperty

      public Map<String,Object> removeMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. If the property is found, it is removed from the InstanceProperties structure. If the property is not a map property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • removeLongMapFromProperty

      public Map<String,Long> removeLongMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. If the property is found, it is removed from the InstanceProperties structure. If the property is not a map property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • removeIntegerMapFromProperty

      public Map<String,Integer> removeIntegerMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. If the property is found, it is removed from the InstanceProperties structure. If the property is not a map property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • removeBooleanMapFromProperty

      public Map<String,Boolean> removeBooleanMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map. If the property is found, it is removed from the InstanceProperties structure. If the property is not a map property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • removeProperty

      protected void removeProperty(String propertyName, ElementProperties properties)
      Remove the named property from the instance properties object.
      Parameters:
      propertyName - name of property to remove
      properties - instance properties object to work on
    • getStringMapFromProperty

      public Map<String,String> getStringMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • getBooleanMapFromProperty

      public Map<String,Boolean> getBooleanMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • getLongMapFromProperty

      public Map<String,Long> getLongMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • getIntegerMapFromProperty

      public Map<String,Integer> getIntegerMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - values of the property
      methodName - method of caller
      Returns:
      map property value or null
    • getMapFromProperty

      public Map<String,Object> getMapFromProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - all the properties of the instance
      methodName - method of caller
      Returns:
      map property value or null
    • getEnumPropertySymbolicName

      public String getEnumPropertySymbolicName(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Retrieve the ordinal value from an enum property.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      int ordinal or -1 if not found
    • getElementPropertiesAsMap

      public Map<String,Object> getElementPropertiesAsMap(ElementProperties properties)
      Convert an element properties object into a map.
      Parameters:
      properties - packed properties
      Returns:
      properties stored in Java map
    • getStringProperty

      public String getStringProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or null if property is not found. If the property is not a string property then a logic exception is thrown
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • getStringArrayProperty

      public List<String> getStringArrayProperty(String sourceName, String propertyName, ElementProperties properties, String callingMethodName)
      Locates and extracts a string array property and extracts its values.
      Parameters:
      sourceName - source of call
      propertyName - name of requested map property
      properties - all the properties of the instance
      callingMethodName - method of caller
      Returns:
      array property value or null
    • getIntProperty

      public int getIntProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or 0 if property is not found. If the property is not an int property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • getLongProperty

      public long getLongProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or 0 if property is not found. If the property is not a long property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • getDateProperty

      public Date getDateProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or null if property is not found. If the property is not a date property then a logic exception is thrown.
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • getBooleanProperty

      public boolean getBooleanProperty(String sourceName, String propertyName, ElementProperties properties, String methodName)
      Return the requested property or false if property is not found. If the property is not a boolean property then a logic exception is thrown
      Parameters:
      sourceName - source of call
      propertyName - name of requested property
      properties - properties from the instance.
      methodName - method of caller
      Returns:
      string property value or null
    • getSearchProperties

      public SearchProperties getSearchProperties(ElementProperties properties, MatchCriteria matchCriteria)
      Convert the provided instance properties and match criteria into an equivalent SearchProperties object.
      Parameters:
      properties - properties object to convert
      matchCriteria - match criteria to apply
      Returns:
      SearchProperties object.