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.approval.dataobject;
017    
018    import edu.sampleu.travel.approval.TravelAuthorizationDocument;
019    import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
020    import org.kuali.rice.krad.util.KRADPropertyConstants;
021    
022    import javax.persistence.Column;
023    import javax.persistence.Entity;
024    import javax.persistence.JoinColumn;
025    import javax.persistence.ManyToOne;
026    import javax.persistence.Table;
027    import java.util.LinkedHashMap;
028    
029    @Entity
030    @Table(name="TRVL_TRANS_MD_DTL_T")
031    public class TransportationModeDetail extends PersistableBusinessObjectBase {
032    
033        private String documentNumber;
034        private String transportationModeCode;
035        private TransportationMode transportationMode;
036        private TravelAuthorizationDocument travelAuthorizationDocument;
037    
038    
039        /**
040         *
041         * This method returns the document number this TransportationModeDetail object is associated with
042         * @return document number
043         */
044        @Column(name="doc_nbr")
045        public String getDocumentNumber() {
046            return documentNumber;
047        }
048    
049        /**
050         *
051         * This method sets the document number this TransportationModeDetail object will be associated with
052         * @param documentNumber
053         */
054        public void setDocumentNumber(String documentNumber) {
055            this.documentNumber = documentNumber;
056        }
057    
058        @Column(name="TRANS_MODE_CD",length=3, nullable=false)
059        public String getTransportationModeCode() {
060            return transportationModeCode;
061        }
062    
063    
064        public void setTransportationModeCode(String transportationModeCode) {
065            this.transportationModeCode = transportationModeCode;
066        }
067    
068        @ManyToOne
069        @JoinColumn(name="TRANS_MODE_CD")
070        public TransportationMode getTransportationMode() {
071            return transportationMode;
072        }
073    
074    
075        public void setTransportationMode(TransportationMode transportationMode) {
076            this.transportationMode = transportationMode;
077        }
078    
079        public TravelAuthorizationDocument getTravelAuthorizationDocument() {
080            return travelAuthorizationDocument;
081        }
082    
083    
084        public void setTravelAuthorizationDocument(TravelAuthorizationDocument travelAuthorizationDocument) {
085            this.travelAuthorizationDocument = travelAuthorizationDocument;
086        }
087    
088    
089        protected LinkedHashMap toStringMapper() {
090            LinkedHashMap m = new LinkedHashMap();
091            m.put(KRADPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
092            m.put("transportationModeCode", this.transportationModeCode);
093            return m;
094        }
095    
096        /**
097         * @see java.lang.Object#equals(java.lang.Object)
098         */
099        @Override
100        public boolean equals(Object obj) {
101            TransportationModeDetail detail = (TransportationModeDetail)obj;
102    
103            if(this.transportationModeCode.equals(detail.getTransportationModeCode()) && this.documentNumber.equals(detail.getDocumentNumber())) {
104                return true;
105            }
106            return false;
107        }
108    
109    }