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 edu.sampleu.travel.dataobject;
17  
18  import java.util.ArrayList;
19  import java.util.Date;
20  import java.util.List;
21  
22  import javax.persistence.AssociationOverride;
23  import javax.persistence.AssociationOverrides;
24  import javax.persistence.AttributeOverride;
25  import javax.persistence.AttributeOverrides;
26  import javax.persistence.CascadeType;
27  import javax.persistence.Column;
28  import javax.persistence.Convert;
29  import javax.persistence.Entity;
30  import javax.persistence.FetchType;
31  import javax.persistence.JoinColumn;
32  import javax.persistence.OneToMany;
33  import javax.persistence.Table;
34  import javax.persistence.Temporal;
35  import javax.persistence.TemporalType;
36  import javax.persistence.Transient;
37  
38  import edu.sampleu.travel.dataobject.TravelDestination;
39  import edu.sampleu.travel.dataobject.TravelExpenseItem;
40  import edu.sampleu.travel.dataobject.TravelPerDiemExpense;
41  import edu.sampleu.travel.dataobject.TravelerDetail;
42  import edu.sampleu.travel.options.TripTypeKeyValuesFinder;
43  import org.kuali.rice.core.api.util.type.KualiDecimal;
44  import org.kuali.rice.krad.data.jpa.converters.KualiDecimalConverter;
45  import org.kuali.rice.krad.data.provider.annotation.Description;
46  import org.kuali.rice.krad.data.provider.annotation.KeyValuesFinderClass;
47  import org.kuali.rice.krad.data.provider.annotation.Label;
48  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
49  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
50  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
51  import org.kuali.rice.krad.document.TransactionalDocumentBase;
52  
53  
54  /**
55   * Travel authorization transactional document.
56   *
57   * <p>
58   *  This is a sample KRAD transactional document that demonstrates how
59   *  to implement transactional documents within the KRAD UIF.
60   * </p>
61   *
62   * @author Kuali Rice Team (rice.collab@kuali.org)
63   */
64  @Entity
65  @Table(name = "TRVL_AUTH_DOC_T")
66  @AttributeOverrides({
67      @AttributeOverride(name="documentNumber",
68                         column=@Column(name="TRVL_AUTH_DOC_ID",insertable=true,updatable=true,length=14))
69  })
70  @AssociationOverrides({
71  	@AssociationOverride(name="pessimisticLocks",
72                           joinColumns= {@JoinColumn(name = "TRVL_AUTH_DOC_ID", insertable = false, updatable = false)})
73  })
74  public class TravelAuthorizationDocument extends TransactionalDocumentBase {
75  	private static final long serialVersionUID = -6609385831976630737L;
76  
77      // trip begin date
78      @Temporal(TemporalType.DATE)
79  	@Column(name="TRVL_BGN_DT")
80      @Label("Trip Begin Date")
81      private Date tripBegin;
82  
83      // trip end date
84      @Temporal(TemporalType.DATE)
85  	@Column(name="TRVL_END_DT")
86      @Label("Trip End Date")
87      private Date tripEnd;
88  
89      // travel description
90  	@Column(name="TRVL_DESC",length=255)
91  	@Label("Business Purpose")
92  	private String tripDescription;
93  
94      // travel destination
95      @Column(name="TRVL_DEST_ID",length=40)
96      private String tripDestinationId;
97      @Transient
98      private TravelDestination tripDestination;
99  
100     // traveler
101 	@Column(name="TRAVELER_DTL_ID",length=40)
102     private String travelerDetailId;
103 	@Transient
104     private TravelerDetail travelerDetail;
105 
106     // travel type code
107     @Column(name = "TRVL_TYP_CD", length = 40)
108     @Label("Travel type code")
109     @Description("Trip Type")
110     @KeyValuesFinderClass(TripTypeKeyValuesFinder.class)
111     @UifDisplayHints({
112             @UifDisplayHint(UifDisplayHintType.DROPDOWN),
113             @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)})
114     private String travelTypeCode;
115 
116     // expense limit
117 	@Column(name="EXP_LMT",length=19,precision=2)
118 	@Label("Expense Limit")
119     @Convert(converter=KualiDecimalConverter.class)
120 	@Description("Expense limit imposed by department or grant or some other budgetary restrictions on trip.")
121     private KualiDecimal expenseLimit;
122 
123     // contact number
124 	@Column(name="CELL_PH_NUM",length=20)
125 	@Label("Contact Number")
126     @Description("This is the contact phone number during the trip.")
127     private String cellPhoneNumber;
128 
129     @OneToMany(fetch= FetchType.EAGER, orphanRemoval=true, cascade= {CascadeType.ALL})
130     @JoinColumn(name = "TRVL_AUTH_DOC_ID", insertable = true, updatable = true)
131     private List<TravelPerDiemExpense> dailyExpenseEstimates = new ArrayList<TravelPerDiemExpense>();
132 
133     @OneToMany(fetch= FetchType.EAGER, orphanRemoval=true, cascade= {CascadeType.ALL})
134     @JoinColumn(name = "TRVL_AUTH_DOC_ID", insertable = true, updatable = true)
135     private List<TravelExpenseItem> actualExpenseItems = new ArrayList<TravelExpenseItem>();
136 
137     public Date getTripBegin() {
138         return tripBegin;
139     }
140 
141     public void setTripBegin(Date tripBegin) {
142         this.tripBegin = tripBegin;
143     }
144 
145     public Date getTripEnd() {
146         return tripEnd;
147     }
148 
149     public void setTripEnd(Date tripEnd) {
150         this.tripEnd = tripEnd;
151     }
152 
153     public String getTripDescription() {
154         return tripDescription;
155     }
156 
157     public void setTripDescription(String tripDescription) {
158         this.tripDescription = tripDescription;
159     }
160 
161     public String getTravelerDetailId() {
162         return travelerDetailId;
163     }
164 
165     public void setTravelerDetailId(String travelerDetailId) {
166         this.travelerDetailId = travelerDetailId;
167     }
168 
169     public TravelerDetail getTravelerDetail() {
170         return travelerDetail;
171     }
172 
173     public void setTravelerDetail(TravelerDetail travelerDetail) {
174         this.travelerDetail = travelerDetail;
175     }
176 
177     public String getCellPhoneNumber() {
178         return cellPhoneNumber;
179     }
180 
181     public void setCellPhoneNumber(String cellPhoneNumber) {
182         this.cellPhoneNumber = cellPhoneNumber;
183     }
184 
185     public KualiDecimal getExpenseLimit() {
186         return expenseLimit;
187     }
188 
189     public void setExpenseLimit(KualiDecimal expenseLimit) {
190         this.expenseLimit = expenseLimit;
191     }
192 
193     public String getTripDestinationId() {
194         return tripDestinationId;
195     }
196 
197     public void setTripDestinationId(String tripDestinationId) {
198         this.tripDestinationId = tripDestinationId;
199     }
200 
201     public TravelDestination getTripDestination() {
202         return tripDestination;
203     }
204 
205     public void setTripDestination(TravelDestination tripDestination) {
206         this.tripDestination = tripDestination;
207     }
208 
209     public List<TravelPerDiemExpense> getDailyExpenseEstimates() {
210         return dailyExpenseEstimates;
211     }
212 
213     public void setDailyExpenseEstimates(List<TravelPerDiemExpense> dailyExpenseEstimates) {
214         this.dailyExpenseEstimates = dailyExpenseEstimates;
215     }
216 
217     public List<TravelExpenseItem> getActualExpenseItems() {
218         return actualExpenseItems;
219     }
220 
221     public void setActualExpenseItems(List<TravelExpenseItem> actualExpenseItems) {
222         this.actualExpenseItems = actualExpenseItems;
223     }
224 
225     public String getTravelTypeCode() {
226         return travelTypeCode;
227     }
228 
229     public void setTravelTypeCode(String travelTypeCode) {
230         this.travelTypeCode = travelTypeCode;
231     }
232 }