View Javadoc
1   /**
2    * Copyright 2005-2014 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  * This is a test copy of AccountRequestDocument that has been modified to allow for custom lock descriptors.
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  
50  	@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
51  	@JoinColumn(name="fdoc_nbr",insertable=false,updatable=false)
52      private AccountRequestDocumentWithCyclicalReference parent;
53      
54      @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST})
55  	@JoinTable(
56  			name="TRAV_DOC_2_ACCOUNTS",
57  			joinColumns=@JoinColumn(name="DOC_HDR_ID", referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false),
58  			inverseJoinColumns=@JoinColumn(name="ACCT_NUM", referencedColumnName="ACCT_NUM",insertable=false,updatable=false)
59  				)
60      private List<Account> accounts;
61  
62      public AccountRequestDocumentWithCyclicalReference() {
63          accounts = new ArrayList<Account>();
64      }
65  
66      public String getReason2() {
67          return reason2;
68      }
69  
70      public void setReason2(String reason2) {
71          this.reason2 = reason2;
72      }
73  
74      public String getReason1() {
75          return reason1;
76      }
77  
78      public void setReason1(String reason1) {
79          this.reason1 = reason1;
80      }
81  
82      public String getRequester() {
83          return requester;
84      }
85  
86      public void setRequester(String requester) {
87          this.requester = requester;
88      }
89  
90      public List<Account> getAccounts() {
91          return accounts;
92      }
93  
94      public void setAccounts(List<Account> accounts) {
95          this.accounts = accounts;
96      }
97  
98      public Account getAccount(int index) {
99          while(accounts.size() - 1 < index) {
100             accounts.add(new Account());
101         }
102         return accounts.get(index);
103     }
104 
105     public String getRequestType() {
106         return requestType;
107     }
108 
109     public void setRequestType(String requestType) {
110         this.requestType = requestType;
111     }
112 
113     public void setAccountTypeCode(String accountType) {
114         this.accountTypeCode = accountType;
115     }
116 
117     public String getAccountTypeCode() {
118         return accountTypeCode;
119     }
120 
121 	public AccountRequestDocumentWithCyclicalReference getChild() {
122 		return this.child;
123 	}
124 
125 	public void setChild(AccountRequestDocumentWithCyclicalReference child) {
126 		this.child = child;
127 	}
128 
129 	public AccountRequestDocumentWithCyclicalReference getParent() {
130 		return this.parent;
131 	}
132 
133 	public void setParent(AccountRequestDocumentWithCyclicalReference parent) {
134 		this.parent = parent;
135 	}
136 
137 }