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