001/** 002 * Copyright 2005-2014 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.util; 017 018import org.kuali.rice.kew.actionrequest.KimGroupRecipient; 019import org.kuali.rice.kew.actionrequest.Recipient; 020import org.kuali.rice.kew.role.KimRoleRecipient; 021import org.kuali.rice.kim.api.group.Group; 022import org.kuali.rice.kim.api.identity.Person; 023 024/** 025 * Class was declared multiple times in different classes. Removed 026 * from classes and placed here. Also changed some of the logic 027 * so that we can stop using workflowUser 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 * 031 */ 032public class WebFriendlyRecipient implements Recipient{ 033 034 private static final long serialVersionUID = 2259350039081951688L; 035 036 private String displayName; 037 private String recipientId; 038 039 public WebFriendlyRecipient(String recipientId, String displayName) { 040 this.recipientId = recipientId; 041 this.displayName = displayName; 042 } 043 044 public WebFriendlyRecipient(Object recipient) { 045 if (recipient instanceof WebFriendlyRecipient) { 046 recipientId = ((WebFriendlyRecipient) recipient).getRecipientId(); 047 displayName = ((WebFriendlyRecipient) recipient).getDisplayName(); 048 049 // NOTE: ActionItemDAO code is constructing WebFriendlyRecipient directly w/ Person objects 050 // this should probably be changed to return only Recipients from DAO tier to web tier 051 } else if(recipient instanceof Person){ 052 recipientId = ((Person)recipient).getPrincipalId(); 053 displayName = ((Person)recipient).getLastName() + ", " + ((Person)recipient).getFirstName(); 054 055 } else if(recipient instanceof KimGroupRecipient){ 056 recipientId = ((KimGroupRecipient)recipient).getGroupId(); 057 displayName = ((KimGroupRecipient)recipient).getGroup().getNamespaceCode() + ":" + ((KimGroupRecipient)recipient).getGroup().getName(); 058 059 }else { 060 throw new IllegalArgumentException("Must pass in type Recipient or Person"); 061 } 062 } 063 064 public String getRecipientId() { 065 return recipientId; 066 } 067 068 /** 069 * 070 * @see org.kuali.rice.kew.actionrequest.Recipient#getDisplayName() 071 */ 072 public String getDisplayName() { 073 return this.displayName; 074 } 075 076}