org.norther.tammi.spray.db.step
Class SelectionStepAction

java.lang.Object
  extended by org.norther.tammi.spray.loader.task.Action
      extended by org.norther.tammi.spray.loader.task.ActionEvent
          extended by org.norther.tammi.spray.template.step.FlowStepAction
              extended by org.norther.tammi.spray.template.step.NextStepAction
                  extended by org.norther.tammi.spray.template.step.FormStepAction
                      extended by org.norther.tammi.spray.db.step.RepositoryStepAction
                          extended by org.norther.tammi.spray.db.step.SelectionStepAction
All Implemented Interfaces:
Serializable, Task, StepFlowConstants
Direct Known Subclasses:
DeleteVariableAction, InsertVariableAction, UpdateVariableAction, UserAccountAction

public class SelectionStepAction
extends RepositoryStepAction

A flow step action for selecting and caching form variables.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
protected static int DELETE_ACTION
          The delete action.
protected static int INSERT_ACTION
          The insert action.
static String MARKED_NAME_PROPERTY
          The marked name property.
static String SELECTED_NAME_PROPERTY
          The selected name property.
protected static int UPDATE_ACTION
          The update action.
 
Fields inherited from class org.norther.tammi.spray.db.step.RepositoryStepAction
NULL_PK, ROOT_PK
 
Fields inherited from interface org.norther.tammi.spray.template.flow.StepFlowConstants
ADAPTABLE_STATE, DISPOSABLE_STATE, EXPLICIT_STATE, FINISHED_STATE, HELP_PIPE_PROPERTY, QUALIFIED_STATE, READ_ONLY_STATE, REPOSITORY_PROPERTY, SELECTABLE_STATE
 
Constructor Summary
SelectionStepAction()
          Constructs a new flow step action.
 
