Java tutorial
/** * Copyright 2002 Instituto Superior Tcnico * * This file is part of FenixEdu Core. * * FenixEdu Core is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FenixEdu Core is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with FenixEdu Core. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.fenixedu.presentationTier.Action.teacher.executionCourse; import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.FenixServiceException; import net.sourceforge.fenixedu.applicationTier.Servico.teacher.EditEvaluation; import net.sourceforge.fenixedu.dataTransferObject.teacher.executionCourse.ImportContentBean; import net.sourceforge.fenixedu.domain.CompetenceCourse; import net.sourceforge.fenixedu.domain.EvaluationMethod; import net.sourceforge.fenixedu.domain.ExecutionCourse; import net.sourceforge.fenixedu.presentationTier.Action.teacher.ManageExecutionCourseDA; import org.apache.commons.lang.StringUtils; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.DynaActionForm; import pt.ist.fenixWebFramework.struts.annotations.Input; import pt.ist.fenixWebFramework.struts.annotations.Mapping; import pt.utl.ist.fenix.tools.util.i18n.MultiLanguageString; @Mapping(path = "/manageEvaluationMethod", module = "teacher", functionality = ManageExecutionCourseDA.class, formBean = "evaluationMethodForm") public class EvaluationMethodDA extends ManageExecutionCourseDA { // EVALUATION METHOD @Input public ActionForward evaluationMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return forward(request, "/teacher/executionCourse/evaluationMethod.jsp"); } public ActionForward prepareEditEvaluationMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final ExecutionCourse executionCourse = (ExecutionCourse) request.getAttribute("executionCourse"); EvaluationMethod evaluationMethod = executionCourse.getEvaluationMethod(); MultiLanguageString evaluationElements = evaluationMethod == null ? null : evaluationMethod.getEvaluationElements(); if (evaluationMethod == null || evaluationElements == null || evaluationElements.isEmpty() || StringUtils.isEmpty(evaluationElements.getContent())) { MultiLanguageString evaluationMethodMls = new MultiLanguageString(); final Set<CompetenceCourse> competenceCourses = executionCourse.getCompetenceCourses(); if (!competenceCourses.isEmpty()) { final CompetenceCourse competenceCourse = competenceCourses.iterator().next(); final String pt = competenceCourse.getEvaluationMethod(); final String en = competenceCourse.getEvaluationMethodEn(); evaluationMethodMls = evaluationMethodMls.with(MultiLanguageString.pt, pt == null ? "" : pt) .with(MultiLanguageString.en, en == null ? "" : en); } EditEvaluation.runEditEvaluation(executionCourse, evaluationMethodMls); evaluationMethod = executionCourse.getEvaluationMethod(); } return forward(request, "/teacher/executionCourse/editEvaluationMethod.jsp"); } public ActionForward editEvaluationMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final DynaActionForm dynaActionForm = (DynaActionForm) form; final String evaluationMethod = request.getParameter("evaluationMethod"); final String evaluationMethodEn = dynaActionForm.getString("evaluationMethodEn"); MultiLanguageString multiLanguageString = new MultiLanguageString(); multiLanguageString = multiLanguageString.with(MultiLanguageString.pt, evaluationMethod); multiLanguageString = multiLanguageString.with(MultiLanguageString.en, evaluationMethodEn); final ExecutionCourse executionCourse = (ExecutionCourse) request.getAttribute("executionCourse"); EditEvaluation.runEditEvaluation(executionCourse, multiLanguageString); return forward(request, "/teacher/executionCourse/evaluationMethod.jsp"); } public ActionForward prepareImportEvaluationMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { request.setAttribute("importContentBean", new ImportContentBean()); return forward(request, "/teacher/executionCourse/importEvaluationMethod.jsp"); } public ActionForward prepareImportEvaluationMethodPostBack(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { prepareImportContentPostBack(request); return forward(request, "/teacher/executionCourse/importEvaluationMethod.jsp"); } public ActionForward prepareImportEvaluationMethodInvalid(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { prepareImportContentInvalid(request); return forward(request, "/teacher/executionCourse/importEvaluationMethod.jsp"); } public ActionForward listExecutionCoursesToImportEvaluationMethod(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { listExecutionCoursesToImportContent(request); return forward(request, "/teacher/executionCourse/importEvaluationMethod.jsp"); } public ActionForward importEvaluationMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixServiceException { importContent(request, "ImportEvaluationMethod"); return forward(request, "/teacher/executionCourse/evaluationMethod.jsp"); } }