01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/course-management/tags/sakai_2-4-1/cm-impl/hibernate-impl/hibernate/src/java/org/sakaiproject/coursemanagement/impl/CanonicalCourseCmImpl.java $
03: * $Id: CanonicalCourseCmImpl.java 13913 2006-08-22 20:25:48Z jholtzman@berkeley.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.coursemanagement.impl;
21:
22: import java.io.Serializable;
23: import java.util.HashSet;
24: import java.util.Iterator;
25: import java.util.Set;
26:
27: import org.apache.commons.lang.builder.EqualsBuilder;
28: import org.apache.commons.lang.builder.HashCodeBuilder;
29: import org.sakaiproject.coursemanagement.api.CanonicalCourse;
30: import org.sakaiproject.coursemanagement.api.CourseSet;
31:
32: public class CanonicalCourseCmImpl extends CrossListableCmImpl
33: implements CanonicalCourse, Serializable {
34:
35: private static final long serialVersionUID = 1L;
36:
37: private CrossListingCmImpl crossListingCmImpl;
38: private Set courseSets;
39:
40: /** A cache of courseSetEids */
41: private Set courseSetEids;
42:
43: public CanonicalCourseCmImpl() {
44: }
45:
46: public CanonicalCourseCmImpl(String eid, String title,
47: String description) {
48: this .eid = eid;
49: this .title = title;
50: this .description = description;
51: }
52:
53: public Set getCourseSets() {
54: return courseSets;
55: }
56:
57: public void setCourseSets(Set courseSets) {
58: this .courseSets = courseSets;
59:
60: // Update our cache of courseSetEids
61: if (courseSets == null) {
62: courseSetEids = null;
63: return;
64: }
65: courseSetEids = new HashSet(courseSets.size());
66: for (Iterator iter = courseSets.iterator(); iter.hasNext();) {
67: CourseSet courseSet = (CourseSet) iter.next();
68: courseSetEids.add(courseSet.getEid());
69: }
70: }
71:
72: public CrossListingCmImpl getCrossListing() {
73: return crossListingCmImpl;
74: }
75:
76: public void setCrossListing(CrossListingCmImpl crossListingCmImpl) {
77: this .crossListingCmImpl = crossListingCmImpl;
78: }
79:
80: public boolean equals(Object o) {
81: CanonicalCourse other = (CanonicalCourse) o;
82: return new EqualsBuilder().append(this .eid, other.getEid())
83: .isEquals();
84: }
85:
86: public int hashCode() {
87: return new HashCodeBuilder().append(eid).toHashCode();
88: }
89:
90: public Set getCourseSetEids() {
91: return courseSetEids;
92: }
93: }
|