View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.actionlist.web;
17  
18  import org.kuali.rice.core.api.config.property.ConfigContext;
19  import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
20  import org.kuali.rice.kew.actionlist.ActionToTake;
21  import org.kuali.rice.kew.api.KewApiConstants;
22  import org.kuali.rice.kew.util.WebFriendlyRecipient;
23  import org.kuali.rice.kim.api.identity.principal.Principal;
24  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
25  import org.kuali.rice.kns.web.struts.form.KualiForm;
26  import org.kuali.rice.kns.web.ui.ExtraButton;
27  import org.kuali.rice.krad.util.GlobalVariables;
28  import org.kuali.rice.krad.util.KRADConstants;
29  import org.kuali.rice.krad.util.UrlFactory;
30  
31  import javax.servlet.http.HttpServletRequest;
32  import java.util.ArrayList;
33  import java.util.HashMap;
34  import java.util.List;
35  import java.util.Map;
36  import java.util.Properties;
37  
38  /**
39   * Struts form for action ActionListAction
40   *
41   * @author Kuali Rice Team (rice.collab@kuali.org)
42   */
43  public class ActionListForm extends KualiForm {
44  
45      private static final long serialVersionUID = -6246391732337228007L;
46  
47      private String delegator;
48      private String methodToCall = "";
49      private String helpDeskActionListUserName;
50      private String docType;
51      private String filterLegend;
52      private String actionListType;
53      private Boolean customActionList;
54      private String defaultActionToTake;
55      private List<ActionToTake> actionsToTake = new ArrayList<ActionToTake>();
56      private Map<?, ?> defaultActions = new HashMap<Object, Object>();
57      private String delegationId;
58      private List<?> delegators;
59      private Boolean hasCustomActions;
60      private Boolean routeLogPopup;
61      private Boolean documentPopup;
62      private List<WebFriendlyRecipient> primaryDelegates;
63      private String primaryDelegateId;
64  
65      private Boolean hasDisplayParameters;
66  
67      // "sticky" parameters for paginated action list
68      private Integer currentPage;
69      private String currentSort;
70      private String currentDir;
71  
72      // parameters for paginated action list
73      private Integer page;
74      private String sort;
75      private String dir;
76  
77      private int count;
78      private String cssFile = "kuali.css";
79      private String logoAlign = "left";
80      private String viewOutbox;
81      private String[] outboxItems;
82      private boolean outBoxEmpty;
83      private Boolean showOutbox;
84      private List<ExtraButton> headerButtons = new ArrayList<ExtraButton>();
85  
86      public String getHelpDeskActionListUserName() {
87          return helpDeskActionListUserName;
88      }
89  
90      public void setHelpDeskActionListUserName(String helpDeskActionListUserName) {
91          this.helpDeskActionListUserName = helpDeskActionListUserName;
92      }
93  
94      @Override
95      public String getMethodToCall() {
96          return methodToCall;
97      }
98  
99      @Override
100     public void setMethodToCall(String methodToCall) {
101         this.methodToCall = methodToCall;
102     }
103 
104     public String getDelegator() {
105         return delegator;
106     }
107 
108     public void setDelegator(String delegator) {
109         this.delegator = delegator;
110     }
111 
112     public String getDocType() {
113         return docType;
114     }
115 
116     public void setDocType(String docType) {
117         this.docType = docType;
118     }
119 
120     public String getFilterLegend() {
121         return filterLegend;
122     }
123 
124     public void setFilterLegend(String filterLegend) {
125         this.filterLegend = filterLegend;
126     }
127 
128     public String getActionListType() {
129         if (actionListType == null) {
130             setActionListType("all");
131         }
132         return actionListType;
133     }
134 
135     public void setActionListType(String actionListType) {
136         this.actionListType = actionListType;
137     }
138 
139     public Boolean getCustomActionList() {
140         return customActionList;
141     }
142 
143     public void setCustomActionList(Boolean customActionList) {
144         this.customActionList = customActionList;
145     }
146 
147     public String getDefaultActionToTake() {
148         return defaultActionToTake;
149     }
150 
151     public void setDefaultActionToTake(String defaultActionToTake) {
152         this.defaultActionToTake = defaultActionToTake;
153     }
154 
155     public List<ActionToTake> getActionsToTake() {
156         return actionsToTake;
157     }
158 
159     public void setActionsToTake(List<ActionToTake> actionsToTake) {
160         this.actionsToTake = actionsToTake;
161     }
162 
163     public ActionToTake getActions(int index) {
164         while (getActionsToTake().size() <= index) {
165             getActionsToTake().add(new ActionToTake());
166         }
167         return getActionsToTake().get(index);
168     }
169 
170     public Map<?, ?> getDefaultActions() {
171         return defaultActions;
172     }
173 
174     public void setDefaultActions(Map<?, ?> defaultActions) {
175         this.defaultActions = defaultActions;
176     }
177 
178     public String getDelegationId() {
179         return delegationId;
180     }
181 
182     public void setDelegationId(String delegationId) {
183         this.delegationId = delegationId;
184     }
185 
186     public List<?> getDelegators() {
187         return delegators;
188     }
189 
190     public void setDelegators(List<?> delegators) {
191         this.delegators = delegators;
192     }
193 
194     public Boolean getHasCustomActions() {
195         return hasCustomActions;
196     }
197 
198     public void setHasCustomActions(Boolean hasCustomActions) {
199         this.hasCustomActions = hasCustomActions;
200     }
201 
202     public String getDir() {
203         return dir;
204     }
205 
206     public void setDir(String dir) {
207         this.dir = dir;
208     }
209 
210     public Integer getPage() {
211         return page;
212     }
213 
214     public void setPage(Integer page) {
215         this.page = page;
216     }
217 
218     public String getSort() {
219         return sort;
220     }
221 
222     public void setSort(String sort) {
223         this.sort = sort;
224     }
225 
226     public Integer getCurrentPage() {
227         return currentPage;
228     }
229 
230     public void setCurrentPage(Integer currentPage) {
231         this.currentPage = currentPage;
232     }
233 
234     public String getCurrentDir() {
235         return currentDir;
236     }
237 
238     public void setCurrentDir(String currentDir) {
239         this.currentDir = currentDir;
240     }
241 
242     public String getCurrentSort() {
243         return currentSort;
244     }
245 
246     public void setCurrentSort(String currentSort) {
247         this.currentSort = currentSort;
248     }
249 
250     public int getCount() {
251         return count;
252     }
253 
254     public void setCount(int count) {
255         this.count = count;
256     }
257 
258     public String getCssFile() {
259         return cssFile;
260     }
261 
262     public void setCssFile(String cssFile) {
263         this.cssFile = cssFile;
264     }
265 
266     public String getLogoAlign() {
267         return logoAlign;
268     }
269 
270     public void setLogoAlign(String logoAlign) {
271         this.logoAlign = logoAlign;
272     }
273 
274     public String getViewOutbox() {
275         return this.viewOutbox;
276     }
277 
278     public void setViewOutbox(String viewOutbox) {
279         this.viewOutbox = viewOutbox;
280     }
281 
282     public String[] getOutboxItems() {
283         return outboxItems;
284     }
285 
286     public void setOutboxItems(String[] outboxItems) {
287         this.outboxItems = outboxItems;
288     }
289 
290     public boolean isOutBoxEmpty() {
291         return this.outBoxEmpty;
292     }
293 
294     public void setOutBoxEmpty(boolean outBoxEmpty) {
295         this.outBoxEmpty = outBoxEmpty;
296     }
297 
298     public Boolean getShowOutbox() {
299         return this.showOutbox;
300     }
301 
302     public void setShowOutbox(Boolean showOutbox) {
303         this.showOutbox = showOutbox;
304     }
305 
306     public List<ExtraButton> getHeaderButtons() {
307         return this.headerButtons;
308     }
309 
310     public void setHeaderButtons(List<ExtraButton> headerButtons) {
311         this.headerButtons = headerButtons;
312     }
313 
314     public String getMenuBar() {
315         String url = "";
316         Properties parameters = new Properties();
317         url = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, parameters);
318         String krBaseUrl = ConfigContext.getCurrentContextConfig().getKRBaseURL();
319         url = "<a href=\""
320                 + url
321                 + "\"><img src=\""
322                 + krBaseUrl
323                 + "/images/tinybutton-preferences.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>";
324         return url;
325     }
326 
327     @Override
328     public void populate(HttpServletRequest request) {
329         setHeaderButtons(getHeaderButtons());
330 
331         // take the UserSession from the HttpSession and add it to the request
332         request.setAttribute(KRADConstants.USER_SESSION_KEY, GlobalVariables.getUserSession());
333 
334         //refactor actionlist.jsp not to be dependent on this
335         request.setAttribute("preferences", GlobalVariables.getUserSession().retrieveObject(KewApiConstants.PREFERENCES));
336 
337         String principalId = GlobalVariables.getUserSession().getPrincipalId();
338         final Principal hdalPrinc = (Principal) GlobalVariables.getUserSession().retrieveObject(
339                 KewApiConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME);
340         if (hdalPrinc != null) {
341             setHelpDeskActionListUserName(hdalPrinc.getPrincipalName());
342         }
343         boolean isHelpDeskAuthorized = KimApiServiceLocator.getPermissionService().isAuthorized(principalId,
344                 KewApiConstants.KEW_NAMESPACE, KewApiConstants.PermissionNames.VIEW_OTHER_ACTION_LIST,
345                 new HashMap<String, String>());
346         if (isHelpDeskAuthorized) {
347             request.setAttribute("helpDeskActionList", "true");
348         }
349         //String routeLogPopup = "false";
350         //boolean routeLogPopupInd = Utilities.getKNSParameterBooleanValue(KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ACTION_LIST_DETAIL_TYPE, KewApiConstants.ACTION_LIST_ROUTE_LOG_POPUP_IND);
351         //if (routeLogPopupInd) {
352         //	routeLogPopup = "true";
353         //}
354         //String documentPopup = "false";
355         //boolean documentPopupInd = Utilities.getKNSParameterBooleanValue(KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ACTION_LIST_DETAIL_TYPE, KewApiConstants.ACTION_LIST_DOCUMENT_POPUP_IND);
356         //if (documentPopupInd) {
357         //    documentPopup = "true";
358         //}
359         setRouteLogPopup(CoreFrameworkServiceLocator.getParameterService().getParameterValueAsBoolean(
360                 KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ACTION_LIST_DETAIL_TYPE,
361                 KewApiConstants.ACTION_LIST_ROUTE_LOG_POPUP_IND));
362         setDocumentPopup(CoreFrameworkServiceLocator.getParameterService().getParameterValueAsBoolean(
363                 KewApiConstants.KEW_NAMESPACE, KRADConstants.DetailTypes.ACTION_LIST_DETAIL_TYPE,
364                 KewApiConstants.ACTION_LIST_DOCUMENT_POPUP_IND));
365         request.setAttribute("noRefresh", Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(
366                 KewApiConstants.ACTION_LIST_NO_REFRESH)));
367         super.populate(request);
368     }
369 
370     public Boolean getRouteLogPopup() {
371         return this.routeLogPopup;
372     }
373 
374     public Boolean getDocumentPopup() {
375         return this.documentPopup;
376     }
377 
378     public void setRouteLogPopup(Boolean routeLogPopup) {
379         this.routeLogPopup = routeLogPopup;
380     }
381 
382     public void setDocumentPopup(Boolean documentPopup) {
383         this.documentPopup = documentPopup;
384     }
385 
386     public Boolean getHasDisplayParameters() {
387         return this.hasDisplayParameters;
388     }
389 
390     public void setHasDisplayParameters(Boolean hasDisplayParameters) {
391         this.hasDisplayParameters = hasDisplayParameters;
392     }
393 
394     public List<WebFriendlyRecipient> getPrimaryDelegates() {
395         return this.primaryDelegates;
396     }
397 
398     public void setPrimaryDelegates(List<WebFriendlyRecipient> primaryDelegates) {
399         this.primaryDelegates = primaryDelegates;
400     }
401 
402     public String getPrimaryDelegateId() {
403         return this.primaryDelegateId;
404     }
405 
406     public void setPrimaryDelegateId(String primaryDelegateId) {
407         this.primaryDelegateId = primaryDelegateId;
408     }
409 
410 }