Source Code Cross Referenced for EnrollmentDecorator.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » section » decorator » 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.decorator 
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-util/src/java/org/sakaiproject/tool/section/decorator/EnrollmentDecorator.java $
003:         * $Id: EnrollmentDecorator.java 20507 2007-01-20 21:33:16Z louis@media.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.decorator;
021:
022:        import java.io.Serializable;
023:        import java.util.Comparator;
024:        import java.util.Map;
025:
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:        import org.sakaiproject.section.api.coursemanagement.CourseSection;
029:        import org.sakaiproject.section.api.coursemanagement.EnrollmentRecord;
030:        import org.sakaiproject.section.api.coursemanagement.User;
031:
032:        /**
033:         * Decorates an EnrollmentRecord for display in the UI.
034:         * 
035:         * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
036:         *
037:         */
038:        public class EnrollmentDecorator implements  Serializable {
039:            private static final long serialVersionUID = 1L;
040:            private static final Log log = LogFactory
041:                    .getLog(EnrollmentDecorator.class);
042:
043:            protected EnrollmentRecord enrollment;
044:
045:            // A Map of categoryId -> Enrolled Section
046:            protected Map categoryToSectionMap;
047:
048:            public EnrollmentDecorator(EnrollmentRecord enrollment,
049:                    Map categoryToSectionMap) {
050:                this .enrollment = enrollment;
051:                this .categoryToSectionMap = categoryToSectionMap;
052:            }
053:
054:            public static final Comparator<EnrollmentDecorator> getNameComparator(
055:                    final boolean sortAscending) {
056:                return new Comparator<EnrollmentDecorator>() {
057:                    public int compare(EnrollmentDecorator enr1,
058:                            EnrollmentDecorator enr2) {
059:                        int comparison = enr1.getUser().getSortName()
060:                                .compareTo(enr2.getUser().getSortName());
061:                        return sortAscending ? comparison : (-1 * comparison);
062:                    }
063:                };
064:            }
065:
066:            public static final Comparator<EnrollmentDecorator> getDisplayIdComparator(
067:                    final boolean sortAscending) {
068:                return new Comparator<EnrollmentDecorator>() {
069:                    public int compare(EnrollmentDecorator enr1,
070:                            EnrollmentDecorator enr2) {
071:                        int comparison = enr1.getUser().getDisplayId()
072:                                .compareTo(enr2.getUser().getDisplayId());
073:                        return sortAscending ? comparison : (-1 * comparison);
074:                    }
075:                };
076:            }
077:
078:            public static final Comparator<EnrollmentDecorator> getCategoryComparator(
079:                    final String categoryId, final boolean sortAscending) {
080:                if (log.isDebugEnabled())
081:                    log.debug("Comparing enrollment decorators by "
082:                            + categoryId);
083:                return new Comparator<EnrollmentDecorator>() {
084:                    public int compare(EnrollmentDecorator enr1,
085:                            EnrollmentDecorator enr2) {
086:                        CourseSection section1 = (CourseSection) enr1
087:                                .getCategoryToSectionMap().get(categoryId);
088:                        CourseSection section2 = (CourseSection) enr2
089:                                .getCategoryToSectionMap().get(categoryId);
090:                        if (section1 == null && section2 != null) {
091:                            return sortAscending ? -1 : 1;
092:                        }
093:                        if (section1 != null && section2 == null) {
094:                            return sortAscending ? 1 : -1;
095:                        }
096:                        if (section1 == null && section2 == null) {
097:                            return getNameComparator(sortAscending).compare(
098:                                    enr1, enr2);
099:                        }
100:
101:                        int comparison = 0;
102:                        if (section1.getTitle().equals(section2.getTitle())) {
103:                            // Use the student name for comparison if the titles are equal
104:                            comparison = enr1.getUser().getSortName()
105:                                    .compareTo(enr2.getUser().getSortName());
106:                        } else {
107:                            // Use the section title for comparison if the titles are different
108:                            comparison = section1.getTitle().compareTo(
109:                                    section2.getTitle());
110:                        }
111:                        return sortAscending ? comparison : (-1 * comparison);
112:                    }
113:                };
114:            }
115:
116:            public String getStatus() {
117:                return enrollment.getStatus();
118:            }
119:
120:            public User getUser() {
121:                return enrollment.getUser();
122:            }
123:
124:            public Map getCategoryToSectionMap() {
125:                return categoryToSectionMap;
126:            }
127:
128:            public String getCategory() {
129:                return null;
130:            }
131:
132:            public String getCatgeoryName() {
133:                return null;
134:            }
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.