1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
28
29
30
31 @Entity
32 @Table(name="TRV_DOC_2")
33 public class AccountRequestDocumentWithCyclicalReference extends TransactionalDocumentBase implements SessionDocument {
34
35 @Column(name="traveler")
36 private String requester;
37 @Column(name= "org")
38 private String reason1;
39 @Column(name="dest")
40 private String reason2;
41 @Column(name="request_trav")
42 private String requestType;
43 @Transient
44 private String accountTypeCode;
45
46 @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
47 @JoinColumn(name="fdoc_nbr",insertable=false,updatable=false)
48 private AccountRequestDocumentWithCyclicalReference child;
49 @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
50 @JoinColumn(name="fdoc_nbr",insertable=false,updatable=false)
51 private AccountRequestDocumentWithCyclicalReference parent;
52
53 @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST})
54 @JoinTable(
55 name="TRAV_DOC_2_ACCOUNTS",
56 joinColumns=@JoinColumn(name="DOC_HDR_ID", referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false),
57 inverseJoinColumns=@JoinColumn(name="ACCT_NUM", referencedColumnName="ACCT_NUM",insertable=false,updatable=false)
58 )
59 private List<Account> accounts;
60
61 public AccountRequestDocumentWithCyclicalReference() {
62 accounts = new ArrayList<Account>();
63 }
64
65 public String getReason2() {
66 return reason2;
67 }
68
69 public void setReason2(String reason2) {
70 this.reason2 = reason2;
71 }
72
73 public String getReason1() {
74 return reason1;
75 }
76
77 public void setReason1(String reason1) {
78 this.reason1 = reason1;
79 }
80
81 public String getRequester() {
82 return requester;
83 }
84
85 public void setRequester(String requester) {
86 this.requester = requester;
87 }
88
89 public List<Account> getAccounts() {
90 return accounts;
91 }
92
93 public void setAccounts(List<Account> accounts) {
94 this.accounts = accounts;
95 }
96
97 public Account getAccount(int index) {
98 while(accounts.size() - 1 < index) {
99 accounts.add(new Account());
100 }
101 return accounts.get(index);
102 }
103
104 public String getRequestType() {
105 return requestType;
106 }
107
108 public void setRequestType(String requestType) {
109 this.requestType = requestType;
110 }
111
112 public void setAccountTypeCode(String accountType) {
113 this.accountTypeCode = accountType;
114 }
115
116 public String getAccountTypeCode() {
117 return accountTypeCode;
118 }
119
120 public AccountRequestDocumentWithCyclicalReference getChild() {
121 return this.child;
122 }
123
124 public void setChild(AccountRequestDocumentWithCyclicalReference child) {
125 this.child = child;
126 }
127
128 public AccountRequestDocumentWithCyclicalReference getParent() {
129 return this.parent;
130 }
131
132 public void setParent(AccountRequestDocumentWithCyclicalReference parent) {
133 this.parent = parent;
134 }
135
136 }