Пример #1
0
  public ActionForward insert(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {

    IUserView userView = UserView.getUser();

    DynaActionForm dynaForm = (DynaValidatorForm) form;
    String code = (String) dynaForm.get("code");
    String name = (String) dynaForm.get("name");
    String nameEn = (String) dynaForm.get("nameEn");
    String degreeTypeInt = (String) dynaForm.get("degreeType");
    String gradeTypeString = (String) dynaForm.get("gradeType");

    DegreeType degreeType = DegreeType.valueOf(degreeTypeInt);
    GradeScale gradeScale = null;
    if (gradeTypeString != null && gradeTypeString.length() > 0) {
      gradeScale = GradeScale.valueOf(gradeTypeString);
    }

    try {
      InsertDegree.run(code, name, nameEn, degreeType, gradeScale);

    } catch (ExistingServiceException ex) {
      throw new ExistingActionException(
          "message.already.existing.degree", mapping.findForward("readDegrees"));
    } catch (FenixServiceException e) {
      throw new FenixActionException(e.getMessage());
    }

    return mapping.findForward("readDegrees");
  }
  public ActionForward insert(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {

    User userView = Authenticate.getUser();

    final Degree degree = FenixFramework.getDomainObject(request.getParameter("degreeId"));

    DynaActionForm dynaForm = (DynaValidatorForm) form;

    String name = (String) dynaForm.get("name");
    String stateString = (String) dynaForm.get("state");
    String initialDateString = (String) dynaForm.get("initialDate");
    String endDateString = (String) dynaForm.get("endDate");
    Integer degreeDuration = new Integer((String) dynaForm.get("degreeDuration"));
    Integer minimalYearForOptionalCourses =
        new Integer((String) dynaForm.get("minimalYearForOptionalCourses"));
    String neededCreditsString = (String) dynaForm.get("neededCredits");
    String markTypeString = (String) dynaForm.get("markType");
    String numerusClaususString = (String) dynaForm.get("numerusClausus");
    String anotationString = (String) dynaForm.get("anotation");

    String gradeTypeString = (String) dynaForm.get("gradeType");
    GradeScale gradeScale = null;
    if (gradeTypeString != null && gradeTypeString.length() > 0) {
      gradeScale = GradeScale.valueOf(gradeTypeString);
    }

    InfoDegreeCurricularPlanEditor infoDegreeCurricularPlan = new InfoDegreeCurricularPlanEditor();
    DegreeCurricularPlanState state = DegreeCurricularPlanState.valueOf(stateString);

    Calendar initialDate = Calendar.getInstance();
    if (initialDateString.compareTo("") != 0) {
      String[] initialDateTokens = initialDateString.split("/");
      initialDate.set(Calendar.DAY_OF_MONTH, (new Integer(initialDateTokens[0])).intValue());
      initialDate.set(Calendar.MONTH, (new Integer(initialDateTokens[1])).intValue() - 1);
      initialDate.set(Calendar.YEAR, (new Integer(initialDateTokens[2])).intValue());
      infoDegreeCurricularPlan.setInitialDate(initialDate.getTime());
    }

    Calendar endDate = Calendar.getInstance();
    if (endDateString.compareTo("") != 0) {
      String[] endDateTokens = endDateString.split("/");
      endDate.set(Calendar.DAY_OF_MONTH, (new Integer(endDateTokens[0])).intValue());
      endDate.set(Calendar.MONTH, (new Integer(endDateTokens[1])).intValue() - 1);
      endDate.set(Calendar.YEAR, (new Integer(endDateTokens[2])).intValue());
      infoDegreeCurricularPlan.setEndDate(endDate.getTime());
    }

    if (endDate.before(initialDate)) {
      throw new InvalidArgumentsActionException("message.manager.date.restriction");
    }

    if (neededCreditsString.compareTo("") != 0) {
      Double neededCredits = new Double(neededCreditsString);
      infoDegreeCurricularPlan.setNeededCredits(neededCredits);
    }

    MarkType markType = new MarkType(new Integer(markTypeString));
    infoDegreeCurricularPlan.setMarkType(markType);

    if (numerusClaususString.compareTo("") != 0) {
      Integer numerusClausus = new Integer(numerusClaususString);
      infoDegreeCurricularPlan.setNumerusClausus(numerusClausus);
    }

    infoDegreeCurricularPlan.setName(name);
    infoDegreeCurricularPlan.setState(state);
    infoDegreeCurricularPlan.setDegreeDuration(degreeDuration);
    infoDegreeCurricularPlan.setMinimalYearForOptionalCourses(minimalYearForOptionalCourses);
    infoDegreeCurricularPlan.setAnotation(anotationString);
    infoDegreeCurricularPlan.setGradeScale(gradeScale);
    InfoDegree infoDegree = new InfoDegree(degree);
    infoDegreeCurricularPlan.setInfoDegree(infoDegree);

    try {
      InsertDegreeCurricularPlan.run(infoDegreeCurricularPlan);

    } catch (ExistingServiceException ex) {
      throw new ExistingActionException(ex.getMessage(), ex);
    } catch (NonExistingServiceException exception) {
      throw new NonExistingActionException(
          "message.nonExistingDegree", mapping.findForward("readDegree"));
    } catch (FenixServiceException e) {
      throw new FenixActionException(e);
    }

    return mapping.findForward("readDegree");
  }