View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.r2.lum.clu.dto;
17  
18  import java.io.Serializable;
19  import java.util.ArrayList;
20  import java.util.Date;
21  import java.util.List;
22  
23  import javax.xml.bind.annotation.XmlAccessType;
24  import javax.xml.bind.annotation.XmlAccessorType;
25  import javax.xml.bind.annotation.XmlAnyElement;
26  import javax.xml.bind.annotation.XmlElement;
27  import javax.xml.bind.annotation.XmlType;
28  
29  import org.kuali.student.r2.common.dto.IdNamelessEntityInfo;
30  import org.kuali.student.r2.lum.clu.infc.CluPublication;
31  import org.kuali.student.r2.lum.clu.infc.Field;
32  
33  @XmlAccessorType(XmlAccessType.FIELD)
34  @XmlType(name = "CluPublicationInfo", propOrder = {"id", "typeKey", "stateKey", "cluId", "variants", "startCycle", "endCycle", "effectiveDate",
35          "expirationDate", "meta", "attributes" , "_futureElements" }) 
36  public class CluPublicationInfo extends IdNamelessEntityInfo implements Serializable, CluPublication {
37  
38      private static final long serialVersionUID = 1L;
39  
40      @XmlElement
41      private String cluId;
42  
43      @XmlElement
44      private List<FieldInfo> variants;
45  
46      @XmlElement
47      private String startCycle;
48  
49      @XmlElement
50      private String endCycle;
51  
52      @XmlElement
53      private Date effectiveDate;
54  
55      @XmlElement
56      private Date expirationDate;
57  
58      @XmlAnyElement
59      private List<Object> _futureElements;  
60  
61      public CluPublicationInfo() {
62  
63      }
64  
65      public CluPublicationInfo(CluPublication cluPublication) {
66          super(cluPublication);
67          if (null != cluPublication) {
68              this.cluId = cluPublication.getCluId();
69              this.variants = new ArrayList<FieldInfo>();
70              for (Field field : cluPublication.getVariants()) {
71                  this.variants.add(new FieldInfo(field));
72              }
73              this.startCycle = cluPublication.getStartCycle();
74              this.endCycle = cluPublication.getEndCycle();
75              this.effectiveDate = (null != cluPublication.getEffectiveDate()) ? new Date(cluPublication.getEffectiveDate().getTime()) : null;
76              this.expirationDate = (null != cluPublication.getExpirationDate()) ? new Date(cluPublication.getExpirationDate().getTime()) : null;
77          }
78      }
79  
80      @Override
81      public String getCluId() {
82          return cluId;
83      }
84  
85      public void setCluId(String cluId) {
86          this.cluId = cluId;
87      }
88  
89      @Override
90      public List<FieldInfo> getVariants() {
91          if (variants == null) {
92              variants = new ArrayList<FieldInfo>(0);
93          }
94          return variants;
95      }
96  
97      public void setVariants(List<FieldInfo> variants) {
98          this.variants = variants;
99      }
100 
101     @Override
102     public String getStartCycle() {
103         return startCycle;
104     }
105 
106     public void setStartCycle(String startCycle) {
107         this.startCycle = startCycle;
108     }
109 
110     @Override
111     public String getEndCycle() {
112         return endCycle;
113     }
114 
115     public void setEndCycle(String endCycle) {
116         this.endCycle = endCycle;
117     }
118 
119     @Override
120     public Date getEffectiveDate() {
121         return effectiveDate;
122     }
123 
124     public void setEffectiveDate(Date effectiveDate) {
125         this.effectiveDate = effectiveDate;
126     }
127 
128     @Override
129     public Date getExpirationDate() {
130         return expirationDate;
131     }
132 
133     public void setExpirationDate(Date expirationDate) {
134         this.expirationDate = expirationDate;
135     }
136 
137     @Override
138     public String toString() {
139         return "CluPublicationInfo[id=" + this.getId() + ", cluId=" + this.getCluId() + ", type=" + this.getTypeKey() + "]";
140     }
141 
142 }