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