View Javadoc

1   /*
2    * Copyright 2010 The Kuali Foundation 
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the
6    * License. You may obtain a copy of the License at
7    *
8    * http://www.osedu.org/licenses/ECL-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13   * implied. See the License for the specific language governing
14   * permissions and limitations under the License.
15   */
16  
17  package org.kuali.student.r2.common.dto;
18  
19  import java.io.Serializable;
20  import java.util.Date;
21  
22  import javax.xml.bind.annotation.XmlAccessType;
23  import javax.xml.bind.annotation.XmlAccessorType;
24  import javax.xml.bind.annotation.XmlAttribute;
25  import javax.xml.bind.annotation.XmlElement;
26  import javax.xml.bind.annotation.XmlTransient;
27  
28  import org.kuali.student.r2.common.infc.Relationship;
29  
30  /**
31   * Information about a Relationship entity.
32   *
33   * @author tom
34   */
35  
36  @XmlAccessorType(XmlAccessType.FIELD)
37  @XmlTransient
38  public abstract class RelationshipInfo 
39      extends HasAttributesAndMetaInfo 
40      implements Relationship, Serializable {
41  
42      private static final long serialVersionUID = 1L;
43  
44      @XmlAttribute
45      private String id;
46  
47      @XmlAttribute
48      private String typeKey;
49  
50      @XmlAttribute
51      private String stateKey;
52  
53      @XmlElement
54      private Date effectiveDate;
55  
56      @XmlElement
57      private Date expirationDate;
58  
59      /**
60       * Constructs a new RelationshipInfo.
61       */
62      public RelationshipInfo() {
63      }
64  
65      /**
66       * Constructs a new RelationshipInfo from another Relationship.
67       *
68       * @param relationship the Relationship top copy
69       */
70      public RelationshipInfo(Relationship relationship) {
71          super(relationship);
72          
73          if (relationship != null) {
74              this.id = relationship.getId();
75              this.typeKey = relationship.getTypeKey();
76              this.stateKey = relationship.getStateKey();
77  
78              if (relationship.getEffectiveDate() != null) {
79                  this.effectiveDate = new Date(relationship.getEffectiveDate().getTime());
80              } 
81  
82              if (relationship.getExpirationDate() != null) {
83                  this.expirationDate = new Date(relationship.getExpirationDate().getTime());
84              }
85          }
86      }
87  
88      @Override
89      public String getId() {
90          return id;
91      }
92  
93      public void setId(String id) {
94          this.id = id;
95      }
96  
97      @Override
98      public String getTypeKey() {
99          return typeKey;
100     }
101         
102     public void setTypeKey(String typeKey) {
103         this.typeKey = typeKey;
104     }
105 
106     @Override
107     public String getStateKey() {
108         return stateKey;
109     }
110         
111     public void setStateKey(String stateKey) {
112         this.stateKey = stateKey;
113     }
114 
115     @Override
116     public Date getEffectiveDate() {
117         return effectiveDate;
118     }
119 
120     public void setEffectiveDate(Date effectiveDate) {
121         this.effectiveDate = effectiveDate;
122     }
123 
124     @Override
125     public Date getExpirationDate() {
126         return expirationDate;
127     }
128 
129     public void setExpirationDate(Date expirationDate) {
130         this.expirationDate = expirationDate;
131     }
132 
133 
134     // Compatibility 
135 
136     @Override
137     @Deprecated
138     public String getType() {
139         return getTypeKey();
140     }
141 
142     @Deprecated
143     public void setType(String typeKey) {
144         setTypeKey(typeKey);
145     }
146 
147     @Override
148     @Deprecated
149     public String getState() {
150         return getStateKey();
151     }
152 
153     @Deprecated
154     public void setState(String stateKey) {
155         setStateKey(stateKey);
156     }
157 }