View Javadoc

1   /*
2    * Copyright 2007-2008 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 edu.sampleu.travel.bo;
17  
18  import org.apache.commons.lang.ObjectUtils;
19  import org.apache.commons.lang.StringUtils;
20  import org.apache.commons.lang.builder.HashCodeBuilder;
21  import org.kuali.rice.core.jpa.annotations.Sequence;
22  import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
23  
24  import javax.persistence.*;
25  import java.util.LinkedHashMap;
26  import java.util.List;
27  
28  
29  /**
30   * FiscalOfficer
31   */
32  @Entity
33  @Table(name="TRV_ACCT_FO")
34  @Sequence(name="seq_acct_fo_id", property="id")
35  public class FiscalOfficer extends PersistableBusinessObjectBase {
36  	
37  	private static final long serialVersionUID = -4645124696676896963L;
38  
39  	@Id
40  	@Column(name="acct_fo_id")
41  	private Long id;
42  	
43  	@Column(name="acct_fo_user_name")
44  	private String userName;
45  	
46  	@Column(name="acct_fo_user_name")
47  	private String firstName;
48  
49  	@OneToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER, mappedBy="fiscalOfficer")
50  	private List<TravelAccount> accounts;
51  
52  	/**
53  	 * @return the firstName
54  	 */
55  	public String getFirstName() {
56  		return this.firstName;
57  	}
58  
59  	/**
60  	 * @param firstName the firstName to set
61  	 */
62  	public void setFirstName(String firstName) {
63  		this.firstName = firstName;
64  	}
65  
66  	public void setUserName(String userId) {
67  		userName = userId;
68  	}
69  
70  	public String getUserName() {
71  		return userName;
72  	}
73  
74  	public final boolean equals(Object o) {
75          if (o == null) return false;
76          if (!(o instanceof FiscalOfficer)) return false;
77          FiscalOfficer f = (FiscalOfficer) o;
78          return StringUtils.equals(userName, f.getUserName()) &&
79                 ObjectUtils.equals(id, f.getId());
80  	}
81  
82  	public int hashCode() {
83      	return new HashCodeBuilder().append(id).append(userName).toHashCode();
84  	}
85  
86  	public Long getId() {
87  		return id;
88  	}
89  
90  	public void setId(Long id) {
91  		this.id = id;
92  	}
93  
94      public List<TravelAccount> getAccounts() {
95          return accounts;
96      }
97  
98      public void setAccounts(List<TravelAccount> accounts) {
99          this.accounts = accounts;
100     }
101     
102     @Override
103     protected LinkedHashMap toStringMapper() {
104         LinkedHashMap propMap = new LinkedHashMap();
105         propMap.put("id", getId());
106         propMap.put("userName", getUserName());
107         return propMap;
108     }
109     
110 }