001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.actionlist; 017 018import org.kuali.rice.core.api.config.property.ConfigContext; 019import org.kuali.rice.core.api.util.RiceConstants; 020import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator; 021import org.kuali.rice.kew.actionitem.ActionItemActionListExtension; 022import org.kuali.rice.kew.actionlist.ActionToTake; 023import org.kuali.rice.kew.api.KewApiConstants; 024import org.kuali.rice.kew.api.preferences.Preferences; 025import org.kuali.rice.kew.util.WebFriendlyRecipient; 026import org.kuali.rice.kim.api.identity.Person; 027import org.kuali.rice.kim.api.identity.principal.Principal; 028import org.kuali.rice.kim.api.services.KimApiServiceLocator; 029import org.displaytag.pagination.PaginatedList; 030import org.kuali.rice.kns.web.ui.ExtraButton; 031import org.kuali.rice.krad.util.GlobalVariables; 032import org.kuali.rice.krad.util.KRADConstants; 033import org.kuali.rice.krad.util.UrlFactory; 034import org.kuali.rice.krad.web.form.UifFormBase; 035import org.kuali.rice.kew.api.action.ActionItem; 036 037import javax.servlet.http.HttpServletRequest; 038import java.text.ParseException; 039import java.util.ArrayList; 040import java.util.HashMap; 041import java.util.List; 042import java.util.Map; 043import java.util.Properties; 044 045/** 046 * Action List form implementation for the action list. 047 * 048 * <p> 049 * Holds properties necessary to determine the {@code View} instance that 050 * will be used to render the UI for the action list. 051 * </p> 052 * 053 * @author Kuali Rice Team (rice.collab@kuali.org) 054 */ 055public class ActionListForm extends UifFormBase { 056 057 private static final long serialVersionUID = -6246391732337228107L; 058 059 private String delegator; 060 private String methodToCall = ""; 061 private String helpDeskActionListUserName; 062 private String docType; 063 private String filterLegend; 064 private String actionListType; 065 private Boolean customActionList; 066 private String defaultActionToTake; 067 private List<ActionToTake> actionsToTake = new ArrayList<ActionToTake>(); 068 private Map<?, ?> defaultActions = new HashMap<Object, Object>(); 069 private String delegationId; 070 private List<?> delegators; 071 private Boolean hasCustomActions; 072 private Boolean routeLogPopup; 073 private Boolean documentPopup; 074 private List<WebFriendlyRecipient> primaryDelegates; 075 private String primaryDelegateId; 076 private Boolean hasDisplayParameters; 077 078 private String cssFile = "kuali.css"; 079 private String logoAlign = "left"; 080 private String viewOutbox; 081 private String[] outboxItems; 082 private boolean outBoxEmpty; 083 private Boolean showOutbox; 084 085 //moved from session 086 private boolean requeryActionList; 087 private Preferences preferences; 088 private boolean updateActionList; 089 private boolean outBoxMode; 090 private Principal helpDeskActionListPrincipal; 091 private Person helpDeskActionListPerson; 092 093 //moved from filter 094 private static String CREATE_DATE_FROM = "createDateFrom"; 095 private static String CREATE_DATE_TO = "createDateTo"; 096 private static String LAST_ASSIGNED_DATE_FROM = "lastAssignedDateFrom"; 097 private static String LAST_ASSIGNED_DATE_TO = "lastAssignedDateTo"; 098 private ActionListFilter filter; 099 private ActionListFilter oldFilter; 100 private String createDateFrom; 101 private String createDateTo; 102 private String lastAssignedDateTo; 103 private String lastAssignedDateFrom; 104 private String lookupableImplServiceName; 105 private String lookupType; 106 private String docTypeFullName; 107 private List userWorkgroups; 108 109 public String getCreateDateTo() { 110 return createDateTo; 111 } 112 public void setCreateDateTo(String createDateTo) { 113 if(createDateTo == null){ 114 createDateTo = ""; 115 } 116 else{ 117 this.createDateTo = createDateTo.trim(); 118 } 119 } 120 121 public String getLastAssignedDateFrom() { 122 return lastAssignedDateFrom; 123 } 124 125 public void setLastAssignedDateFrom(String lastAssignedDateFrom) { 126 if(lastAssignedDateFrom == null){ 127 lastAssignedDateFrom = ""; 128 } 129 else{ 130 this.lastAssignedDateFrom = lastAssignedDateFrom.trim(); 131 } 132 } 133 134 public String getCreateDateFrom() { 135 return createDateFrom; 136 } 137 138 public void setCreateDateFrom(String createDate) { 139 if(createDate == null){ 140 createDate = ""; 141 } 142 else{ 143 this.createDateFrom = createDate.trim(); 144 } 145 } 146 147 public ActionListFilter getFilter() { 148 return filter; 149 } 150 151 public void setFilter(ActionListFilter filter) { 152 this.filter = filter; 153 if (filter.getCreateDateFrom() != null) { 154 setCreateDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateFrom())); 155 } 156 if (filter.getCreateDateTo() != null) { 157 setCreateDateTo(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateTo())); 158 } 159 if (filter.getLastAssignedDateFrom() != null) { 160 setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateFrom())); 161 } 162 if (filter.getLastAssignedDateTo() != null) { 163 setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateTo())); 164 } 165 } 166 167 public String getLastAssignedDateTo() { 168 return lastAssignedDateTo; 169 } 170 171 public void setLastAssignedDateTo(String lastAssignedDate) { 172 if(lastAssignedDate == null){ 173 lastAssignedDate = ""; 174 } 175 else{ 176 this.lastAssignedDateTo = lastAssignedDate.trim(); 177 } 178 } 179 180 public ActionListFilter getOldFilter() { 181 return oldFilter; 182 } 183 184 public void setOldFilter(ActionListFilter oldFilter) { 185 this.oldFilter = oldFilter; 186 } 187 188 public void validateDates() { 189 //List errors = new ArrayList(); 190 //ActionErrors errors = new ActionErrors(); 191 if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) { 192 try { 193 RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom()); 194 } catch (ParseException e) { 195 GlobalVariables.getMessageMap().putError(CREATE_DATE_FROM, "general.error.fieldinvalid", "Create Date From"); 196 } 197 } 198 if (getCreateDateTo() != null && getCreateDateTo().length() != 0) { 199 try { 200 RiceConstants.getDefaultDateFormat().parse(getCreateDateTo()); 201 } catch (ParseException e) { 202 GlobalVariables.getMessageMap().putError(CREATE_DATE_TO, "general.error.fieldinvalid", "Create Date To"); 203 } 204 } 205 if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) { 206 try { 207 RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom()); 208 } catch (ParseException e1) { 209 GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_FROM, "general.error.fieldinvalid", "Last Assigned Date From"); 210 } 211 } 212 if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) { 213 try { 214 RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo()); 215 } catch (ParseException e1) { 216 GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_TO, "general.error.fieldinvalid", "Last Assigned Date To"); 217 } 218 } 219 } 220 221 public ActionListFilter getLoadedFilter()/* throws ParseException*/ { 222 try { 223 if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) { 224 filter.setCreateDateFrom(RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom())); 225 } 226 if (getCreateDateTo() != null && getCreateDateTo().length() != 0) { 227 filter.setCreateDateTo(RiceConstants.getDefaultDateFormat().parse(getCreateDateTo())); 228 } 229 if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) { 230 filter.setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom())); 231 } 232 if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) { 233 filter.setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo())); 234 } 235 if (getDocTypeFullName() != null && ! "".equals(getDocTypeFullName())) { 236 filter.setDocumentType(getDocTypeFullName()); 237 } 238 } catch (ParseException e) { 239 //error caught and displayed in validateDates() 240 } 241 242 return filter; 243 } 244 245 public String getLookupableImplServiceName() { 246 return lookupableImplServiceName; 247 } 248 249 public void setLookupableImplServiceName(String lookupableImplServiceName) { 250 this.lookupableImplServiceName = lookupableImplServiceName; 251 } 252 253 public String getLookupType() { 254 return lookupType; 255 } 256 257 public void setLookupType(String lookupType) { 258 this.lookupType = lookupType; 259 } 260 261 public String getDocTypeFullName() { 262 return docTypeFullName; 263 } 264 265 public void setDocTypeFullName(String docTypeFullName) { 266 this.docTypeFullName = docTypeFullName; 267 } 268 269 public List getUserWorkgroups() { 270 return userWorkgroups; 271 } 272 273 public void setUserWorkgroups(List userWorkgroups) { 274 this.userWorkgroups = userWorkgroups; 275 } 276 277 public Principal getHelpDeskActionListPrincipal() { 278 return helpDeskActionListPrincipal; 279 } 280 281 public void setHelpDeskActionListPrincipal(Principal helpDeskActionListPrincipal) { 282 this.helpDeskActionListPrincipal = helpDeskActionListPrincipal; 283 } 284 285 public Person getHelpDeskActionListPerson() { 286 return helpDeskActionListPerson; 287 } 288 289 public void setHelpDeskActionListPerson(Person helpDeskActionListPerson) { 290 this.helpDeskActionListPerson = helpDeskActionListPerson; 291 } 292 293 public boolean isOutBoxMode() { 294 return outBoxMode; 295 } 296 297 public void setOutBoxMode(boolean outBoxMode) { 298 this.outBoxMode = outBoxMode; 299 } 300 301 public void setUser(String user) { 302 this.user = user; 303 } 304 305 public String getUser() { 306 return user; 307 } 308 309 private String user; 310 311 public boolean isNoRefresh() { 312 return noRefresh; 313 } 314 315 public void setNoRefresh(boolean noRefresh) { 316 this.noRefresh = noRefresh; 317 } 318 319 private boolean noRefresh; 320 321 public boolean isHelpDeskActionList() { 322 return helpDeskActionList; 323 } 324 325 public void setHelpDeskActionList(boolean helpDeskActionList) { 326 this.helpDeskActionList = helpDeskActionList; 327 } 328 329 private boolean helpDeskActionList; 330 private List<ActionItemActionListExtension> actionList; 331 private List<ActionItem> ApiActionItems; 332 333 public List<ActionItemActionListExtension> getActionList() { 334 return actionList; 335 } 336 public void setActionList(ArrayList<ActionItemActionListExtension> actionList) { 337 this.actionList = actionList; 338 } 339 340 public boolean isRequeryActionList() { 341 return requeryActionList; 342 } 343 344 public void setRequeryActionList(boolean requeryActionList) { 345 this.requeryActionList = requeryActionList; 346 } 347 348 public Preferences getPreferences() { 349 return preferences; 350 } 351 352 public void setPreferences(Preferences preferences) { 353 this.preferences = preferences; 354 } 355 356 public boolean isUpdateActionList() { 357 return updateActionList; 358 } 359 360 public void setUpdateActionList(boolean updateActionList) { 361 this.updateActionList = updateActionList; 362 } 363 364 public String getHelpDeskActionListUserName() { 365 return helpDeskActionListUserName; 366 } 367 368 public void setHelpDeskActionListUserName(String helpDeskActionListUserName) { 369 this.helpDeskActionListUserName = helpDeskActionListUserName; 370 } 371 372 @Override 373 public String getMethodToCall() { 374 return methodToCall; 375 } 376 377 @Override 378 public void setMethodToCall(String methodToCall) { 379 this.methodToCall = methodToCall; 380 } 381 382 public String getDelegator() { 383 return delegator; 384 } 385 386 public void setDelegator(String delegator) { 387 this.delegator = delegator; 388 } 389 390 public String getDocType() { 391 return docType; 392 } 393 394 public void setDocType(String docType) { 395 this.docType = docType; 396 } 397 398 public String getFilterLegend() { 399 return filterLegend; 400 } 401 402 public void setFilterLegend(String filterLegend) { 403 this.filterLegend = filterLegend; 404 } 405 406 public String getActionListType() { 407 if (actionListType == null) { 408 setActionListType("all"); 409 } 410 return actionListType; 411 } 412 413 public void setActionListType(String actionListType) { 414 this.actionListType = actionListType; 415 } 416 417 public Boolean getCustomActionList() { 418 return customActionList; 419 } 420 421 public void setCustomActionList(Boolean customActionList) { 422 this.customActionList = customActionList; 423 } 424 425 public String getDefaultActionToTake() { 426 return defaultActionToTake; 427 } 428 429 public void setDefaultActionToTake(String defaultActionToTake) { 430 this.defaultActionToTake = defaultActionToTake; 431 } 432 433 public List<ActionToTake> getActionsToTake() { 434 return actionsToTake; 435 } 436 437 public void setActionsToTake(List<ActionToTake> actionsToTake) { 438 this.actionsToTake = actionsToTake; 439 } 440 441 public ActionToTake getActions(int index) { 442 while (getActionsToTake().size() <= index) { 443 getActionsToTake().add(new ActionToTake()); 444 } 445 return getActionsToTake().get(index); 446 } 447 448 public Map<?, ?> getDefaultActions() { 449 return defaultActions; 450 } 451 452 public void setDefaultActions(Map<?, ?> defaultActions) { 453 this.defaultActions = defaultActions; 454 } 455 456 public String getDelegationId() { 457 return delegationId; 458 } 459 460 public void setDelegationId(String delegationId) { 461 this.delegationId = delegationId; 462 } 463 464 public List<?> getDelegators() { 465 return delegators; 466 } 467 468 public void setDelegators(List<?> delegators) { 469 this.delegators = delegators; 470 } 471 472 public Boolean getHasCustomActions() { 473 return hasCustomActions; 474 } 475 476 public void setHasCustomActions(Boolean hasCustomActions) { 477 this.hasCustomActions = hasCustomActions; 478 } 479 480 public String getCssFile() { 481 return cssFile; 482 } 483 484 public void setCssFile(String cssFile) { 485 this.cssFile = cssFile; 486 } 487 488 public String getLogoAlign() { 489 return logoAlign; 490 } 491 492 public void setLogoAlign(String logoAlign) { 493 this.logoAlign = logoAlign; 494 } 495 496 public String getViewOutbox() { 497 return this.viewOutbox; 498 } 499 500 public void setViewOutbox(String viewOutbox) { 501 this.viewOutbox = viewOutbox; 502 } 503 504 public String[] getOutboxItems() { 505 return outboxItems; 506 } 507 508 public void setOutboxItems(String[] outboxItems) { 509 this.outboxItems = outboxItems; 510 } 511 512 public boolean isOutBoxEmpty() { 513 return this.outBoxEmpty; 514 } 515 516 public void setOutBoxEmpty(boolean outBoxEmpty) { 517 this.outBoxEmpty = outBoxEmpty; 518 } 519 520 public Boolean getShowOutbox() { 521 return this.showOutbox; 522 } 523 524 public void setShowOutbox(Boolean showOutbox) { 525 this.showOutbox = showOutbox; 526 } 527 528 public String getMenuBar() { 529 String url = ""; 530 Properties parameters = new Properties(); 531 url = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, parameters); 532 String krBaseUrl = ConfigContext.getCurrentContextConfig().getKRBaseURL(); 533 url = "<a href=\"" 534 + url 535 + "\"><img src=\"" 536 + krBaseUrl 537 + "/images/tinybutton-preferences.gif\" alt=\"create new\" width=\"70\" height=\"15\"/></a>"; 538 539 return url; 540 } 541 542 @Override 543 public void postBind(HttpServletRequest request) { 544 545 //add the preferences to the form 546 setPreferences((Preferences)(GlobalVariables.getUserSession().retrieveObject(KewApiConstants.PREFERENCES))); 547 548 String principalId = GlobalVariables.getUserSession().getPrincipalId(); 549 final Principal hdalPrinc = (Principal) GlobalVariables.getUserSession().retrieveObject( 550 KewApiConstants.HELP_DESK_ACTION_LIST_PRINCIPAL_ATTR_NAME); 551 if (hdalPrinc != null) { 552 setHelpDeskActionListUserName(hdalPrinc.getPrincipalName()); 553 } 554 boolean isHelpDeskAuthorized = KimApiServiceLocator.getPermissionService().isAuthorized(principalId, 555 KewApiConstants.KEW_NAMESPACE, KewApiConstants.PermissionNames.VIEW_OTHER_ACTION_LIST, 556 new HashMap<String, String>()); 557 if (isHelpDeskAuthorized) { 558 setHelpDeskActionList(true); 559 } 560 561 super.postBind(request); 562 } 563 564 public Boolean getRouteLogPopup() { 565 return this.routeLogPopup; 566 } 567 568 public Boolean getDocumentPopup() { 569 return this.documentPopup; 570 } 571 572 public void setRouteLogPopup(Boolean routeLogPopup) { 573 this.routeLogPopup = routeLogPopup; 574 } 575 576 public void setDocumentPopup(Boolean documentPopup) { 577 this.documentPopup = documentPopup; 578 } 579 580 public Boolean getHasDisplayParameters() { 581 return this.hasDisplayParameters; 582 } 583 584 public void setHasDisplayParameters(Boolean hasDisplayParameters) { 585 this.hasDisplayParameters = hasDisplayParameters; 586 } 587 588 public List<WebFriendlyRecipient> getPrimaryDelegates() { 589 return this.primaryDelegates; 590 } 591 592 public void setPrimaryDelegates(List<WebFriendlyRecipient> primaryDelegates) { 593 this.primaryDelegates = primaryDelegates; 594 } 595 596 public String getPrimaryDelegateId() { 597 return this.primaryDelegateId; 598 } 599 600 public void setPrimaryDelegateId(String primaryDelegateId) { 601 this.primaryDelegateId = primaryDelegateId; 602 } 603 604 // convert a List of org.kuali.rice.kew.actionitem.ActionItemS to org.kuali.rice.kew.api.action.ActionItemS 605 public List<ActionItem> getApiActionList() { 606 List<org.kuali.rice.kew.api.action.ActionItem> apiActionItems = new ArrayList<org.kuali.rice.kew.api.action.ActionItem>(actionList.size()); 607 608 for (ActionItemActionListExtension actionItemObj : actionList) { 609 apiActionItems.add( 610 org.kuali.rice.kew.api.action.ActionItem.Builder.create(actionItemObj).build()); 611 } 612 613 return apiActionItems; 614 } 615}