@Override
  public void save(PageRequestContext requestContext) throws SetupWizardException {
    EducationTypeDAO educationTypeDAO = DAOFactory.getInstance().getEducationTypeDAO();

    int rowCount = requestContext.getInteger("educationTypesTable.rowCount");
    for (int i = 0; i < rowCount; i++) {
      String colPrefix = "educationTypesTable." + i;
      String name = requestContext.getString(colPrefix + ".name");
      String code = requestContext.getString(colPrefix + ".code");
      educationTypeDAO.create(name, code);
    }
  }
  /**
   * Processes the page request by including the corresponding JSP page to the response.
   *
   * @param pageRequestContext Page request context
   */
  public void process(PageRequestContext pageRequestContext) {
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    EducationTypeDAO educationTypeDAO = DAOFactory.getInstance().getEducationTypeDAO();

    List<Subject> subjects = subjectDAO.listUnarchived();
    Collections.sort(subjects, new StringAttributeComparator("getName"));

    List<EducationType> educationTypes = educationTypeDAO.listUnarchived();
    Collections.sort(educationTypes, new StringAttributeComparator("getName"));

    JSONArray jsonSubjects = new JSONArrayExtractor("name", "code", "id").extract(subjects);
    for (int i = 0; i < jsonSubjects.size(); i++) {
      JSONObject jsonStudyProgrammeCategory = jsonSubjects.getJSONObject(i);
      if (subjects.get(i).getEducationType() != null)
        jsonStudyProgrammeCategory.put(
            "educationTypeId", subjects.get(i).getEducationType().getId());
    }
    String jsonEducationTypes = new JSONArrayExtractor("name", "id").extractString(educationTypes);

    this.setJsDataVariable(pageRequestContext, "subjects", jsonSubjects.toString());
    this.setJsDataVariable(pageRequestContext, "educationTypes", jsonEducationTypes);
    pageRequestContext.setIncludeJSP("/templates/settings/subjects.jsp");
  }
 @Override
 public boolean isInitialized(PageRequestContext requestContext) throws SetupWizardException {
   EducationTypeDAO educationTypeDAO = DAOFactory.getInstance().getEducationTypeDAO();
   return !educationTypeDAO.listUnarchived().isEmpty();
 }