Class CollectionGroupLineBuilder

java.lang.Object
org.kuali.rice.krad.uif.container.CollectionGroupLineBuilder
All Implemented Interfaces:
Serializable

public class CollectionGroupLineBuilder extends Object implements Serializable
Process configuration from the collection group to prepare components for a new line and invokes the associated layout manager to add the line.
Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
  • Constructor Details

    • CollectionGroupLineBuilder

      public CollectionGroupLineBuilder(LineBuilderContext lineBuilderContext)
  • Method Details

    • buildLine

      public void buildLine()
      Invoked to build a line in the collection.

      First the context for the line is preprocessed in preprocessLine(). After preprocessing the configured layout manager is invoked to place the line into the layout.

    • preprocessLine

      public void preprocessLine()
      Performs various preprocessing of the line components and configuration.

      Preprocessing includes:

      • Make a copy of the collection groups items and adjust binding and id
      • Process any remotable fields within the line
      • Check line and field authorization
      • Remove fields that should not be rendered
      • Configure client side functionality such as save enable and add line validation
      • Build field groups to hold any configured sub-collections
    • initializeLineItems

      protected List<? extends Component> initializeLineItems()
      Copies either the collections groups items or add line items to a list of components that will be used for the collection line.
      Returns:
      list of component instance for the collection line
    • processAnyRemoteFieldsHolder

      public List<Field> processAnyRemoteFieldsHolder(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:
      group - collection group instance to check for any remotable fields holder
      items - list of items to process
    • adjustFieldBindingAndId

      protected void adjustFieldBindingAndId(List<Field> lineFields, String bindingPath)
      Adjusts the binding path for the given fields to match the collections path, and sets the container id suffix for the fields so all nested components will get their ids adjusted.
      Parameters:
      lineFields - list of fields to update
      bindingPath - binding path to add
    • adjustFieldBinding

      protected void adjustFieldBinding(Field lineField, String bindingPath)
      Adjusts the binding path for the given field to match the collections path.
      Parameters:
      lineField - field to update
      bindingPath - binding path to add
    • adjustFieldId

      protected void adjustFieldId(Field lineField)
      Adjusts the id suffix for the given field.
      Parameters:
      lineField - field to update
    • setFocusOnIdForActions

      protected void setFocusOnIdForActions(List<Action> actions, List<Field> lineFields)
      For any actions with focus id UifConstants.Order.LINE_FIRST, the focus id is replaced to match to id of the first control in the line.
      Parameters:
      actions - list of actions to potientially update
      lineFields - list of line fields, the control for the first field in the list will be used for the focus id
    • applyOnChangeForSave

      protected void applyOnChangeForSave(List<Field> lineFields)
      If CollectionGroup.isRenderSaveLineActions() is true and the line has been added by the user, on change script is added to any controls in the line to enable the save action.
      Parameters:
      lineFields - list of line fields
    • removeNonRenderLineFields

      protected List<Field> removeNonRenderLineFields(List<Field> lineFields)
      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:
      lineFields - list of fields configured for the line
      Returns:
      list of field instances that should be rendered
    • checkViewLineAuthorization

      protected boolean checkViewLineAuthorization()
      Determines whether the user is authorized to the view the line.
      Returns:
      boolean true if the user can view the line, false if not
    • checkViewLineAuthorizationAndPresentationLogic

      protected boolean checkViewLineAuthorizationAndPresentationLogic()
      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).
      Returns:
      true if the user can view the line, false if not
    • checkEditLineAuthorization

      protected boolean checkEditLineAuthorization(List<Field> lineFields)
      Determines whether the user is authorized to the edit the line.
      Parameters:
      lineFields - list of fields configured for the line
      Returns:
      boolean true if the user can edit the line, false if not
    • checkEditLineAuthorizationAndPresentationLogic

      protected boolean checkEditLineAuthorizationAndPresentationLogic(CollectionGroup collectionGroup, ViewModel model, Object currentLine)
      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).
      Returns:
      true if the user can edit the line, false if not
    • addUnauthorizedBindingInfo

      protected void addUnauthorizedBindingInfo()
      Adds a BindingInfo instance for the given binding path to the collection groups unauthorized list.
    • applyLineFieldAuthorizationAndPresentationLogic

      protected void applyLineFieldAuthorizationAndPresentationLogic(boolean readOnlyLine, List<Field> lineFields, List<? extends Component> actionList)
      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:
      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
      actionList - list of action field instances for the line
    • buildSubCollectionFieldGroups

      protected void buildSubCollectionFieldGroups()
      For each configured sub collection of the collection group, creates a field group by copying CollectionLayoutManager.getSubCollectionFieldGroupPrototype() and adds to a list which is stored in the line context.
    • checkSubCollectionRender

      protected boolean checkSubCollectionRender(CollectionGroup subCollectionGroup)
      Checks whether the given sub-collection should be rendered, any conditional render string is evaluated.
      Parameters:
      subCollectionGroup - sub collection group to check render status for
      Returns:
      true if sub collection should be rendered, false if it should not be rendered
    • setupAddLineControlValidation

      protected void setupAddLineControlValidation(List<Field> lineFields)
      Add additional information to the fields in the add line to allow for correct add control selection.
      Parameters:
      lineFields - list of fields instances for the line
    • setupAddLineControlValidation

      protected void setupAddLineControlValidation(InputField lineField, List<String> selectors, String suffix)
      Add additional information to a field in the add line to allow for correct add control selection.
      Parameters:
      lineField - field instance for the line
      selectors - list of selectors
      suffix - id suffix to add
    • setupEditLineDetails

      protected void setupEditLineDetails()
      Setup edit line dialog group with the line fields

      The items for a dialog are created from line fields and added if not provided by the user, but if they are then each item is processed.

    • 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:
      Mapinvalid input: '<'String, Object> context for field