001 /** 002 * Copyright 2005-2011 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 org.kuali.rice.krad.test.document; 017 018 import org.kuali.rice.krad.document.SessionDocument; 019 import org.kuali.rice.krad.document.TransactionalDocumentBase; 020 import org.kuali.rice.krad.test.document.bo.Account; 021 022 import javax.persistence.*; 023 import java.util.ArrayList; 024 import java.util.List; 025 026 027 @Entity 028 @Table(name="TRV_DOC_2") 029 public class AccountRequestDocument extends TransactionalDocumentBase implements SessionDocument { 030 031 @Column(name="traveler") 032 private String requester; 033 @Column(name="org") 034 private String reason1; 035 @Column(name="dest") 036 private String reason2; 037 @Column(name="request_trav") 038 private String requestType; 039 @Transient 040 private String accountTypeCode; 041 042 @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST}) 043 @JoinTable( 044 name="TRAV_DOC_2_ACCOUNTS", 045 joinColumns=@JoinColumn(name="DOC_HDR_ID", referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false), 046 inverseJoinColumns=@JoinColumn(name="ACCT_NUM", referencedColumnName="ACCT_NUM",insertable=false,updatable=false) 047 ) 048 private List<Account> accounts; 049 050 public AccountRequestDocument() { 051 accounts = new ArrayList<Account>(); 052 } 053 054 public String getReason2() { 055 return reason2; 056 } 057 058 public void setReason2(String reason2) { 059 this.reason2 = reason2; 060 } 061 062 public String getReason1() { 063 return reason1; 064 } 065 066 public void setReason1(String reason1) { 067 this.reason1 = reason1; 068 } 069 070 public String getRequester() { 071 return requester; 072 } 073 074 public void setRequester(String requester) { 075 this.requester = requester; 076 } 077 078 public List<Account> getAccounts() { 079 return accounts; 080 } 081 082 public void setAccounts(List<Account> accounts) { 083 this.accounts = accounts; 084 } 085 086 public Account getAccount(int index) { 087 while(accounts.size() - 1 < index) { 088 accounts.add(new Account()); 089 } 090 return accounts.get(index); 091 } 092 093 public String getRequestType() { 094 return requestType; 095 } 096 097 public void setRequestType(String requestType) { 098 this.requestType = requestType; 099 } 100 101 public void setAccountTypeCode(String accountType) { 102 this.accountTypeCode = accountType; 103 } 104 105 public String getAccountTypeCode() { 106 return accountTypeCode; 107 } 108 109 }