org.kuali.rice.krad.uif.container
Class CollectionGroupBuilder

java.lang.Object
  extended by org.kuali.rice.krad.uif.container.CollectionGroupBuilder
All Implemented Interfaces:
Serializable

public class CollectionGroupBuilder
extends Object
implements Serializable

Builds out the Field instances for a collection group with a series of steps that interact with the configured CollectionLayoutManager to assemble the fields as necessary for the layout

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
Serialized Form

Constructor Summary
CollectionGroupBuilder()
           
 
Method Summary
protected  void applyLineFieldAuthorizationAndPresentationLogic(View view, ViewModel model, CollectionGroup collectionGroup, Object line, boolean readOnlyLine, List<Field> lineFields, List<ActionField> actions)
          Iterates through the line fields and checks the view field authorization using the view's configured authorizer and presentation controller.
 void build(View view, Object model, CollectionGroup collectionGroup)
          Creates the Field instances that make up the table
protected  void buildAddLine(View view, Object model, CollectionGroup collectionGroup)
          Builds the fields for holding the collection add line and if necessary makes call to setup the new line instance
protected  void buildLine(View view, Object model, CollectionGroup collectionGroup, String bindingPath, List<ActionField> actions, boolean bindToForm, Object currentLine, int lineIndex)
          Builds the field instances for the collection line.
protected  boolean checkEditLineAuthorizationAndPresentationLogic(View view, ViewModel model, CollectionGroup collectionGroup, Object line)
          Invokes the view's configured authorizer and presentation controller to determine if the user has permission to edit the line (if a permission has been established)
protected  boolean checkSubCollectionRender(View view, Object model, CollectionGroup collectionGroup, CollectionGroup subCollectionGroup)
          Checks whether the given sub-collection should be rendered, any conditional render string is evaluated
protected  boolean checkViewLineAuthorizationAndPresentationLogic(View view, ViewModel model, CollectionGroup collectionGroup, Object line)
          Invokes the view's configured authorizer and presentation controller to determine if the user has permission to view the line (if a permission has been established)
protected  List<ActionField> getAddLineActions(View view, Object model, CollectionGroup collectionGroup)
          Creates new ActionField instances for the add line
protected  Map<String,Object> getContextForField(View view, CollectionGroup collectionGroup, Field field)
          Helper method to build the context for a field (needed because the apply model phase for line fields has not been applied yet and their full context not set)
protected  ExpressionEvaluatorService getExpressionEvaluatorService()
           
protected  List<ActionField> getLineActions(View view, Object model, CollectionGroup collectionGroup, Object collectionLine, int lineIndex)
          Creates new ActionField instances for the line
 void initializeNewCollectionLine(View view, Object model, CollectionGroup collectionGroup, boolean clearExistingLine)
          Initializes a new instance of the collection class
protected  List<Integer> performCollectionFiltering(View view, Object model, CollectionGroup collectionGroup, Collection<?> collection)
          Performs any filtering necessary on the collection before building the collection fields
protected  List<Field> processAnyRemoteFieldsHolder(View view, Object model, CollectionGroup group, List<? extends Component> items)
          Iterates through the given items checking for RemotableFieldsHolder, if found the holder is invoked to retrieved the remotable fields and translate to attribute fields.
protected  List<Field> removeNonRenderLineFields(View view, Object model, CollectionGroup collectionGroup, List<Field> lineFields, Object currentLine, int lineIndex)
          Evaluates the render property for the given list of Field instances for the line and removes any fields from the returned list that have render false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionGroupBuilder

public CollectionGroupBuilder()
Method Detail

build

public void build(View view,
                  Object model,
                  CollectionGroup collectionGroup)
Creates the Field instances that make up the table

The corresponding collection is retrieved from the model and iterated over to create the necessary fields. The binding path for fields that implement DataBinding is adjusted to point to the collection line it is apart of. For example, field 'number' of collection 'accounts' for line 1 will be set to 'accounts[0].number', and for line 2 'accounts[1].number'. Finally parameters are set on the line's action fields to indicate what collection and line they apply to.

