Пример #1
0
  public static boolean isTextValid(String aText, boolean canBeNull) {
    if (!canBeNull && (aText == null || aText.trim().length() == 0)) {
      return (false);
    }

    if (canBeNull && (aText == null || aText.trim().length() == 0)) {
      return (true);
    }

    String checkText = aText.toUpperCase();
    try {
      Pattern pattern =
          Pattern.compile(
              patternStr, Pattern.DOTALL + Pattern.CASE_INSENSITIVE + Pattern.UNIX_LINES);
      Matcher matcher = pattern.matcher(checkText);
      if (matcher.matches()) {
        return (false);
      }
      Pattern patternHex =
          Pattern.compile(
              hexPatternStr, Pattern.DOTALL + Pattern.CASE_INSENSITIVE + Pattern.UNIX_LINES);
      Matcher matcherHex = patternHex.matcher(checkText);
      if (matcherHex.matches()) {
        return (false);
      }
    } catch (Exception e) {
      Debug.info("Threw exception " + e.getMessage());
      return (false);
    }

    return (true);
  }
Пример #2
0
  /** Initializes the application */
  public void init() throws ServletException {

    Debug.info(
        "******* UniTime "
            + Constants.getVersion()
            + " build on "
            + Constants.getReleaseDate()
            + " is starting up *******");

    super.init();

    try {

      Debug.info(" - Initializing Logging ... ");
      Debug.init(ApplicationProperties.getProperties());

      Debug.info(" - Initializing Hibernate ... ");
      _RootDAO.initialize();

      Debug.info(" - Initializing Solver Register ... ");
      SolverRegisterService.startService();
      SolverRegisterService.addShutdownHook();

      if (RoomAvailability.getInstance() != null) {
        Debug.info(" - Initializing Room Availability Service ... ");
        RoomAvailability.getInstance().startService();
      }

      Debug.info(" - Cleaning Logs ...");
      LogCleaner.cleanupLogs();

      Debug.info(" - Starting Online Sectioning Service ...");
      OnlineSectioningService.startService();

      Debug.info(
          "******* UniTime "
              + Constants.getVersion()
              + " build on "
              + Constants.getReleaseDate()
              + " initialized successfully *******");

    } catch (Exception e) {
      Debug.error("UniTime Initialization Failed : " + e.getMessage(), e);
      sInitializationException = e;
    }
  }
Пример #3
0
 public void run() {
   Debug.info("InfoCache cleanup thread started.");
   try {
     while (true) {
       sleep(sInfoCacheCleanupInterval);
       if (sInfoCache == null) return;
       synchronized (sInfoCache) {
         if (sInfoCache.isEmpty()) continue;
         for (Iterator i = sInfoCache.entrySet().iterator(); i.hasNext(); ) {
           Map.Entry entry = (Map.Entry) i.next();
           CachedTimetableInfo cInfo = (CachedTimetableInfo) entry.getValue();
           if (cInfo.getAge() > sInfoCacheTimeToLive) {
             i.remove();
           }
         }
       }
     }
   } catch (InterruptedException ex) {
     Debug.info("InfoCache cleanup thread interrupted.");
   }
   Debug.info("InfoCache cleanup thread finished.");
 }
