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.util.ArrayList;
20  import java.util.List;
21  
22  import javax.xml.bind.annotation.XmlAccessType;
23  import javax.xml.bind.annotation.XmlAccessorType;
24  import javax.xml.bind.annotation.XmlAnyElement;
25  import javax.xml.bind.annotation.XmlElement;
26  import javax.xml.bind.annotation.XmlType;
27  
28  import org.kuali.student.enrollment.courseoffering.infc.RegistrationGroupTemplate;
29  import org.kuali.student.enrollment.courseoffering.infc.ActivityOfferingTemplate;
30  import org.kuali.student.r2.common.dto.IdEntityInfo;
31  
32  import org.w3c.dom.Element;
33  
34  /**
35   * @author Kuali Student Team (Kamal)
36   */
37  @XmlAccessorType(XmlAccessType.FIELD)
38  @XmlType(name = "RegistrationGroupTemplateInfo", propOrder = {
39                  "id", "typeKey", "stateKey", "name", "descr", 
40                  "formatOfferingId",  "activityOfferingTemplates",
41                  "meta", "attributes", "_futureElements"})
42  
43  public class RegistrationGroupTemplateInfo 
44      extends IdEntityInfo 
45      implements RegistrationGroupTemplate {
46  
47      private static final long serialVersionUID = 1L;
48  
49      @XmlElement
50      private String formatOfferingId;
51  
52      @XmlElement
53      private List<ActivityOfferingTemplateInfo> activityOfferingTemplates;
54  
55      @XmlAnyElement
56      private List<Element> _futureElements;
57  
58      
59      /**
60       * Constructs a new RegistrationGroupTemplateInfo.
61       */
62      public RegistrationGroupTemplateInfo() {
63      }
64  
65      /**
66       * Constructs a new RegistrationGroupTemplateInfo from another
67       * RegistrationGroupTemplate.
68       *
69       * @param template the registration group template to copy
70       */
71      public RegistrationGroupTemplateInfo(RegistrationGroupTemplate template) {
72          super(template); 
73          
74          if (template == null) {
75              return;      
76          }
77  
78          this.formatOfferingId = template.getFormatOfferingId();
79          if (template.getActivityOfferingTemplates() != null) {
80              this.activityOfferingTemplates = new ArrayList<ActivityOfferingTemplateInfo>(template.getActivityOfferingTemplates().size());
81              for (ActivityOfferingTemplate aotemplate : template.getActivityOfferingTemplates()) {
82                  this.activityOfferingTemplates.add(new ActivityOfferingTemplateInfo(aotemplate));
83              }
84          }
85      }
86  
87      @Override
88      public String getFormatOfferingId() {
89          return formatOfferingId;
90      }
91  
92      public void setFormatOfferingId(String formatOfferingId) {
93          this.formatOfferingId = formatOfferingId;
94      }
95  
96      @Override
97      public List<ActivityOfferingTemplateInfo> getActivityOfferingTemplates() {
98          if (activityOfferingTemplates == null) {
99              activityOfferingTemplates = new ArrayList<ActivityOfferingTemplateInfo>();
100         }
101 
102         return activityOfferingTemplates;
103     }
104 
105     public void setActivityOfferingTemplates(List<ActivityOfferingTemplateInfo> activityOfferingTemplates) {
106         this.activityOfferingTemplates = activityOfferingTemplates;
107     }
108 }