Coverage Report - org.kuali.student.enrollment.class2.courseregistration.service.impl.CourseRegistrationServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseRegistrationServiceImpl
0%
0/336
0%
0/98
1.943
 
 1  
 package org.kuali.student.enrollment.class2.courseregistration.service.impl;
 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.apache.commons.lang.StringUtils;
 9  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 10  
 import org.kuali.rice.krms.api.engine.EngineResults;
 11  
 import org.kuali.student.common.util.krms.RulesExecutionConstants;
 12  
 import org.kuali.student.core.statement.dto.ReqComponentInfo;
 13  
 import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
 14  
 import org.kuali.student.core.statement.service.StatementService;
 15  
 import org.kuali.student.core.statement.util.PropositionBuilder;
 16  
 import org.kuali.student.core.statement.util.RulesEvaluationUtil;
 17  
 import org.kuali.student.enrollment.class2.courseregistration.service.assembler.CourseRegistrationAssembler;
 18  
 import org.kuali.student.enrollment.class2.courseregistration.service.assembler.RegRequestAssembler;
 19  
 import org.kuali.student.enrollment.class2.courseregistration.service.assembler.RegResponseAssembler;
 20  
 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
 21  
 import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
 22  
 import org.kuali.student.enrollment.courseoffering.dto.RegistrationGroupInfo;
 23  
 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
 24  
 import org.kuali.student.enrollment.courseregistration.dto.ActivityRegistrationInfo;
 25  
 import org.kuali.student.enrollment.courseregistration.dto.CourseRegistrationInfo;
 26  
 import org.kuali.student.enrollment.courseregistration.dto.RegGroupRegistrationInfo;
 27  
 import org.kuali.student.enrollment.courseregistration.dto.RegRequestInfo;
 28  
 import org.kuali.student.enrollment.courseregistration.dto.RegRequestItemInfo;
 29  
 import org.kuali.student.enrollment.courseregistration.dto.RegResponseInfo;
 30  
 import org.kuali.student.enrollment.courseregistration.service.CourseRegistrationService;
 31  
 import org.kuali.student.enrollment.coursewaitlist.dto.CourseWaitlistEntryInfo;
 32  
 import org.kuali.student.enrollment.grading.dto.LoadInfo;
 33  
 import org.kuali.student.enrollment.lpr.dto.LprRosterEntryInfo;
 34  
 import org.kuali.student.enrollment.lpr.dto.LprRosterInfo;
 35  
 import org.kuali.student.enrollment.lpr.dto.LprTransactionInfo;
 36  
 import org.kuali.student.enrollment.lpr.dto.LprTransactionItemInfo;
 37  
 import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo;
 38  
 import org.kuali.student.enrollment.lpr.service.LuiPersonRelationService;
 39  
 import org.kuali.student.lum.course.service.CourseService;
 40  
 import org.kuali.student.r2.common.assembler.AssemblyException;
 41  
 import org.kuali.student.r2.common.dto.ContextInfo;
 42  
 import org.kuali.student.r2.common.dto.DateRangeInfo;
 43  
 import org.kuali.student.r2.common.dto.OperationStatusInfo;
 44  
 import org.kuali.student.r2.common.dto.StatusInfo;
 45  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 46  
 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
 47  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 48  
 import org.kuali.student.r2.common.exceptions.DisabledIdentifierException;
 49  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 50  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 51  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 52  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 53  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 54  
 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
 55  
 import org.kuali.student.r2.common.infc.ValidationResult;
 56  
 import org.kuali.student.r2.common.util.constants.LrcServiceConstants;
 57  
 import org.kuali.student.r2.common.util.constants.LuiPersonRelationServiceConstants;
 58  
 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
 59  
 
 60  
 import org.kuali.student.r2.core.process.service.ProcessService;
 61  
 import org.kuali.student.r2.lum.lrc.dto.ResultScaleInfo;
 62  
 import org.kuali.student.r2.lum.lrc.infc.ResultValuesGroup;
 63  
 import org.kuali.student.r2.lum.lrc.service.LRCService;
 64  
 
 65  0
 public class CourseRegistrationServiceImpl implements CourseRegistrationService {
 66  
 
 67  
     private LuiPersonRelationService lprService;
 68  
     private CourseOfferingService courseOfferingService;
 69  
     private RegRequestAssembler regRequestAssembler;
 70  
     private RegResponseAssembler regResponseAssembler;
 71  
     private CourseRegistrationAssembler courseRegistrationAssembler;
 72  
     private StatementService statementService;
 73  
     private CourseService courseService;
 74  
     private PropositionBuilder propositionBuilder;
 75  
     private RulesEvaluationUtil rulesEvaluationUtil;
 76  
     private ProcessService processService;
 77  
     private LRCService lrcService;
 78  
 
 79  
     public ProcessService getProcessService() {
 80  0
         return processService;
 81  
     }
 82  
 
 83  
     public void setProcessService(ProcessService processService) {
 84  0
         this.processService = processService;
 85  0
     }
 86  
 
 87  
     public LRCService getLrcService() {
 88  0
         return lrcService;
 89  
     }
 90  
 
 91  
     public void setLrcService(LRCService lrcService) {
 92  0
         this.lrcService = lrcService;
 93  0
     }
 94  
 
 95  
     public LuiPersonRelationService getLprService() {
 96  0
         return lprService;
 97  
     }
 98  
 
 99  
     public void setLprService(LuiPersonRelationService lprService) {
 100  0
         this.lprService = lprService;
 101  0
     }
 102  
 
 103  
     public CourseOfferingService getCourseOfferingService() {
 104  0
         return courseOfferingService;
 105  
     }
 106  
 
 107  
     public void setCourseOfferingService(CourseOfferingService courseOfferingService) {
 108  0
         this.courseOfferingService = courseOfferingService;
 109  0
     }
 110  
 
 111  
     public RegRequestAssembler getRegRequestAssembler() {
 112  0
         return regRequestAssembler;
 113  
     }
 114  
 
 115  
     public void setRegRequestAssembler(RegRequestAssembler regRequestAssembler) {
 116  0
         this.regRequestAssembler = regRequestAssembler;
 117  0
     }
 118  
 
 119  
     public RegResponseAssembler getRegResponseAssembler() {
 120  0
         return regResponseAssembler;
 121  
     }
 122  
 
 123  
     public void setRegResponseAssembler(RegResponseAssembler regResponseAssembler) {
 124  0
         this.regResponseAssembler = regResponseAssembler;
 125  0
     }
 126  
 
 127  
     public CourseRegistrationAssembler getCourseRegistrationAssembler() {
 128  0
         return courseRegistrationAssembler;
 129  
     }
 130  
 
 131  
     public void setCourseRegistrationAssembler(CourseRegistrationAssembler courseRegistrationAssembler) {
 132  0
         this.courseRegistrationAssembler = courseRegistrationAssembler;
 133  0
     }
 134  
 
 135  
     public StatementService getStatementService() {
 136  0
         return statementService;
 137  
     }
 138  
 
 139  
     public void setStatementService(StatementService statementService) {
 140  0
         this.statementService = statementService;
 141  0
     }
 142  
 
 143  
     public CourseService getCourseService() {
 144  0
         return courseService;
 145  
     }
 146  
 
 147  
     public void setCourseService(CourseService courseService) {
 148  0
         this.courseService = courseService;
 149  0
     }
 150  
 
 151  
     public PropositionBuilder getPropositionBuilder() {
 152  0
         return propositionBuilder;
 153  
     }
 154  
 
 155  
     public void setPropositionBuilder(PropositionBuilder propositionBuilder) {
 156  0
         this.propositionBuilder = propositionBuilder;
 157  0
     }
 158  
 
 159  
     public RulesEvaluationUtil getRulesEvaluationUtil() {
 160  0
         return rulesEvaluationUtil;
 161  
     }
 162  
 
 163  
     public void setRulesEvaluationUtil(RulesEvaluationUtil rulesEvaluationUtil) {
 164  0
         this.rulesEvaluationUtil = rulesEvaluationUtil;
 165  0
     }
 166  
 
 167  
     private List<LprTransactionItemInfo> createModifiedLprTransactionItemsForNew(RegRequestItemInfo regRequestItem, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 168  
             MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException {
 169  
 
 170  0
         List<LprTransactionItemInfo> newTransactionItems = new ArrayList<LprTransactionItemInfo>();
 171  
 
 172  0
         String regGroupId = regRequestItem.getNewRegGroupId();
 173  0
         RegistrationGroupInfo regGroup = courseOfferingService.getRegistrationGroup(regGroupId, context);
 174  0
         LprTransactionItemInfo lprTransactionItem = regRequestAssembler.disassembleItem(regRequestItem, null, context);
 175  0
         if (getAvailableSeatsForStudentInRegGroup(regRequestItem.getStudentId(), regGroupId, context) > 0) {
 176  0
             List<LprTransactionItemInfo> lprActivityTransactionItems = new ArrayList<LprTransactionItemInfo>();
 177  0
             for (String activityOfferingId : regGroup.getActivityOfferingIds()) {
 178  0
                 LprTransactionItemInfo activtyItemInfo = regRequestAssembler.disassembleItem(regRequestItem, null, context);
 179  0
                 activtyItemInfo.setId(null);
 180  0
                 activtyItemInfo.setNewLuiId(activityOfferingId);
 181  0
                 newTransactionItems.add(activtyItemInfo);
 182  0
             }
 183  
 
 184  0
             String courseOfferingId = regGroup.getCourseOfferingId();
 185  0
             LprTransactionItemInfo courseOfferingItemInfo = regRequestAssembler.disassembleItem(regRequestItem, null, context);
 186  0
             courseOfferingItemInfo.setNewLuiId(courseOfferingId);
 187  0
             courseOfferingItemInfo.setId(null);
 188  0
             ArrayList<String> rvgs = new ArrayList<String>();
 189  0
             rvgs.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER);
 190  0
             courseOfferingItemInfo.setResultValuesGroupKeys(rvgs);
 191  0
             newTransactionItems.add(courseOfferingItemInfo);
 192  
 
 193  0
         } else {
 194  
             // TODO: copy the transaction item and change the type
 195  
             // of the new one to be ADD TO WAITLIST
 196  
             // and then on that item mark the original with a state
 197  
             // of failed
 198  
 
 199  0
             lprTransactionItem.setTypeKey(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_ADD_TO_WAITLIST_TYPE_KEY);
 200  0
             lprTransactionItem.setStateKey(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_NEW_STATE_KEY);
 201  
         }
 202  0
         newTransactionItems.add(lprTransactionItem);
 203  0
         return newTransactionItems;
 204  
 
 205  
     }
 206  
 
 207  
     private List<LprTransactionItemInfo> createModifiedLprTransactionItemsForDrop(RegRequestItemInfo regRequestItem, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 208  
             MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException {
 209  0
         List<LprTransactionItemInfo> newTransactionItems = new ArrayList<LprTransactionItemInfo>();
 210  
 
 211  0
         String regGroupId = regRequestItem.getExistingRegGroupId();
 212  0
         RegistrationGroupInfo regGroup = courseOfferingService.getRegistrationGroup(regGroupId, context);
 213  0
         List<LprTransactionItemInfo> lprActivityTransactionItems = new ArrayList<LprTransactionItemInfo>();
 214  0
         for (String activityOfferingId : regGroup.getActivityOfferingIds()) {
 215  0
             LprTransactionItemInfo activtyItemInfo = regRequestAssembler.disassembleItem(regRequestItem, null, context);
 216  0
             activtyItemInfo.setId(null);
 217  0
             activtyItemInfo.setExistingLuiId(activityOfferingId);
 218  0
             activtyItemInfo.setGroupId(regRequestItem.getId());
 219  0
             newTransactionItems.add(activtyItemInfo);
 220  
 
 221  0
         }
 222  
 
 223  0
         String courseOfferingId = regGroup.getCourseOfferingId();
 224  0
         LprTransactionItemInfo courseOfferingItemInfo = regRequestAssembler.disassembleItem(regRequestItem, null, context);
 225  0
         courseOfferingItemInfo.setId(null);
 226  0
         courseOfferingItemInfo.setExistingLuiId(courseOfferingId);
 227  0
         courseOfferingItemInfo.setGroupId(regRequestItem.getId());
 228  0
         lprActivityTransactionItems.add(courseOfferingItemInfo);
 229  0
         newTransactionItems.add(courseOfferingItemInfo);
 230  
         // regRequestAssembler.disassembleItem(regRequestItem, null, context);
 231  0
         return newTransactionItems;
 232  
 
 233  
     }
 234  
 
 235  
     private LprTransactionInfo createModifiedTransactionItems(LprTransactionInfo storedLprTransaction, RegRequestInfo storedRegRequest, ContextInfo context) throws DoesNotExistException,
 236  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException {
 237  0
         List<LprTransactionItemInfo> newTransactionItems = new ArrayList<LprTransactionItemInfo>();
 238  0
         List<RegRequestItemInfo> regRequestItems = storedRegRequest.getRegRequestItems();
 239  0
         for (RegRequestItemInfo regRequestItem : regRequestItems) {
 240  0
             if (regRequestItem.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_ADD_TYPE_KEY)
 241  
                     || regRequestItem.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_DROP_TYPE_KEY)
 242  
                     || regRequestItem.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_UPDATE_TYPE_KEY)) {
 243  0
                 if (regRequestItem.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_ADD_TYPE_KEY)) {
 244  
 
 245  0
                     newTransactionItems.addAll(createModifiedLprTransactionItemsForNew(regRequestItem, context));
 246  
 
 247  0
                 } else if (regRequestItem.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_DROP_TYPE_KEY)) {
 248  
 
 249  0
                     newTransactionItems.addAll(createModifiedLprTransactionItemsForDrop(regRequestItem, context));
 250  
                 }
 251  
 
 252  
             }
 253  
 
 254  
         }
 255  0
         storedLprTransaction.setLprTransactionItems(newTransactionItems);
 256  
 
 257  0
         storedLprTransaction = lprService.updateLprTransaction(storedLprTransaction.getId(), storedLprTransaction, context);
 258  0
         return lprService.getLprTransaction(storedLprTransaction.getId(), context);
 259  
 
 260  
     }
 261  
 
 262  
     @Override
 263  
     public List<ValidationResultInfo> checkStudentEligibility(String studentId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 264  
             PermissionDeniedException {
 265  
 
 266  
 //        String matchingProcessKey = null;
 267  
 //        List<ProcessInfo> studentElgibilityProcesses = processService.getProcessesForProcessCategory(ProcessServiceConstants.PROCESS_CATEGORY_STUDENT_ELIGIBILITY, context);
 268  
 //
 269  
 //        for (ProcessInfo processInfo : studentElgibilityProcesses) {
 270  
 //            if (processInfo.getOwnerOrgId().equals(ProcessServiceConstants.PROCESS_OWNING_ORG_GRAD_SCHOOL)) {
 271  
 //                matchingProcessKey = processInfo.getKey();
 272  
 //                break;
 273  
 //            }
 274  
 //        }
 275  
 
 276  0
         return null;
 277  
     }
 278  
 
 279  
     @Override
 280  
     public List<ValidationResultInfo> checkStudentEligibilityForTerm(String studentId, String termKey, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 281  
             OperationFailedException, PermissionDeniedException {
 282  0
         return null;
 283  
     }
 284  
 
 285  
     @Override
 286  
     public List<DateRangeInfo> getAppointmentWindows(String studentId, String termKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 287  
             PermissionDeniedException {
 288  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 289  0
         return null;
 290  
     }
 291  
 
 292  
     @Override
 293  
     public List<ValidationResultInfo> checkStudentEligibiltyForCourseOffering(String studentId, String courseOfferingId, ContextInfo context) throws InvalidParameterException,
 294  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 295  
 
 296  0
         CourseOfferingInfo courseOffering = null;
 297  
         try {
 298  0
             courseOffering = courseOfferingService.getCourseOffering(courseOfferingId, context);
 299  0
         } catch (DoesNotExistException e) {
 300  0
             throw new InvalidParameterException("Invalid courseOfferingId, no course offering found with id of: " + courseOfferingId);
 301  0
         }
 302  
 
 303  
         List<StatementTreeViewInfo> statements;
 304  
 
 305  
         try {
 306  
             // TODO fill in nlUsageType and language parameters once the
 307  
             // implementation actually uses them
 308  0
             statements = courseService.getCourseStatements(courseOffering.getCourseId(), null, null);
 309  0
         } catch (Exception e) {
 310  0
             throw new OperationFailedException(e.getMessage(), e);
 311  0
         }
 312  
 
 313  0
         List<ValidationResultInfo> resultInfos = new ArrayList<ValidationResultInfo>();
 314  
 
 315  
         // find and process statements that the PropositionBuilder can handle
 316  0
         for (StatementTreeViewInfo statementTree : statements) {
 317  0
             if (PropositionBuilder.TRANSLATABLE_STATEMENT_TYPES.contains(statementTree.getType())) {
 318  0
                 PropositionBuilder.TranslationResults translationResults = null;
 319  
                 try {
 320  0
                     translationResults = propositionBuilder.translateStatement(statementTree, null);
 321  0
                 } catch (org.kuali.student.common.exceptions.InvalidParameterException e) {
 322  0
                     throw new OperationFailedException("Exception thrown attempting statement translation for statement: " + statementTree.getId(), e);
 323  0
                 }
 324  
 
 325  0
                 Map<String, Object> executionFacts = new HashMap<String, Object>();
 326  0
                 executionFacts.put(RulesExecutionConstants.STUDENT_ID_TERM_NAME, studentId);
 327  0
                 executionFacts.put(RulesExecutionConstants.COURSE_ID_TO_ENROLL_TERM_NAME, courseOffering.getCourseId());
 328  0
                 executionFacts.put(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME, context);
 329  
 
 330  0
                 EngineResults engineResults = rulesEvaluationUtil.executeAgenda(translationResults.agenda, executionFacts);
 331  
 
 332  0
                 List<ReqComponentInfo> failedRequirements = rulesEvaluationUtil.getFailedRequirementsFromEngineResults(engineResults, translationResults.reqComponentPropositionMap);
 333  
 
 334  0
                 if (!failedRequirements.isEmpty()) {
 335  0
                     for (ReqComponentInfo failedRequirement : failedRequirements) {
 336  0
                         ValidationResultInfo resultInfo = new ValidationResultInfo();
 337  0
                         resultInfo.setLevel(ValidationResult.ErrorLevel.ERROR);
 338  0
                         resultInfo.setElement(failedRequirement.getId());
 339  
                         try {
 340  0
                             resultInfo.setMessage(statementService.getNaturalLanguageForReqComponent(failedRequirement.getId(), "KUALI.RULE", "en"));
 341  0
                         } catch (Exception e) {
 342  0
                             throw new OperationFailedException(e.getMessage(), e);
 343  0
                         }
 344  
 
 345  0
                         resultInfos.add(resultInfo);
 346  0
                     }
 347  
                 }
 348  0
             }
 349  
         }
 350  
 
 351  0
         if (resultInfos.isEmpty()) {
 352  0
             ValidationResultInfo resultInfo = new ValidationResultInfo();
 353  0
             resultInfo.setLevel(ValidationResult.ErrorLevel.OK);
 354  
 
 355  0
             resultInfos.add(resultInfo);
 356  
         }
 357  
 
 358  0
         return resultInfos;
 359  
     }
 360  
 
 361  
     @Override
 362  
     public List<org.kuali.student.r2.common.dto.ValidationResultInfo> checkStudentEligibiltyForRegGroup(String studentId, String regGroupId, ContextInfo context) throws InvalidParameterException,
 363  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 364  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 365  0
         return null;
 366  
     }
 367  
 
 368  
     @Override
 369  
     public List<RegistrationGroupInfo> getEligibleRegGroupsForStudentInCourseOffering(String studentId, String courseOfferingId, ContextInfo context) throws InvalidParameterException,
 370  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 371  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 372  0
         return null;
 373  
     }
 374  
 
 375  
     @Override
 376  
     public LoadInfo calculateCreditLoadForTerm(String studentId, String termKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 377  
             PermissionDeniedException {
 378  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 379  0
         return null;
 380  
     }
 381  
 
 382  
     @Override
 383  
     public LoadInfo calculateCreditLoadForRegRequest(String studentId, RegRequestInfo regRequestInfo, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 384  
             OperationFailedException, PermissionDeniedException {
 385  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 386  0
         return null;
 387  
     }
 388  
 
 389  
     @Override
 390  
     public Integer getAvailableSeatsForCourseOffering(String courseOfferingId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 391  
             PermissionDeniedException {
 392  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 393  0
         return null;
 394  
     }
 395  
 
 396  
     @Override
 397  
     public Integer getAvailableSeatsForRegGroup(String regGroupId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 398  
             PermissionDeniedException {
 399  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 400  0
         return null;
 401  
     }
 402  
 
 403  
     @Override
 404  
     public Integer getAvailableSeatsForStudentInRegGroup(String studentId, String regGroupId, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 405  
             OperationFailedException, PermissionDeniedException {
 406  
         // TODO - rules and waitlist implementation needed
 407  0
         return new Integer(3);
 408  
 
 409  
     }
 410  
 
 411  
     @Override
 412  
     public Integer getAvailableSeatsInSeatpool(String seatpoolId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 413  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 414  0
         return null;
 415  
     }
 416  
 
 417  
     @Override
 418  
     public RegRequestInfo updateRegRequest(String regRequestId, RegRequestInfo regRequestInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException,
 419  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException {
 420  
         RegRequestInfo rrInfo;
 421  
         try {
 422  0
             LprTransactionInfo lprTransactionInfo = regRequestAssembler.disassemble(regRequestInfo, context);
 423  0
             rrInfo = regRequestAssembler.assemble(lprService.updateLprTransaction(regRequestId, lprTransactionInfo, context), context);
 424  0
         } catch (AssemblyException e) {
 425  0
             throw new OperationFailedException("AssemblyException : " + e.getMessage());
 426  0
         }
 427  
 
 428  0
         return rrInfo;
 429  
     }
 430  
 
 431  
     @Override
 432  
     public StatusInfo deleteRegRequest(String regRequestId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 433  
             PermissionDeniedException {
 434  0
         return lprService.deleteLprTransaction(regRequestId, context);
 435  
     }
 436  
 
 437  
     @Override
 438  
     public List<ValidationResultInfo> validateRegRequest(RegRequestInfo regRequestInfo, ContextInfo context) throws DataValidationErrorException, InvalidParameterException, MissingParameterException,
 439  
             OperationFailedException, PermissionDeniedException {
 440  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 441  0
         return null;
 442  
     }
 443  
 
 444  
     @Override
 445  
     public List<ValidationResultInfo> verifyRegRequest(RegRequestInfo regRequestInfo, ContextInfo context) throws DataValidationErrorException, InvalidParameterException, MissingParameterException,
 446  
             OperationFailedException, PermissionDeniedException {
 447  0
         return new ArrayList<ValidationResultInfo>();
 448  
     }
 449  
 
 450  
     @Override
 451  
     public RegResponseInfo verifySavedReqRequest(String regRequestId, ContextInfo context) throws DataValidationErrorException, InvalidParameterException, MissingParameterException,
 452  
             OperationFailedException, PermissionDeniedException {
 453  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 454  0
         return null;
 455  
     }
 456  
 
 457  
     @Override
 458  
     public RegRequestInfo createRegRequest(RegRequestInfo regRequestInfo, ContextInfo context) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException,
 459  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 460  
 
 461  0
         LprTransactionInfo lprTransaction = null;
 462  
         try {
 463  0
             lprTransaction = regRequestAssembler.disassemble(regRequestInfo, context);
 464  0
         } catch (AssemblyException e) {
 465  0
             throw new OperationFailedException("AssemblyException in disassembling: " + e.getMessage());
 466  0
         }
 467  
 
 468  0
         LprTransactionInfo newLprTransaction = lprService.createLprTransaction(lprTransaction.getTypeKey(), lprTransaction, context);
 469  
         try {
 470  0
             newLprTransaction = lprService.getLprTransaction(newLprTransaction.getId(), context);
 471  0
         } catch (DoesNotExistException e) {
 472  0
             return null;
 473  0
         }
 474  
 
 475  0
         RegRequestInfo createdRegRequestInfo = null;
 476  
         try {
 477  0
             createdRegRequestInfo = regRequestAssembler.assemble(newLprTransaction, context);
 478  0
         } catch (AssemblyException e) {
 479  0
             throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 480  0
         }
 481  
 
 482  0
         return createdRegRequestInfo;
 483  
     }
 484  
 
 485  
     @Override
 486  
     public RegRequestInfo createRegRequestFromExisting(String existingRegRequestId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 487  
             OperationFailedException, PermissionDeniedException {
 488  
 
 489  0
         LprTransactionInfo newLprTransaction = lprService.createLprTransactionFromExisting(existingRegRequestId, context);
 490  0
         RegRequestInfo createdRegRequestInfo = null;
 491  
         try {
 492  0
             createdRegRequestInfo = regRequestAssembler.assemble(newLprTransaction, context);
 493  0
         } catch (AssemblyException e) {
 494  0
             throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 495  0
         }
 496  0
         return createdRegRequestInfo;
 497  
     }
 498  
 
 499  
     @Override
 500  
     public RegResponseInfo submitRegRequest(String regRequestId, ContextInfo context) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException,
 501  
             OperationFailedException, PermissionDeniedException, AlreadyExistsException {
 502  0
         LprTransactionInfo storedLprTransaction = lprService.getLprTransaction(regRequestId, context);
 503  
 
 504  0
         RegRequestInfo storedRegRequest = null;
 505  
         try {
 506  0
             storedRegRequest = regRequestAssembler.assemble(storedLprTransaction, context);
 507  0
         } catch (AssemblyException e) {
 508  0
             throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 509  0
         }
 510  
 
 511  
         try {
 512  0
             List<ValidationResultInfo> listValidationResult = validateRegRequest(storedRegRequest, context);
 513  
 
 514  0
             if (listValidationResult != null && listValidationResult.size() > 0) {
 515  0
                 throw new DataValidationErrorException("Reg Request is invalid:", listValidationResult);
 516  
             }
 517  0
             List<ValidationResultInfo> verificationResultList = verifyRegRequest(storedRegRequest, context);
 518  0
             for (ValidationResultInfo verificationResult : verificationResultList) {
 519  0
                 if (!verificationResult.isOk()) {
 520  0
                     throw new DataValidationErrorException("Error while verifying registration request: " + verificationResult.getMessage());
 521  
                 }
 522  
             }
 523  0
         } catch (DataValidationErrorException dataValidException) {
 524  0
             throw new OperationFailedException(dataValidException.getMessage(), dataValidException);
 525  0
         }
 526  
 
 527  
         // check eligibility requirements
 528  0
         for (RegRequestItemInfo item : storedRegRequest.getRegRequestItems()) {
 529  0
             if (!StringUtils.equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_DROP_TYPE_KEY, item.getTypeKey())) {
 530  0
                 RegistrationGroupInfo regGroup = courseOfferingService.getRegistrationGroup(item.getNewRegGroupId(), context);
 531  
 
 532  0
                 List<ValidationResultInfo> validations = checkStudentEligibiltyForCourseOffering(storedLprTransaction.getRequestingPersonId(), regGroup.getCourseOfferingId(), context);
 533  0
                 List<String> errorMessages = new ArrayList<String>();
 534  0
                 for (ValidationResultInfo validation : validations) {
 535  0
                     if (validation.isError()) {
 536  0
                         errorMessages.add(validation.getMessage());
 537  
                     }
 538  
                 }
 539  
 
 540  0
                 if (!errorMessages.isEmpty()) {
 541  0
                     RegResponseInfo errorResponse = new RegResponseInfo();
 542  0
                     errorResponse.setOperationStatus(new OperationStatusInfo());
 543  0
                     errorResponse.getOperationStatus().setErrors(errorMessages);
 544  0
                     errorResponse.getOperationStatus().setStatus("FAILURE");
 545  
 
 546  0
                     return errorResponse;
 547  
                 }
 548  0
             }
 549  
         }
 550  
 
 551  0
         LprTransactionInfo multipleItemsTransaction = createModifiedTransactionItems(storedLprTransaction, storedRegRequest, context);
 552  
 
 553  0
         LprTransactionInfo submittedLprTransaction = lprService.processLprTransaction(multipleItemsTransaction.getId(), context);
 554  
 
 555  0
         RegResponseInfo returnRegResponse = null;
 556  
         try {
 557  0
             returnRegResponse = regResponseAssembler.assemble(submittedLprTransaction, context);
 558  0
         } catch (AssemblyException e) {
 559  0
             throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 560  0
         }
 561  
 
 562  0
         if (checkSuccessfulRegCriteria(returnRegResponse)) {
 563  
 
 564  0
             createGradeRosterEntryForRegisteredStudent(submittedLprTransaction, context);
 565  
 
 566  
         }
 567  
 
 568  0
         return returnRegResponse;
 569  
 
 570  
     }
 571  
 
 572  
     private boolean checkSuccessfulRegCriteria(RegResponseInfo returnRegResponse) {
 573  0
         return true;
 574  
     }
 575  
 
 576  
     private void createGradeRosterEntryForRegisteredStudent(LprTransactionInfo submittedLprTransaction, ContextInfo context) throws DataValidationErrorException, AlreadyExistsException,
 577  
             InvalidParameterException, MissingParameterException, DoesNotExistException, OperationFailedException, PermissionDeniedException {
 578  
 
 579  
         // TODO: since we're creating at a minimum 3 lprs per course reg we
 580  
         // shouldn't loop through all of them. need a way to get directly to the
 581  
         // grade roster
 582  0
         for (LprTransactionItemInfo lprItem : submittedLprTransaction.getLprTransactionItems()) {
 583  0
             if (lprItem.getTypeKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_ADD_TYPE_KEY)) {
 584  0
                 LprRosterEntryInfo newLprRosterEntry = new LprRosterEntryInfo();
 585  0
                 newLprRosterEntry.setLprId(lprItem.getLprTransactionItemResult().getResultingLprId());
 586  0
                 newLprRosterEntry.setTypeKey(LuiPersonRelationServiceConstants.LPRROSTER_COURSE_FINAL_GRADE_TYPE_KEY);
 587  0
                 newLprRosterEntry.setStateKey(LuiPersonRelationServiceConstants.LPRROSTER_COURSE_FINAL_GRADEROSTER_READY_STATE_KEY);
 588  
 
 589  0
                 List<LprRosterInfo> lprRosters = lprService.getLprRostersByLuiAndType(lprItem.getNewLuiId(), LuiPersonRelationServiceConstants.LPRROSTER_COURSE_FINAL_GRADEROSTER_TYPE_KEY,
 590  
                         context);
 591  0
                 if (lprRosters.size() == 1) {
 592  0
                     newLprRosterEntry.setLprRosterId(lprRosters.get(0).getId());
 593  0
                     lprService.createLprRosterEntry(newLprRosterEntry, context);
 594  
                 }
 595  
 
 596  0
             }
 597  
 
 598  
         }
 599  
 
 600  0
     }
 601  
 
 602  
     @Override
 603  
     public StatusInfo cancelRegRequest(String regRequestId, ContextInfo context) throws DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException,
 604  
             PermissionDeniedException {
 605  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 606  0
         return null;
 607  
     }
 608  
 
 609  
     @Override
 610  
     public List<RegRequestInfo> getRegRequestsByIds(List<String> regRequestIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 611  
             OperationFailedException, PermissionDeniedException {
 612  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 613  0
         return null;
 614  
     }
 615  
 
 616  
     @Override
 617  
     public List<RegRequestInfo> getRegRequestsForStudentByTerm(String studentId, String termKey, List<String> requestStates, ContextInfo context) throws DoesNotExistException,
 618  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 619  0
         List<LprTransactionInfo> retrievedLprTransactions = lprService.getLprTransactionsByRequestingPersonAndAtp(studentId, termKey, context);
 620  0
         List<RegRequestInfo> regRequestInfos = new ArrayList<RegRequestInfo>();
 621  0
         for (LprTransactionInfo retrievedLprTransaction : retrievedLprTransactions) {
 622  0
             if (requestStates.contains(retrievedLprTransaction.getStateKey())) {
 623  
                 try {
 624  0
                     regRequestInfos.add(regRequestAssembler.assemble(retrievedLprTransaction, context));
 625  0
                 } catch (AssemblyException e) {
 626  0
                     throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 627  0
                 }
 628  
             }
 629  
         }
 630  0
         return regRequestInfos;
 631  
     }
 632  
 
 633  
     @Override
 634  
     public CourseWaitlistEntryInfo getCourseWaitlistEntry(String courseWaitlistEntryId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 635  
             OperationFailedException, PermissionDeniedException {
 636  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 637  0
         return null;
 638  
     }
 639  
 
 640  
     @Override
 641  
     public StatusInfo updateCourseWaitlistEntry(String courseWaitlistEntryId, CourseWaitlistEntryInfo courseWaitlistEntryInfo, ContextInfo context) throws DoesNotExistException,
 642  
             DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 643  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 644  0
         return null;
 645  
     }
 646  
 
 647  
     @Override
 648  
     public StatusInfo reorderCourseWaitlistEntries(List<String> courseWaitlistEntryIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 649  
             OperationFailedException, PermissionDeniedException {
 650  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 651  0
         return null;
 652  
     }
 653  
 
 654  
     @Override
 655  
     public StatusInfo insertCourseWaitlistEntryAtPosition(String courseWaitlistEntryId, Integer position, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 656  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 657  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 658  0
         return null;
 659  
     }
 660  
 
 661  
     @Override
 662  
     public StatusInfo removeCourseWaitlistEntry(String courseWaitlistEntryId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 663  
             OperationFailedException, PermissionDeniedException {
 664  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 665  0
         return null;
 666  
     }
 667  
 
 668  
     @Override
 669  
     public StatusInfo validateCourseWaitlistEntry(String validateTypeKey, CourseWaitlistEntryInfo courseWaitlistEntryInfo, ContextInfo context) throws DataValidationErrorException,
 670  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 671  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 672  0
         return null;
 673  
     }
 674  
 
 675  
     @Override
 676  
     public RegResponseInfo registerStudentFromWaitlist(String courseWaitlistEntryId, ContextInfo context) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException,
 677  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 678  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 679  0
         return null;
 680  
     }
 681  
 
 682  
     @Override
 683  
     public List<CourseWaitlistEntryInfo> getCourseWaitlistEntriesForCourseOffering(String courseOfferingId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 684  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 685  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 686  0
         return null;
 687  
     }
 688  
 
 689  
     @Override
 690  
     public List<CourseWaitlistEntryInfo> getCourseWaitlistEntriesForRegGroup(String regGroupId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 691  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 692  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 693  0
         return null;
 694  
     }
 695  
 
 696  
     @Override
 697  
     public List<CourseWaitlistEntryInfo> getCourseWaitlistEntriesForStudentInCourseOffering(String courseOfferingId, String studentId, ContextInfo context) throws DoesNotExistException,
 698  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 699  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 700  0
         return null;
 701  
     }
 702  
 
 703  
     @Override
 704  
     public CourseWaitlistEntryInfo getCourseWaitlistEntryForStudentInRegGroup(String regGroupId, String studentId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 705  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 706  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 707  0
         return null;
 708  
     }
 709  
 
 710  
     @Override
 711  
     public List<CourseWaitlistEntryInfo> getCourseWaitlistEntriesForStudentByTerm(String studentId, String termKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 712  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 713  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 714  0
         return null;
 715  
     }
 716  
 
 717  
     @Override
 718  
     public CourseRegistrationInfo getCourseRegistration(String courseRegistrationId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 719  
             OperationFailedException, PermissionDeniedException {
 720  0
         return new CourseRegistrationInfo();
 721  
 
 722  
     }
 723  
 
 724  
     @Override
 725  
     public List<CourseRegistrationInfo> getCourseRegistrationsByIds(List<String> courseRegistrationIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 726  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 727  
 
 728  0
         List<CourseRegistrationInfo> courseRegistrationInfos = new ArrayList<CourseRegistrationInfo>();
 729  0
         ResultValuesGroup rvGroup = null;
 730  0
         List<LuiPersonRelationInfo> lprs = lprService.getLprsByIds(courseRegistrationIds, context);
 731  0
         for (LuiPersonRelationInfo lpr : lprs) {
 732  0
             for (String rvGroupKey : lpr.getResultValuesGroupKeys()) {
 733  0
                 rvGroup = lrcService.getResultValuesGroup(rvGroupKey, context);
 734  0
                 if (rvGroup != null) {
 735  0
                     ResultScaleInfo resScale = lrcService.getResultScale(rvGroup.getResultScaleKey(), context);
 736  0
                     if (resScale != null) {
 737  0
                         if (StringUtils.equals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED, resScale.getTypeKey())) {
 738  0
                             courseRegistrationInfos.add(courseRegistrationAssembler.assemble(lpr, rvGroup, context));
 739  0
                             break;
 740  
                         }
 741  
                     }
 742  0
                 }
 743  
 
 744  
             }
 745  
         }
 746  
 
 747  0
         return courseRegistrationInfos;
 748  
 
 749  
     }
 750  
 
 751  
     // TODO - post core slice need to ensure that the list has one
 752  
     private List<LuiPersonRelationInfo> filterLprByState(List<LuiPersonRelationInfo> lprInfoList, String stateKey) {
 753  0
         List<LuiPersonRelationInfo> filteredLprInfoList = new ArrayList<LuiPersonRelationInfo>();
 754  0
         for (LuiPersonRelationInfo lprInfo : filteredLprInfoList) {
 755  0
             if (lprInfo.getStateKey().equals(stateKey)) {
 756  0
                 filteredLprInfoList.add(lprInfo);
 757  
             }
 758  
         }
 759  0
         return filteredLprInfoList;
 760  
     }
 761  
 
 762  
     @Override
 763  
     public CourseRegistrationInfo getActiveCourseRegistrationForStudentByCourseOffering(String studentId, String courseOfferingId, ContextInfo context) throws DoesNotExistException,
 764  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DisabledIdentifierException {
 765  
 
 766  0
         return new CourseRegistrationInfo();
 767  
     }
 768  
 
 769  
     @Override
 770  
     public List<CourseRegistrationInfo> getCourseRegistrationsForStudentByTerm(String studentId, String termKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 771  
             MissingParameterException, OperationFailedException, PermissionDeniedException, DisabledIdentifierException {
 772  
 
 773  0
         List<CourseRegistrationInfo> courseRegistrationList = new ArrayList<CourseRegistrationInfo>();
 774  
 
 775  0
         List<LuiPersonRelationInfo> courseLprList = lprService.getLprsByPersonForAtpAndLuiType(studentId, termKey, LuiServiceConstants.COURSE_OFFERING_TYPE_KEY, context);
 776  
 
 777  0
         List<LuiPersonRelationInfo> regGroupLprList = lprService.getLprsByPersonForAtpAndLuiType(studentId, termKey, LuiServiceConstants.REGISTRATION_GROUP_TYPE_KEY, context);
 778  
 
 779  0
         getCourseRegistration(studentId, courseRegistrationList, courseLprList, regGroupLprList, context);
 780  
 
 781  0
         return courseRegistrationList;
 782  
     }
 783  
 
 784  
     private void getCourseRegistration(String studentId, List<CourseRegistrationInfo> courseRegistrationList, List<LuiPersonRelationInfo> courseLprList, List<LuiPersonRelationInfo> regGroupLprList,
 785  
             ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DisabledIdentifierException {
 786  0
         if (courseLprList != null && !courseLprList.isEmpty()) {
 787  0
             for (LuiPersonRelationInfo courseOfferinglprInfo : courseLprList) {
 788  
 
 789  0
                 if (courseOfferinglprInfo.getTypeKey().equals(LuiPersonRelationServiceConstants.REGISTRANT_TYPE_KEY)) {
 790  0
                     CourseOfferingInfo courseOfferingInfo = courseOfferingService.getCourseOffering(courseOfferinglprInfo.getLuiId(), context);
 791  
 
 792  0
                     List<RegistrationGroupInfo> regGroupList = courseOfferingService.getRegistrationGroupsForCourseOffering(courseOfferinglprInfo.getLuiId(), context);
 793  
 
 794  0
                     for (RegistrationGroupInfo regGroup : regGroupList) {
 795  
 
 796  0
                         RegistrationGroupInfo reg = new RegistrationGroupInfo();
 797  
 
 798  0
                         Map<LuiPersonRelationInfo, ActivityOfferingInfo> activtiesLprInfoMap = new HashMap<LuiPersonRelationInfo, ActivityOfferingInfo>();
 799  
 
 800  0
                         for (LuiPersonRelationInfo regGroupLprInfo : regGroupLprList) {
 801  
 
 802  0
                             if (regGroup.getId().equals(regGroupLprInfo.getLuiId()) && regGroupLprInfo.getTypeKey().equals(LuiPersonRelationServiceConstants.REGISTRANT_TYPE_KEY)) {
 803  
 
 804  0
                                 reg = courseOfferingService.getRegistrationGroup(regGroup.getId(), context);
 805  
 
 806  0
                                 for (String activityOfferingId : regGroup.getActivityOfferingIds()) {
 807  
 
 808  0
                                     List<LuiPersonRelationInfo> lprsForActivity = lprService.getLprsByPersonAndLui(studentId, activityOfferingId, context);
 809  
 
 810  0
                                     for (LuiPersonRelationInfo activityLpr : lprsForActivity) {
 811  
 
 812  0
                                         if (activityLpr.getTypeKey().equals(LuiPersonRelationServiceConstants.REGISTRANT_TYPE_KEY) && activityLpr.getStateKey().equals(regGroupLprInfo.getStateKey())) {
 813  
 
 814  0
                                             ActivityOfferingInfo activityOffering = courseOfferingService.getActivityOffering(activityOfferingId, context);
 815  
 
 816  0
                                             activtiesLprInfoMap.put(activityLpr, activityOffering);
 817  0
                                         }
 818  
                                     }
 819  
 
 820  0
                                 }
 821  
 
 822  0
                                 courseRegistrationList.add(courseRegistrationAssembler.assemble(courseOfferinglprInfo, courseOfferingInfo, activtiesLprInfoMap, regGroupLprInfo, reg, context));
 823  
                             }
 824  
 
 825  
                         }
 826  
 
 827  0
                     }
 828  0
                 }
 829  
 
 830  
             }
 831  
         }
 832  0
     }
 833  
 
 834  
     @Override
 835  
     public List<CourseRegistrationInfo> getActiveCourseRegistrationsByCourseOfferingId(String courseOfferingId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 836  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 837  0
         List<CourseRegistrationInfo> courseRegInfoList = courseRegistrationAssembler.assembleList(lprService.getLprsByLui(courseOfferingId, context), context);
 838  0
         return courseRegInfoList;
 839  
     }
 840  
 
 841  
     @Override
 842  
     public List<RegRequestInfo> getRegRequestsForCourseRegistration(String courseRegistrationId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 843  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 844  0
         List<RegRequestInfo> regrequests = new ArrayList<RegRequestInfo>();
 845  0
         List<LprTransactionInfo> lprTransactions = lprService.getLprTransactionsWithItemsByResultingLpr(courseRegistrationId, context);
 846  0
         for (LprTransactionInfo lprTransaction : lprTransactions) {
 847  
 
 848  
             try {
 849  0
                 regrequests.add(regRequestAssembler.assemble(lprTransaction, context));
 850  0
             } catch (AssemblyException e) {
 851  0
                 throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 852  0
             }
 853  
 
 854  
         }
 855  
 
 856  0
         return regrequests;
 857  
     }
 858  
 
 859  
     @Override
 860  
     public List<RegRequestInfo> getRegRequestsForCourseOffering(String courseOfferingId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 861  
             OperationFailedException, PermissionDeniedException {
 862  0
         return regRequestAssembler.assembleList(lprService.getLprTransactionsWithItemsByLui(courseOfferingId, context), context);
 863  
 
 864  
     }
 865  
 
 866  
     @Override
 867  
     public List<RegRequestInfo> getRegRequestsForCourseOfferingByStudent(String courseOfferingId, String studentId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 868  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 869  0
         return regRequestAssembler.assembleList(lprService.getLprTransactionsWithItemsByPersonAndLui(studentId, courseOfferingId, context), context);
 870  
     }
 871  
 
 872  
     @Override
 873  
     public List<CourseRegistrationInfo> searchForCourseRegistrations(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 874  
             OperationFailedException, PermissionDeniedException {
 875  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 876  0
         return null;
 877  
     }
 878  
 
 879  
     @Override
 880  
     public List<String> searchForCourseOfferingRegistrationIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 881  
             PermissionDeniedException {
 882  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 883  0
         return null;
 884  
     }
 885  
 
 886  
     @Override
 887  
     public List<ActivityRegistrationInfo> searchForActivityRegistrations(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 888  
             OperationFailedException, PermissionDeniedException {
 889  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 890  0
         return null;
 891  
     }
 892  
 
 893  
     @Override
 894  
     public List<String> searchForActivityRegistrationIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 895  
             PermissionDeniedException {
 896  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 897  0
         return null;
 898  
     }
 899  
 
 900  
     @Override
 901  
     public List<RegGroupRegistrationInfo> searchForRegGroupRegistrations(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 902  
             OperationFailedException, PermissionDeniedException {
 903  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 904  0
         return null;
 905  
     }
 906  
 
 907  
     @Override
 908  
     public List<String> searchForRegGroupRegistrationIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 909  
             PermissionDeniedException {
 910  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 911  0
         return null;
 912  
     }
 913  
 
 914  
     @Override
 915  
     public List<CourseWaitlistEntryInfo> searchForCourseWaitlistEntries(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException,
 916  
             OperationFailedException, PermissionDeniedException {
 917  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 918  0
         return null;
 919  
     }
 920  
 
 921  
     @Override
 922  
     public List<String> searchForCourseWaitlistEntryIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 923  
             PermissionDeniedException {
 924  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 925  0
         return null;
 926  
     }
 927  
 
 928  
     @Override
 929  
     public RegRequestInfo getRegRequest(String regRequestId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
 930  
             PermissionDeniedException {
 931  0
         LprTransactionInfo lprTransaction = lprService.getLprTransaction(regRequestId, context);
 932  0
         RegRequestInfo regRequest = null;
 933  
         try {
 934  0
             regRequest = regRequestAssembler.assemble(lprTransaction, context);
 935  0
         } catch (AssemblyException e) {
 936  0
             throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage());
 937  0
         }
 938  0
         return regRequest;
 939  
     }
 940  
 
 941  
     @Override
 942  
     public StatusInfo deleteCourseWaitlistEntry(String courseWaitlistEntryId, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException,
 943  
             PermissionDeniedException {
 944  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 945  0
         return null;
 946  
     }
 947  
 
 948  
     @Override
 949  
     public RegResponseInfo dropStudentsFromRegGroups(List<String> regGroupIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 950  
             OperationFailedException, PermissionDeniedException {
 951  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 952  0
         return null;
 953  
     }
 954  
 
 955  
     @Override
 956  
     public RegResponseInfo moveStudentsBetweenRegGroups(String sourceRegGroupId, String destinationRegGroupId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 957  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 958  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 959  0
         return null;
 960  
     }
 961  
 
 962  
     @Override
 963  
     public List<CourseRegistrationInfo> getCourseRegistrationsForStudentByCourseOffering(String studentId, String courseOfferingId, ContextInfo context) throws DoesNotExistException,
 964  
             InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DisabledIdentifierException {
 965  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 966  0
         return null;
 967  
     }
 968  
 
 969  
     @Override
 970  
     public List<CourseRegistrationInfo> getDroppedCourseRegistrationsByCourseOfferingId(String courseOfferingId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
 971  
             MissingParameterException, OperationFailedException, PermissionDeniedException {
 972  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 973  0
         return null;
 974  
     }
 975  
 
 976  
     @Override
 977  
     public List<CourseRegistrationInfo> getCourseRegistrationsForStudent(String studentId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 978  
             OperationFailedException, PermissionDeniedException, DisabledIdentifierException {
 979  0
         List<CourseRegistrationInfo> courseRegistrationList = new ArrayList<CourseRegistrationInfo>();
 980  
 
 981  0
         List<LuiPersonRelationInfo> courseLprList = lprService.getLprsByPersonAndLuiType(studentId, LuiServiceConstants.COURSE_OFFERING_TYPE_KEY, context);
 982  
 
 983  0
         List<LuiPersonRelationInfo> regGroupLprList = lprService.getLprsByPersonAndLuiType(studentId, LuiServiceConstants.REGISTRATION_GROUP_TYPE_KEY, context);
 984  
 
 985  0
         getCourseRegistration(studentId, courseRegistrationList, courseLprList, regGroupLprList, context);
 986  
 
 987  0
         return courseRegistrationList;
 988  
     }
 989  
 }