View Javadoc

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