private ResultValuesGroupInfo _createCreditOptions(String credits, ContextInfo context) {
   ResultValuesGroupInfo info = new ResultValuesGroupInfo();
   info.setKey(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE + credits);
   info.setName(credits);
   info.setResultValueKeys(Arrays.asList(credits));
   return info;
 }
  protected static void populateCreateCourseOfferingForm(
      MaintenanceDocumentForm form, HttpServletRequest request) {
    int firstValue = 0;

    try {
      ContextInfo contextInfo = ContextUtils.createDefaultContextInfo();
      MaintenanceDocument document = form.getDocument();
      String termId = request.getParameter(CourseOfferingConstants.TARGET_TERM_ID);
      CourseInfo courseInfo =
          CourseOfferingManagementUtil.getCourseService()
              .getCourse(request.getParameter(CourseOfferingConstants.COURSE_ID), contextInfo);

      // 1. set CourseOfferingInfo - no saved Course Offering as of yet (see logic in
      // CourseOfferingEditMaintainableImpl.retrieveObjectForEditOrCopy
      CourseOfferingInfo coInfo =
          CourseOfferingManagementUtil.createCourseOfferingInfo(termId, courseInfo);
      // set the default value for hasWaitlist based on info defined in ks-enroll-config.xml through
      // CourseWaitListServiceFacade
      coInfo.setHasWaitlist(getCourseWaitListServiceFacade().getHasWaitlist());

      CourseOfferingEditWrapper formObject = new CourseOfferingEditWrapper(coInfo);
      formObject.setCreateCO(true);

      // 2. set CourseInfo
      formObject.setCourse(courseInfo);

      // 3. set formatOfferingList
      formObject.setFormatOfferingList(new ArrayList<FormatOfferingWrapper>());
      FormatOfferingWrapper defaultFO = new FormatOfferingWrapper();
      defaultFO.setFormatId(courseInfo.getFormats().get(firstValue).getId());
      defaultFO.getRenderHelper().setNewRow(true);
      defaultFO.setCourseOfferingWrapper(formObject);
      formObject.getFormatOfferingList().add(defaultFO);
      formObject.setFinalExamDriver(LuServiceConstants.LU_EXAM_DRIVER_AO_KEY);

      // 4. Checking if Grading Options should be disabled or not and assign default (if no value)
      // 5. Checking if there are any student registration options from CLU for screen display
      List<String> studentRegOptions = new ArrayList<String>();
      List<String> crsGradingOptions = new ArrayList<String>();
      if (courseInfo != null) {
        List<String> gradingOptions = courseInfo.getGradingOptions();
        Set<String> regOpts =
            new HashSet<String>(
                Arrays.asList(
                    CourseOfferingServiceConstants.ALL_STUDENT_REGISTRATION_OPTION_TYPE_KEYS));
        for (String gradingOption : gradingOptions) {
          if (regOpts.contains(gradingOption)) {
            studentRegOptions.add(gradingOption);
          } else {
            crsGradingOptions.add(gradingOption);
          }
        }
        // Audit is pulled out into a dynamic attribute on course so map it back
        if ("true"
            .equals(
                courseInfo.getAttributeValue(
                    CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_AUDIT))) {
          studentRegOptions.add(LrcServiceConstants.RESULT_GROUP_KEY_GRADE_AUDIT);
        }
      }

      formObject.setStudentRegOptions(studentRegOptions);
      formObject.setCrsGradingOptions(crsGradingOptions);

      // 6. Defining Credit Option and if CLU is fixed (then it's disabled)
      boolean creditOptionFixed = false;
      CreditOptionInfo creditOption = new CreditOptionInfo();

      // Grab the Course's credit constraints
      // FindBugs: getCreditOptions() null check is in CourseInfo
      List<ResultValuesGroupInfo> courseCreditOptions = courseInfo.getCreditOptions();

      // Lookup the related course's credit constraints and set them on the creditOption
      if (!courseCreditOptions.isEmpty()) {
        ResultValuesGroupInfo resultValuesGroupInfo = courseCreditOptions.get(firstValue);
        // Check for fixed
        if (resultValuesGroupInfo
            .getTypeKey()
            .equalsIgnoreCase(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED)) {
          if (!resultValuesGroupInfo.getResultValueKeys().isEmpty()) {
            creditOption.setCourseFixedCredits(
                CourseOfferingManagementUtil.getLrcService()
                    .getResultValue(
                        resultValuesGroupInfo.getResultValueKeys().get(firstValue), contextInfo)
                    .getValue());
          }
          // Set the flag
          creditOptionFixed = true;

          // Default the value
          creditOption.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED);
          creditOption.setFixedCredit(creditOption.getCourseFixedCredits());
          creditOption.getAllowedCredits().add(creditOption.getCourseFixedCredits());
        } else {
          // This is either range or multiple

          // Copy all the allowed credits and sort so that the multiple checkboxes can be properly
          // displayed
          List<ResultValueInfo> resultValueInfos =
              CourseOfferingManagementUtil.getLrcService()
                  .getResultValuesForResultValuesGroup(resultValuesGroupInfo.getKey(), contextInfo);
          for (ResultValueInfo rVI : resultValueInfos) {
            creditOption.getAllowedCredits().add(rVI.getValue());
          }
          Collections.sort(creditOption.getAllowedCredits());

          if (resultValuesGroupInfo
              .getTypeKey()
              .equalsIgnoreCase(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE)) {
            creditOption.setCourseMinCredits(
                resultValuesGroupInfo.getResultValueRange().getMinValue());
            creditOption.setCourseMaxCredits(
                resultValuesGroupInfo.getResultValueRange().getMaxValue());

            // Default the value
            creditOption.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE);
            creditOption.setMinCredits(creditOption.getCourseMinCredits());
            creditOption.setMaxCredits(creditOption.getCourseMaxCredits());
          } else if (resultValuesGroupInfo
              .getTypeKey()
              .equalsIgnoreCase(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE)) {
            // Default the value
            creditOption.setTypeKey(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE);
            creditOption.getCredits().addAll(creditOption.getAllowedCredits());
          }
        }
      }

      formObject.setCreditOption(creditOption);
      formObject.setCreditOptionFixed(creditOptionFixed);

      formObject.setOrganizationNames(new ArrayList<OrganizationInfoWrapper>());

      ArrayList<OrganizationInfoWrapper> orgList = new ArrayList<OrganizationInfoWrapper>();

      if (courseInfo.getUnitsContentOwner() != null
          && !courseInfo.getUnitsContentOwner().isEmpty()) {
        for (String orgId : courseInfo.getUnitsContentOwner()) {
          OrgInfo orgInfo =
              CourseOfferingManagementUtil.getOrganizationService().getOrg(orgId, contextInfo);
          orgList.add(new OrganizationInfoWrapper(orgInfo));
        }
      }
      formObject.setOrganizationNames(orgList);

      // retrieve exam period id for the term that the CO is attached to
      try {
        String examPeriodId =
            CourseOfferingManagementUtil.getExamOfferingServiceFacade()
                .getExamPeriodId(
                    formObject.getCourseOfferingInfo().getTermId(),
                    ContextUtils.createDefaultContextInfo());
        if (!StringUtils.isEmpty(examPeriodId)) {
          formObject.setExamPeriodId(examPeriodId);
        }
      } catch (DoesNotExistException e) {
        LOG.warn(
            "The Term {} that the course offering {} is attached to doesn't have an exam period to create exam offerings.",
            formObject.getCourseOfferingInfo().getTermId(),
            formObject.getCourseOfferingCode());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }

      formObject.setUseFinalExamMatrixSystemDefault(
          CourseOfferingManagementUtil.getExamOfferingServiceFacade().isUseFinalExamMatrix());
      formObject.setUseFinalExamMatrix(
          CourseOfferingManagementUtil.getExamOfferingServiceFacade().isUseFinalExamMatrix());

      // adding SOC
      SocInfo socInfo =
          CourseOfferingManagementUtil.getCourseOfferingSetService()
              .getSoc(request.getParameter(CourseOfferingConstants.SOC_ID), contextInfo);
      formObject.setSocInfo(socInfo);

      setTermPropertiesOnFormObject(formObject, termId, contextInfo);
      formObject.setContextBar(
          CourseOfferingContextBar.NEW_INSTANCE(
              formObject.getTerm(),
              formObject.getSocInfo(),
              CourseOfferingManagementUtil.getStateService(),
              CourseOfferingManagementUtil.getAcademicCalendarService(),
              contextInfo));

      document.getNewMaintainableObject().setDataObject(formObject);
      document.getOldMaintainableObject().setDataObject(formObject);
      document.getDocumentHeader().setDocumentDescription("Create CO - " + courseInfo.getCode());

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }