001 //
002 // This file is generated by MetaBoss Ver 1.4.0001 at Thu Dec 15 22:36:54 EST 2005
003 // MetaBoss is Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
004 // Content of this file is Copyright 2000-2005 © Softaris Pty. Ltd. All Rights Reserved.
005 // This content is licensed under Open Source Gnu Public License (GPL)
006 // Full terms and conditions of GPL can be found found at www.gnu.org
007 //
008 package com.almamater.crs.services.coursesdomainsupport.generatedimpl;
009
010 import com.metaboss.enterprise.bo.BOException;
011 import com.metaboss.enterprise.bo.BORecordNotFoundException;
012 import com.metaboss.enterprise.bs.BSException;
013 import com.metaboss.enterprise.bs.BSIllegalArgumentException;
014 import com.metaboss.enterprise.bs.BSDomainObjectInvocationException;
015 import com.metaboss.enterprise.bs.BSUnexpectedProgramConditionException;
016 import com.metaboss.enterprise.bs.BSTransactionServiceInvocationException;
017 import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
018 import com.metaboss.enterprise.bs.impl.BSTransactionUtils;
019 import com.almamater.crs.services.coursesdomainsupport.BSDataManagement;
020
021 /** Implementation of the administration service for the Enterprise/systems[CRS]/domains[Courses] domain */
022 public class BSDataManagementImpl implements BSDataManagement
023 {
024 /** Retrieves count of all Students present in the domain. */
025 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsCountResult getAllStudentsCount(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsCountInput pInput) throws BSException
026 {
027 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsCountResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsCountResult();
028 try
029 {
030 javax.naming.Context lContext = new javax.naming.InitialContext();
031 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
032 lOperationResult.setStudentsCount(lDomain.getAllStudents().size());
033 return lOperationResult;
034 }
035 catch (javax.naming.NamingException e)
036 {
037 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllStudentsCount operation.", e);
038 }
039 catch (BOException e)
040 {
041 throw new BSDomainObjectInvocationException("Unable to complete getAllStudentsCount operation.", e);
042 }
043 }
044 /** Retrieves details of all Students present in the domain. */
045 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsResult getAllStudents(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsInput pInput) throws BSException
046 {
047 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllStudentsResult();
048 try
049 {
050 javax.naming.Context lContext = new javax.naming.InitialContext();
051 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
052 com.almamater.crs.domains.courses.BOStudentCollection lCollection = lDomain.getAllStudents();
053 com.almamater.crs.types.system.courses.StudentOrderingInstruction[] lOrderingInstructions = pInput.getOrderingInstructions();
054 if (lOrderingInstructions != null && lOrderingInstructions.length > 0)
055 {
056 for (int i = 0; i < lOrderingInstructions.length; i++)
057 lCollection = lCollection.sortStudents(lOrderingInstructions[i]);
058 }
059 com.almamater.crs.domains.courses.BOStudent[] lEntities = lCollection.toStudentsArray();
060 lOperationResult.setStudents( TRBOStudent.convertToDetailsStructureArray(lEntities));
061 return lOperationResult;
062 }
063 catch (javax.naming.NamingException e)
064 {
065 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllStudents operation.", e);
066 }
067 catch (BOException e)
068 {
069 throw new BSDomainObjectInvocationException("Unable to complete getAllStudents operation.", e);
070 }
071 }
072 /** Retrieves details of the required subset of Students present in the domain. */
073 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfStudentsResult getSubsetOfStudents(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfStudentsInput pInput) throws BSException
074 {
075 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfStudentsResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfStudentsResult();
076 try
077 {
078 javax.naming.Context lContext = new javax.naming.InitialContext();
079 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
080 com.almamater.crs.domains.courses.BOStudentCollection lCollection = lDomain.getAllStudents();
081 com.almamater.crs.types.system.courses.StudentOrderingInstruction[] lOrderingInstructions = pInput.getOrderingInstructions();
082 if (lOrderingInstructions != null && lOrderingInstructions.length > 0)
083 {
084 for (int i = 0; i < lOrderingInstructions.length; i++)
085 lCollection = lCollection.sortStudents(lOrderingInstructions[i]);
086 }
087 lCollection = lCollection.selectStudents(pInput.getFirstRecordOffset(),pInput.getRequiredMaxSize());
088 com.almamater.crs.domains.courses.BOStudent[] lEntities = lCollection.toStudentsArray();
089 lOperationResult.setStudents( TRBOStudent.convertToDetailsStructureArray(lEntities));
090 return lOperationResult;
091 }
092 catch (javax.naming.NamingException e)
093 {
094 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getSubsetOfStudents operation.", e);
095 }
096 catch (BOException e)
097 {
098 throw new BSDomainObjectInvocationException("Unable to complete getSubsetOfStudents operation.", e);
099 }
100 }
101 /** Retrieves details of a particular Student instance from the domain. Instance is identified by key structure. */
102 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetStudentResult getStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetStudentInput pInput) throws BSException
103 {
104 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetStudentResult();
105 com.almamater.crs.services.coursesdomainsupport.STStudentKey lStudentKey = pInput.getStudentKey();
106 try
107 {
108 javax.naming.Context lContext = new javax.naming.InitialContext();
109 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
110 com.almamater.crs.domains.courses.BOStudent lEntity = TRBOStudent.getBOStudent( lDomain, lStudentKey);
111 lOperationResult.setStudent( TRBOStudent.convertToDetailsStructure(lEntity));
112 return lOperationResult;
113 }
114 catch (javax.naming.NamingException e)
115 {
116 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getStudent operation.", e);
117 }
118 catch (BORecordNotFoundException e)
119 {
120 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Student]"))
121 {
122 com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError();
123 lOperationResult.setStudentNotFoundError(lErrorMessage);
124 return lOperationResult;
125 }
126 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
127 }
128 catch (BOException e)
129 {
130 throw new BSDomainObjectInvocationException("Unable to complete getStudent operation.", e);
131 }
132 }
133 /** Creates new instance of Student in the domain. */
134 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateStudentResult createStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateStudentInput pInput) throws BSException
135 {
136 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateStudentResult();
137 com.almamater.crs.services.coursesdomainsupport.STStudentDetails lProposedDetails = pInput.getProposedDetails();
138 try
139 {
140 javax.naming.Context lContext = new javax.naming.InitialContext();
141 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
142 lDomain.beginEdit();
143 com.almamater.crs.domains.courses.BOStudent lEntity = lDomain.createStudent( lProposedDetails.getStudentNo());
144 if (lProposedDetails.getFirstName() != null)
145 lEntity.setFirstName(lProposedDetails.getFirstName());
146 if (lProposedDetails.getSecondName() != null)
147 lEntity.setSecondName(lProposedDetails.getSecondName());
148 if (lProposedDetails.getFamilyName() != null)
149 lEntity.setFamilyName(lProposedDetails.getFamilyName());
150 if (lProposedDetails.getDateOfBirth() != null)
151 lEntity.setDateOfBirth(lProposedDetails.getDateOfBirth());
152 lOperationResult.setCreatedDetails( TRBOStudent.convertToDetailsStructure(lEntity));
153 return lOperationResult;
154 }
155 catch (javax.naming.NamingException e)
156 {
157 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete createStudent operation.", e);
158 }
159 catch (BOException e)
160 {
161 throw new BSDomainObjectInvocationException("Unable to complete createStudent operation.", e);
162 }
163 }
164 /** Updates existing instance of Student in the domain. */
165 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateStudentResult updateStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateStudentInput pInput) throws BSException
166 {
167 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateStudentResult();
168 com.almamater.crs.services.coursesdomainsupport.STStudentDetails lProposedDetails = pInput.getProposedDetails();
169 try
170 {
171 javax.naming.Context lContext = new javax.naming.InitialContext();
172 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
173 lDomain.beginEdit();
174 com.almamater.crs.domains.courses.BOStudent lEntity = TRBOStudent.getBOStudent( lDomain, lProposedDetails);
175 if (lProposedDetails.getVersionId() != null && lProposedDetails.getVersionId().equals(lEntity.getStudentVersionId()) == false)
176 {
177 com.almamater.crs.services.coursesdomainsupport.MOStudentVersionMismatchError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentVersionMismatchError();
178 lErrorMessage.setExpectedVersionId(lProposedDetails.getVersionId());
179 lErrorMessage.setStoredVersionId(lEntity.getStudentVersionId());
180 lOperationResult.setVersionMismatchError(lErrorMessage);
181 BSTransactionUtils.markCurrentTransactionForRollback();
182 return lOperationResult;
183 }
184 lEntity.beginEdit();
185 if (lProposedDetails.getFirstName() != null)
186 lEntity.setFirstName(lProposedDetails.getFirstName());
187 if (lProposedDetails.getSecondName() != null)
188 lEntity.setSecondName(lProposedDetails.getSecondName());
189 if (lProposedDetails.getFamilyName() != null)
190 lEntity.setFamilyName(lProposedDetails.getFamilyName());
191 if (lProposedDetails.getDateOfBirth() != null)
192 lEntity.setDateOfBirth(lProposedDetails.getDateOfBirth());
193 lOperationResult.setUpdatedDetails( TRBOStudent.convertToDetailsStructure(lEntity));
194 return lOperationResult;
195 }
196 catch (javax.naming.NamingException e)
197 {
198 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete updateStudent operation.", e);
199 }
200 catch (BORecordNotFoundException e)
201 {
202 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Student]"))
203 {
204 com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError();
205 lOperationResult.setStudentNotFoundError(lErrorMessage);
206 BSTransactionUtils.markCurrentTransactionForRollback();
207 return lOperationResult;
208 }
209 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
210 }
211 catch (BOException e)
212 {
213 throw new BSDomainObjectInvocationException("Unable to complete updateStudent operation.", e);
214 }
215 }
216 /** Deletes existing instance of Student in the domain. */
217 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteStudentResult deleteStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteStudentInput pInput) throws BSException
218 {
219 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteStudentResult();
220 com.almamater.crs.services.coursesdomainsupport.STStudentKey lStudentKey = pInput.getStudentKey();
221 try
222 {
223 javax.naming.Context lContext = new javax.naming.InitialContext();
224 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
225 lDomain.beginEdit();
226 com.almamater.crs.domains.courses.BOStudent lEntity = TRBOStudent.getBOStudent( lDomain, lStudentKey);
227 lEntity.delete();
228 return lOperationResult;
229 }
230 catch (javax.naming.NamingException e)
231 {
232 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete deleteStudent operation.", e);
233 }
234 catch (BORecordNotFoundException e)
235 {
236 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Student]"))
237 {
238 com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError();
239 lOperationResult.setStudentNotFoundError(lErrorMessage);
240 return lOperationResult;
241 }
242 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
243 }
244 catch (BOException e)
245 {
246 throw new BSDomainObjectInvocationException("Unable to complete deleteStudent operation.", e);
247 }
248 }
249 /** Retrieves count of all Courses present in the domain. */
250 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesCountResult getAllCoursesCount(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesCountInput pInput) throws BSException
251 {
252 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesCountResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesCountResult();
253 try
254 {
255 javax.naming.Context lContext = new javax.naming.InitialContext();
256 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
257 lOperationResult.setCoursesCount(lDomain.getAllCourses().size());
258 return lOperationResult;
259 }
260 catch (javax.naming.NamingException e)
261 {
262 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllCoursesCount operation.", e);
263 }
264 catch (BOException e)
265 {
266 throw new BSDomainObjectInvocationException("Unable to complete getAllCoursesCount operation.", e);
267 }
268 }
269 /** Retrieves details of all Courses present in the domain. */
270 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesResult getAllCourses(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesInput pInput) throws BSException
271 {
272 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesResult();
273 try
274 {
275 javax.naming.Context lContext = new javax.naming.InitialContext();
276 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
277 com.almamater.crs.domains.courses.BOCourseCollection lCollection = lDomain.getAllCourses();
278 com.almamater.crs.types.system.courses.CourseOrderingInstruction[] lOrderingInstructions = pInput.getOrderingInstructions();
279 if (lOrderingInstructions != null && lOrderingInstructions.length > 0)
280 {
281 for (int i = 0; i < lOrderingInstructions.length; i++)
282 lCollection = lCollection.sortCourses(lOrderingInstructions[i]);
283 }
284 com.almamater.crs.domains.courses.BOCourse[] lEntities = lCollection.toCoursesArray();
285 lOperationResult.setCourses( TRBOCourse.convertToDetailsStructureArray(lEntities));
286 return lOperationResult;
287 }
288 catch (javax.naming.NamingException e)
289 {
290 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllCourses operation.", e);
291 }
292 catch (BOException e)
293 {
294 throw new BSDomainObjectInvocationException("Unable to complete getAllCourses operation.", e);
295 }
296 }
297 /** Retrieves details of the required subset of Courses present in the domain. */
298 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfCoursesResult getSubsetOfCourses(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfCoursesInput pInput) throws BSException
299 {
300 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfCoursesResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfCoursesResult();
301 try
302 {
303 javax.naming.Context lContext = new javax.naming.InitialContext();
304 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
305 com.almamater.crs.domains.courses.BOCourseCollection lCollection = lDomain.getAllCourses();
306 com.almamater.crs.types.system.courses.CourseOrderingInstruction[] lOrderingInstructions = pInput.getOrderingInstructions();
307 if (lOrderingInstructions != null && lOrderingInstructions.length > 0)
308 {
309 for (int i = 0; i < lOrderingInstructions.length; i++)
310 lCollection = lCollection.sortCourses(lOrderingInstructions[i]);
311 }
312 lCollection = lCollection.selectCourses(pInput.getFirstRecordOffset(),pInput.getRequiredMaxSize());
313 com.almamater.crs.domains.courses.BOCourse[] lEntities = lCollection.toCoursesArray();
314 lOperationResult.setCourses( TRBOCourse.convertToDetailsStructureArray(lEntities));
315 return lOperationResult;
316 }
317 catch (javax.naming.NamingException e)
318 {
319 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getSubsetOfCourses operation.", e);
320 }
321 catch (BOException e)
322 {
323 throw new BSDomainObjectInvocationException("Unable to complete getSubsetOfCourses operation.", e);
324 }
325 }
326 /** Retrieves details of a particular Course instance from the domain. Instance is identified by key structure. */
327 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetCourseResult getCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetCourseInput pInput) throws BSException
328 {
329 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetCourseResult();
330 com.almamater.crs.services.coursesdomainsupport.STCourseKey lCourseKey = pInput.getCourseKey();
331 try
332 {
333 javax.naming.Context lContext = new javax.naming.InitialContext();
334 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
335 com.almamater.crs.domains.courses.BOCourse lEntity = TRBOCourse.getBOCourse( lDomain, lCourseKey);
336 lOperationResult.setCourse( TRBOCourse.convertToDetailsStructure(lEntity));
337 return lOperationResult;
338 }
339 catch (javax.naming.NamingException e)
340 {
341 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getCourse operation.", e);
342 }
343 catch (BORecordNotFoundException e)
344 {
345 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
346 {
347 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
348 lOperationResult.setCourseNotFoundError(lErrorMessage);
349 return lOperationResult;
350 }
351 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
352 }
353 catch (BOException e)
354 {
355 throw new BSDomainObjectInvocationException("Unable to complete getCourse operation.", e);
356 }
357 }
358 /** Creates new instance of Course in the domain. */
359 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateCourseResult createCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateCourseInput pInput) throws BSException
360 {
361 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateCourseResult();
362 com.almamater.crs.services.coursesdomainsupport.STCourseDetails lProposedDetails = pInput.getProposedDetails();
363 try
364 {
365 javax.naming.Context lContext = new javax.naming.InitialContext();
366 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
367 lDomain.beginEdit();
368 com.almamater.crs.domains.courses.BOCourse lEntity = lDomain.createCourse( lProposedDetails.getCode());
369 if (lProposedDetails.getName() != null)
370 lEntity.setName(lProposedDetails.getName());
371 if (lProposedDetails.getSupervisor() != null && lProposedDetails.getSupervisor().isEmpty() == false)
372 lEntity.setSupervisor(TRBOTeacher.getBOTeacher( lDomain, lProposedDetails.getSupervisor()));
373 lOperationResult.setCreatedDetails( TRBOCourse.convertToDetailsStructure(lEntity));
374 return lOperationResult;
375 }
376 catch (javax.naming.NamingException e)
377 {
378 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete createCourse operation.", e);
379 }
380 catch (BORecordNotFoundException e)
381 {
382 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
383 {
384 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
385 lOperationResult.setTeacherNotFoundError(lErrorMessage);
386 BSTransactionUtils.markCurrentTransactionForRollback();
387 return lOperationResult;
388 }
389 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
390 }
391 catch (BOException e)
392 {
393 throw new BSDomainObjectInvocationException("Unable to complete createCourse operation.", e);
394 }
395 }
396 /** Updates existing instance of Course in the domain. */
397 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateCourseResult updateCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateCourseInput pInput) throws BSException
398 {
399 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateCourseResult();
400 com.almamater.crs.services.coursesdomainsupport.STCourseDetails lProposedDetails = pInput.getProposedDetails();
401 try
402 {
403 javax.naming.Context lContext = new javax.naming.InitialContext();
404 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
405 lDomain.beginEdit();
406 com.almamater.crs.domains.courses.BOCourse lEntity = TRBOCourse.getBOCourse( lDomain, lProposedDetails);
407 if (lProposedDetails.getVersionId() != null && lProposedDetails.getVersionId().equals(lEntity.getCourseVersionId()) == false)
408 {
409 com.almamater.crs.services.coursesdomainsupport.MOCourseVersionMismatchError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseVersionMismatchError();
410 lErrorMessage.setExpectedVersionId(lProposedDetails.getVersionId());
411 lErrorMessage.setStoredVersionId(lEntity.getCourseVersionId());
412 lOperationResult.setVersionMismatchError(lErrorMessage);
413 BSTransactionUtils.markCurrentTransactionForRollback();
414 return lOperationResult;
415 }
416 lEntity.beginEdit();
417 if (lProposedDetails.getName() != null)
418 lEntity.setName(lProposedDetails.getName());
419 if (lProposedDetails.getSupervisor() != null)
420 {
421 if (!lProposedDetails.getSupervisor().isEmpty())
422 lEntity.setSupervisor(TRBOTeacher.getBOTeacher( lDomain, lProposedDetails.getSupervisor()));
423 else
424 throw new BSIllegalArgumentException("The Supervisor field can not be empty for the updateCourse() operation.");
425 }
426 lOperationResult.setUpdatedDetails( TRBOCourse.convertToDetailsStructure(lEntity));
427 return lOperationResult;
428 }
429 catch (javax.naming.NamingException e)
430 {
431 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete updateCourse operation.", e);
432 }
433 catch (BORecordNotFoundException e)
434 {
435 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
436 {
437 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
438 lOperationResult.setTeacherNotFoundError(lErrorMessage);
439 BSTransactionUtils.markCurrentTransactionForRollback();
440 return lOperationResult;
441 }
442 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
443 {
444 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
445 lOperationResult.setCourseNotFoundError(lErrorMessage);
446 BSTransactionUtils.markCurrentTransactionForRollback();
447 return lOperationResult;
448 }
449 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
450 }
451 catch (BOException e)
452 {
453 throw new BSDomainObjectInvocationException("Unable to complete updateCourse operation.", e);
454 }
455 }
456 /** Deletes existing instance of Course in the domain. */
457 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteCourseResult deleteCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteCourseInput pInput) throws BSException
458 {
459 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteCourseResult();
460 com.almamater.crs.services.coursesdomainsupport.STCourseKey lCourseKey = pInput.getCourseKey();
461 try
462 {
463 javax.naming.Context lContext = new javax.naming.InitialContext();
464 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
465 lDomain.beginEdit();
466 com.almamater.crs.domains.courses.BOCourse lEntity = TRBOCourse.getBOCourse( lDomain, lCourseKey);
467 lEntity.delete();
468 return lOperationResult;
469 }
470 catch (javax.naming.NamingException e)
471 {
472 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete deleteCourse operation.", e);
473 }
474 catch (BORecordNotFoundException e)
475 {
476 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
477 {
478 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
479 lOperationResult.setCourseNotFoundError(lErrorMessage);
480 return lOperationResult;
481 }
482 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
483 }
484 catch (BOException e)
485 {
486 throw new BSDomainObjectInvocationException("Unable to complete deleteCourse operation.", e);
487 }
488 }
489 /** Retrieves count of all Teachers present in the domain. */
490 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersCountResult getAllTeachersCount(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersCountInput pInput) throws BSException
491 {
492 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersCountResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersCountResult();
493 try
494 {
495 javax.naming.Context lContext = new javax.naming.InitialContext();
496 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
497 lOperationResult.setTeachersCount(lDomain.getAllTeachers().size());
498 return lOperationResult;
499 }
500 catch (javax.naming.NamingException e)
501 {
502 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllTeachersCount operation.", e);
503 }
504 catch (BOException e)
505 {
506 throw new BSDomainObjectInvocationException("Unable to complete getAllTeachersCount operation.", e);
507 }
508 }
509 /** Retrieves details of all Teachers present in the domain. */
510 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersResult getAllTeachers(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersInput pInput) throws BSException
511 {
512 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllTeachersResult();
513 try
514 {
515 javax.naming.Context lContext = new javax.naming.InitialContext();
516 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
517 com.almamater.crs.domains.courses.BOTeacherCollection lCollection = lDomain.getAllTeachers();
518 com.almamater.crs.types.system.courses.TeacherOrderingInstruction[] lOrderingInstructions = pInput.getOrderingInstructions();
519 if (lOrderingInstructions != null && lOrderingInstructions.length > 0)
520 {
521 for (int i = 0; i < lOrderingInstructions.length; i++)
522 lCollection = lCollection.sortTeachers(lOrderingInstructions[i]);
523 }
524 com.almamater.crs.domains.courses.BOTeacher[] lEntities = lCollection.toTeachersArray();
525 lOperationResult.setTeachers( TRBOTeacher.convertToDetailsStructureArray(lEntities));
526 return lOperationResult;
527 }
528 catch (javax.naming.NamingException e)
529 {
530 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllTeachers operation.", e);
531 }
532 catch (BOException e)
533 {
534 throw new BSDomainObjectInvocationException("Unable to complete getAllTeachers operation.", e);
535 }
536 }
537 /** Retrieves details of the required subset of Teachers present in the domain. */
538 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfTeachersResult getSubsetOfTeachers(com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfTeachersInput pInput) throws BSException
539 {
540 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfTeachersResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetSubsetOfTeachersResult();
541 try
542 {
543 javax.naming.Context lContext = new javax.naming.InitialContext();
544 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
545 com.almamater.crs.domains.courses.BOTeacherCollection lCollection = lDomain.getAllTeachers();
546 com.almamater.crs.types.system.courses.TeacherOrderingInstruction[] lOrderingInstructions = pInput.getOrderingInstructions();
547 if (lOrderingInstructions != null && lOrderingInstructions.length > 0)
548 {
549 for (int i = 0; i < lOrderingInstructions.length; i++)
550 lCollection = lCollection.sortTeachers(lOrderingInstructions[i]);
551 }
552 lCollection = lCollection.selectTeachers(pInput.getFirstRecordOffset(),pInput.getRequiredMaxSize());
553 com.almamater.crs.domains.courses.BOTeacher[] lEntities = lCollection.toTeachersArray();
554 lOperationResult.setTeachers( TRBOTeacher.convertToDetailsStructureArray(lEntities));
555 return lOperationResult;
556 }
557 catch (javax.naming.NamingException e)
558 {
559 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getSubsetOfTeachers operation.", e);
560 }
561 catch (BOException e)
562 {
563 throw new BSDomainObjectInvocationException("Unable to complete getSubsetOfTeachers operation.", e);
564 }
565 }
566 /** Retrieves details of a particular Teacher instance from the domain. Instance is identified by key structure. */
567 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetTeacherResult getTeacher( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetTeacherInput pInput) throws BSException
568 {
569 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetTeacherResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetTeacherResult();
570 com.almamater.crs.services.coursesdomainsupport.STTeacherKey lTeacherKey = pInput.getTeacherKey();
571 try
572 {
573 javax.naming.Context lContext = new javax.naming.InitialContext();
574 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
575 com.almamater.crs.domains.courses.BOTeacher lEntity = TRBOTeacher.getBOTeacher( lDomain, lTeacherKey);
576 lOperationResult.setTeacher( TRBOTeacher.convertToDetailsStructure(lEntity));
577 return lOperationResult;
578 }
579 catch (javax.naming.NamingException e)
580 {
581 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getTeacher operation.", e);
582 }
583 catch (BORecordNotFoundException e)
584 {
585 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
586 {
587 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
588 lOperationResult.setTeacherNotFoundError(lErrorMessage);
589 return lOperationResult;
590 }
591 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
592 }
593 catch (BOException e)
594 {
595 throw new BSDomainObjectInvocationException("Unable to complete getTeacher operation.", e);
596 }
597 }
598 /** Creates new instance of Teacher in the domain. */
599 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateTeacherResult createTeacher( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateTeacherInput pInput) throws BSException
600 {
601 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateTeacherResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STCreateTeacherResult();
602 com.almamater.crs.services.coursesdomainsupport.STTeacherDetails lProposedDetails = pInput.getProposedDetails();
603 try
604 {
605 javax.naming.Context lContext = new javax.naming.InitialContext();
606 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
607 lDomain.beginEdit();
608 com.almamater.crs.domains.courses.BOTeacher lEntity = lDomain.createTeacher();
609 if (lProposedDetails.getFirstName() != null)
610 lEntity.setFirstName(lProposedDetails.getFirstName());
611 if (lProposedDetails.getSecondName() != null)
612 lEntity.setSecondName(lProposedDetails.getSecondName());
613 if (lProposedDetails.getFamilyName() != null)
614 lEntity.setFamilyName(lProposedDetails.getFamilyName());
615 lOperationResult.setCreatedDetails( TRBOTeacher.convertToDetailsStructure(lEntity));
616 return lOperationResult;
617 }
618 catch (javax.naming.NamingException e)
619 {
620 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete createTeacher operation.", e);
621 }
622 catch (BOException e)
623 {
624 throw new BSDomainObjectInvocationException("Unable to complete createTeacher operation.", e);
625 }
626 }
627 /** Updates existing instance of Teacher in the domain. */
628 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateTeacherResult updateTeacher( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateTeacherInput pInput) throws BSException
629 {
630 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateTeacherResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STUpdateTeacherResult();
631 com.almamater.crs.services.coursesdomainsupport.STTeacherDetails lProposedDetails = pInput.getProposedDetails();
632 try
633 {
634 javax.naming.Context lContext = new javax.naming.InitialContext();
635 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
636 lDomain.beginEdit();
637 com.almamater.crs.domains.courses.BOTeacher lEntity = TRBOTeacher.getBOTeacher( lDomain, lProposedDetails);
638 if (lProposedDetails.getVersionId() != null && lProposedDetails.getVersionId().equals(lEntity.getTeacherVersionId()) == false)
639 {
640 com.almamater.crs.services.coursesdomainsupport.MOTeacherVersionMismatchError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherVersionMismatchError();
641 lErrorMessage.setExpectedVersionId(lProposedDetails.getVersionId());
642 lErrorMessage.setStoredVersionId(lEntity.getTeacherVersionId());
643 lOperationResult.setVersionMismatchError(lErrorMessage);
644 BSTransactionUtils.markCurrentTransactionForRollback();
645 return lOperationResult;
646 }
647 lEntity.beginEdit();
648 if (lProposedDetails.getFirstName() != null)
649 lEntity.setFirstName(lProposedDetails.getFirstName());
650 if (lProposedDetails.getSecondName() != null)
651 lEntity.setSecondName(lProposedDetails.getSecondName());
652 if (lProposedDetails.getFamilyName() != null)
653 lEntity.setFamilyName(lProposedDetails.getFamilyName());
654 lOperationResult.setUpdatedDetails( TRBOTeacher.convertToDetailsStructure(lEntity));
655 return lOperationResult;
656 }
657 catch (javax.naming.NamingException e)
658 {
659 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete updateTeacher operation.", e);
660 }
661 catch (BORecordNotFoundException e)
662 {
663 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
664 {
665 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
666 lOperationResult.setTeacherNotFoundError(lErrorMessage);
667 BSTransactionUtils.markCurrentTransactionForRollback();
668 return lOperationResult;
669 }
670 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
671 }
672 catch (BOException e)
673 {
674 throw new BSDomainObjectInvocationException("Unable to complete updateTeacher operation.", e);
675 }
676 }
677 /** Deletes existing instance of Teacher in the domain. */
678 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteTeacherResult deleteTeacher( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteTeacherInput pInput) throws BSException
679 {
680 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteTeacherResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STDeleteTeacherResult();
681 com.almamater.crs.services.coursesdomainsupport.STTeacherKey lTeacherKey = pInput.getTeacherKey();
682 try
683 {
684 javax.naming.Context lContext = new javax.naming.InitialContext();
685 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
686 lDomain.beginEdit();
687 com.almamater.crs.domains.courses.BOTeacher lEntity = TRBOTeacher.getBOTeacher( lDomain, lTeacherKey);
688 lEntity.delete();
689 return lOperationResult;
690 }
691 catch (javax.naming.NamingException e)
692 {
693 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete deleteTeacher operation.", e);
694 }
695 catch (BORecordNotFoundException e)
696 {
697 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
698 {
699 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
700 lOperationResult.setTeacherNotFoundError(lErrorMessage);
701 return lOperationResult;
702 }
703 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
704 }
705 catch (BOException e)
706 {
707 throw new BSDomainObjectInvocationException("Unable to complete deleteTeacher operation.", e);
708 }
709 }
710
711 /** Adds one or more Lecturers to the specified Course instance. */
712 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddLecturersToCourseResult addLecturersToCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddLecturersToCourseInput pInput) throws BSException
713 {
714 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddLecturersToCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddLecturersToCourseResult();
715 com.almamater.crs.services.coursesdomainsupport.STCourseKey lCourseKey = pInput.getCourseKey();
716 com.almamater.crs.services.coursesdomainsupport.STTeacherKey[] lLecturerKeys = pInput.getLecturerKeys();
717 try
718 {
719 javax.naming.Context lContext = new javax.naming.InitialContext();
720 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
721 lDomain.beginEdit();
722 com.almamater.crs.domains.courses.BOCourse lCourse = TRBOCourse.getBOCourse( lDomain, lCourseKey);
723 lCourse.beginEdit();
724 for (int i = 0; i < lLecturerKeys.length; i++)
725 {
726 com.almamater.crs.domains.courses.BOTeacher lLecturer = TRBOTeacher.getBOTeacher( lDomain, lLecturerKeys[i]);
727 lCourse.addLecturer(lLecturer);
728 }
729 return lOperationResult;
730 }
731 catch (javax.naming.NamingException e)
732 {
733 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete addLecturersToCourse operation.", e);
734 }
735 catch (BORecordNotFoundException e)
736 {
737 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
738 {
739 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
740 lOperationResult.setTeacherNotFoundError(lErrorMessage);
741 return lOperationResult;
742 }
743 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
744 {
745 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
746 lOperationResult.setCourseNotFoundError(lErrorMessage);
747 return lOperationResult;
748 }
749 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
750 }
751 catch (BOException e)
752 {
753 throw new BSDomainObjectInvocationException("Unable to complete addLecturersToCourse operation.", e);
754 }
755 }
756
757 /** Removes one or more Lecturers from the specified Course instance. */
758 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveLecturersFromCourseResult removeLecturersFromCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveLecturersFromCourseInput pInput) throws BSException
759 {
760 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveLecturersFromCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveLecturersFromCourseResult();
761 com.almamater.crs.services.coursesdomainsupport.STCourseKey lCourseKey = pInput.getCourseKey();
762 com.almamater.crs.services.coursesdomainsupport.STTeacherKey[] lLecturerKeys = pInput.getLecturerKeys();
763 try
764 {
765 javax.naming.Context lContext = new javax.naming.InitialContext();
766 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
767 lDomain.beginEdit();
768 com.almamater.crs.domains.courses.BOCourse lCourse = TRBOCourse.getBOCourse( lDomain, lCourseKey);
769 lCourse.beginEdit();
770 for (int i = 0; i < lLecturerKeys.length; i++)
771 {
772 com.almamater.crs.domains.courses.BOTeacher lLecturer = TRBOTeacher.getBOTeacher( lDomain, lLecturerKeys[i]);
773 lCourse.removeLecturer(lLecturer);
774 }
775 return lOperationResult;
776 }
777 catch (javax.naming.NamingException e)
778 {
779 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete removeLecturersFromCourse operation.", e);
780 }
781 catch (BORecordNotFoundException e)
782 {
783 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Teacher]"))
784 {
785 com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOTeacherInstanceNotFoundError();
786 lOperationResult.setTeacherNotFoundError(lErrorMessage);
787 return lOperationResult;
788 }
789 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
790 {
791 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
792 lOperationResult.setCourseNotFoundError(lErrorMessage);
793 return lOperationResult;
794 }
795 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
796 }
797 catch (BOException e)
798 {
799 throw new BSDomainObjectInvocationException("Unable to complete removeLecturersFromCourse operation.", e);
800 }
801 }
802
803 /** Returns all Lecturers associated with the specified Course instance. */
804 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllLecturersForCourseResult getAllLecturersForCourse( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllLecturersForCourseInput pInput) throws BSException
805 {
806 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllLecturersForCourseResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllLecturersForCourseResult();
807 com.almamater.crs.services.coursesdomainsupport.STCourseKey lCourseKey = pInput.getCourseKey();
808 try
809 {
810 javax.naming.Context lContext = new javax.naming.InitialContext();
811 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
812 com.almamater.crs.domains.courses.BOCourse lCourse = TRBOCourse.getBOCourse( lDomain, lCourseKey);
813 com.almamater.crs.domains.courses.BOTeacher[] lLecturers = lCourse.getLecturers().toTeachersArray();
814 lOperationResult.setLecturers( TRBOTeacher.convertToDetailsStructureArray(lLecturers));
815 return lOperationResult;
816 }
817 catch (javax.naming.NamingException e)
818 {
819 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllLecturersForCourse operation.", e);
820 }
821 catch (BORecordNotFoundException e)
822 {
823 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
824 {
825 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
826 lOperationResult.setCourseNotFoundError(lErrorMessage);
827 return lOperationResult;
828 }
829 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
830 }
831 catch (BOException e)
832 {
833 throw new BSDomainObjectInvocationException("Unable to complete getAllLecturersForCourse operation.", e);
834 }
835 }
836
837 /** Adds one or more Courses to the specified Student instance. */
838 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddCoursesToStudentResult addCoursesToStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddCoursesToStudentInput pInput) throws BSException
839 {
840 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddCoursesToStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STAddCoursesToStudentResult();
841 com.almamater.crs.services.coursesdomainsupport.STStudentKey lStudentKey = pInput.getStudentKey();
842 com.almamater.crs.services.coursesdomainsupport.STCourseKey[] lCourseKeys = pInput.getCourseKeys();
843 try
844 {
845 javax.naming.Context lContext = new javax.naming.InitialContext();
846 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
847 lDomain.beginEdit();
848 com.almamater.crs.domains.courses.BOStudent lStudent = TRBOStudent.getBOStudent( lDomain, lStudentKey);
849 lStudent.beginEdit();
850 for (int i = 0; i < lCourseKeys.length; i++)
851 {
852 com.almamater.crs.domains.courses.BOCourse lCourse = TRBOCourse.getBOCourse( lDomain, lCourseKeys[i]);
853 lStudent.addCourse(lCourse);
854 }
855 return lOperationResult;
856 }
857 catch (javax.naming.NamingException e)
858 {
859 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete addCoursesToStudent operation.", e);
860 }
861 catch (BORecordNotFoundException e)
862 {
863 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Student]"))
864 {
865 com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError();
866 lOperationResult.setStudentNotFoundError(lErrorMessage);
867 return lOperationResult;
868 }
869 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
870 {
871 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
872 lOperationResult.setCourseNotFoundError(lErrorMessage);
873 return lOperationResult;
874 }
875 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
876 }
877 catch (BOException e)
878 {
879 throw new BSDomainObjectInvocationException("Unable to complete addCoursesToStudent operation.", e);
880 }
881 }
882
883 /** Removes one or more Courses from the specified Student instance. */
884 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveCoursesFromStudentResult removeCoursesFromStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveCoursesFromStudentInput pInput) throws BSException
885 {
886 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveCoursesFromStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STRemoveCoursesFromStudentResult();
887 com.almamater.crs.services.coursesdomainsupport.STStudentKey lStudentKey = pInput.getStudentKey();
888 com.almamater.crs.services.coursesdomainsupport.STCourseKey[] lCourseKeys = pInput.getCourseKeys();
889 try
890 {
891 javax.naming.Context lContext = new javax.naming.InitialContext();
892 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
893 lDomain.beginEdit();
894 com.almamater.crs.domains.courses.BOStudent lStudent = TRBOStudent.getBOStudent( lDomain, lStudentKey);
895 lStudent.beginEdit();
896 for (int i = 0; i < lCourseKeys.length; i++)
897 {
898 com.almamater.crs.domains.courses.BOCourse lCourse = TRBOCourse.getBOCourse( lDomain, lCourseKeys[i]);
899 lStudent.removeCourse(lCourse);
900 }
901 return lOperationResult;
902 }
903 catch (javax.naming.NamingException e)
904 {
905 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete removeCoursesFromStudent operation.", e);
906 }
907 catch (BORecordNotFoundException e)
908 {
909 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Student]"))
910 {
911 com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError();
912 lOperationResult.setStudentNotFoundError(lErrorMessage);
913 return lOperationResult;
914 }
915 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Course]"))
916 {
917 com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOCourseInstanceNotFoundError();
918 lOperationResult.setCourseNotFoundError(lErrorMessage);
919 return lOperationResult;
920 }
921 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
922 }
923 catch (BOException e)
924 {
925 throw new BSDomainObjectInvocationException("Unable to complete removeCoursesFromStudent operation.", e);
926 }
927 }
928
929 /** Returns all Courses associated with the specified Student instance. */
930 public com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesForStudentResult getAllCoursesForStudent( com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesForStudentInput pInput) throws BSException
931 {
932 com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesForStudentResult lOperationResult = new com.almamater.crs.services.coursesdomainsupport.BSDataManagement.STGetAllCoursesForStudentResult();
933 com.almamater.crs.services.coursesdomainsupport.STStudentKey lStudentKey = pInput.getStudentKey();
934 try
935 {
936 javax.naming.Context lContext = new javax.naming.InitialContext();
937 com.almamater.crs.domains.courses.BODomain lDomain = (com.almamater.crs.domains.courses.BODomain)lContext.lookup(com.almamater.crs.domains.courses.BODomain.COMPONENT_URL);
938 com.almamater.crs.domains.courses.BOStudent lStudent = TRBOStudent.getBOStudent( lDomain, lStudentKey);
939 com.almamater.crs.domains.courses.BOCourse[] lCourses = lStudent.getCourses().toCoursesArray();
940 lOperationResult.setCourses( TRBOCourse.convertToDetailsStructureArray(lCourses));
941 return lOperationResult;
942 }
943 catch (javax.naming.NamingException e)
944 {
945 throw new BSNamingAndDirectoryServiceInvocationException("Unable to complete getAllCoursesForStudent operation.", e);
946 }
947 catch (BORecordNotFoundException e)
948 {
949 if (e.getRecordType().equals("Enterprise/systems[CRS]/domains[Courses]/entities[Student]"))
950 {
951 com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError lErrorMessage = new com.almamater.crs.services.coursesdomainsupport.MOStudentInstanceNotFoundError();
952 lOperationResult.setStudentNotFoundError(lErrorMessage);
953 return lOperationResult;
954 }
955 throw new BSUnexpectedProgramConditionException("Caught unexpected exception.",e);
956 }
957 catch (BOException e)
958 {
959 throw new BSDomainObjectInvocationException("Unable to complete getAllCoursesForStudent operation.", e);
960 }
961 }
962 }
|