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