1
22
23 package com.liferay.portlet.calendar.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.spring.hibernate.CustomSQLUtil;
27 import com.liferay.portal.spring.hibernate.HibernateUtil;
28 import com.liferay.portlet.calendar.model.impl.CalEventImpl;
29 import com.liferay.util.cal.CalendarUtil;
30 import com.liferay.util.dao.hibernate.QueryPos;
31
32 import java.sql.Timestamp;
33
34 import java.util.Date;
35 import java.util.List;
36
37 import org.hibernate.SQLQuery;
38 import org.hibernate.Session;
39
40
46 public class CalEventFinder {
47
48 public static String FIND_BY_G_SD =
49 CalEventFinder.class.getName() + ".findByG_SD";
50
51 public static String FIND_BY_REMINDBY =
52 CalEventFinder.class.getName() + ".findByRemindBy";
53
54 public static List findByG_SD(
55 long groupId, Date startDateGT, Date startDateLT,
56 boolean timeZoneSensitive)
57 throws SystemException {
58
59 Timestamp startDateGT_TS = CalendarUtil.getTimestamp(startDateGT);
60 Timestamp startDateLT_TS = CalendarUtil.getTimestamp(startDateLT);
61
62 Session session = null;
63
64 try {
65 session = HibernateUtil.openSession();
66
67 String sql = CustomSQLUtil.get(FIND_BY_G_SD);
68
69 SQLQuery q = session.createSQLQuery(sql);
70
71 q.addEntity("CalEvent", CalEventImpl.class);
72
73 QueryPos qPos = QueryPos.getInstance(q);
74
75 qPos.add(groupId);
76 qPos.add(startDateGT_TS);
77 qPos.add(startDateLT_TS);
78 qPos.add(timeZoneSensitive);
79 qPos.add(false);
80
81 return q.list();
82 }
83 catch (Exception e) {
84 throw new SystemException(e);
85 }
86 finally {
87 HibernateUtil.closeSession(session);
88 }
89 }
90
91 public static List findByRemindBy() throws SystemException {
92 Session session = null;
93
94 try {
95 session = HibernateUtil.openSession();
96
97 String sql = CustomSQLUtil.get(FIND_BY_REMINDBY);
98
99 SQLQuery q = session.createSQLQuery(sql);
100
101 q.addEntity("CalEvent", CalEventImpl.class);
102
103 QueryPos qPos = QueryPos.getInstance(q);
104
105 qPos.add(CalEventImpl.REMIND_BY_NONE);
106
107 return q.list();
108 }
109 catch (Exception e) {
110 throw new SystemException(e);
111 }
112 finally {
113 HibernateUtil.closeSession(session);
114 }
115 }
116
117 }