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