1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.calendar.service.persistence;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.dao.orm.QueryPos;
19  import com.liferay.portal.kernel.dao.orm.SQLQuery;
20  import com.liferay.portal.kernel.dao.orm.Session;
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  /**
33   * <a href="CalEventFinderImpl.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Brian Wing Shun Chan
36   */
37  public class CalEventFinderImpl
38      extends BasePersistenceImpl<CalEvent> implements CalEventFinder {
39  
40      public static String FIND_BY_G_SD =
41          CalEventFinder.class.getName() + ".findByG_SD";
42  
43      public List<CalEvent> findByG_SD(
44              long groupId, Date startDateGT, Date startDateLT,
45              boolean timeZoneSensitive)
46          throws SystemException {
47  
48          Timestamp startDateGT_TS = CalendarUtil.getTimestamp(startDateGT);
49          Timestamp startDateLT_TS = CalendarUtil.getTimestamp(startDateLT);
50  
51          Session session = null;
52  
53          try {
54              session = openSession();
55  
56              String sql = CustomSQLUtil.get(FIND_BY_G_SD);
57  
58              SQLQuery q = session.createSQLQuery(sql);
59  
60              q.addEntity("CalEvent", CalEventImpl.class);
61  
62              QueryPos qPos = QueryPos.getInstance(q);
63  
64              qPos.add(groupId);
65              qPos.add(startDateGT_TS);
66              qPos.add(startDateLT_TS);
67              qPos.add(timeZoneSensitive);
68              qPos.add(false);
69  
70              return q.list();
71          }
72          catch (Exception e) {
73              throw new SystemException(e);
74          }
75          finally {
76              closeSession(session);
77          }
78      }
79  
80  }