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     */
016    package edu.sampleu.travel.dataobject;
017    
018    import java.util.ArrayList;
019    import java.util.Date;
020    import java.util.List;
021    
022    import javax.persistence.AssociationOverride;
023    import javax.persistence.AssociationOverrides;
024    import javax.persistence.AttributeOverride;
025    import javax.persistence.AttributeOverrides;
026    import javax.persistence.CascadeType;
027    import javax.persistence.Column;
028    import javax.persistence.Convert;
029    import javax.persistence.Entity;
030    import javax.persistence.FetchType;
031    import javax.persistence.JoinColumn;
032    import javax.persistence.OneToMany;
033    import javax.persistence.Table;
034    import javax.persistence.Temporal;
035    import javax.persistence.TemporalType;
036    import javax.persistence.Transient;
037    
038    import edu.sampleu.travel.dataobject.TravelDestination;
039    import edu.sampleu.travel.dataobject.TravelExpenseItem;
040    import edu.sampleu.travel.dataobject.TravelPerDiemExpense;
041    import edu.sampleu.travel.dataobject.TravelerDetail;
042    import edu.sampleu.travel.options.TripTypeKeyValuesFinder;
043    import org.kuali.rice.core.api.util.type.KualiDecimal;
044    import org.kuali.rice.krad.data.jpa.converters.KualiDecimalConverter;
045    import org.kuali.rice.krad.data.provider.annotation.Description;
046    import org.kuali.rice.krad.data.provider.annotation.KeyValuesFinderClass;
047    import org.kuali.rice.krad.data.provider.annotation.Label;
048    import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType;
049    import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews;
050    import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
051    import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
052    import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
053    import org.kuali.rice.krad.document.TransactionalDocumentBase;
054    
055    
056    /**
057     * Travel authorization transactional document.
058     *
059     * <p>
060     *  This is a sample KRAD transactional document that demonstrates how
061     *  to implement transactional documents within the KRAD UIF.
062     * </p>
063     *
064     * @author Kuali Rice Team (rice.collab@kuali.org)
065     */
066    @Entity
067    @Table(name = "TRVL_AUTH_DOC_T")
068    @AttributeOverrides({
069        @AttributeOverride(name="documentNumber",
070                           column=@Column(name="TRVL_AUTH_DOC_ID",insertable=true,updatable=true,length=14))
071    })
072    @AssociationOverrides({
073            @AssociationOverride(name="pessimisticLocks",
074                             joinColumns= {@JoinColumn(name = "TRVL_AUTH_DOC_ID", insertable = false, updatable = false)})
075    })
076    @UifAutoCreateViews({UifAutoCreateViewType.INQUIRY, UifAutoCreateViewType.LOOKUP})
077    public class TravelAuthorizationDocument extends TransactionalDocumentBase {
078            private static final long serialVersionUID = -6609385831976630737L;
079    
080        // trip begin date
081        @Temporal(TemporalType.DATE)
082            @Column(name="TRVL_BGN_DT")
083        @Label("Trip Begin Date")
084        private Date tripBegin;
085    
086        // trip end date
087        @Temporal(TemporalType.DATE)
088            @Column(name="TRVL_END_DT")
089        @Label("Trip End Date")
090        private Date tripEnd;
091    
092        // travel description
093            @Column(name="TRVL_DESC",length=255)
094            @Label("Business Purpose")
095            private String tripDescription;
096    
097        // travel destination
098        @Column(name="TRVL_DEST_ID",length=40)
099        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    }