API - SessionContext
Provides information about the context of the current rules execution. Those include information about the environment the current action takes place.
Current logged-in user
The method provides the user which is currently logged-in and executes the rules. The user information can be used to check for specific rights or to get information about the user.
/**
* Get the current logged-in user
*/
User getLoginUser();
Message bundles (internal)
For internal use only. The method provides access to the message bundles which are used to get localized messages for the current user.
/**
* Get localized messages
*/
Messages getMessages();
Current action
The method provides information about the current action which is executed. The action can be either INPUT or SAVE. The action information can be used to check if the rules are executed during input or save of an object.
INPUT action
Input actions are triggered when a user is entering data into a form. Whenever a change in an input form is made the rules are executed to check if the input is valid or to set other attributes based on the input. The rules can be used to provide feedback to the user about invalid input.
SAVE action
Save actions are triggered when a user is saving an object. This happens when the user presses the save button in a form when moving / resizing an object in scheduler or gant views. Additionally, it is triggered if an object as result of other actions is altered, e.g. due to dependencies in relationships. The rules are executed to check if the object is valid and can be saved. The rules can be used to provide feedback to the user about invalid input or to set other attributes based on the input.
/**
* Get current runtime action (INPUT or SAVE)
*/
TMS getAction();
Non working days
Administrators can define non-working days in the configuration file as well as weekend days which are considered as work days. To allow the rules descriptor for each day to know if it is considered a working days 2 utility methods are provided. The first method checks if a specific date is a non-working day. The other lists all non-working days in a given time range.
/**
* @param date the date to check. Should not be {@code null}.
* @return {@code true} if a day is configured as non working day. <br>
* configuration allows to declare certain Sundays or Saturdays to
* be working days -- in some countries this is common practice. <br>
* More common is the configuration of specific (bank) holidays.
*/
boolean isNonWorkingday(LocalDate date);
/**
* @param start The beginning of the date range. Should not be {@code null}.
* @param end The ending of the date range. Should not be {@code null}.
* @return All dates in range marked as non-working days. Empty set, if either of the parameters is {@code null}.
*/
Set<LocalDate> getNonWorkingdays(LocalDate start, LocalDate end);
Creating new Activities
The system allows to create new activities of a specific type, e.g. to later add it as a Sub activity. The method provides a new created activity which is not yet persisted in the database. The activity can be used to set attributes and relationships before saving it. Initially all fields and assignments are empty.
/**
* @param typeName the name of the type
* @return new created + un-persisted activity
* @throws DataAccessException if the {@code typeName} cannot be found or is deleted
*/
Activity newActivity(String typeName) throws DataAccessException;