001/**
002 * Copyright 2005-2015 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 edu.sampleu.travel.options.PostalCountryCode;
019import edu.sampleu.travel.options.PostalCountryCodeKeyValuesFinder;
020import edu.sampleu.travel.options.PostalStateCode;
021import edu.sampleu.travel.options.PostalStateCodeKeyValuesFinder;
022import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
023import org.kuali.rice.krad.bo.DataObjectBase;
024import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
025import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
026import org.kuali.rice.krad.data.provider.annotation.Description;
027import org.kuali.rice.krad.data.provider.annotation.KeyValuesFinderClass;
028import org.kuali.rice.krad.data.provider.annotation.Label;
029import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType;
030import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews;
031import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
032import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
033import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
034import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName;
035
036import javax.persistence.Column;
037import javax.persistence.Entity;
038import javax.persistence.GeneratedValue;
039import javax.persistence.Id;
040import javax.persistence.Table;
041import javax.persistence.Transient;
042import 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})
052public 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}