Rev 1310 | Rev 1327 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
110 | susana | 1 | package pt.estgp.estgweb.domain.dao.impl; |
2 | |||
748 | jmachado | 3 | import org.apache.log4j.Logger; |
205 | jmachado | 4 | import org.hibernate.Criteria; |
358 | jmachado | 5 | import org.hibernate.Query; |
748 | jmachado | 6 | import org.hibernate.criterion.Criterion; |
7 | import org.hibernate.criterion.Order; |
||
1103 | jmachado | 8 | import org.hibernate.criterion.Projections; |
376 | jmachado | 9 | import org.hibernate.sql.JoinFragment; |
1094 | jmachado | 10 | import pt.estgp.estgweb.Globals; |
961 | jmachado | 11 | import pt.estgp.estgweb.domain.*; |
12 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
748 | jmachado | 13 | import pt.estgp.estgweb.domain.dao.DaoUtils; |
14 | import pt.estgp.estgweb.services.common.SearchTypeEnum; |
||
15 | import pt.estgp.estgweb.utils.DatesUtils; |
||
116 | jmachado | 16 | |
961 | jmachado | 17 | import java.util.ArrayList; |
125 | fvelez | 18 | import java.util.List; |
19 | |||
748 | jmachado | 20 | import static org.hibernate.criterion.Restrictions.*; |
21 | |||
110 | susana | 22 | /** |
23 | * @author Jorge Machado |
||
24 | * @date 28/Fev/2008 |
||
25 | * @time 2:51:06 |
||
26 | * @see pt.estgp.estgweb.domain.dao.impl |
||
27 | */ |
||
28 | public class CourseUnitDaoImpl extends CourseUnitDao |
||
29 | { |
||
30 | |||
219 | jmachado | 31 | 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(CourseUnitDaoImpl.class); |
110 | susana | 32 | |
751 | jmachado | 33 | |
202 | jmachado | 34 | private CourseUnitDaoImpl() |
35 | { |
||
110 | susana | 36 | } |
37 | |||
38 | public static CourseUnitDaoImpl getInstance() |
||
39 | { |
||
40 | if (myInstance == null) |
||
41 | myInstance = new CourseUnitDaoImpl(); |
||
42 | return (CourseUnitDaoImpl) myInstance; |
||
43 | } |
||
44 | |||
125 | fvelez | 45 | public List<CourseUnit> loadBySigesCode(1.5.0/docs/api/java/lang/String.html">String sigesCode) |
116 | jmachado | 46 | { |
202 | jmachado | 47 | return createCriteria().add(eq("code", sigesCode)).list(); |
116 | jmachado | 48 | } |
202 | jmachado | 49 | |
214 | jmachado | 50 | public List<CourseUnit> loadByCourse(long course, 1.5.0/docs/api/java/lang/String.html">String importYear) |
51 | { |
||
371 | jmachado | 52 | return createCriteria().add(eq("importYear", importYear)).add(eq("course.id", course)).list(); |
214 | jmachado | 53 | } |
54 | |||
371 | jmachado | 55 | public List<CourseUnit> load(1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String semestre) |
358 | jmachado | 56 | { |
371 | jmachado | 57 | return createCriteria().add(eq("importYear", importYear)).add(eq("semestre", semestre)).list(); |
358 | jmachado | 58 | } |
59 | |||
1312 | jmachado | 60 | public List<Long> loadByYearInstitutionCode(1.5.0/docs/api/java/lang/String.html">String importYear, int institutionCode) |
61 | { |
||
62 | return createCriteria() |
||
63 | .setProjection(Projections.property("id")) |
||
64 | .add(eq("importYear", importYear)) |
||
65 | .add(eq("institutionCode", institutionCode+"")) |
||
66 | .list(); |
||
67 | } |
||
68 | |||
771 | jmachado | 69 | public List<CourseUnit> loadYear(1.5.0/docs/api/java/lang/String.html">String importYear) |
70 | { |
||
71 | return createCriteria().add(eq("importYear", importYear)).list(); |
||
72 | } |
||
73 | |||
767 | jmachado | 74 | |
75 | |||
371 | jmachado | 76 | public List<Long> loadIds(1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String semestre) |
358 | jmachado | 77 | { |
1312 | jmachado | 78 | if(semestre == null || semestre.trim().length() == 0) |
79 | return loadIds(importYear); |
||
371 | jmachado | 80 | 1.5.0/docs/api/javax/management/Query.html">Query q = createQuery("select c.id from c in class " + CourseUnit.class.getName() + " where c.importYear = ? and c.semestre = ?"); |
81 | q.setString(0, importYear); |
||
82 | q.setString(1, semestre); |
||
358 | jmachado | 83 | return q.list(); |
84 | } |
||
85 | |||
995 | jmachado | 86 | public List<Long> loadIds(1.5.0/docs/api/java/lang/String.html">String importYear) |
87 | { |
||
88 | 1.5.0/docs/api/javax/management/Query.html">Query q = createQuery("select c.id from c in class " + CourseUnit.class.getName() + " where c.importYear = ?"); |
||
89 | q.setString(0, importYear); |
||
90 | //q.setString(1, semestre); |
||
91 | return q.list(); |
||
92 | } |
||
93 | |||
218 | jmachado | 94 | public List<CourseUnit> loadSubscribedImportYearUnits(long studentId, 1.5.0/docs/api/java/lang/String.html">String importYear) |
95 | { |
||
1072 | jmachado | 96 | return createCriteria() |
371 | jmachado | 97 | .createAlias("students", "st") |
1072 | jmachado | 98 | .add(eq("st.id", studentId)) |
99 | .add(eq("importYear", importYear)) |
||
100 | .addOrder(Order.asc("name")) |
||
101 | .list(); |
||
218 | jmachado | 102 | } |
420 | jmachado | 103 | public List<CourseUnit> loadSubscribedImportYearSemestreUnits(long studentId, 1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String semestre) |
104 | { |
||
105 | Criteria c =createCriteria() |
||
1072 | jmachado | 106 | .createAlias("students", "st") |
107 | .add(eq("st.id", studentId)) |
||
108 | .add(eq("importYear", importYear)); |
||
420 | jmachado | 109 | if(semestre != null) |
110 | c.add(eq("semestre", semestre)); |
||
111 | return c.addOrder(Order.asc("name")).list(); |
||
112 | } |
||
255 | jmachado | 113 | |
114 | public List<CourseUnit> loadSubscribedOtherImportYearUnits(long studentId, 1.5.0/docs/api/java/lang/String.html">String importYear) |
||
115 | { |
||
371 | jmachado | 116 | return createCriteria().add(not(eq("importYear", importYear))) |
117 | .createAlias("students", "st") |
||
255 | jmachado | 118 | .add(eq("st.id", studentId)).addOrder(Order.asc("name")).list(); |
119 | } |
||
343 | jmachado | 120 | |
253 | jmachado | 121 | public List<CourseUnitImpl> loadTeachedImportYearUnits(long teacherId, 1.5.0/docs/api/java/lang/String.html">String importYear) |
218 | jmachado | 122 | { |
371 | jmachado | 123 | return createCriteria().add(eq("importYear", importYear)) |
124 | .createAlias("teachers", "st") |
||
255 | jmachado | 125 | .add(eq("st.id", teacherId)).addOrder(Order.asc("importYear")).addOrder(Order.asc("name")).list(); |
218 | jmachado | 126 | } |
127 | |||
821 | jmachado | 128 | public List<CourseUnitImpl> loadResponsableImportYearUnits(long teacherId, 1.5.0/docs/api/java/lang/String.html">String importYear) |
129 | { |
||
130 | return createCriteria().add(eq("importYear", importYear)) |
||
131 | .add(eq("responsableTeacher.id", teacherId)).addOrder(Order.asc("importYear")).addOrder(Order.asc("name")).list(); |
||
132 | } |
||
133 | |||
420 | jmachado | 134 | public List<CourseUnit> loadTeachedImportYearSemestreUnits(long teacherId, 1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String semestre) |
135 | { |
||
136 | Criteria c =createCriteria() |
||
137 | .add(eq("importYear", importYear)) |
||
138 | .createAlias("teachers", "st") |
||
139 | .add(eq("st.id", teacherId)) |
||
140 | .add(eq("st.id", teacherId)); |
||
141 | if(semestre != null) |
||
142 | c.add(eq("semestre", semestre)); |
||
143 | return c.addOrder(Order.asc("name")).list(); |
||
144 | } |
||
145 | |||
146 | |||
147 | |||
163 | jmachado | 148 | public CourseUnit loadBySigesCodeUnique(1.5.0/docs/api/java/lang/String.html">String sigesCode) |
149 | { |
||
202 | jmachado | 150 | return (CourseUnit) createCriteria().add(eq("code", sigesCode)).uniqueResult(); |
163 | jmachado | 151 | } |
116 | jmachado | 152 | |
202 | jmachado | 153 | public CourseUnit loadBySigesCodeUnique(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode) |
154 | { |
||
155 | return (CourseUnit) createCriteria().add(eq("code", sigesCode)).add(eq("courseCode", courseCode)).uniqueResult(); |
||
156 | } |
||
163 | jmachado | 157 | |
228 | jmachado | 158 | public CourseUnit loadBySigesCodeUniqueSubscribed(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String year, 1.5.0/docs/api/java/lang/String.html">String courseCode, long studentId, 1.5.0/docs/api/java/lang/String.html">String semestre) |
219 | jmachado | 159 | { |
371 | jmachado | 160 | List<CourseUnit> cus = createCriteria() |
219 | jmachado | 161 | .add(eq("code", sigesCode)) |
228 | jmachado | 162 | .add(eq("importYear", year)) |
219 | jmachado | 163 | .add(eq("courseCode", courseCode)) |
228 | jmachado | 164 | .add(eq("semestre", semestre)) |
371 | jmachado | 165 | .createAlias("students", "st") |
166 | .add(eq("st.id", studentId)) |
||
219 | jmachado | 167 | .list(); |
371 | jmachado | 168 | if (cus.size() > 1) |
219 | jmachado | 169 | { |
170 | CourseUnit cu1 = cus.get(0); |
||
171 | CourseUnit cu2 = cus.get(1); |
||
371 | jmachado | 172 | if (cus.size() > 2) |
219 | jmachado | 173 | { |
174 | logger.error("CourseUnit in more than two places in a course:" + cu1.getCode()); |
||
175 | } |
||
176 | else |
||
177 | { |
||
371 | jmachado | 178 | if (cu1.getSemestre().equals("S1")) |
219 | jmachado | 179 | { |
371 | jmachado | 180 | if (cu2.getSemestre().equals("S1")) |
219 | jmachado | 181 | logger.error("CourseUnit in more than two places in a semestre:" + cu1.getCode()); |
182 | else |
||
183 | { |
||
184 | return cu2; |
||
185 | } |
||
186 | } |
||
187 | else |
||
188 | { |
||
371 | jmachado | 189 | if (cu2.getSemestre().equals("S2")) |
219 | jmachado | 190 | logger.error("CourseUnit in more than two places in a semestre:" + cu1.getCode()); |
191 | else |
||
192 | { |
||
193 | return cu1; |
||
194 | } |
||
195 | } |
||
196 | } |
||
197 | } |
||
371 | jmachado | 198 | else if (cus.size() == 1) |
219 | jmachado | 199 | return cus.get(0); |
200 | |||
201 | return null; |
||
202 | } |
||
203 | |||
751 | jmachado | 204 | |
205 | public void consistCourseUnitCourseCodes(1.5.0/docs/api/java/lang/String.html">String importYear) |
||
206 | { |
||
207 | List<CourseUnit> courseUnit = createCriteria() |
||
208 | .add(eq("importYear", importYear)).list(); |
||
209 | for(CourseUnit cu: courseUnit) |
||
210 | { |
||
211 | if(cu.getCourse() != null) |
||
212 | { |
||
213 | if(cu.getCourseCode() == null || (cu.getCourseCode() != null && !cu.getCourseCode().equals(cu.getCourse().getCode()))) |
||
214 | { |
||
215 | 1.5.0/docs/api/java/lang/System.html">System.out.println("Course code wrong: " + cu.getId() + " - " + cu.getName() + " old CourseCode " + cu.getCourseCode() + " now:" + cu.getCourse().getCode() ); |
||
216 | } |
||
217 | |||
218 | if(cu.getCourseName() == null || (cu.getCourseName() != null && !cu.getCourseName().equals(cu.getCourse().getName()))) |
||
219 | { |
||
220 | 1.5.0/docs/api/java/lang/System.html">System.out.println("Course name wrong: " + cu.getId() + " - " + cu.getName() + " old CourseCode " + cu.getCourseName() + " now:" + cu.getCourse().getName() ); |
||
221 | } |
||
222 | cu.setCourseCode(cu.getCourse().getCode()); |
||
223 | cu.setCourseName(cu.getCourse().getName()); |
||
224 | } |
||
225 | else |
||
226 | { |
||
227 | cu.setCourseCode(""); |
||
228 | cu.setCourseName(""); |
||
229 | } |
||
230 | } |
||
231 | } |
||
232 | |||
233 | |||
1117 | jmachado | 234 | //TODO Na actualizacao de uma cadeira para o curso de TESTE mudar o coursecode para o o coursecode desse curso para nao deixar os dados duplicados e mal |
748 | jmachado | 235 | //se nao a carregar unidades vai buscar a errada |
1138 | jmachado | 236 | |
237 | /** |
||
238 | * Turma required to be unique in BACO Model |
||
239 | * @param sigesCode |
||
240 | * @param courseCode |
||
241 | * @param semestre |
||
242 | * @param year |
||
243 | * @return |
||
244 | */ |
||
245 | public List<CourseUnit> loadBySigesCode(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year) |
||
202 | jmachado | 246 | { |
1138 | jmachado | 247 | return |
225 | jmachado | 248 | createCriteria() |
249 | .add(eq("code", sigesCode)) |
||
250 | .add(eq("courseCode", courseCode)) |
||
251 | .add(eq("semestre", semestre)) |
||
252 | .add(eq("importYear", year)) |
||
1138 | jmachado | 253 | .list(); |
202 | jmachado | 254 | } |
767 | jmachado | 255 | |
1117 | jmachado | 256 | /** |
257 | * Metodo especial para a fase de transicao para terem código de turma |
||
258 | * @param sigesCode |
||
259 | * @param courseCode |
||
260 | * @param semestre |
||
261 | * @param year |
||
262 | * @return |
||
263 | */ |
||
264 | public List<CourseUnit> loadBySigesCodeTurmaNull(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year) |
||
265 | { |
||
1232 | jmachado | 266 | //todo cdTurma Rollback |
1117 | jmachado | 267 | return (List<CourseUnit>) |
268 | createCriteria() |
||
269 | .add(eq("code", sigesCode)) |
||
270 | .add(eq("courseCode", courseCode)) |
||
271 | .add(eq("semestre", semestre)) |
||
272 | .add(eq("importYear", year)) |
||
273 | .add(isNull("cdTurma")) |
||
274 | .list(); |
||
275 | } |
||
276 | |||
277 | //TODO Na actualizacao de uma cadeira para o curso de TESTE mudar o coursecode para o o coursecode desse curso para nao deixar os dados duplicados e mal |
||
278 | //se nao a carregar unidades vai buscar a errada |
||
1245 | jmachado | 279 | public List<CourseUnit> loadBySigesCodeUnique(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year) |
1117 | jmachado | 280 | { |
1245 | jmachado | 281 | List<CourseUnit> cus = |
1117 | jmachado | 282 | createCriteria() |
283 | .add(eq("code", sigesCode)) |
||
284 | .add(eq("courseCode", courseCode)) |
||
285 | .add(eq("semestre", semestre)) |
||
286 | .add(eq("importYear", year)) |
||
1245 | jmachado | 287 | //not any more .add(eq("cdTurma", turma)) |
288 | .list(); |
||
289 | if(cus.size() > 1) |
||
290 | { |
||
291 | logger.warn("WARNING WARNING ####Two units found for: "); |
||
292 | logger.warn("WARNING WARNING ####String sigesCode, String courseCode, String semestre, String year = " + sigesCode + ", " + courseCode + "," + semestre + "," + year); |
||
293 | logger.warn("WARNING WARNING ####returning first one, this could be a case of units spared because of TURMAS split used in 201516: "); |
||
294 | } |
||
295 | |||
296 | return cus; |
||
1117 | jmachado | 297 | } |
298 | |||
1312 | jmachado | 299 | public List<CourseUnit> loadBySigesCodeUniqueWithTurma(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year,1.5.0/docs/api/java/lang/String.html">String turma) |
300 | { |
||
301 | List<CourseUnit> cus = |
||
302 | createCriteria() |
||
303 | .add(eq("code", sigesCode)) |
||
304 | .add(eq("courseCode", courseCode)) |
||
305 | .add(eq("semestre", semestre)) |
||
306 | .add(eq("importYear", year)) |
||
307 | .add(eq("cdTurma", turma)) |
||
308 | .list(); |
||
309 | if(cus.size() > 1) |
||
310 | { |
||
311 | logger.warn("WARNING WARNING ####Two units found for: "); |
||
312 | logger.warn("WARNING WARNING ####String sigesCode, String courseCode, String semestre, String year = " + sigesCode + ", " + courseCode + "," + semestre + "," + year); |
||
313 | logger.warn("WARNING WARNING ####returning first one, this could be a case of units spared because of TURMAS split used in 201516: "); |
||
314 | } |
||
315 | |||
316 | return cus; |
||
317 | } |
||
318 | |||
1245 | jmachado | 319 | public List<CourseUnit> loadBySigesCodeUniqueAllCourses(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year) |
1232 | jmachado | 320 | { |
321 | //todo cdTurma Rollback |
||
1233 | jmachado | 322 | return |
1232 | jmachado | 323 | createCriteria() |
324 | .add(eq("code", sigesCode)) |
||
325 | // REMOVED TO LET BE ALL COURSES .add(eq("courseCode", courseCode)) |
||
326 | .add(eq("semestre", semestre)) |
||
327 | .add(eq("importYear", year)) |
||
1245 | jmachado | 328 | //not anymore .add(eq("cdTurma", turma)) |
1233 | jmachado | 329 | .list(); |
1232 | jmachado | 330 | } |
331 | |||
899 | jmachado | 332 | public CourseUnit loadBySigesCodeUniqueMostRecent(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String semestre) |
333 | { |
||
1098 | jmachado | 334 | List<CourseUnit> cus = |
899 | jmachado | 335 | createCriteria() |
336 | .add(eq("code", sigesCode)) |
||
337 | .add(eq("courseCode", courseCode)) |
||
338 | .add(eq("semestre", semestre)) |
||
339 | .addOrder(Order.desc("importYear")) |
||
1098 | jmachado | 340 | .setMaxResults(1).list(); |
341 | if(cus.size() > 0) |
||
342 | return cus.get(0); |
||
343 | logger.warn("Accessing unit not existent with siges code " + sigesCode + " course code: " + courseCode + " semestre: " + semestre); |
||
344 | return null; |
||
899 | jmachado | 345 | } |
346 | |||
347 | |||
883 | jmachado | 348 | public CourseUnit loadBySigesCodeUniqueLastYear(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String semestre) |
767 | jmachado | 349 | { |
899 | jmachado | 350 | return loadBySigesCodeUniqueMostRecent(sigesCode,courseCode,semestre); |
883 | jmachado | 351 | } |
352 | |||
353 | |||
354 | public List<CourseUnit> loadBySigesCodeUnique(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year) |
||
355 | { |
||
767 | jmachado | 356 | return createCriteria() |
357 | .add(eq("code", sigesCode)) |
||
358 | .add(eq("courseCode", courseCode)) |
||
359 | .add(eq("importYear", year)) |
||
360 | .addOrder(Order.desc("id")) |
||
361 | .list(); |
||
362 | } |
||
363 | |||
457 | jmachado | 364 | public List<CourseUnit> loadBySigesCodes(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode) |
365 | { |
||
366 | return (List<CourseUnit>) createCriteria() |
||
367 | .add(eq("code", sigesCode)) |
||
368 | .add(eq("courseCode", courseCode)) |
||
369 | .addOrder(Order.desc("importYear")) |
||
370 | .list(); |
||
371 | } |
||
163 | jmachado | 372 | |
1077 | jmachado | 373 | /** |
374 | * Metodo usado para carregar unidades de anos anteriores que possam estar em edição |
||
375 | * para mostrar na página da unidade |
||
376 | * |
||
377 | * Este metodo nao serve para mais nada, nao é usado nas Tarefas da Home |
||
378 | * @param sigesCode |
||
379 | * @param courseCode |
||
380 | * @return |
||
381 | */ |
||
382 | public CourseUnit loadUnitInEvaluationBySigesCodes(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String courseCode) |
||
1074 | jmachado | 383 | { |
1077 | jmachado | 384 | 1.5.0/docs/api/java/lang/String.html">String activeImportYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear(); |
1074 | jmachado | 385 | |
1077 | jmachado | 386 | Criterion crtDegrees = getCourseUnitActiveDegreeCourseIdsCriterion(activeImportYear); |
387 | if(crtDegrees == null) |
||
388 | { |
||
389 | //Nao ha graus nem cursos portanto o ano não interessa |
||
390 | //o ano deve ser usado para abrir graus ou cursos senao nao |
||
391 | //abre nada |
||
392 | crtDegrees = eq("evaluationOpenByAdmin",true); |
||
393 | } |
||
394 | else |
||
395 | { |
||
396 | crtDegrees = and(eq("importYear", activeImportYear),crtDegrees); |
||
397 | crtDegrees = or(eq("evaluationOpenByAdmin",true),crtDegrees); |
||
398 | } |
||
399 | |||
1074 | jmachado | 400 | List<CourseUnit> cus = (List<CourseUnit>) createCriteria() |
401 | .createAlias("course","c") |
||
402 | .createAlias("courseUnitEvaluation","ce") |
||
403 | .add(eq("code", sigesCode)) |
||
404 | .add(eq("courseCode", courseCode)) |
||
405 | .add(crtDegrees) |
||
406 | .add(eq("ce.closed",false)) |
||
407 | .list(); |
||
1077 | jmachado | 408 | List<CourseUnit> cusNull = (List<CourseUnit>) createCriteria() |
409 | .createAlias("course","c") |
||
410 | .add(eq("code", sigesCode)) |
||
411 | .add(eq("courseCode", courseCode)) |
||
412 | .add(crtDegrees) |
||
413 | .add(isNull("courseUnitEvaluation")) |
||
414 | .list(); |
||
415 | cus.addAll(cusNull); |
||
1074 | jmachado | 416 | if(cus != null && cus.size() > 1) |
417 | { |
||
418 | logger.warn("Mais do que uma unidade do mesmo codigo em avaliacao curricular, e suposto haver apenas uma, verificar logica aplicacional"); |
||
419 | } |
||
420 | else if(cus != null && cus.size() > 0) |
||
421 | { |
||
422 | return cus.get(0); |
||
423 | } |
||
424 | |||
425 | return null; |
||
426 | } |
||
427 | |||
376 | jmachado | 428 | public List<CourseUnit> loadCourseUnits(long courseId, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year, boolean withTeacher, boolean withNoTeacher) |
429 | { |
||
1312 | jmachado | 430 | return loadCourseUnits( courseId, semestre, year, withTeacher, withNoTeacher,null); |
431 | } |
||
432 | public List<CourseUnit> loadCourseUnits(long courseId, 1.5.0/docs/api/java/lang/String.html">String semestre, 1.5.0/docs/api/java/lang/String.html">String year, boolean withTeacher, boolean withNoTeacher,1.5.0/docs/api/java/lang/String.html">String institutionCode) |
||
433 | { |
||
376 | jmachado | 434 | Criteria c = createCriteria(); |
435 | if(courseId > 0) |
||
436 | c.add(eq("course.id", courseId)); |
||
1312 | jmachado | 437 | if(semestre != null && semestre.trim().length() > 0) |
376 | jmachado | 438 | c.add(eq("semestre", semestre)); |
1312 | jmachado | 439 | if(year != null && year.trim().length() > 0) |
376 | jmachado | 440 | c.add(eq("importYear", year)); |
1312 | jmachado | 441 | if(institutionCode != null && institutionCode.trim().length() > 0) |
442 | c.add(eq("institutionCode", institutionCode)); |
||
443 | |||
376 | jmachado | 444 | if(withTeacher && !withNoTeacher) |
445 | { |
||
446 | c.createAlias("teachers", "th"); |
||
447 | c.add(isNotNull("th.id")); |
||
448 | } |
||
449 | else if(!withTeacher && withNoTeacher) |
||
450 | { |
||
451 | c.createAlias("teachers", "th", JoinFragment.LEFT_OUTER_JOIN); |
||
452 | c.add(isNull("th.id")); |
||
453 | } |
||
454 | return c.list(); |
||
455 | } |
||
163 | jmachado | 456 | |
376 | jmachado | 457 | |
205 | jmachado | 458 | public int countCourseUnits(1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType) |
459 | { |
||
749 | jmachado | 460 | Criterion c = DaoUtils.createSearchQuery(query, searchType, "objectives", "name","code"); |
205 | jmachado | 461 | return createCriteria().add(c).list().size(); |
462 | } |
||
163 | jmachado | 463 | |
205 | jmachado | 464 | public List<CourseUnit> search(1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchTypeEnum, int maxUnits, int page) |
465 | { |
||
748 | jmachado | 466 | Criterion c = DaoUtils.createSearchQuery(query, searchTypeEnum, "objectives", "name","code"); |
205 | jmachado | 467 | Criteria criteria = createCriteria(); |
468 | criteria.add(c) |
||
469 | .addOrder(Order.asc("name")) |
||
470 | .setMaxResults(maxUnits) |
||
471 | .setFirstResult(page * maxUnits); |
||
472 | return criteria.list(); |
||
473 | } |
||
202 | jmachado | 474 | |
206 | jmachado | 475 | public int countCourseUnitsActualYear(1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType) |
476 | { |
||
371 | jmachado | 477 | Criterion c = DaoUtils.createSearchQuery(query, searchType, "objectives", "name"); |
206 | jmachado | 478 | return createCriteria() |
479 | .add(c) |
||
995 | jmachado | 480 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
206 | jmachado | 481 | .list().size(); |
482 | } |
||
483 | |||
484 | public List<CourseUnit> searchActualYear(1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchTypeEnum, int maxUnits, int page) |
||
485 | { |
||
486 | Criterion c = DaoUtils.createSearchQuery(query, searchTypeEnum, "objectives", "name"); |
||
487 | Criteria criteria = createCriteria(); |
||
488 | criteria.add(c) |
||
995 | jmachado | 489 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
206 | jmachado | 490 | .addOrder(Order.asc("name")) |
491 | .setMaxResults(maxUnits) |
||
492 | .setFirstResult(page * maxUnits); |
||
493 | return criteria.list(); |
||
494 | } |
||
495 | |||
205 | jmachado | 496 | public List<CourseUnit> loadMissingObjectives(long teacherId) |
497 | { |
||
498 | //todo falta a projeccao do teacher id |
||
499 | return createCriteria() |
||
995 | jmachado | 500 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
371 | jmachado | 501 | .add((or(isNull("objectives"), eq("objectives", "")))) |
205 | jmachado | 502 | .createAlias("teachers", "th") |
371 | jmachado | 503 | .add(eq("semestre", DatesUtils.getSemestre())) |
504 | .add(eq("th.id", teacherId)) |
||
205 | jmachado | 505 | .list(); |
506 | } |
||
507 | |||
214 | jmachado | 508 | public List<CourseUnit> loadMissingPrograms(long teacherId) |
509 | { |
||
510 | //todo falta a projeccao do teacher id |
||
511 | return createCriteria() |
||
1171 | jmachado | 512 | .createAlias("course","c") |
513 | .add(eq("c.status", true)) |
||
995 | jmachado | 514 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
371 | jmachado | 515 | .add((or(isNull("programStreamId"), eq("programStreamId", "")))) |
214 | jmachado | 516 | .createAlias("teachers", "th") |
371 | jmachado | 517 | .add(eq("semestre", DatesUtils.getSemestre())) |
518 | .add(eq("th.id", teacherId)) |
||
214 | jmachado | 519 | .list(); |
520 | } |
||
521 | |||
343 | jmachado | 522 | public List<CourseUnit> loadMissingObjectivesOrPrograms(long teacherId) |
523 | { |
||
524 | //todo falta a projeccao do teacher id |
||
371 | jmachado | 525 | Criteria c = createCriteria() |
995 | jmachado | 526 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
371 | jmachado | 527 | .add(or(or(isNull("objectives"), eq("objectives", "")), or(isNull("programStreamId"), eq("programStreamId", "")))); |
528 | |||
529 | DatesUtils.SemestreModerate semestreModerate = DatesUtils.getSemestreModerate(); |
||
530 | if (semestreModerate == DatesUtils.SemestreModerate.S1) |
||
531 | c.add(eq("semestre", "S1")); |
||
532 | else if (semestreModerate == DatesUtils.SemestreModerate.S2) |
||
533 | c.add(eq("semestre", "S2")); |
||
534 | else |
||
535 | c.add(or(eq("semestre", "S1"), eq("semestre", "S2"))); |
||
536 | |||
537 | return c.createAlias("teachers", "th") |
||
538 | .add(eq("th.id", teacherId)) |
||
343 | jmachado | 539 | .list(); |
540 | } |
||
214 | jmachado | 541 | |
343 | jmachado | 542 | |
214 | jmachado | 543 | public List<CourseUnit> loadMissingObjectivesGivenCourse(long courseId) |
544 | { |
||
545 | return createCriteria() |
||
546 | .createAlias("course", "c") |
||
371 | jmachado | 547 | .add(eq("c.id", courseId)) |
995 | jmachado | 548 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
371 | jmachado | 549 | .add(eq("semestre", DatesUtils.getSemestre())) |
550 | .add((or(isNull("objectives"), eq("objectives", "")))) |
||
214 | jmachado | 551 | .list(); |
552 | } |
||
553 | |||
554 | public List<CourseUnit> loadMissingProgramGivenCourse(long courseId) |
||
555 | { |
||
556 | return createCriteria() |
||
557 | .createAlias("course", "c") |
||
371 | jmachado | 558 | .add(eq("c.id", courseId)) |
995 | jmachado | 559 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
371 | jmachado | 560 | .add(eq("semestre", DatesUtils.getSemestre())) |
561 | .add((or(isNull("programStreamId"), eq("programStreamId", "")))) |
||
214 | jmachado | 562 | .list(); |
563 | } |
||
564 | |||
509 | jmachado | 565 | public List<CourseUnit> loadMissingProgramValidateGivenCourse(long courseId) |
566 | { |
||
567 | return createCriteria() |
||
568 | .createAlias("course", "c") |
||
569 | .add(eq("c.id", courseId)) |
||
995 | jmachado | 570 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
509 | jmachado | 571 | .add(eq("semestre", DatesUtils.getSemestre())) |
572 | .add((and(isNotNull("programStreamId"), not(eq("programStreamId", ""))))) |
||
573 | .add((eq("validProgram", false))) |
||
574 | .list(); |
||
575 | } |
||
576 | |||
219 | jmachado | 577 | public List<CourseUnit> loadMissingObjectivesOrProgramGivenCourse(long courseId) |
214 | jmachado | 578 | { |
579 | return createCriteria() |
||
580 | .createAlias("course", "c") |
||
371 | jmachado | 581 | .add(eq("c.id", courseId)) |
995 | jmachado | 582 | .add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())) |
371 | jmachado | 583 | .add(eq("semestre", DatesUtils.getSemestre())) |
584 | .add((or(or(isNull("objectives"), eq("objectives", "")), or(isNull("programStreamId"), eq("programStreamId", ""))))) |
||
214 | jmachado | 585 | .list(); |
586 | } |
||
205 | jmachado | 587 | |
343 | jmachado | 588 | public int countMissingProgramGivenCourse(long courseId) |
589 | { |
||
590 | return loadMissingProgramGivenCourse(courseId).size(); |
||
591 | } |
||
205 | jmachado | 592 | |
509 | jmachado | 593 | public int countMissingProgramValidateCourse(long courseId) |
594 | { |
||
595 | return loadMissingProgramValidateGivenCourse(courseId).size(); |
||
596 | } |
||
751 | jmachado | 597 | |
598 | |||
599 | public List<String> getTeachersEmails(long unit) { |
||
600 | 1.5.0/docs/api/javax/management/Query.html">Query q = createQuery("select e.email from " |
||
601 | + Teacher.class.getName() + " e join e.teachedUnits as unit " |
||
602 | + " where " |
||
603 | + " unit.id = ? " |
||
604 | |||
605 | ); |
||
606 | q.setLong(0,unit); |
||
607 | return q.list(); |
||
608 | } |
||
961 | jmachado | 609 | |
610 | public static class CourseMissingValidationProgram |
||
611 | { |
||
612 | public Course course; |
||
613 | public List<CourseUnit> courseUnits; |
||
614 | } |
||
1171 | jmachado | 615 | |
616 | /** |
||
617 | * Load all programs from active courses that are for validation |
||
618 | * @param userSession |
||
619 | * @return |
||
620 | */ |
||
961 | jmachado | 621 | public List<CourseMissingValidationProgram> loadMissingProgramValidate(UserSession userSession) |
622 | { |
||
623 | List<CourseMissingValidationProgram> result = new ArrayList<CourseMissingValidationProgram>(); |
||
1171 | jmachado | 624 | List<Course> courses = DaoFactory.getCourseDaoImpl().findActiveCourses(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()); |
961 | jmachado | 625 | for(Course course: courses) |
626 | { |
||
1094 | jmachado | 627 | if(userSession.getUser().hasRole(course.getValidationRole()) || userSession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE)) |
961 | jmachado | 628 | { |
629 | List<CourseUnit> courseUnits = loadMissingProgramValidateGivenCourse(course.getId()); |
||
630 | if(courseUnits != null && courseUnits.size() > 0) |
||
631 | { |
||
632 | CourseMissingValidationProgram c = new CourseMissingValidationProgram(); |
||
633 | c.course = course; |
||
634 | c.courseUnits = courseUnits; |
||
635 | result.add(c); |
||
636 | } |
||
637 | } |
||
638 | } |
||
639 | return result; |
||
640 | } |
||
1103 | jmachado | 641 | |
1171 | jmachado | 642 | /** |
643 | * Load all programs missing from active courses |
||
644 | * @param userSession |
||
645 | * @return |
||
646 | */ |
||
1040 | jmachado | 647 | public List<CourseMissingValidationProgram> loadMissingPrograms(UserSession userSession) |
648 | { |
||
649 | List<CourseMissingValidationProgram> result = new ArrayList<CourseMissingValidationProgram>(); |
||
1171 | jmachado | 650 | List<Course> courses = DaoFactory.getCourseDaoImpl().findActiveCourses(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()); |
1040 | jmachado | 651 | for(Course course: courses) |
652 | { |
||
1094 | jmachado | 653 | if(userSession.getUser().hasRole(course.getValidationRole()) || userSession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE)) |
1040 | jmachado | 654 | { |
655 | List<CourseUnit> courseUnits = loadMissingProgramGivenCourse(course.getId()); |
||
656 | if(courseUnits != null && courseUnits.size() > 0) |
||
657 | { |
||
658 | CourseMissingValidationProgram c = new CourseMissingValidationProgram(); |
||
659 | c.course = course; |
||
660 | c.courseUnits = courseUnits; |
||
661 | result.add(c); |
||
662 | } |
||
663 | } |
||
664 | } |
||
665 | return result; |
||
666 | } |
||
961 | jmachado | 667 | public static class CourseMissingValidationEvaluation |
668 | { |
||
669 | public Course course; |
||
670 | public List<CourseUnit> courseUnits; |
||
671 | } |
||
672 | |||
673 | public List<CourseMissingValidationEvaluation> loadMissingEvaluationValidate(UserSession userSession) |
||
674 | { |
||
675 | List<CourseMissingValidationEvaluation> result = new ArrayList<CourseMissingValidationEvaluation>(); |
||
962 | jmachado | 676 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(); |
961 | jmachado | 677 | for(Course course: courses) |
678 | { |
||
1094 | jmachado | 679 | if(userSession.getUser().hasRole(course.getValidationRole()) || userSession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE)) |
961 | jmachado | 680 | { |
681 | List<CourseUnit> courseUnits = loadMissingEvaluationValidateGivenCourse(course.getId()); |
||
682 | if(courseUnits != null && courseUnits.size() > 0) |
||
683 | { |
||
684 | CourseMissingValidationEvaluation c = new CourseMissingValidationEvaluation(); |
||
685 | c.course = course; |
||
686 | c.courseUnits = courseUnits; |
||
687 | result.add(c); |
||
688 | } |
||
689 | } |
||
690 | } |
||
691 | return result; |
||
692 | } |
||
693 | |||
1103 | jmachado | 694 | |
695 | |||
961 | jmachado | 696 | /* |
697 | * Neste caso apenas se validam as do ano anterior*/ |
||
698 | |||
699 | public List<CourseUnit> loadMissingEvaluationValidateGivenCourse(long courseId) |
||
700 | { |
||
1070 | jmachado | 701 | 1.5.0/docs/api/java/lang/String.html">String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear(); |
1077 | jmachado | 702 | |
703 | Criterion degreesCrit = getCourseUnitActiveDegreeCourseIdsCriterion(activeYear); |
||
704 | if(degreesCrit == null) |
||
1017 | jmachado | 705 | return new ArrayList<CourseUnit>(); |
706 | |||
961 | jmachado | 707 | return createCriteria() |
708 | .createAlias("course", "c") |
||
709 | .createAlias("courseUnitEvaluation", "ce") |
||
710 | .add(eq("c.id", courseId)) |
||
1070 | jmachado | 711 | .add(eq("importYear", activeYear)) |
712 | .add(degreesCrit) |
||
961 | jmachado | 713 | .add((eq("ce.closed", false))) |
1017 | jmachado | 714 | .add((eq("ce.teacherComplete", true))) |
961 | jmachado | 715 | .list(); |
716 | } |
||
967 | jmachado | 717 | |
1077 | jmachado | 718 | /** |
1103 | jmachado | 719 | * |
720 | * @return devolve todos os ids de unidades que verifiquem a condição de avaliação |
||
721 | * do periodo actual e tenham o programa fechado pela comissão |
||
722 | */ |
||
723 | |||
724 | public List<Long> loadClosedCourseUnitsEvaluations() |
||
725 | { |
||
726 | 1.5.0/docs/api/java/lang/String.html">String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear(); |
||
727 | |||
728 | Criterion degreesCrit = getCourseUnitActiveDegreeCourseIdsCriterion(activeYear); |
||
729 | if(degreesCrit == null) |
||
730 | return new ArrayList<Long>(); |
||
731 | |||
732 | return createCriteria() |
||
733 | .setProjection(Projections.property("id")) |
||
734 | .createAlias("course", "c") |
||
735 | .createAlias("courseUnitEvaluation", "ce") |
||
736 | .add(eq("importYear", activeYear)) |
||
737 | .add(degreesCrit) |
||
738 | .add((eq("ce.closed", true))) |
||
739 | .list(); |
||
740 | } |
||
741 | |||
742 | /** |
||
1077 | jmachado | 743 | * Devolve um criteio OR para todos os cursos de grau pertencente à lista de graus |
744 | * ou pertencete à lista de cursoIds |
||
745 | |||
746 | * @return |
||
747 | */ |
||
748 | private Criterion getCourseUnitActiveDegreeCourseIdsCriterion(1.5.0/docs/api/java/lang/String.html">String activeYear) |
||
1070 | jmachado | 749 | { |
1077 | jmachado | 750 | List<String> activeDegrees = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveDegrees(); |
751 | List<Long> activeCourseIds = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveCourseIds(); |
||
752 | boolean activeDegreesOff = activeDegrees == null || activeDegrees.size() == 0; |
||
753 | boolean activeCourseIdsOff = activeCourseIds == null || activeCourseIds.size() == 0; |
||
754 | if(activeYear == null || (activeDegreesOff && activeCourseIdsOff)) |
||
755 | return null; |
||
756 | |||
757 | Criterion crit = null; |
||
758 | |||
759 | if(activeDegrees != null) |
||
760 | for(1.5.0/docs/api/java/lang/String.html">String degree: activeDegrees) |
||
761 | { |
||
762 | if(crit == null) |
||
763 | crit = eq("c.degree",degree); |
||
764 | else |
||
765 | crit = or(crit,eq("c.degree",degree)); |
||
766 | } |
||
767 | if(activeCourseIds != null) |
||
768 | for(1.5.0/docs/api/java/lang/Long.html">Long courseId: activeCourseIds) |
||
769 | { |
||
770 | if(crit == null) |
||
771 | crit = eq("c.id",courseId); |
||
772 | else |
||
773 | crit = or(crit,eq("c.id",courseId)); |
||
774 | } |
||
775 | |||
776 | return crit; |
||
1070 | jmachado | 777 | } |
778 | |||
1077 | jmachado | 779 | |
1024 | jmachado | 780 | public List<CourseUnit> loadTeacherUnitsMissingEvaluation(UserSession userSession) |
781 | { |
||
782 | 1.5.0/docs/api/java/lang/String.html">String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear(); |
||
1077 | jmachado | 783 | |
784 | Criterion degreesCrit = getCourseUnitActiveDegreeCourseIdsCriterion(activeYear); |
||
785 | if(degreesCrit == null) |
||
1024 | jmachado | 786 | return new ArrayList<CourseUnit>(); |
787 | |||
1070 | jmachado | 788 | |
1024 | jmachado | 789 | List<CourseUnit> nulls = |
790 | createCriteria() |
||
1070 | jmachado | 791 | .createAlias("course", "c") |
1074 | jmachado | 792 | .createAlias("teachers", "t") |
1077 | jmachado | 793 | .add(eq("importYear", activeYear)) |
1024 | jmachado | 794 | //.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))) |
795 | //.add(ge("importYear", "201415" )) |
||
796 | //.add(isNull("courseUnitEvaluation")) |
||
797 | //todo novo testar |
||
798 | .add(eq("t.id", userSession.getUser().getId())) |
||
1070 | jmachado | 799 | .add(degreesCrit) |
1024 | jmachado | 800 | .add(isNull("courseUnitEvaluation")) |
801 | .list(); |
||
802 | |||
803 | List<CourseUnit> teacherCompleteFalse = |
||
804 | createCriteria() |
||
1070 | jmachado | 805 | .createAlias("course", "c") |
1024 | jmachado | 806 | .createAlias("courseUnitEvaluation", "ce") |
1094 | jmachado | 807 | .createAlias("teachers", "t") |
1028 | jmachado | 808 | .add(eq("t.id", userSession.getUser().getId())) |
1077 | jmachado | 809 | .add(eq("importYear", activeYear)) |
1024 | jmachado | 810 | //.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))) |
811 | //.add(ge("importYear", "201415" )) |
||
812 | //.add(isNull("courseUnitEvaluation")) |
||
813 | //todo novo testar |
||
1070 | jmachado | 814 | .add(degreesCrit) |
1074 | jmachado | 815 | .add(eq("ce.teacherComplete", false)) |
1024 | jmachado | 816 | .list(); |
817 | teacherCompleteFalse.addAll(nulls); |
||
818 | return teacherCompleteFalse; |
||
819 | } |
||
820 | |||
821 | |||
967 | jmachado | 822 | public List<CourseMissingValidationEvaluation> loadMissingEvaluation(UserSession userSession) |
823 | { |
||
824 | List<CourseMissingValidationEvaluation> result = new ArrayList<CourseMissingValidationEvaluation>(); |
||
825 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(); |
||
826 | for(Course course: courses) |
||
827 | { |
||
1094 | jmachado | 828 | if(userSession.getUser().hasRole(course.getValidationRole()) || userSession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE)) |
967 | jmachado | 829 | { |
830 | List<CourseUnit> courseUnits = loadMissingEvaluation(course.getId()); |
||
831 | if(courseUnits != null && courseUnits.size() > 0) |
||
832 | { |
||
833 | CourseMissingValidationEvaluation c = new CourseMissingValidationEvaluation(); |
||
834 | c.course = course; |
||
835 | c.courseUnits = courseUnits; |
||
836 | result.add(c); |
||
837 | } |
||
838 | } |
||
839 | } |
||
840 | return result; |
||
841 | } |
||
842 | |||
843 | public List<CourseUnit> loadMissingEvaluation(long courseId) |
||
844 | { |
||
1070 | jmachado | 845 | |
846 | 1.5.0/docs/api/java/lang/String.html">String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear(); |
||
1077 | jmachado | 847 | Criterion degreesCrit = getCourseUnitActiveDegreeCourseIdsCriterion(activeYear); |
848 | |||
849 | if(degreesCrit == null) |
||
1017 | jmachado | 850 | return new ArrayList<CourseUnit>(); |
851 | |||
1024 | jmachado | 852 | List<CourseUnit> nulls = |
853 | createCriteria() |
||
967 | jmachado | 854 | .createAlias("course", "c") |
855 | .add(eq("c.id", courseId)) |
||
1070 | jmachado | 856 | .add(eq("importYear", activeYear)) |
857 | .add(degreesCrit) |
||
1024 | jmachado | 858 | .add(isNull("courseUnitEvaluation")) |
967 | jmachado | 859 | .list(); |
1024 | jmachado | 860 | |
861 | List<CourseUnit> teacherCompleteFalse = |
||
862 | createCriteria() |
||
863 | .createAlias("course", "c") |
||
864 | .createAlias("courseUnitEvaluation", "ce") |
||
865 | .add(eq("c.id", courseId)) |
||
1070 | jmachado | 866 | .add(degreesCrit) |
867 | .add(eq("importYear", activeYear)) |
||
1024 | jmachado | 868 | .add(eq("ce.teacherComplete", false)) |
869 | .list(); |
||
870 | teacherCompleteFalse.addAll(nulls); |
||
871 | return teacherCompleteFalse; |
||
967 | jmachado | 872 | } |
973 | jmachado | 873 | |
874 | public CourseUnit loadByEvaluationStreamId(1.5.0/docs/api/java/lang/String.html">String identifier) |
||
875 | { |
||
876 | return |
||
877 | (CourseUnit) |
||
878 | createCriteria() |
||
879 | .add(eq("evaluationStreamId",identifier)) |
||
880 | .uniqueResult(); |
||
881 | } |
||
110 | susana | 882 | } |