View Javadoc

1   /*
2    * Copyright 2006-2007 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.kns.bo;
17  
18  import javax.persistence.Entity;
19  import javax.persistence.IdClass;
20  import javax.persistence.Table;
21  import javax.persistence.Transient;
22  
23  import org.kuali.rice.kim.bo.Person;
24  
25  /**
26   * Ad Hoc Route Person Business Object
27   */
28  @IdClass(org.kuali.rice.kns.bo.AdHocRoutePersonId.class)
29  @Entity
30  @Table(name="KRNS_ADHOC_RTE_ACTN_RECIP_T")
31  public class AdHocRoutePerson extends AdHocRouteRecipient {
32  
33      private static final long serialVersionUID = 1L;
34      
35      @Transient
36      private transient Person person;
37  
38      public AdHocRoutePerson() {
39          setType(PERSON_TYPE);
40      }
41  
42      @Override
43      public void setType(Integer type) {
44          if (!PERSON_TYPE.equals(type)) {
45              throw new IllegalArgumentException("cannot change type to " + type);
46          }
47          super.setType(type);
48      }
49  
50      @Override
51      public String getName() {
52          if ( person == null || person.getPrincipalName() == null || !person.getPrincipalName().equalsIgnoreCase( getId() ) ) {
53              person = org.kuali.rice.kim.service.KIMServiceLocator.getPersonService().getPersonByPrincipalName( getId() );
54          }
55          if ( person == null ) {
56              return "";
57          }
58          return person.getName();
59      }
60      
61      
62  }
63