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 | 0 | public TravelDocument2() { |
60 | 0 | travelAccounts = new ArrayList<TravelAccount>(); |
61 | 0 | } |
62 | |
|
63 | |
@Override |
64 | |
protected LinkedHashMap toStringMapper() { |
65 | 0 | LinkedHashMap<String, String> meMap = new LinkedHashMap<String, String>(); |
66 | 0 | meMap.put("traveler", getTraveler()); |
67 | 0 | meMap.put("origin", getOrigin()); |
68 | 0 | meMap.put("destination", getDestination()); |
69 | 0 | return meMap; |
70 | |
} |
71 | |
|
72 | |
public String getDestination() { |
73 | 0 | return destination; |
74 | |
} |
75 | |
|
76 | |
public void setDestination(String destination) { |
77 | 0 | this.destination = destination; |
78 | 0 | } |
79 | |
|
80 | |
public String getOrigin() { |
81 | 0 | return origin; |
82 | |
} |
83 | |
|
84 | |
public void setOrigin(String origin) { |
85 | 0 | this.origin = origin; |
86 | 0 | } |
87 | |
|
88 | |
public String getTraveler() { |
89 | 0 | return traveler; |
90 | |
} |
91 | |
|
92 | |
public void setTraveler(String traveler) { |
93 | 0 | this.traveler = traveler; |
94 | 0 | } |
95 | |
|
96 | |
public List<TravelAccount> getTravelAccounts() { |
97 | 0 | return travelAccounts; |
98 | |
} |
99 | |
|
100 | |
public void setTravelAccounts(List<TravelAccount> travelAccounts) { |
101 | 0 | this.travelAccounts = travelAccounts; |
102 | 0 | } |
103 | |
|
104 | |
public TravelAccount getTravelAccount(int index) { |
105 | 0 | while(travelAccounts.size() - 1 < index) { |
106 | 0 | travelAccounts.add(new TravelAccount()); |
107 | |
} |
108 | 0 | return travelAccounts.get(index); |
109 | |
} |
110 | |
|
111 | |
public String getRequestType() { |
112 | 0 | return requestType; |
113 | |
} |
114 | |
|
115 | |
public void setRequestType(String requestType) { |
116 | 0 | this.requestType = requestType; |
117 | 0 | } |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public void setAccountType(String accountType) { |
123 | 0 | this.accountType = accountType; |
124 | 0 | } |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public String getAccountType() { |
130 | 0 | return accountType; |
131 | |
} |
132 | |
|
133 | |
} |