001/**
002 * Copyright 2005-2014 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 org.kuali.rice.krad.test.document.bo;
017
018import java.util.List;
019
020import javax.persistence.CascadeType;
021import javax.persistence.Column;
022import javax.persistence.Entity;
023import javax.persistence.FetchType;
024import javax.persistence.GeneratedValue;
025import javax.persistence.Id;
026import javax.persistence.JoinColumn;
027import javax.persistence.OneToMany;
028import javax.persistence.Table;
029import javax.persistence.Transient;
030
031import org.apache.commons.lang.ObjectUtils;
032import org.apache.commons.lang.StringUtils;
033import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
034
035
036/**
037 * FiscalOfficer
038 */
039@Entity
040@Table(name="TRV_ACCT_FO")
041public class AccountManager extends PersistableBusinessObjectBase {
042        private static final long serialVersionUID = 1555425302284842267L;
043
044    @Column(name="acct_fo_user_name")
045        private String userName;
046        @Id
047        @GeneratedValue(generator="TRV_FO_ID_S")
048        @Column(name="acct_fo_id")
049        private Long amId;
050        @Transient
051        private String defaultType;
052        @OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
053        @JoinColumn(name="acct_fo_id",referencedColumnName="acct_fo_id",insertable=false,updatable=false)
054        private List<Account> accounts;
055
056    public AccountManager() {}
057
058
059
060        public AccountManager(Long amId, String userName) {
061        super();
062        this.amId = amId;
063        this.userName = userName;
064    }
065
066    public void setUserName(String userId) {
067                userName = userId;
068        }
069
070        public String getUserName() {
071                return userName;
072        }
073
074        public String getDefaultType() {
075        return this.defaultType;
076    }
077
078    public void setDefaultType(String defaultType) {
079        this.defaultType = defaultType;
080    }
081
082    @Override
083    public final boolean equals(Object o) {
084        if (o == null) return false;
085        if (!(o instanceof AccountManager)) return false;
086        AccountManager am = (AccountManager) o;
087        return StringUtils.equals(userName, am.getUserName()) &&
088               ObjectUtils.equals(amId, am.getAmId());
089        }
090
091        public Long getAmId() {
092                return amId;
093        }
094
095        public void setAmId(Long id) {
096                this.amId = id;
097        }
098
099    public List<Account> getAccounts() {
100        return accounts;
101    }
102
103    public void setAccounts(List<Account> accounts) {
104        this.accounts = accounts;
105    }
106}