Coverage Report - org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingViewHelperServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseOfferingViewHelperServiceImpl
0%
0/261
0%
0/88
5.056
 
 1  
 /**
 2  
  * Copyright 2012 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  *
 15  
  * Created by Charles on 5/7/12
 16  
  */
 17  
 package org.kuali.student.enrollment.class2.courseoffering.service.impl;
 18  
 
 19  
 import org.kuali.rice.core.api.criteria.PredicateFactory;
 20  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 21  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 22  
 import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl;
 23  
 import org.kuali.student.enrollment.acal.constants.AcademicCalendarServiceConstants;
 24  
 import org.kuali.student.enrollment.acal.dto.TermInfo;
 25  
 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
 26  
 import org.kuali.student.enrollment.class2.courseoffering.form.CourseOfferingRolloverManagementForm;
 27  
 import org.kuali.student.enrollment.class2.courseoffering.service.CourseOfferingViewHelperService;
 28  
 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
 29  
 import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
 30  
 import org.kuali.student.enrollment.courseoffering.dto.FinalExam;
 31  
 import org.kuali.student.enrollment.courseoffering.dto.FormatOfferingInfo;
 32  
 import org.kuali.student.enrollment.courseoffering.dto.OfferingInstructorInfo;
 33  
 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
 34  
 import org.kuali.student.enrollment.courseofferingset.dto.SocInfo;
 35  
 import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultInfo;
 36  
 import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultItemInfo;
 37  
 import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetService;
 38  
 import org.kuali.student.r2.common.constants.CommonServiceConstants;
 39  
 import org.kuali.student.r2.common.dto.ContextInfo;
 40  
 import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
 41  
 import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
 42  
 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
 43  
 import org.kuali.student.lum.course.service.CourseService;
 44  
 
 45  
 import javax.xml.namespace.QName;
 46  
 import java.util.ArrayList;
 47  
 import java.util.List;
 48  
 
 49  
 /**
 50  
  * This class //TODO ...
 51  
  *
 52  
  * @author Kuali Student Team
 53  
  */
 54  0
 public class CourseOfferingViewHelperServiceImpl extends ViewHelperServiceImpl implements CourseOfferingViewHelperService {
 55  0
     private AcademicCalendarService acalService = null;
 56  0
     private CourseOfferingService coService = null;
 57  0
     private CourseOfferingSetService socService = null;
 58  0
     private CourseService courseService = null;
 59  
 
 60  
     @Override
 61  
     public List<TermInfo> findTermByTermCode(String termCode) throws Exception {
 62  
         // TODO: Find sensible way to rewrap exception that acal service may throw
 63  
         // Find the term (alas, I think it does approximate search)
 64  0
         QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create();
 65  
         // TODO: How does one get rid of hard-coding "atpCode"?
 66  0
         qbcBuilder.setPredicates(PredicateFactory.equal("atpCode", termCode));
 67  
 
 68  0
         QueryByCriteria criteria = qbcBuilder.build();
 69  
 
 70  
         // Do search.  In ideal case, terms returns one element, which is the desired term.
 71  0
         AcademicCalendarService acalService = _getAcalService();
 72  0
         List<TermInfo> terms = acalService.searchForTerms(criteria, new ContextInfo());
 73  0
         return terms;
 74  
     }
 75  
 
 76  
     private CourseOfferingInfo _createCourseOffering(String termId) {
 77  0
         CourseOfferingService coService = _getCourseOfferingService();
 78  0
         CourseOfferingInfo coInfo = new CourseOfferingInfo();
 79  0
         coInfo.setCourseOfferingTitle("Intro to Finite Math");
 80  0
         coInfo.setTypeKey(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY);
 81  0
         coInfo.setStateKey(LuiServiceConstants.LUI_OFFERED_STATE_KEY);
 82  
         // info.setCourseId("REFERENCECOURSEMATH140");
 83  0
         coInfo.setCourseId("5aa58103-1644-40d8-8d9c-09f64e437b93"); // In the new DB
 84  0
         coInfo.setCourseOfferingCode("MATH106");
 85  0
         coInfo.setCourseNumberSuffix("106");
 86  0
         coInfo.setEvaluated(Boolean.TRUE);
 87  0
         coInfo.setFinalExamType(FinalExam.STANDARD.fromEnum());
 88  0
         coInfo.setTermId(termId);
 89  0
         coInfo.setFeeAtActivityOffering(Boolean.FALSE);
 90  0
         coInfo.setInstructors(new ArrayList<OfferingInstructorInfo>());
 91  
         try {
 92  0
             String courseId = coInfo.getCourseId();
 93  0
             String infoTermId = coInfo.getTermId();
 94  0
             String typeKey = coInfo.getTypeKey();
 95  0
             List<String> options = new ArrayList<String>();
 96  0
             ContextInfo contextInfo = new ContextInfo();
 97  0
             CourseOfferingInfo result = coService.createCourseOffering(courseId, infoTermId, typeKey, coInfo,
 98  
                                                                        options, contextInfo);
 99  0
             return result;
 100  0
         } catch (Exception e) {
 101  0
             e.printStackTrace();
 102  0
             return null;
 103  
         }
 104  
     }
 105  
 
 106  
     private FormatOfferingInfo _createFormatOffering(CourseOfferingInfo coInfo) {
 107  0
         FormatOfferingInfo foInfo = new FormatOfferingInfo();
 108  0
         foInfo.setName("DEVTEST");
 109  0
         foInfo.setCourseOfferingId(coInfo.getId());
 110  0
         foInfo.setFormatId("5b264632-0eba-479c-bce8-66d35a05b834");
 111  0
         foInfo.setTypeKey(LuiServiceConstants.FORMAT_OFFERING_TYPE_KEY);
 112  0
         foInfo.setStateKey(LuiServiceConstants.LUI_OFFERED_STATE_KEY);
 113  
         try {
 114  0
             FormatOfferingInfo result =
 115  
                     coService.createFormatOffering(coInfo.getId(), foInfo.getFormatId(), foInfo.getTypeKey(), foInfo, new ContextInfo());
 116  0
             return result;
 117  0
         } catch (Exception e) {
 118  0
             e.printStackTrace();
 119  0
             return null;
 120  
         }
 121  
     }
 122  
 
 123  
     private ActivityOfferingInfo _createActivityOffering(FormatOfferingInfo foInfo, CourseOfferingInfo coInfo) {
 124  0
         ActivityOfferingInfo aoInfo = new ActivityOfferingInfo();
 125  0
         aoInfo.setActivityId("3a8d155d-715a-43ab-b9ca-6575f576b5c4");
 126  0
         aoInfo.setName("DEVTEST");
 127  0
         aoInfo.setTypeKey(LuiServiceConstants.LECTURE_ACTIVITY_OFFERING_TYPE_KEY);
 128  0
         aoInfo.setStateKey(LuiServiceConstants.LUI_OFFERED_STATE_KEY);
 129  0
         aoInfo.setActivityCode("A");
 130  0
         aoInfo.setCourseOfferingCode(coInfo.getCourseOfferingCode());
 131  0
         aoInfo.setCourseOfferingTitle(coInfo.getCourseOfferingTitle());
 132  0
         aoInfo.setFormatOfferingId(foInfo.getId());
 133  
         try {
 134  0
             ActivityOfferingInfo result =
 135  
                     coService.createActivityOffering(foInfo.getId(), aoInfo.getActivityId(), aoInfo.getTypeKey(), aoInfo, new ContextInfo());
 136  0
             return result;
 137  0
         } catch (Exception e) {
 138  0
             e.printStackTrace();
 139  0
             return null;
 140  
         }
 141  
     }
 142  
 
 143  
     private List<CourseOfferingInfo> _getCourseOfferingsByTerm(String termId) {
 144  0
         CourseOfferingSetService socService = _getSocService();
 145  
         try {
 146  0
             List<String> socIds = socService.getSocIdsByTerm(termId, new ContextInfo());
 147  0
             SocInfo soc = null;
 148  0
             if (socIds != null && socIds.size() > 0) {
 149  0
                 soc = socService.getSoc(socIds.get(0), new ContextInfo());
 150  
             }
 151  0
             List<String> coIds = socService.getCourseOfferingIdsBySoc(soc.getId(), new ContextInfo());
 152  0
             List<CourseOfferingInfo> coInfos = new ArrayList<CourseOfferingInfo>();
 153  0
             for (String id: coIds) {
 154  0
                 CourseOfferingInfo coInfo = coService.getCourseOffering(id, new ContextInfo());
 155  0
                 coInfos.add(coInfo);
 156  0
             }
 157  0
             return coInfos;
 158  0
         } catch (Exception e) {
 159  0
             return null;
 160  
         }
 161  
     }
 162  
 
 163  
     private void _deleteCourseOfferingById(String coId) {
 164  0
         CourseOfferingService coService = _getCourseOfferingService();
 165  
         try {
 166  0
             coService.deleteCourseOffering(coId, new ContextInfo());
 167  0
         } catch (Exception e) {
 168  0
         }
 169  0
     }
 170  
 
 171  
     private void _verify(CourseOfferingInfo coInfo, FormatOfferingInfo foInfo, ActivityOfferingInfo aoInfo) {
 172  0
         CourseOfferingService coService = _getCourseOfferingService();
 173  
         CourseOfferingInfo coFetched;
 174  
         FormatOfferingInfo foFetched;
 175  
         ActivityOfferingInfo aoFetched;
 176  
         try {
 177  0
             coFetched = coService.getCourseOffering(coInfo.getId(), new ContextInfo());
 178  0
             foFetched = coService.getFormatOffering(foInfo.getId(), new ContextInfo());
 179  0
             aoFetched = coService.getActivityOffering(aoInfo.getId(), new ContextInfo());
 180  0
             System.err.println("Success 1");
 181  0
         } catch (Exception e) {
 182  0
             System.err.println("Error");
 183  0
         }
 184  0
         System.err.println("Success");
 185  0
     }
 186  
     @Override
 187  
     public SocInfo createSocCoFoAoForTerm(String termId, CourseOfferingRolloverManagementForm form) {
 188  0
         CourseOfferingInfo coOffering = _createCourseOffering(termId);
 189  
 
 190  0
         if (coOffering == null) {
 191  0
             form.setStatusField("createSocCoFoAoForTerm: Course offering not created");
 192  
         }
 193  0
         FormatOfferingInfo foOffering = _createFormatOffering(coOffering);
 194  0
         ActivityOfferingInfo aoOffering = _createActivityOffering(foOffering, coOffering);
 195  0
         _verify(coOffering, foOffering, aoOffering);
 196  0
         CourseOfferingSetService socService = _getSocService();
 197  
         // Create the SOC
 198  0
         SocInfo socInfo = new SocInfo();
 199  0
         socInfo.setTypeKey(CourseOfferingSetServiceConstants.MAIN_SOC_TYPE_KEY);
 200  0
         socInfo.setStateKey(CourseOfferingSetServiceConstants.ACTIVE_SOC_STATE_KEY);
 201  0
         socInfo.setTermId(termId);
 202  
         try {
 203  0
             String socTermId = socInfo.getTermId();
 204  0
             String typeKey = socInfo.getTypeKey();
 205  0
             ContextInfo contextInfo = new ContextInfo();
 206  0
             SocInfo result = socService.createSoc(socTermId, typeKey, socInfo, contextInfo);
 207  0
             return result;
 208  0
         } catch (Exception e) {
 209  0
             return null;
 210  
         }
 211  
     }
 212  
 
 213  
     private String _deleteSocAndCourseOfferingsByTerm(String termId, String termCode) {
 214  0
         CourseOfferingSetService socService = _getSocService();
 215  0
         CourseOfferingService coService = _getCourseOfferingService();
 216  0
         String mesg = "";
 217  
         try {
 218  0
             List<String> socIds = socService.getSocIdsByTerm(termId, new ContextInfo());
 219  0
             if (socIds == null || socIds.isEmpty()) {
 220  0
                 mesg = "NO_SOC";
 221  
             } 
 222  
             // String socId = socIds.get(0);
 223  
             // TODO: Ideally, use socService.getCourseOfferingsBySoc()
 224  0
             List<String> coIds = coService.getCourseOfferingIdsByTerm(termId, Boolean.FALSE, new ContextInfo());
 225  0
             if (coIds.size() > 3) {
 226  0
                 return "MANYCOS";
 227  
             } else {
 228  
                 // TODO: Currently, deleteCourseOfferingsByTerm is not implemented in SOC service
 229  0
                 for (String coId: coIds) {
 230  0
                     coService.deleteCourseOffering(coId, new ContextInfo());
 231  
                 }
 232  0
                 if (!mesg.equals("NO_SOC")) {
 233  0
                     String socId = socIds.get(0);
 234  0
                     socService.deleteSoc(socId, new ContextInfo());
 235  
                 }
 236  
             }
 237  0
             return mesg;
 238  0
         } catch (Exception e) {
 239  0
             e.printStackTrace();
 240  0
             return e.getMessage();
 241  
         }
 242  
     }
 243  
 
 244  
     @Override
 245  
     public SocRolloverResultInfo performReverseRollover(String sourceTermId, String targetTermId, CourseOfferingRolloverManagementForm form) {
 246  0
         CourseOfferingSetService socService = _getSocService();
 247  
         try {
 248  0
             List<String> socIds = socService.getSocIdsByTerm(sourceTermId, new ContextInfo());
 249  0
             if (socIds == null || socIds.isEmpty()) {
 250  0
                 form.setStatusField("No SOCS in source term");
 251  0
                 return null;
 252  0
             } else if (socIds.size() > 1) {
 253  0
                 form.setStatusField("Too many SOCS in source term: " + socIds.size());
 254  0
                 return null;
 255  
             } else {
 256  0
                 String sourceSocId = socIds.get(0);
 257  0
                 List<String> resultIds = socService.getSocRolloverResultIdsBySourceSoc(sourceSocId, new ContextInfo());
 258  0
                 if (resultIds == null || resultIds.isEmpty()) {
 259  0
                     form.setStatusField("No rollover results for source term");
 260  0
                     return null;
 261  0
                 } else if (resultIds.size() > 1) {
 262  0
                     form.setStatusField("Too many rollover results for source term: " + resultIds.size());
 263  0
                     return null;
 264  
                 } else {
 265  0
                     String socResultId = resultIds.get(0);
 266  0
                     List<String> options = new ArrayList<String>();
 267  0
                     SocRolloverResultInfo info = socService.reverseRollover(socResultId, options, new ContextInfo());
 268  0
                     return info;
 269  
                 }
 270  
             }
 271  0
         } catch (Exception e) {
 272  0
             return null;       
 273  
         }
 274  
     }
 275  
     
 276  
     @Override
 277  
     public SocInfo performRollover(String sourceTermId, String targetTermId, CourseOfferingRolloverManagementForm form) {
 278  0
         CourseOfferingSetService socService = _getSocService();
 279  
         try {
 280  0
             List<String> socIds = socService.getSocIdsByTerm(sourceTermId, new ContextInfo());
 281  0
             if (socIds == null || socIds.isEmpty()) {
 282  0
                 form.setStatusField("No source soc ID found");
 283  0
             } else if (socIds.size() > 1) {
 284  0
                 form.setStatusField("Too many SOCs in source term: " + socIds.size());
 285  
             } else {
 286  0
                 String sourceSocId = socIds.get(0);
 287  0
                 List<String> options = new ArrayList<String>();
 288  
                 // TODO: Force rollover to run synchronously for now
 289  0
                 options.add(CourseOfferingSetServiceConstants.RUN_SYNCHRONOUSLY_OPTION_KEY);
 290  0
                 options.add(CourseOfferingSetServiceConstants.LOG_SUCCESSES_OPTION_KEY);
 291  0
                 SocInfo result = socService.rolloverSoc(sourceSocId, targetTermId, options, new ContextInfo());
 292  0
                 return result;
 293  
             }
 294  0
         } catch (Exception e) {
 295  0
             System.err.println("--------- rollover exception in performRollover [START]");
 296  0
             e.printStackTrace();
 297  0
             System.err.println("--------- rollover exception in performRollover [END]");
 298  0
             form.setStatusField("performRollover: Exception thrown");
 299  0
         }
 300  0
         return null;
 301  
     }
 302  
 
 303  
     @Override
 304  
     public void cleanTargetTerm(String targetTermId, CourseOfferingRolloverManagementForm form) {
 305  
         // Remove SOCS, SOCResults, and course offerings
 306  0
         CourseOfferingSetService socService = _getSocService();
 307  0
         CourseOfferingService coService = _getCourseOfferingService();
 308  
 
 309  
         try {
 310  
             // First, the course offerings
 311  0
             List<String> coIds = coService.getCourseOfferingIdsByTerm(targetTermId, Boolean.FALSE, new ContextInfo());
 312  0
             if (coIds != null) {
 313  0
                 for (String coId : coIds) {
 314  0
                     List<FormatOfferingInfo> foInfos =
 315  
                             coService.getFormatOfferingsByCourseOffering(coId, new ContextInfo());
 316  0
                     for (FormatOfferingInfo foInfo: foInfos) {
 317  0
                         String foId = foInfo.getId();
 318  
                         // Delete activity offerings
 319  0
                         List<ActivityOfferingInfo> aoInfos =
 320  
                                 coService.getActivityOfferingsByFormatOffering(foId, new ContextInfo());
 321  0
                         for (ActivityOfferingInfo aoInfo: aoInfos) {
 322  0
                             coService.deleteActivityOffering(aoInfo.getId(), new ContextInfo());
 323  
                         }
 324  
                         // Delete format offerings first
 325  0
                         coService.deleteFormatOffering(foInfo.getId(), new ContextInfo());
 326  0
                     }
 327  0
                     coService.deleteCourseOffering(coId, new ContextInfo());
 328  0
                 }
 329  
             }
 330  
             // Then, SocRolloverItems
 331  0
             List<String> socIds = socService.getSocIdsByTerm(targetTermId, new ContextInfo());
 332  0
             if (socIds != null) {
 333  0
                 ContextInfo contextInfo = new ContextInfo();
 334  0
                 for (String targetSocId : socIds) {
 335  0
                     SocInfo socInfo = socService.getSoc(targetSocId, new ContextInfo());
 336  0
                     if (socInfo.getTypeKey().equals(CourseOfferingSetServiceConstants.MAIN_SOC_TYPE_KEY)) {
 337  0
                         List<String> resultIds = socService.getSocRolloverResultIdsByTargetSoc(targetSocId, contextInfo);
 338  0
                         if (resultIds != null) {
 339  0
                             for (String resultId: resultIds) {
 340  0
                                 List<SocRolloverResultItemInfo> items = socService.getSocRolloverResultItemsByResultId(resultId, contextInfo);
 341  
                                 // Items deleted here
 342  0
                                 for (SocRolloverResultItemInfo item: items) {
 343  0
                                     socService.deleteSocRolloverResultItem(item.getId(), contextInfo);
 344  
                                 }
 345  
                                 // Results deleted here
 346  0
                                 socService.deleteSocRolloverResult(resultId, contextInfo);
 347  0
                             }
 348  
                         }
 349  
                         // Finally, delete the SOC
 350  0
                         socService.deleteSoc(targetSocId, contextInfo);
 351  
                     }
 352  0
                 }
 353  
             }
 354  
             
 355  0
         } catch (Exception ex) {
 356  0
             form.setStatusField("Exception in cleanTargetTerm");
 357  0
         }
 358  0
     }
 359  
 
 360  
     @Override
 361  
     public boolean cleanSourceTerm(String sourceTermId, CourseOfferingRolloverManagementForm form) {
 362  
      // Remove SOCS, SOCResults, and course offerings
 363  0
         CourseOfferingSetService socService = _getSocService();
 364  0
         CourseOfferingService coService = _getCourseOfferingService();
 365  
 
 366  
         try {
 367  
             // Delete course offerings since they will be regenerated
 368  0
             List<String> coIds = coService.getCourseOfferingIdsByTerm(sourceTermId, Boolean.TRUE, new ContextInfo());
 369  0
             if (coIds != null) {
 370  0
                 if (coIds.size() > 3) {
 371  
                     // Probably deleting wrong term
 372  0
                     form.setStatusField("Too many course offerings to delete: " + coIds.size());
 373  0
                     return false;
 374  
                 } else {
 375  
                     // Delete course offerings
 376  0
                     for (String coId : coIds) {
 377  0
                         List<FormatOfferingInfo> foInfos =
 378  
                                 coService.getFormatOfferingsByCourseOffering(coId, new ContextInfo());
 379  0
                         for (FormatOfferingInfo foInfo: foInfos) {
 380  0
                             String foId = foInfo.getId();
 381  
                             // Delete activity offerings
 382  0
                             List<ActivityOfferingInfo> aoInfos =
 383  
                                     coService.getActivityOfferingsByFormatOffering(foId, new ContextInfo());
 384  0
                             for (ActivityOfferingInfo aoInfo: aoInfos) {
 385  0
                                 coService.deleteActivityOffering(aoInfo.getId(), new ContextInfo());
 386  
                             }
 387  
                             // Delete format offerings first
 388  0
                             coService.deleteFormatOffering(foInfo.getId(), new ContextInfo());
 389  0
                         }
 390  0
                         coService.deleteCourseOffering(coId, new ContextInfo());
 391  0
                     }
 392  
                 }
 393  
             }
 394  
             // Then, SocRolloverItems
 395  0
             List<String> socIds = socService.getSocIdsByTerm(sourceTermId, new ContextInfo());
 396  0
             if (socIds != null) {
 397  0
                 ContextInfo contextInfo = new ContextInfo();
 398  0
                 for (String sourceSocId: socIds) {
 399  0
                     SocInfo socInfo = socService.getSoc(sourceSocId, new ContextInfo());
 400  0
                     if (socInfo.getTypeKey().equals(CourseOfferingSetServiceConstants.MAIN_SOC_TYPE_KEY)) {
 401  
                         // Only deal with main SOCs for now
 402  0
                         List<String> resultIds = socService.getSocRolloverResultIdsBySourceSoc(sourceSocId, contextInfo);
 403  0
                         if (resultIds != null) {
 404  0
                             for (String resultId: resultIds) {
 405  0
                                 List<SocRolloverResultItemInfo> items = socService.getSocRolloverResultItemsByResultId(resultId, contextInfo);
 406  
                                 // Items deleted here
 407  0
                                 for (SocRolloverResultItemInfo item: items) {
 408  0
                                     socService.deleteSocRolloverResultItem(item.getId(), contextInfo);
 409  
                                 }
 410  
                                 // Results deleted here
 411  0
                                 socService.deleteSocRolloverResult(resultId, contextInfo);
 412  0
                             }
 413  
                         }
 414  
                         // Finally, delete the SOC
 415  0
                         socService.deleteSoc(sourceSocId, contextInfo);
 416  
                     }
 417  0
                 }
 418  
             }
 419  0
             return true;
 420  0
         } catch (Exception ex) {
 421  0
             form.setStatusField("Exception in cleanTargetTerm");
 422  0
             return false;
 423  
         }
 424  
     }
 425  
 
 426  
     private List<SocInfo> _getSocsByTerm(String termId) {
 427  0
         CourseOfferingSetService socService = _getSocService();
 428  
         try {
 429  0
             List<String> socIds = socService.getSocIdsByTerm(termId, new ContextInfo());
 430  0
             List<SocInfo> socInfos = new ArrayList<SocInfo>();
 431  0
             for (String id: socIds) {
 432  0
                 SocInfo info = socService.getSoc(id, new ContextInfo());
 433  0
                 socInfos.add(info);
 434  0
             }
 435  0
             return socInfos;
 436  0
         } catch (Exception e) {
 437  0
             return null;
 438  
         }
 439  
     }
 440  
 
 441  
     private AcademicCalendarService _getAcalService() {
 442  0
         if (acalService == null) {
 443  0
             acalService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(AcademicCalendarServiceConstants.NAMESPACE,
 444  
                                                                                     AcademicCalendarServiceConstants.SERVICE_NAME_LOCAL_PART));
 445  
         }
 446  0
         return acalService;
 447  
     }
 448  
 
 449  
     private CourseOfferingService _getCourseOfferingService() {
 450  0
         if (coService == null) {
 451  0
             coService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE,
 452  
                          CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
 453  
         }
 454  0
         return coService;
 455  
     }
 456  
 
 457  
     private CourseOfferingSetService _getSocService() {
 458  0
         if (socService == null) {
 459  0
             socService = (CourseOfferingSetService) GlobalResourceLoader.getService(new QName(CourseOfferingSetServiceConstants.NAMESPACE,
 460  
                           CourseOfferingSetServiceConstants.SERVICE_NAME_LOCAL_PART));
 461  
         }
 462  0
         return socService;
 463  
     }
 464  
 
 465  
     private CourseService _getCourseService() {
 466  0
         if (courseService == null) {
 467  0
             Object o = GlobalResourceLoader.getService(new QName(CommonServiceConstants.REF_OBJECT_URI_GLOBAL_PREFIX + "course",
 468  
                     "CourseService"));
 469  0
             courseService = (CourseService) o;
 470  
         }
 471  0
         return courseService;
 472  
     }
 473  
 }