001 /** 002 * Copyright 2005-2013 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.UifDisplayHint; 049 import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType; 050 import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints; 051 import org.kuali.rice.krad.document.TransactionalDocumentBase; 052 053 054 /** 055 * Travel authorization transactional document. 056 * 057 * <p> 058 * This is a sample KRAD transactional document that demonstrates how 059 * to implement transactional documents within the KRAD UIF. 060 * </p> 061 * 062 * @author Kuali Rice Team (rice.collab@kuali.org) 063 */ 064 @Entity 065 @Table(name = "TRVL_AUTH_DOC_T") 066 @AttributeOverrides({ 067 @AttributeOverride(name="documentNumber", 068 column=@Column(name="TRVL_AUTH_DOC_ID",insertable=true,updatable=true,length=14)) 069 }) 070 @AssociationOverrides({ 071 @AssociationOverride(name="pessimisticLocks", 072 joinColumns= {@JoinColumn(name = "TRVL_AUTH_DOC_ID", insertable = false, updatable = false)}) 073 }) 074 public class TravelAuthorizationDocument extends TransactionalDocumentBase { 075 private static final long serialVersionUID = -6609385831976630737L; 076 077 // trip begin date 078 @Temporal(TemporalType.DATE) 079 @Column(name="TRVL_BGN_DT") 080 @Label("Trip Begin Date") 081 private Date tripBegin; 082 083 // trip end date 084 @Temporal(TemporalType.DATE) 085 @Column(name="TRVL_END_DT") 086 @Label("Trip End Date") 087 private Date tripEnd; 088 089 // travel description 090 @Column(name="TRVL_DESC",length=255) 091 @Label("Business Purpose") 092 private String tripDescription; 093 094 // travel destination 095 @Column(name="TRVL_DEST_ID",length=40) 096 private String tripDestinationId; 097 @Transient 098 private TravelDestination tripDestination; 099 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 }