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