Rev 1586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1547 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
1579 | jmachado | 3 | import jomm.utils.StringsUtils; |
4 | import org.json.JSONArray; |
||
5 | import org.json.JSONException; |
||
6 | import org.json.JSONObject; |
||
1573 | jmachado | 7 | import pt.estgp.estgweb.domain.utils.InputDrivenInput; |
1579 | jmachado | 8 | import pt.estgp.estgweb.utils.ConfigProperties; |
1586 | jmachado | 9 | import pt.estgp.estgweb.utils.DatesUtils; |
1573 | jmachado | 10 | |
11 | import java.util.ArrayList; |
||
12 | import java.util.List; |
||
13 | |||
1547 | jmachado | 14 | /** |
15 | * Created by jorgemachado on 05/11/16. |
||
16 | */ |
||
1573 | jmachado | 17 | public class QuestionarioReportFileGroupAnoImpl extends QuestionarioReportFileGroupAno |
18 | { |
||
19 | public static final 1.5.0/docs/api/java/lang/String.html">String INPUT_DRIVEN_ANO_NAME = "Ano"; |
||
20 | public static final 1.5.0/docs/api/java/lang/String.html">String INPUT_DRIVEN_PERIODOS_NAME = "Periodos"; |
||
21 | public static final 1.5.0/docs/api/java/lang/String.html">String INPUT_DRIVEN_DEGREES_NAME = "Tipos"; |
||
1579 | jmachado | 22 | |
23 | public void setPeriodosList(List<String> periodos) |
||
24 | { |
||
25 | setPeriodos(StringsUtils.getSerialElements(periodos, ";")); |
||
26 | } |
||
27 | public void setDegreesList(List<String> degrees) |
||
28 | { |
||
29 | setDegrees(StringsUtils.getSerialElements(degrees, ";")); |
||
30 | } |
||
31 | |||
32 | public 1.5.0/docs/api/java/lang/String.html">String[] getPeriodosArray() |
||
33 | { |
||
34 | return StringsUtils.getElementsFromSerial(getPeriodos(), ";").toArray(new 1.5.0/docs/api/java/lang/String.html">String[0]); |
||
35 | } |
||
36 | public 1.5.0/docs/api/java/lang/String.html">String[] getDegreesArray() |
||
37 | { |
||
38 | return StringsUtils.getElementsFromSerial(getDegrees(), ";").toArray(new 1.5.0/docs/api/java/lang/String.html">String[0]); |
||
39 | } |
||
40 | |||
1586 | jmachado | 41 | public boolean isSemestre1() |
1579 | jmachado | 42 | { |
43 | return hasPeriodo("S1"); |
||
44 | } |
||
1586 | jmachado | 45 | public boolean isSemestre2() |
1579 | jmachado | 46 | { |
47 | return hasPeriodo("S2"); |
||
48 | } |
||
1586 | jmachado | 49 | public boolean isTrimestre1() |
1579 | jmachado | 50 | { |
51 | return hasPeriodo("T1"); |
||
52 | } |
||
1586 | jmachado | 53 | public boolean isTrimestre2() |
1579 | jmachado | 54 | { |
55 | return hasPeriodo("T2"); |
||
56 | } |
||
1586 | jmachado | 57 | public boolean isTrimestre3() |
1579 | jmachado | 58 | { |
59 | return hasPeriodo("T3"); |
||
60 | } |
||
1586 | jmachado | 61 | public boolean isTrimestre4() |
1579 | jmachado | 62 | { |
63 | return hasPeriodo("T4"); |
||
64 | } |
||
1586 | jmachado | 65 | public boolean isAnuais() |
1579 | jmachado | 66 | { |
67 | return hasPeriodo("A"); |
||
68 | } |
||
69 | |||
1586 | jmachado | 70 | public boolean isLicenciaturas() |
1579 | jmachado | 71 | { |
72 | return hasDegree("L"); |
||
73 | } |
||
1586 | jmachado | 74 | public boolean isMestrados() |
1579 | jmachado | 75 | { |
76 | return hasDegree("M"); |
||
77 | } |
||
1586 | jmachado | 78 | public boolean isTesps() |
1579 | jmachado | 79 | { |
80 | return hasDegree("T"); |
||
81 | } |
||
1586 | jmachado | 82 | public boolean isCets() |
1579 | jmachado | 83 | { |
84 | return hasDegree("E"); |
||
85 | } |
||
86 | |||
87 | private boolean hasPeriodo(1.5.0/docs/api/java/lang/String.html">String periodo) |
||
88 | { |
||
89 | if(getPeriodos() == null || getPeriodos().length() == 0) |
||
90 | return false; |
||
91 | else |
||
92 | return getPeriodos().contains(periodo); |
||
93 | } |
||
94 | |||
95 | private boolean hasDegree(1.5.0/docs/api/java/lang/String.html">String degree) |
||
96 | { |
||
97 | if(getDegrees() == null || getDegrees().length() == 0) |
||
98 | return false; |
||
99 | else |
||
100 | return getDegrees().contains(degree); |
||
101 | } |
||
102 | |||
103 | public 1.5.0/docs/api/java/lang/String.html">String getPeriodosDesc() |
||
104 | { |
||
105 | 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder str = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder(); |
||
106 | if(getPeriodos() != null) |
||
107 | { |
||
108 | 1.5.0/docs/api/java/lang/String.html">String union = ""; |
||
109 | for(1.5.0/docs/api/java/lang/String.html">String periodo: getPeriodosArray()) |
||
110 | { |
||
111 | str.append(union).append(ConfigProperties.getProperty("intranet.semestre." + periodo)); |
||
112 | union = " ,"; |
||
113 | } |
||
114 | } |
||
115 | return str.toString(); |
||
116 | } |
||
117 | public 1.5.0/docs/api/java/lang/String.html">String getDegreesDesc() |
||
118 | { |
||
119 | 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder str = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder(); |
||
120 | if(getDegrees() != null) |
||
121 | { |
||
122 | 1.5.0/docs/api/java/lang/String.html">String union = ""; |
||
123 | for(1.5.0/docs/api/java/lang/String.html">String degree: getDegreesArray()) |
||
124 | { |
||
125 | str.append(union).append(ConfigProperties.getProperty("course." + degree)); |
||
126 | union = " ,"; |
||
127 | } |
||
128 | } |
||
129 | return str.toString(); |
||
130 | } |
||
131 | |||
1573 | jmachado | 132 | @1.5.0/docs/api/java/lang/Override.html">Override |
133 | public List<InputDrivenInput> getInputs() |
||
134 | { |
||
135 | List<InputDrivenInput> inputs = new ArrayList<InputDrivenInput>(); |
||
136 | inputs.add(new InputDrivenInput(INPUT_DRIVEN_ANO_NAME,getImportYear())); |
||
1579 | jmachado | 137 | inputs.add(new InputDrivenInput(INPUT_DRIVEN_PERIODOS_NAME,getPeriodosDesc())); |
138 | inputs.add(new InputDrivenInput(INPUT_DRIVEN_DEGREES_NAME,getDegreesDesc())); |
||
1573 | jmachado | 139 | return inputs; |
140 | } |
||
1579 | jmachado | 141 | |
142 | public JSONArray getInputsJsonArray() throws JSONException |
||
143 | { |
||
144 | JSONArray inputs = new JSONArray(); |
||
145 | |||
146 | if(getImportYear()!= null && getImportYear().trim().length()>0) |
||
147 | { |
||
148 | JSONObject yearJson = new JSONObject(); |
||
149 | yearJson.put("name" ,INPUT_DRIVEN_ANO_NAME); |
||
150 | yearJson.put("value",getImportYear()); |
||
151 | inputs.put(yearJson); |
||
152 | } |
||
153 | |||
154 | if(getPeriodos()!= null && getPeriodos().trim().length()>0) |
||
155 | { |
||
156 | JSONObject periodosJson = new JSONObject(); |
||
157 | periodosJson.put("name" ,INPUT_DRIVEN_PERIODOS_NAME); |
||
158 | periodosJson.put("value",getPeriodosDesc()); |
||
159 | inputs.put(periodosJson); |
||
160 | } |
||
161 | |||
162 | if(getDegrees()!= null && getDegrees().trim().length()>0) |
||
163 | { |
||
164 | JSONObject degreesJson = new JSONObject(); |
||
165 | degreesJson.put("name" ,INPUT_DRIVEN_DEGREES_NAME); |
||
166 | degreesJson.put("value",getDegreesDesc()); |
||
167 | inputs.put(degreesJson); |
||
168 | } |
||
169 | |||
170 | return inputs; |
||
171 | } |
||
172 | |||
173 | public 1.5.0/docs/api/java/lang/String.html">String getInputsJson() throws JSONException |
||
174 | { |
||
175 | return getInputsJsonArray().toString(); |
||
176 | } |
||
1586 | jmachado | 177 | |
178 | public 1.5.0/docs/api/java/lang/String.html">String getImportYearFormatted(){ |
||
179 | return DatesUtils.getImportYearFormatted(getImportYear()); |
||
180 | } |
||
1547 | jmachado | 181 | } |