1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.web.struts.action;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.log4j.Logger;
20 import org.apache.struts.action.ActionForm;
21 import org.apache.struts.action.ActionForward;
22 import org.apache.struts.action.ActionMapping;
23 import org.kuali.rice.core.api.util.RiceConstants;
24 import org.kuali.rice.core.api.util.RiceKeyConstants;
25 import org.kuali.rice.kim.api.KimConstants;
26 import org.kuali.rice.kim.api.group.Group;
27 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
28 import org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase;
29 import org.kuali.rice.kim.web.struts.form.IdentityManagementGroupDocumentForm;
30 import org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata;
31 import org.kuali.rice.krad.util.GlobalVariables;
32 import org.kuali.rice.krad.util.KRADConstants;
33
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.http.HttpServletResponse;
36
37
38
39
40
41
42
43 public class IdentityManagementGroupInquiry extends IdentityManagementBaseInquiryAction {
44 private static final Logger LOG = Logger.getLogger(IdentityManagementGroupInquiry.class);
45
46
47
48
49
50
51 @Override
52 protected void loadKimObject(HttpServletRequest request, IdentityManagementDocumentFormBase form) {
53 IdentityManagementGroupDocumentForm groupDocumentForm = (IdentityManagementGroupDocumentForm) form;
54 String id = request.getParameter(KimConstants.PrimaryKeyConstants.GROUP_ID);
55 String altId = request.getParameter(KimConstants.AttributeConstants.GROUP_ID);
56
57 String groupId = StringUtils.isNotEmpty(id) ? id : altId;
58 Group group = null;
59 if (StringUtils.isNotEmpty(groupId)) {
60 group = KimApiServiceLocator.getGroupService().getGroup(groupId);
61 } else {
62 String namespaceCode = request.getParameter(KimConstants.UniqueKeyConstants.NAMESPACE_CODE);
63 String groupName = request.getParameter(KimConstants.UniqueKeyConstants.GROUP_NAME);
64
65 if (!StringUtils.isBlank(namespaceCode) && !StringUtils.isBlank(groupName)) {
66 group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(namespaceCode, groupName);
67 }
68 }
69 if (group != null) {
70 getUiDocumentService().loadGroupDoc(groupDocumentForm.getGroupDocument(), group);
71 } else {
72 LOG.error("No records found for Group Inquiry.");
73 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_INQUIRY);
74 }
75 }
76
77
78 @Override
79 public ActionForward execute(ActionMapping mapping, ActionForm form,
80 HttpServletRequest request, HttpServletResponse response) throws Exception {
81
82 IdentityManagementGroupDocumentForm groupDocumentForm = (IdentityManagementGroupDocumentForm) form;
83
84 ActionForward forward = super.execute(mapping, form, request, response);
85
86 String previouslySortedColumnName = (String)GlobalVariables.getUserSession().retrieveObject(KimConstants.KimUIConstants.KIM_GROUP_INQUIRY_SORT_PREV_COL_NM);
87 Boolean sortDescending = ((Boolean)GlobalVariables.getUserSession().retrieveObject(KimConstants.KimUIConstants.KIM_GROUP_INQUIRY_SORT_DESC_VALUE));
88
89 KualiTableRenderFormMetadata memberTableMetadata = groupDocumentForm.getMemberTableMetadata();
90 memberTableMetadata.setPreviouslySortedColumnName(previouslySortedColumnName);
91 if (sortDescending != null) {
92 memberTableMetadata.setSortDescending(sortDescending.booleanValue());
93 }
94 if (groupDocumentForm.getMemberRows() != null) {
95 memberTableMetadata.sort(groupDocumentForm.getMemberRows(), groupDocumentForm.getRecordsPerPage());
96 memberTableMetadata.jumpToPage(memberTableMetadata.getSwitchToPageNumber(), groupDocumentForm.getMemberRows().size(), groupDocumentForm.getRecordsPerPage());
97 }
98
99 GlobalVariables.getUserSession().addObject(KimConstants.KimUIConstants.KIM_GROUP_INQUIRY_SORT_PREV_COL_NM, memberTableMetadata.getPreviouslySortedColumnName());
100 GlobalVariables.getUserSession().addObject(KimConstants.KimUIConstants.KIM_GROUP_INQUIRY_SORT_DESC_VALUE, memberTableMetadata.isSortDescending());
101
102 return forward;
103 }
104
105
106 public ActionForward sort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
107 return mapping.findForward(RiceConstants.MAPPING_BASIC);
108 }
109 }