Parameters:
view - - View instance the collection belongs to
model - - Top level object containing the data
collectionGroup - - CollectionGroup component for the collection

performCollectionFiltering

protected List<Integer> performCollectionFiltering(View view,
                                                   Object model,
                                                   CollectionGroup collectionGroup,
                                                   Collection<?> collection)
Performs any filtering necessary on the collection before building the collection fields

If showInactive is set to false and the collection line type implements Inactivatable, invokes the active collection filter. Then any CollectionFilter instances configured for the collection group are invoked to filter the collection. Collections lines must pass all filters in order to be displayed

Parameters:
view - - view instance that contains the collection
model - - object containing the views data
collectionGroup - - collection group component instance that will display the collection
collection - - collection instance that will be filtered

buildAddLine

protected void buildAddLine(View view,
                            Object model,
                            CollectionGroup collectionGroup)
Builds the fields for holding the collection add line and if necessary makes call to setup the new line instance

Parameters:
view - - view instance the collection belongs to
collectionGroup - - collection group the layout manager applies to
model - - Object containing the view data, should extend UifFormBase if using framework managed new lines

buildLine

protected void buildLine(View view,
                         Object model,
                         CollectionGroup collectionGroup,
                         String bindingPath,
                         List<ActionField> actions,
                         boolean bindToForm,
                         Object currentLine,
                         int lineIndex)
Builds the field instances for the collection line. A copy of the configured items on the CollectionGroup is made and adjusted for the line (id and binding). Then a call is made to the CollectionLayoutManager to assemble the line as necessary for the layout

Parameters:
view - - view instance the collection belongs to
model - - top level object containing the data
collectionGroup - - collection group component for the collection
bindingPath - - binding path for the line fields (if DataBinding)
actions - - List of actions to set in the lines action column
bindToForm - - whether the bindToForm property on the items bindingInfo should be set to true (needed for add line)
currentLine - - object instance for the current line, or null if add line
lineIndex - - index of the line in the collection, or -1 if we are building the add line

processAnyRemoteFieldsHolder

protected List<Field> processAnyRemoteFieldsHolder(View view,
                                                   Object model,
                                                   CollectionGroup group,
                                                   List<? extends Component> items)
Iterates through the given items checking for RemotableFieldsHolder, if found the holder is invoked to retrieved the remotable fields and translate to attribute fields. The translated list is then inserted into the returned list at the position of the holder

Parameters:
view - - view instance containing the container
model - - object instance containing the view data
group - - collection group instance to check for any remotable fields holder
items - - list of items to process

removeNonRenderLineFields

protected List<Field> removeNonRenderLineFields(View view,
                                                Object model,
                                                CollectionGroup collectionGroup,
                                                List<Field> lineFields,
                                                Object currentLine,
                                                int lineIndex)
Evaluates the render property for the given list of Field instances for the line and removes any fields from the returned list that have render false. The conditional render string is also taken into account. This needs to be done here as opposed to during the normal condition evaluation so the the fields are not used while building the collection lines

Parameters:
view - - view instance the collection group belongs to
model - - object containing the view data
collectionGroup - - collection group for the line fields
lineFields - - list of fields configured for the line
currentLine - - object containing the line data
lineIndex - - index of the line in the collection
Returns:
List list of field instances that should be rendered

checkViewLineAuthorizationAndPresentationLogic

protected boolean checkViewLineAuthorizationAndPresentationLogic(View view,
                                                                 ViewModel model,
                                                                 CollectionGroup collectionGroup,
                                                                 Object line)
Invokes the view's configured authorizer and presentation controller to determine if the user has permission to view the line (if a permission has been established)

Parameters:
view - - view instance the collection belongs to and from which the authorizer/presentation controller will be pulled
model - - object containing the view's data
collectionGroup - - collection group containing the line
line - - object containing the lines data
Returns:
boolean true if the user can view the line, false if not

