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 edu.sampleu.travel.options.PostalCountryCode;
019    import edu.sampleu.travel.options.PostalCountryCodeKeyValuesFinder;
020    import edu.sampleu.travel.options.PostalStateCode;
021    import edu.sampleu.travel.options.PostalStateCodeKeyValuesFinder;
022    import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
023    import org.kuali.rice.krad.bo.DataObjectBase;
024    import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
025    import org.kuali.rice.krad.data.jpa.eclipselink.PortableSequenceGenerator;
026    import org.kuali.rice.krad.data.provider.annotation.Description;
027    import org.kuali.rice.krad.data.provider.annotation.KeyValuesFinderClass;
028    import org.kuali.rice.krad.data.provider.annotation.Label;
029    import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType;
030    import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews;
031    import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
032    import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
033    import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
034    import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName;
035    
036    import javax.persistence.Column;
037    import javax.persistence.Entity;
038    import javax.persistence.GeneratedValue;
039    import javax.persistence.Id;
040    import javax.persistence.Table;
041    import javax.persistence.Transient;
042    import java.io.Serializable;
043    
044    /**
045     * This class provides travel destination record for TEM sample
046     *
047     * @author Kuali Rice Team (rice.collab@kuali.org)
048     */
049    @Entity
050    @Table(name = "TRVL_DEST_T")
051    @UifAutoCreateViews({UifAutoCreateViewType.INQUIRY, UifAutoCreateViewType.LOOKUP})
052    public class TravelDestination extends DataObjectBase implements MutableInactivatable, Serializable {
053    
054        private static final long serialVersionUID = 8448891916448081149L;
055    
056        @Id @Column(name = "TRVL_DEST_ID", length = 40)
057        @GeneratedValue(generator = "TRVL_DEST_ID_S")
058        @PortableSequenceGenerator(name = "TRVL_DEST_ID_S")
059        @Label("Id")
060        @Description("Unique identifier for destination item")
061        @UifValidCharactersConstraintBeanName("AlphaNumericPatternConstraint")
062        private String travelDestinationId;
063    
064        @Column(name = "DEST_NM", length = 40)
065        @Label("Destination")
066        @Description("Name of location")
067        private String travelDestinationName;
068    
069        @Column(name = "POSTAL_CNTRY_CD")
070        @UifDisplayHints({@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT),
071                          @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)})
072        @KeyValuesFinderClass(PostalCountryCodeKeyValuesFinder.class)
073        @Label("Country")
074        private String countryCd;
075    
076        @Transient
077        @UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA))
078        @Label("Country")
079        private String countryName;
080    
081        @Column(name = "POSTAL_STATE_CD")
082        @UifDisplayHints({@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT),
083                          @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)})
084        @KeyValuesFinderClass(PostalStateCodeKeyValuesFinder.class)
085        @Label("State")
086        private String stateCd;
087    
088        @Transient
089        @UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA))
090        @Label("State")
091        private String stateName;
092    
093    
094        @Column(name = "ACTV_IND", nullable = false, length = 1)
095        @javax.persistence.Convert(converter = BooleanYNConverter.class)
096        @Label("Active")
097        @Description("Whether active or inactive")
098        private boolean active = Boolean.TRUE;
099    
100        public String getTravelDestinationId() {
101            return travelDestinationId;
102        }
103    
104        public void setTravelDestinationId(String travelDestinationId) {
105            this.travelDestinationId = travelDestinationId;
106        }
107    
108        public String getTravelDestinationName() {
109            return travelDestinationName;
110        }
111    
112        public void setTravelDestinationName(String travelDestinationName) {
113            this.travelDestinationName = travelDestinationName;
114        }
115    
116        public String getCountryCd() {
117            return countryCd;
118        }
119    
120        public void setCountryCd(String countryCd) {
121            this.countryCd = countryCd;
122        }
123    
124        public String getCountryName() {
125            return PostalCountryCode.valueOf(countryCd).getLabel();
126        }
127    
128        public String getStateCd() {
129            return stateCd;
130        }
131    
132        public void setStateCd(String stateCd) {
133            this.stateCd = stateCd;
134        }
135    
136        public String getStateName() {
137            return PostalStateCode.valueOf(stateCd).getLabel();
138        }
139    
140        public boolean isActive() {
141            return active;
142        }
143    
144        public void setActive(boolean active) {
145            this.active = active;
146        }
147    }