View Javadoc

1   /**
2    * Copyright 2005-2015 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 edu.sampleu.travel.document;
17  
18  import edu.sampleu.travel.bo.TravelAccount;
19  import org.kuali.rice.krad.document.SessionDocument;
20  import org.kuali.rice.krad.document.TransactionalDocumentBase;
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 TravelDocument2 extends TransactionalDocumentBase implements SessionDocument {
30  
31      @Column(name="traveler")
32      private String traveler;
33      @Column(name="org")
34      private String origin;
35      @Column(name="dest")
36      private String destination;
37      @Column(name="request_trav")
38      private String requestType;
39      @Transient
40      private String accountType;
41  
42      @ManyToMany(fetch = FetchType.EAGER)    // Do not use cascade here or it will try to update the TravelAccounts
43      @JoinTable(name="TRAV_DOC_2_ACCOUNTS", 
44  	           joinColumns={@JoinColumn(name="fdoc_nbr", referencedColumnName="fdoc_nbr", unique=false)},         // Goes with this class: TravelDocument2
45  	           inverseJoinColumns={@JoinColumn(name="acct_num", referencedColumnName="acct_num", unique=false)}   // Goes with that class: TravelAccount
46      )
47      private List<TravelAccount> travelAccounts;
48  
49      public TravelDocument2() {
50          travelAccounts = new ArrayList<TravelAccount>();
51      }
52  
53      public String getDestination() {
54          return destination;
55      }
56  
57      public void setDestination(String destination) {
58          this.destination = destination;
59      }
60  
61      public String getOrigin() {
62          return origin;
63      }
64  
65      public void setOrigin(String origin) {
66          this.origin = origin;
67      }
68  
69      public String getTraveler() {
70          return traveler;
71      }
72  
73      public void setTraveler(String traveler) {
74          this.traveler = traveler;
75      }
76  
77      public List<TravelAccount> getTravelAccounts() {
78          return travelAccounts;
79      }
80  
81      public void setTravelAccounts(List<TravelAccount> travelAccounts) {
82          this.travelAccounts = travelAccounts;
83      }
84  
85      public TravelAccount getTravelAccount(int index) {
86          while(travelAccounts.size() - 1 < index) {
87              travelAccounts.add(new TravelAccount());
88          }
89          return travelAccounts.get(index);
90      }
91  
92      public String getRequestType() {
93          return requestType;
94      }
95  
96      public void setRequestType(String requestType) {
97          this.requestType = requestType;
98      }
99  
100     /**
101      * @param accountType the accountType to set
102      */
103     public void setAccountType(String accountType) {
104         this.accountType = accountType;
105     }
106 
107     /**
108      * @return the accountType
109      */
110     public String getAccountType() {
111         return accountType;
112     }
113 
114 }