001/*
002 * Copyright 2012 The Kuali Foundation 
003 *
004 * Licensed under the Educational Community License, Version 1.0 (the
005 * "License"); you may not use this file except in compliance with the
006 * License. You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl1.php 
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
013 * implied. See the License for the specific language governing
014 * permissions and limitations under the License.
015 */
016
017package org.kuali.student.enrollment.courseoffering.dto;
018
019import org.kuali.student.r2.common.dto.IdNamelessEntityInfo;
020import org.kuali.student.enrollment.courseoffering.infc.CourseOfferingCrossListing;
021
022import org.w3c.dom.Element;
023
024import javax.xml.bind.annotation.XmlAccessType;
025import javax.xml.bind.annotation.XmlAccessorType;
026import javax.xml.bind.annotation.XmlAnyElement;
027import javax.xml.bind.annotation.XmlElement;
028import javax.xml.bind.annotation.XmlType;
029
030import java.util.List;
031
032import java.io.Serializable;
033
034
035@XmlAccessorType(XmlAccessType.FIELD)
036@XmlType(name = "CourseOfferingCrossListingInfo", propOrder = {
037                "id", "typeKey", "stateKey", "code", "subjectArea",
038        "subjectOrgId", "courseNumberSuffix",
039                "meta", "attributes", "_futureElements"
040})
041
042public class CourseOfferingCrossListingInfo 
043    extends IdNamelessEntityInfo 
044    implements CourseOfferingCrossListing, Serializable,
045                Comparable<CourseOfferingCrossListing> {
046
047    private static final long serialVersionUID = 1L;
048
049    @XmlElement
050    private String code;
051
052    @XmlElement
053    private String subjectArea;
054
055    @XmlElement
056    private String subjectOrgId;
057
058    @XmlElement
059    private String courseNumberSuffix;
060
061    @XmlAnyElement
062    private List<Element> _futureElements;
063
064    
065    /**
066     *  Constructs a new CourseOfferingCrossListingInfo.
067     */
068
069    public CourseOfferingCrossListingInfo() {
070
071    }
072
073    /**
074     *  Constructs a new CourseOfferingCrossListingInfo 
075     *  from another CourseOfferingCrossListing.
076     *
077     *  @param crossListing the CourseOfferingCrossListing to copy
078     */
079
080    public CourseOfferingCrossListingInfo(CourseOfferingCrossListing crossListing) {
081        super(crossListing);
082        if (crossListing != null) {
083            this.code = crossListing.getCode();
084            this.subjectArea = crossListing.getSubjectArea();
085            this.subjectOrgId = crossListing.getSubjectOrgId();
086            this.courseNumberSuffix = crossListing.getCourseNumberSuffix();
087        }
088    }
089
090    @Override
091    public String getCode() {
092        return code;
093    }
094
095    public void setCode(String code) {
096        this.code = code;
097    }
098
099    @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}