View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.test.document;
17  
18  import org.kuali.rice.krad.document.SessionDocument;
19  import org.kuali.rice.krad.document.TransactionalDocumentBase;
20  import org.kuali.rice.krad.test.document.bo.Account;
21  
22  import javax.persistence.*;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  
27  @Entity
28  @Table(name="TRV_DOC_2")
29  public class AccountRequestDocument extends TransactionalDocumentBase implements SessionDocument {
30  
31  	@Column(name="traveler")
32      private String requester;
33  	@Column(name= "org")
34      private String reason1;
35  	@Column(name="dest")
36      private String reason2;
37  	@Column(name="request_trav")
38      private String requestType;
39  	@Transient
40      private String accountTypeCode;
41  
42  	@ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST})
43  	@JoinTable(
44  			name="TRAV_DOC_2_ACCOUNTS",
45  			joinColumns=@JoinColumn(name="DOC_HDR_ID", referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false),
46  			inverseJoinColumns=@JoinColumn(name="ACCT_NUM", referencedColumnName="ACCT_NUM",insertable=false,updatable=false)
47  				)
48      private List<Account> accounts;
49  
50      public AccountRequestDocument() {
51          accounts = new ArrayList<Account>();
52      }
53  
54      public String getReason2() {
55          return reason2;
56      }
57  
58      public void setReason2(String reason2) {
59          this.reason2 = reason2;
60      }
61  
62      public String getReason1() {
63          return reason1;
64      }
65  
66      public void setReason1(String reason1) {
67          this.reason1 = reason1;
68      }
69  
70      public String getRequester() {
71          return requester;
72      }
73  
74      public void setRequester(String requester) {
75          this.requester = requester;
76      }
77  
78      public List<Account> getAccounts() {
79          return accounts;
80      }
81  
82      public void setAccounts(List<Account> accounts) {
83          this.accounts = accounts;
84      }
85  
86      public Account getAccount(int index) {
87          while(accounts.size() - 1 < index) {
88              accounts.add(new Account());
89          }
90          return accounts.get(index);
91      }
92  
93      public String getRequestType() {
94          return requestType;
95      }
96  
97      public void setRequestType(String requestType) {
98          this.requestType = requestType;
99      }
100 
101     public void setAccountTypeCode(String accountType) {
102         this.accountTypeCode = accountType;
103     }
104 
105     public String getAccountTypeCode() {
106         return accountTypeCode;
107     }
108 
109 }