View Javadoc

1   /*
2    * Copyright 2012 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 org.kuali.student.r2.common.dto.IdNamelessEntityInfo;
20  import org.kuali.student.enrollment.courseoffering.infc.CourseOfferingCrossListing;
21  
22  import org.w3c.dom.Element;
23  
24  import javax.xml.bind.annotation.XmlAccessType;
25  import javax.xml.bind.annotation.XmlAccessorType;
26  import javax.xml.bind.annotation.XmlAnyElement;
27  import javax.xml.bind.annotation.XmlElement;
28  import javax.xml.bind.annotation.XmlType;
29  
30  import java.util.List;
31  
32  import java.io.Serializable;
33  
34  
35  @XmlAccessorType(XmlAccessType.FIELD)
36  @XmlType(name = "CourseOfferingCrossListingInfo", propOrder = {
37                  "id", "typeKey", "stateKey", "code", "subjectArea",
38          "subjectOrgId", "courseNumberSuffix",
39                  "meta", "attributes", "_futureElements"
40  })
41  
42  public class CourseOfferingCrossListingInfo 
43      extends IdNamelessEntityInfo 
44      implements CourseOfferingCrossListing, Serializable,
45                  Comparable<CourseOfferingCrossListing> {
46  
47      private static final long serialVersionUID = 1L;
48  
49      @XmlElement
50      private String code;
51  
52      @XmlElement
53      private String subjectArea;
54  
55      @XmlElement
56      private String subjectOrgId;
57  
58      @XmlElement
59      private String courseNumberSuffix;
60  
61      @XmlAnyElement
62      private List<Element> _futureElements;
63  
64      
65      /**
66       *  Constructs a new CourseOfferingCrossListingInfo.
67       */
68  
69      public CourseOfferingCrossListingInfo() {
70  
71      }
72  
73      /**
74       *  Constructs a new CourseOfferingCrossListingInfo 
75       *  from another CourseOfferingCrossListing.
76       *
77       *  @param crossListing the CourseOfferingCrossListing to copy
78       */
79  
80      public CourseOfferingCrossListingInfo(CourseOfferingCrossListing crossListing) {
81          super(crossListing);
82          if (crossListing != null) {
83              this.code = crossListing.getCode();
84              this.subjectArea = crossListing.getSubjectArea();
85              this.subjectOrgId = crossListing.getSubjectOrgId();
86              this.courseNumberSuffix = crossListing.getCourseNumberSuffix();
87          }
88      }
89  
90      @Override
91      public String getCode() {
92          return code;
93      }
94  
95      public void setCode(String code) {
96          this.code = code;
97      }
98  
99      @Override
100     public String getSubjectArea() {
101         return subjectArea;
102     }
103 
104     public void setSubjectArea(String subjectArea) {
105         this.subjectArea = subjectArea;
106     }
107 
108     @Override
109     public String getDepartmentOrgId() {
110         return getSubjectOrgId();
111     }
112 
113     /**
114      * Replaced by setSubjectOrgId (no longer refers to the admin org).
115      * @param subjectOrgId
116      */
117     @Deprecated
118     public void setDepartmentOrgId(String subjectOrgId) {
119         setSubjectOrgId(subjectOrgId);
120     }
121 
122     @Override
123     public String getSubjectOrgId() {
124         return subjectOrgId;
125     }
126 
127     public void setSubjectOrgId(String subjectOrgId) {
128         this.subjectOrgId = subjectOrgId;
129     }
130 
131     @Override
132     public String getCourseNumberSuffix() {
133         return courseNumberSuffix;
134     }
135 
136     public void setCourseNumberSuffix(String courseNumberSuffix) {
137         this.courseNumberSuffix = courseNumberSuffix;
138     }
139 
140     @Override
141     public int compareTo(CourseOfferingCrossListing that) {
142         final int BEFORE = -1;
143         final int EQUAL = 0;
144         final int AFTER = 1;
145 
146         if( that == null ) throw new NullPointerException("that cannot be null");
147         if( this == that ) return EQUAL;
148 
149         int comparison = this.getSubjectArea().compareTo(that.getSubjectArea());
150         if( comparison != EQUAL ) return comparison;
151 
152         comparison = this.getCode().compareTo(that.getCode());
153         if( comparison != EQUAL ) return comparison;
154 
155         comparison = this.getCourseNumberSuffix().compareTo(that.getCourseNumberSuffix());
156         if( comparison != EQUAL ) return comparison;
157 
158         return EQUAL;
159     }
160 
161 }