1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.travel.document;
17
18 import java.util.ArrayList;
19 import java.util.LinkedHashMap;
20 import java.util.List;
21
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.FetchType;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.JoinTable;
27 import javax.persistence.ManyToMany;
28 import javax.persistence.Table;
29 import javax.persistence.Transient;
30
31 import org.kuali.rice.kns.document.SessionDocument;
32 import org.kuali.rice.kns.document.TransactionalDocumentBase;
33
34 import edu.sampleu.travel.bo.TravelAccount;
35
36
37 @Entity
38 @Table(name="TRV_DOC_2")
39 public class TravelDocument2 extends TransactionalDocumentBase implements SessionDocument {
40
41 @Column(name="traveler")
42 private String traveler;
43 @Column(name="org")
44 private String origin;
45 @Column(name="dest")
46 private String destination;
47 @Column(name="request_trav")
48 private String requestType;
49 @Transient
50 private String accountType;
51
52 @ManyToMany(fetch = FetchType.EAGER)
53 @JoinTable(name="TRAV_DOC_2_ACCOUNTS",
54 joinColumns={@JoinColumn(name="fdoc_nbr", referencedColumnName="fdoc_nbr", unique=false)},
55 inverseJoinColumns={@JoinColumn(name="acct_num", referencedColumnName="acct_num", unique=false)}
56 )
57 private List<TravelAccount> travelAccounts;
58
59 public TravelDocument2() {
60 travelAccounts = new ArrayList<TravelAccount>();
61 }
62
63 @Override
64 protected LinkedHashMap toStringMapper() {
65 LinkedHashMap<String, String> meMap = new LinkedHashMap<String, String>();
66 meMap.put("traveler", getTraveler());
67 meMap.put("origin", getOrigin());
68 meMap.put("destination", getDestination());
69 return meMap;
70 }
71
72 public String getDestination() {
73 return destination;
74 }
75
76 public void setDestination(String destination) {
77 this.destination = destination;
78 }
79
80 public String getOrigin() {
81 return origin;
82 }
83
84 public void setOrigin(String origin) {
85 this.origin = origin;
86 }
87
88 public String getTraveler() {
89 return traveler;
90 }
91
92 public void setTraveler(String traveler) {
93 this.traveler = traveler;
94 }
95
96 public List<TravelAccount> getTravelAccounts() {
97 return travelAccounts;
98 }
99
100 public void setTravelAccounts(List<TravelAccount> travelAccounts) {
101 this.travelAccounts = travelAccounts;
102 }
103
104 public TravelAccount getTravelAccount(int index) {
105 while(travelAccounts.size() - 1 < index) {
106 travelAccounts.add(new TravelAccount());
107 }
108 return travelAccounts.get(index);
109 }
110
111 public String getRequestType() {
112 return requestType;
113 }
114
115 public void setRequestType(String requestType) {
116 this.requestType = requestType;
117 }
118
119
120
121
122 public void setAccountType(String accountType) {
123 this.accountType = accountType;
124 }
125
126
127
128
129 public String getAccountType() {
130 return accountType;
131 }
132
133 }