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.NoSuchActivityTrackerException;
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.ActivityTracker;
0033: import com.liferay.portal.model.ModelListener;
0034: import com.liferay.portal.model.impl.ActivityTrackerImpl;
0035: import com.liferay.portal.model.impl.ActivityTrackerModelImpl;
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="ActivityTrackerPersistenceImpl.java.html"><b><i>View Source</i></b></a>
0054: *
0055: * @author Brian Wing Shun Chan
0056: *
0057: */
0058: public class ActivityTrackerPersistenceImpl extends BasePersistence
0059: implements ActivityTrackerPersistence {
0060: public ActivityTracker create(long activityTrackerId) {
0061: ActivityTracker activityTracker = new ActivityTrackerImpl();
0062:
0063: activityTracker.setNew(true);
0064: activityTracker.setPrimaryKey(activityTrackerId);
0065:
0066: return activityTracker;
0067: }
0068:
0069: public ActivityTracker remove(long activityTrackerId)
0070: throws NoSuchActivityTrackerException, SystemException {
0071: Session session = null;
0072:
0073: try {
0074: session = openSession();
0075:
0076: ActivityTracker activityTracker = (ActivityTracker) session
0077: .get(ActivityTrackerImpl.class, new Long(
0078: activityTrackerId));
0079:
0080: if (activityTracker == null) {
0081: if (_log.isWarnEnabled()) {
0082: _log
0083: .warn("No ActivityTracker exists with the primary key "
0084: + activityTrackerId);
0085: }
0086:
0087: throw new NoSuchActivityTrackerException(
0088: "No ActivityTracker exists with the primary key "
0089: + activityTrackerId);
0090: }
0091:
0092: return remove(activityTracker);
0093: } catch (NoSuchActivityTrackerException nsee) {
0094: throw nsee;
0095: } catch (Exception e) {
0096: throw HibernateUtil.processException(e);
0097: } finally {
0098: closeSession(session);
0099: }
0100: }
0101:
0102: public ActivityTracker remove(ActivityTracker activityTracker)
0103: throws SystemException {
0104: ModelListener listener = _getListener();
0105:
0106: if (listener != null) {
0107: listener.onBeforeRemove(activityTracker);
0108: }
0109:
0110: activityTracker = removeImpl(activityTracker);
0111:
0112: if (listener != null) {
0113: listener.onAfterRemove(activityTracker);
0114: }
0115:
0116: return activityTracker;
0117: }
0118:
0119: protected ActivityTracker removeImpl(ActivityTracker activityTracker)
0120: throws SystemException {
0121: Session session = null;
0122:
0123: try {
0124: session = openSession();
0125:
0126: session.delete(activityTracker);
0127:
0128: session.flush();
0129:
0130: return activityTracker;
0131: } catch (Exception e) {
0132: throw HibernateUtil.processException(e);
0133: } finally {
0134: closeSession(session);
0135:
0136: FinderCache.clearCache(ActivityTracker.class.getName());
0137: }
0138: }
0139:
0140: public ActivityTracker update(ActivityTracker activityTracker)
0141: throws SystemException {
0142: return update(activityTracker, false);
0143: }
0144:
0145: public ActivityTracker update(ActivityTracker activityTracker,
0146: boolean merge) throws SystemException {
0147: ModelListener listener = _getListener();
0148:
0149: boolean isNew = activityTracker.isNew();
0150:
0151: if (listener != null) {
0152: if (isNew) {
0153: listener.onBeforeCreate(activityTracker);
0154: } else {
0155: listener.onBeforeUpdate(activityTracker);
0156: }
0157: }
0158:
0159: activityTracker = updateImpl(activityTracker, merge);
0160:
0161: if (listener != null) {
0162: if (isNew) {
0163: listener.onAfterCreate(activityTracker);
0164: } else {
0165: listener.onAfterUpdate(activityTracker);
0166: }
0167: }
0168:
0169: return activityTracker;
0170: }
0171:
0172: public ActivityTracker updateImpl(
0173: com.liferay.portal.model.ActivityTracker activityTracker,
0174: boolean merge) throws SystemException {
0175: Session session = null;
0176:
0177: try {
0178: session = openSession();
0179:
0180: if (merge) {
0181: session.merge(activityTracker);
0182: } else {
0183: if (activityTracker.isNew()) {
0184: session.save(activityTracker);
0185: }
0186: }
0187:
0188: session.flush();
0189:
0190: activityTracker.setNew(false);
0191:
0192: return activityTracker;
0193: } catch (Exception e) {
0194: throw HibernateUtil.processException(e);
0195: } finally {
0196: closeSession(session);
0197:
0198: FinderCache.clearCache(ActivityTracker.class.getName());
0199: }
0200: }
0201:
0202: public ActivityTracker findByPrimaryKey(long activityTrackerId)
0203: throws NoSuchActivityTrackerException, SystemException {
0204: ActivityTracker activityTracker = fetchByPrimaryKey(activityTrackerId);
0205:
0206: if (activityTracker == null) {
0207: if (_log.isWarnEnabled()) {
0208: _log
0209: .warn("No ActivityTracker exists with the primary key "
0210: + activityTrackerId);
0211: }
0212:
0213: throw new NoSuchActivityTrackerException(
0214: "No ActivityTracker exists with the primary key "
0215: + activityTrackerId);
0216: }
0217:
0218: return activityTracker;
0219: }
0220:
0221: public ActivityTracker fetchByPrimaryKey(long activityTrackerId)
0222: throws SystemException {
0223: Session session = null;
0224:
0225: try {
0226: session = openSession();
0227:
0228: return (ActivityTracker) session.get(
0229: ActivityTrackerImpl.class, new Long(
0230: activityTrackerId));
0231: } catch (Exception e) {
0232: throw HibernateUtil.processException(e);
0233: } finally {
0234: closeSession(session);
0235: }
0236: }
0237:
0238: public List findByGroupId(long groupId) throws SystemException {
0239: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0240: String finderClassName = ActivityTracker.class.getName();
0241: String finderMethodName = "findByGroupId";
0242: String[] finderParams = new String[] { Long.class.getName() };
0243: Object[] finderArgs = new Object[] { new Long(groupId) };
0244:
0245: Object result = null;
0246:
0247: if (finderClassNameCacheEnabled) {
0248: result = FinderCache.getResult(finderClassName,
0249: finderMethodName, finderParams, finderArgs,
0250: getSessionFactory());
0251: }
0252:
0253: if (result == null) {
0254: Session session = null;
0255:
0256: try {
0257: session = openSession();
0258:
0259: StringMaker query = new StringMaker();
0260:
0261: query
0262: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0263:
0264: query.append("groupId = ?");
0265:
0266: query.append(" ");
0267:
0268: query.append("ORDER BY ");
0269:
0270: query.append("createDate DESC");
0271:
0272: Query q = session.createQuery(query.toString());
0273:
0274: int queryPos = 0;
0275:
0276: q.setLong(queryPos++, groupId);
0277:
0278: List list = q.list();
0279:
0280: FinderCache.putResult(finderClassNameCacheEnabled,
0281: finderClassName, finderMethodName,
0282: finderParams, finderArgs, list);
0283:
0284: return list;
0285: } catch (Exception e) {
0286: throw HibernateUtil.processException(e);
0287: } finally {
0288: closeSession(session);
0289: }
0290: } else {
0291: return (List) result;
0292: }
0293: }
0294:
0295: public List findByGroupId(long groupId, int begin, int end)
0296: throws SystemException {
0297: return findByGroupId(groupId, begin, end, null);
0298: }
0299:
0300: public List findByGroupId(long groupId, int begin, int end,
0301: OrderByComparator obc) throws SystemException {
0302: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0303: String finderClassName = ActivityTracker.class.getName();
0304: String finderMethodName = "findByGroupId";
0305: String[] finderParams = new String[] { Long.class.getName(),
0306:
0307: "java.lang.Integer", "java.lang.Integer",
0308: "com.liferay.portal.kernel.util.OrderByComparator" };
0309: Object[] finderArgs = new Object[] { new Long(groupId),
0310:
0311: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0312:
0313: Object result = null;
0314:
0315: if (finderClassNameCacheEnabled) {
0316: result = FinderCache.getResult(finderClassName,
0317: finderMethodName, finderParams, finderArgs,
0318: getSessionFactory());
0319: }
0320:
0321: if (result == null) {
0322: Session session = null;
0323:
0324: try {
0325: session = openSession();
0326:
0327: StringMaker query = new StringMaker();
0328:
0329: query
0330: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0331:
0332: query.append("groupId = ?");
0333:
0334: query.append(" ");
0335:
0336: if (obc != null) {
0337: query.append("ORDER BY ");
0338: query.append(obc.getOrderBy());
0339: }
0340:
0341: else {
0342: query.append("ORDER BY ");
0343:
0344: query.append("createDate DESC");
0345: }
0346:
0347: Query q = session.createQuery(query.toString());
0348:
0349: int queryPos = 0;
0350:
0351: q.setLong(queryPos++, groupId);
0352:
0353: List list = QueryUtil.list(q, getDialect(), begin, end);
0354:
0355: FinderCache.putResult(finderClassNameCacheEnabled,
0356: finderClassName, finderMethodName,
0357: finderParams, finderArgs, list);
0358:
0359: return list;
0360: } catch (Exception e) {
0361: throw HibernateUtil.processException(e);
0362: } finally {
0363: closeSession(session);
0364: }
0365: } else {
0366: return (List) result;
0367: }
0368: }
0369:
0370: public ActivityTracker findByGroupId_First(long groupId,
0371: OrderByComparator obc)
0372: throws NoSuchActivityTrackerException, SystemException {
0373: List list = findByGroupId(groupId, 0, 1, obc);
0374:
0375: if (list.size() == 0) {
0376: StringMaker msg = new StringMaker();
0377:
0378: msg.append("No ActivityTracker exists with the key {");
0379:
0380: msg.append("groupId=" + groupId);
0381:
0382: msg.append(StringPool.CLOSE_CURLY_BRACE);
0383:
0384: throw new NoSuchActivityTrackerException(msg.toString());
0385: } else {
0386: return (ActivityTracker) list.get(0);
0387: }
0388: }
0389:
0390: public ActivityTracker findByGroupId_Last(long groupId,
0391: OrderByComparator obc)
0392: throws NoSuchActivityTrackerException, SystemException {
0393: int count = countByGroupId(groupId);
0394:
0395: List list = findByGroupId(groupId, count - 1, count, obc);
0396:
0397: if (list.size() == 0) {
0398: StringMaker msg = new StringMaker();
0399:
0400: msg.append("No ActivityTracker exists with the key {");
0401:
0402: msg.append("groupId=" + groupId);
0403:
0404: msg.append(StringPool.CLOSE_CURLY_BRACE);
0405:
0406: throw new NoSuchActivityTrackerException(msg.toString());
0407: } else {
0408: return (ActivityTracker) list.get(0);
0409: }
0410: }
0411:
0412: public ActivityTracker[] findByGroupId_PrevAndNext(
0413: long activityTrackerId, long groupId, OrderByComparator obc)
0414: throws NoSuchActivityTrackerException, SystemException {
0415: ActivityTracker activityTracker = findByPrimaryKey(activityTrackerId);
0416:
0417: int count = countByGroupId(groupId);
0418:
0419: Session session = null;
0420:
0421: try {
0422: session = openSession();
0423:
0424: StringMaker query = new StringMaker();
0425:
0426: query
0427: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0428:
0429: query.append("groupId = ?");
0430:
0431: query.append(" ");
0432:
0433: if (obc != null) {
0434: query.append("ORDER BY ");
0435: query.append(obc.getOrderBy());
0436: }
0437:
0438: else {
0439: query.append("ORDER BY ");
0440:
0441: query.append("createDate DESC");
0442: }
0443:
0444: Query q = session.createQuery(query.toString());
0445:
0446: int queryPos = 0;
0447:
0448: q.setLong(queryPos++, groupId);
0449:
0450: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0451: activityTracker);
0452:
0453: ActivityTracker[] array = new ActivityTrackerImpl[3];
0454:
0455: array[0] = (ActivityTracker) objArray[0];
0456: array[1] = (ActivityTracker) objArray[1];
0457: array[2] = (ActivityTracker) objArray[2];
0458:
0459: return array;
0460: } catch (Exception e) {
0461: throw HibernateUtil.processException(e);
0462: } finally {
0463: closeSession(session);
0464: }
0465: }
0466:
0467: public List findByCompanyId(long companyId) throws SystemException {
0468: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0469: String finderClassName = ActivityTracker.class.getName();
0470: String finderMethodName = "findByCompanyId";
0471: String[] finderParams = new String[] { Long.class.getName() };
0472: Object[] finderArgs = new Object[] { new Long(companyId) };
0473:
0474: Object result = null;
0475:
0476: if (finderClassNameCacheEnabled) {
0477: result = FinderCache.getResult(finderClassName,
0478: finderMethodName, finderParams, finderArgs,
0479: getSessionFactory());
0480: }
0481:
0482: if (result == null) {
0483: Session session = null;
0484:
0485: try {
0486: session = openSession();
0487:
0488: StringMaker query = new StringMaker();
0489:
0490: query
0491: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0492:
0493: query.append("companyId = ?");
0494:
0495: query.append(" ");
0496:
0497: query.append("ORDER BY ");
0498:
0499: query.append("createDate DESC");
0500:
0501: Query q = session.createQuery(query.toString());
0502:
0503: int queryPos = 0;
0504:
0505: q.setLong(queryPos++, companyId);
0506:
0507: List list = q.list();
0508:
0509: FinderCache.putResult(finderClassNameCacheEnabled,
0510: finderClassName, finderMethodName,
0511: finderParams, finderArgs, list);
0512:
0513: return list;
0514: } catch (Exception e) {
0515: throw HibernateUtil.processException(e);
0516: } finally {
0517: closeSession(session);
0518: }
0519: } else {
0520: return (List) result;
0521: }
0522: }
0523:
0524: public List findByCompanyId(long companyId, int begin, int end)
0525: throws SystemException {
0526: return findByCompanyId(companyId, begin, end, null);
0527: }
0528:
0529: public List findByCompanyId(long companyId, int begin, int end,
0530: OrderByComparator obc) throws SystemException {
0531: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0532: String finderClassName = ActivityTracker.class.getName();
0533: String finderMethodName = "findByCompanyId";
0534: String[] finderParams = new String[] { Long.class.getName(),
0535:
0536: "java.lang.Integer", "java.lang.Integer",
0537: "com.liferay.portal.kernel.util.OrderByComparator" };
0538: Object[] finderArgs = new Object[] { new Long(companyId),
0539:
0540: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0541:
0542: Object result = null;
0543:
0544: if (finderClassNameCacheEnabled) {
0545: result = FinderCache.getResult(finderClassName,
0546: finderMethodName, finderParams, finderArgs,
0547: getSessionFactory());
0548: }
0549:
0550: if (result == null) {
0551: Session session = null;
0552:
0553: try {
0554: session = openSession();
0555:
0556: StringMaker query = new StringMaker();
0557:
0558: query
0559: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0560:
0561: query.append("companyId = ?");
0562:
0563: query.append(" ");
0564:
0565: if (obc != null) {
0566: query.append("ORDER BY ");
0567: query.append(obc.getOrderBy());
0568: }
0569:
0570: else {
0571: query.append("ORDER BY ");
0572:
0573: query.append("createDate DESC");
0574: }
0575:
0576: Query q = session.createQuery(query.toString());
0577:
0578: int queryPos = 0;
0579:
0580: q.setLong(queryPos++, companyId);
0581:
0582: List list = QueryUtil.list(q, getDialect(), begin, end);
0583:
0584: FinderCache.putResult(finderClassNameCacheEnabled,
0585: finderClassName, finderMethodName,
0586: finderParams, finderArgs, list);
0587:
0588: return list;
0589: } catch (Exception e) {
0590: throw HibernateUtil.processException(e);
0591: } finally {
0592: closeSession(session);
0593: }
0594: } else {
0595: return (List) result;
0596: }
0597: }
0598:
0599: public ActivityTracker findByCompanyId_First(long companyId,
0600: OrderByComparator obc)
0601: throws NoSuchActivityTrackerException, SystemException {
0602: List list = findByCompanyId(companyId, 0, 1, obc);
0603:
0604: if (list.size() == 0) {
0605: StringMaker msg = new StringMaker();
0606:
0607: msg.append("No ActivityTracker exists with the key {");
0608:
0609: msg.append("companyId=" + companyId);
0610:
0611: msg.append(StringPool.CLOSE_CURLY_BRACE);
0612:
0613: throw new NoSuchActivityTrackerException(msg.toString());
0614: } else {
0615: return (ActivityTracker) list.get(0);
0616: }
0617: }
0618:
0619: public ActivityTracker findByCompanyId_Last(long companyId,
0620: OrderByComparator obc)
0621: throws NoSuchActivityTrackerException, SystemException {
0622: int count = countByCompanyId(companyId);
0623:
0624: List list = findByCompanyId(companyId, count - 1, count, obc);
0625:
0626: if (list.size() == 0) {
0627: StringMaker msg = new StringMaker();
0628:
0629: msg.append("No ActivityTracker exists with the key {");
0630:
0631: msg.append("companyId=" + companyId);
0632:
0633: msg.append(StringPool.CLOSE_CURLY_BRACE);
0634:
0635: throw new NoSuchActivityTrackerException(msg.toString());
0636: } else {
0637: return (ActivityTracker) list.get(0);
0638: }
0639: }
0640:
0641: public ActivityTracker[] findByCompanyId_PrevAndNext(
0642: long activityTrackerId, long companyId,
0643: OrderByComparator obc)
0644: throws NoSuchActivityTrackerException, SystemException {
0645: ActivityTracker activityTracker = findByPrimaryKey(activityTrackerId);
0646:
0647: int count = countByCompanyId(companyId);
0648:
0649: Session session = null;
0650:
0651: try {
0652: session = openSession();
0653:
0654: StringMaker query = new StringMaker();
0655:
0656: query
0657: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0658:
0659: query.append("companyId = ?");
0660:
0661: query.append(" ");
0662:
0663: if (obc != null) {
0664: query.append("ORDER BY ");
0665: query.append(obc.getOrderBy());
0666: }
0667:
0668: else {
0669: query.append("ORDER BY ");
0670:
0671: query.append("createDate DESC");
0672: }
0673:
0674: Query q = session.createQuery(query.toString());
0675:
0676: int queryPos = 0;
0677:
0678: q.setLong(queryPos++, companyId);
0679:
0680: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0681: activityTracker);
0682:
0683: ActivityTracker[] array = new ActivityTrackerImpl[3];
0684:
0685: array[0] = (ActivityTracker) objArray[0];
0686: array[1] = (ActivityTracker) objArray[1];
0687: array[2] = (ActivityTracker) objArray[2];
0688:
0689: return array;
0690: } catch (Exception e) {
0691: throw HibernateUtil.processException(e);
0692: } finally {
0693: closeSession(session);
0694: }
0695: }
0696:
0697: public List findByUserId(long userId) throws SystemException {
0698: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0699: String finderClassName = ActivityTracker.class.getName();
0700: String finderMethodName = "findByUserId";
0701: String[] finderParams = new String[] { Long.class.getName() };
0702: Object[] finderArgs = new Object[] { new Long(userId) };
0703:
0704: Object result = null;
0705:
0706: if (finderClassNameCacheEnabled) {
0707: result = FinderCache.getResult(finderClassName,
0708: finderMethodName, finderParams, finderArgs,
0709: getSessionFactory());
0710: }
0711:
0712: if (result == null) {
0713: Session session = null;
0714:
0715: try {
0716: session = openSession();
0717:
0718: StringMaker query = new StringMaker();
0719:
0720: query
0721: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0722:
0723: query.append("userId = ?");
0724:
0725: query.append(" ");
0726:
0727: query.append("ORDER BY ");
0728:
0729: query.append("createDate DESC");
0730:
0731: Query q = session.createQuery(query.toString());
0732:
0733: int queryPos = 0;
0734:
0735: q.setLong(queryPos++, userId);
0736:
0737: List list = q.list();
0738:
0739: FinderCache.putResult(finderClassNameCacheEnabled,
0740: finderClassName, finderMethodName,
0741: finderParams, finderArgs, list);
0742:
0743: return list;
0744: } catch (Exception e) {
0745: throw HibernateUtil.processException(e);
0746: } finally {
0747: closeSession(session);
0748: }
0749: } else {
0750: return (List) result;
0751: }
0752: }
0753:
0754: public List findByUserId(long userId, int begin, int end)
0755: throws SystemException {
0756: return findByUserId(userId, begin, end, null);
0757: }
0758:
0759: public List findByUserId(long userId, int begin, int end,
0760: OrderByComparator obc) throws SystemException {
0761: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0762: String finderClassName = ActivityTracker.class.getName();
0763: String finderMethodName = "findByUserId";
0764: String[] finderParams = new String[] { Long.class.getName(),
0765:
0766: "java.lang.Integer", "java.lang.Integer",
0767: "com.liferay.portal.kernel.util.OrderByComparator" };
0768: Object[] finderArgs = new Object[] { new Long(userId),
0769:
0770: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
0771:
0772: Object result = null;
0773:
0774: if (finderClassNameCacheEnabled) {
0775: result = FinderCache.getResult(finderClassName,
0776: finderMethodName, finderParams, finderArgs,
0777: getSessionFactory());
0778: }
0779:
0780: if (result == null) {
0781: Session session = null;
0782:
0783: try {
0784: session = openSession();
0785:
0786: StringMaker query = new StringMaker();
0787:
0788: query
0789: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0790:
0791: query.append("userId = ?");
0792:
0793: query.append(" ");
0794:
0795: if (obc != null) {
0796: query.append("ORDER BY ");
0797: query.append(obc.getOrderBy());
0798: }
0799:
0800: else {
0801: query.append("ORDER BY ");
0802:
0803: query.append("createDate DESC");
0804: }
0805:
0806: Query q = session.createQuery(query.toString());
0807:
0808: int queryPos = 0;
0809:
0810: q.setLong(queryPos++, userId);
0811:
0812: List list = QueryUtil.list(q, getDialect(), begin, end);
0813:
0814: FinderCache.putResult(finderClassNameCacheEnabled,
0815: finderClassName, finderMethodName,
0816: finderParams, finderArgs, list);
0817:
0818: return list;
0819: } catch (Exception e) {
0820: throw HibernateUtil.processException(e);
0821: } finally {
0822: closeSession(session);
0823: }
0824: } else {
0825: return (List) result;
0826: }
0827: }
0828:
0829: public ActivityTracker findByUserId_First(long userId,
0830: OrderByComparator obc)
0831: throws NoSuchActivityTrackerException, SystemException {
0832: List list = findByUserId(userId, 0, 1, obc);
0833:
0834: if (list.size() == 0) {
0835: StringMaker msg = new StringMaker();
0836:
0837: msg.append("No ActivityTracker exists with the key {");
0838:
0839: msg.append("userId=" + userId);
0840:
0841: msg.append(StringPool.CLOSE_CURLY_BRACE);
0842:
0843: throw new NoSuchActivityTrackerException(msg.toString());
0844: } else {
0845: return (ActivityTracker) list.get(0);
0846: }
0847: }
0848:
0849: public ActivityTracker findByUserId_Last(long userId,
0850: OrderByComparator obc)
0851: throws NoSuchActivityTrackerException, SystemException {
0852: int count = countByUserId(userId);
0853:
0854: List list = findByUserId(userId, count - 1, count, obc);
0855:
0856: if (list.size() == 0) {
0857: StringMaker msg = new StringMaker();
0858:
0859: msg.append("No ActivityTracker exists with the key {");
0860:
0861: msg.append("userId=" + userId);
0862:
0863: msg.append(StringPool.CLOSE_CURLY_BRACE);
0864:
0865: throw new NoSuchActivityTrackerException(msg.toString());
0866: } else {
0867: return (ActivityTracker) list.get(0);
0868: }
0869: }
0870:
0871: public ActivityTracker[] findByUserId_PrevAndNext(
0872: long activityTrackerId, long userId, OrderByComparator obc)
0873: throws NoSuchActivityTrackerException, SystemException {
0874: ActivityTracker activityTracker = findByPrimaryKey(activityTrackerId);
0875:
0876: int count = countByUserId(userId);
0877:
0878: Session session = null;
0879:
0880: try {
0881: session = openSession();
0882:
0883: StringMaker query = new StringMaker();
0884:
0885: query
0886: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0887:
0888: query.append("userId = ?");
0889:
0890: query.append(" ");
0891:
0892: if (obc != null) {
0893: query.append("ORDER BY ");
0894: query.append(obc.getOrderBy());
0895: }
0896:
0897: else {
0898: query.append("ORDER BY ");
0899:
0900: query.append("createDate DESC");
0901: }
0902:
0903: Query q = session.createQuery(query.toString());
0904:
0905: int queryPos = 0;
0906:
0907: q.setLong(queryPos++, userId);
0908:
0909: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
0910: activityTracker);
0911:
0912: ActivityTracker[] array = new ActivityTrackerImpl[3];
0913:
0914: array[0] = (ActivityTracker) objArray[0];
0915: array[1] = (ActivityTracker) objArray[1];
0916: array[2] = (ActivityTracker) objArray[2];
0917:
0918: return array;
0919: } catch (Exception e) {
0920: throw HibernateUtil.processException(e);
0921: } finally {
0922: closeSession(session);
0923: }
0924: }
0925:
0926: public List findByReceiverUserId(long receiverUserId)
0927: throws SystemException {
0928: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0929: String finderClassName = ActivityTracker.class.getName();
0930: String finderMethodName = "findByReceiverUserId";
0931: String[] finderParams = new String[] { Long.class.getName() };
0932: Object[] finderArgs = new Object[] { new Long(receiverUserId) };
0933:
0934: Object result = null;
0935:
0936: if (finderClassNameCacheEnabled) {
0937: result = FinderCache.getResult(finderClassName,
0938: finderMethodName, finderParams, finderArgs,
0939: getSessionFactory());
0940: }
0941:
0942: if (result == null) {
0943: Session session = null;
0944:
0945: try {
0946: session = openSession();
0947:
0948: StringMaker query = new StringMaker();
0949:
0950: query
0951: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
0952:
0953: query.append("receiverUserId = ?");
0954:
0955: query.append(" ");
0956:
0957: query.append("ORDER BY ");
0958:
0959: query.append("createDate DESC");
0960:
0961: Query q = session.createQuery(query.toString());
0962:
0963: int queryPos = 0;
0964:
0965: q.setLong(queryPos++, receiverUserId);
0966:
0967: List list = q.list();
0968:
0969: FinderCache.putResult(finderClassNameCacheEnabled,
0970: finderClassName, finderMethodName,
0971: finderParams, finderArgs, list);
0972:
0973: return list;
0974: } catch (Exception e) {
0975: throw HibernateUtil.processException(e);
0976: } finally {
0977: closeSession(session);
0978: }
0979: } else {
0980: return (List) result;
0981: }
0982: }
0983:
0984: public List findByReceiverUserId(long receiverUserId, int begin,
0985: int end) throws SystemException {
0986: return findByReceiverUserId(receiverUserId, begin, end, null);
0987: }
0988:
0989: public List findByReceiverUserId(long receiverUserId, int begin,
0990: int end, OrderByComparator obc) throws SystemException {
0991: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
0992: String finderClassName = ActivityTracker.class.getName();
0993: String finderMethodName = "findByReceiverUserId";
0994: String[] finderParams = new String[] { Long.class.getName(),
0995:
0996: "java.lang.Integer", "java.lang.Integer",
0997: "com.liferay.portal.kernel.util.OrderByComparator" };
0998: Object[] finderArgs = new Object[] { new Long(receiverUserId),
0999:
1000: String.valueOf(begin), String.valueOf(end), String.valueOf(obc) };
1001:
1002: Object result = null;
1003:
1004: if (finderClassNameCacheEnabled) {
1005: result = FinderCache.getResult(finderClassName,
1006: finderMethodName, finderParams, finderArgs,
1007: getSessionFactory());
1008: }
1009:
1010: if (result == null) {
1011: Session session = null;
1012:
1013: try {
1014: session = openSession();
1015:
1016: StringMaker query = new StringMaker();
1017:
1018: query
1019: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1020:
1021: query.append("receiverUserId = ?");
1022:
1023: query.append(" ");
1024:
1025: if (obc != null) {
1026: query.append("ORDER BY ");
1027: query.append(obc.getOrderBy());
1028: }
1029:
1030: else {
1031: query.append("ORDER BY ");
1032:
1033: query.append("createDate DESC");
1034: }
1035:
1036: Query q = session.createQuery(query.toString());
1037:
1038: int queryPos = 0;
1039:
1040: q.setLong(queryPos++, receiverUserId);
1041:
1042: List list = QueryUtil.list(q, getDialect(), begin, end);
1043:
1044: FinderCache.putResult(finderClassNameCacheEnabled,
1045: finderClassName, finderMethodName,
1046: finderParams, finderArgs, list);
1047:
1048: return list;
1049: } catch (Exception e) {
1050: throw HibernateUtil.processException(e);
1051: } finally {
1052: closeSession(session);
1053: }
1054: } else {
1055: return (List) result;
1056: }
1057: }
1058:
1059: public ActivityTracker findByReceiverUserId_First(
1060: long receiverUserId, OrderByComparator obc)
1061: throws NoSuchActivityTrackerException, SystemException {
1062: List list = findByReceiverUserId(receiverUserId, 0, 1, obc);
1063:
1064: if (list.size() == 0) {
1065: StringMaker msg = new StringMaker();
1066:
1067: msg.append("No ActivityTracker exists with the key {");
1068:
1069: msg.append("receiverUserId=" + receiverUserId);
1070:
1071: msg.append(StringPool.CLOSE_CURLY_BRACE);
1072:
1073: throw new NoSuchActivityTrackerException(msg.toString());
1074: } else {
1075: return (ActivityTracker) list.get(0);
1076: }
1077: }
1078:
1079: public ActivityTracker findByReceiverUserId_Last(
1080: long receiverUserId, OrderByComparator obc)
1081: throws NoSuchActivityTrackerException, SystemException {
1082: int count = countByReceiverUserId(receiverUserId);
1083:
1084: List list = findByReceiverUserId(receiverUserId, count - 1,
1085: count, obc);
1086:
1087: if (list.size() == 0) {
1088: StringMaker msg = new StringMaker();
1089:
1090: msg.append("No ActivityTracker exists with the key {");
1091:
1092: msg.append("receiverUserId=" + receiverUserId);
1093:
1094: msg.append(StringPool.CLOSE_CURLY_BRACE);
1095:
1096: throw new NoSuchActivityTrackerException(msg.toString());
1097: } else {
1098: return (ActivityTracker) list.get(0);
1099: }
1100: }
1101:
1102: public ActivityTracker[] findByReceiverUserId_PrevAndNext(
1103: long activityTrackerId, long receiverUserId,
1104: OrderByComparator obc)
1105: throws NoSuchActivityTrackerException, SystemException {
1106: ActivityTracker activityTracker = findByPrimaryKey(activityTrackerId);
1107:
1108: int count = countByReceiverUserId(receiverUserId);
1109:
1110: Session session = null;
1111:
1112: try {
1113: session = openSession();
1114:
1115: StringMaker query = new StringMaker();
1116:
1117: query
1118: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1119:
1120: query.append("receiverUserId = ?");
1121:
1122: query.append(" ");
1123:
1124: if (obc != null) {
1125: query.append("ORDER BY ");
1126: query.append(obc.getOrderBy());
1127: }
1128:
1129: else {
1130: query.append("ORDER BY ");
1131:
1132: query.append("createDate DESC");
1133: }
1134:
1135: Query q = session.createQuery(query.toString());
1136:
1137: int queryPos = 0;
1138:
1139: q.setLong(queryPos++, receiverUserId);
1140:
1141: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1142: activityTracker);
1143:
1144: ActivityTracker[] array = new ActivityTrackerImpl[3];
1145:
1146: array[0] = (ActivityTracker) objArray[0];
1147: array[1] = (ActivityTracker) objArray[1];
1148: array[2] = (ActivityTracker) objArray[2];
1149:
1150: return array;
1151: } catch (Exception e) {
1152: throw HibernateUtil.processException(e);
1153: } finally {
1154: closeSession(session);
1155: }
1156: }
1157:
1158: public List findByC_C(long classNameId, long classPK)
1159: throws SystemException {
1160: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1161: String finderClassName = ActivityTracker.class.getName();
1162: String finderMethodName = "findByC_C";
1163: String[] finderParams = new String[] { Long.class.getName(),
1164: Long.class.getName() };
1165: Object[] finderArgs = new Object[] { new Long(classNameId),
1166: new Long(classPK) };
1167:
1168: Object result = null;
1169:
1170: if (finderClassNameCacheEnabled) {
1171: result = FinderCache.getResult(finderClassName,
1172: finderMethodName, finderParams, finderArgs,
1173: getSessionFactory());
1174: }
1175:
1176: if (result == null) {
1177: Session session = null;
1178:
1179: try {
1180: session = openSession();
1181:
1182: StringMaker query = new StringMaker();
1183:
1184: query
1185: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1186:
1187: query.append("classNameId = ?");
1188:
1189: query.append(" AND ");
1190:
1191: query.append("classPK = ?");
1192:
1193: query.append(" ");
1194:
1195: query.append("ORDER BY ");
1196:
1197: query.append("createDate DESC");
1198:
1199: Query q = session.createQuery(query.toString());
1200:
1201: int queryPos = 0;
1202:
1203: q.setLong(queryPos++, classNameId);
1204:
1205: q.setLong(queryPos++, classPK);
1206:
1207: List list = q.list();
1208:
1209: FinderCache.putResult(finderClassNameCacheEnabled,
1210: finderClassName, finderMethodName,
1211: finderParams, finderArgs, list);
1212:
1213: return list;
1214: } catch (Exception e) {
1215: throw HibernateUtil.processException(e);
1216: } finally {
1217: closeSession(session);
1218: }
1219: } else {
1220: return (List) result;
1221: }
1222: }
1223:
1224: public List findByC_C(long classNameId, long classPK, int begin,
1225: int end) throws SystemException {
1226: return findByC_C(classNameId, classPK, begin, end, null);
1227: }
1228:
1229: public List findByC_C(long classNameId, long classPK, int begin,
1230: int end, OrderByComparator obc) throws SystemException {
1231: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1232: String finderClassName = ActivityTracker.class.getName();
1233: String finderMethodName = "findByC_C";
1234: String[] finderParams = new String[] { Long.class.getName(),
1235: Long.class.getName(),
1236:
1237: "java.lang.Integer", "java.lang.Integer",
1238: "com.liferay.portal.kernel.util.OrderByComparator" };
1239: Object[] finderArgs = new Object[] { new Long(classNameId),
1240: new Long(classPK),
1241:
1242: String.valueOf(begin), String.valueOf(end),
1243: String.valueOf(obc) };
1244:
1245: Object result = null;
1246:
1247: if (finderClassNameCacheEnabled) {
1248: result = FinderCache.getResult(finderClassName,
1249: finderMethodName, finderParams, finderArgs,
1250: getSessionFactory());
1251: }
1252:
1253: if (result == null) {
1254: Session session = null;
1255:
1256: try {
1257: session = openSession();
1258:
1259: StringMaker query = new StringMaker();
1260:
1261: query
1262: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1263:
1264: query.append("classNameId = ?");
1265:
1266: query.append(" AND ");
1267:
1268: query.append("classPK = ?");
1269:
1270: query.append(" ");
1271:
1272: if (obc != null) {
1273: query.append("ORDER BY ");
1274: query.append(obc.getOrderBy());
1275: }
1276:
1277: else {
1278: query.append("ORDER BY ");
1279:
1280: query.append("createDate DESC");
1281: }
1282:
1283: Query q = session.createQuery(query.toString());
1284:
1285: int queryPos = 0;
1286:
1287: q.setLong(queryPos++, classNameId);
1288:
1289: q.setLong(queryPos++, classPK);
1290:
1291: List list = QueryUtil.list(q, getDialect(), begin, end);
1292:
1293: FinderCache.putResult(finderClassNameCacheEnabled,
1294: finderClassName, finderMethodName,
1295: finderParams, finderArgs, list);
1296:
1297: return list;
1298: } catch (Exception e) {
1299: throw HibernateUtil.processException(e);
1300: } finally {
1301: closeSession(session);
1302: }
1303: } else {
1304: return (List) result;
1305: }
1306: }
1307:
1308: public ActivityTracker findByC_C_First(long classNameId,
1309: long classPK, OrderByComparator obc)
1310: throws NoSuchActivityTrackerException, SystemException {
1311: List list = findByC_C(classNameId, classPK, 0, 1, obc);
1312:
1313: if (list.size() == 0) {
1314: StringMaker msg = new StringMaker();
1315:
1316: msg.append("No ActivityTracker exists with the key {");
1317:
1318: msg.append("classNameId=" + classNameId);
1319:
1320: msg.append(", ");
1321: msg.append("classPK=" + classPK);
1322:
1323: msg.append(StringPool.CLOSE_CURLY_BRACE);
1324:
1325: throw new NoSuchActivityTrackerException(msg.toString());
1326: } else {
1327: return (ActivityTracker) list.get(0);
1328: }
1329: }
1330:
1331: public ActivityTracker findByC_C_Last(long classNameId,
1332: long classPK, OrderByComparator obc)
1333: throws NoSuchActivityTrackerException, SystemException {
1334: int count = countByC_C(classNameId, classPK);
1335:
1336: List list = findByC_C(classNameId, classPK, count - 1, count,
1337: obc);
1338:
1339: if (list.size() == 0) {
1340: StringMaker msg = new StringMaker();
1341:
1342: msg.append("No ActivityTracker exists with the key {");
1343:
1344: msg.append("classNameId=" + classNameId);
1345:
1346: msg.append(", ");
1347: msg.append("classPK=" + classPK);
1348:
1349: msg.append(StringPool.CLOSE_CURLY_BRACE);
1350:
1351: throw new NoSuchActivityTrackerException(msg.toString());
1352: } else {
1353: return (ActivityTracker) list.get(0);
1354: }
1355: }
1356:
1357: public ActivityTracker[] findByC_C_PrevAndNext(
1358: long activityTrackerId, long classNameId, long classPK,
1359: OrderByComparator obc)
1360: throws NoSuchActivityTrackerException, SystemException {
1361: ActivityTracker activityTracker = findByPrimaryKey(activityTrackerId);
1362:
1363: int count = countByC_C(classNameId, classPK);
1364:
1365: Session session = null;
1366:
1367: try {
1368: session = openSession();
1369:
1370: StringMaker query = new StringMaker();
1371:
1372: query
1373: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1374:
1375: query.append("classNameId = ?");
1376:
1377: query.append(" AND ");
1378:
1379: query.append("classPK = ?");
1380:
1381: query.append(" ");
1382:
1383: if (obc != null) {
1384: query.append("ORDER BY ");
1385: query.append(obc.getOrderBy());
1386: }
1387:
1388: else {
1389: query.append("ORDER BY ");
1390:
1391: query.append("createDate DESC");
1392: }
1393:
1394: Query q = session.createQuery(query.toString());
1395:
1396: int queryPos = 0;
1397:
1398: q.setLong(queryPos++, classNameId);
1399:
1400: q.setLong(queryPos++, classPK);
1401:
1402: Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1403: activityTracker);
1404:
1405: ActivityTracker[] array = new ActivityTrackerImpl[3];
1406:
1407: array[0] = (ActivityTracker) objArray[0];
1408: array[1] = (ActivityTracker) objArray[1];
1409: array[2] = (ActivityTracker) objArray[2];
1410:
1411: return array;
1412: } catch (Exception e) {
1413: throw HibernateUtil.processException(e);
1414: } finally {
1415: closeSession(session);
1416: }
1417: }
1418:
1419: public List findWithDynamicQuery(
1420: DynamicQueryInitializer queryInitializer)
1421: throws SystemException {
1422: Session session = null;
1423:
1424: try {
1425: session = openSession();
1426:
1427: DynamicQuery query = queryInitializer.initialize(session);
1428:
1429: return query.list();
1430: } catch (Exception e) {
1431: throw HibernateUtil.processException(e);
1432: } finally {
1433: closeSession(session);
1434: }
1435: }
1436:
1437: public List findWithDynamicQuery(
1438: DynamicQueryInitializer queryInitializer, int begin, int end)
1439: throws SystemException {
1440: Session session = null;
1441:
1442: try {
1443: session = openSession();
1444:
1445: DynamicQuery query = queryInitializer.initialize(session);
1446:
1447: query.setLimit(begin, end);
1448:
1449: return query.list();
1450: } catch (Exception e) {
1451: throw HibernateUtil.processException(e);
1452: } finally {
1453: closeSession(session);
1454: }
1455: }
1456:
1457: public List findAll() throws SystemException {
1458: return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1459: }
1460:
1461: public List findAll(int begin, int end) throws SystemException {
1462: return findAll(begin, end, null);
1463: }
1464:
1465: public List findAll(int begin, int end, OrderByComparator obc)
1466: throws SystemException {
1467: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1468: String finderClassName = ActivityTracker.class.getName();
1469: String finderMethodName = "findAll";
1470: String[] finderParams = new String[] { "java.lang.Integer",
1471: "java.lang.Integer",
1472: "com.liferay.portal.kernel.util.OrderByComparator" };
1473: Object[] finderArgs = new Object[] { String.valueOf(begin),
1474: String.valueOf(end), String.valueOf(obc) };
1475:
1476: Object result = null;
1477:
1478: if (finderClassNameCacheEnabled) {
1479: result = FinderCache.getResult(finderClassName,
1480: finderMethodName, finderParams, finderArgs,
1481: getSessionFactory());
1482: }
1483:
1484: if (result == null) {
1485: Session session = null;
1486:
1487: try {
1488: session = openSession();
1489:
1490: StringMaker query = new StringMaker();
1491:
1492: query
1493: .append("FROM com.liferay.portal.model.ActivityTracker ");
1494:
1495: if (obc != null) {
1496: query.append("ORDER BY ");
1497: query.append(obc.getOrderBy());
1498: }
1499:
1500: else {
1501: query.append("ORDER BY ");
1502:
1503: query.append("createDate DESC");
1504: }
1505:
1506: Query q = session.createQuery(query.toString());
1507:
1508: List list = QueryUtil.list(q, getDialect(), begin, end);
1509:
1510: if (obc == null) {
1511: Collections.sort(list);
1512: }
1513:
1514: FinderCache.putResult(finderClassNameCacheEnabled,
1515: finderClassName, finderMethodName,
1516: finderParams, finderArgs, list);
1517:
1518: return list;
1519: } catch (Exception e) {
1520: throw HibernateUtil.processException(e);
1521: } finally {
1522: closeSession(session);
1523: }
1524: } else {
1525: return (List) result;
1526: }
1527: }
1528:
1529: public void removeByGroupId(long groupId) throws SystemException {
1530: Iterator itr = findByGroupId(groupId).iterator();
1531:
1532: while (itr.hasNext()) {
1533: ActivityTracker activityTracker = (ActivityTracker) itr
1534: .next();
1535:
1536: remove(activityTracker);
1537: }
1538: }
1539:
1540: public void removeByCompanyId(long companyId)
1541: throws SystemException {
1542: Iterator itr = findByCompanyId(companyId).iterator();
1543:
1544: while (itr.hasNext()) {
1545: ActivityTracker activityTracker = (ActivityTracker) itr
1546: .next();
1547:
1548: remove(activityTracker);
1549: }
1550: }
1551:
1552: public void removeByUserId(long userId) throws SystemException {
1553: Iterator itr = findByUserId(userId).iterator();
1554:
1555: while (itr.hasNext()) {
1556: ActivityTracker activityTracker = (ActivityTracker) itr
1557: .next();
1558:
1559: remove(activityTracker);
1560: }
1561: }
1562:
1563: public void removeByReceiverUserId(long receiverUserId)
1564: throws SystemException {
1565: Iterator itr = findByReceiverUserId(receiverUserId).iterator();
1566:
1567: while (itr.hasNext()) {
1568: ActivityTracker activityTracker = (ActivityTracker) itr
1569: .next();
1570:
1571: remove(activityTracker);
1572: }
1573: }
1574:
1575: public void removeByC_C(long classNameId, long classPK)
1576: throws SystemException {
1577: Iterator itr = findByC_C(classNameId, classPK).iterator();
1578:
1579: while (itr.hasNext()) {
1580: ActivityTracker activityTracker = (ActivityTracker) itr
1581: .next();
1582:
1583: remove(activityTracker);
1584: }
1585: }
1586:
1587: public void removeAll() throws SystemException {
1588: Iterator itr = findAll().iterator();
1589:
1590: while (itr.hasNext()) {
1591: remove((ActivityTracker) itr.next());
1592: }
1593: }
1594:
1595: public int countByGroupId(long groupId) throws SystemException {
1596: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1597: String finderClassName = ActivityTracker.class.getName();
1598: String finderMethodName = "countByGroupId";
1599: String[] finderParams = new String[] { Long.class.getName() };
1600: Object[] finderArgs = new Object[] { new Long(groupId) };
1601:
1602: Object result = null;
1603:
1604: if (finderClassNameCacheEnabled) {
1605: result = FinderCache.getResult(finderClassName,
1606: finderMethodName, finderParams, finderArgs,
1607: getSessionFactory());
1608: }
1609:
1610: if (result == null) {
1611: Session session = null;
1612:
1613: try {
1614: session = openSession();
1615:
1616: StringMaker query = new StringMaker();
1617:
1618: query.append("SELECT COUNT(*) ");
1619: query
1620: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1621:
1622: query.append("groupId = ?");
1623:
1624: query.append(" ");
1625:
1626: Query q = session.createQuery(query.toString());
1627:
1628: int queryPos = 0;
1629:
1630: q.setLong(queryPos++, groupId);
1631:
1632: Long count = null;
1633:
1634: Iterator itr = q.list().iterator();
1635:
1636: if (itr.hasNext()) {
1637: count = (Long) itr.next();
1638: }
1639:
1640: if (count == null) {
1641: count = new Long(0);
1642: }
1643:
1644: FinderCache.putResult(finderClassNameCacheEnabled,
1645: finderClassName, finderMethodName,
1646: finderParams, finderArgs, count);
1647:
1648: return count.intValue();
1649: } catch (Exception e) {
1650: throw HibernateUtil.processException(e);
1651: } finally {
1652: closeSession(session);
1653: }
1654: } else {
1655: return ((Long) result).intValue();
1656: }
1657: }
1658:
1659: public int countByCompanyId(long companyId) throws SystemException {
1660: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1661: String finderClassName = ActivityTracker.class.getName();
1662: String finderMethodName = "countByCompanyId";
1663: String[] finderParams = new String[] { Long.class.getName() };
1664: Object[] finderArgs = new Object[] { new Long(companyId) };
1665:
1666: Object result = null;
1667:
1668: if (finderClassNameCacheEnabled) {
1669: result = FinderCache.getResult(finderClassName,
1670: finderMethodName, finderParams, finderArgs,
1671: getSessionFactory());
1672: }
1673:
1674: if (result == null) {
1675: Session session = null;
1676:
1677: try {
1678: session = openSession();
1679:
1680: StringMaker query = new StringMaker();
1681:
1682: query.append("SELECT COUNT(*) ");
1683: query
1684: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1685:
1686: query.append("companyId = ?");
1687:
1688: query.append(" ");
1689:
1690: Query q = session.createQuery(query.toString());
1691:
1692: int queryPos = 0;
1693:
1694: q.setLong(queryPos++, companyId);
1695:
1696: Long count = null;
1697:
1698: Iterator itr = q.list().iterator();
1699:
1700: if (itr.hasNext()) {
1701: count = (Long) itr.next();
1702: }
1703:
1704: if (count == null) {
1705: count = new Long(0);
1706: }
1707:
1708: FinderCache.putResult(finderClassNameCacheEnabled,
1709: finderClassName, finderMethodName,
1710: finderParams, finderArgs, count);
1711:
1712: return count.intValue();
1713: } catch (Exception e) {
1714: throw HibernateUtil.processException(e);
1715: } finally {
1716: closeSession(session);
1717: }
1718: } else {
1719: return ((Long) result).intValue();
1720: }
1721: }
1722:
1723: public int countByUserId(long userId) throws SystemException {
1724: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1725: String finderClassName = ActivityTracker.class.getName();
1726: String finderMethodName = "countByUserId";
1727: String[] finderParams = new String[] { Long.class.getName() };
1728: Object[] finderArgs = new Object[] { new Long(userId) };
1729:
1730: Object result = null;
1731:
1732: if (finderClassNameCacheEnabled) {
1733: result = FinderCache.getResult(finderClassName,
1734: finderMethodName, finderParams, finderArgs,
1735: getSessionFactory());
1736: }
1737:
1738: if (result == null) {
1739: Session session = null;
1740:
1741: try {
1742: session = openSession();
1743:
1744: StringMaker query = new StringMaker();
1745:
1746: query.append("SELECT COUNT(*) ");
1747: query
1748: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1749:
1750: query.append("userId = ?");
1751:
1752: query.append(" ");
1753:
1754: Query q = session.createQuery(query.toString());
1755:
1756: int queryPos = 0;
1757:
1758: q.setLong(queryPos++, userId);
1759:
1760: Long count = null;
1761:
1762: Iterator itr = q.list().iterator();
1763:
1764: if (itr.hasNext()) {
1765: count = (Long) itr.next();
1766: }
1767:
1768: if (count == null) {
1769: count = new Long(0);
1770: }
1771:
1772: FinderCache.putResult(finderClassNameCacheEnabled,
1773: finderClassName, finderMethodName,
1774: finderParams, finderArgs, count);
1775:
1776: return count.intValue();
1777: } catch (Exception e) {
1778: throw HibernateUtil.processException(e);
1779: } finally {
1780: closeSession(session);
1781: }
1782: } else {
1783: return ((Long) result).intValue();
1784: }
1785: }
1786:
1787: public int countByReceiverUserId(long receiverUserId)
1788: throws SystemException {
1789: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1790: String finderClassName = ActivityTracker.class.getName();
1791: String finderMethodName = "countByReceiverUserId";
1792: String[] finderParams = new String[] { Long.class.getName() };
1793: Object[] finderArgs = new Object[] { new Long(receiverUserId) };
1794:
1795: Object result = null;
1796:
1797: if (finderClassNameCacheEnabled) {
1798: result = FinderCache.getResult(finderClassName,
1799: finderMethodName, finderParams, finderArgs,
1800: getSessionFactory());
1801: }
1802:
1803: if (result == null) {
1804: Session session = null;
1805:
1806: try {
1807: session = openSession();
1808:
1809: StringMaker query = new StringMaker();
1810:
1811: query.append("SELECT COUNT(*) ");
1812: query
1813: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1814:
1815: query.append("receiverUserId = ?");
1816:
1817: query.append(" ");
1818:
1819: Query q = session.createQuery(query.toString());
1820:
1821: int queryPos = 0;
1822:
1823: q.setLong(queryPos++, receiverUserId);
1824:
1825: Long count = null;
1826:
1827: Iterator itr = q.list().iterator();
1828:
1829: if (itr.hasNext()) {
1830: count = (Long) itr.next();
1831: }
1832:
1833: if (count == null) {
1834: count = new Long(0);
1835: }
1836:
1837: FinderCache.putResult(finderClassNameCacheEnabled,
1838: finderClassName, finderMethodName,
1839: finderParams, finderArgs, count);
1840:
1841: return count.intValue();
1842: } catch (Exception e) {
1843: throw HibernateUtil.processException(e);
1844: } finally {
1845: closeSession(session);
1846: }
1847: } else {
1848: return ((Long) result).intValue();
1849: }
1850: }
1851:
1852: public int countByC_C(long classNameId, long classPK)
1853: throws SystemException {
1854: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1855: String finderClassName = ActivityTracker.class.getName();
1856: String finderMethodName = "countByC_C";
1857: String[] finderParams = new String[] { Long.class.getName(),
1858: Long.class.getName() };
1859: Object[] finderArgs = new Object[] { new Long(classNameId),
1860: new Long(classPK) };
1861:
1862: Object result = null;
1863:
1864: if (finderClassNameCacheEnabled) {
1865: result = FinderCache.getResult(finderClassName,
1866: finderMethodName, finderParams, finderArgs,
1867: getSessionFactory());
1868: }
1869:
1870: if (result == null) {
1871: Session session = null;
1872:
1873: try {
1874: session = openSession();
1875:
1876: StringMaker query = new StringMaker();
1877:
1878: query.append("SELECT COUNT(*) ");
1879: query
1880: .append("FROM com.liferay.portal.model.ActivityTracker WHERE ");
1881:
1882: query.append("classNameId = ?");
1883:
1884: query.append(" AND ");
1885:
1886: query.append("classPK = ?");
1887:
1888: query.append(" ");
1889:
1890: Query q = session.createQuery(query.toString());
1891:
1892: int queryPos = 0;
1893:
1894: q.setLong(queryPos++, classNameId);
1895:
1896: q.setLong(queryPos++, classPK);
1897:
1898: Long count = null;
1899:
1900: Iterator itr = q.list().iterator();
1901:
1902: if (itr.hasNext()) {
1903: count = (Long) itr.next();
1904: }
1905:
1906: if (count == null) {
1907: count = new Long(0);
1908: }
1909:
1910: FinderCache.putResult(finderClassNameCacheEnabled,
1911: finderClassName, finderMethodName,
1912: finderParams, finderArgs, count);
1913:
1914: return count.intValue();
1915: } catch (Exception e) {
1916: throw HibernateUtil.processException(e);
1917: } finally {
1918: closeSession(session);
1919: }
1920: } else {
1921: return ((Long) result).intValue();
1922: }
1923: }
1924:
1925: public int countAll() throws SystemException {
1926: boolean finderClassNameCacheEnabled = ActivityTrackerModelImpl.CACHE_ENABLED;
1927: String finderClassName = ActivityTracker.class.getName();
1928: String finderMethodName = "countAll";
1929: String[] finderParams = new String[] {};
1930: Object[] finderArgs = new Object[] {};
1931:
1932: Object result = null;
1933:
1934: if (finderClassNameCacheEnabled) {
1935: result = FinderCache.getResult(finderClassName,
1936: finderMethodName, finderParams, finderArgs,
1937: getSessionFactory());
1938: }
1939:
1940: if (result == null) {
1941: Session session = null;
1942:
1943: try {
1944: session = openSession();
1945:
1946: Query q = session
1947: .createQuery("SELECT COUNT(*) FROM com.liferay.portal.model.ActivityTracker");
1948:
1949: Long count = null;
1950:
1951: Iterator itr = q.list().iterator();
1952:
1953: if (itr.hasNext()) {
1954: count = (Long) itr.next();
1955: }
1956:
1957: if (count == null) {
1958: count = new Long(0);
1959: }
1960:
1961: FinderCache.putResult(finderClassNameCacheEnabled,
1962: finderClassName, finderMethodName,
1963: finderParams, finderArgs, count);
1964:
1965: return count.intValue();
1966: } catch (Exception e) {
1967: throw HibernateUtil.processException(e);
1968: } finally {
1969: closeSession(session);
1970: }
1971: } else {
1972: return ((Long) result).intValue();
1973: }
1974: }
1975:
1976: protected void initDao() {
1977: }
1978:
1979: private static ModelListener _getListener() {
1980: if (Validator.isNotNull(_LISTENER)) {
1981: try {
1982: return (ModelListener) Class.forName(_LISTENER)
1983: .newInstance();
1984: } catch (Exception e) {
1985: _log.error(e);
1986: }
1987: }
1988:
1989: return null;
1990: }
1991:
1992: private static final String _LISTENER = GetterUtil
1993: .getString(PropsUtil
1994: .get("value.object.listener.com.liferay.portal.model.ActivityTracker"));
1995: private static Log _log = LogFactory
1996: .getLog(ActivityTrackerPersistenceImpl.class);
1997: }
|