1
14
15 package com.liferay.portlet.calendar.service.persistence;
16
17 import com.liferay.portal.kernel.dao.orm.QueryPos;
18 import com.liferay.portal.kernel.dao.orm.SQLQuery;
19 import com.liferay.portal.kernel.dao.orm.Session;
20 import com.liferay.portal.kernel.exception.SystemException;
21 import com.liferay.portal.kernel.util.CalendarUtil;
22 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
23 import com.liferay.portlet.calendar.model.CalEvent;
24 import com.liferay.portlet.calendar.model.impl.CalEventImpl;
25 import com.liferay.util.dao.orm.CustomSQLUtil;
26
27 import java.sql.Timestamp;
28
29 import java.util.Date;
30 import java.util.List;
31
32
37 public class CalEventFinderImpl
38 extends BasePersistenceImpl<CalEvent> implements CalEventFinder {
39
40 public static String FIND_BY_NO_ASSETS =
41 CalEventFinder.class.getName() + ".findByNoAssets";
42
43 public static String FIND_BY_G_SD =
44 CalEventFinder.class.getName() + ".findByG_SD";
45
46 public List<CalEvent> findByNoAssets() throws SystemException {
47 Session session = null;
48
49 try {
50 session = openSession();
51
52 String sql = CustomSQLUtil.get(FIND_BY_NO_ASSETS);
53
54 SQLQuery q = session.createSQLQuery(sql);
55
56 q.addEntity("CalEvent", CalEventImpl.class);
57
58 return q.list();
59 }
60 catch (Exception e) {
61 throw new SystemException(e);
62 }
63 finally {
64 closeSession(session);
65 }
66 }
67
68 public List<CalEvent> findByG_SD(
69 long groupId, Date startDateGT, Date startDateLT,
70 boolean timeZoneSensitive)
71 throws SystemException {
72
73 Timestamp startDateGT_TS = CalendarUtil.getTimestamp(startDateGT);
74 Timestamp startDateLT_TS = CalendarUtil.getTimestamp(startDateLT);
75
76 Session session = null;
77
78 try {
79 session = openSession();
80
81 String sql = CustomSQLUtil.get(FIND_BY_G_SD);
82
83 SQLQuery q = session.createSQLQuery(sql);
84
85 q.addEntity("CalEvent", CalEventImpl.class);
86
87 QueryPos qPos = QueryPos.getInstance(q);
88
89 qPos.add(groupId);
90 qPos.add(startDateGT_TS);
91 qPos.add(startDateLT_TS);
92 qPos.add(timeZoneSensitive);
93 qPos.add(false);
94
95 return q.list();
96 }
97 catch (Exception e) {
98 throw new SystemException(e);
99 }
100 finally {
101 closeSession(session);
102 }
103 }
104
105 }