Source Code Cross Referenced for EditStudentsBean.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » section » jsf » backingbean » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.tool.section.jsf.backingbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sections/tags/sakai_2-4-1/sections-app/src/java/org/sakaiproject/tool/section/jsf/backingbean/EditStudentsBean.java $
003:         * $Id: EditStudentsBean.java 22767 2007-03-16 17:41:08Z 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.Collections;
025:        import java.util.Iterator;
026:        import java.util.List;
027:        import java.util.Set;
028:
029:        import javax.faces.event.ValueChangeEvent;
030:        import javax.faces.model.SelectItem;
031:
032:        import org.apache.commons.lang.StringUtils;
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:        import org.sakaiproject.section.api.coursemanagement.CourseSection;
036:        import org.sakaiproject.section.api.coursemanagement.ParticipationRecord;
037:        import org.sakaiproject.section.api.coursemanagement.User;
038:        import org.sakaiproject.section.api.exception.RoleConfigurationException;
039:        import org.sakaiproject.section.api.facade.Role;
040:        import org.sakaiproject.tool.section.decorator.SectionDecorator;
041:        import org.sakaiproject.tool.section.jsf.JsfUtil;
042:
043:        /**
044:         * Controls the edit students page (where students are assigned to sections).
045:         * 
046:         * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
047:         *
048:         */
049:        public class EditStudentsBean extends EditManagersBean implements 
050:                Serializable {
051:
052:            private static final long serialVersionUID = 1L;
053:
054:            private static final Log log = LogFactory
055:                    .getLog(EditStudentsBean.class);
056:
057:            // For the "View" selectbox
058:            private String availableSectionUuid;
059:            private String availableSectionTitle;
060:            private Integer availableSectionMax;
061:            private List availableSectionItems;
062:
063:            private Integer sectionMax;
064:
065:            public void init() {
066:                SectionDecorator currentSection = initializeFields();
067:                sectionMax = currentSection.getMaxEnrollments();
068:
069:                // Get the current users
070:                List enrollments = getSectionManager().getSectionEnrollments(
071:                        currentSection.getUuid());
072:                Collections.sort(enrollments,
073:                        EditManagersBean.sortNameComparator);
074:
075:                populateSelectedUsers(enrollments);
076:
077:                // Build the list of items for the left-side box
078:                List available;
079:                if (StringUtils.trimToNull(availableSectionUuid) == null) {
080:                    available = getSectionManager().getUnsectionedEnrollments(
081:                            currentSection.getCourse().getUuid(),
082:                            currentSection.getCategory());
083:                } else {
084:                    available = getSectionManager().getSectionEnrollments(
085:                            availableSectionUuid);
086:                }
087:                Collections
088:                        .sort(available, EditManagersBean.sortNameComparator);
089:
090:                availableUsers = new ArrayList();
091:                for (Iterator iter = available.iterator(); iter.hasNext();) {
092:                    User student = ((ParticipationRecord) iter.next())
093:                            .getUser();
094:                    availableUsers.add(new SelectItem(student.getUserUid(),
095:                            student.getSortName()));
096:                }
097:
098:                // Build the list of available sections
099:                List sectionsInCategory = getSectionManager()
100:                        .getSectionsInCategory(getSiteContext(),
101:                                currentSection.getCategory());
102:                Collections.sort(sectionsInCategory);
103:                availableSectionItems = new ArrayList();
104:                availableSectionItems.add(new SelectItem("", JsfUtil
105:                        .getLocalizedMessage("edit_student_unassigned")));
106:                for (Iterator iter = sectionsInCategory.iterator(); iter
107:                        .hasNext();) {
108:                    CourseSection section = (CourseSection) iter.next();
109:                    // Don't include the current section
110:                    if (section.getUuid().equals(currentSection.getUuid())) {
111:                        continue;
112:                    }
113:                    if (section.getUuid().equals(availableSectionUuid)) {
114:                        availableSectionTitle = section.getTitle();
115:                        availableSectionMax = section.getMaxEnrollments();
116:                    }
117:                    availableSectionItems.add(new SelectItem(section.getUuid(),
118:                            section.getTitle()));
119:                }
120:            }
121:
122:            public void processChangeSection(ValueChangeEvent event) {
123:                // Reset all lists
124:                init();
125:            }
126:
127:            public String update() {
128:                CourseSection section = getSectionManager().getSection(
129:                        sectionUuid);
130:
131:                // The section might have been deleted
132:                if (section == null) {
133:                    JsfUtil.addErrorMessage(JsfUtil
134:                            .getLocalizedMessage("error_section_deleted"));
135:                    return "overview";
136:                }
137:
138:                Set selectedUserUuids = getHighlightedUsers("memberForm:selectedUsers");
139:                try {
140:                    getSectionManager().setSectionMemberships(
141:                            selectedUserUuids, Role.STUDENT, sectionUuid);
142:                } catch (RoleConfigurationException rce) {
143:                    JsfUtil.addErrorMessage(JsfUtil
144:                            .getLocalizedMessage("role_config_error"));
145:                    return null;
146:                }
147:
148:                // If the "available" box is a section, update that section's members as well
149:                Set availableUserUuids = getHighlightedUsers("memberForm:availableUsers");
150:                if (StringUtils.trimToNull(availableSectionUuid) != null) {
151:                    availableUserUuids = getHighlightedUsers("memberForm:availableUsers");
152:                    try {
153:                        getSectionManager().setSectionMemberships(
154:                                availableUserUuids, Role.STUDENT,
155:                                availableSectionUuid);
156:                    } catch (RoleConfigurationException rce) {
157:                        JsfUtil.addErrorMessage(JsfUtil
158:                                .getLocalizedMessage("role_config_error"));
159:                        return null;
160:                    }
161:                }
162:                StringBuffer titles = new StringBuffer();
163:                titles.append(sectionTitle);
164:                if (StringUtils.trimToNull(availableSectionUuid) != null) {
165:                    titles.append(" ");
166:                    titles.append(JsfUtil.getLocalizedMessage("and"));
167:                    titles.append(" ");
168:                    titles.append(availableSectionTitle);
169:                }
170:
171:                // Add the success message first, before any caveats (see below)
172:                JsfUtil.addRedirectSafeInfoMessage(JsfUtil.getLocalizedMessage(
173:                        "edit_student_successful", new String[] { titles
174:                                .toString() }));
175:
176:                // If the selected section is now overenrolled, let the user know
177:                if (sectionMax != null
178:                        && selectedUserUuids.size() > sectionMax.intValue()) {
179:                    JsfUtil
180:                            .addRedirectSafeWarnMessage(JsfUtil
181:                                    .getLocalizedMessage(
182:                                            "edit_student_over_max_warning",
183:                                            new String[] {
184:                                                    sectionTitle,
185:                                                    Integer
186:                                                            .toString(selectedUserUuids
187:                                                                    .size()),
188:                                                    Integer
189:                                                            .toString(selectedUserUuids
190:                                                                    .size()
191:                                                                    - sectionMax
192:                                                                            .intValue()) }));
193:                }
194:
195:                // If the available section is now overenrolled, let the user know
196:                if (availableSectionMax != null
197:                        && availableUserUuids.size() > availableSectionMax
198:                                .intValue()) {
199:                    JsfUtil.addRedirectSafeWarnMessage(JsfUtil
200:                            .getLocalizedMessage(
201:                                    "edit_student_over_max_warning",
202:                                    new String[] {
203:                                            availableSectionTitle,
204:                                            Integer.toString(availableUserUuids
205:                                                    .size()),
206:                                            Integer.toString(availableUserUuids
207:                                                    .size()
208:                                                    - availableSectionMax
209:                                                            .intValue()) }));
210:                }
211:
212:                return "overview";
213:            }
214:
215:            public String getAvailableSectionUuid() {
216:                return availableSectionUuid;
217:            }
218:
219:            public void setAvailableSectionUuid(String availableSectionUuid) {
220:                this .availableSectionUuid = availableSectionUuid;
221:            }
222:
223:            public List getAvailableSectionItems() {
224:                return availableSectionItems;
225:            }
226:
227:            public Integer getSectionMax() {
228:                return sectionMax;
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.