0001: /**
0002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
0003: *
0004: * Permission is hereby granted, free of charge, to any person obtaining a copy
0005: * of this software and associated documentation files (the "Software"), to deal
0006: * in the Software without restriction, including without limitation the rights
0007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0008: * copies of the Software, and to permit persons to whom the Software is
0009: * furnished to do so, subject to the following conditions:
0010: *
0011: * The above copyright notice and this permission notice shall be included in
0012: * all copies or substantial portions of the Software.
0013: *
0014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0020: * SOFTWARE.
0021: */package com.liferay.portal.service.persistence;
0022:
0023: import com.liferay.portal.NoSuchLayoutException;
0024: import com.liferay.portal.SystemException;
0025: import com.liferay.portal.kernel.dao.DynamicQuery;
0026: import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
0027: import com.liferay.portal.kernel.util.GetterUtil;
0028: import com.liferay.portal.kernel.util.OrderByComparator;
0029: import com.liferay.portal.kernel.util.StringMaker;
0030: import com.liferay.portal.kernel.util.StringPool;
0031: import com.liferay.portal.kernel.util.Validator;
0032: import com.liferay.portal.model.Layout;
0033: import com.liferay.portal.model.ModelListener;
0034: import com.liferay.portal.model.impl.LayoutImpl;
0035: import com.liferay.portal.model.impl.LayoutModelImpl;
0036: import com.liferay.portal.spring.hibernate.FinderCache;
0037: import com.liferay.portal.spring.hibernate.HibernateUtil;
0038: import com.liferay.portal.util.PropsUtil;
0039:
0040: import com.liferay.util.dao.hibernate.QueryUtil;
0041:
0042: import org.apache.commons.logging.Log;
0043: import org.apache.commons.logging.LogFactory;
0044:
0045: import org.hibernate.Query;
0046: import org.hibernate.Session;
0047:
0048: import java.util.Collections;
0049: import java.util.Iterator;
0050: import java.util.List;
0051:
0052: /**
0053: * <a href="LayoutPersistenceImpl.java.html"><b><i>View Source</i></b></a>
0054: *
0055: * @author Brian Wing Shun Chan
0056: *
0057: */
0058: public class LayoutPersistenceImpl extends BasePersistence implements
0059: LayoutPersistence {
0060: public Layout create(long plid) {
0061: Layout layout = new LayoutImpl();
0062:
0063: layout.setNew(true);
0064: layout.setPrimaryKey(plid);
0065:
0066: return layout;
0067: }
0068:
0069: public Layout remove(long plid) throws NoSuchLayoutException,
0070: SystemException {
0071: Session session = null;
0072:
0073: try {
0074: session = openSession();
0075:
0076: Layout layout = (Layout) session.get(LayoutImpl.class,
0077: new Long(plid));
0078:
0079: if (layout == null) {
0080: if (_log.isWarnEnabled()) {
0081: _log.warn("No Layout exists with the primary key "
0082: + plid);
0083: }
0084:
0085: throw new NoSuchLayoutException(
0086: "No Layout exists with the primary key " + plid);
0087: }
0088:
0089: return remove(layout);
0090: } catch (NoSuchLayoutException nsee) {
0091: throw nsee;
0092: } catch (Exception e) {
0093: throw HibernateUtil.processException(e);
0094: } finally {
0095: closeSession(session);
0096: }
0097: }
0098:
0099: public Layout remove(Layout layout) throws SystemException {
0100: ModelListener listener = _getListener();
0101:
0102: if (listener != null) {
0103: listener.onBeforeRemove(layout);
0104: }
0105:
0106: layout = removeImpl(layout);
0107:
0108: if (listener != null) {
0109: listener.onAfterRemove(layout);
0110: }
0111:
0112: return layout;
0113: }
0114:
0115: protected Layout removeImpl(Layout layout) throws SystemException {
0116: Session session = null;
0117:
0118: try {
0119: session = openSession();
0120:
0121: session.delete(layout);
0122:
0123: session.flush();
0124:
0125: return layout;
0126: } catch (Exception e) {
0127: throw HibernateUtil.processException(e);
0128: } finally {
0129: closeSession(session);
0130:
0131: FinderCache.clearCache(Layout.class.getName());
0132: }
0133: }
0134:
0135: public Layout update(Layout layout) throws SystemException {
0136: return update(layout, false);
0137: }
0138:
0139: public Layout update(Layout layout, boolean merge)
0140: throws SystemException {
0141: ModelListener listener = _getListener();
0142:
0143: boolean isNew = layout.isNew();
0144:
0145: if (listener != null) {
0146: if (isNew) {
0147: listener.onBeforeCreate(layout);
0148: } else {
0149: listener.onBeforeUpdate(layout);
0150: }
0151: }
0152:
0153: layout = updateImpl(layout, merge);
0154:
0155: if (listener != null) {
0156: if (isNew) {
0157: listener.onAfterCreate(layout);
0158: } else {
0159: listener.onAfterUpdate(layout);
0160: }
0161: }
0162:
0163: return layout;
0164: }
0165:
0166: public Layout updateImpl(com.liferay.portal.model.Layout layout,
0167: boolean merge) throws SystemException {
0168: Session session = null;
0169:
0170: try {
0171: session = openSession();
0172:
0173: if (merge) {
0174: session.merge(layout);
0175: } else {
0176: if (layout.isNew()) {
0177: session.save(layout);
0178: }
0179: }
0180:
0181: session.flush();
0182:
0183: layout.setNew(false);
0184:
0185: return layout;
0186: } catch (Exception e) {
0187: throw HibernateUtil.processException(e);
0188: } finally {
0189: closeSession(session);
0190:
0191: FinderCache.clearCache(Layout.class.getName());
0192: }
0193: }
0194:
0195: public Layout findByPrimaryKey(long plid)
0196: throws NoSuchLayoutException, SystemException {
0197: Layout layout = fetchByPrimaryKey(plid);
0198:
0199: if (layout == null) {
0200: if (_log.isWarnEnabled()) {
0201: _log.warn("No Layout exists with the primary key "
0202: + plid);
0203: }
0204:
0205: throw new NoSuchLayoutException(
0206: "No Layout exists with the primary key " + plid);
0207: }
0208:
0209: return layout;
0210: }
0211:
0212: public Layout fetchByPrimaryKey(long plid) throws SystemException {
0213: Session session = null;
0214:
0215: try {
0216: session = openSession();
0217:
0218: return (Layout) session.get(LayoutImpl.class,
0219: new Long(plid));
0220: } catch (Exception e) {
0221: throw HibernateUtil.processException(e);
0222: } finally {
0223: closeSession(session);
0224: }
0225: }
0226:
0227: public List findByGroupId(long groupId) throws SystemException {
0228: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0229: String finderClassName = Layout.class.getName();
0230: String finderMethodName = "findByGroupId";
0231: String[] finderParams = new String[] { Long.class.getName() };
0232: Object[] finderArgs = new Object[] { new Long(groupId) };
0233:
0234: Object result = null;
0235:
0236: if (finderClassNameCacheEnabled) {
0237: result = FinderCache.getResult(finderClassName,
0238: finderMethodName, finderParams, finderArgs,
0239: getSessionFactory());
0240: }
0241:
0242: if (result == null) {
0243: Session session = null;
0244:
0245: try {
0246: session = openSession();
0247:
0248: StringMaker query = new StringMaker();
0249:
0250: query
0251: .append("FROM com.liferay.portal.model.Layout WHERE ");
0252:
0253: query.append("groupId = ?");
0254:
0255: query.append(" ");
0256:
0257: query.append("ORDER BY ");
0258:
0259: query.append("parentLayoutId ASC, ");
0260: query.append("priority ASC");
0261:
0262: Query q = session.createQuery(query.toString());
0263:
0264: int queryPos = 0;
0265:
0266: q.setLong(queryPos++, groupId);
0267:
0268: List list = q.list();
0269:
0270: FinderCache.putResult(finderClassNameCacheEnabled,
0271: finderClassName, finderMethodName,
0272: finderParams, finderArgs, list);
0273:
0274: return list;
0275: } catch (Exception e) {
0276: throw HibernateUtil.processException(e);
0277: } finally {
0278: closeSession(session);
0279: }
0280: } else {
0281: return (List) result;
0282: }
0283: }
0284:
0285: public List findByGroupId(long groupId, int begin, int end)
0286: throws SystemException {
0287: return findByGroupId(groupId, begin, end, null);
0288: }
0289:
0290: public List findByGroupId(long groupId, int begin, int end,
0291: OrderByComparator obc) throws SystemException {
0292: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0293: String finderClassName = Layout.class.getName();
0294: String finderMethodName = "findByGroupId";
0295: String[] finderParams = new String[] { Long.class.getName(),
0296:
0297: "java.lang.Integer", "java.lang.Integer",
0298: "com.liferay.portal.kernel.util.OrderByComparator" };
0299: Object[] finderArgs = new Object[] { new Long(groupId),
0300:
0301: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0302:
0303: Object result = null;
0304:
0305: if (finderClassNameCacheEnabled) {
0306: result = FinderCache.getResult(finderClassName,
0307: finderMethodName, finderParams, finderArgs,
0308: getSessionFactory());
0309: }
0310:
0311: if (result == null) {
0312: Session session = null;
0313:
0314: try {
0315: session = openSession();
0316:
0317: StringMaker query = new StringMaker();
0318:
0319: query
0320: .append("FROM com.liferay.portal.model.Layout WHERE ");
0321:
0322: query.append("groupId = ?");
0323:
0324: query.append(" ");
0325:
0326: if (obc != null) {
0327: query.append("ORDER BY ");
0328: query.append(obc.getOrderBy());
0329: }
0330:
0331: else {
0332: query.append("ORDER BY ");
0333:
0334: query.append("parentLayoutId ASC, ");
0335: query.append("priority ASC");
0336: }
0337:
0338: Query q = session.createQuery(query.toString());
0339:
0340: int queryPos = 0;
0341:
0342: q.setLong(queryPos++, groupId);
0343:
0344: List list = QueryUtil.list(q, getDialect(), begin, end);
0345:
0346: FinderCache.putResult(finderClassNameCacheEnabled,
0347: finderClassName, finderMethodName,
0348: finderParams, finderArgs, list);
0349:
0350: return list;
0351: } catch (Exception e) {
0352: throw HibernateUtil.processException(e);
0353: } finally {
0354: closeSession(session);
0355: }
0356: } else {
0357: return (List) result;
0358: }
0359: }
0360:
0361: public Layout findByGroupId_First(long groupId,
0362: OrderByComparator obc) throws NoSuchLayoutException,
0363: SystemException {
0364: List list = findByGroupId(groupId, 0, 1, obc);
0365:
0366: if (list.size() == 0) {
0367: StringMaker msg = new StringMaker();
0368:
0369: msg.append("No Layout exists with the key {");
0370:
0371: msg.append("groupId=" + groupId);
0372:
0373: msg.append(StringPool.CLOSE_CURLY_BRACE);
0374:
0375: throw new NoSuchLayoutException(msg.toString());
0376: } else {
0377: return (Layout) list.get(0);
0378: }
0379: }
0380:
0381: public Layout findByGroupId_Last(long groupId, OrderByComparator obc)
0382: throws NoSuchLayoutException, SystemException {
0383: int count = countByGroupId(groupId);
0384:
0385: List list = findByGroupId(groupId, count - 1, count, obc);
0386:
0387: if (list.size() == 0) {
0388: StringMaker msg = new StringMaker();
0389:
0390: msg.append("No Layout exists with the key {");
0391:
0392: msg.append("groupId=" + groupId);
0393:
0394: msg.append(StringPool.CLOSE_CURLY_BRACE);
0395:
0396: throw new NoSuchLayoutException(msg.toString());
0397: } else {
0398: return (Layout) list.get(0);
0399: }
0400: }
0401:
0402: public Layout[] findByGroupId_PrevAndNext(long plid, long groupId,
0403: OrderByComparator obc) throws NoSuchLayoutException,
0404: SystemException {
0405: Layout layout = findByPrimaryKey(plid);
0406:
0407: int count = countByGroupId(groupId);
0408:
0409: Session session = null;
0410:
0411: try {
0412: session = openSession();
0413:
0414: StringMaker query = new StringMaker();
0415:
0416: query.append("FROM com.liferay.portal.model.Layout WHERE ");
0417:
0418: query.append("groupId = ?");
0419:
0420: query.append(" ");
0421:
0422: if (obc != null) {
0423: query.append("ORDER BY ");
0424: query.append(obc.getOrderBy());
0425: }
0426:
0427: else {
0428: query.append("ORDER BY ");
0429:
0430: query.append("parentLayoutId ASC, ");
0431: query.append("priority ASC");
0432: }
0433:
0434: Query q = session.createQuery(query.toString());
0435:
0436: int queryPos = 0;
0437:
0438: q.setLong(queryPos++, groupId);
0439:
0440: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0441: layout);
0442:
0443: Layout[] array = new LayoutImpl[3];
0444:
0445: array[0] = (Layout) objArray[0];
0446: array[1] = (Layout) objArray[1];
0447: array[2] = (Layout) objArray[2];
0448:
0449: return array;
0450: } catch (Exception e) {
0451: throw HibernateUtil.processException(e);
0452: } finally {
0453: closeSession(session);
0454: }
0455: }
0456:
0457: public List findByCompanyId(long companyId) throws SystemException {
0458: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0459: String finderClassName = Layout.class.getName();
0460: String finderMethodName = "findByCompanyId";
0461: String[] finderParams = new String[] { Long.class.getName() };
0462: Object[] finderArgs = new Object[] { new Long(companyId) };
0463:
0464: Object result = null;
0465:
0466: if (finderClassNameCacheEnabled) {
0467: result = FinderCache.getResult(finderClassName,
0468: finderMethodName, finderParams, finderArgs,
0469: getSessionFactory());
0470: }
0471:
0472: if (result == null) {
0473: Session session = null;
0474:
0475: try {
0476: session = openSession();
0477:
0478: StringMaker query = new StringMaker();
0479:
0480: query
0481: .append("FROM com.liferay.portal.model.Layout WHERE ");
0482:
0483: query.append("companyId = ?");
0484:
0485: query.append(" ");
0486:
0487: query.append("ORDER BY ");
0488:
0489: query.append("parentLayoutId ASC, ");
0490: query.append("priority ASC");
0491:
0492: Query q = session.createQuery(query.toString());
0493:
0494: int queryPos = 0;
0495:
0496: q.setLong(queryPos++, companyId);
0497:
0498: List list = q.list();
0499:
0500: FinderCache.putResult(finderClassNameCacheEnabled,
0501: finderClassName, finderMethodName,
0502: finderParams, finderArgs, list);
0503:
0504: return list;
0505: } catch (Exception e) {
0506: throw HibernateUtil.processException(e);
0507: } finally {
0508: closeSession(session);
0509: }
0510: } else {
0511: return (List) result;
0512: }
0513: }
0514:
0515: public List findByCompanyId(long companyId, int begin, int end)
0516: throws SystemException {
0517: return findByCompanyId(companyId, begin, end, null);
0518: }
0519:
0520: public List findByCompanyId(long companyId, int begin, int end,
0521: OrderByComparator obc) throws SystemException {
0522: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0523: String finderClassName = Layout.class.getName();
0524: String finderMethodName = "findByCompanyId";
0525: String[] finderParams = new String[] { Long.class.getName(),
0526:
0527: "java.lang.Integer", "java.lang.Integer",
0528: "com.liferay.portal.kernel.util.OrderByComparator" };
0529: Object[] finderArgs = new Object[] { new Long(companyId),
0530:
0531: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0532:
0533: Object result = null;
0534:
0535: if (finderClassNameCacheEnabled) {
0536: result = FinderCache.getResult(finderClassName,
0537: finderMethodName, finderParams, finderArgs,
0538: getSessionFactory());
0539: }
0540:
0541: if (result == null) {
0542: Session session = null;
0543:
0544: try {
0545: session = openSession();
0546:
0547: StringMaker query = new StringMaker();
0548:
0549: query
0550: .append("FROM com.liferay.portal.model.Layout WHERE ");
0551:
0552: query.append("companyId = ?");
0553:
0554: query.append(" ");
0555:
0556: if (obc != null) {
0557: query.append("ORDER BY ");
0558: query.append(obc.getOrderBy());
0559: }
0560:
0561: else {
0562: query.append("ORDER BY ");
0563:
0564: query.append("parentLayoutId ASC, ");
0565: query.append("priority ASC");
0566: }
0567:
0568: Query q = session.createQuery(query.toString());
0569:
0570: int queryPos = 0;
0571:
0572: q.setLong(queryPos++, companyId);
0573:
0574: List list = QueryUtil.list(q, getDialect(), begin, end);
0575:
0576: FinderCache.putResult(finderClassNameCacheEnabled,
0577: finderClassName, finderMethodName,
0578: finderParams, finderArgs, list);
0579:
0580: return list;
0581: } catch (Exception e) {
0582: throw HibernateUtil.processException(e);
0583: } finally {
0584: closeSession(session);
0585: }
0586: } else {
0587: return (List) result;
0588: }
0589: }
0590:
0591: public Layout findByCompanyId_First(long companyId,
0592: OrderByComparator obc) throws NoSuchLayoutException,
0593: SystemException {
0594: List list = findByCompanyId(companyId, 0, 1, obc);
0595:
0596: if (list.size() == 0) {
0597: StringMaker msg = new StringMaker();
0598:
0599: msg.append("No Layout exists with the key {");
0600:
0601: msg.append("companyId=" + companyId);
0602:
0603: msg.append(StringPool.CLOSE_CURLY_BRACE);
0604:
0605: throw new NoSuchLayoutException(msg.toString());
0606: } else {
0607: return (Layout) list.get(0);
0608: }
0609: }
0610:
0611: public Layout findByCompanyId_Last(long companyId,
0612: OrderByComparator obc) throws NoSuchLayoutException,
0613: SystemException {
0614: int count = countByCompanyId(companyId);
0615:
0616: List list = findByCompanyId(companyId, count - 1, count, obc);
0617:
0618: if (list.size() == 0) {
0619: StringMaker msg = new StringMaker();
0620:
0621: msg.append("No Layout exists with the key {");
0622:
0623: msg.append("companyId=" + companyId);
0624:
0625: msg.append(StringPool.CLOSE_CURLY_BRACE);
0626:
0627: throw new NoSuchLayoutException(msg.toString());
0628: } else {
0629: return (Layout) list.get(0);
0630: }
0631: }
0632:
0633: public Layout[] findByCompanyId_PrevAndNext(long plid,
0634: long companyId, OrderByComparator obc)
0635: throws NoSuchLayoutException, SystemException {
0636: Layout layout = findByPrimaryKey(plid);
0637:
0638: int count = countByCompanyId(companyId);
0639:
0640: Session session = null;
0641:
0642: try {
0643: session = openSession();
0644:
0645: StringMaker query = new StringMaker();
0646:
0647: query.append("FROM com.liferay.portal.model.Layout WHERE ");
0648:
0649: query.append("companyId = ?");
0650:
0651: query.append(" ");
0652:
0653: if (obc != null) {
0654: query.append("ORDER BY ");
0655: query.append(obc.getOrderBy());
0656: }
0657:
0658: else {
0659: query.append("ORDER BY ");
0660:
0661: query.append("parentLayoutId ASC, ");
0662: query.append("priority ASC");
0663: }
0664:
0665: Query q = session.createQuery(query.toString());
0666:
0667: int queryPos = 0;
0668:
0669: q.setLong(queryPos++, companyId);
0670:
0671: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0672: layout);
0673:
0674: Layout[] array = new LayoutImpl[3];
0675:
0676: array[0] = (Layout) objArray[0];
0677: array[1] = (Layout) objArray[1];
0678: array[2] = (Layout) objArray[2];
0679:
0680: return array;
0681: } catch (Exception e) {
0682: throw HibernateUtil.processException(e);
0683: } finally {
0684: closeSession(session);
0685: }
0686: }
0687:
0688: public Layout findByDLFolderId(long dlFolderId)
0689: throws NoSuchLayoutException, SystemException {
0690: Layout layout = fetchByDLFolderId(dlFolderId);
0691:
0692: if (layout == null) {
0693: StringMaker msg = new StringMaker();
0694:
0695: msg.append("No Layout exists with the key {");
0696:
0697: msg.append("dlFolderId=" + dlFolderId);
0698:
0699: msg.append(StringPool.CLOSE_CURLY_BRACE);
0700:
0701: if (_log.isWarnEnabled()) {
0702: _log.warn(msg.toString());
0703: }
0704:
0705: throw new NoSuchLayoutException(msg.toString());
0706: }
0707:
0708: return layout;
0709: }
0710:
0711: public Layout fetchByDLFolderId(long dlFolderId)
0712: throws SystemException {
0713: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0714: String finderClassName = Layout.class.getName();
0715: String finderMethodName = "fetchByDLFolderId";
0716: String[] finderParams = new String[] { Long.class.getName() };
0717: Object[] finderArgs = new Object[] { new Long(dlFolderId) };
0718:
0719: Object result = null;
0720:
0721: if (finderClassNameCacheEnabled) {
0722: result = FinderCache.getResult(finderClassName,
0723: finderMethodName, finderParams, finderArgs,
0724: getSessionFactory());
0725: }
0726:
0727: if (result == null) {
0728: Session session = null;
0729:
0730: try {
0731: session = openSession();
0732:
0733: StringMaker query = new StringMaker();
0734:
0735: query
0736: .append("FROM com.liferay.portal.model.Layout WHERE ");
0737:
0738: query.append("dlFolderId = ?");
0739:
0740: query.append(" ");
0741:
0742: query.append("ORDER BY ");
0743:
0744: query.append("parentLayoutId ASC, ");
0745: query.append("priority ASC");
0746:
0747: Query q = session.createQuery(query.toString());
0748:
0749: int queryPos = 0;
0750:
0751: q.setLong(queryPos++, dlFolderId);
0752:
0753: List list = q.list();
0754:
0755: FinderCache.putResult(finderClassNameCacheEnabled,
0756: finderClassName, finderMethodName,
0757: finderParams, finderArgs, list);
0758:
0759: if (list.size() == 0) {
0760: return null;
0761: } else {
0762: return (Layout) list.get(0);
0763: }
0764: } catch (Exception e) {
0765: throw HibernateUtil.processException(e);
0766: } finally {
0767: closeSession(session);
0768: }
0769: } else {
0770: List list = (List) result;
0771:
0772: if (list.size() == 0) {
0773: return null;
0774: } else {
0775: return (Layout) list.get(0);
0776: }
0777: }
0778: }
0779:
0780: public Layout findByIconImageId(long iconImageId)
0781: throws NoSuchLayoutException, SystemException {
0782: Layout layout = fetchByIconImageId(iconImageId);
0783:
0784: if (layout == null) {
0785: StringMaker msg = new StringMaker();
0786:
0787: msg.append("No Layout exists with the key {");
0788:
0789: msg.append("iconImageId=" + iconImageId);
0790:
0791: msg.append(StringPool.CLOSE_CURLY_BRACE);
0792:
0793: if (_log.isWarnEnabled()) {
0794: _log.warn(msg.toString());
0795: }
0796:
0797: throw new NoSuchLayoutException(msg.toString());
0798: }
0799:
0800: return layout;
0801: }
0802:
0803: public Layout fetchByIconImageId(long iconImageId)
0804: throws SystemException {
0805: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0806: String finderClassName = Layout.class.getName();
0807: String finderMethodName = "fetchByIconImageId";
0808: String[] finderParams = new String[] { Long.class.getName() };
0809: Object[] finderArgs = new Object[] { new Long(iconImageId) };
0810:
0811: Object result = null;
0812:
0813: if (finderClassNameCacheEnabled) {
0814: result = FinderCache.getResult(finderClassName,
0815: finderMethodName, finderParams, finderArgs,
0816: getSessionFactory());
0817: }
0818:
0819: if (result == null) {
0820: Session session = null;
0821:
0822: try {
0823: session = openSession();
0824:
0825: StringMaker query = new StringMaker();
0826:
0827: query
0828: .append("FROM com.liferay.portal.model.Layout WHERE ");
0829:
0830: query.append("iconImageId = ?");
0831:
0832: query.append(" ");
0833:
0834: query.append("ORDER BY ");
0835:
0836: query.append("parentLayoutId ASC, ");
0837: query.append("priority ASC");
0838:
0839: Query q = session.createQuery(query.toString());
0840:
0841: int queryPos = 0;
0842:
0843: q.setLong(queryPos++, iconImageId);
0844:
0845: List list = q.list();
0846:
0847: FinderCache.putResult(finderClassNameCacheEnabled,
0848: finderClassName, finderMethodName,
0849: finderParams, finderArgs, list);
0850:
0851: if (list.size() == 0) {
0852: return null;
0853: } else {
0854: return (Layout) list.get(0);
0855: }
0856: } catch (Exception e) {
0857: throw HibernateUtil.processException(e);
0858: } finally {
0859: closeSession(session);
0860: }
0861: } else {
0862: List list = (List) result;
0863:
0864: if (list.size() == 0) {
0865: return null;
0866: } else {
0867: return (Layout) list.get(0);
0868: }
0869: }
0870: }
0871:
0872: public List findByG_P(long groupId, boolean privateLayout)
0873: throws SystemException {
0874: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0875: String finderClassName = Layout.class.getName();
0876: String finderMethodName = "findByG_P";
0877: String[] finderParams = new String[] { Long.class.getName(),
0878: Boolean.class.getName() };
0879: Object[] finderArgs = new Object[] { new Long(groupId),
0880: Boolean.valueOf(privateLayout) };
0881:
0882: Object result = null;
0883:
0884: if (finderClassNameCacheEnabled) {
0885: result = FinderCache.getResult(finderClassName,
0886: finderMethodName, finderParams, finderArgs,
0887: getSessionFactory());
0888: }
0889:
0890: if (result == null) {
0891: Session session = null;
0892:
0893: try {
0894: session = openSession();
0895:
0896: StringMaker query = new StringMaker();
0897:
0898: query
0899: .append("FROM com.liferay.portal.model.Layout WHERE ");
0900:
0901: query.append("groupId = ?");
0902:
0903: query.append(" AND ");
0904:
0905: query.append("privateLayout = ?");
0906:
0907: query.append(" ");
0908:
0909: query.append("ORDER BY ");
0910:
0911: query.append("parentLayoutId ASC, ");
0912: query.append("priority ASC");
0913:
0914: Query q = session.createQuery(query.toString());
0915:
0916: int queryPos = 0;
0917:
0918: q.setLong(queryPos++, groupId);
0919:
0920: q.setBoolean(queryPos++, privateLayout);
0921:
0922: List list = q.list();
0923:
0924: FinderCache.putResult(finderClassNameCacheEnabled,
0925: finderClassName, finderMethodName,
0926: finderParams, finderArgs, list);
0927:
0928: return list;
0929: } catch (Exception e) {
0930: throw HibernateUtil.processException(e);
0931: } finally {
0932: closeSession(session);
0933: }
0934: } else {
0935: return (List) result;
0936: }
0937: }
0938:
0939: public List findByG_P(long groupId, boolean privateLayout,
0940: int begin, int end) throws SystemException {
0941: return findByG_P(groupId, privateLayout, begin, end, null);
0942: }
0943:
0944: public List findByG_P(long groupId, boolean privateLayout,
0945: int begin, int end, OrderByComparator obc)
0946: throws SystemException {
0947: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
0948: String finderClassName = Layout.class.getName();
0949: String finderMethodName = "findByG_P";
0950: String[] finderParams = new String[] { Long.class.getName(),
0951: Boolean.class.getName(),
0952:
0953: "java.lang.Integer", "java.lang.Integer",
0954: "com.liferay.portal.kernel.util.OrderByComparator" };
0955: Object[] finderArgs = new Object[] { new Long(groupId),
0956: Boolean.valueOf(privateLayout),
0957:
0958: String.valueOf(begin), String.valueOf(end),
0959: String.valueOf(obc) };
0960:
0961: Object result = null;
0962:
0963: if (finderClassNameCacheEnabled) {
0964: result = FinderCache.getResult(finderClassName,
0965: finderMethodName, finderParams, finderArgs,
0966: getSessionFactory());
0967: }
0968:
0969: if (result == null) {
0970: Session session = null;
0971:
0972: try {
0973: session = openSession();
0974:
0975: StringMaker query = new StringMaker();
0976:
0977: query
0978: .append("FROM com.liferay.portal.model.Layout WHERE ");
0979:
0980: query.append("groupId = ?");
0981:
0982: query.append(" AND ");
0983:
0984: query.append("privateLayout = ?");
0985:
0986: query.append(" ");
0987:
0988: if (obc != null) {
0989: query.append("ORDER BY ");
0990: query.append(obc.getOrderBy());
0991: }
0992:
0993: else {
0994: query.append("ORDER BY ");
0995:
0996: query.append("parentLayoutId ASC, ");
0997: query.append("priority ASC");
0998: }
0999:
1000: Query q = session.createQuery(query.toString());
1001:
1002: int queryPos = 0;
1003:
1004: q.setLong(queryPos++, groupId);
1005:
1006: q.setBoolean(queryPos++, privateLayout);
1007:
1008: List list = QueryUtil.list(q, getDialect(), begin, end);
1009:
1010: FinderCache.putResult(finderClassNameCacheEnabled,
1011: finderClassName, finderMethodName,
1012: finderParams, finderArgs, list);
1013:
1014: return list;
1015: } catch (Exception e) {
1016: throw HibernateUtil.processException(e);
1017: } finally {
1018: closeSession(session);
1019: }
1020: } else {
1021: return (List) result;
1022: }
1023: }
1024:
1025: public Layout findByG_P_First(long groupId, boolean privateLayout,
1026: OrderByComparator obc) throws NoSuchLayoutException,
1027: SystemException {
1028: List list = findByG_P(groupId, privateLayout, 0, 1, obc);
1029:
1030: if (list.size() == 0) {
1031: StringMaker msg = new StringMaker();
1032:
1033: msg.append("No Layout exists with the key {");
1034:
1035: msg.append("groupId=" + groupId);
1036:
1037: msg.append(", ");
1038: msg.append("privateLayout=" + privateLayout);
1039:
1040: msg.append(StringPool.CLOSE_CURLY_BRACE);
1041:
1042: throw new NoSuchLayoutException(msg.toString());
1043: } else {
1044: return (Layout) list.get(0);
1045: }
1046: }
1047:
1048: public Layout findByG_P_Last(long groupId, boolean privateLayout,
1049: OrderByComparator obc) throws NoSuchLayoutException,
1050: SystemException {
1051: int count = countByG_P(groupId, privateLayout);
1052:
1053: List list = findByG_P(groupId, privateLayout, count - 1, count,
1054: obc);
1055:
1056: if (list.size() == 0) {
1057: StringMaker msg = new StringMaker();
1058:
1059: msg.append("No Layout exists with the key {");
1060:
1061: msg.append("groupId=" + groupId);
1062:
1063: msg.append(", ");
1064: msg.append("privateLayout=" + privateLayout);
1065:
1066: msg.append(StringPool.CLOSE_CURLY_BRACE);
1067:
1068: throw new NoSuchLayoutException(msg.toString());
1069: } else {
1070: return (Layout) list.get(0);
1071: }
1072: }
1073:
1074: public Layout[] findByG_P_PrevAndNext(long plid, long groupId,
1075: boolean privateLayout, OrderByComparator obc)
1076: throws NoSuchLayoutException, SystemException {
1077: Layout layout = findByPrimaryKey(plid);
1078:
1079: int count = countByG_P(groupId, privateLayout);
1080:
1081: Session session = null;
1082:
1083: try {
1084: session = openSession();
1085:
1086: StringMaker query = new StringMaker();
1087:
1088: query.append("FROM com.liferay.portal.model.Layout WHERE ");
1089:
1090: query.append("groupId = ?");
1091:
1092: query.append(" AND ");
1093:
1094: query.append("privateLayout = ?");
1095:
1096: query.append(" ");
1097:
1098: if (obc != null) {
1099: query.append("ORDER BY ");
1100: query.append(obc.getOrderBy());
1101: }
1102:
1103: else {
1104: query.append("ORDER BY ");
1105:
1106: query.append("parentLayoutId ASC, ");
1107: query.append("priority ASC");
1108: }
1109:
1110: Query q = session.createQuery(query.toString());
1111:
1112: int queryPos = 0;
1113:
1114: q.setLong(queryPos++, groupId);
1115:
1116: q.setBoolean(queryPos++, privateLayout);
1117:
1118: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1119: layout);
1120:
1121: Layout[] array = new LayoutImpl[3];
1122:
1123: array[0] = (Layout) objArray[0];
1124: array[1] = (Layout) objArray[1];
1125: array[2] = (Layout) objArray[2];
1126:
1127: return array;
1128: } catch (Exception e) {
1129: throw HibernateUtil.processException(e);
1130: } finally {
1131: closeSession(session);
1132: }
1133: }
1134:
1135: public Layout findByG_P_L(long groupId, boolean privateLayout,
1136: long layoutId) throws NoSuchLayoutException,
1137: SystemException {
1138: Layout layout = fetchByG_P_L(groupId, privateLayout, layoutId);
1139:
1140: if (layout == null) {
1141: StringMaker msg = new StringMaker();
1142:
1143: msg.append("No Layout exists with the key {");
1144:
1145: msg.append("groupId=" + groupId);
1146:
1147: msg.append(", ");
1148: msg.append("privateLayout=" + privateLayout);
1149:
1150: msg.append(", ");
1151: msg.append("layoutId=" + layoutId);
1152:
1153: msg.append(StringPool.CLOSE_CURLY_BRACE);
1154:
1155: if (_log.isWarnEnabled()) {
1156: _log.warn(msg.toString());
1157: }
1158:
1159: throw new NoSuchLayoutException(msg.toString());
1160: }
1161:
1162: return layout;
1163: }
1164:
1165: public Layout fetchByG_P_L(long groupId, boolean privateLayout,
1166: long layoutId) throws SystemException {
1167: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1168: String finderClassName = Layout.class.getName();
1169: String finderMethodName = "fetchByG_P_L";
1170: String[] finderParams = new String[] { Long.class.getName(),
1171: Boolean.class.getName(), Long.class.getName() };
1172: Object[] finderArgs = new Object[] { new Long(groupId),
1173: Boolean.valueOf(privateLayout), new Long(layoutId) };
1174:
1175: Object result = null;
1176:
1177: if (finderClassNameCacheEnabled) {
1178: result = FinderCache.getResult(finderClassName,
1179: finderMethodName, finderParams, finderArgs,
1180: getSessionFactory());
1181: }
1182:
1183: if (result == null) {
1184: Session session = null;
1185:
1186: try {
1187: session = openSession();
1188:
1189: StringMaker query = new StringMaker();
1190:
1191: query
1192: .append("FROM com.liferay.portal.model.Layout WHERE ");
1193:
1194: query.append("groupId = ?");
1195:
1196: query.append(" AND ");
1197:
1198: query.append("privateLayout = ?");
1199:
1200: query.append(" AND ");
1201:
1202: query.append("layoutId = ?");
1203:
1204: query.append(" ");
1205:
1206: query.append("ORDER BY ");
1207:
1208: query.append("parentLayoutId ASC, ");
1209: query.append("priority ASC");
1210:
1211: Query q = session.createQuery(query.toString());
1212:
1213: int queryPos = 0;
1214:
1215: q.setLong(queryPos++, groupId);
1216:
1217: q.setBoolean(queryPos++, privateLayout);
1218:
1219: q.setLong(queryPos++, layoutId);
1220:
1221: List list = q.list();
1222:
1223: FinderCache.putResult(finderClassNameCacheEnabled,
1224: finderClassName, finderMethodName,
1225: finderParams, finderArgs, list);
1226:
1227: if (list.size() == 0) {
1228: return null;
1229: } else {
1230: return (Layout) list.get(0);
1231: }
1232: } catch (Exception e) {
1233: throw HibernateUtil.processException(e);
1234: } finally {
1235: closeSession(session);
1236: }
1237: } else {
1238: List list = (List) result;
1239:
1240: if (list.size() == 0) {
1241: return null;
1242: } else {
1243: return (Layout) list.get(0);
1244: }
1245: }
1246: }
1247:
1248: public List findByG_P_P(long groupId, boolean privateLayout,
1249: long parentLayoutId) throws SystemException {
1250: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1251: String finderClassName = Layout.class.getName();
1252: String finderMethodName = "findByG_P_P";
1253: String[] finderParams = new String[] { Long.class.getName(),
1254: Boolean.class.getName(), Long.class.getName() };
1255: Object[] finderArgs = new Object[] { new Long(groupId),
1256: Boolean.valueOf(privateLayout),
1257: new Long(parentLayoutId) };
1258:
1259: Object result = null;
1260:
1261: if (finderClassNameCacheEnabled) {
1262: result = FinderCache.getResult(finderClassName,
1263: finderMethodName, finderParams, finderArgs,
1264: getSessionFactory());
1265: }
1266:
1267: if (result == null) {
1268: Session session = null;
1269:
1270: try {
1271: session = openSession();
1272:
1273: StringMaker query = new StringMaker();
1274:
1275: query
1276: .append("FROM com.liferay.portal.model.Layout WHERE ");
1277:
1278: query.append("groupId = ?");
1279:
1280: query.append(" AND ");
1281:
1282: query.append("privateLayout = ?");
1283:
1284: query.append(" AND ");
1285:
1286: query.append("parentLayoutId = ?");
1287:
1288: query.append(" ");
1289:
1290: query.append("ORDER BY ");
1291:
1292: query.append("parentLayoutId ASC, ");
1293: query.append("priority ASC");
1294:
1295: Query q = session.createQuery(query.toString());
1296:
1297: int queryPos = 0;
1298:
1299: q.setLong(queryPos++, groupId);
1300:
1301: q.setBoolean(queryPos++, privateLayout);
1302:
1303: q.setLong(queryPos++, parentLayoutId);
1304:
1305: List list = q.list();
1306:
1307: FinderCache.putResult(finderClassNameCacheEnabled,
1308: finderClassName, finderMethodName,
1309: finderParams, finderArgs, list);
1310:
1311: return list;
1312: } catch (Exception e) {
1313: throw HibernateUtil.processException(e);
1314: } finally {
1315: closeSession(session);
1316: }
1317: } else {
1318: return (List) result;
1319: }
1320: }
1321:
1322: public List findByG_P_P(long groupId, boolean privateLayout,
1323: long parentLayoutId, int begin, int end)
1324: throws SystemException {
1325: return findByG_P_P(groupId, privateLayout, parentLayoutId,
1326: begin, end, null);
1327: }
1328:
1329: public List findByG_P_P(long groupId, boolean privateLayout,
1330: long parentLayoutId, int begin, int end,
1331: OrderByComparator obc) throws SystemException {
1332: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1333: String finderClassName = Layout.class.getName();
1334: String finderMethodName = "findByG_P_P";
1335: String[] finderParams = new String[] { Long.class.getName(),
1336: Boolean.class.getName(), Long.class.getName(),
1337:
1338: "java.lang.Integer", "java.lang.Integer",
1339: "com.liferay.portal.kernel.util.OrderByComparator" };
1340: Object[] finderArgs = new Object[] { new Long(groupId),
1341: Boolean.valueOf(privateLayout),
1342: new Long(parentLayoutId),
1343:
1344: String.valueOf(begin), String.valueOf(end),
1345: String.valueOf(obc) };
1346:
1347: Object result = null;
1348:
1349: if (finderClassNameCacheEnabled) {
1350: result = FinderCache.getResult(finderClassName,
1351: finderMethodName, finderParams, finderArgs,
1352: getSessionFactory());
1353: }
1354:
1355: if (result == null) {
1356: Session session = null;
1357:
1358: try {
1359: session = openSession();
1360:
1361: StringMaker query = new StringMaker();
1362:
1363: query
1364: .append("FROM com.liferay.portal.model.Layout WHERE ");
1365:
1366: query.append("groupId = ?");
1367:
1368: query.append(" AND ");
1369:
1370: query.append("privateLayout = ?");
1371:
1372: query.append(" AND ");
1373:
1374: query.append("parentLayoutId = ?");
1375:
1376: query.append(" ");
1377:
1378: if (obc != null) {
1379: query.append("ORDER BY ");
1380: query.append(obc.getOrderBy());
1381: }
1382:
1383: else {
1384: query.append("ORDER BY ");
1385:
1386: query.append("parentLayoutId ASC, ");
1387: query.append("priority ASC");
1388: }
1389:
1390: Query q = session.createQuery(query.toString());
1391:
1392: int queryPos = 0;
1393:
1394: q.setLong(queryPos++, groupId);
1395:
1396: q.setBoolean(queryPos++, privateLayout);
1397:
1398: q.setLong(queryPos++, parentLayoutId);
1399:
1400: List list = QueryUtil.list(q, getDialect(), begin, end);
1401:
1402: FinderCache.putResult(finderClassNameCacheEnabled,
1403: finderClassName, finderMethodName,
1404: finderParams, finderArgs, list);
1405:
1406: return list;
1407: } catch (Exception e) {
1408: throw HibernateUtil.processException(e);
1409: } finally {
1410: closeSession(session);
1411: }
1412: } else {
1413: return (List) result;
1414: }
1415: }
1416:
1417: public Layout findByG_P_P_First(long groupId,
1418: boolean privateLayout, long parentLayoutId,
1419: OrderByComparator obc) throws NoSuchLayoutException,
1420: SystemException {
1421: List list = findByG_P_P(groupId, privateLayout, parentLayoutId,
1422: 0, 1, obc);
1423:
1424: if (list.size() == 0) {
1425: StringMaker msg = new StringMaker();
1426:
1427: msg.append("No Layout exists with the key {");
1428:
1429: msg.append("groupId=" + groupId);
1430:
1431: msg.append(", ");
1432: msg.append("privateLayout=" + privateLayout);
1433:
1434: msg.append(", ");
1435: msg.append("parentLayoutId=" + parentLayoutId);
1436:
1437: msg.append(StringPool.CLOSE_CURLY_BRACE);
1438:
1439: throw new NoSuchLayoutException(msg.toString());
1440: } else {
1441: return (Layout) list.get(0);
1442: }
1443: }
1444:
1445: public Layout findByG_P_P_Last(long groupId, boolean privateLayout,
1446: long parentLayoutId, OrderByComparator obc)
1447: throws NoSuchLayoutException, SystemException {
1448: int count = countByG_P_P(groupId, privateLayout, parentLayoutId);
1449:
1450: List list = findByG_P_P(groupId, privateLayout, parentLayoutId,
1451: count - 1, count, obc);
1452:
1453: if (list.size() == 0) {
1454: StringMaker msg = new StringMaker();
1455:
1456: msg.append("No Layout exists with the key {");
1457:
1458: msg.append("groupId=" + groupId);
1459:
1460: msg.append(", ");
1461: msg.append("privateLayout=" + privateLayout);
1462:
1463: msg.append(", ");
1464: msg.append("parentLayoutId=" + parentLayoutId);
1465:
1466: msg.append(StringPool.CLOSE_CURLY_BRACE);
1467:
1468: throw new NoSuchLayoutException(msg.toString());
1469: } else {
1470: return (Layout) list.get(0);
1471: }
1472: }
1473:
1474: public Layout[] findByG_P_P_PrevAndNext(long plid, long groupId,
1475: boolean privateLayout, long parentLayoutId,
1476: OrderByComparator obc) throws NoSuchLayoutException,
1477: SystemException {
1478: Layout layout = findByPrimaryKey(plid);
1479:
1480: int count = countByG_P_P(groupId, privateLayout, parentLayoutId);
1481:
1482: Session session = null;
1483:
1484: try {
1485: session = openSession();
1486:
1487: StringMaker query = new StringMaker();
1488:
1489: query.append("FROM com.liferay.portal.model.Layout WHERE ");
1490:
1491: query.append("groupId = ?");
1492:
1493: query.append(" AND ");
1494:
1495: query.append("privateLayout = ?");
1496:
1497: query.append(" AND ");
1498:
1499: query.append("parentLayoutId = ?");
1500:
1501: query.append(" ");
1502:
1503: if (obc != null) {
1504: query.append("ORDER BY ");
1505: query.append(obc.getOrderBy());
1506: }
1507:
1508: else {
1509: query.append("ORDER BY ");
1510:
1511: query.append("parentLayoutId ASC, ");
1512: query.append("priority ASC");
1513: }
1514:
1515: Query q = session.createQuery(query.toString());
1516:
1517: int queryPos = 0;
1518:
1519: q.setLong(queryPos++, groupId);
1520:
1521: q.setBoolean(queryPos++, privateLayout);
1522:
1523: q.setLong(queryPos++, parentLayoutId);
1524:
1525: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1526: layout);
1527:
1528: Layout[] array = new LayoutImpl[3];
1529:
1530: array[0] = (Layout) objArray[0];
1531: array[1] = (Layout) objArray[1];
1532: array[2] = (Layout) objArray[2];
1533:
1534: return array;
1535: } catch (Exception e) {
1536: throw HibernateUtil.processException(e);
1537: } finally {
1538: closeSession(session);
1539: }
1540: }
1541:
1542: public Layout findByG_P_F(long groupId, boolean privateLayout,
1543: String friendlyURL) throws NoSuchLayoutException,
1544: SystemException {
1545: Layout layout = fetchByG_P_F(groupId, privateLayout,
1546: friendlyURL);
1547:
1548: if (layout == null) {
1549: StringMaker msg = new StringMaker();
1550:
1551: msg.append("No Layout exists with the key {");
1552:
1553: msg.append("groupId=" + groupId);
1554:
1555: msg.append(", ");
1556: msg.append("privateLayout=" + privateLayout);
1557:
1558: msg.append(", ");
1559: msg.append("friendlyURL=" + friendlyURL);
1560:
1561: msg.append(StringPool.CLOSE_CURLY_BRACE);
1562:
1563: if (_log.isWarnEnabled()) {
1564: _log.warn(msg.toString());
1565: }
1566:
1567: throw new NoSuchLayoutException(msg.toString());
1568: }
1569:
1570: return layout;
1571: }
1572:
1573: public Layout fetchByG_P_F(long groupId, boolean privateLayout,
1574: String friendlyURL) throws SystemException {
1575: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1576: String finderClassName = Layout.class.getName();
1577: String finderMethodName = "fetchByG_P_F";
1578: String[] finderParams = new String[] { Long.class.getName(),
1579: Boolean.class.getName(), String.class.getName() };
1580: Object[] finderArgs = new Object[] { new Long(groupId),
1581: Boolean.valueOf(privateLayout),
1582:
1583: friendlyURL };
1584:
1585: Object result = null;
1586:
1587: if (finderClassNameCacheEnabled) {
1588: result = FinderCache.getResult(finderClassName,
1589: finderMethodName, finderParams, finderArgs,
1590: getSessionFactory());
1591: }
1592:
1593: if (result == null) {
1594: Session session = null;
1595:
1596: try {
1597: session = openSession();
1598:
1599: StringMaker query = new StringMaker();
1600:
1601: query
1602: .append("FROM com.liferay.portal.model.Layout WHERE ");
1603:
1604: query.append("groupId = ?");
1605:
1606: query.append(" AND ");
1607:
1608: query.append("privateLayout = ?");
1609:
1610: query.append(" AND ");
1611:
1612: if (friendlyURL == null) {
1613: query.append("friendlyURL IS NULL");
1614: } else {
1615: query.append("lower(friendlyURL) = ?");
1616: }
1617:
1618: query.append(" ");
1619:
1620: query.append("ORDER BY ");
1621:
1622: query.append("parentLayoutId ASC, ");
1623: query.append("priority ASC");
1624:
1625: Query q = session.createQuery(query.toString());
1626:
1627: int queryPos = 0;
1628:
1629: q.setLong(queryPos++, groupId);
1630:
1631: q.setBoolean(queryPos++, privateLayout);
1632:
1633: if (friendlyURL != null) {
1634: q.setString(queryPos++, friendlyURL);
1635: }
1636:
1637: List list = q.list();
1638:
1639: FinderCache.putResult(finderClassNameCacheEnabled,
1640: finderClassName, finderMethodName,
1641: finderParams, finderArgs, list);
1642:
1643: if (list.size() == 0) {
1644: return null;
1645: } else {
1646: return (Layout) list.get(0);
1647: }
1648: } catch (Exception e) {
1649: throw HibernateUtil.processException(e);
1650: } finally {
1651: closeSession(session);
1652: }
1653: } else {
1654: List list = (List) result;
1655:
1656: if (list.size() == 0) {
1657: return null;
1658: } else {
1659: return (Layout) list.get(0);
1660: }
1661: }
1662: }
1663:
1664: public List findWithDynamicQuery(
1665: DynamicQueryInitializer queryInitializer)
1666: throws SystemException {
1667: Session session = null;
1668:
1669: try {
1670: session = openSession();
1671:
1672: DynamicQuery query = queryInitializer.initialize(session);
1673:
1674: return query.list();
1675: } catch (Exception e) {
1676: throw HibernateUtil.processException(e);
1677: } finally {
1678: closeSession(session);
1679: }
1680: }
1681:
1682: public List findWithDynamicQuery(
1683: DynamicQueryInitializer queryInitializer, int begin, int end)
1684: throws SystemException {
1685: Session session = null;
1686:
1687: try {
1688: session = openSession();
1689:
1690: DynamicQuery query = queryInitializer.initialize(session);
1691:
1692: query.setLimit(begin, end);
1693:
1694: return query.list();
1695: } catch (Exception e) {
1696: throw HibernateUtil.processException(e);
1697: } finally {
1698: closeSession(session);
1699: }
1700: }
1701:
1702: public List findAll() throws SystemException {
1703: return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1704: }
1705:
1706: public List findAll(int begin, int end) throws SystemException {
1707: return findAll(begin, end, null);
1708: }
1709:
1710: public List findAll(int begin, int end, OrderByComparator obc)
1711: throws SystemException {
1712: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1713: String finderClassName = Layout.class.getName();
1714: String finderMethodName = "findAll";
1715: String[] finderParams = new String[] { "java.lang.Integer",
1716: "java.lang.Integer",
1717: "com.liferay.portal.kernel.util.OrderByComparator" };
1718: Object[] finderArgs = new Object[] { String.valueOf(begin),
1719: String.valueOf(end), String.valueOf(obc) };
1720:
1721: Object result = null;
1722:
1723: if (finderClassNameCacheEnabled) {
1724: result = FinderCache.getResult(finderClassName,
1725: finderMethodName, finderParams, finderArgs,
1726: getSessionFactory());
1727: }
1728:
1729: if (result == null) {
1730: Session session = null;
1731:
1732: try {
1733: session = openSession();
1734:
1735: StringMaker query = new StringMaker();
1736:
1737: query.append("FROM com.liferay.portal.model.Layout ");
1738:
1739: if (obc != null) {
1740: query.append("ORDER BY ");
1741: query.append(obc.getOrderBy());
1742: }
1743:
1744: else {
1745: query.append("ORDER BY ");
1746:
1747: query.append("parentLayoutId ASC, ");
1748: query.append("priority ASC");
1749: }
1750:
1751: Query q = session.createQuery(query.toString());
1752:
1753: List list = QueryUtil.list(q, getDialect(), begin, end);
1754:
1755: if (obc == null) {
1756: Collections.sort(list);
1757: }
1758:
1759: FinderCache.putResult(finderClassNameCacheEnabled,
1760: finderClassName, finderMethodName,
1761: finderParams, finderArgs, list);
1762:
1763: return list;
1764: } catch (Exception e) {
1765: throw HibernateUtil.processException(e);
1766: } finally {
1767: closeSession(session);
1768: }
1769: } else {
1770: return (List) result;
1771: }
1772: }
1773:
1774: public void removeByGroupId(long groupId) throws SystemException {
1775: Iterator itr = findByGroupId(groupId).iterator();
1776:
1777: while (itr.hasNext()) {
1778: Layout layout = (Layout) itr.next();
1779:
1780: remove(layout);
1781: }
1782: }
1783:
1784: public void removeByCompanyId(long companyId)
1785: throws SystemException {
1786: Iterator itr = findByCompanyId(companyId).iterator();
1787:
1788: while (itr.hasNext()) {
1789: Layout layout = (Layout) itr.next();
1790:
1791: remove(layout);
1792: }
1793: }
1794:
1795: public void removeByDLFolderId(long dlFolderId)
1796: throws NoSuchLayoutException, SystemException {
1797: Layout layout = findByDLFolderId(dlFolderId);
1798:
1799: remove(layout);
1800: }
1801:
1802: public void removeByIconImageId(long iconImageId)
1803: throws NoSuchLayoutException, SystemException {
1804: Layout layout = findByIconImageId(iconImageId);
1805:
1806: remove(layout);
1807: }
1808:
1809: public void removeByG_P(long groupId, boolean privateLayout)
1810: throws SystemException {
1811: Iterator itr = findByG_P(groupId, privateLayout).iterator();
1812:
1813: while (itr.hasNext()) {
1814: Layout layout = (Layout) itr.next();
1815:
1816: remove(layout);
1817: }
1818: }
1819:
1820: public void removeByG_P_L(long groupId, boolean privateLayout,
1821: long layoutId) throws NoSuchLayoutException,
1822: SystemException {
1823: Layout layout = findByG_P_L(groupId, privateLayout, layoutId);
1824:
1825: remove(layout);
1826: }
1827:
1828: public void removeByG_P_P(long groupId, boolean privateLayout,
1829: long parentLayoutId) throws SystemException {
1830: Iterator itr = findByG_P_P(groupId, privateLayout,
1831: parentLayoutId).iterator();
1832:
1833: while (itr.hasNext()) {
1834: Layout layout = (Layout) itr.next();
1835:
1836: remove(layout);
1837: }
1838: }
1839:
1840: public void removeByG_P_F(long groupId, boolean privateLayout,
1841: String friendlyURL) throws NoSuchLayoutException,
1842: SystemException {
1843: Layout layout = findByG_P_F(groupId, privateLayout, friendlyURL);
1844:
1845: remove(layout);
1846: }
1847:
1848: public void removeAll() throws SystemException {
1849: Iterator itr = findAll().iterator();
1850:
1851: while (itr.hasNext()) {
1852: remove((Layout) itr.next());
1853: }
1854: }
1855:
1856: public int countByGroupId(long groupId) throws SystemException {
1857: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1858: String finderClassName = Layout.class.getName();
1859: String finderMethodName = "countByGroupId";
1860: String[] finderParams = new String[] { Long.class.getName() };
1861: Object[] finderArgs = new Object[] { new Long(groupId) };
1862:
1863: Object result = null;
1864:
1865: if (finderClassNameCacheEnabled) {
1866: result = FinderCache.getResult(finderClassName,
1867: finderMethodName, finderParams, finderArgs,
1868: getSessionFactory());
1869: }
1870:
1871: if (result == null) {
1872: Session session = null;
1873:
1874: try {
1875: session = openSession();
1876:
1877: StringMaker query = new StringMaker();
1878:
1879: query.append("SELECT COUNT(*) ");
1880: query
1881: .append("FROM com.liferay.portal.model.Layout WHERE ");
1882:
1883: query.append("groupId = ?");
1884:
1885: query.append(" ");
1886:
1887: Query q = session.createQuery(query.toString());
1888:
1889: int queryPos = 0;
1890:
1891: q.setLong(queryPos++, groupId);
1892:
1893: Long count = null;
1894:
1895: Iterator itr = q.list().iterator();
1896:
1897: if (itr.hasNext()) {
1898: count = (Long) itr.next();
1899: }
1900:
1901: if (count == null) {
1902: count = new Long(0);
1903: }
1904:
1905: FinderCache.putResult(finderClassNameCacheEnabled,
1906: finderClassName, finderMethodName,
1907: finderParams, finderArgs, count);
1908:
1909: return count.intValue();
1910: } catch (Exception e) {
1911: throw HibernateUtil.processException(e);
1912: } finally {
1913: closeSession(session);
1914: }
1915: } else {
1916: return ((Long) result).intValue();
1917: }
1918: }
1919:
1920: public int countByCompanyId(long companyId) throws SystemException {
1921: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1922: String finderClassName = Layout.class.getName();
1923: String finderMethodName = "countByCompanyId";
1924: String[] finderParams = new String[] { Long.class.getName() };
1925: Object[] finderArgs = new Object[] { new Long(companyId) };
1926:
1927: Object result = null;
1928:
1929: if (finderClassNameCacheEnabled) {
1930: result = FinderCache.getResult(finderClassName,
1931: finderMethodName, finderParams, finderArgs,
1932: getSessionFactory());
1933: }
1934:
1935: if (result == null) {
1936: Session session = null;
1937:
1938: try {
1939: session = openSession();
1940:
1941: StringMaker query = new StringMaker();
1942:
1943: query.append("SELECT COUNT(*) ");
1944: query
1945: .append("FROM com.liferay.portal.model.Layout WHERE ");
1946:
1947: query.append("companyId = ?");
1948:
1949: query.append(" ");
1950:
1951: Query q = session.createQuery(query.toString());
1952:
1953: int queryPos = 0;
1954:
1955: q.setLong(queryPos++, companyId);
1956:
1957: Long count = null;
1958:
1959: Iterator itr = q.list().iterator();
1960:
1961: if (itr.hasNext()) {
1962: count = (Long) itr.next();
1963: }
1964:
1965: if (count == null) {
1966: count = new Long(0);
1967: }
1968:
1969: FinderCache.putResult(finderClassNameCacheEnabled,
1970: finderClassName, finderMethodName,
1971: finderParams, finderArgs, count);
1972:
1973: return count.intValue();
1974: } catch (Exception e) {
1975: throw HibernateUtil.processException(e);
1976: } finally {
1977: closeSession(session);
1978: }
1979: } else {
1980: return ((Long) result).intValue();
1981: }
1982: }
1983:
1984: public int countByDLFolderId(long dlFolderId)
1985: throws SystemException {
1986: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
1987: String finderClassName = Layout.class.getName();
1988: String finderMethodName = "countByDLFolderId";
1989: String[] finderParams = new String[] { Long.class.getName() };
1990: Object[] finderArgs = new Object[] { new Long(dlFolderId) };
1991:
1992: Object result = null;
1993:
1994: if (finderClassNameCacheEnabled) {
1995: result = FinderCache.getResult(finderClassName,
1996: finderMethodName, finderParams, finderArgs,
1997: getSessionFactory());
1998: }
1999:
2000: if (result == null) {
2001: Session session = null;
2002:
2003: try {
2004: session = openSession();
2005:
2006: StringMaker query = new StringMaker();
2007:
2008: query.append("SELECT COUNT(*) ");
2009: query
2010: .append("FROM com.liferay.portal.model.Layout WHERE ");
2011:
2012: query.append("dlFolderId = ?");
2013:
2014: query.append(" ");
2015:
2016: Query q = session.createQuery(query.toString());
2017:
2018: int queryPos = 0;
2019:
2020: q.setLong(queryPos++, dlFolderId);
2021:
2022: Long count = null;
2023:
2024: Iterator itr = q.list().iterator();
2025:
2026: if (itr.hasNext()) {
2027: count = (Long) itr.next();
2028: }
2029:
2030: if (count == null) {
2031: count = new Long(0);
2032: }
2033:
2034: FinderCache.putResult(finderClassNameCacheEnabled,
2035: finderClassName, finderMethodName,
2036: finderParams, finderArgs, count);
2037:
2038: return count.intValue();
2039: } catch (Exception e) {
2040: throw HibernateUtil.processException(e);
2041: } finally {
2042: closeSession(session);
2043: }
2044: } else {
2045: return ((Long) result).intValue();
2046: }
2047: }
2048:
2049: public int countByIconImageId(long iconImageId)
2050: throws SystemException {
2051: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
2052: String finderClassName = Layout.class.getName();
2053: String finderMethodName = "countByIconImageId";
2054: String[] finderParams = new String[] { Long.class.getName() };
2055: Object[] finderArgs = new Object[] { new Long(iconImageId) };
2056:
2057: Object result = null;
2058:
2059: if (finderClassNameCacheEnabled) {
2060: result = FinderCache.getResult(finderClassName,
2061: finderMethodName, finderParams, finderArgs,
2062: getSessionFactory());
2063: }
2064:
2065: if (result == null) {
2066: Session session = null;
2067:
2068: try {
2069: session = openSession();
2070:
2071: StringMaker query = new StringMaker();
2072:
2073: query.append("SELECT COUNT(*) ");
2074: query
2075: .append("FROM com.liferay.portal.model.Layout WHERE ");
2076:
2077: query.append("iconImageId = ?");
2078:
2079: query.append(" ");
2080:
2081: Query q = session.createQuery(query.toString());
2082:
2083: int queryPos = 0;
2084:
2085: q.setLong(queryPos++, iconImageId);
2086:
2087: Long count = null;
2088:
2089: Iterator itr = q.list().iterator();
2090:
2091: if (itr.hasNext()) {
2092: count = (Long) itr.next();
2093: }
2094:
2095: if (count == null) {
2096: count = new Long(0);
2097: }
2098:
2099: FinderCache.putResult(finderClassNameCacheEnabled,
2100: finderClassName, finderMethodName,
2101: finderParams, finderArgs, count);
2102:
2103: return count.intValue();
2104: } catch (Exception e) {
2105: throw HibernateUtil.processException(e);
2106: } finally {
2107: closeSession(session);
2108: }
2109: } else {
2110: return ((Long) result).intValue();
2111: }
2112: }
2113:
2114: public int countByG_P(long groupId, boolean privateLayout)
2115: throws SystemException {
2116: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
2117: String finderClassName = Layout.class.getName();
2118: String finderMethodName = "countByG_P";
2119: String[] finderParams = new String[] { Long.class.getName(),
2120: Boolean.class.getName() };
2121: Object[] finderArgs = new Object[] { new Long(groupId),
2122: Boolean.valueOf(privateLayout) };
2123:
2124: Object result = null;
2125:
2126: if (finderClassNameCacheEnabled) {
2127: result = FinderCache.getResult(finderClassName,
2128: finderMethodName, finderParams, finderArgs,
2129: getSessionFactory());
2130: }
2131:
2132: if (result == null) {
2133: Session session = null;
2134:
2135: try {
2136: session = openSession();
2137:
2138: StringMaker query = new StringMaker();
2139:
2140: query.append("SELECT COUNT(*) ");
2141: query
2142: .append("FROM com.liferay.portal.model.Layout WHERE ");
2143:
2144: query.append("groupId = ?");
2145:
2146: query.append(" AND ");
2147:
2148: query.append("privateLayout = ?");
2149:
2150: query.append(" ");
2151:
2152: Query q = session.createQuery(query.toString());
2153:
2154: int queryPos = 0;
2155:
2156: q.setLong(queryPos++, groupId);
2157:
2158: q.setBoolean(queryPos++, privateLayout);
2159:
2160: Long count = null;
2161:
2162: Iterator itr = q.list().iterator();
2163:
2164: if (itr.hasNext()) {
2165: count = (Long) itr.next();
2166: }
2167:
2168: if (count == null) {
2169: count = new Long(0);
2170: }
2171:
2172: FinderCache.putResult(finderClassNameCacheEnabled,
2173: finderClassName, finderMethodName,
2174: finderParams, finderArgs, count);
2175:
2176: return count.intValue();
2177: } catch (Exception e) {
2178: throw HibernateUtil.processException(e);
2179: } finally {
2180: closeSession(session);
2181: }
2182: } else {
2183: return ((Long) result).intValue();
2184: }
2185: }
2186:
2187: public int countByG_P_L(long groupId, boolean privateLayout,
2188: long layoutId) throws SystemException {
2189: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
2190: String finderClassName = Layout.class.getName();
2191: String finderMethodName = "countByG_P_L";
2192: String[] finderParams = new String[] { Long.class.getName(),
2193: Boolean.class.getName(), Long.class.getName() };
2194: Object[] finderArgs = new Object[] { new Long(groupId),
2195: Boolean.valueOf(privateLayout), new Long(layoutId) };
2196:
2197: Object result = null;
2198:
2199: if (finderClassNameCacheEnabled) {
2200: result = FinderCache.getResult(finderClassName,
2201: finderMethodName, finderParams, finderArgs,
2202: getSessionFactory());
2203: }
2204:
2205: if (result == null) {
2206: Session session = null;
2207:
2208: try {
2209: session = openSession();
2210:
2211: StringMaker query = new StringMaker();
2212:
2213: query.append("SELECT COUNT(*) ");
2214: query
2215: .append("FROM com.liferay.portal.model.Layout WHERE ");
2216:
2217: query.append("groupId = ?");
2218:
2219: query.append(" AND ");
2220:
2221: query.append("privateLayout = ?");
2222:
2223: query.append(" AND ");
2224:
2225: query.append("layoutId = ?");
2226:
2227: query.append(" ");
2228:
2229: Query q = session.createQuery(query.toString());
2230:
2231: int queryPos = 0;
2232:
2233: q.setLong(queryPos++, groupId);
2234:
2235: q.setBoolean(queryPos++, privateLayout);
2236:
2237: q.setLong(queryPos++, layoutId);
2238:
2239: Long count = null;
2240:
2241: Iterator itr = q.list().iterator();
2242:
2243: if (itr.hasNext()) {
2244: count = (Long) itr.next();
2245: }
2246:
2247: if (count == null) {
2248: count = new Long(0);
2249: }
2250:
2251: FinderCache.putResult(finderClassNameCacheEnabled,
2252: finderClassName, finderMethodName,
2253: finderParams, finderArgs, count);
2254:
2255: return count.intValue();
2256: } catch (Exception e) {
2257: throw HibernateUtil.processException(e);
2258: } finally {
2259: closeSession(session);
2260: }
2261: } else {
2262: return ((Long) result).intValue();
2263: }
2264: }
2265:
2266: public int countByG_P_P(long groupId, boolean privateLayout,
2267: long parentLayoutId) throws SystemException {
2268: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
2269: String finderClassName = Layout.class.getName();
2270: String finderMethodName = "countByG_P_P";
2271: String[] finderParams = new String[] { Long.class.getName(),
2272: Boolean.class.getName(), Long.class.getName() };
2273: Object[] finderArgs = new Object[] { new Long(groupId),
2274: Boolean.valueOf(privateLayout),
2275: new Long(parentLayoutId) };
2276:
2277: Object result = null;
2278:
2279: if (finderClassNameCacheEnabled) {
2280: result = FinderCache.getResult(finderClassName,
2281: finderMethodName, finderParams, finderArgs,
2282: getSessionFactory());
2283: }
2284:
2285: if (result == null) {
2286: Session session = null;
2287:
2288: try {
2289: session = openSession();
2290:
2291: StringMaker query = new StringMaker();
2292:
2293: query.append("SELECT COUNT(*) ");
2294: query
2295: .append("FROM com.liferay.portal.model.Layout WHERE ");
2296:
2297: query.append("groupId = ?");
2298:
2299: query.append(" AND ");
2300:
2301: query.append("privateLayout = ?");
2302:
2303: query.append(" AND ");
2304:
2305: query.append("parentLayoutId = ?");
2306:
2307: query.append(" ");
2308:
2309: Query q = session.createQuery(query.toString());
2310:
2311: int queryPos = 0;
2312:
2313: q.setLong(queryPos++, groupId);
2314:
2315: q.setBoolean(queryPos++, privateLayout);
2316:
2317: q.setLong(queryPos++, parentLayoutId);
2318:
2319: Long count = null;
2320:
2321: Iterator itr = q.list().iterator();
2322:
2323: if (itr.hasNext()) {
2324: count = (Long) itr.next();
2325: }
2326:
2327: if (count == null) {
2328: count = new Long(0);
2329: }
2330:
2331: FinderCache.putResult(finderClassNameCacheEnabled,
2332: finderClassName, finderMethodName,
2333: finderParams, finderArgs, count);
2334:
2335: return count.intValue();
2336: } catch (Exception e) {
2337: throw HibernateUtil.processException(e);
2338: } finally {
2339: closeSession(session);
2340: }
2341: } else {
2342: return ((Long) result).intValue();
2343: }
2344: }
2345:
2346: public int countByG_P_F(long groupId, boolean privateLayout,
2347: String friendlyURL) throws SystemException {
2348: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
2349: String finderClassName = Layout.class.getName();
2350: String finderMethodName = "countByG_P_F";
2351: String[] finderParams = new String[] { Long.class.getName(),
2352: Boolean.class.getName(), String.class.getName() };
2353: Object[] finderArgs = new Object[] { new Long(groupId),
2354: Boolean.valueOf(privateLayout),
2355:
2356: friendlyURL };
2357:
2358: Object result = null;
2359:
2360: if (finderClassNameCacheEnabled) {
2361: result = FinderCache.getResult(finderClassName,
2362: finderMethodName, finderParams, finderArgs,
2363: getSessionFactory());
2364: }
2365:
2366: if (result == null) {
2367: Session session = null;
2368:
2369: try {
2370: session = openSession();
2371:
2372: StringMaker query = new StringMaker();
2373:
2374: query.append("SELECT COUNT(*) ");
2375: query
2376: .append("FROM com.liferay.portal.model.Layout WHERE ");
2377:
2378: query.append("groupId = ?");
2379:
2380: query.append(" AND ");
2381:
2382: query.append("privateLayout = ?");
2383:
2384: query.append(" AND ");
2385:
2386: if (friendlyURL == null) {
2387: query.append("friendlyURL IS NULL");
2388: } else {
2389: query.append("lower(friendlyURL) = ?");
2390: }
2391:
2392: query.append(" ");
2393:
2394: Query q = session.createQuery(query.toString());
2395:
2396: int queryPos = 0;
2397:
2398: q.setLong(queryPos++, groupId);
2399:
2400: q.setBoolean(queryPos++, privateLayout);
2401:
2402: if (friendlyURL != null) {
2403: q.setString(queryPos++, friendlyURL);
2404: }
2405:
2406: Long count = null;
2407:
2408: Iterator itr = q.list().iterator();
2409:
2410: if (itr.hasNext()) {
2411: count = (Long) itr.next();
2412: }
2413:
2414: if (count == null) {
2415: count = new Long(0);
2416: }
2417:
2418: FinderCache.putResult(finderClassNameCacheEnabled,
2419: finderClassName, finderMethodName,
2420: finderParams, finderArgs, count);
2421:
2422: return count.intValue();
2423: } catch (Exception e) {
2424: throw HibernateUtil.processException(e);
2425: } finally {
2426: closeSession(session);
2427: }
2428: } else {
2429: return ((Long) result).intValue();
2430: }
2431: }
2432:
2433: public int countAll() throws SystemException {
2434: boolean finderClassNameCacheEnabled = LayoutModelImpl.CACHE_ENABLED;
2435: String finderClassName = Layout.class.getName();
2436: String finderMethodName = "countAll";
2437: String[] finderParams = new String[] {};
2438: Object[] finderArgs = new Object[] {};
2439:
2440: Object result = null;
2441:
2442: if (finderClassNameCacheEnabled) {
2443: result = FinderCache.getResult(finderClassName,
2444: finderMethodName, finderParams, finderArgs,
2445: getSessionFactory());
2446: }
2447:
2448: if (result == null) {
2449: Session session = null;
2450:
2451: try {
2452: session = openSession();
2453:
2454: Query q = session
2455: .createQuery("SELECT COUNT(*) FROM com.liferay.portal.model.Layout");
2456:
2457: Long count = null;
2458:
2459: Iterator itr = q.list().iterator();
2460:
2461: if (itr.hasNext()) {
2462: count = (Long) itr.next();
2463: }
2464:
2465: if (count == null) {
2466: count = new Long(0);
2467: }
2468:
2469: FinderCache.putResult(finderClassNameCacheEnabled,
2470: finderClassName, finderMethodName,
2471: finderParams, finderArgs, count);
2472:
2473: return count.intValue();
2474: } catch (Exception e) {
2475: throw HibernateUtil.processException(e);
2476: } finally {
2477: closeSession(session);
2478: }
2479: } else {
2480: return ((Long) result).intValue();
2481: }
2482: }
2483:
2484: protected void initDao() {
2485: }
2486:
2487: private static ModelListener _getListener() {
2488: if (Validator.isNotNull(_LISTENER)) {
2489: try {
2490: return (ModelListener) Class.forName(_LISTENER)
2491: .newInstance();
2492: } catch (Exception e) {
2493: _log.error(e);
2494: }
2495: }
2496:
2497: return null;
2498: }
2499:
2500: private static final String _LISTENER = GetterUtil
2501: .getString(PropsUtil
2502: .get("value.object.listener.com.liferay.portal.model.Layout"));
2503: private static Log _log = LogFactory
2504: .getLog(LayoutPersistenceImpl.class);
2505: }
|