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

java.lang.Object
  extended by org.norther.tammi.spray.loader.task.Action
      extended by org.norther.tammi.spray.loader.task.Submit
          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
All Implemented Interfaces:
Serializable, Task
Direct Known Subclasses:
DictionaryAction, SelectionStepAction

public class RepositoryStepAction
extends FormStepAction

A flow step action for repository based actions.

Version:
$Id: RepositoryStepAction.java,v 1.59 2009/09/28 15:08:28 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.norther.tammi.spray.loader.task.Task
Task.Control
 
Field Summary
 
Fields inherited from class org.norther.tammi.spray.loader.task.Submit
EXECUTE_METHOD, SUBMIT_PREFIX
 
Constructor Summary
RepositoryStepAction()
          Constructs a new flow step action.
 
Method Summary
 boolean add1NForeignReferences(Object node, String className, String fkField, Object[] fks, Persister persister, FilterChain chain)
          Adds foreign references to 1:n relations.
 boolean add1NNullReferences(String className, String fkField, Object[] fks, Persister persister, FilterChain chain)
          Adds null references to 1:n relations.
 boolean add1NObjectReferences(Object node, String relField, String fkField, Object[] fks, Persister persister, FilterChain chain)
          Adds object references to 1:n relations.
 boolean addAttributeValues(Object node, String field, Persister persister, FilterChain chain, List<Object> result)
          Adds attribute values to a list.
 boolean addToRelationMap(Object node, String relField, Persister persister, FilterChain chain, ConcurrentMap<Object,Object> result)
          Adds to a map of referenced objects.
