001    /**
002     * Copyright 2005-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.test.document;
017    
018    import org.kuali.rice.krad.document.SessionDocument;
019    import org.kuali.rice.krad.document.TransactionalDocumentBase;
020    import org.kuali.rice.krad.test.document.bo.Account;
021    
022    import javax.persistence.*;
023    import java.util.ArrayList;
024    import java.util.List;
025    
026    /*
027    * This is a test copy of AccountRequestDocument that has been modified to allow for custom lock descriptors.
028    * 
029    */
030    
031    @Entity
032    @Table(name="TRV_DOC_2")
033    public class AccountRequestDocumentWithCyclicalReference extends TransactionalDocumentBase implements SessionDocument {
034    
035            @Column(name="traveler")
036        private String requester;
037            @Column(name= "org")
038        private String reason1;
039            @Column(name="dest")
040        private String reason2;
041            @Column(name="request_trav")
042        private String requestType;
043            @Transient
044        private String accountTypeCode;
045    
046            @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
047            @JoinColumn(name="fdoc_nbr",insertable=false,updatable=false)
048        private AccountRequestDocumentWithCyclicalReference child;
049            @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
050            @JoinColumn(name="fdoc_nbr",insertable=false,updatable=false)
051        private AccountRequestDocumentWithCyclicalReference parent;
052        
053        @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST})
054            @JoinTable(
055                            name="TRAV_DOC_2_ACCOUNTS",
056                            joinColumns=@JoinColumn(name="DOC_HDR_ID", referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false),
057                            inverseJoinColumns=@JoinColumn(name="ACCT_NUM", referencedColumnName="ACCT_NUM",insertable=false,updatable=false)
058                                    )
059        private List<Account> accounts;
060    
061        public AccountRequestDocumentWithCyclicalReference() {
062            accounts = new ArrayList<Account>();
063        }
064    
065        public String getReason2() {
066            return reason2;
067        }
068    
069        public void setReason2(String reason2) {
070            this.reason2 = reason2;
071        }
072    
073        public String getReason1() {
074            return reason1;
075        }
076    
077        public void setReason1(String reason1) {
078            this.reason1 = reason1;
079        }
080    
081        public String getRequester() {
082            return requester;
083        }
084    
085        public void setRequester(String requester) {
086            this.requester = requester;
087        }
088    
089        public List<Account> getAccounts() {
090            return accounts;
091        }
092    
093        public void setAccounts(List<Account> accounts) {
094            this.accounts = accounts;
095        }
096    
097        public Account getAccount(int index) {
098            while(accounts.size() - 1 < index) {
099                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    }