001/**
002 * Copyright 2005-2014 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 */
016package org.kuali.rice.krad.test.document;
017
018import org.kuali.rice.krad.document.SessionDocument;
019import org.kuali.rice.krad.document.TransactionalDocumentBase;
020import org.kuali.rice.krad.test.document.bo.Account;
021
022import javax.persistence.*;
023import java.util.ArrayList;
024import 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")
033public 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
050        @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
051        @JoinColumn(name="fdoc_nbr",insertable=false,updatable=false)
052    private AccountRequestDocumentWithCyclicalReference parent;
053    
054    @ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST})
055        @JoinTable(
056                        name="TRAV_DOC_2_ACCOUNTS",
057                        joinColumns=@JoinColumn(name="DOC_HDR_ID", referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false),
058                        inverseJoinColumns=@JoinColumn(name="ACCT_NUM", referencedColumnName="ACCT_NUM",insertable=false,updatable=false)
059                                )
060    private List<Account> accounts;
061
062    public AccountRequestDocumentWithCyclicalReference() {
063        accounts = new ArrayList<Account>();
064    }
065
066    public String getReason2() {
067        return reason2;
068    }
069
070    public void setReason2(String reason2) {
071        this.reason2 = reason2;
072    }
073
074    public String getReason1() {
075        return reason1;
076    }
077
078    public void setReason1(String reason1) {
079        this.reason1 = reason1;
080    }
081
082    public String getRequester() {
083        return requester;
084    }
085
086    public void setRequester(String requester) {
087        this.requester = requester;
088    }
089
090    public List<Account> getAccounts() {
091        return accounts;
092    }
093
094    public void setAccounts(List<Account> accounts) {
095        this.accounts = accounts;
096    }
097
098    public Account getAccount(int index) {
099        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}