Source Code Cross Referenced for BSMiscellaneousQueriesImpl.java in  » UML » MetaBoss » com » almamater » crs » services » reporting » impl » 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 » UML » MetaBoss » com.almamater.crs.services.reporting.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.almamater.crs.services.reporting.impl;
002:
003:        import java.util.Arrays;
004:        import java.util.HashSet;
005:        import java.util.Set;
006:
007:        import javax.naming.Context;
008:        import javax.naming.InitialContext;
009:
010:        import org.apache.commons.logging.Log;
011:        import org.apache.commons.logging.LogFactory;
012:
013:        import com.almamater.crs.domains.courses.BOCourseCollection;
014:        import com.almamater.crs.domains.courses.BODomain;
015:        import com.almamater.crs.domains.courses.BOStudent;
016:        import com.almamater.crs.domains.courses.BOStudentCollection;
017:        import com.almamater.crs.domains.courses.BOTeacher;
018:        import com.almamater.crs.domains.courses.BOTeacherCollection;
019:        import com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError;
020:        import com.almamater.crs.services.coursesdomainsupport.STStudentDetails;
021:        import com.almamater.crs.services.coursesdomainsupport.STStudentKey;
022:        import com.almamater.crs.services.coursesdomainsupport.STTeacherDetails;
023:        import com.almamater.crs.services.coursesdomainsupport.generatedimpl.TRBOStudent;
024:        import com.almamater.crs.services.coursesdomainsupport.generatedimpl.TRBOTeacher;
025:        import com.almamater.crs.services.reporting.BSMiscellaneousQueries;
026:        import com.metaboss.enterprise.bo.BOException;
027:        import com.metaboss.enterprise.bo.BORecordNotFoundException;
028:        import com.metaboss.enterprise.bs.BSDomainObjectInvocationException;
029:        import com.metaboss.enterprise.bs.BSException;
030:        import com.metaboss.enterprise.bs.BSIllegalArgumentException;
031:        import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
032:
033:        /** This class contains handcoded 'real' implementation of the services, which uses 
034:         *  domain objects from the com.almamater.crs.domains.courses package. Similarly to other implementations
035:         *  this one is required to implement corresponding interface. In our case it is the
036:         *  com.almamater.crs.services.reporting.BSMiscellaneousQueries interface. */
037:        public class BSMiscellaneousQueriesImpl implements 
038:                com.almamater.crs.services.reporting.BSMiscellaneousQueries {
039:            private static final Log sLogger = LogFactory
040:                    .getLog(BSMiscellaneousQueriesImpl.class);
041:
042:            /** Constructor. Has package visibility. Instances of this class must be created via object factory class located in the same package */
043:            BSMiscellaneousQueriesImpl(java.util.Hashtable pEnvironment)
044:                    throws Exception {
045:            }
046:
047:            /** Implementation of the method */
048:            public BSMiscellaneousQueries.STFindFreeTeachersResult findFreeTeachers(
049:                    BSMiscellaneousQueries.STFindFreeTeachersInput pInput)
050:                    throws BSException {
051:                // Precreate the result structure ahead of processing
052:                BSMiscellaneousQueries.STFindFreeTeachersResult lOperationResult = new BSMiscellaneousQueries.STFindFreeTeachersResult();
053:                try {
054:                    // ===== Section 1
055:                    // Obtain the courses domain object via JNDI. This object acts as an entry point
056:                    // to the database navigation and modification operations  
057:                    Context lContext = new InitialContext();
058:                    BODomain lDomain = (BODomain) lContext
059:                            .lookup(BODomain.COMPONENT_URL);
060:
061:                    // ===== Section 2
062:                    // Build query as follows
063:                    // 1. Find all busy Teachers by combining all Course Supervisors with all Course Lecturers
064:                    BOCourseCollection lAllCourses = lDomain.getAllCourses();
065:                    BOTeacherCollection lAllCourseSupervisors = lAllCourses
066:                            .getAllSupervisors();
067:                    BOTeacherCollection lAllCourseLecturers = lAllCourses
068:                            .getAllLecturers();
069:                    BOTeacherCollection lAllAllocatedTeachers = lAllCourseSupervisors
070:                            .union(lAllCourseLecturers);
071:
072:                    // 2. Find all free Teachers by finding a difference between
073:                    // collection of all Teachers and the collection of busy Teachers
074:                    BOTeacherCollection lAllTeachers = lDomain.getAllTeachers();
075:                    BOTeacherCollection lAllFreeTeachers = lAllTeachers
076:                            .difference(lAllAllocatedTeachers);
077:
078:                    // ===== Section 3
079:                    // Now that query is built, obtain the result as follows
080:                    // 1. Obtain the resulting array of Teacher domain objects,
081:                    BOTeacher[] lResultTeacherObjectArray = lAllFreeTeachers
082:                            .toTeachersArray();
083:
084:                    // 2. Convert to array of Teacher detail structures using generated helper class
085:                    STTeacherDetails[] lResultTeacherDetailsArray = TRBOTeacher
086:                            .convertToDetailsStructureArray(lResultTeacherObjectArray);
087:
088:                    // 3. Populate the operation result structure
089:                    lOperationResult
090:                            .setFreeTeachers(lResultTeacherDetailsArray);
091:
092:                    // That's all			
093:                    return lOperationResult; // Returning the result structure containing required data 
094:                } catch (javax.naming.NamingException e) {
095:                    throw new BSNamingAndDirectoryServiceInvocationException(
096:                            "Unable to complete findFreeTeachers operation.", e);
097:                } catch (BOException e) {
098:                    throw new BSDomainObjectInvocationException(
099:                            "Unable to complete findFreeTeachers operation.", e);
100:                }
101:            }
102:
103:            /** Implementation of the method */
104:            public BSMiscellaneousQueries.STFindStudentAcquaintancesResult findStudentAcquaintances(
105:                    BSMiscellaneousQueries.STFindStudentAcquaintancesInput pInput)
106:                    throws BSException {
107:                // Extract the student identification form the input
108:                STStudentKey lStudentKey = pInput.getStudent();
109:                if (lStudentKey == null)
110:                    throw new BSIllegalArgumentException(
111:                            "StudentKey parameter can not be null when invoking findStudentAcquaintances() operation.");
112:
113:                // Precreate the result structure ahead of processing
114:                BSMiscellaneousQueries.STFindStudentAcquaintancesResult lOperationResult = new BSMiscellaneousQueries.STFindStudentAcquaintancesResult();
115:                try {
116:                    // ===== Section 1
117:                    // Obtain the courses domain object via JNDI. This object acts as an entry point
118:                    // to the database navigation and modification operations  
119:                    Context lContext = new InitialContext();
120:                    BODomain lDomain = (BODomain) lContext
121:                            .lookup(BODomain.COMPONENT_URL);
122:
123:                    // ===== Section 2
124:                    // Obtain an instance of the student using generated helper class
125:                    // Cater for the possibility that the studen may not be found
126:                    BOStudent lStudent = null;
127:                    try {
128:                        lStudent = TRBOStudent.getBOStudent(lDomain,
129:                                lStudentKey);
130:                    } catch (BORecordNotFoundException e) {
131:                        // Specified Student has not been found. Build and return error message result
132:                        MOStudentInstanceNotFoundError lErrorMessage = new MOStudentInstanceNotFoundError();
133:                        lOperationResult.setStudentNotFoundError(lErrorMessage);
134:                        return lOperationResult; // Returning the result structure containing error message 
135:                    }
136:
137:                    // ===== Section 3
138:                    // Build queries as follows
139:                    // 1. Find all Courses our Student is enrolled in
140:                    BOCourseCollection lAllStudentCourses = lStudent
141:                            .getCourses();
142:
143:                    // 2. Find Teacher Acquaintances as a combination of all Lecturers and Supervisors for the Courses our sudent is enrolled in
144:                    BOTeacherCollection lAllCourseSupervisors = lAllStudentCourses
145:                            .getAllSupervisors();
146:                    BOTeacherCollection lAllCourseLecturers = lAllStudentCourses
147:                            .getAllLecturers();
148:                    BOTeacherCollection lAllTeacherAcquaintances = lAllCourseSupervisors
149:                            .union(lAllCourseLecturers);
150:
151:                    // 3. Find Student Acquaintances as a combination of all Students enrolled in the Courses our sudent is enrolled in
152:                    BOStudentCollection lAllCourseAttendees = lAllStudentCourses
153:                            .getAllAttendees();
154:
155:                    // ===== Section 3
156:                    // Now that queries are built, obtain the teachers result as follows
157:                    // 1. Obtain the resulting array of Teachers
158:                    BOTeacher[] lResultTeacherObjectArray = lAllTeacherAcquaintances
159:                            .toTeachersArray();
160:
161:                    // 2. Convert to array of Teacher detail structures using generated helper class
162:                    STTeacherDetails[] lResultTeacherDetailsArray = TRBOTeacher
163:                            .convertToDetailsStructureArray(lResultTeacherObjectArray);
164:
165:                    // 3. Populate the operation result structure
166:                    lOperationResult.setTeachers(lResultTeacherDetailsArray);
167:
168:                    // ===== Section 4
169:                    // Now that queries are built, obtain the students result as follows
170:                    // 1. Obtain the resulting array of Student attendees
171:                    BOStudent[] lAllCourseAttendeesObjectArray = lAllCourseAttendees
172:                            .toStudentsArray();
173:
174:                    // 2. Exclude the student himself/herself from the list of all attendees, using HashSet facilities
175:                    Set lTempSet = new HashSet(Arrays
176:                            .asList(lAllCourseAttendeesObjectArray));
177:                    lTempSet.remove(lStudent);
178:                    BOStudent[] lResultStudentsObjectArray = (BOStudent[]) lTempSet
179:                            .toArray(new BOStudent[lTempSet.size()]);
180:
181:                    // 3. Convert to array of Student detail structures using generated helper class
182:                    STStudentDetails[] lResultStudentDetailsArray = TRBOStudent
183:                            .convertToDetailsStructureArray(lResultStudentsObjectArray);
184:
185:                    // 4. Populate the operation result structure
186:                    lOperationResult.setStudents(lResultStudentDetailsArray);
187:
188:                    // That's all			
189:                    return lOperationResult; // Returning the result structure containing required data 
190:                } catch (javax.naming.NamingException e) {
191:                    throw new BSNamingAndDirectoryServiceInvocationException(
192:                            "Unable to complete findStudentAcquaintances operation.",
193:                            e);
194:                } catch (BOException e) {
195:                    throw new BSDomainObjectInvocationException(
196:                            "Unable to complete findStudentAcquaintances operation.",
197:                            e);
198:                }
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.