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