Class ExpressionUtil
java.lang.Object
com.ssgllc.fish.service.util.registered.ExpressionUtil
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
@Component
public class ExpressionUtil
extends Object
implements org.springframework.context.ApplicationContextAware
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static com.ssgllc.fish.config.CasetivityProperties
-
Constructor Summary
ConstructorsConstructorDescriptionExpressionUtil
(com.ssgllc.fish.repository.gen.UserRepository userRepository) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areExactAddresses
(com.ssgllc.fish.domain.CasetivityAddress address, com.ssgllc.fish.domain.CasetivityAddress addressToCompare) Checks if two CasetivityAddress objects are an exact match.static boolean
areExactAddressesIgnoreUnit
(com.ssgllc.fish.domain.CasetivityAddress address, com.ssgllc.fish.domain.CasetivityAddress addressToCompare) Checks if two CasetivityAddress objects are an exact match, ignoring the unit field.static boolean
bothNotNull
(Object valueOne, Object valueTwo) Checks if both values are non-null.static boolean
Checks if both values are null.static Object
Returns the first non-null object of two objects.static Boolean
currentUserHasARoleIn
(List<String> roleNames) Checks if the current user has any of the given roles.static Boolean
currentUserHasRole
(String roleName) static String
formatDate
(LocalDate date, String format) Formats a LocalDate object using the specified date format.static String
formatDateDefault
(LocalDate date) Formats a LocalDate object using the default date format specified in casetivityProperties.static String
Gets the ID of the currently logged in user.static String
Gets the login name of the currently logged in user.static com.ssgllc.fish.domain.gen.User
Gets the User object for the currently logged in user.static Object
Returns the property for the current user's session as specified in the userTokenFields of the casetivity.properties file for the application.Gets a list of the roles that the currently logged in user belongs to.static UUID
Gets the UUID of the currently logged in user.static String
Gets the UUID string of the currently logged in user.static String
getDateString
(Object date) Returns a string representation of a date object.static String
getDuplicateItems
(List<String> list) Returns a string containing the items that appear more than once in a list.static String
getUserIdByLogin
(String login) Deprecated.static Object
getUserProperty
(com.ssgllc.fish.bpm.domain.BpmUser user, String key) static boolean
static boolean
isContainedInOther
(String text, String textToCompare, String splitRegEx, Integer minContainsLen) Checks if one string is contained in another string.static boolean
isFirstLastBirthDateExact
(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Checks if the first name, last name, and birth date fields in two CasetivityPerson objects are an exact match.static boolean
isFirstLastGenderBirthDateExact
(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Checks if the first name, last name, gender, and birth date fields in two CasetivityPerson objects are an exact match.static boolean
isFirstLastMiddleExact
(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Checks if the first name, last name, and middle name fields in two CasetivityPerson objects are an exact match.static boolean
static boolean
Checks if a list contains only unique items.static Boolean
matchPattern
(String string, String pattern) Deprecated.This method is deprecated.static double
mlAddressMatch
(com.ssgllc.fish.domain.CasetivityAddress address, com.ssgllc.fish.domain.CasetivityAddress addressToCompare) Returns the match score between two CasetivityAddress objects using MLAddressMatch.static double
mlPersonMatch
(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Returns the match score between two CasetivityPerson objects using MLPersonMatch.static com.ssgllc.fish.dedupe.match.ml.dataset.ScoreHolder
mlPersonMatchScores
(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Returns a ScoreHolder object containing the match scores between two CasetivityPerson objects using MLPersonMatch.static boolean
oneNullOneGiven
(Object valueOne, Object valueTwo) Checks if one of the values is null and the other is non-null.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) static Boolean
userHasARoleIn
(com.ssgllc.fish.bpm.domain.BpmUser user, List<String> roleNames) Checks if a given user has any of the given roles.static Boolean
userHasRole
(com.ssgllc.fish.bpm.domain.BpmUser user, String roleName) Checks if a given user has a specified role.static Integer
ZeroOrOne: Returns 0 if the value is null or blank, else returns 1.
-
Field Details
-
casetivityProperties
protected static com.ssgllc.fish.config.CasetivityProperties casetivityProperties
-
-
Constructor Details
-
ExpressionUtil
public ExpressionUtil(com.ssgllc.fish.repository.gen.UserRepository userRepository)
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
Z
ZeroOrOne: Returns 0 if the value is null or blank, else returns 1.- Parameters:
value
- the object whose nullness is to be checked- Returns:
- 0 if the value is null or blank, else returns 1
-
oneNullOneGiven
Checks if one of the values is null and the other is non-null.- Parameters:
valueOne
- the first object whose nullness is to be checkedvalueTwo
- the second object whose nullness is to be checked- Returns:
- true if one of the values is null and the other is non-null, false otherwise
-
bothNull
Checks if both values are null.- Parameters:
valueOne
- the first object whose nullness is to be checkedvalueTwo
- the second object whose nullness is to be checked- Returns:
- true if both values are null, false otherwise
-
bothNotNull
Checks if both values are non-null.- Parameters:
valueOne
- the first object whose nullness is to be checkedvalueTwo
- the second object whose nullness is to be checked- Returns:
- true if both values are non-null, false otherwise
-
mlPersonMatch
public static double mlPersonMatch(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Returns the match score between two CasetivityPerson objects using MLPersonMatch.- Parameters:
person
- the first CasetivityPerson object to be comparedpersonToCompare
- the second CasetivityPerson object to be compared- Returns:
- the match score between the two CasetivityPerson objects using MLPersonMatch
-
mlPersonMatchScores
public static com.ssgllc.fish.dedupe.match.ml.dataset.ScoreHolder mlPersonMatchScores(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Returns a ScoreHolder object containing the match scores between two CasetivityPerson objects using MLPersonMatch.- Parameters:
person
- the first CasetivityPerson object to be comparedpersonToCompare
- the second CasetivityPerson object to be compared- Returns:
- a ScoreHolder object containing the match scores between the two CasetivityPerson objects using MLPersonMatch
-
mlAddressMatch
public static double mlAddressMatch(com.ssgllc.fish.domain.CasetivityAddress address, com.ssgllc.fish.domain.CasetivityAddress addressToCompare) Returns the match score between two CasetivityAddress objects using MLAddressMatch.- Parameters:
address
- the first CasetivityAddress object to be comparedaddressToCompare
- the second CasetivityAddress object to be compared- Returns:
- the match score between the two CasetivityAddress objects using MLAddressMatch
-
areExactAddresses
public static boolean areExactAddresses(com.ssgllc.fish.domain.CasetivityAddress address, com.ssgllc.fish.domain.CasetivityAddress addressToCompare) Checks if two CasetivityAddress objects are an exact match.- Parameters:
address
- the first CasetivityAddress object to be comparedaddressToCompare
- the second CasetivityAddress object to be compared- Returns:
- true if the two CasetivityAddress objects are an exact match, false otherwise
-
areExactAddressesIgnoreUnit
public static boolean areExactAddressesIgnoreUnit(com.ssgllc.fish.domain.CasetivityAddress address, com.ssgllc.fish.domain.CasetivityAddress addressToCompare) Checks if two CasetivityAddress objects are an exact match, ignoring the unit field.- Parameters:
address
- the first CasetivityAddress object to be comparedaddressToCompare
- the second CasetivityAddress object to be compared- Returns:
- true if the two CasetivityAddress objects are an exact match, ignoring the unit field, false otherwise
-
isFirstLastMiddleExact
public static boolean isFirstLastMiddleExact(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Checks if the first name, last name, and middle name fields in two CasetivityPerson objects are an exact match.- Parameters:
person
- the first CasetivityPerson object to be comparedpersonToCompare
- the second CasetivityPerson object to be compared- Returns:
- true if the first name, last name, and middle name fields in the two CasetivityPerson objects are an exact match, false otherwise
-
isFirstLastBirthDateExact
public static boolean isFirstLastBirthDateExact(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Checks if the first name, last name, and birth date fields in two CasetivityPerson objects are an exact match.- Parameters:
person
- the first CasetivityPerson object to be comparedpersonToCompare
- the second CasetivityPerson object to be compared- Returns:
- true if the first name, last name, and birth date fields in the two CasetivityPerson objects are an exact match, false otherwise
-
isFirstLastGenderBirthDateExact
public static boolean isFirstLastGenderBirthDateExact(com.ssgllc.fish.domain.CasetivityPerson person, com.ssgllc.fish.domain.CasetivityPerson personToCompare) Checks if the first name, last name, gender, and birth date fields in two CasetivityPerson objects are an exact match.- Parameters:
person
- the first CasetivityPerson object to be comparedpersonToCompare
- the second CasetivityPerson object to be compared- Returns:
- true if the first name, last name, gender, and birth date fields in the two CasetivityPerson objects are an exact match, false otherwise
-
isContainedInOther
public static boolean isContainedInOther(String text, String textToCompare, String splitRegEx, Integer minContainsLen) Checks if one string is contained in another string.- Parameters:
text
- the string to be searchedtextToCompare
- the string to search forsplitRegEx
- a regular expression used to split the strings into wordsminContainsLen
- the minimum length of a word to be considered for a match- Returns:
- true if the second string contains a word that is at least as long as minContainsLen and is a word in the first string, false otherwise
-
isUnique
Checks if a list contains only unique items.- Parameters:
list
- the list to be checked- Returns:
- true if the list contains only unique items, false otherwise
-
getDuplicateItems
Returns a string containing the items that appear more than once in a list.- Parameters:
list
- the list to be checked- Returns:
- a string containing the items that appear more than once in the list
-
formatDateDefault
Formats a LocalDate object using the default date format specified in casetivityProperties.- Parameters:
date
- the LocalDate object to be formatted- Returns:
- a string containing the formatted date
-
formatDate
Formats a LocalDate object using the specified date format.- Parameters:
date
- the LocalDate object to be formattedformat
- the format to be used for the date- Returns:
- a string containing the formatted date
-
getDateString
Returns a string representation of a date object.- Parameters:
date
- the date object to be represented as a string- Returns:
- a string representation of the date object
-
matchPattern
Deprecated.This method is deprecated. Use SpEL matches to achieve the same functionality.This method is deprecated. Use SpEL matches to achieve the same functionality. Usage examples with SpEL matches:#inputString matches #regexPattern
Checks if a string matches a specified regular expression pattern.
#inputString matches 'Hello,.*'
- Parameters:
string
- the string to be checkedpattern
- the regular expression pattern to check the string against- Returns:
- true if the string matches the pattern, false otherwise
-
coalesce
Returns the first non-null object of two objects.- Parameters:
a
- the first object to be checkedb
- the second object to be checked- Returns:
- the first non-null object of the two objects
-
getCurrentUserProperty
Returns the property for the current user's session as specified in the userTokenFields of the casetivity.properties file for the application. These properties are evaluated and set when a user logs into the application and carried in the user's access token.- Parameters:
the
- user property key to get
-
getUserProperty
-
currentUserHasRole
-
currentUserHasARoleIn
Checks if the current user has any of the given roles.- Parameters:
roleNames
- A list of role names to check.- Returns:
- True if the current user has any of the specified roles, false otherwise.
-
userHasRole
Checks if a given user has a specified role.- Parameters:
user
- The user to check.roleName
- The name of the role to check for.- Returns:
- True if the user has the specified role, false otherwise.
-
userHasARoleIn
public static Boolean userHasARoleIn(com.ssgllc.fish.bpm.domain.BpmUser user, List<String> roleNames) Checks if a given user has any of the given roles.- Parameters:
user
- The user to check.roleNames
- A list of role names to check.- Returns:
- True if the user has any of the specified roles, false otherwise.
-
getCurrentUserId
Gets the ID of the currently logged in user.- Returns:
- The ID of the current user.
-
getCurrentUserUuid
Gets the UUID of the currently logged in user.- Returns:
- The UUID of the current user.
-
getCurrentUserUuidStr
Gets the UUID string of the currently logged in user.- Returns:
- The UUID string of the current user.
-
getCurrentUserLogin
Gets the login name of the currently logged in user.- Returns:
- The login name of the current user.
-
getUserIdByLogin
Deprecated.Gets the ID of a user with a given login name. Useinvalid @link
{@link UserUtil.getUserIdByLogin(String)
- Parameters:
login
- The login name of the user to look up.- Returns:
- The ID of the user with the specified login name.
-
getCurrentUserObject
@Transactional(readOnly=true) public static com.ssgllc.fish.domain.gen.User getCurrentUserObject()Gets the User object for the currently logged in user.- Returns:
- The User object for the current user.
-
getCurrentUserRoles
Gets a list of the roles that the currently logged in user belongs to.- Returns:
- A list of the roles that the current user belongs to.
-
isFrontend
public static boolean isFrontend() -
isBackend
public static boolean isBackend()
-