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