View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.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
13   * implied.  See the License for the specific language governing
14   * permissions and limitations under the License.
15   */
16  
17  package org.kuali.student.enrollment.courseoffering.dto;
18  
19  import java.io.Serializable;
20  import java.util.ArrayList;
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.apache.commons.lang.StringUtils;
30  import org.kuali.student.enrollment.courseoffering.infc.RegistrationGroup;
31  import org.kuali.student.r2.common.dto.IdEntityInfo;
32  import org.w3c.dom.Element;
33  
34  /**
35   * @author Kuali Student Team (Kamal)
36   */
37  @XmlAccessorType(XmlAccessType.FIELD)
38  @XmlType(name = "RegistrationGroupInfo", propOrder = {
39                  "id", "typeKey", "stateKey", "name", "descr", 
40                  "formatOfferingId",  "courseOfferingId", 
41                  "activityOfferingClusterId", "termId", 
42                  "registrationCode", "activityOfferingIds", 
43                  "isGenerated",
44                  "meta", "attributes", "_futureElements"})
45  
46  public class RegistrationGroupInfo 
47      extends IdEntityInfo 
48      implements RegistrationGroup, Serializable {
49  
50      private static final long serialVersionUID = 1L;
51  
52      // PLEASE READ ---------------------------- Aug 22, 2012 (East Coast1 PDT)
53      // registrationCode will store a 5-digit string which is a unique value by registration group in a given term
54      // i.e., no two reg groups will share the same registration code in the same term--this is not used in M4, so the
55      // value is not needed yet.
56      // The <name> field (which is inherited from IdEntityInfo) will store a 4 digit string , that is the registration
57      // group code.  This is unique (for a given term) within the CO which the RG belongs to.  Thus, no two RGs within
58      // the same CO has the same 4 digit reg group code.
59      // Thus, two terms: registration code (unique across all RGs in a term) and registration group code (unique to all
60      // RG belong to a given CO).
61  
62      @XmlElement
63      private String formatOfferingId;
64  
65      @XmlElement
66      private String courseOfferingId;
67      
68      @XmlElement
69      private String activityOfferingClusterId;
70  
71      @XmlElement
72      private String termId;
73      
74      @XmlElement
75      private String registrationCode;
76  
77      @XmlElement
78      private List<String> activityOfferingIds;
79  
80      @XmlElement
81      private Boolean isGenerated;
82  
83      @XmlAnyElement
84      private List<Element> _futureElements;
85  
86      
87      /**
88       * Constructs a new RegistrationGroupInfo.
89       */
90      public RegistrationGroupInfo() {
91      }
92  
93      /**
94       * Constructs a new RegistrationGroupInfo from another
95       * RegistrationGroup.
96       *
97       * @param registrationGroup the registration group to copy
98       */
99      public RegistrationGroupInfo(RegistrationGroup registrationGroup) {
100         super(registrationGroup); 
101         
102         if (registrationGroup == null) {
103             return;      
104         }
105 
106         this.formatOfferingId = registrationGroup.getFormatOfferingId();
107         this.courseOfferingId = registrationGroup.getCourseOfferingId();
108         this.activityOfferingClusterId = registrationGroup.getActivityOfferingClusterId();
109         
110         this.termId = registrationGroup.getTermId();
111         
112         this.registrationCode = registrationGroup.getRegistrationCode();
113         
114         if (registrationGroup.getActivityOfferingIds() != null) {
115             this.activityOfferingIds = new ArrayList<String>(registrationGroup.getActivityOfferingIds());
116         }
117 
118         this.isGenerated = registrationGroup.getIsGenerated();
119         
120     }
121 
122     @Override
123     public String getFormatOfferingId() {
124         return formatOfferingId;
125     }
126 
127     public void setFormatOfferingId(String formatOfferingId) {
128         this.formatOfferingId = formatOfferingId;
129     }
130 
131     @Override
132     public String getCourseOfferingId() {
133         return courseOfferingId;
134     }
135 
136     public void setCourseOfferingId(String courseOfferingId) {
137         this.courseOfferingId = courseOfferingId;
138     }
139 
140     @Override
141     public String getTermId() {
142         return termId;
143     }
144 
145     public void setTermId(String termId) {
146         this.termId = termId;
147     }
148 
149     @Override
150     public String getRegistrationCode() {
151         return registrationCode;
152     }
153 
154     public void setRegistrationCode(String registrationCode) {
155         this.registrationCode = registrationCode;
156     }
157 
158     @Override
159     public List<String> getActivityOfferingIds() {
160         if (activityOfferingIds == null) {
161             activityOfferingIds = new ArrayList<String>();
162         }
163 
164         return activityOfferingIds;
165     }
166 
167     public void setActivityOfferingIds(List<String> activityOfferingIds) {
168         this.activityOfferingIds = activityOfferingIds;
169     }
170 
171     @Override
172     public Boolean getIsGenerated() {
173         return isGenerated;
174     }
175 
176     public void setIsGenerated(Boolean isGenerated) {
177         this.isGenerated = isGenerated;
178     }
179     
180     
181     
182     public void setActivityOfferingClusterId(String activityOfferingClusterId) {
183 		this.activityOfferingClusterId = activityOfferingClusterId;
184 	}
185 
186 	@Override
187 	public String getActivityOfferingClusterId() {
188 		return activityOfferingClusterId;
189 	}
190 
191 	@Override
192     public String toString() {
193         StringBuilder builder = new StringBuilder();
194         builder.append("RegistrationGroupInfo [id=");
195         builder.append(getId());
196         builder.append("formatOfferingId=");
197         builder.append(formatOfferingId);
198         builder.append(", courseOfferingId=");
199         builder.append(courseOfferingId);
200         builder.append(", activityOfferingClusterId=");
201         builder.append(activityOfferingClusterId);
202         builder.append(", termId=");
203         builder.append(termId);
204         builder.append(", activityOfferingIds=");
205         builder.append(StringUtils.join(activityOfferingIds, ", "));
206         builder.append(", registrationCode=");
207         builder.append(registrationCode);
208         builder.append(", isGenerated=");
209         builder.append(isGenerated);
210         builder.append("]");
211         return builder.toString();
212     }
213 }