Rev 1929 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1929 | Rev 1930 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.domain.dao.impl; |
1 | package pt.estgp.estgweb.domain.dao.impl; |
2 | 2 | ||
3 | import pt.estgp.estgweb.domain.CourseYear; |
3 | import pt.estgp.estgweb.domain.CourseYear; |
4 | 4 | ||
5 | import java.util.List; |
5 | import java.util.List; |
6 | 6 | ||
7 | import static org.hibernate.criterion.Restrictions.eq; |
7 | import static org.hibernate.criterion.Restrictions.eq; |
8 | 8 | ||
9 | /** |
9 | /** |
10 | * Created by jorgemachado on 06/03/16. |
10 | * Created by jorgemachado on 06/03/16. |
11 | */ |
11 | */ |
12 | public class CourseYearDaoImpl extends CourseYearDao |
12 | public class CourseYearDaoImpl extends CourseYearDao |
13 | { |
13 | { |
14 | public static CourseYearDaoImpl getInstance() |
14 | public static CourseYearDaoImpl getInstance() |
15 | { |
15 | { |
16 | if (myInstance == null) |
16 | if (myInstance == null) |
17 | myInstance = new CourseYearDaoImpl(); |
17 | myInstance = new CourseYearDaoImpl(); |
18 | return (CourseYearDaoImpl) myInstance; |
18 | return (CourseYearDaoImpl) myInstance; |
19 | } |
19 | } |
20 | 20 | ||
21 | public List<CourseYear> findCourseYear(1.5.0/docs/api/java/lang/String.html">String code, 1.5.0/docs/api/java/lang/String.html">String importYear) |
21 | public List<CourseYear> findCourseYear(1.5.0/docs/api/java/lang/String.html">String code, 1.5.0/docs/api/java/lang/String.html">String importYear) |
22 | { |
22 | { |
23 | List<CourseYear> cYs = createCriteria() |
23 | List<CourseYear> cYs = createCriteria() |
24 | .createAlias("course","c") |
24 | .createAlias("course","c") |
25 | .add(eq("importYear", importYear)) |
25 | .add(eq("importYear", importYear)) |
26 | .add(eq("c.code",code)).list(); |
26 | .add(eq("c.code",code)).list(); |
27 | return cYs; |
27 | return cYs; |
28 | } |
28 | } |
- | 29 | ||
29 | public CourseYear findCourseYearU(1.5.0/docs/api/java/lang/String.html">String code, 1.5.0/docs/api/java/lang/String.html">String importYear) |
30 | public CourseYear findCourseYearU(1.5.0/docs/api/java/lang/String.html">String code, 1.5.0/docs/api/java/lang/String.html">String importYear) |
30 | { |
31 | { |
31 | List<CourseYear> cYs = findCourseYear(code,importYear); |
32 | List<CourseYear> cYs = findCourseYear(code, importYear); |
32 | 33 | ||
33 | if (cYs.isEmpty()) |
34 | if (cYs.isEmpty()) |
34 | return null; |
35 | return null; |
35 | 36 | ||
36 | return cYs.get(0); |
37 | return cYs.get(0); |
37 | } |
38 | } |
38 | } |
39 | } |
39 | 40 |