org.itracker.services.util
Class WorkflowUtilities

java.lang.Object
  extended by org.itracker.services.util.WorkflowUtilities

public class WorkflowUtilities
extends Object

Contains utilities used when displaying and processing workflow and field events


Field Summary
static int EVENT_FIELD_ONPOPULATE
          Fires for each field when building the form.
static int EVENT_FIELD_ONPOSTSUBMIT
          Fires after all data is submitted to the db for all fields.
static int EVENT_FIELD_ONPRESUBMIT
          Fires after validation, but before the data is committed to the database.
static int EVENT_FIELD_ONSETDEFAULT
          Fires to set the current value of a form field.
static int EVENT_FIELD_ONSORT
          NOT CURRENTLY IMPLEMENTED.
static int EVENT_FIELD_ONVALIDATE
          Fires on validation of the form field.
 
Constructor Summary
WorkflowUtilities()
           
 
Method Summary
static String getEventName(int value, Locale locale)
          Returns a title of workflow event, according to selected locale.
static String getEventName(String value, Locale locale)
           
static NameValuePair[] getEvents(Locale locale)
          Returns an array of pairs (eventName, eventId), where eventName is an event title, according to selected locale.
static List<NameValuePair> getListOptions(Map<Integer,List<NameValuePair>> listOptions, int fieldId)
          Select a list of NameValuePair objects from provided map object according to fieldId selector.
static List<NameValuePair> getListOptions(Map listOptions, Integer fieldId)
          Select a list of NameValuePair objects from provided map object according to fieldId selector.
static List<NameValuePair> processFieldScript(ProjectScript projectScript, int event, Integer fieldId, List<NameValuePair> currentValues, org.apache.struts.action.ActionMessages currentErrors, org.apache.struts.validator.ValidatorForm form)
          Run provided BEANSHELL script against form instance, taking into account incoming event type, field raised an event and current values.
static List<NameValuePair> processFieldScripts(List<ProjectScript> projectScripts, int event, Integer fieldId, List<NameValuePair> currentValue, org.apache.struts.action.ActionErrors currentErrors, org.apache.struts.validator.ValidatorForm form)
          Run appropriate script, selecting it from provided list by matching event and field.
static void processFieldScripts(List<ProjectScript> projectScriptModels, int event, Map<Integer,List<NameValuePair>> currentValues, org.apache.struts.action.ActionMessages currentErrors, org.apache.struts.validator.ValidatorForm form)
          The most general way to run scripts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_FIELD_ONPOPULATE

public static final int EVENT_FIELD_ONPOPULATE
Fires for each field when building the form. Mainly used to build dynamic list options.

See Also:
Constant Field Values

EVENT_FIELD_ONSORT

public static final int EVENT_FIELD_ONSORT
NOT CURRENTLY IMPLEMENTED. Use the onPopulate event instead. In the future, this event may be implemented to allow for list sorting after list value population.

See Also:
Constant Field Values

EVENT_FIELD_ONSETDEFAULT

public static final int EVENT_FIELD_ONSETDEFAULT
Fires to set the current value of a form field. This will overwrite any data in the form field pulled from the database.

See Also:
Constant Field Values

EVENT_FIELD_ONVALIDATE

public static final int EVENT_FIELD_ONVALIDATE
Fires on validation of the form field.

See Also:
Constant Field Values

EVENT_FIELD_ONPRESUBMIT

public static final int EVENT_FIELD_ONPRESUBMIT
Fires after validation, but before the data is committed to the database.

See Also:
Constant Field Values

EVENT_FIELD_ONPOSTSUBMIT

public static final int EVENT_FIELD_ONPOSTSUBMIT
Fires after all data is submitted to the db for all fields. Performed right before the response is sent.

See Also:
Constant Field Values
Constructor Detail

WorkflowUtilities

public WorkflowUtilities()
Method Detail

getEventName

public static String getEventName(int value,
                                  Locale locale)
Returns a title of workflow event, according to selected locale.

Parameters:
value - is an identifier of incoming event.
locale - is a selected locale.
Returns:
a name of event or something like "MISSING KEY: ".

getEventName

public static String getEventName(String value,
                                  Locale locale)

getEvents

public static NameValuePair[] getEvents(Locale locale)
Returns an array of pairs (eventName, eventId), where eventName is an event title, according to selected locale.

Parameters:
locale - is a selected locale.
Returns:
an array of pairs (eventName, eventId), which is never null.

getListOptions

public static List<NameValuePair> getListOptions(Map<Integer,List<NameValuePair>> listOptions,
                                                 int fieldId)
Select a list of NameValuePair objects from provided map object according to fieldId selector. Typesafe version of #getListOptions(Map, Integer)

Parameters:
listOptions - is a map, with stored NameValuePair objects lists associated with specific integer id.
fieldId - is a selector from map.
Returns:
a list of objects, which may be empty, but never null.

getListOptions

public static List<NameValuePair> getListOptions(Map listOptions,
                                                 Integer fieldId)
Select a list of NameValuePair objects from provided map object according to fieldId selector.

Parameters:
listOptions - is a map, with stored NameValuePair objects lists associated with specific integer id.
fieldId - is a selector from map.
Returns:
a list of objects, which may be empty, but never null.

processFieldScripts

public static void processFieldScripts(List<ProjectScript> projectScriptModels,
                                       int event,
                                       Map<Integer,List<NameValuePair>> currentValues,
                                       org.apache.struts.action.ActionMessages currentErrors,
                                       org.apache.struts.validator.ValidatorForm form)
                                throws WorkflowException
The most general way to run scripts. All matching of event and fields are embedded within. As a result, currentValues parameter will contain updated values and form will contain new default values if appropriate.

Parameters:
projectScriptModels - is a list of scripts.
event - is an event type.
currentValues - is a map of current values to fields.
currentErrors - is a container for errors.
form - contains default values of fields.
Throws:
WorkflowException

processFieldScripts

public static List<NameValuePair> processFieldScripts(List<ProjectScript> projectScripts,
                                                      int event,
                                                      Integer fieldId,
                                                      List<NameValuePair> currentValue,
                                                      org.apache.struts.action.ActionErrors currentErrors,
                                                      org.apache.struts.validator.ValidatorForm form)
                                               throws WorkflowException
Run appropriate script, selecting it from provided list by matching event and field.

Parameters:
projectScripts - is a list of provided scripts.
event - is an event type.
fieldId - is a field, associated with event.
currentValue - is a set of current values.
currentErrors - is a container for errors.
form - is a form, holder of default values.
Returns:
new set of values.
Throws:
WorkflowException

processFieldScript

public static List<NameValuePair> processFieldScript(ProjectScript projectScript,
                                                     int event,
                                                     Integer fieldId,
                                                     List<NameValuePair> currentValues,
                                                     org.apache.struts.action.ActionMessages currentErrors,
                                                     org.apache.struts.validator.ValidatorForm form)
                                              throws WorkflowException
Run provided BEANSHELL script against form instance, taking into account incoming event type, field raised an event and current values. As a result, a set of new current values is returned and if appropriate, default values are changed in form. TODO: should issue, project, user, services be available too?

Parameters:
projectScript - is a script to run.
event - is an event type.
fieldId - is a field id associated with event.
currentValues - is a set of current values.
currentErrors - is a container for occured errors.
form - is a form instance, holding values.
Returns:
new current values.
Throws:
WorkflowException


Copyright © 2002-2012 itracker. All Rights Reserved.