Coverage Report - org.kuali.student.enrollment.classII.courseoffering.service.CourseOfferingServiceMockImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseOfferingServiceMockImpl
0%
0/278
0%
0/98
1.984
 
 1  
 package org.kuali.student.enrollment.classII.courseoffering.service;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.HashMap;
 5  
 import java.util.List;
 6  
 import java.util.Map;
 7  
 
 8  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 9  
 import org.kuali.student.r2.core.statement.dto.StatementTreeViewInfo;
 10  
 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
 11  
 import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
 12  
 import org.kuali.student.enrollment.courseoffering.dto.OfferingInstructorInfo;
 13  
 import org.kuali.student.enrollment.courseoffering.dto.RegistrationGroupInfo;
 14  
 import org.kuali.student.enrollment.courseoffering.dto.SeatPoolDefinitionInfo;
 15  
 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
 16  
 import org.kuali.student.enrollment.courseoffering.service.R1ToR2CopyHelper;
 17  
 import org.kuali.student.enrollment.courseregistration.dto.CourseRegistrationInfo;
 18  
 import org.kuali.student.lum.course.dto.CourseInfo;
 19  
 import org.kuali.student.lum.course.dto.FormatInfo;
 20  
 import org.kuali.student.lum.course.service.CourseService;
 21  
 import org.kuali.student.r2.common.dto.ContextInfo;
 22  
 import org.kuali.student.r2.common.dto.StatusInfo;
 23  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 24  
 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
 25  
 import org.kuali.student.r2.common.exceptions.CircularReferenceException;
 26  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 27  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 28  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 29  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 30  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 31  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 32  
 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
 33  
 import org.kuali.student.r2.core.type.dto.TypeInfo;
 34  
 
 35  
 public class CourseOfferingServiceMockImpl implements CourseOfferingService {
 36  
 
 37  0
     private static Map<String, CourseOfferingInfo> courseOfferingCache = new HashMap<String, CourseOfferingInfo>();
 38  0
     private static Map<String, ActivityOfferingInfo> activityOfferingCache = new HashMap<String, ActivityOfferingInfo>();
 39  0
     private static Map<String, List<ActivityOfferingInfo>> courseToActivityOfferingCache = new HashMap<String, List<ActivityOfferingInfo>>();
 40  0
     private static Map<String, List<RegistrationGroupInfo>> courseToRegGroupCache = new HashMap<String, List<RegistrationGroupInfo>>();
 41  0
     private static Map<String, RegistrationGroupInfo> registrationGroupCache = new HashMap<String, RegistrationGroupInfo>();
 42  0
     private static Map<String, CourseInfo> courseCache = new HashMap<String, CourseInfo>();
 43  0
     private static Map<String, TypeInfo> typesCache = new HashMap<String, TypeInfo>();
 44  0
     private static Map<String, SeatPoolDefinitionInfo> seatPoolDefinitionCache = new HashMap<String, SeatPoolDefinitionInfo>();
 45  
     private CourseService courseService;
 46  
 
 47  0
     public CourseOfferingServiceMockImpl() {
 48  0
         loadCaches();
 49  0
     }
 50  
 
 51  
     private void loadCaches() {
 52  0
         CourseOfferingInfo courseOfferingInfo = new CourseOfferingInfo();
 53  0
         courseOfferingInfo.setCourseId("101");
 54  0
         courseOfferingInfo.setId("PHYS121");
 55  0
         courseOfferingInfo.setCourseOfferingCode("PHYS121");
 56  0
         courseOfferingInfo.setSubjectArea("PHYS");
 57  0
         courseOfferingInfo.setCourseTitle("Fundamentals of Physics I");
 58  0
         org.kuali.student.r2.common.dto.RichTextInfo desc = new org.kuali.student.r2.common.dto.RichTextInfo();
 59  0
         desc.setPlain("Fundamentals of Physics");
 60  0
         courseOfferingInfo.setDescr(desc);
 61  0
         courseOfferingInfo.setCourseNumberSuffix("PHY");
 62  0
         courseOfferingInfo.setHasFinalExam(Boolean.TRUE);
 63  0
         courseOfferingInfo.setIsHonorsOffering(Boolean.TRUE);
 64  0
         courseOfferingInfo.setTermId("201108");
 65  
 
 66  0
         courseOfferingCache.put(courseOfferingInfo.getId(), courseOfferingInfo);
 67  
 
 68  0
         CourseOfferingInfo courseOfferingInfo1 = new CourseOfferingInfo();
 69  0
         courseOfferingInfo1.setCourseId("102");
 70  0
         courseOfferingInfo1.setId("PHYS122");
 71  0
         courseOfferingInfo1.setCourseOfferingCode("PHYS122");
 72  0
         courseOfferingInfo.setSubjectArea("PHYS");
 73  0
         courseOfferingInfo1.setCourseTitle("Fundamentals of Physics II");
 74  0
         desc = new org.kuali.student.r2.common.dto.RichTextInfo();
 75  0
         desc.setPlain("Fundamentals of Physics");
 76  0
         courseOfferingInfo1.setDescr(desc);
 77  0
         courseOfferingInfo1.setCourseNumberSuffix("PHY");
 78  0
         courseOfferingInfo1.setHasFinalExam(Boolean.TRUE);
 79  0
         courseOfferingInfo1.setIsHonorsOffering(Boolean.TRUE);
 80  0
         courseOfferingInfo1.setTermId("201108");
 81  
 
 82  0
         courseOfferingCache.put(courseOfferingInfo1.getId(), courseOfferingInfo1);
 83  
 
 84  0
         CourseOfferingInfo courseOfferingInfo2 = new CourseOfferingInfo();
 85  0
         courseOfferingInfo2.setCourseId("103");
 86  0
         courseOfferingInfo2.setId("PHYS123");
 87  0
         courseOfferingInfo2.setCourseOfferingCode("PHYS123");
 88  0
         courseOfferingInfo.setSubjectArea("PHYS");
 89  0
         courseOfferingInfo2.setCourseTitle("Advanced Physics I");
 90  0
         desc = new org.kuali.student.r2.common.dto.RichTextInfo();
 91  0
         desc.setPlain("Advanced Physics");
 92  0
         courseOfferingInfo2.setDescr(desc);
 93  0
         courseOfferingInfo2.setCourseNumberSuffix("PHY");
 94  0
         courseOfferingInfo2.setHasFinalExam(Boolean.TRUE);
 95  0
         courseOfferingInfo2.setIsHonorsOffering(Boolean.TRUE);
 96  0
         courseOfferingInfo2.setTermId("201108");
 97  
 
 98  0
         courseOfferingCache.put(courseOfferingInfo2.getId(), courseOfferingInfo2);
 99  0
     }
 100  
 
 101  
     public CourseService getCourseService() {
 102  0
         return courseService;
 103  
     }
 104  
 
 105  
     public void setCourseService(CourseService courseService) {
 106  0
         this.courseService = courseService;
 107  0
     }
 108  
 
 109  
     @Override
 110  
     public CourseOfferingInfo getCourseOffering(String courseOfferingId, ContextInfo context)
 111  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 112  
             OperationFailedException, PermissionDeniedException {
 113  0
         return courseOfferingCache.get(courseOfferingId);
 114  
 
 115  
     }
 116  
 
 117  
     @Override
 118  
     public List<CourseOfferingInfo> getCourseOfferingsForCourseAndTerm(String courseId, String termId,
 119  
             ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 120  
             OperationFailedException, PermissionDeniedException {
 121  
 
 122  0
         List<CourseOfferingInfo> courseOfferings = new ArrayList<CourseOfferingInfo>();
 123  0
         for (CourseOfferingInfo courseOffering : courseOfferingCache.values()) {
 124  0
             if (courseOffering.getCourseId().equals(courseId) && courseOffering.getTermId().equals(termId)) {
 125  0
                 courseOfferings.add(courseOffering);
 126  
             }
 127  
         }
 128  0
         return courseOfferings;
 129  
     }
 130  
 
 131  
     @Override
 132  
     public List<String> getCourseOfferingIdsForTerm(String termId, Boolean useIncludedTerm, ContextInfo context)
 133  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 134  
             OperationFailedException, PermissionDeniedException {
 135  
 
 136  0
         List<String> courseOfferings = new ArrayList<String>();
 137  0
         for (CourseOfferingInfo courseOffering : courseOfferingCache.values()) {
 138  0
             if (courseOffering.getTermId().equals(termId)) {
 139  0
                 courseOfferings.add(courseOffering.getId());
 140  
             }
 141  
         }
 142  0
         return courseOfferings;
 143  
     }
 144  
 
 145  
     @Override
 146  
     public List<String> getCourseOfferingIdsByTermAndSubjectArea(String termId, String subjectArea, ContextInfo context)
 147  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 148  
             OperationFailedException, PermissionDeniedException {
 149  
 
 150  0
         List<String> courseOfferings = new ArrayList<String>();
 151  0
         for (CourseOfferingInfo courseOffering : courseOfferingCache.values()) {
 152  0
             if (courseOffering.getSubjectArea().equals(subjectArea)) {
 153  0
                 courseOfferings.add(courseOffering.getId());
 154  
             }
 155  
         }
 156  0
         return courseOfferings;
 157  
     }
 158  
 
 159  
     @Override
 160  
     public List<String> getCourseOfferingIdsByTermAndUnitContentOwner(String termId, String unitOwnerId, ContextInfo context)
 161  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 162  
             OperationFailedException, PermissionDeniedException {
 163  
 
 164  0
         List<String> courseOfferings = new ArrayList<String>();
 165  0
         for (CourseOfferingInfo courseOffering : courseOfferingCache.values()) {
 166  0
             if (courseOffering.getUnitsContentOwner().contains(unitOwnerId)
 167  
                     && courseOffering.getTermId().equals(termId)) {
 168  0
                 courseOfferings.add(courseOffering.getId());
 169  
             }
 170  
         }
 171  0
         return courseOfferings;
 172  
     }
 173  
 
 174  
     @Override
 175  
     public CourseOfferingInfo createCourseOfferingFromCanonical(String courseid, String termId,
 176  
             List<String> formatIdList, ContextInfo context) throws AlreadyExistsException, DoesNotExistException,
 177  
             DataValidationErrorException, InvalidParameterException, MissingParameterException,
 178  
             OperationFailedException, PermissionDeniedException {
 179  
 
 180  0
         CourseOfferingInfo courseOfferingInfo = new CourseOfferingInfo();
 181  0
         courseOfferingInfo.setCourseId(courseid);
 182  0
         courseOfferingInfo.setTermId(termId);
 183  0
         courseOfferingInfo.setId(String.valueOf(Math.random()));
 184  0
         CourseInfo courseInfo = courseCache.get(courseid);
 185  0
         courseOfferingInfo.setCourseId(courseInfo.getId());
 186  0
         courseOfferingInfo.setCourseNumberSuffix(courseInfo.getCourseNumberSuffix());
 187  0
         courseOfferingInfo.setCourseTitle(courseInfo.getCourseTitle());
 188  
         // TODO: worry about which credit option to apply.
 189  0
         if (courseInfo.getCreditOptions() == null) {
 190  0
             courseOfferingInfo.setCreditOptions(null);
 191  0
         } else if (courseInfo.getCreditOptions().isEmpty()) {
 192  0
             courseOfferingInfo.setCreditOptions(null);
 193  
         } else {
 194  0
             courseOfferingInfo.setCreditOptions(new R1ToR2CopyHelper().copyResultValuesGroup(courseInfo.getCreditOptions().get(0)));
 195  
         }
 196  0
         courseOfferingInfo.setDescr(new R1ToR2CopyHelper().copyRichText(courseInfo.getDescr()));
 197  0
         courseOfferingInfo.setExpenditure(new R1ToR2CopyHelper().copyCourseExpenditure(courseInfo.getExpenditure()));
 198  0
         courseOfferingInfo.setFees(new R1ToR2CopyHelper().copyCourseFeeList(courseInfo.getFees()));
 199  
         //courseOfferingInfo.setFormats(canicalCourseo.getFormats());
 200  
 
 201  0
         courseOfferingCache.put(courseOfferingInfo.getId(), courseOfferingInfo);
 202  
 
 203  0
         return courseOfferingInfo;
 204  
     }
 205  
 
 206  
     @Override
 207  
     public CourseOfferingInfo updateCourseOffering(String courseOfferingId, CourseOfferingInfo courseOfferingInfo,
 208  
             ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException,
 209  
             MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException {
 210  0
         courseOfferingCache.put(courseOfferingId, courseOfferingInfo);
 211  0
         return courseOfferingInfo;
 212  
     }
 213  
 
 214  
     @Override
 215  
     public CourseOfferingInfo updateCourseOfferingFromCanonical(String courseOfferingId, ContextInfo context)
 216  
             throws DataValidationErrorException, DoesNotExistException, InvalidParameterException,
 217  
             MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException {
 218  0
         CourseOfferingInfo courseOfferingInfo = courseOfferingCache.get(courseOfferingId);
 219  0
         CourseInfo courseInfo = courseCache.get(courseOfferingInfo.getCourseId());
 220  0
         courseOfferingInfo.setCourseOfferingCode(courseInfo.getCode());
 221  0
         courseOfferingInfo.setCourseId(courseInfo.getId());
 222  0
         courseOfferingInfo.setCourseNumberSuffix(courseInfo.getCourseNumberSuffix());
 223  0
         courseOfferingInfo.setCourseTitle(courseInfo.getCourseTitle());
 224  
         // TODO: worry about which credit option to apply.
 225  0
         if (courseInfo.getCreditOptions() == null) {
 226  0
             courseOfferingInfo.setCreditOptions(null);
 227  0
         } else if (courseInfo.getCreditOptions().isEmpty()) {
 228  0
             courseOfferingInfo.setCreditOptions(null);
 229  
         } else {
 230  0
             courseOfferingInfo.setCreditOptions(new R1ToR2CopyHelper().copyResultValuesGroup(courseInfo.getCreditOptions().get(0)));
 231  
         }
 232  0
         courseOfferingInfo.setDescr(new R1ToR2CopyHelper().copyRichText(courseInfo.getDescr()));
 233  0
         courseOfferingInfo.setExpenditure(new R1ToR2CopyHelper().copyCourseExpenditure(courseInfo.getExpenditure()));
 234  0
         courseOfferingInfo.setFees(new R1ToR2CopyHelper().copyCourseFeeList(courseInfo.getFees()));
 235  
         //courseOfferingInfo.setFormats(courseInfo.getFormats());
 236  0
         return courseOfferingInfo;
 237  
     }
 238  
 
 239  
     @Override
 240  
     public StatusInfo deleteCourseOffering(String courseOfferingId, ContextInfo context) throws DoesNotExistException,
 241  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 242  
 
 243  0
         StatusInfo status = new StatusInfo();
 244  0
         status.setSuccess(courseOfferingCache.remove(courseOfferingId) != null);
 245  0
         return status;
 246  
     }
 247  
 
 248  
     @Override
 249  
     public TypeInfo getActivityOfferingType(String activityOfferingTypeKey, ContextInfo context)
 250  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 251  
             OperationFailedException {
 252  0
         TypeInfo typeInfo = typesCache.get(activityOfferingTypeKey);
 253  0
         return typeInfo;
 254  
     }
 255  
 
 256  
     @Override
 257  
     public List<TypeInfo> getAllActivityOfferingTypes(ContextInfo context) throws InvalidParameterException,
 258  
             MissingParameterException, OperationFailedException {
 259  0
         return new ArrayList<TypeInfo>();
 260  
     }
 261  
 
 262  
     @Override
 263  
     public List<TypeInfo> getActivityOfferingTypesForActivityType(String activityTypeKey, ContextInfo context)
 264  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 265  
             OperationFailedException {
 266  0
         return new ArrayList<TypeInfo>();
 267  
     }
 268  
 
 269  
     @Override
 270  
     public ActivityOfferingInfo getActivityOffering(String activityOfferingId, ContextInfo context)
 271  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 272  
             OperationFailedException, PermissionDeniedException {
 273  
 
 274  0
         return activityOfferingCache.get(activityOfferingId);
 275  
     }
 276  
 
 277  
     @Override
 278  
     public List<ActivityOfferingInfo> getActivitiesForCourseOffering(String courseOfferingId, ContextInfo context)
 279  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 280  
             OperationFailedException, PermissionDeniedException {
 281  0
         return courseToActivityOfferingCache.get(courseOfferingId);
 282  
     }
 283  
 
 284  
     @Override
 285  
     public ActivityOfferingInfo createActivityOffering(List<String> courseOfferingIdList,
 286  
             ActivityOfferingInfo activityOfferingInfo, ContextInfo context) throws AlreadyExistsException,
 287  
             DataValidationErrorException, InvalidParameterException, MissingParameterException,
 288  
             OperationFailedException, PermissionDeniedException {
 289  
 
 290  0
         activityOfferingInfo.setId(String.valueOf(Math.random()));
 291  0
         activityOfferingCache.put(activityOfferingInfo.getId(), activityOfferingInfo);
 292  
 
 293  0
         for (String courseOfferingId : courseOfferingIdList) {
 294  0
             List<ActivityOfferingInfo> activities = courseToActivityOfferingCache.get(courseOfferingId);
 295  0
             if (null == activities) {
 296  0
                 activities = new ArrayList<ActivityOfferingInfo>();
 297  
             }
 298  
 
 299  0
             activities.add(activityOfferingInfo);
 300  
 
 301  0
             courseToActivityOfferingCache.put(courseOfferingId, activities);
 302  0
         }
 303  
 
 304  0
         return activityOfferingInfo;
 305  
     }
 306  
 
 307  
     @Override
 308  
     public ActivityOfferingInfo updateActivityOffering(String activityOfferingId,
 309  
             ActivityOfferingInfo activityOfferingInfo, ContextInfo context) throws DataValidationErrorException,
 310  
             DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 311  
             PermissionDeniedException, VersionMismatchException {
 312  0
         activityOfferingCache.put(activityOfferingId, activityOfferingInfo);
 313  0
         return activityOfferingInfo;
 314  
     }
 315  
 
 316  
     @Override
 317  
     public StatusInfo deleteActivityOffering(String activityOfferingId, ContextInfo context)
 318  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 319  
             OperationFailedException, PermissionDeniedException {
 320  
 
 321  0
         StatusInfo status = new StatusInfo();
 322  0
         status.setSuccess(activityOfferingCache.remove(activityOfferingId) != null);
 323  0
         return status;
 324  
     }
 325  
 
 326  
     @Override
 327  
     public Float calculateInClassContactHoursForTerm(String activityOfferingId, ContextInfo context)
 328  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 329  
             OperationFailedException, PermissionDeniedException {
 330  0
         ActivityOfferingInfo activity = activityOfferingCache.get(activityOfferingId);
 331  
         // approximate number of weeks, in real impl calculate class weeks from
 332  
         // TermInfo
 333  0
         return activity.getWeeklyInclassContactHours() * 16;
 334  
 
 335  
     }
 336  
 
 337  
     @Override
 338  
     public Float calculateOutofClassContactHoursForTerm(String activityOfferingId, ContextInfo context)
 339  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 340  
             OperationFailedException, PermissionDeniedException {
 341  0
         ActivityOfferingInfo activity = activityOfferingCache.get(activityOfferingId);
 342  
 
 343  
         // approximate number of weeks, in real impl calculate class weeks from
 344  
         // TermInfo
 345  0
         return activity.getWeeklyOutofclassContactHours() * 16;
 346  
     }
 347  
 
 348  
     @Override
 349  
     public Float calculateTotalContactHoursForTerm(String activityOfferingId, ContextInfo context)
 350  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 351  
             OperationFailedException, PermissionDeniedException {
 352  0
         return calculateInClassContactHoursForTerm(activityOfferingId, context)
 353  
                 + calculateOutofClassContactHoursForTerm(activityOfferingId, context);
 354  
     }
 355  
 
 356  
     @Override
 357  
     public List<ActivityOfferingInfo> copyActivityOffering(String activityOfferingId, Integer numberOfCopies,
 358  
             String copyContextTypeKey, ContextInfo context) throws InvalidParameterException,
 359  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 360  0
         List<ActivityOfferingInfo> activityOfferings = new ArrayList<ActivityOfferingInfo>(numberOfCopies);
 361  
         // TODO - implement activityOfferingInf & activityOffering
 362  0
         ActivityOfferingInfo activityOfferingInf = activityOfferingCache.get(activityOfferingId);
 363  0
         for (ActivityOfferingInfo activityOffering : activityOfferings) {
 364  
             // activityOffering = new ActivityOfferingInfo(activityOfferingInf);
 365  
         }
 366  
 
 367  0
         return activityOfferings;
 368  
     }
 369  
 
 370  
     @Override
 371  
     public RegistrationGroupInfo getRegistrationGroup(String registrationGroupId, ContextInfo context)
 372  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 373  
             OperationFailedException, PermissionDeniedException {
 374  0
         return registrationGroupCache.get(registrationGroupId);
 375  
     }
 376  
 
 377  
     @Override
 378  
     public List<RegistrationGroupInfo> getRegGroupsForCourseOffering(String courseOfferingId, ContextInfo context)
 379  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 380  
             OperationFailedException, PermissionDeniedException {
 381  0
         return courseToRegGroupCache.get(courseOfferingId);
 382  
     }
 383  
 
 384  
     @Override
 385  
     public List<RegistrationGroupInfo> getRegGroupsByFormatForCourse(String courseOfferingId, String formatTypeKey,
 386  
             ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 387  
             OperationFailedException, PermissionDeniedException {
 388  0
         CourseOfferingInfo courseOffering = courseOfferingCache.get(courseOfferingId);
 389  0
         List<FormatInfo> formatsInfo = new ArrayList<FormatInfo>();
 390  
 
 391  0
         List<RegistrationGroupInfo> regGroups = courseToRegGroupCache.get(courseOfferingId);
 392  
 
 393  0
         if (null == regGroups) {
 394  0
             regGroups = new ArrayList<RegistrationGroupInfo>();
 395  
         }
 396  
 
 397  0
         List<RegistrationGroupInfo> result = new ArrayList<RegistrationGroupInfo>();
 398  
 
 399  
         try {
 400  0
             formatsInfo = courseService.getCourseFormats(courseOffering.getCourseId());
 401  0
         } catch (org.kuali.student.common.exceptions.DoesNotExistException e) {
 402  0
             throw new OperationFailedException(courseOffering.getCourseId(), e);
 403  0
         } catch (org.kuali.student.common.exceptions.InvalidParameterException e) {
 404  0
             throw new OperationFailedException(courseOffering.getCourseId(), e);
 405  0
         } catch (org.kuali.student.common.exceptions.MissingParameterException e) {
 406  0
             throw new OperationFailedException(courseOffering.getCourseId(), e);
 407  0
         } catch (org.kuali.student.common.exceptions.OperationFailedException e) {
 408  0
             throw new OperationFailedException(courseOffering.getCourseId(), e);
 409  0
         } catch (org.kuali.student.common.exceptions.PermissionDeniedException e) {
 410  0
             throw new OperationFailedException(courseOffering.getCourseId(), e);
 411  0
         }
 412  
 
 413  0
         for (FormatInfo format : formatsInfo) {
 414  
 
 415  0
             for (RegistrationGroupInfo regGroup : regGroups) {
 416  0
                 if (format.getId().equals(regGroup.getFormatId()) && format.getType().equals(formatTypeKey)) {
 417  0
                     result.add(regGroup);
 418  
                 }
 419  
             }
 420  
         }
 421  0
         return result;
 422  
     }
 423  
 
 424  
     @Override
 425  
     public RegistrationGroupInfo createRegistrationGroup(String courseOfferingId,
 426  
             RegistrationGroupInfo registrationGroupInfo, ContextInfo context) throws AlreadyExistsException,
 427  
             DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException,
 428  
             OperationFailedException, PermissionDeniedException {
 429  
 
 430  0
         registrationGroupInfo.setId(String.valueOf(Math.random()));
 431  0
         registrationGroupCache.put(registrationGroupInfo.getId(), registrationGroupInfo);
 432  
 
 433  0
         List<RegistrationGroupInfo> regGroups = courseToRegGroupCache.get(courseOfferingId);
 434  
 
 435  0
         if (null == regGroups) {
 436  0
             regGroups = new ArrayList<RegistrationGroupInfo>();
 437  
         }
 438  
 
 439  0
         regGroups.add(registrationGroupInfo);
 440  
 
 441  0
         courseToRegGroupCache.put(courseOfferingId, regGroups);
 442  
 
 443  0
         return registrationGroupInfo;
 444  
     }
 445  
 
 446  
     @Override
 447  
     public RegistrationGroupInfo updateRegistrationGroup(String registrationGroupId,
 448  
             RegistrationGroupInfo registrationGroupInfo, ContextInfo context) throws DataValidationErrorException,
 449  
             DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 450  
             PermissionDeniedException, VersionMismatchException {
 451  0
         registrationGroupCache.put(registrationGroupId, registrationGroupInfo);
 452  0
         return registrationGroupInfo;
 453  
     }
 454  
 
 455  
     @Override
 456  
     public StatusInfo deleteRegistrationGroup(String registrationGroupId, ContextInfo context)
 457  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 458  
             OperationFailedException, PermissionDeniedException {
 459  
 
 460  0
         StatusInfo status = new StatusInfo();
 461  0
         status.setSuccess(registrationGroupCache.remove(registrationGroupId) != null);
 462  
 
 463  0
         return status;
 464  
     }
 465  
 
 466  
     @Override
 467  
     public SeatPoolDefinitionInfo getSeatPoolDefinition(String seatPoolDefinitionId, ContextInfo context)
 468  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 469  
             OperationFailedException, PermissionDeniedException {
 470  
 
 471  0
         return seatPoolDefinitionCache.get(seatPoolDefinitionId);
 472  
     }
 473  
 
 474  
     @Override
 475  
     public List<SeatPoolDefinitionInfo> getSeatPoolsForCourseOffering(String courseOfferingId, ContextInfo context)
 476  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 477  
             OperationFailedException, PermissionDeniedException {
 478  
 
 479  0
         List<SeatPoolDefinitionInfo> seatPoolsForCourseOff = new ArrayList<SeatPoolDefinitionInfo>();
 480  0
         for (SeatPoolDefinitionInfo seatPoolInfo : seatPoolDefinitionCache.values()) {
 481  0
             if (seatPoolInfo.getCourseOfferingId().equals(courseOfferingId)) {
 482  0
                 seatPoolsForCourseOff.add(seatPoolInfo);
 483  
             }
 484  
         }
 485  0
         return seatPoolsForCourseOff;
 486  
     }
 487  
 
 488  
     @Override
 489  
     public List<SeatPoolDefinitionInfo> getSeatPoolsForRegGroup(String registrationGroupId, ContextInfo context)
 490  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 491  
             OperationFailedException, PermissionDeniedException {
 492  0
         List<SeatPoolDefinitionInfo> seatPoolsForRegGroup = new ArrayList<SeatPoolDefinitionInfo>();
 493  0
         for (SeatPoolDefinitionInfo seatPoolInfo : seatPoolDefinitionCache.values()) {
 494  0
             if (seatPoolInfo.getRegistrationGroupIds().contains(registrationGroupId)) {
 495  0
                 seatPoolsForRegGroup.add(seatPoolInfo);
 496  
             }
 497  
         }
 498  0
         return seatPoolsForRegGroup;
 499  
     }
 500  
 
 501  
     @Override
 502  
     public SeatPoolDefinitionInfo createSeatPoolDefinition(SeatPoolDefinitionInfo seatPoolDefinitionInfo,
 503  
             ContextInfo context) throws AlreadyExistsException, DataValidationErrorException,
 504  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 505  0
         seatPoolDefinitionInfo.setId(String.valueOf(Math.random()));
 506  0
         seatPoolDefinitionCache.put(seatPoolDefinitionInfo.getId(), seatPoolDefinitionInfo);
 507  0
         return seatPoolDefinitionInfo;
 508  
     }
 509  
 
 510  
     @Override
 511  
     public SeatPoolDefinitionInfo updateSeatPoolDefinition(String seatPoolDefinitionId,
 512  
             SeatPoolDefinitionInfo seatPoolDefinitionInfo, ContextInfo context) throws DataValidationErrorException,
 513  
             DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 514  
             PermissionDeniedException, VersionMismatchException {
 515  0
         seatPoolDefinitionCache.put(seatPoolDefinitionId, seatPoolDefinitionInfo);
 516  0
         return seatPoolDefinitionInfo;
 517  
     }
 518  
 
 519  
     @Override
 520  
     public StatusInfo deleteSeatPoolDefinition(String seatPoolDefinitionId, ContextInfo context)
 521  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 522  
             OperationFailedException, PermissionDeniedException {
 523  
 
 524  0
         StatusInfo status = new StatusInfo();
 525  0
         status.setSuccess(seatPoolDefinitionCache.remove(seatPoolDefinitionId) != null);
 526  0
         return status;
 527  
     }
 528  
 
 529  
     @Override
 530  
     public List<StatementTreeViewInfo> getCourseOfferingRestrictions(String courseOfferingId, String nlUsageTypeKey, String language, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 531  0
         return new ArrayList<StatementTreeViewInfo>();
 532  
     }
 533  
 
 534  
     @Override
 535  
     public StatementTreeViewInfo createCourseOfferingRestriction(String courseOfferingId, StatementTreeViewInfo statementTreeViewInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException {
 536  0
         return null;
 537  
     }
 538  
 
 539  
     @Override
 540  
     public StatementTreeViewInfo updateCourseOfferingRestriction(String courseOfferingId, StatementTreeViewInfo statementTreeViewInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, CircularReferenceException, VersionMismatchException {
 541  0
         return null;
 542  
     }
 543  
 
 544  
     @Override
 545  
     public StatusInfo deleteCourseOfferingRestriction(String courseOfferingId, String restrictionId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 546  0
         return null;
 547  
     }
 548  
 
 549  
     @Override
 550  
     public List<StatementTreeViewInfo> getActivityOfferingRestrictions(String activityOfferingId, String nlUsageTypeKey, String language, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 551  0
         return new ArrayList<StatementTreeViewInfo>();
 552  
     }
 553  
 
 554  
     @Override
 555  
     public StatementTreeViewInfo createActivityOfferingRestriction(String activityOfferingId, StatementTreeViewInfo statementTreeViewInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException {
 556  0
         return null;
 557  
     }
 558  
 
 559  
     @Override
 560  
     public StatementTreeViewInfo updateActivityOfferingRestriction(String activityOfferingId, StatementTreeViewInfo statementTreeViewInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, CircularReferenceException, VersionMismatchException {
 561  0
         return null;
 562  
     }
 563  
 
 564  
     @Override
 565  
     public StatusInfo deleteActivityOfferingRestriction(String activityOfferingId, String restrictionId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 566  0
         return null;
 567  
     }
 568  
 
 569  
     @Override
 570  
     public List<ValidationResultInfo> validateCourseOffering(String validationType, CourseOfferingInfo courseOfferingInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 571  
         // TODO Kamal - THIS METHOD NEEDS JAVADOCS
 572  0
         return null;
 573  
     }
 574  
 
 575  
     @Override
 576  
     public List<ValidationResultInfo> validateCourseOfferingRestriction(String validationType, StatementTreeViewInfo restrictionInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 577  
         // TODO Kamal - THIS METHOD NEEDS JAVADOCS
 578  0
         return null;
 579  
     }
 580  
 
 581  
     @Override
 582  
     public List<ValidationResultInfo> validateActivityOffering(String validationType, ActivityOfferingInfo activityOfferingInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 583  
         // TODO Kamal - THIS METHOD NEEDS JAVADOCS
 584  0
         return null;
 585  
     }
 586  
 
 587  
     @Override
 588  
     public List<ValidationResultInfo> validateActivityOfferingRestriction(String validationType, StatementTreeViewInfo restrictionInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 589  
         // TODO Kamal - THIS METHOD NEEDS JAVADOCS
 590  0
         return null;
 591  
     }
 592  
 
 593  
     @Override
 594  
     public List<ValidationResultInfo> validateRegistrationGroup(String validationType, RegistrationGroupInfo registrationGroupInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 595  
         // TODO Kamal - THIS METHOD NEEDS JAVADOCS
 596  0
         return null;
 597  
     }
 598  
 
 599  
     @Override
 600  
     public List<CourseOfferingInfo> getCourseOfferingsByIdList(List<String> courseOfferingIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 601  0
         List<CourseOfferingInfo> cList = new ArrayList<CourseOfferingInfo>();
 602  
 
 603  0
         for (String cId : courseOfferingIds) {
 604  0
             CourseOfferingInfo cOffering = courseOfferingCache.get(cId);
 605  0
             if (null == cOffering) {
 606  0
                 throw new DoesNotExistException("Course Offering not found for: " + cId);
 607  
             }
 608  0
             cList.add(cOffering);
 609  0
         }
 610  
 
 611  0
         return cList;
 612  
     }
 613  
 
 614  
     @Override
 615  
     public List<ActivityOfferingInfo> getActivityOfferingsByIdList(List<String> activityOfferingIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 616  0
         List<ActivityOfferingInfo> aList = new ArrayList<ActivityOfferingInfo>();
 617  
 
 618  0
         for (String aId : activityOfferingIds) {
 619  0
             ActivityOfferingInfo activity = activityOfferingCache.get(aId);
 620  0
             if (null == activity) {
 621  0
                 throw new DoesNotExistException("Activity Offering not found for: " + aId);
 622  
             }
 623  0
             aList.add(activity);
 624  0
         }
 625  
 
 626  0
         return aList;
 627  
     }
 628  
 
 629  
     @Override
 630  
     public StatusInfo assignActivityToCourseOffering(String activityOfferingId, List<String> courseOfferingIdList, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 631  0
         ActivityOfferingInfo activity = activityOfferingCache.get(activityOfferingId);
 632  0
         if (null == activity) {
 633  0
             throw new DoesNotExistException("Activity offering not found for: " + activityOfferingId);
 634  
         }
 635  
 
 636  0
         for (String cId : courseOfferingIdList) {
 637  0
             CourseOfferingInfo cInfo = courseOfferingCache.get(cId);
 638  0
             if (null == cInfo) {
 639  0
                 throw new DoesNotExistException("Course offering not found for: " + cId);
 640  
             }
 641  0
         }
 642  
 
 643  0
         for (String cId : courseOfferingIdList) {
 644  0
             List<ActivityOfferingInfo> aList = courseToActivityOfferingCache.get(cId);
 645  0
             if (null == aList) {
 646  0
                 throw new OperationFailedException("Inconsistent data!");
 647  
             }
 648  
 
 649  0
             for (ActivityOfferingInfo aInfo : aList) {
 650  0
                 if (aInfo.getId().equals(activityOfferingId)) {
 651  0
                     throw new AlreadyExistsException("activity offering " + activityOfferingId + " already mapped to course offering " + cId);
 652  
                 }
 653  
             }
 654  
 
 655  0
             aList.add(activity);
 656  0
             courseToActivityOfferingCache.put(cId, aList);
 657  0
         }
 658  
 
 659  
 
 660  0
         StatusInfo s = new StatusInfo();
 661  0
         s.setSuccess(true);
 662  0
         return s;
 663  
     }
 664  
 
 665  
     @Override
 666  
     public List<RegistrationGroupInfo> getRegistrationGroupsByIdList(List<String> registrationGroupIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 667  0
         List<RegistrationGroupInfo> regList = new ArrayList<RegistrationGroupInfo>();
 668  
 
 669  0
         for (String regId : registrationGroupIds) {
 670  0
             RegistrationGroupInfo reg = registrationGroupCache.get(regId);
 671  0
             if (null == reg) {
 672  0
                 throw new DoesNotExistException("Reg group not found for: " + regId);
 673  
             }
 674  0
             regList.add(reg);
 675  0
         }
 676  
 
 677  0
         return regList;
 678  
     }
 679  
 
 680  
     @Override
 681  
     public List<CourseOfferingInfo> searchForCourseOfferings(QueryByCriteria criteria, ContextInfo context)
 682  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 683  
             PermissionDeniedException {
 684  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 685  0
         return null;
 686  
     }
 687  
 
 688  
     @Override
 689  
     public List<String> searchForCourseOfferingIds(QueryByCriteria criteria, ContextInfo context)
 690  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 691  
             PermissionDeniedException {
 692  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 693  0
         return null;
 694  
     }
 695  
 
 696  
     @Override
 697  
     public List<ActivityOfferingInfo> searchForActivityOfferings(QueryByCriteria criteria, ContextInfo context)
 698  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 699  
             PermissionDeniedException {
 700  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 701  0
         return null;
 702  
     }
 703  
 
 704  
     @Override
 705  
     public List<String> searchForActivityOfferingIds(QueryByCriteria criteria, ContextInfo context)
 706  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 707  
             PermissionDeniedException {
 708  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 709  0
         return null;
 710  
     }
 711  
 
 712  
     @Override
 713  
     public List<CourseRegistrationInfo> searchForRegistrationGroups(QueryByCriteria criteria, ContextInfo context)
 714  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 715  
             PermissionDeniedException {
 716  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 717  0
         return null;
 718  
     }
 719  
 
 720  
     @Override
 721  
     public List<String> searchForRegistrationGroupIds(QueryByCriteria criteria, ContextInfo context)
 722  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 723  
             PermissionDeniedException {
 724  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 725  0
         return null;
 726  
     }
 727  
 
 728  
     @Override
 729  
     public List<SeatPoolDefinitionInfo> searchForSeatpoolDefintions(QueryByCriteria criteria, ContextInfo context)
 730  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 731  
             PermissionDeniedException {
 732  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 733  0
         return null;
 734  
     }
 735  
 
 736  
     @Override
 737  
     public List<String> searchForSeatpoolDefintionIds(QueryByCriteria criteria, ContextInfo context)
 738  
             throws InvalidParameterException, MissingParameterException, OperationFailedException,
 739  
             PermissionDeniedException {
 740  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 741  0
         return null;
 742  
     }
 743  
 
 744  
     @Override
 745  
     public List<String> getCourseOfferingIdsByTermAndInstructorId(String termId, String instructorId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 746  0
         List<String> list = new ArrayList<String>();
 747  0
         for (CourseOfferingInfo courseOfferingInfo : this.courseOfferingCache.values()) {
 748  0
             if (termId.equals(courseOfferingInfo.getTermId())) {
 749  0
                 if (courseOfferingInfo.getInstructors() != null) {
 750  0
                     for (OfferingInstructorInfo offeringInstructorInfo : courseOfferingInfo.getInstructors()) {
 751  0
                         if (instructorId.equals(offeringInstructorInfo.getPersonId())) {
 752  0
                             list.add(courseOfferingInfo.getId());
 753  0
                             break;
 754  
                         }
 755  
                     }
 756  
                 }
 757  
             }
 758  
         }
 759  0
         return list;
 760  
     }
 761  
 }