| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| WebFriendlyRecipient |
|
| 1.75;1.75 |
| 1 | /* | |
| 2 | * Copyright 2007-2009 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.util; | |
| 17 | ||
| 18 | import org.kuali.rice.kew.actionrequest.Recipient; | |
| 19 | import org.kuali.rice.kim.bo.Person; | |
| 20 | ||
| 21 | /** | |
| 22 | * Class was declared multiple times in different classes. Removed | |
| 23 | * from classes and placed here. Also changed some of the logic | |
| 24 | * so that we can stop using workflowUser | |
| 25 | * | |
| 26 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 27 | * | |
| 28 | */ | |
| 29 | public class WebFriendlyRecipient implements Recipient{ | |
| 30 | ||
| 31 | private static final long serialVersionUID = 2259350039081951688L; | |
| 32 | ||
| 33 | private String displayName; | |
| 34 | private String recipientId; | |
| 35 | ||
| 36 | 0 | public WebFriendlyRecipient(String recipientId, String displayName) { |
| 37 | 0 | this.recipientId = recipientId; |
| 38 | 0 | this.displayName = displayName; |
| 39 | 0 | } |
| 40 | ||
| 41 | 0 | public WebFriendlyRecipient(Object recipient) { |
| 42 | 0 | if (recipient instanceof WebFriendlyRecipient) { |
| 43 | 0 | recipientId = ((WebFriendlyRecipient) recipient).getRecipientId(); |
| 44 | 0 | displayName = ((WebFriendlyRecipient) recipient).getDisplayName(); |
| 45 | 0 | } else if(recipient instanceof Person){ |
| 46 | 0 | recipientId = ((Person)recipient).getPrincipalId(); |
| 47 | 0 | displayName = ((Person)recipient).getLastName() + ", " + ((Person)recipient).getFirstName(); |
| 48 | }else { | |
| 49 | 0 | throw new IllegalArgumentException("Must pass in type Recipient or Person"); |
| 50 | } | |
| 51 | 0 | } |
| 52 | ||
| 53 | public String getRecipientId() { | |
| 54 | 0 | return recipientId; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * | |
| 59 | * @see org.kuali.rice.kew.actionrequest.Recipient#getDisplayName() | |
| 60 | */ | |
| 61 | public String getDisplayName() { | |
| 62 | 0 | return this.displayName; |
| 63 | } | |
| 64 | ||
| 65 | } |