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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/presence/trunk/presence-api/api/src/java/org/sakaiproject/presence/api/PresenceService.java $
003:         * $Id: PresenceService.java 7844 2006-04-17 13:06:02Z ggolden@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 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.roster;
021:
022:        import java.util.Comparator;
023:        import java.util.List;
024:        import java.text.Collator;
025:
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:        import org.sakaiproject.api.app.profile.Profile;
029:        import org.sakaiproject.api.app.roster.Participant;
030:        import org.sakaiproject.user.api.UserNotDefinedException;
031:        import org.sakaiproject.user.cover.UserDirectoryService;
032:
033:        /**
034:         * @author rshastri
035:         *
036:         */
037:        public class ParticipantImpl implements  Participant {
038:            private final static Log Log = LogFactory
039:                    .getLog(ParticipantImpl.class);
040:            private String id;
041:            private String eid;
042:            private String displayId;
043:            private String firstName;
044:            private String lastName;
045:            private Profile profile;
046:            private String roleTitle;
047:            private List sections;
048:            private String sectionsForDisplay;
049:            public static Comparator LastNameComparator;
050:            public static Comparator FirstNameComparator;
051:            public static Comparator UserIdComparator;
052:            public static Comparator RoleComparator;
053:            public static Comparator SectionsComparator;
054:
055:            Collator collator = Collator.getInstance();
056:
057:            /**
058:             * 
059:             * @param id
060:             * @param fname
061:             * @param lname
062:             * @param profile TODO
063:             */
064:            public ParticipantImpl(String id, String displayId, String eid,
065:                    String fname, String lname, Profile profile,
066:                    String roleTitle, List sections) {
067:                if (Log.isDebugEnabled()) {
068:                    Log.debug("ParticipantImpl(String " + id + ", String "
069:                            + fname + ", String " + lname + ")");
070:                }
071:                setId(id);
072:                setEid(eid);
073:                setDisplayId(displayId);
074:                setFirstName(fname);
075:                setLastName(lname);
076:                setProfile(profile);
077:                setRoleTitle(roleTitle);
078:                setSections(sections);
079:            }
080:
081:            /* (non-Javadoc)
082:             * @see org.sakaiproject.component.app.roster.Participant#getFirstName()
083:             */
084:            public String getFirstName() {
085:                Log.debug("getFirstName()");
086:                return firstName;
087:            }
088:
089:            /* (non-Javadoc)
090:             * @see org.sakaiproject.component.app.roster.Participant#setFirstName(java.lang.String)
091:             */
092:            public void setFirstName(String firstName) {
093:                if (Log.isDebugEnabled()) {
094:                    Log.debug("setFirstName(String" + firstName + ")");
095:                }
096:                this .firstName = firstName;
097:            }
098:
099:            /* (non-Javadoc)
100:             * @see org.sakaiproject.component.app.roster.Participant#getId()
101:             */
102:            public String getId() {
103:                Log.debug("getId()");
104:                return id;
105:            }
106:
107:            /* (non-Javadoc)
108:             * @see org.sakaiproject.component.app.roster.Participant#setId(java.lang.String)
109:             */
110:            public void setId(String id) {
111:                if (Log.isDebugEnabled()) {
112:                    Log.debug("setId(String" + id + ")");
113:                }
114:                this .id = id;
115:            }
116:
117:            public String getDisplayId() {
118:                return displayId;
119:            }
120:
121:            public void setDisplayId(String displayId) {
122:                this .displayId = displayId;
123:            }
124:
125:            /* (non-Javadoc)
126:             * @see org.sakaiproject.component.app.roster.Participant#getLastName()
127:             */
128:            public String getLastName() {
129:                Log.debug("getLastName()");
130:                return lastName;
131:            }
132:
133:            /* (non-Javadoc)
134:             * @see org.sakaiproject.component.app.roster.Participant#setLastName(java.lang.String)
135:             */
136:            public void setLastName(String lastName) {
137:                if (Log.isDebugEnabled()) {
138:                    Log.debug("setLastName(String" + lastName + ")");
139:                }
140:                this .lastName = lastName;
141:            }
142:
143:            public boolean equals(Object o) {
144:                if (Log.isDebugEnabled()) {
145:                    Log.debug("equals(Object" + o + ")");
146:                }
147:                if (!(o instanceof  Participant))
148:                    return false;
149:                Participant participant = (Participant) o;
150:                return participant.hashCode() == this .hashCode();
151:            }
152:
153:            public String toString() {
154:                Log.debug("toString()");
155:                return firstName + " " + lastName;
156:
157:            }
158:
159:            public int compareTo(Object anotherParticipant)
160:                    throws ClassCastException {
161:                if (Log.isDebugEnabled()) {
162:                    Log.debug("compare(Object " + anotherParticipant + ")");
163:                }
164:                if (!(anotherParticipant instanceof  Participant))
165:                    throw new ClassCastException(
166:                            "A Participant object expected.");
167:                String anotherParticipantLastName = ((Participant) anotherParticipant)
168:                        .getLastName();
169:                String anotherParticipantFirstName = ((Participant) anotherParticipant)
170:                        .getFirstName();
171:                int lastNameComp = collator.compare(this .lastName,
172:                        anotherParticipantLastName);
173:                return (lastNameComp != 0 ? lastNameComp : collator.compare(
174:                        this .firstName, anotherParticipantFirstName));
175:            }
176:
177:            static {
178:                LastNameComparator = new Comparator()
179:
180:                {
181:                    public int compare(Object participant,
182:                            Object otherParticipant) {
183:                        if (Log.isDebugEnabled()) {
184:                            Log.debug("compare(Object " + participant
185:                                    + ", Object " + otherParticipant + ")");
186:                        }
187:                        String lastName1 = ((Participant) participant)
188:                                .getLastName().toUpperCase();
189:                        String firstName1 = ((Participant) participant)
190:                                .getFirstName().toUpperCase();
191:                        String lastName2 = ((Participant) otherParticipant)
192:                                .getLastName().toUpperCase();
193:                        String firstName2 = ((Participant) otherParticipant)
194:                                .getFirstName().toUpperCase();
195:                        while (lastName1.startsWith(" ")) {
196:                            lastName1 = lastName1.replaceFirst(" ", "");
197:                        }
198:                        while (lastName2.startsWith(" ")) {
199:                            lastName2 = lastName2.replaceFirst(" ", "");
200:                        }
201:                        while (firstName1.startsWith(" ")) {
202:                            firstName1 = firstName1.replaceFirst(" ", "");
203:                        }
204:                        while (firstName2.startsWith(" ")) {
205:                            firstName2 = firstName2.replaceFirst(" ", "");
206:                        }
207:
208:                        if (!(lastName1.equals(lastName2)))
209:                            return Collator.getInstance().compare(lastName1,
210:                                    lastName2);
211:                        else
212:                            return Collator.getInstance().compare(firstName1,
213:                                    firstName2);
214:                    }
215:                };
216:
217:                FirstNameComparator = new Comparator() {
218:                    public int compare(Object participant,
219:                            Object otherParticipant) {
220:                        if (Log.isDebugEnabled()) {
221:                            Log.debug("compare(Object " + participant
222:                                    + ", Object " + otherParticipant + ")");
223:                        }
224:                        String lastName1 = ((Participant) participant)
225:                                .getLastName().toUpperCase();
226:                        String firstName1 = ((Participant) participant)
227:                                .getFirstName().toUpperCase();
228:                        String lastName2 = ((Participant) otherParticipant)
229:                                .getLastName().toUpperCase();
230:                        String firstName2 = ((Participant) otherParticipant)
231:                                .getFirstName().toUpperCase();
232:                        while (lastName1.startsWith(" ")) {
233:                            lastName1 = lastName1.replaceFirst(" ", "");
234:                        }
235:                        while (lastName2.startsWith(" ")) {
236:                            lastName2 = lastName2.replaceFirst(" ", "");
237:                        }
238:                        while (firstName1.startsWith(" ")) {
239:                            firstName1 = firstName1.replaceFirst(" ", "");
240:                        }
241:                        while (firstName2.startsWith(" ")) {
242:                            firstName2 = firstName2.replaceFirst(" ", "");
243:                        }
244:
245:                        if (!(firstName1.equals(firstName2)))
246:                            return Collator.getInstance().compare(firstName1,
247:                                    firstName2);
248:                        else
249:                            return Collator.getInstance().compare(lastName1,
250:                                    lastName2);
251:                    }
252:                };
253:
254:                UserIdComparator = new Comparator() {
255:                    public int compare(Object participant,
256:                            Object otherParticipant) {
257:                        if (Log.isDebugEnabled()) {
258:                            Log.debug("compare(Object " + participant
259:                                    + ", Object " + otherParticipant + ")");
260:                        }
261:                        String userId1 = ((Participant) participant).getId();
262:                        String userId2 = ((Participant) otherParticipant)
263:                                .getId();
264:                        String eid1 = "";
265:                        String eid2 = "";
266:
267:                        try {
268:                            eid1 = UserDirectoryService.getUserEid(userId1);
269:                            eid2 = UserDirectoryService.getUserEid(userId2);
270:                        } catch (UserNotDefinedException e) {
271:                            Log.error("UserNotDefinedException", e);
272:                        }
273:
274:                        return Collator.getInstance().compare(eid1, eid2);
275:
276:                    }
277:                };
278:
279:                RoleComparator = new Comparator() {
280:                    public int compare(Object participant,
281:                            Object otherParticipant) {
282:                        if (Log.isDebugEnabled()) {
283:                            Log.debug("compare(Object " + participant
284:                                    + ", Object " + otherParticipant + ")");
285:                        }
286:                        String role1 = ((Participant) participant)
287:                                .getRoleTitle().toUpperCase();
288:                        String role2 = ((Participant) otherParticipant)
289:                                .getRoleTitle().toUpperCase();
290:
291:                        String lastName1 = ((Participant) participant)
292:                                .getLastName().toUpperCase();
293:                        String firstName1 = ((Participant) participant)
294:                                .getFirstName().toUpperCase();
295:                        String lastName2 = ((Participant) otherParticipant)
296:                                .getLastName().toUpperCase();
297:                        String firstName2 = ((Participant) otherParticipant)
298:                                .getFirstName().toUpperCase();
299:
300:                        while (lastName1.startsWith(" ")) {
301:                            lastName1 = lastName1.replaceFirst(" ", "");
302:                        }
303:                        while (lastName2.startsWith(" ")) {
304:                            lastName2 = lastName2.replaceFirst(" ", "");
305:                        }
306:                        while (firstName1.startsWith(" ")) {
307:                            firstName1 = firstName1.replaceFirst(" ", "");
308:                        }
309:                        while (firstName2.startsWith(" ")) {
310:                            firstName2 = firstName2.replaceFirst(" ", "");
311:                        }
312:
313:                        if (!(role1.equals(role2)))
314:                            return Collator.getInstance().compare(role1, role2);
315:                        else if (!(lastName1.equals(lastName2)))
316:                            return Collator.getInstance().compare(lastName1,
317:                                    lastName2);
318:                        else
319:                            return Collator.getInstance().compare(firstName1,
320:                                    firstName2);
321:                    }
322:                };
323:
324:                SectionsComparator = new Comparator() {
325:                    public int compare(Object participant,
326:                            Object otherParticipant) {
327:                        if (Log.isDebugEnabled()) {
328:                            Log.debug("compare(Object " + participant
329:                                    + ", Object " + otherParticipant + ")");
330:                        }
331:                        String sectionString1 = ((Participant) participant)
332:                                .getSectionsForDisplay().toUpperCase();
333:                        String sectionString2 = ((Participant) otherParticipant)
334:                                .getSectionsForDisplay().toUpperCase();
335:
336:                        String lastName1 = ((Participant) participant)
337:                                .getLastName().toUpperCase();
338:                        String firstName1 = ((Participant) participant)
339:                                .getFirstName().toUpperCase();
340:                        String lastName2 = ((Participant) otherParticipant)
341:                                .getLastName().toUpperCase();
342:                        String firstName2 = ((Participant) otherParticipant)
343:                                .getFirstName().toUpperCase();
344:
345:                        while (lastName1.startsWith(" ")) {
346:                            lastName1 = lastName1.replaceFirst(" ", "");
347:                        }
348:                        while (lastName2.startsWith(" ")) {
349:                            lastName2 = lastName2.replaceFirst(" ", "");
350:                        }
351:                        while (firstName1.startsWith(" ")) {
352:                            firstName1 = firstName1.replaceFirst(" ", "");
353:                        }
354:                        while (firstName2.startsWith(" ")) {
355:                            firstName2 = firstName2.replaceFirst(" ", "");
356:                        }
357:
358:                        if (!(sectionString1.equals(sectionString2)))
359:                            return Collator.getInstance().compare(
360:                                    sectionString1, sectionString2);
361:                        else if (!(lastName1.equals(lastName2)))
362:                            return Collator.getInstance().compare(lastName1,
363:                                    lastName2);
364:                        else
365:                            return Collator.getInstance().compare(firstName1,
366:                                    firstName2);
367:                    }
368:                };
369:            }
370:
371:            public Profile getProfile() {
372:                Log.debug("getProfile()");
373:                return profile;
374:            }
375:
376:            public void setProfile(Profile profile) {
377:                if (Log.isDebugEnabled()) {
378:                    Log.debug("setProfile(Profile" + profile + ")");
379:                }
380:                this .profile = profile;
381:            }
382:
383:            public void setEid(String eid) {
384:                this .eid = eid;
385:            }
386:
387:            public String getEid() {
388:                return eid;
389:            }
390:
391:            public void setRoleTitle(String roleTitle) {
392:                this .roleTitle = roleTitle;
393:            }
394:
395:            public String getRoleTitle() {
396:                return roleTitle;
397:            }
398:
399:            public void setSections(List sections) {
400:                this .sections = sections;
401:            }
402:
403:            public List getSections() {
404:                return sections;
405:            }
406:
407:            public String getSectionsForDisplay() {
408:                if (sectionsForDisplay != null)
409:                    return sectionsForDisplay;
410:
411:                sectionsForDisplay = "";
412:                for (int index = 0; index < sections.size(); index++) {
413:                    if (index == (sections.size() - 1))
414:                        sectionsForDisplay += sections.get(index);
415:                    else
416:                        sectionsForDisplay += sections.get(index) + ", ";
417:                }
418:                return sectionsForDisplay;
419:            }
420:
421:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.