checkEditLineAuthorizationAndPresentationLogic

protected boolean checkEditLineAuthorizationAndPresentationLogic(View view,
                                                                 ViewModel model,
                                                                 CollectionGroup collectionGroup,
                                                                 Object line)
Invokes the view's configured authorizer and presentation controller to determine if the user has permission to edit the line (if a permission has been established)

Parameters:
view - - view instance the collection belongs to and from which the authorizer/presentation controller will be pulled
model - - object containing the view's data
collectionGroup - - collection group containing the line
line - - object containing the lines data
Returns:
boolean true if the user can edit the line, false if not

applyLineFieldAuthorizationAndPresentationLogic

protected void applyLineFieldAuthorizationAndPresentationLogic(View view,
                                                               ViewModel model,
                                                               CollectionGroup collectionGroup,
                                                               Object line,
                                                               boolean readOnlyLine,
                                                               List<Field> lineFields,
                                                               List<ActionField> actions)
Iterates through the line fields and checks the view field authorization using the view's configured authorizer and presentation controller. If the field is viewable, then sets the edit field authorization. Finally iterates through the line actions invoking the authorizer and presentation controller to authorizer the action

Parameters:
view - - view instance the collection belongs to and from which the authorizer/presentation controller will be pulled
model - - object containing the view's data
collectionGroup - - collection group containing the line
line - - object containing the lines data
readOnlyLine - - flag indicating whether the line has been marked as read only (which will force the fields to be read only)
lineFields - - list of fields instances for the line
actions - - list of action field instances for the line

checkSubCollectionRender

protected boolean checkSubCollectionRender(View view,
                                           Object model,
                                           CollectionGroup collectionGroup,
                                           CollectionGroup subCollectionGroup)
Checks whether the given sub-collection should be rendered, any conditional render string is evaluated

Parameters:
view - - view instance the sub collection belongs to
model - - object containing the view data
collectionGroup - - collection group the sub collection belongs to
subCollectionGroup - - sub collection group to check render status for
Returns:
boolean true if sub collection should be rendered, false if it should not be rendered

getLineActions

protected List<ActionField> getLineActions(View view,
                                           Object model,
                                           CollectionGroup collectionGroup,
                                           Object collectionLine,
                                           int lineIndex)
Creates new ActionField instances for the line

Adds context to the action fields for the given line so that the line the action was performed on can be determined when that action is selected

Parameters:
view - - view instance the collection belongs to
model - - top level object containing the data
collectionGroup - - collection group component for the collection
collectionLine - - object instance for the current line
lineIndex - - index of the line the actions should apply to

getAddLineActions

protected List<ActionField> getAddLineActions(View view,
                                              Object model,
                                              CollectionGroup collectionGroup)
Creates new ActionField instances for the add line

Adds context to the action fields for the add line so that the collection the action was performed on can be determined

Parameters:
view - - view instance the collection belongs to
model - - top level object containing the data
collectionGroup - - collection group component for the collection

getContextForField

protected Map<String,Object> getContextForField(View view,
                                                CollectionGroup collectionGroup,
                                                Field field)
Helper method to build the context for a field (needed because the apply model phase for line fields has not been applied yet and their full context not set)

Parameters:
view - - view instance the field belongs to
collectionGroup - - collection group instance the field belongs to
field - - field instance to build context for
Returns:
Map context for field

initializeNewCollectionLine

public void initializeNewCollectionLine(View view,
                                        Object model,
                                        CollectionGroup collectionGroup,
                                        boolean clearExistingLine)
Initializes a new instance of the collection class

If the add line property was not specified for the collection group the new lines will be added to the generic map on the UifFormBase, else it will be added to the property given by the addLineBindingInfo

New line will only be created if the current line property is null or clearExistingLine is true. In the case of a new line default values are also applied

See Also:
initializeNewCollectionLine(View, Object, CollectionGroup, boolean)

getExpressionEvaluatorService

protected ExpressionEvaluatorService getExpressionEvaluatorService()


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.