1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.web.struts.form; |
17 | |
|
18 | |
import org.apache.log4j.Logger; |
19 | |
import org.kuali.rice.core.api.parameter.Parameter; |
20 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
21 | |
import org.kuali.rice.kim.util.KimConstants; |
22 | |
import org.kuali.rice.kns.util.KNSConstants; |
23 | |
import org.kuali.rice.kns.util.PagingBannerUtils; |
24 | |
import org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata; |
25 | |
import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase; |
26 | |
|
27 | |
import javax.servlet.http.HttpServletRequest; |
28 | |
import java.util.ArrayList; |
29 | |
import java.util.List; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
@SuppressWarnings("serial") |
38 | 0 | public abstract class IdentityManagementDocumentFormBase extends KualiTransactionalDocumentFormBase { |
39 | 0 | protected static final Logger LOG = Logger.getLogger(IdentityManagementDocumentFormBase.class); |
40 | |
protected static final String MAX_MEMBERS_PER_PAGE_PARM = "MAX_MEMBERS_PER_PAGE"; |
41 | |
protected transient KualiTableRenderFormMetadata memberTableMetadata; |
42 | 0 | protected int recordsPerPage = -1; |
43 | 0 | protected boolean inquiry = false; |
44 | |
|
45 | |
protected static final String CHANGE_NAMESPACE_METHOD_TO_CALL = "methodToCall.changeNamespace"; |
46 | |
protected static final String CHANGE_MEMBER_TYPE_CODE_METHOD_TO_CALL = "methodToCall.changeMemberTypeCode"; |
47 | |
protected static final String CHANGE_DEL_ROLE_MEMBER_METHOD_TO_CALL = "methodToCall.changeDelegationRoleMember"; |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
@SuppressWarnings("unchecked") |
53 | |
@Override |
54 | |
public void populate(HttpServletRequest request) { |
55 | 0 | super.populate(request); |
56 | |
|
57 | 0 | memberTableMetadata = new KualiTableRenderFormMetadata(); |
58 | |
|
59 | 0 | if (KNSConstants.TableRenderConstants.SWITCH_TO_PAGE_METHOD.equals(getMethodToCall())) { |
60 | 0 | final String paramPrefix = KNSConstants.DISPATCH_REQUEST_PARAMETER + "." + KNSConstants.TableRenderConstants.SWITCH_TO_PAGE_METHOD + "."; |
61 | 0 | memberTableMetadata.setSwitchToPageNumber(PagingBannerUtils.getNumbericalValueAfterPrefix(paramPrefix, request.getParameterNames())); |
62 | 0 | if (memberTableMetadata.getSwitchToPageNumber() == -1) { |
63 | 0 | throw new RuntimeException("Couldn't find page number"); |
64 | |
} |
65 | 0 | } else if (KNSConstants.TableRenderConstants.SORT_METHOD.equals(getMethodToCall())) { |
66 | 0 | final String paramPrefix = KNSConstants.DISPATCH_REQUEST_PARAMETER + "." + KNSConstants.TableRenderConstants.SORT_METHOD + "."; |
67 | 0 | memberTableMetadata.setColumnToSortIndex(PagingBannerUtils.getNumbericalValueAfterPrefix(paramPrefix, request.getParameterNames())); |
68 | 0 | if (memberTableMetadata.getColumnToSortIndex() == -1) { |
69 | 0 | throw new RuntimeException("Couldn't find page number"); |
70 | |
} |
71 | |
} |
72 | 0 | } |
73 | |
|
74 | |
public KualiTableRenderFormMetadata getMemberTableMetadata() { |
75 | 0 | return this.memberTableMetadata; |
76 | |
} |
77 | |
|
78 | |
public void setMemberTableMetadata( |
79 | |
KualiTableRenderFormMetadata memberTableMetadata) { |
80 | 0 | this.memberTableMetadata = memberTableMetadata; |
81 | 0 | } |
82 | |
|
83 | |
public int getRecordsPerPage() { |
84 | 0 | if ( recordsPerPage == -1 ) { |
85 | 0 | Parameter param = CoreFrameworkServiceLocator.getParameterService().getParameter(KimConstants.NAMESPACE_CODE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, MAX_MEMBERS_PER_PAGE_PARM); |
86 | 0 | if ( param != null ) { |
87 | |
try { |
88 | 0 | recordsPerPage = Integer.parseInt( param.getValue() ); |
89 | 0 | } catch ( NumberFormatException ex ) { |
90 | 0 | LOG.error( "Unable to parse parameter " + KimConstants.NAMESPACE_CODE+"/"+KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE+"/"+MAX_MEMBERS_PER_PAGE_PARM + "(+"+param.getValue()+") as an int - defaulting to 1." ); |
91 | 0 | recordsPerPage = 1; |
92 | 0 | } |
93 | |
} else { |
94 | 0 | LOG.error( "Unable to find " + KimConstants.NAMESPACE_CODE+"/"+KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE+"/"+MAX_MEMBERS_PER_PAGE_PARM + " - defaulting to 1." ); |
95 | 0 | recordsPerPage = 1; |
96 | |
} |
97 | |
} |
98 | 0 | return recordsPerPage; |
99 | |
} |
100 | |
|
101 | |
|
102 | |
public boolean isCanExport() { |
103 | 0 | return false; |
104 | |
} |
105 | |
|
106 | |
@SuppressWarnings("unchecked") |
107 | |
public List getMemberRows() { |
108 | 0 | return new ArrayList(); |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public boolean isInquiry() { |
115 | 0 | return this.inquiry; |
116 | |
} |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public void setInquiry(boolean inquiry) { |
122 | 0 | this.inquiry = inquiry; |
123 | 0 | } |
124 | |
} |