Rev 1314 | Rev 1325 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1314 | Rev 1315 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | import jomm.dao.impl.AbstractDao; |
3 | import jomm.dao.impl.AbstractDao; |
4 | import org.apache.log4j.Logger; |
4 | import org.apache.log4j.Logger; |
5 | import org.apache.struts.action.ActionForm; |
5 | import org.apache.struts.action.ActionForm; |
6 | import org.apache.struts.action.ActionForward; |
6 | import org.apache.struts.action.ActionForward; |
7 | import org.apache.struts.action.ActionMapping; |
7 | import org.apache.struts.action.ActionMapping; |
8 | import pt.estgp.estgweb.domain.ConfigurationGradesEpocaAvaliacao; |
- | |
9 | import pt.estgp.estgweb.domain.ConfigurationGradesStatusEpoca; |
8 | import pt.estgp.estgweb.domain.QuestionarioImpl; |
10 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
9 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
11 | import pt.estgp.estgweb.web.UserSessionProxy; |
- | |
12 | import pt.estgp.estgweb.web.controllers.ApplicationDispatchController; |
10 | import pt.estgp.estgweb.web.controllers.ApplicationDispatchController; |
13 | import pt.estgp.estgweb.web.form.configuration.ConfigurationGradesForm; |
11 | import pt.estgp.estgweb.web.form.questionarios.QuestionarioForm; |
14 | 12 | ||
15 | import javax.servlet.ServletException; |
13 | import javax.servlet.ServletException; |
16 | import javax.servlet.http.HttpServletRequest; |
14 | import javax.servlet.http.HttpServletRequest; |
17 | import javax.servlet.http.HttpServletResponse; |
15 | import javax.servlet.http.HttpServletResponse; |
18 | 16 | ||
Line 27... | Line 25... | ||
27 | 25 | ||
28 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(QuestionarioController.class); |
26 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(QuestionarioController.class); |
29 | 27 | ||
30 | 28 | ||
31 | 29 | ||
32 | public ActionForward saveGrades(ActionMapping mapping, |
30 | public ActionForward newEdit(ActionMapping mapping, |
33 | ActionForm form, |
31 | ActionForm form, |
34 | HttpServletRequest request, |
32 | HttpServletRequest request, |
35 | HttpServletResponse response) |
33 | HttpServletResponse response) |
36 | throws ServletException |
34 | throws ServletException |
37 | { |
35 | { |
38 | 36 | ||
39 | if(!UserSessionProxy.loadUserSessionFromRequest(request).getUser().isAdmin() && !UserSessionProxy.loadUserSessionFromRequest(request).getUser().hasRole("services")) |
- | |
40 | { |
- | |
41 | return mapping.findForward("error401"); |
- | |
42 | } |
- | |
43 | - | ||
44 | ConfigurationGradesForm f = (ConfigurationGradesForm) form; |
37 | QuestionarioForm frm = (QuestionarioForm) form; |
45 | AbstractDao.getCurrentSession().beginTransaction(); |
38 | AbstractDao.getCurrentSession().beginTransaction(); |
46 | for(ConfigurationGradesEpocaAvaliacao a: f.getConfigurationGrades().getEpocasAvaliacao()) |
39 | if(frm.getQuestionario().getId() <= 0) |
47 | { |
40 | { |
48 | if(a.getId() > 0) |
- | |
49 | { |
- | |
50 | ConfigurationGradesEpocaAvaliacao persist = DaoFactory.getConfigurationGradesEpocaAvaliacaoDaoImpl().load(a.getId()); |
- | |
51 | persist.setCodigoEpoca(a.getCodigoEpoca()); |
- | |
52 | persist.setCodigoMomento(a.getCodigoMomento()); |
- | |
53 | persist.setObs(a.getObs()); |
- | |
54 | persist.setDescricao(a.getDescricao()); |
41 | DaoFactory.getQuestionarioDaoImpl().save(frm.getQuestionario()); |
55 | } |
- | |
56 | } |
42 | } |
57 | - | ||
58 | for(ConfigurationGradesStatusEpoca a: f.getConfigurationGrades().getStatusEpocas()) |
43 | else |
59 | { |
44 | { |
60 | if(a.getId() > 0) |
- | |
61 | { |
- | |
62 | ConfigurationGradesStatusEpoca persist = DaoFactory.getConfigurationGradesStatusEpocaDaoImpl().load(a.getId()); |
- | |
63 | persist.setStatus(a.getStatus()); |
- | |
64 | persist.setObs(a.getObs()); |
- | |
65 | persist.setDescricao(a.getDescricao()); |
45 | DaoFactory.getQuestionarioDaoImpl().merge(frm.getQuestionario()); |
66 | } |
- | |
67 | } |
46 | } |
68 | AbstractDao.getCurrentSession().getTransaction().commit(); |
47 | AbstractDao.getCurrentSession().getTransaction().commit(); |
69 | 48 | ||
- | 49 | ||
70 | return mapping.findForward("grades"); |
50 | return mapping.findForward("list"); |
- | 51 | } |
|
- | 52 | ||
- | 53 | public ActionForward refresh(ActionMapping mapping, |
|
- | 54 | ActionForm form, |
|
- | 55 | HttpServletRequest request, |
|
- | 56 | HttpServletResponse response) |
|
- | 57 | throws ServletException |
|
- | 58 | { |
|
- | 59 | ||
- | 60 | QuestionarioForm frm = (QuestionarioForm) form; |
|
- | 61 | frm.setShowQuestionarioForm(true); |
|
- | 62 | return mapping.getInputForward(); |
|
- | 63 | } |
|
- | 64 | ||
- | 65 | public ActionForward form(ActionMapping mapping, |
|
- | 66 | ActionForm form, |
|
- | 67 | HttpServletRequest request, |
|
- | 68 | HttpServletResponse response) |
|
- | 69 | throws ServletException |
|
- | 70 | { |
|
- | 71 | ||
- | 72 | QuestionarioForm frm = (QuestionarioForm) form; |
|
- | 73 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 74 | ||
- | 75 | QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().get(frm.getQuestionario().getId()); |
|
- | 76 | frm.setQuestionario(q); |
|
- | 77 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 78 | ||
- | 79 | frm.setShowQuestionarioForm(true); |
|
- | 80 | return mapping.findForward("list"); |
|
71 | } |
81 | } |
72 | 82 | ||
73 | 83 | ||
74 | 84 | ||
75 | } |
85 | } |