Source Code Cross Referenced for StudentGradesImpl.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » component » app » postem » data » 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.component.app.postem.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/postem/tags/sakai_2-4-1/postem-hbm/src/java/org/sakaiproject/component/app/postem/data/StudentGradesImpl.java $
003:         * $Id: StudentGradesImpl.java 17140 2006-10-16 17:40:49Z wagnermr@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
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.component.app.postem.data;
021:
022:        import java.io.Serializable;
023:        import java.sql.Timestamp;
024:        import java.text.DateFormat;
025:        import java.text.SimpleDateFormat;
026:        import java.util.ArrayList;
027:        import java.util.Date;
028:        import java.util.Iterator;
029:        import java.util.List;
030:
031:        import org.sakaiproject.api.app.postem.data.Gradebook;
032:        import org.sakaiproject.api.app.postem.data.StudentGrades;
033:        import org.sakaiproject.api.app.postem.data.Template;
034:
035:        public class StudentGradesImpl implements  StudentGrades, Comparable,
036:                Serializable {
037:            protected Gradebook gradebook;
038:
039:            protected String username;
040:
041:            protected List grades = new ArrayList();
042:
043:            protected DateFormat dateFormat = new SimpleDateFormat(
044:                    "d MMM yyyy HH:mm");
045:
046:            protected Timestamp lastChecked;
047:
048:            protected Long id;
049:
050:            protected Integer lockId;
051:
052:            public StudentGradesImpl() {
053:
054:            }
055:
056:            public StudentGradesImpl(String username, List grades) {
057:                this .username = username.trim();
058:                this .grades = grades;
059:            }
060:
061:            public Integer getLockId() {
062:                return lockId;
063:            }
064:
065:            public void setLockId(Integer lockId) {
066:                this .lockId = lockId;
067:            }
068:
069:            public Gradebook getGradebook() {
070:                return gradebook;
071:            }
072:
073:            public void setGradebook(Gradebook gradebook) {
074:                this .gradebook = gradebook;
075:            }
076:
077:            public String getUsername() {
078:                return username;
079:            }
080:
081:            public void setUsername(String username) {
082:                this .username = username.trim();
083:            }
084:
085:            public List getGrades() {
086:                return grades;
087:            }
088:
089:            public void setGrades(List grades) {
090:                this .grades = grades;
091:            }
092:
093:            public String getCheckDateTime() {
094:                if (lastChecked == null) {
095:                    return "never";
096:                }
097:                return dateFormat.format((Date) lastChecked);
098:            }
099:
100:            public Timestamp getLastChecked() {
101:                return lastChecked;
102:            }
103:
104:            public void setLastChecked(Timestamp lastChecked) {
105:                this .lastChecked = lastChecked;
106:            }
107:
108:            public Long getId() {
109:                return id;
110:            }
111:
112:            public void setId(Long id) {
113:                this .id = id;
114:            }
115:
116:            public int compareTo(Object other) {
117:                if (this  == other)
118:                    return 0;
119:                final StudentGrades that = (StudentGrades) other;
120:
121:                return this .getUsername().compareTo(that.getUsername());
122:            }
123:
124:            public boolean equals(Object other) {
125:                if (this  == other)
126:                    return true;
127:                if (!(other instanceof  StudentGrades))
128:                    return false;
129:                final StudentGrades that = (StudentGrades) other;
130:
131:                return this .getUsername().equals(that.getUsername());
132:            }
133:
134:            public int hashCode() {
135:                return getUsername().hashCode();
136:            }
137:
138:            public boolean getReadAfterUpdate() {
139:                if (lastChecked == null) {
140:                    return false;
141:                }
142:                return getLastChecked().after(gradebook.getLastUpdated());
143:            }
144:
145:            /**
146:             * Formats the grades for display, independently of the JSF display. If a
147:             * {@link Template} exists for the parent gradebook, that template's
148:             * fillGrades method is used. Otherwise, the grades are formatted into a plain
149:             * old table.
150:             * <p>
151:             * This is a bad method for including display code within it; however, I do
152:             * this for a simple reason: we're already including display code at this
153:             * level via the template.
154:             * <p>
155:             * The prettier eventual solution will be to inject a default template via the
156:             * controller, or possibly in the manager class (using a defaultTemplate
157:             * property). This works for the quick and dirty now.
158:             */
159:            public String formatGrades() {
160:                if (gradebook.getTemplate() == null) {
161:
162:                    List h2 = new ArrayList(gradebook.getHeadings());
163:
164:                    StringBuffer gradeBuffer = new StringBuffer();
165:                    gradeBuffer.append("<table class=\"itemSummary\">");
166:
167:                    if (h2.size() != 0) {
168:                        gradeBuffer.append("<tr><th scope=\"row\">"
169:                                + h2.get(0).toString() + "</th><td>");
170:                        h2.remove(0);
171:                        gradeBuffer.append(getUsername());
172:                        gradeBuffer.append("</td></tr>");
173:                        Iterator ii = h2.iterator();
174:                        Iterator jj = grades.iterator();
175:
176:                        while (ii.hasNext()) {
177:                            gradeBuffer.append("<tr><th scope=\"row\">");
178:                            gradeBuffer.append((String) ii.next());
179:                            gradeBuffer.append("</th><td>");
180:                            gradeBuffer.append((String) jj.next());
181:                            gradeBuffer.append("</td></tr>");
182:                        }
183:                    } else {
184:                        gradeBuffer.append("<tr><td>");
185:                        gradeBuffer.append(getUsername());
186:                        gradeBuffer.append("</td></tr>");
187:                        Iterator jj = grades.iterator();
188:                        while (jj.hasNext()) {
189:                            gradeBuffer.append("<tr><td>");
190:                            gradeBuffer.append((String) jj.next());
191:                            gradeBuffer.append("</td></tr>");
192:                        }
193:                    }
194:                    gradeBuffer.append("</table>");
195:                    return gradeBuffer.toString();
196:                } else {
197:                    return gradebook.getTemplate().fillGrades(this );
198:                }
199:            }
200:
201:            public String getGradesRow() {
202:                StringBuffer gradeBuffer = new StringBuffer();
203:                // gradeBuffer.append("<table><tr>");
204:                int totalWidth = 0;
205:
206:                Iterator jj = grades.iterator();
207:                int ii = 0;
208:                while (jj.hasNext()) {
209:                    String current = (String) jj.next();
210:                    String width = gradebook.getProperWidth(ii);
211:                    int iwidth = Integer.parseInt(width.substring(0, width
212:                            .length() - 2));
213:                    totalWidth += iwidth;
214:                    /*gradeBuffer.append("<td width='");
215:                    gradeBuffer.append(width);
216:                    gradeBuffer.append("' style='min-width: ");
217:                    gradeBuffer.append(width);
218:                    gradeBuffer.append("; width: ");
219:                    gradeBuffer.append(width);
220:                    gradeBuffer.append(";' >");*/
221:                    gradeBuffer.append("<td style=\"padding:0.6em;\">");
222:                    gradeBuffer.append(current);
223:                    gradeBuffer.append("</td>");
224:                    ii++;
225:                }
226:                /*StringBuffer newBuffer = new StringBuffer();
227:                newBuffer.append("<table width='");
228:                newBuffer.append(totalWidth);
229:                newBuffer.append("px' style='min-width: ");
230:                newBuffer.append(totalWidth);
231:                newBuffer.append("px; width: ");
232:                newBuffer.append(totalWidth);
233:                newBuffer.append("px;' ><tr>");
234:                newBuffer.append(gradeBuffer);
235:
236:                newBuffer.append("</tr></table>");
237:                newBuffer.append("</tr>");*/
238:                return gradeBuffer.toString();
239:            }
240:
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.