001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.calendar.service.persistence;
022:
023: import com.liferay.portal.SystemException;
024: import com.liferay.portal.spring.hibernate.CustomSQLUtil;
025: import com.liferay.portal.spring.hibernate.HibernateUtil;
026: import com.liferay.portlet.calendar.model.impl.CalEventImpl;
027: import com.liferay.util.cal.CalendarUtil;
028: import com.liferay.util.dao.hibernate.QueryPos;
029:
030: import java.sql.Timestamp;
031:
032: import java.util.Date;
033: import java.util.List;
034:
035: import org.hibernate.SQLQuery;
036: import org.hibernate.Session;
037:
038: /**
039: * <a href="CalEventFinderImpl.java.html"><b><i>View Source</i></b></a>
040: *
041: * @author Brian Wing Shun Chan
042: *
043: */
044: public class CalEventFinderImpl implements CalEventFinder {
045:
046: public static String FIND_BY_G_SD = CalEventFinder.class.getName()
047: + ".findByG_SD";
048:
049: public static String FIND_BY_REMINDBY = CalEventFinder.class
050: .getName()
051: + ".findByRemindBy";
052:
053: public List findByG_SD(long groupId, Date startDateGT,
054: Date startDateLT, boolean timeZoneSensitive)
055: throws SystemException {
056:
057: Timestamp startDateGT_TS = CalendarUtil
058: .getTimestamp(startDateGT);
059: Timestamp startDateLT_TS = CalendarUtil
060: .getTimestamp(startDateLT);
061:
062: Session session = null;
063:
064: try {
065: session = HibernateUtil.openSession();
066:
067: String sql = CustomSQLUtil.get(FIND_BY_G_SD);
068:
069: SQLQuery q = session.createSQLQuery(sql);
070:
071: q.addEntity("CalEvent", CalEventImpl.class);
072:
073: QueryPos qPos = QueryPos.getInstance(q);
074:
075: qPos.add(groupId);
076: qPos.add(startDateGT_TS);
077: qPos.add(startDateLT_TS);
078: qPos.add(timeZoneSensitive);
079: qPos.add(false);
080:
081: return q.list();
082: } catch (Exception e) {
083: throw new SystemException(e);
084: } finally {
085: HibernateUtil.closeSession(session);
086: }
087: }
088:
089: public List findByRemindBy() throws SystemException {
090: Session session = null;
091:
092: try {
093: session = HibernateUtil.openSession();
094:
095: String sql = CustomSQLUtil.get(FIND_BY_REMINDBY);
096:
097: SQLQuery q = session.createSQLQuery(sql);
098:
099: q.addEntity("CalEvent", CalEventImpl.class);
100:
101: QueryPos qPos = QueryPos.getInstance(q);
102:
103: qPos.add(CalEventImpl.REMIND_BY_NONE);
104:
105: return q.list();
106: } catch (Exception e) {
107: throw new SystemException(e);
108: } finally {
109: HibernateUtil.closeSession(session);
110: }
111: }
112:
113: }
|