Rev 1586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1573 | jmachado | 1 | package pt.estgp.estgweb.web.form.questionarios; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | import org.apache.struts.action.ActionErrors; |
||
5 | import org.apache.struts.action.ActionMapping; |
||
1579 | jmachado | 6 | import org.json.JSONArray; |
7 | import org.json.JSONException; |
||
1586 | jmachado | 8 | import pt.estgp.estgweb.domain.QuestionarioReportFile; |
1579 | jmachado | 9 | import pt.estgp.estgweb.domain.QuestionarioReportFileGroup; |
10 | import pt.estgp.estgweb.domain.QuestionarioReportFileGroupImpl; |
||
1586 | jmachado | 11 | import pt.estgp.estgweb.domain.QuestionarioReportFileImpl; |
1579 | jmachado | 12 | import pt.estgp.estgweb.domain.utils.InputDrivenInput; |
1573 | jmachado | 13 | import pt.estgp.estgweb.web.form.ApplicationForm; |
14 | |||
15 | import javax.servlet.http.HttpServletRequest; |
||
1579 | jmachado | 16 | import java.util.List; |
1573 | jmachado | 17 | |
18 | |||
19 | /** |
||
20 | * @author Jorge Machado |
||
21 | * @date 25/Jun/2008 |
||
22 | * @see pt.estgp.estgweb.web.form.courses |
||
23 | */ |
||
1579 | jmachado | 24 | public class QuestionarioReportGroupForm extends ApplicationForm |
1573 | jmachado | 25 | { |
26 | |||
1579 | jmachado | 27 | 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(QuestionarioReportGroupForm.class); |
1573 | jmachado | 28 | |
1579 | jmachado | 29 | //For new instance creation |
1573 | jmachado | 30 | private 1.5.0/docs/api/java/lang/String.html">String title; |
31 | private 1.5.0/docs/api/java/lang/String.html">String reportFileGroupClass; |
||
32 | private 1.5.0/docs/api/java/lang/String.html">String dispatch; |
||
1579 | jmachado | 33 | private 1.5.0/docs/api/java/lang/String.html">String parametersArrayObtainedFromWidget; |
1830 | jmachado | 34 | private 1.5.0/docs/api/java/lang/String.html">String processSigesCode; |
1573 | jmachado | 35 | |
36 | |||
1579 | jmachado | 37 | //For administration |
38 | QuestionarioReportFileGroup questionarioReportFileGroup = new QuestionarioReportFileGroupImpl() { |
||
39 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
40 | public List<InputDrivenInput> getInputs() { |
||
41 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Only for input form use, thisreportGroup is only for data exchange purposes"); |
||
42 | } |
||
43 | |||
44 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
45 | public 1.5.0/docs/api/java/lang/String.html">String getInputsJson() throws JSONException { |
||
46 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Only for input form use, thisreportGroup is only for data exchange purposes"); |
||
47 | } |
||
48 | |||
49 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
50 | public JSONArray getInputsJsonArray() throws JSONException { |
||
51 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Only for input form use, thisreportGroup is only for data exchange purposes"); |
||
52 | } |
||
53 | }; |
||
54 | |||
1586 | jmachado | 55 | QuestionarioReportFile questionarioReportFile = new QuestionarioReportFileImpl(); |
1579 | jmachado | 56 | |
1586 | jmachado | 57 | |
1579 | jmachado | 58 | public QuestionarioReportGroupForm() |
1573 | jmachado | 59 | { |
60 | |||
61 | } |
||
62 | |||
1586 | jmachado | 63 | public QuestionarioReportFile getQuestionarioReportFile() { |
64 | return questionarioReportFile; |
||
65 | } |
||
66 | |||
67 | public void setQuestionarioReportFile(QuestionarioReportFile questionarioReportFile) { |
||
68 | this.questionarioReportFile = questionarioReportFile; |
||
69 | } |
||
70 | |||
1579 | jmachado | 71 | public 1.5.0/docs/api/java/lang/String.html">String getParametersArrayObtainedFromWidget() { |
72 | return parametersArrayObtainedFromWidget; |
||
73 | } |
||
74 | |||
75 | public void setParametersArrayObtainedFromWidget(1.5.0/docs/api/java/lang/String.html">String parametersArrayObtainedFromWidget) { |
||
76 | this.parametersArrayObtainedFromWidget = parametersArrayObtainedFromWidget; |
||
77 | } |
||
78 | |||
79 | public QuestionarioReportFileGroup getQuestionarioReportFileGroup() { |
||
80 | return questionarioReportFileGroup; |
||
81 | } |
||
82 | |||
83 | public void setQuestionarioReportFileGroup(QuestionarioReportFileGroup questionarioReportFileGroup) { |
||
84 | this.questionarioReportFileGroup = questionarioReportFileGroup; |
||
85 | } |
||
86 | |||
1573 | jmachado | 87 | public 1.5.0/docs/api/java/lang/String.html">String getTitle() { |
88 | return title; |
||
89 | } |
||
90 | |||
91 | public void setTitle(1.5.0/docs/api/java/lang/String.html">String title) { |
||
92 | this.title = title; |
||
93 | } |
||
94 | |||
95 | public 1.5.0/docs/api/java/lang/String.html">String getReportFileGroupClass() { |
||
96 | return reportFileGroupClass; |
||
97 | } |
||
98 | |||
99 | public void setReportFileGroupClass(1.5.0/docs/api/java/lang/String.html">String reportFileGroupClass) { |
||
100 | this.reportFileGroupClass = reportFileGroupClass; |
||
101 | } |
||
102 | |||
103 | public 1.5.0/docs/api/java/lang/String.html">String getOp() { |
||
104 | return dispatch; |
||
105 | } |
||
106 | |||
107 | public void setOp(1.5.0/docs/api/java/lang/String.html">String dispatch) { |
||
108 | this.dispatch = dispatch; |
||
109 | } |
||
110 | |||
1830 | jmachado | 111 | public 1.5.0/docs/api/java/lang/String.html">String getProcessSigesCode() { |
112 | return processSigesCode; |
||
113 | } |
||
114 | |||
115 | public void setProcessSigesCode(1.5.0/docs/api/java/lang/String.html">String processSigesCode) { |
||
116 | this.processSigesCode = processSigesCode; |
||
117 | } |
||
118 | |||
1573 | jmachado | 119 | @1.5.0/docs/api/java/lang/Override.html">Override |
120 | public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { |
||
121 | ActionErrors errors = new ActionErrors(); |
||
1579 | jmachado | 122 | return errors; |
123 | } |
||
1573 | jmachado | 124 | |
1579 | jmachado | 125 | public ActionErrors validateForGenerate(ActionMapping mapping, HttpServletRequest request) { |
126 | ActionErrors errors = new ActionErrors(); |
||
127 | if(getQuestionarioReportFileGroup().getTitle() == null || getQuestionarioReportFileGroup().getTitle().trim().length() == 0) |
||
1573 | jmachado | 128 | { |
1579 | jmachado | 129 | addMessageAsString(errors,"É necessário definir um titulo para o processador de relatórios"); |
1573 | jmachado | 130 | } |
1579 | jmachado | 131 | if(getQuestionarioReportFileGroup().getReportProcessorClass() == null || getQuestionarioReportFileGroup().getReportProcessorClass().trim().length() == 0) |
1573 | jmachado | 132 | { |
1579 | jmachado | 133 | addMessageAsString(errors,"É necessário definir um processador de relatórios"); |
1573 | jmachado | 134 | } |
135 | try { |
||
1579 | jmachado | 136 | if(parametersArrayObtainedFromWidget == null || new JSONArray(parametersArrayObtainedFromWidget).length() == 0) |
137 | addMessageAsString(errors,"É necessário definir os parâmetros antes de mandar processar os relatórios"); |
||
1573 | jmachado | 138 | |
1579 | jmachado | 139 | } catch (JSONException e) { |
140 | logger.error(e,e); |
||
141 | addMessageAsString(errors,"É necessário definir os parâmetros antes de mandar processar os relatórios"); |
||
1573 | jmachado | 142 | } |
143 | return errors; |
||
144 | } |
||
145 | |||
146 | |||
147 | } |