001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sections/tags/sakai_2-4-1/sections-app/src/java/org/sakaiproject/tool/section/jsf/backingbean/LocalSectionModel.java $
003: * $Id: LocalSectionModel.java 21967 2007-02-27 19:51:10Z jholtzman@berkeley.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Regents of the University of California and The Regents of the University of Michigan
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.section.jsf.backingbean;
021:
022: import java.io.Serializable;
023: import java.util.ArrayList;
024: import java.util.Iterator;
025: import java.util.List;
026:
027: import org.apache.commons.lang.builder.ToStringBuilder;
028: import org.apache.commons.logging.Log;
029: import org.apache.commons.logging.LogFactory;
030: import org.sakaiproject.section.api.coursemanagement.Course;
031: import org.sakaiproject.section.api.coursemanagement.CourseSection;
032: import org.sakaiproject.section.api.coursemanagement.Meeting;
033:
034: public class LocalSectionModel implements CourseSection, Serializable {
035: private static final Log log = LogFactory
036: .getLog(LocalSectionModel.class);
037: private static final long serialVersionUID = 1L;
038:
039: private Course course;
040: private String uuid;
041: private String title;
042: private String category;
043: private Integer maxEnrollments;
044:
045: // We need a string to represent size limit due to this JSF bug: http://issues.apache.org/jira/browse/MYFACES-570
046: private String limitSize;
047:
048: private List<Meeting> meetings;
049:
050: public LocalSectionModel() {
051: }
052:
053: public LocalSectionModel(Course course, String title,
054: String category, String uuid) {
055: this .uuid = uuid;
056: this .title = title;
057: this .category = category;
058: limitSize = Boolean.FALSE.toString();
059: }
060:
061: public LocalSectionModel(CourseSection section) {
062: this .course = section.getCourse();
063: this .uuid = section.getUuid();
064: this .title = section.getTitle();
065: this .category = section.getCategory();
066: this .maxEnrollments = section.getMaxEnrollments();
067: if (maxEnrollments == null) {
068: limitSize = Boolean.FALSE.toString();
069: } else {
070: limitSize = Boolean.TRUE.toString();
071: }
072: this .meetings = new ArrayList<Meeting>();
073: for (Iterator iter = section.getMeetings().iterator(); iter
074: .hasNext();) {
075: Meeting meeting = (Meeting) iter.next();
076: meetings.add(new LocalMeetingModel(meeting));
077: }
078: }
079:
080: public Integer getMaxEnrollments() {
081: return maxEnrollments;
082: }
083:
084: public void setMaxEnrollments(Integer maxEnrollments) {
085: this .maxEnrollments = maxEnrollments;
086: }
087:
088: public String getTitle() {
089: return title;
090: }
091:
092: public void setTitle(String title) {
093: this .title = title;
094: }
095:
096: public List<Meeting> getMeetings() {
097: if (meetings == null) {
098: // Keep this out of the constructor to avoid it in deserialization
099: this .meetings = new ArrayList<Meeting>();
100: }
101: return meetings;
102: }
103:
104: public void setMeetings(List<Meeting> meetings) {
105: this .meetings = meetings;
106: }
107:
108: public String toString() {
109: return new ToStringBuilder(this ).append(title).append(
110: maxEnrollments).toString();
111: }
112:
113: public String getLimitSize() {
114: return limitSize;
115: }
116:
117: public void setLimitSize(String limitSize) {
118: this .limitSize = limitSize;
119: }
120:
121: public String getCategory() {
122: return category;
123: }
124:
125: public Course getCourse() {
126: return course;
127: }
128:
129: public String getUuid() {
130: return uuid;
131: }
132:
133: /**
134: * Enterprise ID is not needed in this app.
135: */
136: public String getEid() {
137: return null;
138: }
139: }
|