Class PropertyHelper
java.lang.Object
org.odpi.openmetadata.frameworks.governanceaction.search.PropertyHelper
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddBooleanMapProperty
(ElementProperties properties, String propertyName, Map<String, Boolean> mapValues) Add the supplied map property to an element properties object.addBooleanProperty
(ElementProperties properties, String propertyName, boolean propertyValue) Add the supplied property to an element properties object.addBooleanPropertyMap
(ElementProperties properties, Map<String, Boolean> mapValues) Add the supplied property map to an element properties object.addDateProperty
(ElementProperties properties, String propertyName, Date propertyValue) Add the supplied property to an element properties object.addEnumProperty
(ElementProperties properties, String propertyName, String propertyType, String symbolicName) Add the supplied property to an element properties object.addFloatProperty
(ElementProperties properties, String propertyName, float propertyValue) Add the supplied property to an element properties object.addIntMapProperty
(ElementProperties properties, String propertyName, Map<String, Integer> mapValues) Add the supplied map property to an element properties object.addIntProperty
(ElementProperties properties, String propertyName, int propertyValue) Add the supplied property to an element properties object.addIntPropertyMap
(ElementProperties properties, Map<String, Integer> mapValues) Add the supplied property map to an element properties object.addLongMapProperty
(ElementProperties properties, String propertyName, Map<String, Long> mapValues) Add the supplied map property to an element properties object.addLongProperty
(ElementProperties properties, String propertyName, long propertyValue) Add the supplied property to an element properties object.addLongPropertyMap
(ElementProperties properties, Map<String, Long> mapValues) Add the supplied property map to an element properties object.addMapProperty
(ElementProperties properties, String propertyName, Map<String, Object> mapValues) Add the supplied map property to an element properties object.addPropertyMap
(ElementProperties properties, Map<String, Object> mapValues) Add the supplied property map to an element properties object.addStringArrayProperty
(ElementProperties properties, String propertyName, List<String> arrayValues) Add the supplied array property to an element properties object.addStringMapProperty
(ElementProperties properties, String propertyName, Map<String, String> mapValues) Add the supplied map property to an element properties object.addStringProperty
(ElementProperties properties, String propertyName, String propertyValue) Add the supplied property to an element properties object.addStringPropertyMap
(ElementProperties properties, Map<String, String> mapValues) Add the supplied property map to an element properties object.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.boolean
getBooleanProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or false if property is not found.getDateProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or null if property is not found.getElementPropertiesAsMap
(ElementProperties properties) Convert an element properties object into a map.getEnumPropertySymbolicName
(String sourceName, String propertyName, ElementProperties properties, String methodName) Retrieve the ordinal value from an enum property.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.int
getIntProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or 0 if property is not found.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.long
getLongProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or 0 if property is not found.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.getSearchProperties
(ElementProperties properties, MatchCriteria matchCriteria) Convert the provided instance properties and match criteria into an equivalent SearchProperties object.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.getStringArrayProperty
(String sourceName, String propertyName, ElementProperties properties, String callingMethodName) Locates and extracts a string array property and extracts its values.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.getStringProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or null if property is not found.boolean
isTypeOf
(ElementControlHeader elementControlHeader, String expectedType) Test the type of the element to determine if it matches the desired type.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.boolean
removeBooleanProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or false if property is not found.removeDateProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or null if property is not found.removeEnumProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Retrieve the ordinal value from an enum property.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.int
removeIntProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or 0 if property is not found.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.long
removeLongProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or 0 if property is not found.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.protected void
removeProperty
(String propertyName, ElementProperties properties) Remove the named property from the instance properties object.removeStringArrayProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Locates and extracts a string array property and extracts its values.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.removeStringProperty
(String sourceName, String propertyName, ElementProperties properties, String methodName) Return the requested property or null if property is not found.void
validateGUID
(String guid, String guidParameter, String methodName) Throw an exception if the supplied GUID is nullvoid
validateMandatoryName
(String name, String nameParameter, String methodName) Throw an exception if the supplied name is null
-
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 validateguidParameter
- 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 validatenameParameter
- name of the parameter that passed the name.methodName
- name of the method making the call.- Throws:
InvalidParameterException
- the name is null
-
isTypeOf
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 testexpectedType
- expected type - nul means any type- Returns:
- boolean result
-
getSearchPropertiesByName
Return the search properties that requests elements with an exactly matching name in any of the listed property names.- Parameters:
propertyNames
- list of property namesname
- 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 propertypropertyValue
- 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 propertypropertyValue
- 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 propertypropertyValue
- 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 propertypropertyValue
- 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 propertypropertyValue
- 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 propertypropertyValue
- 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 propertypropertyType
- type of enumsymbolicName
- 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 propertyarrayValues
- 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 propertymapValues
- contents of the map- Returns:
- resulting element properties object
-
addPropertyMap
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 propertymapValues
- 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 propertymapValues
- 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 propertymapValues
- 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 propertymapValues
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested map propertyproperties
- all the properties of the instancemethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- method of caller- Returns:
- map property value or null
-
removeProperty
Remove the named property from the instance properties object.- Parameters:
propertyName
- name of property to removeproperties
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- values of the propertymethodName
- 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 callpropertyName
- name of requested map propertyproperties
- all the properties of the instancemethodName
- 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 callpropertyName
- name of requested propertyproperties
- properties from the instance.methodName
- method of caller- Returns:
- int ordinal or -1 if not found
-
getElementPropertiesAsMap
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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested map propertyproperties
- all the properties of the instancecallingMethodName
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 callpropertyName
- name of requested propertyproperties
- 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 convertmatchCriteria
- match criteria to apply- Returns:
- SearchProperties object.
-