Interface WorkflowUtilityFunctions
Example: ${util.env()}
Example: ${util.randomUUID()}
Example: ${util.randomInt(10)}
-
Method Summary
Modifier and TypeMethodDescriptionvoidadds value(s) to 'listName' list.gets the allowedChildBusinessKeys claim from user's tokenvoidappendLocalValuesToList(String src, String dest) appends values from 'src' local list to 'dest' list.voidappendLocalValueToList(String variableName, String listName) appends a local variable value to a list represented by 'listName'.voidappendValuesToList(String src, String dest) appends values from 'src' list to 'dest' list.voidappendValueToList(String variableName, String listName) appends a variable value to a list represented by 'listName'.authenticate(String authenticatorName, String userNameVariable, String passwordVariable, Collection<String> extraClaims) Authenticates external users using an external authenticator.calculates the duration between two date objects.dateTimeDiff(Temporal start, Temporal end) calculates the duration between two date-time objects.env()Returns current environment (qa, prod)extAuth(String authenticatorName, String userNameVariable, String passwordVariable, String... extraClaims) Authenticates external users using an external authenticator.formatNumber(String pattern, Number number) Formats a number based on the pattern specified.returns the value of the given variable if it exists or null if it doesn't.returns the value of the given variable if it exists or defaultValue if it doesn't.Gets the unique ID of the current stage.booleanisProd()Returns true if current environment is prod, false otherwise.Evaluates the given jsonpath against the object provided.voidJumps to the specified stage id.voidmerges two map like values represented by the variable names specified.periodDiff(LocalDate start, LocalDate end) calculates the period between two date objects.intrandomInt(int bound) generates a pseudorandom number between 0 (inclusive) and the specified bound (exclusive).generates a random UUID.voidremoves one or more entries in a map like value represented by 'dest'.voidsendMessage(String message) Send the specified message.voidsets a property in a map like value represented by 'dest'.voidsetInParentScope(String variableName) propagates the value of the given variable to the immediate parent scope.voidsetVariableLocalTransient(String name, Object value) sets a transient local variable value in current scope.converts a string of pattern yyyy-MM-dd to a date object.converts a string of the given pattern to a date object.toDateTime(String dateTime) converts a string of pattern yyyy-MM-dd'T'HH:mm:ss.SSS to a dateTime object.toDateTime(String dateTime, String pattern) converts a string of given pattern to a dateTime object.longConverts a numeric string to a long number.voidcreates a new 'dest' set from 'src' list.Decodes the given URL-encoded UTF-8 string.Encodes the given UTF-8 string to a URL-safe format.com.protium.apps.turiya.engine.publisher.UserAgentInfoGets user agent info for current request.gets the value of the specified user claimgets the roles assigned to the user in current synchronous transaction context
-
Method Details
-
env
String env()Returns current environment (qa, prod)- Returns:
- current environment
-
isProd
boolean isProd()Returns true if current environment is prod, false otherwise.- Returns:
- true if running in prod environment, false otherwise.
-
randomUUID
String randomUUID()generates a random UUID.- Returns:
- A randomly generated UUID
-
randomInt
int randomInt(int bound) generates a pseudorandom number between 0 (inclusive) and the specified bound (exclusive).- Parameters:
bound- the upper bound (exclusive). Must be positive.- Returns:
- a randomly (pseudorandom) generated integer.
-
merge
merges two map like values represented by the variable names specified. values in source are added onto dest. source remains unchanged.- Parameters:
dest- name of the destination process variablesource- name of the source process variable
-
setInParentScope
propagates the value of the given variable to the immediate parent scope.- Parameters:
variableName- name of the variable to propagate to the parent scope.
-
get
returns the value of the given variable if it exists or null if it doesn't. useful when the variable may or may not exist.- Parameters:
variableName- name of the variable.
-
get
returns the value of the given variable if it exists or defaultValue if it doesn't. useful when the variable may or may not exist.- Parameters:
variableName- name of the variable.
-
set
sets a property in a map like value represented by 'dest'.- Parameters:
dest- process variable representing a map.name- name of the new (or existing) map entry to add/overwrite.value- value of the new entry.
-
remove
removes one or more entries in a map like value represented by 'dest'.- Parameters:
dest- process variable representing a map.keys- keys in map whose entries will be removed.
-
setVariableLocalTransient
sets a transient local variable value in current scope. the variable is not persisted in database and is a good fit for use-and-throw variables.- Parameters:
name- name of the new variablevalue- value of the new variable
-
appendValueToList
appends a variable value to a list represented by 'listName'. list will be created if it doesn't exist.- Parameters:
variableName- name of variable holding the value to be added to the list.listName- name of the variable for the destination list
-
appendLocalValueToList
appends a local variable value to a list represented by 'listName'. list will be created if it doesn't exist.- Parameters:
variableName- name of variable holding the value to be added to the list.listName- name of the variable for the destination list
-
appendValuesToList
appends values from 'src' list to 'dest' list. 'dest' list will be created if it doesn't exist.- Parameters:
src- name of variable representing the source list.dest- name of variable representing the destination list.Note: value of src variable has to be a list. If it's not, it will just be added as a single entry to the destination.
-
appendLocalValuesToList
appends values from 'src' local list to 'dest' list. 'dest' list will be created if it doesn't exist.- Parameters:
src- name of variable representing the source list.dest- name of variable representing the destination list.Note: value of src variable has to be a list. If it's not, it will just be added as a single entry to the destination.
-
addToList
adds value(s) to 'listName' list. 'listName' list will be created if it doesn't exist.- Parameters:
listName- name of variable representing the destination list.values- the values(s) to add.
-
toSet
creates a new 'dest' set from 'src' list.- Parameters:
src- name of variable representing the source list.dest- name of variable representing the destination set.Note: value of src variable has to be a list. If it's not, it will just be added as a single entry to the destination.
-
toDate
converts a string of pattern yyyy-MM-dd to a date object.- Parameters:
date- the date string (Ex: 2022-02-24)- Returns:
- an immutable object representing the provided date. can be used to perform date related operations.
See also
LocalDate
-
toDate
converts a string of the given pattern to a date object.- Parameters:
date- the date string (Ex: 2022-02-24)pattern- the pattern of the provided date. SeeDateTimeFormatterfor pattern specification.- Returns:
- an immutable object representing the provided date. can be used to perform date related operations.
See also
LocalDateSee alsoDateTimeFormatter
-
toDateTime
converts a string of pattern yyyy-MM-dd'T'HH:mm:ss.SSS to a dateTime object.- Parameters:
dateTime- the date-time string (Ex: 2022-02-24T09:15:07+05:30)- Returns:
- an immutable object representing the provided date-time. can be used to perform date related operations.
See also
OffsetDateTime
-
toDateTime
converts a string of given pattern to a dateTime object.- Parameters:
dateTime- the date-time string (Ex: 2022-02-24T09:15:07+05:30)pattern- the pattern of the provided date-time. SeeDateTimeFormatterfor pattern specification.- Returns:
- an immutable object representing the provided date-time. can be used to perform date related operations.
See also
OffsetDateTimeSee alsoDateTimeFormatter
-
periodDiff
calculates the period between two date objects. can be used to calculate the interval between two dates in various supported units.- Parameters:
start- the start dateend- the end date- Returns:
- the period between the provided dates
See also
Period
-
dateDiff
calculates the duration between two date objects. can be used to calculate the interval between two dates in various supported units.- Parameters:
start- the start dateend- the end date- Returns:
- the duration between the provided dates
See also
Duration
-
dateTimeDiff
calculates the duration between two date-time objects. can be used to calculate the interval between two date-times in various supported units.- Parameters:
start- the start dateend- the end date- Returns:
- the duration between the provided dates
See also
Duration
-
userRoles
gets the roles assigned to the user in current synchronous transaction context- Returns:
- user's roles
- Throws:
IllegalStateException- when invoked in an asynchronous transaction
-
userClaim
gets the value of the specified user claim- Parameters:
claim- the name of the claim- Returns:
- the claim value
- Throws:
IllegalStateException- when invoked in an asynchronous transaction
-
allowedChildBusinessKeys
gets the allowedChildBusinessKeys claim from user's token- Returns:
- user's allowedChildBusinessKeys claim
- Throws:
IllegalStateException- when invoked in an asynchronous transaction
-
toLong
Converts a numeric string to a long number.- Parameters:
number- the number to convert- Returns:
- the converted number
-
formatNumber
Formats a number based on the pattern specified. The number can be any subclass ofNumber.- Parameters:
pattern- the pattern as defined inDecimalFormatnumber- the number to format- Returns:
- the formatted string
-
urlEncode
Encodes the given UTF-8 string to a URL-safe format.- Parameters:
value- input string- Returns:
- URL safe equivalent of the input string
-
urlDecode
Decodes the given URL-encoded UTF-8 string.- Parameters:
value- URL encoded input string- Returns:
- Decoded string
-
userAgentInfo
com.protium.apps.turiya.engine.publisher.UserAgentInfo userAgentInfo()Gets user agent info for current request.- Returns:
- The user agent info.
-
jsonPath
Evaluates the given jsonpath against the object provided.Note: Use this only when absolutely required. Using this in hot workflow paths may result in performance degradation in highly concurrent systems.
- Parameters:
object- the object on which the jsonpath expression is to be evaluated.jsonPath- the jsonpath expression to be evaluated.
-
jumpTo
Jumps to the specified stage id.- Parameters:
stageId- the id of the stage to jump to
-
getCurrentStageId
String getCurrentStageId()Gets the unique ID of the current stage. -
sendMessage
Send the specified message.- Parameters:
message- the name of the message to be sent.
-
extAuth
AuthenticationResult extAuth(String authenticatorName, String userNameVariable, String passwordVariable, String... extraClaims) Authenticates external users using an external authenticator.- Parameters:
authenticatorName- name of the authenticatoruserNameVariable- variable that holds the userNamepasswordVariable- variable (transient) that holds the passwordextraClaims- additional claims to include in response
-
authenticate
AuthenticationResult authenticate(String authenticatorName, String userNameVariable, String passwordVariable, Collection<String> extraClaims) Authenticates external users using an external authenticator.Note: this is same as 'extAuth' but accepts a collection of extra claims
- Parameters:
authenticatorName- name of the authenticatoruserNameVariable- variable that holds the userNamepasswordVariable- variable (transient) that holds the passwordextraClaims- additional claims to include in response
-