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.exception.SystemException;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
023 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
024 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
025 import com.liferay.portlet.documentlibrary.model.DLFolder;
026 import com.liferay.portlet.documentlibrary.model.DLSync;
027 import com.liferay.portlet.documentlibrary.model.DLSyncConstants;
028 import com.liferay.portlet.documentlibrary.model.impl.DLSyncImpl;
029 import com.liferay.util.dao.orm.CustomSQLUtil;
030
031 import java.util.List;
032
033
036 public class DLSyncFinderImpl
037 extends BasePersistenceImpl<DLSync> implements DLSyncFinder {
038
039 public static final String FIND_BY_C_M_R_T =
040 DLSyncFinder.class.getName() + ".findByC_M_R_T";
041
042 public List<DLSync> filterFindByC_M_R(
043 long companyId, long modifiedDate, long repositoryId)
044 throws SystemException {
045
046 Session session = null;
047
048 try {
049 session = openSession();
050
051 String sql = CustomSQLUtil.get(FIND_BY_C_M_R_T);
052
053 sql = InlineSQLHelperUtil.replacePermissionCheck(
054 sql, DLFolder.class.getName(), "DLSync.fileId", null,
055 "DLSync.repositoryId", new long[] {repositoryId}, null);
056
057 StringBundler sb = new StringBundler(3);
058
059 sb.append(sql);
060 sb.append(" UNION ALL ");
061
062 sql = CustomSQLUtil.get(FIND_BY_C_M_R_T);
063
064 sql = InlineSQLHelperUtil.replacePermissionCheck(
065 sql, DLFileEntry.class.getName(), "DLSync.fileId", null,
066 "DLSync.repositoryId", new long[] {repositoryId}, null);
067
068 sb.append(sql);
069
070 sql = sb.toString();
071
072 SQLQuery q = session.createSQLQuery(sql);
073
074 q.addEntity("DLSync", DLSyncImpl.class);
075
076 QueryPos qPos = QueryPos.getInstance(q);
077
078 qPos.add(companyId);
079 qPos.add(modifiedDate);
080 qPos.add(repositoryId);
081 qPos.add(DLSyncConstants.TYPE_FOLDER);
082 qPos.add(companyId);
083 qPos.add(modifiedDate);
084 qPos.add(repositoryId);
085 qPos.add(DLSyncConstants.TYPE_FILE);
086
087 return q.list();
088 }
089 catch (Exception e) {
090 throw new SystemException(e);
091 }
092 finally {
093 closeSession(session);
094 }
095 }
096
097 }