Пример #4
0
  /**
   * Method validate
   *
   * @param mapping
   * @param request
   * @return ActionErrors
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();

    if (name == null || name.equalsIgnoreCase("")) {
      errors.add("roomGroup", new ActionMessage("errors.required", "Name"));
    }

    if (abbv == null || abbv.equalsIgnoreCase("")) {
      errors.add("roomGroup", new ActionMessage("errors.required", "Abbreviation"));
    }

    try {

      for (Iterator i = RoomGroup.getAllGlobalRoomGroups(getSessionId()).iterator();
          i.hasNext(); ) {
        RoomGroup rg = (RoomGroup) i.next();
        if (rg.getName().equalsIgnoreCase(name) && !rg.getUniqueId().toString().equals(id))
          errors.add("name", new ActionMessage("errors.exists", name));
      }

      Department dept =
          (deptCode == null ? null : Department.findByDeptCode(deptCode, getSessionId()));
      if (dept != null) {
        for (Iterator i = RoomGroup.getAllDepartmentRoomGroups(dept).iterator(); i.hasNext(); ) {
          RoomGroup rg = (RoomGroup) i.next();
          if (rg.getName().equalsIgnoreCase(name) && !rg.getUniqueId().toString().equals(id))
            errors.add("name", new ActionMessage("errors.exists", name));
        }
      }

    } catch (Exception e) {
      Debug.error(e);
      errors.add("name", new ActionMessage("errors.generic", e.getMessage()));
    }

    if (!global && (deptCode == null || deptCode.equalsIgnoreCase(""))) {
      errors.add("Department", new ActionMessage("errors.required", "Department"));
    }

    return errors;
  }
 @Override
 protected CSVField csvBuildDatePatternCell(
     ClassAssignmentProxy classAssignment, PreferenceGroup prefGroup, boolean isEditable) {
   Assignment a = null;
   if (getDisplayTimetable()
       && isShowTimetable()
       && classAssignment != null
       && prefGroup instanceof Class_) {
     try {
       a = classAssignment.getAssignment((Class_) prefGroup);
     } catch (Exception e) {
       Debug.error(e);
     }
   }
   DatePattern dp = (a != null ? a.getDatePattern() : prefGroup.effectiveDatePattern());
   CSVField cell = createCell();
   if (dp != null) {
     addText(cell, dp.getName(), true);
   }
   return cell;
 }
Пример #6
0
  /** Terminates the application */
  public void destroy() {
    try {

      Debug.info(
          "******* UniTime "
              + Constants.getVersion()
              + " build on "
              + Constants.getReleaseDate()
              + " is going down *******");

      super.destroy();

      Debug.info(" - Stopping Online Sectioning Service ...");
      OnlineSectioningService.stopService();

      Debug.info(" - Stopping Solver Register ... ");
      SolverRegisterService.stopService();
      try {
        SolverRegisterService.removeShutdownHook();
      } catch (IllegalStateException e) {
      }

      SolverInfo.stopInfoCacheCleanup();

      ApplicationProperties.stopListener();

      if (RoomAvailability.getInstance() != null) {
        Debug.info(" - Stopping Room Availability Service ... ");
        RoomAvailability.getInstance().stopService();
      }

      QueueProcessor.stopProcessor();

      Debug.info("******* UniTime " + Constants.getVersion() + " shut down successfully *******");
    } catch (Exception e) {
      Debug.error("UniTime Shutdown Failed : " + e.getMessage(), e);
      if (e instanceof RuntimeException) throw (RuntimeException) e;
      else throw new RuntimeException("UniTime Shutdown Failed : " + e.getMessage(), e);
    }
  }
