public ActionForward sort(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
   KualiTableRenderFormMetadata memberTableMetadata = roleDocumentForm.getMemberTableMetadata();
   memberTableMetadata.setSwitchToPageNumber(0);
   return mapping.findForward(RiceConstants.MAPPING_BASIC);
 }
 /**
  * @see
  *     org.kuali.rice.kns.web.struts.action.KualiTableRenderAction#switchToPage(org.apache.struts.action.ActionMapping,
  *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
  *     javax.servlet.http.HttpServletResponse)
  */
 public ActionForward jumpToRoleMember(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   IdentityManagementRoleDocumentForm idmForm = (IdentityManagementRoleDocumentForm) form;
   String delegationRoleMemberId = getDelegationRoleMemberToJumpTo(request);
   KualiTableRenderFormMetadata memberTableMetadata = idmForm.getMemberTableMetadata();
   memberTableMetadata.jumpToPage(
       idmForm.getPageNumberOfRoleMemberId(delegationRoleMemberId),
       idmForm.getMemberRows().size(),
       idmForm.getRecordsPerPage());
   memberTableMetadata.setColumnToSortIndex(memberTableMetadata.getPreviouslySortedColumnIndex());
   idmForm.setAnchor(delegationRoleMemberId);
   return mapping.findForward(RiceConstants.MAPPING_BASIC);
 }
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
    if (roleDocumentForm.getRoleId() == null) {
      String roleId = request.getParameter(KimConstants.PrimaryKeyConstants.SUB_ROLE_ID);
      roleDocumentForm.setRoleId(roleId);
    }

    KualiTableRenderFormMetadata memberTableMetadata = roleDocumentForm.getMemberTableMetadata();
    if (roleDocumentForm.getRoleDocument() != null && roleDocumentForm.getMemberRows() != null) {
      memberTableMetadata.jumpToPage(
          memberTableMetadata.getViewedPageNumber(),
          roleDocumentForm.getMemberRows().size(),
          roleDocumentForm.getRecordsPerPage());
      // KULRICE-3972: need to be able to sort by column header like on lookups when editing large
      // roles and groups
      memberTableMetadata.sort(
          roleDocumentForm.getMemberRows(), roleDocumentForm.getRecordsPerPage());
    }

    // KULRICE-4762: active delegates of "inactivated" role members cause validation problems
    ActionForward forward =
        promptForAffectedDelegates(mapping, form, request, response, roleDocumentForm);
    // if we need to prompt the user due to affected delegates, do so:
    if (forward != null) {
      return forward;
    }

    forward = super.execute(mapping, roleDocumentForm, request, response);

    roleDocumentForm.setCanAssignRole(validAssignRole(roleDocumentForm.getRoleDocument()));
    if (KimTypeLookupableHelperServiceImpl.hasDerivedRoleTypeService(
        roleDocumentForm.getRoleDocument().getKimType())) {
      roleDocumentForm.setCanModifyAssignees(false);
    }
    GlobalVariables.getUserSession()
        .addObject(
            KimConstants.KimUIConstants.KIM_ROLE_DOCUMENT_SHORT_KEY,
            roleDocumentForm.getRoleDocument());
    return forward;
  }
  public ActionForward clear(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
    roleDocumentForm.setMemberSearchValue("");
    getUiDocumentService()
        .clearRestrictedRoleMembersSearchResults(roleDocumentForm.getRoleDocument());

    KualiTableRenderFormMetadata memberTableMetadata = roleDocumentForm.getMemberTableMetadata();
    if (roleDocumentForm.getMemberRows() != null) {
      memberTableMetadata.jumpToFirstPage(
          roleDocumentForm.getMemberRows().size(), roleDocumentForm.getRecordsPerPage());
    }
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
  }
  /**
   * This overridden method ...
   *
   * @see
   *     org.kuali.rice.krad.web.struts.action.KualiDocumentActionBase#loadDocument(org.kuali.rice.krad.web.struts.form.KualiDocumentFormBase)
   */
  @Override
  protected void loadDocument(KualiDocumentFormBase form) throws WorkflowException {
    super.loadDocument(form);

    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
    setKimType(roleDocumentForm.getRoleDocument().getRoleTypeId(), roleDocumentForm);

    getUiDocumentService().setDelegationMembersInDocument(roleDocumentForm.getRoleDocument());
    getUiDocumentService().setMembersInDocument(roleDocumentForm.getRoleDocument());

    roleDocumentForm.setMember(roleDocumentForm.getRoleDocument().getBlankMember());
    roleDocumentForm.setDelegationMember(
        roleDocumentForm.getRoleDocument().getBlankDelegationMember());

    KualiTableRenderFormMetadata memberTableMetadata = roleDocumentForm.getMemberTableMetadata();
    if (roleDocumentForm.getMemberRows() != null) {
      memberTableMetadata.jumpToFirstPage(
          roleDocumentForm.getMemberRows().size(), roleDocumentForm.getRecordsPerPage());
    }
  }
  /**
   * This overridden method ...
   *
   * @see
   *     org.kuali.rice.krad.web.struts.action.KualiDocumentActionBase#createDocument(org.kuali.rice.krad.web.struts.form.KualiDocumentFormBase)
   */
  @Override
  protected void createDocument(KualiDocumentFormBase form) throws WorkflowException {
    super.createDocument(form);
    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;

    if (roleDocumentForm.getRoleId() == null) {
      roleDocumentForm.getRoleDocument().setKimType(roleDocumentForm.getKimType());
      roleDocumentForm.getRoleDocument().initializeDocumentForNewRole();
      roleDocumentForm.setRoleId(roleDocumentForm.getRoleDocument().getRoleId());
      // roleDocumentForm.setKimType(KimApiServiceLocator.getKimTypeInfoService().getKimType(roleDocumentForm.getRoleDocument().getRoleTypeId()));
    } else {
      loadRoleIntoDocument(roleDocumentForm.getRoleId(), roleDocumentForm);
    }

    roleDocumentForm.setMember(roleDocumentForm.getRoleDocument().getBlankMember());
    roleDocumentForm.setDelegationMember(
        roleDocumentForm.getRoleDocument().getBlankDelegationMember());

    KualiTableRenderFormMetadata memberTableMetadata = roleDocumentForm.getMemberTableMetadata();
    if (roleDocumentForm.getMemberRows() != null) {
      memberTableMetadata.jumpToFirstPage(
          roleDocumentForm.getMemberRows().size(), roleDocumentForm.getRecordsPerPage());
    }
  }