001
014
015 package com.liferay.portal.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.model.PortletPreferences;
022 import com.liferay.portal.model.impl.PortletPreferencesImpl;
023 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
024 import com.liferay.util.dao.orm.CustomSQLUtil;
025
026 import java.util.List;
027
028
032 public class PortletPreferencesFinderImpl
033 extends BasePersistenceImpl<PortletPreferences>
034 implements PortletPreferencesFinder {
035
036 public static final String FIND_BY_PORTLETID =
037 PortletPreferencesFinder.class.getName() + ".findByPortletId";
038
039 public static final String FIND_BY_C_G_O_O_P_P =
040 PortletPreferencesFinder.class.getName() + ".findByC_G_O_O_P_P";
041
042 public List<PortletPreferences> findByPortletId(String portletId)
043 throws SystemException {
044
045 Session session = null;
046
047 try {
048 session = openSession();
049
050 String sql = CustomSQLUtil.get(FIND_BY_PORTLETID);
051
052 SQLQuery q = session.createSQLQuery(sql);
053
054 q.addEntity("PortletPreferences", PortletPreferencesImpl.class);
055
056 QueryPos qPos = QueryPos.getInstance(q);
057
058 qPos.add(portletId);
059
060 return q.list(true);
061 }
062 catch (Exception e) {
063 throw new SystemException(e);
064 }
065 finally {
066 closeSession(session);
067 }
068 }
069
070 public List<PortletPreferences> findByC_G_O_O_P_P(
071 long companyId, long groupId, long ownerId, int ownerType,
072 String portletId, boolean privateLayout)
073 throws SystemException {
074
075 Session session = null;
076
077 try {
078 session = openSession();
079
080 String sql = CustomSQLUtil.get(FIND_BY_C_G_O_O_P_P);
081
082 SQLQuery q = session.createSQLQuery(sql);
083
084 q.addEntity("PortletPreferences", PortletPreferencesImpl.class);
085
086 QueryPos qPos = QueryPos.getInstance(q);
087
088 qPos.add(companyId);
089 qPos.add(groupId);
090 qPos.add(ownerId);
091 qPos.add(ownerType);
092 qPos.add(portletId);
093 qPos.add(portletId.concat("_INSTANCE_%"));
094 qPos.add(privateLayout);
095
096 return q.list(true);
097 }
098 catch (Exception e) {
099 throw new SystemException(e);
100 }
101 finally {
102 closeSession(session);
103 }
104 }
105
106 }