@Override
  public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    // YW <<
    StudyDAO stdao = new StudyDAO(sm.getDataSource());
    int parentStudyId = currentStudy.getParentStudyId();
    ArrayList groups = new ArrayList();
    if (parentStudyId > 0) {
      StudyBean parentStudy = (StudyBean) stdao.findByPK(parentStudyId);
      groups = sgcdao.findAllByStudy(parentStudy);
    } else {
      groups = sgcdao.findAllByStudy(currentStudy);
    }
    // YW >>
    String isReadOnly = request.getParameter("read");

    StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
    for (int i = 0; i < groups.size(); i++) {
      StudyGroupClassBean group = (StudyGroupClassBean) groups.get(i);
      ArrayList studyGroups = sgdao.findAllByGroupClass(group);
      group.setStudyGroups(studyGroups);
    }
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList allGroupRows = StudyGroupClassRow.generateRowsFromBeans(groups);
    boolean isParentStudy = currentStudy.getParentStudyId() > 0 ? false : true;
    request.setAttribute("isParentStudy", isParentStudy);

    String[] columns = {
      resword.getString("subject_group_class"),
      resword.getString("type"),
      resword.getString("subject_assignment"),
      resword.getString("study_name"),
      resword.getString("subject_groups"),
      resword.getString("status"),
      resword.getString("actions")
    };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(4);
    table.hideColumnLink(6);
    table.setQuery("ListSubjectGroupClass", new HashMap());
    // if (isParentStudy && (!currentStudy.getStatus().isLocked())) {
    // table.addLink(resword.getString("create_a_subject_group_class"),
    // "CreateSubjectGroupClass");
    // }
    table.setRows(allGroupRows);
    table.computeDisplay();

    request.setAttribute("table", table);
    if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
      request.setAttribute("readOnly", true);
    }
    forwardPage(Page.SUBJECT_GROUP_CLASS_LIST);
  }
  public void processRequest() throws Exception {
    String action = request.getParameter("action");
    FormProcessor fp = new FormProcessor(request);
    int classId = fp.getInt("id");

    if (classId == 0) {

      addPageMessage("Please choose a subject group class to remove.");
      forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
    } else {
      StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
      StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
      SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());

      if (action.equalsIgnoreCase("confirm")) {
        StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId);
        if (sgcb.getStatus().equals(Status.DELETED)) {
          addPageMessage("This subject group class has been deleted already.");
          forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
          return;
        }
        ArrayList groups = sgdao.findAllByGroupClass(sgcb);

        for (int i = 0; i < groups.size(); i++) {
          StudyGroupBean sg = (StudyGroupBean) groups.get(i);
          ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId());
          sg.setSubjectMaps(subjectMaps);
        }

        session.setAttribute("group", sgcb);
        session.setAttribute("studyGroups", groups);
        forwardPage(Page.REMOVE_SUBJECT_GROUP_CLASS);

      } else if (action.equalsIgnoreCase("submit")) {
        StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
        group.setStatus(Status.DELETED);
        group.setUpdater(ub);
        sgcdao.update(group);

        ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassId(group.getId());
        for (int i = 0; i < subjectMaps.size(); i++) {
          SubjectGroupMapBean sgmb = (SubjectGroupMapBean) subjectMaps.get(i);
          sgmb.setStatus(Status.DELETED);
          sgmb.setUpdater(ub);
          sgmdao.update(sgmb);
        }
        addPageMessage("This subject group class was removed successfully.");
        forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
      } else {
        addPageMessage("No action specified.");
        forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
      }
    }
  }