Пример #7
0
  /**
   * Method execute
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws HibernateException
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    BackTracker.markForBack(request, null, null, false, true);

    sessionContext.checkPermission(Right.Classes);

    sessionContext.setAttribute("callingPage", "classShowSearch");

    Object sas = sessionContext.getAttribute(SessionAttribute.ClassesSubjectAreas);
    Object cn = sessionContext.getAttribute(SessionAttribute.ClassesCourseNumber);
    String subjectAreaIds = "";
    String courseNbr = "";

    if ((sas == null || sas.toString().trim().isEmpty())
        && (cn == null || cn.toString().trim().isEmpty())) {
      // use session variables from io search
      sas = sessionContext.getAttribute(SessionAttribute.OfferingsSubjectArea);
      cn = sessionContext.getAttribute(SessionAttribute.OfferingsCourseNumber);
    }

    request.setAttribute(
        Department.EXTERNAL_DEPT_ATTR_NAME,
        Department.findAllExternal(sessionContext.getUser().getCurrentAcademicSessionId()));

    ClassListForm classListForm = (ClassListForm) form;
    ClassSearchAction.setupGeneralFormFilters(sessionContext, classListForm);
    ClassSearchAction.setupClassListSpecificFormFilters(sessionContext, classListForm);

    if (!sessionContext.hasPermission(Right.CourseTimetabling)) classListForm.setTimetable(null);

    if (!sessionContext.hasPermission(Right.Examinations)) classListForm.setExams(null);

    classListForm.setSubjectAreas(SubjectArea.getUserSubjectAreas(sessionContext.getUser()));

    if (sas == null && classListForm.getSubjectAreas().size() == 1)
      sas =
          ((SubjectArea) classListForm.getSubjectAreas().iterator().next())
              .getUniqueId()
              .toString();

    if (Constants.ALL_OPTION_VALUE.equals(sas)) sas = null;

    // Subject Areas are saved to the session - Perform automatic search
    if (sas != null && sas.toString().trim().length() > 0) {
      subjectAreaIds = sas.toString();

      try {

        if (cn != null && cn.toString().trim().length() > 0) courseNbr = cn.toString();

        Debug.debug("Subject Areas: " + subjectAreaIds);
        Debug.debug("Course Number: " + courseNbr);

        classListForm.setSubjectAreaIds(subjectAreaIds.split(","));
        classListForm.setCourseNbr(courseNbr);
        StringBuffer ids = new StringBuffer();
        StringBuffer names = new StringBuffer();
        StringBuffer subjIds = new StringBuffer();
        classListForm.setClasses(
            ClassSearchAction.getClasses(
                classListForm, WebSolver.getClassAssignmentProxy(request.getSession())));
        Collection classes = classListForm.getClasses();
        if (classes.isEmpty()) {
          ActionMessages errors = new ActionMessages();
          errors.add(
              "searchResult",
              new ActionMessage(
                  "errors.generic", "No records matching the search criteria were found."));
          saveErrors(request, errors);
          return mapping.findForward("showClassSearch");
        } else {
          for (int i = 0; i < classListForm.getSubjectAreaIds().length; i++) {
            if (i > 0) {
              names.append(",");
              subjIds.append(",");
            }
            ids.append("&subjectAreaIds=" + classListForm.getSubjectAreaIds()[i]);
            subjIds.append(classListForm.getSubjectAreaIds()[i]);
            names.append(
                ((new SubjectAreaDAO()).get(new Long(classListForm.getSubjectAreaIds()[i])))
                    .getSubjectAreaAbbreviation());
          }
          BackTracker.markForBack(
              request,
              "classSearch.do?doit=Search&loadFilter=1&"
                  + ids
                  + "&courseNbr="
                  + classListForm.getCourseNbr(),
              "Classes ("
                  + names
                  + (classListForm.getCourseNbr() == null
                          || classListForm.getCourseNbr().length() == 0
                      ? ""
                      : " " + classListForm.getCourseNbr())
                  + ")",
              true,
              true);
          return mapping.findForward("showClassList");
        }
      } catch (NumberFormatException nfe) {
        Debug.error("Subject Area Ids session attribute is corrupted. Resetting ... ");
        sessionContext.removeAttribute(SessionAttribute.ClassesSubjectAreas);
        sessionContext.removeAttribute(SessionAttribute.ClassesCourseNumber);
      }
    }

    return mapping.findForward("showClassSearch");
  }
 public void valueUnbound(HttpSessionBindingEvent evt) {
   Debug.info("TT Session value unbound ... " + evt.getSession().getId());
 }
 public void sessionDidActivate(HttpSessionEvent evt) {
   Debug.info("TT Session did activate ... " + evt.getSession().getId());
 }
 public void sessionWillPassivate(HttpSessionEvent evt) {
   Debug.info("TT Session will passivate ... " + evt.getSession().getId());
 }
Пример #11
0
  public PdfWebTable getTable(
      boolean html, boolean color, ExamReportForm form, Collection<ExamInfo> exams) {
    if (exams == null || exams.isEmpty()) return null;
    boolean timeVertical = RequiredTimeTable.getTimeGridVertical(sessionContext.getUser());
    boolean timeText = RequiredTimeTable.getTimeGridAsText(sessionContext.getUser());

    String nl = (html ? "<br>" : "\n");
    PdfWebTable table =
        new PdfWebTable(
            9,
            "Not-assigned Examinations",
            "unassignedExams.do?ord=%%",
            new String[] {
              (form.getShowSections() ? "Classes / Courses" : "Examination"),
              "Length",
              "Seating" + nl + "Type",
              "Size",
              "Max" + nl + "Rooms",
              "Instructor",
              "Period" + nl + "Preferences",
              "Room" + nl + "Preferences",
              "Distribution" + nl + "Preferences"
            },
            new String[] {
              "left", "right", "center", "right", "right", "left", "left", "left", "left"
            },
            new boolean[] {true, true, true, false, false, true, true, true, true});
    table.setRowStyle("white-space:nowrap");
    try {
      for (ExamInfo exam : exams) {
        String perPref = "", roomPref = "", distPref = "";

        if (html) {
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(RoomPref.class);
          if (roomPref.length() > 0) roomPref += nl;
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(BuildingPref.class);
          if (roomPref.length() > 0) roomPref += nl;
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(RoomFeaturePref.class);
          if (roomPref.length() > 0) roomPref += nl;
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(RoomGroupPref.class);
          if (roomPref.endsWith(nl))
            roomPref = roomPref.substring(0, roomPref.length() - nl.length());
          if (timeText) {
            perPref += exam.getExam().getEffectivePrefHtmlForPrefType(ExamPeriodPref.class);
          } else {
            if (exam.getExam().getExamType().getType() == ExamType.sExamTypeMidterm) {
              MidtermPeriodPreferenceModel epx =
                  new MidtermPeriodPreferenceModel(
                      exam.getExam().getSession(), exam.getExam().getExamType());
              epx.load(exam.getExam());
              perPref += epx.toString(true);
            } else {
              PeriodPreferenceModel px =
                  new PeriodPreferenceModel(exam.getExam().getSession(), exam.getExamTypeId());
              px.load(exam.getExam());
              perPref =
                  "<img border='0' src='pattern?v="
                      + (timeVertical ? 1 : 0)
                      + "&x="
                      + exam.getExamId()
                      + "' title='"
                      + px.toString()
                      + "'>";
            }
          }
          distPref += exam.getExam().getEffectivePrefHtmlForPrefType(DistributionPref.class);
        } else {
          for (Iterator j = exam.getExam().effectivePreferences(RoomPref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          for (Iterator j = exam.getExam().effectivePreferences(BuildingPref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          for (Iterator j = exam.getExam().effectivePreferences(RoomFeaturePref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          for (Iterator j = exam.getExam().effectivePreferences(RoomGroupPref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          if (ExamType.sExamTypeMidterm == exam.getExamType().getType()) {
            MidtermPeriodPreferenceModel epx =
                new MidtermPeriodPreferenceModel(exam.getExam().getSession(), exam.getExamType());
            epx.load(exam.getExam());
            perPref += epx.toString(false, true);
          } else {
            if (timeText || !color) {
              for (Iterator j =
                      exam.getExam().effectivePreferences(ExamPeriodPref.class).iterator();
                  j.hasNext(); ) {
                Preference pref = (Preference) j.next();
                if (perPref.length() > 0) perPref += nl;
                perPref +=
                    (color
                            ? "@@COLOR "
                                + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                                + " "
                            : "")
                        + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                        + " "
                        + pref.preferenceText();
              }
            } else {
              PeriodPreferenceModel px =
                  new PeriodPreferenceModel(
                      exam.getExam().getSession(), exam.getExamType().getUniqueId());
              px.load(exam.getExam());
              RequiredTimeTable rtt = new RequiredTimeTable(px);
              Image image = rtt.createBufferedImage(timeVertical);
              if (image != null) {
                table.addImage(exam.getExamId().toString(), image);
                perPref += "@@IMAGE " + exam.getExamId().toString() + " ";
              } else {
                for (Iterator j =
                        exam.getExam().effectivePreferences(ExamPeriodPref.class).iterator();
                    j.hasNext(); ) {
                  Preference pref = (Preference) j.next();
                  if (perPref.length() > 0) perPref += nl;
                  perPref +=
                      (color
                              ? "@@COLOR "
                                  + PreferenceLevel.prolog2color(
                                      pref.getPrefLevel().getPrefProlog())
                                  + " "
                              : "")
                          + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                          + " "
                          + pref.preferenceText();
                }
              }
            }
          }
          for (Iterator j = exam.getExam().effectivePreferences(DistributionPref.class).iterator();
              j.hasNext(); ) {
            DistributionPref pref = (DistributionPref) j.next();
            if (distPref.length() > 0) distPref += nl;
            distPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText(true, true, " (", ", ", ")")
                        .replaceAll("&lt;", "<")
                        .replaceAll("&gt;", ">");
          }
        }

        String instructors = exam.getInstructorName(", ");

        table.addLine(
            "onClick=\"showGwtDialog('Examination Assignment', 'examInfo.do?examId="
                + exam.getExamId()
                + "','900','90%');\"",
            new String[] {
              (html ? "<a name='" + exam.getExamId() + "'>" : "")
                  + (form.getShowSections() ? exam.getSectionName(nl) : exam.getExamName())
                  + (html ? "</a>" : ""),
              String.valueOf(exam.getLength()),
              (Exam.sSeatingTypeNormal == exam.getSeatingType() ? "Normal" : "Exam"),
              String.valueOf(exam.getNrStudents()),
              String.valueOf(exam.getMaxRooms()),
              instructors,
              perPref,
              roomPref,
              distPref
            },
            new Comparable[] {
              exam,
              exam.getLength(),
              exam.getSeatingType(),
              exam.getNrStudents(),
              exam.getMaxRooms(),
              instructors,
              perPref,
              roomPref,
              distPref
            },
            exam.getExamId().toString());
      }
    } catch (Exception e) {
      Debug.error(e);
      table.addLine(new String[] {"<font color='red'>ERROR:" + e.getMessage() + "</font>"}, null);
    }
    return table;
  }
Пример #12
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    SolverParamDefForm myForm = (SolverParamDefForm) form;

    // Check Access
    sessionContext.checkPermission(Right.SolverParameters);

    // Read operation to be performed
    String op = (myForm.getOp() != null ? myForm.getOp() : request.getParameter("op"));

    if (request.getParameter("op2") != null && request.getParameter("op2").length() > 0)
      op = request.getParameter("op2");

    if (op == null) {
      myForm.reset(mapping, request);
      myForm.setVisible(Boolean.TRUE);
    }

    // Reset Form
    if ("Back".equals(op)) {
      if (myForm.getUniqueId() != null) request.setAttribute("hash", myForm.getUniqueId());
      myForm.reset(mapping, request);
      myForm.setVisible(Boolean.TRUE);
    }

    if ("Add Solver Parameter".equals(op)) {
      myForm.reset(mapping, request);
      myForm.setVisible(Boolean.TRUE);
      myForm.setOp("Save");
      myForm.setGroup(request.getParameter("group"));
    }

    // Add / Update
    if ("Update".equals(op) || "Save".equals(op)) {
      // Validate input
      ActionMessages errors = myForm.validate(mapping, request);
      if (errors.size() > 0) {
        saveErrors(request, errors);
      } else {
        Transaction tx = null;
        try {
          SolverParameterDefDAO dao = new SolverParameterDefDAO();
          org.hibernate.Session hibSession = dao.getSession();
          if (hibSession.getTransaction() == null || !hibSession.getTransaction().isActive())
            tx = hibSession.beginTransaction();

          SolverParameterDef def = null;
          if (op.equals("Save")) def = new SolverParameterDef();
          else def = dao.get(myForm.getUniqueId(), hibSession);

          def.setName(myForm.getName());
          def.setDescription(myForm.getDescription());
          def.setDefault(myForm.getDefault());
          def.setType(myForm.getType());
          def.setVisible(myForm.getVisible());
          SolverParameterGroup group = null;
          List groups =
              hibSession
                  .createCriteria(SolverParameterGroup.class)
                  .add(Restrictions.eq("name", myForm.getGroup()))
                  .list();
          if (!groups.isEmpty()) group = (SolverParameterGroup) groups.get(0);
          if (def.getGroup() != null && !def.getGroup().equals(group)) {
            List list =
                hibSession
                    .createCriteria(SolverParameterDef.class)
                    .add(Restrictions.eq("group", def.getGroup()))
                    .add(Restrictions.gt("order", def.getOrder()))
                    .list();
            for (Iterator i = list.iterator(); i.hasNext(); ) {
              SolverParameterDef d = (SolverParameterDef) i.next();
              d.setOrder(new Integer(d.getOrder().intValue() - 1));
              dao.save(d, hibSession);
            }
            myForm.setOrder(-1);
          }
          if (myForm.getOrder() < 0) {
            def.setOrder(new Integer(group == null ? 0 : group.getParameters().size()));
          }
          def.setGroup(group);
          dao.saveOrUpdate(def, hibSession);

          if (tx != null) tx.commit();

          hibSession.refresh(def);
          request.setAttribute("hash", def.getUniqueId().toString());
        } catch (Exception e) {
          if (tx != null) tx.rollback();
          Debug.error(e);
        }
        myForm.reset(mapping, request);
        myForm.setVisible(Boolean.TRUE);
      }
    }

    // Edit
    if (op.equals("Edit")) {
      String id = request.getParameter("id");
      ActionMessages errors = new ActionMessages();
      if (id == null || id.trim().length() == 0) {
        errors.add("key", new ActionMessage("errors.invalid", "Unique Id : " + id));
        saveErrors(request, errors);
      } else {
        SolverParameterDefDAO dao = new SolverParameterDefDAO();
        SolverParameterDef def = dao.get(new Long(id));
        if (def == null) {
          errors.add("name", new ActionMessage("errors.invalid", "Unique Id : " + id));
          saveErrors(request, errors);
        } else {
          myForm.setUniqueId(def.getUniqueId());
          myForm.setName(def.getName());
          myForm.setOrder(def.getOrder().intValue());
          myForm.setDescription(def.getDescription());
          myForm.setGroup(def.getGroup().getName());
          myForm.setType(def.getType());
          myForm.setDefault(def.getDefault());
          myForm.setVisible(def.isVisible());
          myForm.setOp("Update");
        }
      }
    }

    // Delete
    if ("Delete".equals(op)) {
      Transaction tx = null;

      try {
        SolverParameterDefDAO dao = new SolverParameterDefDAO();
        org.hibernate.Session hibSession = dao.getSession();
        if (hibSession.getTransaction() == null || !hibSession.getTransaction().isActive())
          tx = hibSession.beginTransaction();

        SolverParameterDef def = dao.get(myForm.getUniqueId(), hibSession);

        List list =
            hibSession
                .createCriteria(SolverParameterDef.class)
                .add(Restrictions.eq("group", def.getGroup()))
                .add(Restrictions.gt("order", def.getOrder()))
                .list();

        for (Iterator i = list.iterator(); i.hasNext(); ) {
          SolverParameterDef d = (SolverParameterDef) i.next();
          d.setOrder(new Integer(d.getOrder().intValue() - 1));
          dao.save(d, hibSession);
        }

        dao.delete(def, hibSession);

        if (tx != null) tx.commit();
      } catch (Exception e) {
        if (tx != null) tx.rollback();
        Debug.error(e);
      }
      if (myForm.getGroup() != null) request.setAttribute("hash", myForm.getGroup());
      myForm.reset(mapping, request);
      myForm.setVisible(Boolean.TRUE);
    }

    // Move Up or Down
    if ("Move Up".equals(op) || "Move Down".equals(op)) {
      Transaction tx = null;

      try {
        SolverParameterDefDAO dao = new SolverParameterDefDAO();
        org.hibernate.Session hibSession = dao.getSession();
        if (hibSession.getTransaction() == null || !hibSession.getTransaction().isActive())
          tx = hibSession.beginTransaction();

        SolverParameterDef def = dao.get(myForm.getUniqueId(), hibSession);
        if ("Move Up".equals(op)) {
          List list =
              hibSession
                  .createCriteria(SolverParameterDef.class)
                  .add(Restrictions.eq("group", def.getGroup()))
                  .add(Restrictions.eq("order", new Integer(def.getOrder().intValue() - 1)))
                  .list();
          if (!list.isEmpty()) {
            SolverParameterDef prior = (SolverParameterDef) list.get(0);
            prior.setOrder(new Integer(prior.getOrder().intValue() + 1));
            dao.save(prior, hibSession);
            def.setOrder(new Integer(def.getOrder().intValue() - 1));
            dao.save(def, hibSession);
          }
        } else {
          List list =
              hibSession
                  .createCriteria(SolverParameterDef.class)
                  .add(Restrictions.eq("group", def.getGroup()))
                  .add(Restrictions.eq("order", new Integer(def.getOrder().intValue() + 1)))
                  .list();
          if (!list.isEmpty()) {
            SolverParameterDef next = (SolverParameterDef) list.get(0);
            next.setOrder(new Integer(next.getOrder().intValue() - 1));
            dao.save(next, hibSession);
            def.setOrder(new Integer(def.getOrder().intValue() + 1));
            dao.save(def, hibSession);
          }
        }
        myForm.setOrder(def.getOrder().intValue());

        if (myForm.getUniqueId() != null) request.setAttribute("hash", myForm.getUniqueId());

        if (tx != null) tx.commit();
      } catch (Exception e) {
        if (tx != null) tx.rollback();
        Debug.error(e);
      }
    }
    if ("List".equals(myForm.getOp())) {
      // Read all existing settings and store in request
      getSolverParameterDefs(request, myForm.getUniqueId());
      return mapping.findForward("list");
    }

    return mapping.findForward("Save".equals(myForm.getOp()) ? "add" : "edit");
  }