public interface ExpressionService
extends com.appiancorp.services.ContextSensitiveService
Expressions are configured at design-time within the process application to perform execution-time calculations. For instance, it may be useful to append a timestamp to a process name when it is started - this can be accomplished using the following expression for the process display name at design time: "concatenate("MyProcessName_", now())", where "now()" is a function which returns the current time, and "concatenate" is a function which appends a list of arguments.
Java will call prepareExpression(java.lang.String)
or prepareModifyExpression(java.lang.String, java.lang.String, java.lang.String)
to register an expression to be evaluated with the expression engine. Java
should then call evaluateExpression(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[])
or
evaluateExpressionType(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[], int)
to attempt evaluation of the expression. If
the expression engine encounters a sub-expression within the expression that
it does not recognize, these methods will return a PartialResult
that specifies 1) the name of the function that could not be identified
(via the function
field) and 2) the parameters that were passed
to the expression engine for the unidentified function (via the
functionParameters
field). This allows Java to specify and
evaluate its own custom expressions, which are not known to the expression
engine. After evaluation of the sub-expression (see
ExpressionEvaluationService
), the expression engine can
continue evaluating the entire expression via a call to
continueFunction(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable)
, passing as an argument the result which was
evaluated in Java. Or, if evaluation of the sub-expression fails, Java
can discontinue evaluation of the expression by calling
cancelFunction(java.lang.Long, java.lang.String)
.
If the expression engine recognizes all elements of the expression that is
passed via evaluateExpression(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[])
or evaluateExpressionType(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[], int)
,
these methods will return a PartialResult
with the
result
field populated. This represents the result of the
expression evaluation.
Methods of service classes can all throw the unchecked exception
ServiceException
if any
system-level error (for example, server failure) occurs, and will in general
throw a checked exception (InvalidXXXException
) when an entity
to be retrieved is inaccessible, instead of returning null
.
Exceptions to this paradigm (including the use of ResultList
as
described below) are noted. All checked exceptions extend
AppianException
.
It may be necessary to retrieve a subset of results as opposed to an entire
collection, and also to sort the subset by some property of the returned
object. "Paging" methods which return a
ResultPage
are provided in certain
instances for this purpose. The ResultPage
will contain the
sorted subset of results
(via Result.getResults()
), and the
total number of items in the available result set
(via ResultPage.getAvailableItems()
).
It may also be necessary to retrieve some results, even if all results
cannot be retrieved (for instance, some of the entities corresponding
to a list of entity IDs may no longer exist). Methods which return a
ResultList
are provided for this
purpose. The Result.getResults()
method in this case will return all results which can be retrieved. In
addition, there will be a list of result codes
(ResultList.getResultCodes()
) that
represent the successful retrieval of an entity, or, if the entity could
not be retrieved, the reason for the failure. See the CODE_XXX
constants in ResultList
for details.
ExpressionEvaluationService
Modifier and Type | Field and Description |
---|---|
static boolean |
cancelFunction$UPDATES |
static boolean |
continueFunction$UPDATES |
static boolean |
evaluateExpression$UPDATES |
static boolean |
evaluateExpressionType$UPDATES |
static boolean |
getDefaultFormat$UPDATES |
static boolean |
getDisplayFormatForLocale$UPDATES |
static boolean |
getDisplayFormatsForLocales$UPDATES |
static boolean |
prepareExpression$UPDATES |
static boolean |
prepareModifyExpression$UPDATES |
static boolean |
setDefaultFormat$UPDATES |
static boolean |
setDisplayFormatForLocale$UPDATES |
static boolean |
setDisplayFormatsForLocales$UPDATES |
static boolean |
validateExpression$UPDATES |
Modifier and Type | Method and Description |
---|---|
void |
cancelFunction(java.lang.Long expressionId_,
java.lang.String reason_)
Deprecated.
see ProcessDesignService.evaluateExpression; it handles the full expression lifecycle
|
void |
continueFunction(java.lang.Long expressionId_,
TypedVariable result_)
Deprecated.
see ProcessDesignService.evaluateExpression
|
PartialResult |
evaluateExpression(java.lang.Long expressionId_,
TypedVariable[] parameters_)
Deprecated.
see ProcessDesignService.evaluateExpression; it handles the full expression lifecycle
|
PartialResult |
evaluateExpressionType(java.lang.Long expressionId_,
TypedVariable[] parameters_,
int resultType_)
Deprecated.
see ProcessDesignService.evaluateExpression; it handles the full expression lifecycle
|
java.lang.String |
getDefaultFormat(java.lang.String name_)
Retrieves the default display format for a given format name.
|
LocaleDisplayFormat |
getDisplayFormatForLocale(LocaleDisplayFormat ldf_)
Retrieves the display format information for the locale set in the
LocaleDisplayFormat parameter object. |
LocaleDisplayFormat[] |
getDisplayFormatsForLocales(LocaleDisplayFormat[] ldf_)
Receives an array of
LocaleDisplayFormat objects that have only the
locale field set for each object. |
java.lang.Long |
prepareExpression(java.lang.String textToEvaluate_)
Deprecated.
see ProcessDesignService.evaluateExpression; it handles the full expression lifecycle
|
java.lang.Long |
prepareModifyExpression(java.lang.String variable_,
java.lang.String operator_,
java.lang.String textToEvaluate_)
Deprecated.
see ProcessDesignService.evaluateExpression; it handles the full expression lifecycle
|
void |
setDefaultFormat(java.lang.String name_,
java.lang.String format_)
Sets the default display format for a given format name.
|
void |
setDisplayFormatForLocale(LocaleDisplayFormat ldf_)
Sets a display format for the locale set in the
LocaleDisplayFormat
parameter object. |
void |
setDisplayFormatsForLocales(LocaleDisplayFormat[] ldf_)
Receives an array of
LocaleDisplayFormat objects and sets a
display format for the locale set in each of the
LocaleDisplayFormat objects. |
void |
validateExpression(java.lang.String textToEvaluate_)
Validates the expression.
|
static final boolean prepareExpression$UPDATES
static final boolean prepareModifyExpression$UPDATES
static final boolean evaluateExpression$UPDATES
static final boolean evaluateExpressionType$UPDATES
static final boolean validateExpression$UPDATES
static final boolean continueFunction$UPDATES
static final boolean cancelFunction$UPDATES
static final boolean getDefaultFormat$UPDATES
static final boolean setDefaultFormat$UPDATES
static final boolean getDisplayFormatForLocale$UPDATES
static final boolean setDisplayFormatForLocale$UPDATES
static final boolean getDisplayFormatsForLocales$UPDATES
static final boolean setDisplayFormatsForLocales$UPDATES
@Deprecated java.lang.Long prepareExpression(java.lang.String textToEvaluate_) throws ExpressionException
evaluateExpression(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[])
or evaluateExpressionType(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[], int)
textToEvaluate_
- the expression to be evaluatedExpressionException
- if the expression is invalid.ServiceException
- if any system-level error occurs@Deprecated java.lang.Long prepareModifyExpression(java.lang.String variable_, java.lang.String operator_, java.lang.String textToEvaluate_) throws ExpressionException
prepareExpression(java.lang.String)
in that the variable and operator are already
separated from the rest of the expression.
E.g. a:1+2, a is the assignment variable, : the assignment operator
and a will be set to be 3. "a:1+2" would be the argument passed to
prepareExpression(java.lang.String)
, but "a", ":", "1+2" would be the respective
arguments to prepareModifyExpression
Supported operators are:
variable_
- the name of the variable that will be assigned.operator_
- the assignment operator for the expressiontextToEvaluate_
- the expression to be evaluated in String format.ExpressionException
- if the expression is invalid.ServiceException
- if any system-level error occurss@Deprecated PartialResult evaluateExpression(java.lang.Long expressionId_, TypedVariable[] parameters_) throws ExpressionException, InvalidExpressionException
This method must always be preceded
by a call to prepareExpression(java.lang.String)
or prepareModifyExpression(java.lang.String, java.lang.String, java.lang.String)
NOTE: This function should be called first with parameters_
as an empty array. If the result
field of the returned
PartialResult
is null
, then this method should be
called again with parameters_
set to be the
functionParameters
field of the returned
PartialResult
.
expressionId_
- the unique id of expression being evaluatedparameters_
- the array of parameters to the expression with the given
IDPartialResult
that may contain a final result
or a function for Java to evaluateExpressionException
- if the expression is invalid.InvalidExpressionException
- if the expression with the given ID
does not existServiceException
- if any system-level error occurs@Deprecated PartialResult evaluateExpressionType(java.lang.Long expressionId_, TypedVariable[] parameters_, int resultType_) throws ExpressionException, InvalidExpressionException
This method is the same as evaluateExpression(java.lang.Long, com.appiancorp.suiteapi.process.TypedVariable[])
except the
result
(if any) within the PartialResult
returned will
be cast to the given resultType
.
NOTE: This function should be called first with parameters_
as an empty array. If the result
field of the returned
PartialResult
is null
, then this method should be
called again with parameters_
set to be the
functionParameters
field of the returned
PartialResult
.
expressionId_
- the unique id of expression being evaluatedparameters_
- the array of parameters to the expression with the given
IDresultType_
- the type for the returned PartialResult
.
This is one of the object types in
TypedVariable
PartialResult
of the given type that may contain
a final result or a function for Java to evaluateExpressionException
- if the expression is invalid.InvalidExpressionException
- if the expression with the given ID
does not existServiceException
- if any system-level error occursvoid validateExpression(java.lang.String textToEvaluate_) throws ExpressionException
textToEvaluate_
- the expression to validateExpressionException
- if the expression is invalid.ServiceException
- if any system-level error occurs@Deprecated void continueFunction(java.lang.Long expressionId_, TypedVariable result_) throws InvalidExpressionException
After Java successfully evaluates
a sub-expression, it returns the result and calls
continueFunction
to carry on evaluation of the expression with
the given ID.
NOTE: This method should only be used from within the
ExpressionEvaluationService
expressionId_
- the unique ID of expression being evaluatedresult_
- the result of the sub-expression that Java has evaluatedInvalidExpressionException
- if the expression does not existServiceException
- if any system-level error occurs@Deprecated void cancelFunction(java.lang.Long expressionId_, java.lang.String reason_) throws InvalidExpressionException
If Java evaluation of the sub-expression fails, it returns an appropriate
message as the reason and calls cancelFunction
to terminate
the evaluation of the expression with the given ID.
NOTE: This method should only be used from within the
ExpressionEvaluationService
expressionId_
- the unique ID of expression being evaluatedreason_
- the error that Java encountered while evaluating the
expressionInvalidExpressionException
- if the expression does not existServiceException
- if any system-level error occursjava.lang.String getDefaultFormat(java.lang.String name_) throws java.security.InvalidParameterException, java.lang.NullPointerException
name_
- A string identifying the type of display format, one
of: "date", "time", or "timezone".java.security.InvalidParameterException
java.lang.NullPointerException
void setDefaultFormat(java.lang.String name_, java.lang.String format_) throws java.security.InvalidParameterException, java.lang.NullPointerException
name_
- A string identifying the type of display format, one
of: "date", "time", or "timezone".format_
- The display format to use for the given format name.java.security.InvalidParameterException
java.lang.NullPointerException
LocaleDisplayFormat getDisplayFormatForLocale(LocaleDisplayFormat ldf_) throws java.security.InvalidParameterException, java.lang.NullPointerException
LocaleDisplayFormat
parameter object. Only the locale field
should be set on the ldf_
parameter. If a previously set
LocaleDisplayFormat object exists with the specified locale, the object
will be returned with all of the LocaleDisplayFormat object's fields set.ldf_
- A LocaleDisplayFormat
object that has only the locale
field setjava.lang.NullPointerException
- if LocaleDisplayFormat parameter is nulljava.security.InvalidParameterException
- if the locale field for the parameter is
invalidvoid setDisplayFormatForLocale(LocaleDisplayFormat ldf_) throws java.security.InvalidParameterException, java.lang.NullPointerException
LocaleDisplayFormat
parameter object. All fields of the ldf_
parameter must
be set and may not be null.ldf_
- A LocaleDisplayFormat
object that has all fields setjava.lang.NullPointerException
- if LocaleDisplayFormat
parameter
is nulljava.security.InvalidParameterException
- if a parameter set in the
LocaleDisplayFormat
object is invalidLocaleDisplayFormat[] getDisplayFormatsForLocales(LocaleDisplayFormat[] ldf_) throws java.security.InvalidParameterException, java.lang.NullPointerException
LocaleDisplayFormat
objects that have only the
locale field set for each object. For each object in the array, the
remaining fields are set if a previously set LocaleDisplayFormat object
matches the locale set in the array object. An array of the same length is
returned with all fields set instead of just the locale.ldf_
- An array of LocaleDisplayFormat
objects that have only
the locale field setjava.lang.NullPointerException
- if LocaleDisplayFormat array parameter is nulljava.security.InvalidParameterException
- if the locale set in one of the
LocaleDisplayFormat
objects invalidvoid setDisplayFormatsForLocales(LocaleDisplayFormat[] ldf_) throws java.security.InvalidParameterException, java.lang.NullPointerException
LocaleDisplayFormat
objects and sets a
display format for the locale set in each of the
LocaleDisplayFormat
objects. All fields of each of the
LocaleDisplayFormat
objects in the ldf_
parameter
must be set and may not be null.ldf_
- An array of LocaleDisplayFormat
objects that have all
fields setjava.lang.NullPointerException
- if LocaleDisplayFormat
array
parameter is nulljava.security.InvalidParameterException
- if a parameter set in one of the
LocaleDisplayFormat
objects is invalidCopyright © 2003-2024 Appian Corporation. All Rights Reserved.