001 /*
002 * Copyright 2007-2008 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 */
016 package edu.sampleu.travel.bo;
017
018 import org.apache.commons.lang.ObjectUtils;
019 import org.apache.commons.lang.StringUtils;
020 import org.apache.commons.lang.builder.HashCodeBuilder;
021 import org.kuali.rice.core.jpa.annotations.Sequence;
022 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
023
024 import javax.persistence.*;
025 import java.util.LinkedHashMap;
026 import java.util.List;
027
028
029 /**
030 * FiscalOfficer
031 */
032 @Entity
033 @Table(name="TRV_ACCT_FO")
034 @Sequence(name="seq_acct_fo_id", property="id")
035 public class FiscalOfficer extends PersistableBusinessObjectBase {
036
037 private static final long serialVersionUID = -4645124696676896963L;
038
039 @Id
040 @Column(name="acct_fo_id")
041 private Long id;
042
043 @Column(name="acct_fo_user_name")
044 private String userName;
045
046 @Column(name="acct_fo_user_name")
047 private String firstName;
048
049 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.EAGER, mappedBy="fiscalOfficer")
050 private List<TravelAccount> accounts;
051
052 /**
053 * @return the firstName
054 */
055 public String getFirstName() {
056 return this.firstName;
057 }
058
059 /**
060 * @param firstName the firstName to set
061 */
062 public void setFirstName(String firstName) {
063 this.firstName = firstName;
064 }
065
066 public void setUserName(String userId) {
067 userName = userId;
068 }
069
070 public String getUserName() {
071 return userName;
072 }
073
074 public final boolean equals(Object o) {
075 if (o == null) return false;
076 if (!(o instanceof FiscalOfficer)) return false;
077 FiscalOfficer f = (FiscalOfficer) o;
078 return StringUtils.equals(userName, f.getUserName()) &&
079 ObjectUtils.equals(id, f.getId());
080 }
081
082 public int hashCode() {
083 return new HashCodeBuilder().append(id).append(userName).toHashCode();
084 }
085
086 public Long getId() {
087 return id;
088 }
089
090 public void setId(Long id) {
091 this.id = id;
092 }
093
094 public List<TravelAccount> getAccounts() {
095 return accounts;
096 }
097
098 public void setAccounts(List<TravelAccount> accounts) {
099 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 }