<V extends Variable>
V
createVariable(Class<V> clazz, FilterChain chain)
          Creates a new variable instance of the specified class.
 Variable createVariable(String type, FilterChain chain)
          Creates a new variable instance of the specified type.
 void deleteReferences(Variable var, Persister persister, FilterChain chain)
          Deletes a variable and its dependencies.
 Variable deleteVariable(Variable var, Persister persister, FilterChain chain)
          Deletes a variable.
 Variable deleteVariable(Variable var, String type, Persister persister, FilterChain chain)
          Deletes a variable of the specified type.
 VariableAttributeInfo getAttributeInfo(String name, String type, FilterChain chain)
          Gets the named attribute info of the variable of the specified type.
 List<Object> getAttributeValues(Object node, String field, Persister persister, FilterChain chain)
          Gets a list of attribute values.
 List<Variable> getDesktopData(Persister persister, FilterChain chain)
          Gets desktop data of the current user.
 Introspector getIntrospector(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets a localized introspector.
 Loader getLoader(FilterChain chain)
          Gets the loader for dynamic class loading.
 Variable getMetaDesktop(Persister persister, FilterChain chain)
          Gets the desktop of the current user.
 Variable getMetaFolder(Persister persister, FilterChain chain)
          Gets the folder of the current user.
 Persister getPersister(ServletRequest request, ServletResponse response, FilterChain chain, StepFlowContext context)
          Gets the context specific persister.
 Object getReferenceValue(Object node, int index, String relField, Persister persister, FilterChain chain)
          Gets the indexed referenced node.
protected  BeanRepositoryFilter getRepositoryFilter(FilterChain chain)
          Gets the bean repository client.
 Variable getRootFolder(Persister persister, FilterChain chain)
          Gets the root folder.
 List<?> getRootReferences(Object node, String relField, Persister persister, FilterChain chain)
          Gets the root nodes.
 VariableInfo getVariableInfo(String type, FilterChain chain)
          Gets the variable info of the specified type.
 void insertReferences(Variable var, Persister persister, FilterChain chain)
          Inserts a variable and its dependencies.
 Variable insertVariable(Variable var, Persister persister, FilterChain chain)
          Inserts a variable by exporting the specified one.
 Variable insertVariable(Variable var, String type, Persister persister, FilterChain chain)
          Inserts a variable of the specified type by exporting the specified one.
 boolean isRelatedTo(Variable node, String relField, Object xpk, Persister persister, FilterChain chain)
          Checks whether the specified key is related to the specified node.
 int[] orderObjects(Collection<?> objects, String[] sortFields, Persister persister, FilterChain chain)
          Orders a collection of objects with the specified fields.
<T> Collection<T>
queryAllObjects(DBCriteria<T> criteria, String[] sortFields, Persister persister, FilterChain chain, Object... clazz)
          Queries all objects fulfilling the specified criteria and may sort them by optional sort fields.
<T> Collection<T>
queryAllObjects(DBQuery<T> query, String[] sortFields, Persister persister, FilterChain chain)
          Queries all objects of the specified query and may sort them by optional sort fields.
<T> Collection<T>
queryTreeObjects(DBCriteria<T> criteria, String relField, Object rpk, int depth, String[] sortFields, Persister persister, FilterChain chain, Object... clazz)
          Queries objects to the specified depth in a relation tree fulfilling the specified criteria and may sort them by optional sort fields.
 Object[] setMNForeignReferences(Object node, String indirection, String fkField1, String fkField2, Object[] fks, Persister persister, FilterChain chain)
          Sets foreign references in m:n relations.
 Object[] setMNObjectReferences(Object node, String relField, String indirection, String fkField1, String fkField2, Object[] fks, Persister persister, FilterChain chain)
          Sets object references in m:n relations.
<T> Collection<T>
sortObjects(Collection<T> objects, String[] sortFields, Persister persister, FilterChain chain)
          Sorts a collection of objects with the specified fields.
 Variable storeVariable(Variable var, Persister persister, FilterChain chain)
          Stores a variable by exporting the specified one.
 Variable storeVariable(Variable var, String type, Persister persister, FilterChain chain)
          Stores a variable of the specified type by exporting the specified one.
 Class<?> toClass(String className, FilterChain chain)
          Converts a class name into the corresponding class.
 void updateReferences(Variable var, Persister persister, FilterChain chain)
          Updates a variable and its dependencies.
 Variable updateVariable(Variable var, Persister persister, FilterChain chain)
          Updates a variable by importing the specified one.
 Variable updateVariable(Variable var, String type, Persister persister, FilterChain chain)
          Updates a variable of the specified type by importing the specified one.
 
Methods inherited from class org.norther.tammi.spray.template.step.FormStepAction
clearParameters, loadPropertyFile, loadUploadedFile, submit, submitCancelStep, submitFinishStep, submitInsertForm, submitNextStep, submitPreviousStep, submitRenewForm, submitResetForm, submitReuseForm, submitUpdateForm, update, update, update, update
 
Methods inherited from class org.norther.tammi.spray.template.step.NextStepAction
isNextStepEnabled, setNextStepEnabled, submitBackStep
 
Methods inherited from class org.norther.tammi.spray.template.step.FlowStepAction
checkPermission, checkPermission, checkPermission, construct, execute, execute, finish, forward, getPermissibleRoles, getSignature, include, initialize, initialize, prepare, submit, submitOpenHelp
 
Methods inherited from class org.norther.tammi.spray.loader.task.Submit
getAction, getAction, invoke
 
Methods inherited from class org.norther.tammi.spray.loader.task.Action
find, find, getFilter, getMBeanServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryStepAction

public RepositoryStepAction()
Constructs a new flow step action.

Method Detail

toClass

public Class<?> toClass(String className,
                        FilterChain chain)
                 throws ClassNotFoundException
Converts a class name into the corresponding class.

Parameters:
className - the class name.
chain - the filter chain.
Returns:
the corresponding class.
Throws:
ClassNotFoundException - if not found.

getLoader

public Loader getLoader(FilterChain chain)
Gets the loader for dynamic class loading.

Parameters:
chain - the filter chain.
Returns:
the loader.
Throws:
IllegalStateException - if not found.

getIntrospector

public Introspector getIntrospector(ServletRequest request,
                                    ServletResponse response,
                                    FilterChain chain)
Gets a localized introspector.

Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the introspector.

getPersister

public Persister getPersister(ServletRequest request,
                              ServletResponse response,
                              FilterChain chain,
                              StepFlowContext context)
                       throws Exception
Gets the context specific persister.

Parameters:
request - the request.
response - the response.
chain - the filter chain.
context - the flow context.
Returns:
the default persister.
Throws:
Exception - on errors.

createVariable

public Variable createVariable(String type,
                               FilterChain chain)
                        throws Exception
Creates a new variable instance of the specified type.

Parameters:
type - the type of the variable.
chain - the filter chain.
Returns:
the variable instance.
Throws:
Exception - on errors.

createVariable

public <V extends Variable> V createVariable(Class<V> clazz,
                                             FilterChain chain)
                                  throws Exception
Creates a new variable instance of the specified class.

Type Parameters:
V - the variable type.
Parameters:
clazz - the class of the variable.
chain - the filter chain.
Returns:
the variable instance.
Throws:
Exception - on errors.

insertVariable

public Variable insertVariable(Variable var,
                               Persister persister,
                               FilterChain chain)
                        throws Exception
Inserts a variable by exporting the specified one.

Parameters:
var - the variable to insert.
persister - the persister.
chain - the filter chain.
Returns:
the inserted variable.
Throws:
Exception - on errors.

updateVariable

public Variable updateVariable(Variable var,
                               Persister persister,
                               FilterChain chain)
                        throws Exception
Updates a variable by importing the specified one.

Parameters:
var - the variable to update.
persister - the persister.
chain - the filter chain.
Returns:
the updated variable.
Throws:
Exception - on errors.

storeVariable

public Variable storeVariable(Variable var,
                              Persister persister,
                              FilterChain chain)
                       throws Exception
Stores a variable by exporting the specified one.

Parameters:
var - the variable to store.
persister - the persister.
chain - the filter chain.
Returns:
the updated variable.
Throws:
Exception - on errors.

deleteVariable

public Variable deleteVariable(Variable var,
                               Persister persister,
                               FilterChain chain)
                        throws Exception
Deletes a variable.

Parameters:
var - the variable to delete.
persister - the persister.
chain - the filter chain.
Returns:
the deleted variable.
Throws:
Exception - on errors.

insertVariable

public Variable insertVariable(Variable var,
                               String type,
                               Persister persister,
                               FilterChain chain)
                        throws Exception
Inserts a variable of the specified type by exporting the specified one.

Parameters:
var - the variable to insert.
type - the variable type.
persister - the persister.
chain - the filter chain.
Returns:
the inserted variable.
Throws:
Exception - on errors.

updateVariable

public Variable updateVariable(Variable var,
                               String type,
                               Persister persister,
                               FilterChain chain)
                        throws Exception
Updates a variable of the specified type by importing the specified one.

Parameters:
var - the variable to update.
type - the variable type.
persister - the persister.
chain - the filter chain.
Returns:
the updated variable.
Throws:
Exception - on errors.

storeVariable

public Variable storeVariable(Variable var,
                              String type,
                              Persister persister,
                              FilterChain chain)
                       throws Exception
Stores a variable of the specified type by exporting the specified one.

Parameters:
var - the variable to store.
type - the variable type.
persister - the persister.
chain - the filter chain.
Returns:
the updated variable.
Throws:
Exception - on errors.

deleteVariable

public Variable deleteVariable(Variable var,
                               String type,
                               Persister persister,
                               FilterChain chain)
                        throws Exception
Deletes a variable of the specified type.

Parameters:
var - the variable to delete.
type - the variable type.
persister - the persister.
chain - the filter chain.
Returns:
the deleted variable.
Throws:
Exception - on errors.

insertReferences

public void insertReferences(Variable var,
                             Persister persister,
                             FilterChain chain)
                      throws Exception
Inserts a variable and its dependencies.

Parameters:
var - the variable to insert.
persister - the persister.
chain - the filter chain.
Throws:
Exception - on errors.

updateReferences

public void updateReferences(Variable var,
                             Persister persister,
                             FilterChain chain)
                      throws Exception
Updates a variable and its dependencies.

Parameters:
var - the variable to update.
persister - the persister.
chain - the filter chain.
Throws:
Exception - on errors.

deleteReferences

public void deleteReferences(Variable var,
                             Persister persister,
                             FilterChain chain)
                      throws Exception
Deletes a variable and its dependencies.

Parameters:
var - the variable to delete.
persister - the persister.
chain - the filter chain.
Throws:
Exception - on errors.

getVariableInfo

public VariableInfo getVariableInfo(String type,
                                    FilterChain chain)
Gets the variable info of the specified type.

Parameters:
type - the type of the variable.
chain - the filter chain.
Returns:
the variable info or null.

getAttributeInfo

public VariableAttributeInfo getAttributeInfo(String name,
                                              String type,
                                              FilterChain chain)
Gets the named attribute info of the variable of the specified type.

Parameters:
name - the name of the attribute.
type - the type of the variable.
chain - the filter chain.
Returns:
the attribute info or null.

getAttributeValues

public List<Object> getAttributeValues(Object node,
                                       String field,
                                       Persister persister,
                                       FilterChain chain)
                                throws Exception
Gets a list of attribute values.

Parameters:
node - the node object.
field - the attribute field(s).
persister - the persister.
chain - the filter chain.
Returns:
a list of attribute values.
Throws:
Exception - on errors.

addAttributeValues

public boolean addAttributeValues(Object node,
                                  String field,
                                  Persister persister,
                                  FilterChain chain,
                                  List<Object> result)
                           throws Exception
Adds attribute values to a list.

Parameters:
node - the node object.
field - the attribute field(s).
persister - the persister.
chain - the filter chain.
result - a list of attribute values.
Returns:
true if added, false otherwise.
Throws:
Exception - on errors.

getRootReferences

public List<?> getRootReferences(Object node,
                                 String relField,
                                 Persister persister,
                                 FilterChain chain)
                          throws Exception
Gets the root nodes.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
chain - the filter chain.
Returns:
a read-only list of referenced nodes.
Throws:
Exception - on errors.

getReferenceValue

public Object getReferenceValue(Object node,
                                int index,
                                String relField,
                                Persister persister,
                                FilterChain chain)
                         throws Exception
Gets the indexed referenced node.

Parameters:
node - the node object.
index - the index.
relField - the relation field.
persister - the persister.
chain - the filter chain.
Returns:
the referenced node or null.
Throws:
Exception - on errors.

isRelatedTo

public boolean isRelatedTo(Variable node,
                           String relField,
                           Object xpk,
                           Persister persister,
                           FilterChain chain)
                    throws Exception
Checks whether the specified key is related to the specified node.

Parameters:
node - the node variable.
relField - the relation field.
xpk - the primary key to check.
persister - the persister.
chain - the filter chain.
Returns:
true if referenced, otherwise false.
Throws:
Exception - on errors.

addToRelationMap

public boolean addToRelationMap(Object node,
                                String relField,
                                Persister persister,
                                FilterChain chain,
                                ConcurrentMap<Object,Object> result)
                         throws Exception
Adds to a map of referenced objects.

Parameters:
node - the node object.
relField - the relation field.
persister - the persister.
chain - the filter chain.
result - the result map.
Returns:
true if added, false otherwise.
Throws:
Exception - on errors.

add1NNullReferences

public boolean add1NNullReferences(String className,
                                   String fkField,
                                   Object[] fks,
                                   Persister persister,
                                   FilterChain chain)
                            throws Exception
Adds null references to 1:n relations.

Parameters:
className - the data class name.
fkField - the foreign key field.
fks - an array of new foreign keys or identities.
persister - the persister.
chain - the filter chain.
Returns:
true if references were added.
Throws:
Exception - on errors.

add1NForeignReferences

public boolean add1NForeignReferences(Object node,
                                      String className,
                                      String fkField,
                                      Object[] fks,
                                      Persister persister,
                                      FilterChain chain)
                               throws Exception
Adds foreign references to 1:n relations.

Parameters:
node - the node object.
className - the foreign class name.
fkField - the foreign key field.
fks - an array of new foreign keys or identities.
persister - the persister.
chain - the filter chain.
Returns:
true if references were added.
Throws:
Exception - on errors.

add1NObjectReferences

public boolean add1NObjectReferences(Object node,
                                     String relField,
                                     String fkField,
                                     Object[] fks,
                                     Persister persister,
                                     FilterChain chain)
                              throws Exception
Adds object references to 1:n relations.

Parameters:
node - the node object.
relField - the relation field.
fkField - the foreign key field.
fks - an array of new foreign keys or identities.
persister - the persister.
chain - the filter chain.
Returns:
true if references were added.
Throws:
Exception - on errors.

setMNForeignReferences

public Object[] setMNForeignReferences(Object node,
                                       String indirection,
                                       String fkField1,
                                       String fkField2,
                                       Object[] fks,
                                       Persister persister,
                                       FilterChain chain)
                                throws Exception
Sets foreign references in m:n relations.

Parameters:
node - the node object.
indirection - the indirection class name.
fkField1 - the foreign key field to the node.
fkField2 - the foreign key field to the reference.
fks - an array of new foreign keys or identities.
persister - the persister.
chain - the filter chain.
Returns:
an array of previous foreign keys or null if nothing changed.
Throws:
Exception - on errors.

setMNObjectReferences

public Object[] setMNObjectReferences(Object node,
                                      String relField,
                                      String indirection,
                                      String fkField1,
                                      String fkField2,
                                      Object[] fks,
                                      Persister persister,
                                      FilterChain chain)
                               throws Exception
Sets object references in m:n relations.

Parameters:
node - the node object.
relField - the relation field.
indirection - the indirection class name.
fkField1 - the foreign key field to the node.
fkField2 - the foreign key field to the reference.
fks - an array of new foreign keys or identities.
persister - the persister.
chain - the filter chain.
Returns:
an array of previous foreign keys or null if nothing changed.
Throws:
Exception - on errors.

orderObjects

public int[] orderObjects(Collection<?> objects,
                          String[] sortFields,
                          Persister persister,
                          FilterChain chain)
Orders a collection of objects with the specified fields.

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

sortObjects

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

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

queryAllObjects

public <T> Collection<T> queryAllObjects(DBQuery<T> query,
                                         String[] sortFields,
                                         Persister persister,
                                         FilterChain chain)
                              throws Exception
Queries all objects of the specified query and may sort them by optional sort fields.

Type Parameters:
T - the object type.
Parameters:
query - the query.
sortFields - optional sort fields.
persister - the persister.
chain - the filter chain.
Returns:
a collection of objects.
Throws:
Exception - on errors.

queryAllObjects

public <T> Collection<T> queryAllObjects(DBCriteria<T> criteria,
                                         String[] sortFields,
                                         Persister persister,
                                         FilterChain chain,
                                         Object... clazz)
                              throws Exception
Queries all objects fulfilling the specified criteria and may sort them by optional sort fields.

Type Parameters:
T - the object type.
Parameters:
criteria - optional criteria.
sortFields - optional sort fields.
persister - the persister.
chain - the filter chain.
clazz - an alternate class or class name.
Returns:
a collection of objects.
Throws:
Exception - on errors.

queryTreeObjects

public <T> Collection<T> queryTreeObjects(DBCriteria<T> criteria,
                                          String relField,
                                          Object rpk,
                                          int depth,
                                          String[] sortFields,
                                          Persister persister,
                                          FilterChain chain,
                                          Object... clazz)
                               throws Exception
Queries objects to the specified depth in a relation tree fulfilling the specified criteria and may sort them by optional sort fields.

Type Parameters:
T - the object type.
Parameters:
criteria - optional criteria.
relField - the relation field.
rpk - an optional root primary key.
depth - the tree depth (-1 = bottom).
sortFields - optionals sort field.
persister - the persister.
chain - the filter chain.
clazz - an alternate class or class name.
Returns:
a collection of objects.
Throws:
Exception - on errors.

getMetaDesktop

public Variable getMetaDesktop(Persister persister,
                               FilterChain chain)
                        throws Exception
Gets the desktop of the current user.

Parameters:
persister - the persister.
chain - the filter chain.
Returns:
the desktop variable.
Throws:
Exception - on errors.

getRootFolder

public Variable getRootFolder(Persister persister,
                              FilterChain chain)
                       throws Exception
Gets the root folder.

Parameters:
persister - the persister.
chain - the filter chain.
Returns:
the folder variable.
Throws:
Exception - on errors.

getMetaFolder

public Variable getMetaFolder(Persister persister,
                              FilterChain chain)
                       throws Exception
Gets the folder of the current user.

Parameters:
persister - the persister.
chain - the filter chain.
Returns:
the folder variable.
Throws:
Exception - on errors.

getDesktopData

public List<Variable> getDesktopData(Persister persister,
                                     FilterChain chain)
                              throws Exception
Gets desktop data of the current user.

Parameters:
persister - the persister.
chain - the filter chain.
Returns:
a list of data variables.
Throws:
Exception - on errors.

getRepositoryFilter

protected BeanRepositoryFilter getRepositoryFilter(FilterChain chain)
Gets the bean repository client.

Parameters:
chain - the filter chain.
Returns:
the specified client or null.


Copyright © 2004 The Norther Organization. All rights reserved.