001
014
015 package com.liferay.portlet.documentlibrary.service.persistence;
016
017 import com.liferay.portal.kernel.dao.orm.QueryPos;
018 import com.liferay.portal.kernel.dao.orm.SQLQuery;
019 import com.liferay.portal.kernel.dao.orm.Session;
020 import com.liferay.portal.kernel.dao.orm.Type;
021 import com.liferay.portal.kernel.exception.SystemException;
022 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
023 import com.liferay.portlet.documentlibrary.model.DLFileRank;
024 import com.liferay.portlet.documentlibrary.model.impl.DLFileRankImpl;
025 import com.liferay.util.dao.orm.CustomSQLUtil;
026
027 import java.util.List;
028
029
032 public class DLFileRankFinderImpl
033 extends BasePersistenceImpl<DLFileRank> implements DLFileRankFinder {
034
035 public static final String FIND_BY_STALE_RANKS =
036 DLFileRankFinder.class.getName() + ".findByStaleRanks";
037
038 public static final String FIND_BY_FOLDER_ID =
039 DLFileRankFinder.class.getName() + ".findByFolderId";
040
041 public List<Object[]> findByStaleRanks(int count) throws SystemException {
042 Session session = null;
043
044 try {
045 session = openSession();
046
047 String sql = CustomSQLUtil.get(FIND_BY_STALE_RANKS);
048
049 SQLQuery q = session.createSQLQuery(sql);
050
051 q.addScalar("groupId", Type.LONG);
052 q.addScalar("userId", Type.LONG);
053
054 QueryPos qPos = QueryPos.getInstance(q);
055
056 qPos.add(count);
057
058 return q.list(true);
059 }
060 catch (Exception e) {
061 throw new SystemException(e);
062 }
063 finally {
064 closeSession(session);
065 }
066 }
067
068 public List<DLFileRank> findByFolderId(long folderId)
069 throws SystemException {
070
071 Session session = null;
072
073 try {
074 session = openSession();
075
076 String sql = CustomSQLUtil.get(FIND_BY_FOLDER_ID);
077
078 SQLQuery q = session.createSQLQuery(sql);
079
080 q.addEntity("DLFileRank", DLFileRankImpl.class);
081
082 QueryPos qPos = QueryPos.getInstance(q);
083
084 qPos.add(folderId);
085
086 return q.list(true);
087 }
088 catch (Exception e) {
089 throw new SystemException(e);
090 }
091 finally {
092 closeSession(session);
093 }
094 }
095
096 }