Method Summary
protected  boolean checkPermission(Identity id, int mask, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Check access permission for the cached identity.
 void clearSelectedIdentity(int step, int index, StepFlowContext context)
          Clears the selected identity or identities.
 Variable deleteVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Deletes the indexed variable.
protected  void filterRoleNameEnumeration(Variable var, Variable account, Persister persister, FilterChain chain, StepFlowContext context)
          Filters unauthorized role names from the specified variable.
 Identity getAccountIdentity(String className, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the user account identity of the current user.
 Variable getImportedVariable(int index, Identity id, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the imported indexed variable for the specified identity.
 Variable getImportedVariable(int index, Identity id, String fkField, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the imported indexed variable for the specified identity and foreign key by applying the specified persister.
 Variable getImportedVariable(int index, Identity id, String fkField, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the imported indexed variable for the specified identity and foreign key.
 Variable getImportedVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the imported indexed variable.
protected  Identity getMandatorySelection(int index, String className, String[] nameFields, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the mandatory selection for the specified class.
 Identity[] getSelectedIdentities(int step, int index, StepFlowContext context)
          Gets the selected identities.
 Identity getSelectedIdentity(int step, int index, StepFlowContext context)
          Gets the selected identity.
 int[] getSelectedIndeces(String name, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indeces of the selected variables in the named parameter.
 int getSelectedIndex(String name, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the index of the selected variable in the named parameter.
 Variable getSelectedVariable(int step, int index, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the selected variable.
protected  List getSelectionEnumeration(int index, String className, String[] nameFields, OrderedMap identities, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the selection enumeration for the specified class from the corresponding identity tree.
protected  List getSelectionEnumeration(int index, String className, String[] nameFields, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context, OrderedSet list)
          Gets the selection enumeration for the specified class from the corresponding identity list.
 Variable getSelectionVariable(int index, Identity[] ids, String className, Collection vars, String[] nameFields, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed list selection variable with the specified variables and the specified identities selected.
 Variable getSelectionVariable(int index, Identity[] ids, String className, Collection roots, String parentField, String childField, String[] nameFields, boolean marked, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed tree selection variable with the specified root variables, the specified identities selected and their parents expanded.
 Variable getSelectionVariable(int index, Identity[] ids, String className, DBAttribute attribute, String[] nameFields, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed list selection variable with the specified identities selected.
 Variable getSelectionVariable(int index, Identity[] ids, String className, Object pk, String parentField, String childField, String[] nameFields, boolean marked, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed tree selection variable with the specified identities selected and their parents expanded.
 Variable getSelectionVariable(int index, Identity id, String className, DBAttribute attribute, String[] nameFields, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed list selection variable with the specified identity selected.
 Variable getSelectionVariable(int index, Identity id, String className, Object pk, String parentField, String childField, String[] nameFields, boolean marked, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed tree selection variable with the specified identity selected and its parent expanded.
 Variable getSelectionVariable(int index, String className, DBAttribute attribute, String[] nameFields, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed list selection variable with the current selection.
 Variable getSelectionVariable(int index, String className, Object pk, String parentField, String childField, String[] nameFields, boolean marked, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the indexed tree selection variable with the current selection and expansions.
 Variable insertVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Inserts the indexed variable.
 Variable queryAccountVariable(String className, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Queries an account variable of the current user.
 Collection queryAllObjects(String className, DBCriteria criteria, String[] sortFields, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Queries all objects fulfilling the specified criteria.
 Collection queryTreeObjects(String className, Object pk, String relField, DBCriteria criteria, String[] sortFields, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Queries objects on the next level in a relation tree.
 Collection sortObjects(Collection objects, String[] sortFields, Persister persister, FilterChain chain)
          Sorts a collection of objects with the specified fields.
 void submitDeleteVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Deletes the selected variable.
 void submitInsertVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Inserts the selected variable.
 void submitQueryVariable(int index, String className, String attribute, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Queries a non-localized variable in the indexed selection tree.
 void submitSearchVariable(String className, String attribute, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Searches for a localized variable.
 void submitSelectAll(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Selects all selectable identitis.
 void submitUnselectAll(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Unselects all selectable identities.
 void submitUpdateVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Updates the selected variable.
protected  Variable submitVariable(int index, int action, Persister persister, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Submits the indexed context variable.
 Variable updateVariable(int index, ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Updates the indexed variable.
 
Methods inherited from class org.norther.tammi.spray.db.step.RepositoryStepAction
add1NForeignReferences, add1NNullReferences, add1NObjectReferences, addAttributeValues, addToRelationMap, createVariable, createVariable, deleteVariable, getAttributeValue, getAttributeValues, getBeanRepositoryClient, getConnectionKey, getEndReference, getIntrospector, getKeyAttributeValue, getKeyAttributeValues, getLoader, getNextReference, getNextReference, getNextReferences, getPersister, getPersister, getPersister, getPostDependencies, getPreDependencies, getRepositoryClient, getResourceKey, getRootReference, getRootReferences, insertVariable, isNullPK, isRelatedTo, isRootPK, setAttributeValue, setAttributeValue, setKeyAttributeValue, setKeyAttributeValues, setMNForeignReferences, setMNObjectReferences, setPostDependencies, setPreDependencies, toClass, updateVariable
 
Methods inherited from class org.norther.tammi.spray.template.step.FormStepAction
disableNextStep, enableNextStep, isStepFinished, parseUploadedFile, parseUploadedFile, setStepFinished, submit, submitCancelStep, submitFinishStep, submitNextStep, submitPreviousStep, submitRenewForm, submitResetForm, submitUpdateForm, update, update
 
Methods inherited from class org.norther.tammi.spray.template.step.NextStepAction
submitBackStep
 
Methods inherited from class org.norther.tammi.spray.template.step.FlowStepAction
checkPermission, checkPermission, done, execute, execute, finish, forward, getPermissibleRoles, getSignature, include, initialize, initialize, prepare, pushError, submit, submitOpenHelp
 
Methods inherited from class org.norther.tammi.spray.loader.task.ActionEvent
getAction, getAction, getAction, invoke
 
Methods inherited from class org.norther.tammi.spray.loader.task.Action
find, getFilter, getMBeanServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED_NAME_PROPERTY

public static final String SELECTED_NAME_PROPERTY
The selected name property.

See Also:
Constant Field Values

MARKED_NAME_PROPERTY

public static final String MARKED_NAME_PROPERTY
The marked name property.

See Also:
Constant Field Values

INSERT_ACTION

protected static int INSERT_ACTION
The insert action.


UPDATE_ACTION

protected static int UPDATE_ACTION
The update action.


DELETE_ACTION

protected static int DELETE_ACTION
The delete action.

Constructor Detail

SelectionStepAction

public SelectionStepAction()
Constructs a new flow step action.

Method Detail

queryAllObjects

public Collection queryAllObjects(String className,
                                  DBCriteria criteria,
                                  String[] sortFields,
                                  Persister persister,
                                  ServletRequest request,
                                  ServletResponse response,
                                  FilterChain chain,
                                  StepFlowContext context)
                           throws Exception
Queries all objects fulfilling the specified criteria.

Parameters:
className - the class name.
criteria - optional criteria.
sortFields - optionals sort field.
persister - the persister.
request - the request.
response - the response.
chain - the filter chain.
context - the flow context.
Returns:
a collection of objects.
Throws:
Exception - on errors.

queryTreeObjects

public Collection queryTreeObjects(String className,
                                   Object pk,
                                   String relField,
                                   DBCriteria criteria,
                                   String[] sortFields,
                                   Persister persister,
                                   ServletRequest request,
                                   ServletResponse response,
                                   FilterChain chain,
                                   StepFlowContext context)
                            throws Exception
Queries objects on the next level in a relation tree.

Parameters:
className - the class name.
pk - an optional primary key.
criteria - optional criteria.
relField - the relation field.
sortFields - optionals sort field.
persister - the persister.
request - the request.
response - the response.
chain - the filter chain.
context - the flow context.
Returns:
a collection of objects.
Throws:
Exception - on errors.

sortObjects

public Collection sortObjects(Collection objects,
                              String[] sortFields,
                              Persister persister,
                              FilterChain chain)
Sorts a collection of objects with the specified fields.

Parameters:
objects - a collection of objects.
sortFields - optional sort fields.
persister - the persister.
chain - the filter chain.
Returns:
a sorted collection of objects.

queryAccountVariable

public Variable queryAccountVariable(String className,
                                     Persister persister,
                                     ServletRequest request,
                                     ServletResponse response,
                                     FilterChain chain,
                                     StepFlowContext context)
                              throws Exception
Queries an account variable of the current user.

Parameters:
className - the account class name.
persister - the persister.
request - the request.
response - the response.
chain - the filter chain.
context - the flow context.
Returns:
the account variable or null.
Throws:
Exception - on errors.

getAccountIdentity

public Identity getAccountIdentity(String className,
                                   ServletRequest request,
                                   ServletResponse response,
                                   FilterChain chain)
                            throws Exception
Gets the user account identity of the current user.

Parameters:
className - the account class name.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the account variable or null.
Throws:
Exception - on errors.

getSelectedIndex

public int getSelectedIndex(String name,
                            ServletRequest request,
                            ServletResponse response,
                            FilterChain chain,
                            StepFlowContext context)
Gets the index of the selected variable in the named parameter.

Parameters:
name - the parameter name.
request - the request.
response - the response.
chain - the filter chain.
context - the flow context.
Returns:
the selected index or -1.

getSelectedIndeces

public int[] getSelectedIndeces(String name,
                                ServletRequest request,
                                ServletResponse response,
                                FilterChain chain,
                                StepFlowContext context)
Gets the indeces of the selected variables in the named parameter.

Parameters:
name - the parameter name.
request - the request.
response - the response.
chain - the filter chain.
context - the flow context.
Returns:
the selected indeces.

getSelectedIdentity

public Identity getSelectedIdentity(int step,
                                    int index,
                                    StepFlowContext context)
                             throws Exception
Gets the selected identity.

Parameters:
step - the selection step.
index - the variable index.
context - the flow context.
Returns:
the selected identity or null.
Throws:
Exception - on errors.

getSelectedIdentities

public Identity[] getSelectedIdentities(int step,
                                        int index,
                                        StepFlowContext context)
                                 throws Exception
Gets the selected identities.

Parameters:
step - the selection step.
index - the variable index.
context - the flow context.
Returns:
the selected identity or null.
Throws:
Exception - on errors.

clearSelectedIdentity

public void clearSelectedIdentity(int step,
                                  int index,
                                  StepFlowContext context)
                           throws Exception
Clears the selected identity or identities.

Parameters:
step - the selection step.
index - the variable index.
context - the flow context.
Throws:
Exception - on errors.

getSelectedVariable

public Variable getSelectedVariable(int step,
                                    int index,
                                    Persister persister,