001
014
015 package com.liferay.portlet.mobiledevicerules.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.BatchSessionUtil;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.mobiledevicerules.NoSuchActionException;
046 import com.liferay.portlet.mobiledevicerules.model.MDRAction;
047 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionImpl;
048 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionModelImpl;
049
050 import java.io.Serializable;
051
052 import java.util.ArrayList;
053 import java.util.Collections;
054 import java.util.List;
055
056
068 public class MDRActionPersistenceImpl extends BasePersistenceImpl<MDRAction>
069 implements MDRActionPersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = MDRActionImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
081 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
082 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
083 new String[] {
084 String.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
090 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
092 new String[] { String.class.getName() },
093 MDRActionModelImpl.UUID_COLUMN_BITMASK);
094 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
095 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
097 new String[] { String.class.getName() });
098 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
099 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
100 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
101 new String[] { String.class.getName(), Long.class.getName() },
102 MDRActionModelImpl.UUID_COLUMN_BITMASK |
103 MDRActionModelImpl.GROUPID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
105 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
107 new String[] { String.class.getName(), Long.class.getName() });
108 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
109 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
110 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
111 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112 "findByRuleGroupInstanceId",
113 new String[] {
114 Long.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
120 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
121 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
123 "findByRuleGroupInstanceId", new String[] { Long.class.getName() },
124 MDRActionModelImpl.RULEGROUPINSTANCEID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
126 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
128 "countByRuleGroupInstanceId", new String[] { Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
130 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
131 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
132 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
133 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
134 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
136 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
138
139
144 public void cacheResult(MDRAction mdrAction) {
145 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
146 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
147
148 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
149 new Object[] {
150 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
151 }, mdrAction);
152
153 mdrAction.resetOriginalValues();
154 }
155
156
161 public void cacheResult(List<MDRAction> mdrActions) {
162 for (MDRAction mdrAction : mdrActions) {
163 if (EntityCacheUtil.getResult(
164 MDRActionModelImpl.ENTITY_CACHE_ENABLED,
165 MDRActionImpl.class, mdrAction.getPrimaryKey()) == null) {
166 cacheResult(mdrAction);
167 }
168 else {
169 mdrAction.resetOriginalValues();
170 }
171 }
172 }
173
174
181 @Override
182 public void clearCache() {
183 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
184 CacheRegistryUtil.clear(MDRActionImpl.class.getName());
185 }
186
187 EntityCacheUtil.clearCache(MDRActionImpl.class.getName());
188
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
191 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
192 }
193
194
201 @Override
202 public void clearCache(MDRAction mdrAction) {
203 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
204 MDRActionImpl.class, mdrAction.getPrimaryKey());
205
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
207 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
208
209 clearUniqueFindersCache(mdrAction);
210 }
211
212 @Override
213 public void clearCache(List<MDRAction> mdrActions) {
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
215 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
216
217 for (MDRAction mdrAction : mdrActions) {
218 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
219 MDRActionImpl.class, mdrAction.getPrimaryKey());
220
221 clearUniqueFindersCache(mdrAction);
222 }
223 }
224
225 protected void clearUniqueFindersCache(MDRAction mdrAction) {
226 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
227 new Object[] {
228 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
229 });
230 }
231
232
238 public MDRAction create(long actionId) {
239 MDRAction mdrAction = new MDRActionImpl();
240
241 mdrAction.setNew(true);
242 mdrAction.setPrimaryKey(actionId);
243
244 String uuid = PortalUUIDUtil.generate();
245
246 mdrAction.setUuid(uuid);
247
248 return mdrAction;
249 }
250
251
259 public MDRAction remove(long actionId)
260 throws NoSuchActionException, SystemException {
261 return remove(Long.valueOf(actionId));
262 }
263
264
272 @Override
273 public MDRAction remove(Serializable primaryKey)
274 throws NoSuchActionException, SystemException {
275 Session session = null;
276
277 try {
278 session = openSession();
279
280 MDRAction mdrAction = (MDRAction)session.get(MDRActionImpl.class,
281 primaryKey);
282
283 if (mdrAction == null) {
284 if (_log.isWarnEnabled()) {
285 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
286 }
287
288 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
289 primaryKey);
290 }
291
292 return remove(mdrAction);
293 }
294 catch (NoSuchActionException nsee) {
295 throw nsee;
296 }
297 catch (Exception e) {
298 throw processException(e);
299 }
300 finally {
301 closeSession(session);
302 }
303 }
304
305 @Override
306 protected MDRAction removeImpl(MDRAction mdrAction)
307 throws SystemException {
308 mdrAction = toUnwrappedModel(mdrAction);
309
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 BatchSessionUtil.delete(session, mdrAction);
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323
324 clearCache(mdrAction);
325
326 return mdrAction;
327 }
328
329 @Override
330 public MDRAction updateImpl(
331 com.liferay.portlet.mobiledevicerules.model.MDRAction mdrAction,
332 boolean merge) throws SystemException {
333 mdrAction = toUnwrappedModel(mdrAction);
334
335 boolean isNew = mdrAction.isNew();
336
337 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
338
339 if (Validator.isNull(mdrAction.getUuid())) {
340 String uuid = PortalUUIDUtil.generate();
341
342 mdrAction.setUuid(uuid);
343 }
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 BatchSessionUtil.update(session, mdrAction, merge);
351
352 mdrAction.setNew(false);
353 }
354 catch (Exception e) {
355 throw processException(e);
356 }
357 finally {
358 closeSession(session);
359 }
360
361 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
362
363 if (isNew || !MDRActionModelImpl.COLUMN_BITMASK_ENABLED) {
364 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
365 }
366 else {
367 if ((mdrActionModelImpl.getColumnBitmask() &
368 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
369 Object[] args = new Object[] {
370 mdrActionModelImpl.getOriginalUuid()
371 };
372
373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
375 args);
376
377 args = new Object[] { mdrActionModelImpl.getUuid() };
378
379 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
380 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
381 args);
382 }
383
384 if ((mdrActionModelImpl.getColumnBitmask() &
385 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID.getColumnBitmask()) != 0) {
386 Object[] args = new Object[] {
387 Long.valueOf(mdrActionModelImpl.getOriginalRuleGroupInstanceId())
388 };
389
390 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
391 args);
392 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
393 args);
394
395 args = new Object[] {
396 Long.valueOf(mdrActionModelImpl.getRuleGroupInstanceId())
397 };
398
399 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
400 args);
401 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
402 args);
403 }
404 }
405
406 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
407 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
408
409 if (isNew) {
410 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
411 new Object[] {
412 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
413 }, mdrAction);
414 }
415 else {
416 if ((mdrActionModelImpl.getColumnBitmask() &
417 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
418 Object[] args = new Object[] {
419 mdrActionModelImpl.getOriginalUuid(),
420 Long.valueOf(mdrActionModelImpl.getOriginalGroupId())
421 };
422
423 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
424 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
425
426 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
427 new Object[] {
428 mdrAction.getUuid(),
429 Long.valueOf(mdrAction.getGroupId())
430 }, mdrAction);
431 }
432 }
433
434 return mdrAction;
435 }
436
437 protected MDRAction toUnwrappedModel(MDRAction mdrAction) {
438 if (mdrAction instanceof MDRActionImpl) {
439 return mdrAction;
440 }
441
442 MDRActionImpl mdrActionImpl = new MDRActionImpl();
443
444 mdrActionImpl.setNew(mdrAction.isNew());
445 mdrActionImpl.setPrimaryKey(mdrAction.getPrimaryKey());
446
447 mdrActionImpl.setUuid(mdrAction.getUuid());
448 mdrActionImpl.setActionId(mdrAction.getActionId());
449 mdrActionImpl.setGroupId(mdrAction.getGroupId());
450 mdrActionImpl.setCompanyId(mdrAction.getCompanyId());
451 mdrActionImpl.setUserId(mdrAction.getUserId());
452 mdrActionImpl.setUserName(mdrAction.getUserName());
453 mdrActionImpl.setCreateDate(mdrAction.getCreateDate());
454 mdrActionImpl.setModifiedDate(mdrAction.getModifiedDate());
455 mdrActionImpl.setClassNameId(mdrAction.getClassNameId());
456 mdrActionImpl.setClassPK(mdrAction.getClassPK());
457 mdrActionImpl.setRuleGroupInstanceId(mdrAction.getRuleGroupInstanceId());
458 mdrActionImpl.setName(mdrAction.getName());
459 mdrActionImpl.setDescription(mdrAction.getDescription());
460 mdrActionImpl.setType(mdrAction.getType());
461 mdrActionImpl.setTypeSettings(mdrAction.getTypeSettings());
462
463 return mdrActionImpl;
464 }
465
466
474 @Override
475 public MDRAction findByPrimaryKey(Serializable primaryKey)
476 throws NoSuchModelException, SystemException {
477 return findByPrimaryKey(((Long)primaryKey).longValue());
478 }
479
480
488 public MDRAction findByPrimaryKey(long actionId)
489 throws NoSuchActionException, SystemException {
490 MDRAction mdrAction = fetchByPrimaryKey(actionId);
491
492 if (mdrAction == null) {
493 if (_log.isWarnEnabled()) {
494 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + actionId);
495 }
496
497 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
498 actionId);
499 }
500
501 return mdrAction;
502 }
503
504
511 @Override
512 public MDRAction fetchByPrimaryKey(Serializable primaryKey)
513 throws SystemException {
514 return fetchByPrimaryKey(((Long)primaryKey).longValue());
515 }
516
517
524 public MDRAction fetchByPrimaryKey(long actionId) throws SystemException {
525 MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
526 MDRActionImpl.class, actionId);
527
528 if (mdrAction == _nullMDRAction) {
529 return null;
530 }
531
532 if (mdrAction == null) {
533 Session session = null;
534
535 boolean hasException = false;
536
537 try {
538 session = openSession();
539
540 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
541 Long.valueOf(actionId));
542 }
543 catch (Exception e) {
544 hasException = true;
545
546 throw processException(e);
547 }
548 finally {
549 if (mdrAction != null) {
550 cacheResult(mdrAction);
551 }
552 else if (!hasException) {
553 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
554 MDRActionImpl.class, actionId, _nullMDRAction);
555 }
556
557 closeSession(session);
558 }
559 }
560
561 return mdrAction;
562 }
563
564
571 public List<MDRAction> findByUuid(String uuid) throws SystemException {
572 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
573 }
574
575
588 public List<MDRAction> findByUuid(String uuid, int start, int end)
589 throws SystemException {
590 return findByUuid(uuid, start, end, null);
591 }
592
593
607 public List<MDRAction> findByUuid(String uuid, int start, int end,
608 OrderByComparator orderByComparator) throws SystemException {
609 FinderPath finderPath = null;
610 Object[] finderArgs = null;
611
612 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
613 (orderByComparator == null)) {
614 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
615 finderArgs = new Object[] { uuid };
616 }
617 else {
618 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
619 finderArgs = new Object[] { uuid, start, end, orderByComparator };
620 }
621
622 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
623 finderArgs, this);
624
625 if ((list != null) && !list.isEmpty()) {
626 for (MDRAction mdrAction : list) {
627 if (!Validator.equals(uuid, mdrAction.getUuid())) {
628 list = null;
629
630 break;
631 }
632 }
633 }
634
635 if (list == null) {
636 StringBundler query = null;
637
638 if (orderByComparator != null) {
639 query = new StringBundler(3 +
640 (orderByComparator.getOrderByFields().length * 3));
641 }
642 else {
643 query = new StringBundler(2);
644 }
645
646 query.append(_SQL_SELECT_MDRACTION_WHERE);
647
648 if (uuid == null) {
649 query.append(_FINDER_COLUMN_UUID_UUID_1);
650 }
651 else {
652 if (uuid.equals(StringPool.BLANK)) {
653 query.append(_FINDER_COLUMN_UUID_UUID_3);
654 }
655 else {
656 query.append(_FINDER_COLUMN_UUID_UUID_2);
657 }
658 }
659
660 if (orderByComparator != null) {
661 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
662 orderByComparator);
663 }
664
665 String sql = query.toString();
666
667 Session session = null;
668
669 try {
670 session = openSession();
671
672 Query q = session.createQuery(sql);
673
674 QueryPos qPos = QueryPos.getInstance(q);
675
676 if (uuid != null) {
677 qPos.add(uuid);
678 }
679
680 list = (List<MDRAction>)QueryUtil.list(q, getDialect(), start,
681 end);
682 }
683 catch (Exception e) {
684 throw processException(e);
685 }
686 finally {
687 if (list == null) {
688 FinderCacheUtil.removeResult(finderPath, finderArgs);
689 }
690 else {
691 cacheResult(list);
692
693 FinderCacheUtil.putResult(finderPath, finderArgs, list);
694 }
695
696 closeSession(session);
697 }
698 }
699
700 return list;
701 }
702
703
716 public MDRAction findByUuid_First(String uuid,
717 OrderByComparator orderByComparator)
718 throws NoSuchActionException, SystemException {
719 List<MDRAction> list = findByUuid(uuid, 0, 1, orderByComparator);
720
721 if (list.isEmpty()) {
722 StringBundler msg = new StringBundler(4);
723
724 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
725
726 msg.append("uuid=");
727 msg.append(uuid);
728
729 msg.append(StringPool.CLOSE_CURLY_BRACE);
730
731 throw new NoSuchActionException(msg.toString());
732 }
733 else {
734 return list.get(0);
735 }
736 }
737
738
751 public MDRAction findByUuid_Last(String uuid,
752 OrderByComparator orderByComparator)
753 throws NoSuchActionException, SystemException {
754 int count = countByUuid(uuid);
755
756 List<MDRAction> list = findByUuid(uuid, count - 1, count,
757 orderByComparator);
758
759 if (list.isEmpty()) {
760 StringBundler msg = new StringBundler(4);
761
762 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
763
764 msg.append("uuid=");
765 msg.append(uuid);
766
767 msg.append(StringPool.CLOSE_CURLY_BRACE);
768
769 throw new NoSuchActionException(msg.toString());
770 }
771 else {
772 return list.get(0);
773 }
774 }
775
776
790 public MDRAction[] findByUuid_PrevAndNext(long actionId, String uuid,
791 OrderByComparator orderByComparator)
792 throws NoSuchActionException, SystemException {
793 MDRAction mdrAction = findByPrimaryKey(actionId);
794
795 Session session = null;
796
797 try {
798 session = openSession();
799
800 MDRAction[] array = new MDRActionImpl[3];
801
802 array[0] = getByUuid_PrevAndNext(session, mdrAction, uuid,
803 orderByComparator, true);
804
805 array[1] = mdrAction;
806
807 array[2] = getByUuid_PrevAndNext(session, mdrAction, uuid,
808 orderByComparator, false);
809
810 return array;
811 }
812 catch (Exception e) {
813 throw processException(e);
814 }
815 finally {
816 closeSession(session);
817 }
818 }
819
820 protected MDRAction getByUuid_PrevAndNext(Session session,
821 MDRAction mdrAction, String uuid, OrderByComparator orderByComparator,
822 boolean previous) {
823 StringBundler query = null;
824
825 if (orderByComparator != null) {
826 query = new StringBundler(6 +
827 (orderByComparator.getOrderByFields().length * 6));
828 }
829 else {
830 query = new StringBundler(3);
831 }
832
833 query.append(_SQL_SELECT_MDRACTION_WHERE);
834
835 if (uuid == null) {
836 query.append(_FINDER_COLUMN_UUID_UUID_1);
837 }
838 else {
839 if (uuid.equals(StringPool.BLANK)) {
840 query.append(_FINDER_COLUMN_UUID_UUID_3);
841 }
842 else {
843 query.append(_FINDER_COLUMN_UUID_UUID_2);
844 }
845 }
846
847 if (orderByComparator != null) {
848 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
849
850 if (orderByConditionFields.length > 0) {
851 query.append(WHERE_AND);
852 }
853
854 for (int i = 0; i < orderByConditionFields.length; i++) {
855 query.append(_ORDER_BY_ENTITY_ALIAS);
856 query.append(orderByConditionFields[i]);
857
858 if ((i + 1) < orderByConditionFields.length) {
859 if (orderByComparator.isAscending() ^ previous) {
860 query.append(WHERE_GREATER_THAN_HAS_NEXT);
861 }
862 else {
863 query.append(WHERE_LESSER_THAN_HAS_NEXT);
864 }
865 }
866 else {
867 if (orderByComparator.isAscending() ^ previous) {
868 query.append(WHERE_GREATER_THAN);
869 }
870 else {
871 query.append(WHERE_LESSER_THAN);
872 }
873 }
874 }
875
876 query.append(ORDER_BY_CLAUSE);
877
878 String[] orderByFields = orderByComparator.getOrderByFields();
879
880 for (int i = 0; i < orderByFields.length; i++) {
881 query.append(_ORDER_BY_ENTITY_ALIAS);
882 query.append(orderByFields[i]);
883
884 if ((i + 1) < orderByFields.length) {
885 if (orderByComparator.isAscending() ^ previous) {
886 query.append(ORDER_BY_ASC_HAS_NEXT);
887 }
888 else {
889 query.append(ORDER_BY_DESC_HAS_NEXT);
890 }
891 }
892 else {
893 if (orderByComparator.isAscending() ^ previous) {
894 query.append(ORDER_BY_ASC);
895 }
896 else {
897 query.append(ORDER_BY_DESC);
898 }
899 }
900 }
901 }
902
903 String sql = query.toString();
904
905 Query q = session.createQuery(sql);
906
907 q.setFirstResult(0);
908 q.setMaxResults(2);
909
910 QueryPos qPos = QueryPos.getInstance(q);
911
912 if (uuid != null) {
913 qPos.add(uuid);
914 }
915
916 if (orderByComparator != null) {
917 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
918
919 for (Object value : values) {
920 qPos.add(value);
921 }
922 }
923
924 List<MDRAction> list = q.list();
925
926 if (list.size() == 2) {
927 return list.get(1);
928 }
929 else {
930 return null;
931 }
932 }
933
934
943 public MDRAction findByUUID_G(String uuid, long groupId)
944 throws NoSuchActionException, SystemException {
945 MDRAction mdrAction = fetchByUUID_G(uuid, groupId);
946
947 if (mdrAction == null) {
948 StringBundler msg = new StringBundler(6);
949
950 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
951
952 msg.append("uuid=");
953 msg.append(uuid);
954
955 msg.append(", groupId=");
956 msg.append(groupId);
957
958 msg.append(StringPool.CLOSE_CURLY_BRACE);
959
960 if (_log.isWarnEnabled()) {
961 _log.warn(msg.toString());
962 }
963
964 throw new NoSuchActionException(msg.toString());
965 }
966
967 return mdrAction;
968 }
969
970
978 public MDRAction fetchByUUID_G(String uuid, long groupId)
979 throws SystemException {
980 return fetchByUUID_G(uuid, groupId, true);
981 }
982
983
992 public MDRAction fetchByUUID_G(String uuid, long groupId,
993 boolean retrieveFromCache) throws SystemException {
994 Object[] finderArgs = new Object[] { uuid, groupId };
995
996 Object result = null;
997
998 if (retrieveFromCache) {
999 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1000 finderArgs, this);
1001 }
1002
1003 if (result instanceof MDRAction) {
1004 MDRAction mdrAction = (MDRAction)result;
1005
1006 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
1007 (groupId != mdrAction.getGroupId())) {
1008 result = null;
1009 }
1010 }
1011
1012 if (result == null) {
1013 StringBundler query = new StringBundler(3);
1014
1015 query.append(_SQL_SELECT_MDRACTION_WHERE);
1016
1017 if (uuid == null) {
1018 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1019 }
1020 else {
1021 if (uuid.equals(StringPool.BLANK)) {
1022 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1023 }
1024 else {
1025 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1026 }
1027 }
1028
1029 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1030
1031 String sql = query.toString();
1032
1033 Session session = null;
1034
1035 try {
1036 session = openSession();
1037
1038 Query q = session.createQuery(sql);
1039
1040 QueryPos qPos = QueryPos.getInstance(q);
1041
1042 if (uuid != null) {
1043 qPos.add(uuid);
1044 }
1045
1046 qPos.add(groupId);
1047
1048 List<MDRAction> list = q.list();
1049
1050 result = list;
1051
1052 MDRAction mdrAction = null;
1053
1054 if (list.isEmpty()) {
1055 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1056 finderArgs, list);
1057 }
1058 else {
1059 mdrAction = list.get(0);
1060
1061 cacheResult(mdrAction);
1062
1063 if ((mdrAction.getUuid() == null) ||
1064 !mdrAction.getUuid().equals(uuid) ||
1065 (mdrAction.getGroupId() != groupId)) {
1066 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1067 finderArgs, mdrAction);
1068 }
1069 }
1070
1071 return mdrAction;
1072 }
1073 catch (Exception e) {
1074 throw processException(e);
1075 }
1076 finally {
1077 if (result == null) {
1078 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1079 finderArgs);
1080 }
1081
1082 closeSession(session);
1083 }
1084 }
1085 else {
1086 if (result instanceof List<?>) {
1087 return null;
1088 }
1089 else {
1090 return (MDRAction)result;
1091 }
1092 }
1093 }
1094
1095
1102 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId)
1103 throws SystemException {
1104 return findByRuleGroupInstanceId(ruleGroupInstanceId,
1105 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1106 }
1107
1108
1121 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1122 int start, int end) throws SystemException {
1123 return findByRuleGroupInstanceId(ruleGroupInstanceId, start, end, null);
1124 }
1125
1126
1140 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1141 int start, int end, OrderByComparator orderByComparator)
1142 throws SystemException {
1143 FinderPath finderPath = null;
1144 Object[] finderArgs = null;
1145
1146 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1147 (orderByComparator == null)) {
1148 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1149 finderArgs = new Object[] { ruleGroupInstanceId };
1150 }
1151 else {
1152 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1153 finderArgs = new Object[] {
1154 ruleGroupInstanceId,
1155
1156 start, end, orderByComparator
1157 };
1158 }
1159
1160 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1161 finderArgs, this);
1162
1163 if ((list != null) && !list.isEmpty()) {
1164 for (MDRAction mdrAction : list) {
1165 if ((ruleGroupInstanceId != mdrAction.getRuleGroupInstanceId())) {
1166 list = null;
1167
1168 break;
1169 }
1170 }
1171 }
1172
1173 if (list == null) {
1174 StringBundler query = null;
1175
1176 if (orderByComparator != null) {
1177 query = new StringBundler(3 +
1178 (orderByComparator.getOrderByFields().length * 3));
1179 }
1180 else {
1181 query = new StringBundler(2);
1182 }
1183
1184 query.append(_SQL_SELECT_MDRACTION_WHERE);
1185
1186 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1187
1188 if (orderByComparator != null) {
1189 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1190 orderByComparator);
1191 }
1192
1193 String sql = query.toString();
1194
1195 Session session = null;
1196
1197 try {
1198 session = openSession();
1199
1200 Query q = session.createQuery(sql);
1201
1202 QueryPos qPos = QueryPos.getInstance(q);
1203
1204 qPos.add(ruleGroupInstanceId);
1205
1206 list = (List<MDRAction>)QueryUtil.list(q, getDialect(), start,
1207 end);
1208 }
1209 catch (Exception e) {
1210 throw processException(e);
1211 }
1212 finally {
1213 if (list == null) {
1214 FinderCacheUtil.removeResult(finderPath, finderArgs);
1215 }
1216 else {
1217 cacheResult(list);
1218
1219 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1220 }
1221
1222 closeSession(session);
1223 }
1224 }
1225
1226 return list;
1227 }
1228
1229
1242 public MDRAction findByRuleGroupInstanceId_First(long ruleGroupInstanceId,
1243 OrderByComparator orderByComparator)
1244 throws NoSuchActionException, SystemException {
1245 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1246 0, 1, orderByComparator);
1247
1248 if (list.isEmpty()) {
1249 StringBundler msg = new StringBundler(4);
1250
1251 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1252
1253 msg.append("ruleGroupInstanceId=");
1254 msg.append(ruleGroupInstanceId);
1255
1256 msg.append(StringPool.CLOSE_CURLY_BRACE);
1257
1258 throw new NoSuchActionException(msg.toString());
1259 }
1260 else {
1261 return list.get(0);
1262 }
1263 }
1264
1265
1278 public MDRAction findByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1279 OrderByComparator orderByComparator)
1280 throws NoSuchActionException, SystemException {
1281 int count = countByRuleGroupInstanceId(ruleGroupInstanceId);
1282
1283 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1284 count - 1, count, orderByComparator);
1285
1286 if (list.isEmpty()) {
1287 StringBundler msg = new StringBundler(4);
1288
1289 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1290
1291 msg.append("ruleGroupInstanceId=");
1292 msg.append(ruleGroupInstanceId);
1293
1294 msg.append(StringPool.CLOSE_CURLY_BRACE);
1295
1296 throw new NoSuchActionException(msg.toString());
1297 }
1298 else {
1299 return list.get(0);
1300 }
1301 }
1302
1303
1317 public MDRAction[] findByRuleGroupInstanceId_PrevAndNext(long actionId,
1318 long ruleGroupInstanceId, OrderByComparator orderByComparator)
1319 throws NoSuchActionException, SystemException {
1320 MDRAction mdrAction = findByPrimaryKey(actionId);
1321
1322 Session session = null;
1323
1324 try {
1325 session = openSession();
1326
1327 MDRAction[] array = new MDRActionImpl[3];
1328
1329 array[0] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1330 ruleGroupInstanceId, orderByComparator, true);
1331
1332 array[1] = mdrAction;
1333
1334 array[2] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1335 ruleGroupInstanceId, orderByComparator, false);
1336
1337 return array;
1338 }
1339 catch (Exception e) {
1340 throw processException(e);
1341 }
1342 finally {
1343 closeSession(session);
1344 }
1345 }
1346
1347 protected MDRAction getByRuleGroupInstanceId_PrevAndNext(Session session,
1348 MDRAction mdrAction, long ruleGroupInstanceId,
1349 OrderByComparator orderByComparator, boolean previous) {
1350 StringBundler query = null;
1351
1352 if (orderByComparator != null) {
1353 query = new StringBundler(6 +
1354 (orderByComparator.getOrderByFields().length * 6));
1355 }
1356 else {
1357 query = new StringBundler(3);
1358 }
1359
1360 query.append(_SQL_SELECT_MDRACTION_WHERE);
1361
1362 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1363
1364 if (orderByComparator != null) {
1365 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1366
1367 if (orderByConditionFields.length > 0) {
1368 query.append(WHERE_AND);
1369 }
1370
1371 for (int i = 0; i < orderByConditionFields.length; i++) {
1372 query.append(_ORDER_BY_ENTITY_ALIAS);
1373 query.append(orderByConditionFields[i]);
1374
1375 if ((i + 1) < orderByConditionFields.length) {
1376 if (orderByComparator.isAscending() ^ previous) {
1377 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1378 }
1379 else {
1380 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1381 }
1382 }
1383 else {
1384 if (orderByComparator.isAscending() ^ previous) {
1385 query.append(WHERE_GREATER_THAN);
1386 }
1387 else {
1388 query.append(WHERE_LESSER_THAN);
1389 }
1390 }
1391 }
1392
1393 query.append(ORDER_BY_CLAUSE);
1394
1395 String[] orderByFields = orderByComparator.getOrderByFields();
1396
1397 for (int i = 0; i < orderByFields.length; i++) {
1398 query.append(_ORDER_BY_ENTITY_ALIAS);
1399 query.append(orderByFields[i]);
1400
1401 if ((i + 1) < orderByFields.length) {
1402 if (orderByComparator.isAscending() ^ previous) {
1403 query.append(ORDER_BY_ASC_HAS_NEXT);
1404 }
1405 else {
1406 query.append(ORDER_BY_DESC_HAS_NEXT);
1407 }
1408 }
1409 else {
1410 if (orderByComparator.isAscending() ^ previous) {
1411 query.append(ORDER_BY_ASC);
1412 }
1413 else {
1414 query.append(ORDER_BY_DESC);
1415 }
1416 }
1417 }
1418 }
1419
1420 String sql = query.toString();
1421
1422 Query q = session.createQuery(sql);
1423
1424 q.setFirstResult(0);
1425 q.setMaxResults(2);
1426
1427 QueryPos qPos = QueryPos.getInstance(q);
1428
1429 qPos.add(ruleGroupInstanceId);
1430
1431 if (orderByComparator != null) {
1432 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1433
1434 for (Object value : values) {
1435 qPos.add(value);
1436 }
1437 }
1438
1439 List<MDRAction> list = q.list();
1440
1441 if (list.size() == 2) {
1442 return list.get(1);
1443 }
1444 else {
1445 return null;
1446 }
1447 }
1448
1449
1455 public List<MDRAction> findAll() throws SystemException {
1456 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1457 }
1458
1459
1471 public List<MDRAction> findAll(int start, int end)
1472 throws SystemException {
1473 return findAll(start, end, null);
1474 }
1475
1476
1489 public List<MDRAction> findAll(int start, int end,
1490 OrderByComparator orderByComparator) throws SystemException {
1491 FinderPath finderPath = null;
1492 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1493
1494 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1495 (orderByComparator == null)) {
1496 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1497 finderArgs = FINDER_ARGS_EMPTY;
1498 }
1499 else {
1500 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1501 finderArgs = new Object[] { start, end, orderByComparator };
1502 }
1503
1504 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1505 finderArgs, this);
1506
1507 if (list == null) {
1508 StringBundler query = null;
1509 String sql = null;
1510
1511 if (orderByComparator != null) {
1512 query = new StringBundler(2 +
1513 (orderByComparator.getOrderByFields().length * 3));
1514
1515 query.append(_SQL_SELECT_MDRACTION);
1516
1517 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1518 orderByComparator);
1519
1520 sql = query.toString();
1521 }
1522 else {
1523 sql = _SQL_SELECT_MDRACTION;
1524 }
1525
1526 Session session = null;
1527
1528 try {
1529 session = openSession();
1530
1531 Query q = session.createQuery(sql);
1532
1533 if (orderByComparator == null) {
1534 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1535 start, end, false);
1536
1537 Collections.sort(list);
1538 }
1539 else {
1540 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1541 start, end);
1542 }
1543 }
1544 catch (Exception e) {
1545 throw processException(e);
1546 }
1547 finally {
1548 if (list == null) {
1549 FinderCacheUtil.removeResult(finderPath, finderArgs);
1550 }
1551 else {
1552 cacheResult(list);
1553
1554 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1555 }
1556
1557 closeSession(session);
1558 }
1559 }
1560
1561 return list;
1562 }
1563
1564
1570 public void removeByUuid(String uuid) throws SystemException {
1571 for (MDRAction mdrAction : findByUuid(uuid)) {
1572 remove(mdrAction);
1573 }
1574 }
1575
1576
1583 public void removeByUUID_G(String uuid, long groupId)
1584 throws NoSuchActionException, SystemException {
1585 MDRAction mdrAction = findByUUID_G(uuid, groupId);
1586
1587 remove(mdrAction);
1588 }
1589
1590
1596 public void removeByRuleGroupInstanceId(long ruleGroupInstanceId)
1597 throws SystemException {
1598 for (MDRAction mdrAction : findByRuleGroupInstanceId(
1599 ruleGroupInstanceId)) {
1600 remove(mdrAction);
1601 }
1602 }
1603
1604
1609 public void removeAll() throws SystemException {
1610 for (MDRAction mdrAction : findAll()) {
1611 remove(mdrAction);
1612 }
1613 }
1614
1615
1622 public int countByUuid(String uuid) throws SystemException {
1623 Object[] finderArgs = new Object[] { uuid };
1624
1625 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1626 finderArgs, this);
1627
1628 if (count == null) {
1629 StringBundler query = new StringBundler(2);
1630
1631 query.append(_SQL_COUNT_MDRACTION_WHERE);
1632
1633 if (uuid == null) {
1634 query.append(_FINDER_COLUMN_UUID_UUID_1);
1635 }
1636 else {
1637 if (uuid.equals(StringPool.BLANK)) {
1638 query.append(_FINDER_COLUMN_UUID_UUID_3);
1639 }
1640 else {
1641 query.append(_FINDER_COLUMN_UUID_UUID_2);
1642 }
1643 }
1644
1645 String sql = query.toString();
1646
1647 Session session = null;
1648
1649 try {
1650 session = openSession();
1651
1652 Query q = session.createQuery(sql);
1653
1654 QueryPos qPos = QueryPos.getInstance(q);
1655
1656 if (uuid != null) {
1657 qPos.add(uuid);
1658 }
1659
1660 count = (Long)q.uniqueResult();
1661 }
1662 catch (Exception e) {
1663 throw processException(e);
1664 }
1665 finally {
1666 if (count == null) {
1667 count = Long.valueOf(0);
1668 }
1669
1670 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1671 finderArgs, count);
1672
1673 closeSession(session);
1674 }
1675 }
1676
1677 return count.intValue();
1678 }
1679
1680
1688 public int countByUUID_G(String uuid, long groupId)
1689 throws SystemException {
1690 Object[] finderArgs = new Object[] { uuid, groupId };
1691
1692 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1693 finderArgs, this);
1694
1695 if (count == null) {
1696 StringBundler query = new StringBundler(3);
1697
1698 query.append(_SQL_COUNT_MDRACTION_WHERE);
1699
1700 if (uuid == null) {
1701 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1702 }
1703 else {
1704 if (uuid.equals(StringPool.BLANK)) {
1705 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1706 }
1707 else {
1708 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1709 }
1710 }
1711
1712 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1713
1714 String sql = query.toString();
1715
1716 Session session = null;
1717
1718 try {
1719 session = openSession();
1720
1721 Query q = session.createQuery(sql);
1722
1723 QueryPos qPos = QueryPos.getInstance(q);
1724
1725 if (uuid != null) {
1726 qPos.add(uuid);
1727 }
1728
1729 qPos.add(groupId);
1730
1731 count = (Long)q.uniqueResult();
1732 }
1733 catch (Exception e) {
1734 throw processException(e);
1735 }
1736 finally {
1737 if (count == null) {
1738 count = Long.valueOf(0);
1739 }
1740
1741 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1742 finderArgs, count);
1743
1744 closeSession(session);
1745 }
1746 }
1747
1748 return count.intValue();
1749 }
1750
1751
1758 public int countByRuleGroupInstanceId(long ruleGroupInstanceId)
1759 throws SystemException {
1760 Object[] finderArgs = new Object[] { ruleGroupInstanceId };
1761
1762 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
1763 finderArgs, this);
1764
1765 if (count == null) {
1766 StringBundler query = new StringBundler(2);
1767
1768 query.append(_SQL_COUNT_MDRACTION_WHERE);
1769
1770 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1771
1772 String sql = query.toString();
1773
1774 Session session = null;
1775
1776 try {
1777 session = openSession();
1778
1779 Query q = session.createQuery(sql);
1780
1781 QueryPos qPos = QueryPos.getInstance(q);
1782
1783 qPos.add(ruleGroupInstanceId);
1784
1785 count = (Long)q.uniqueResult();
1786 }
1787 catch (Exception e) {
1788 throw processException(e);
1789 }
1790 finally {
1791 if (count == null) {
1792 count = Long.valueOf(0);
1793 }
1794
1795 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
1796 finderArgs, count);
1797
1798 closeSession(session);
1799 }
1800 }
1801
1802 return count.intValue();
1803 }
1804
1805
1811 public int countAll() throws SystemException {
1812 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1813 FINDER_ARGS_EMPTY, this);
1814
1815 if (count == null) {
1816 Session session = null;
1817
1818 try {
1819 session = openSession();
1820
1821 Query q = session.createQuery(_SQL_COUNT_MDRACTION);
1822
1823 count = (Long)q.uniqueResult();
1824 }
1825 catch (Exception e) {
1826 throw processException(e);
1827 }
1828 finally {
1829 if (count == null) {
1830 count = Long.valueOf(0);
1831 }
1832
1833 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1834 FINDER_ARGS_EMPTY, count);
1835
1836 closeSession(session);
1837 }
1838 }
1839
1840 return count.intValue();
1841 }
1842
1843
1846 public void afterPropertiesSet() {
1847 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1848 com.liferay.portal.util.PropsUtil.get(
1849 "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRAction")));
1850
1851 if (listenerClassNames.length > 0) {
1852 try {
1853 List<ModelListener<MDRAction>> listenersList = new ArrayList<ModelListener<MDRAction>>();
1854
1855 for (String listenerClassName : listenerClassNames) {
1856 listenersList.add((ModelListener<MDRAction>)InstanceFactory.newInstance(
1857 listenerClassName));
1858 }
1859
1860 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1861 }
1862 catch (Exception e) {
1863 _log.error(e);
1864 }
1865 }
1866 }
1867
1868 public void destroy() {
1869 EntityCacheUtil.removeCache(MDRActionImpl.class.getName());
1870 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1871 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1872 }
1873
1874 @BeanReference(type = MDRActionPersistence.class)
1875 protected MDRActionPersistence mdrActionPersistence;
1876 @BeanReference(type = MDRRulePersistence.class)
1877 protected MDRRulePersistence mdrRulePersistence;
1878 @BeanReference(type = MDRRuleGroupPersistence.class)
1879 protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
1880 @BeanReference(type = MDRRuleGroupInstancePersistence.class)
1881 protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
1882 @BeanReference(type = ResourcePersistence.class)
1883 protected ResourcePersistence resourcePersistence;
1884 @BeanReference(type = UserPersistence.class)
1885 protected UserPersistence userPersistence;
1886 private static final String _SQL_SELECT_MDRACTION = "SELECT mdrAction FROM MDRAction mdrAction";
1887 private static final String _SQL_SELECT_MDRACTION_WHERE = "SELECT mdrAction FROM MDRAction mdrAction WHERE ";
1888 private static final String _SQL_COUNT_MDRACTION = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction";
1889 private static final String _SQL_COUNT_MDRACTION_WHERE = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction WHERE ";
1890 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrAction.uuid IS NULL";
1891 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrAction.uuid = ?";
1892 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?)";
1893 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrAction.uuid IS NULL AND ";
1894 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrAction.uuid = ? AND ";
1895 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?) AND ";
1896 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrAction.groupId = ?";
1897 private static final String _FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2 =
1898 "mdrAction.ruleGroupInstanceId = ?";
1899 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrAction.";
1900 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRAction exists with the primary key ";
1901 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRAction exists with the key {";
1902 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1903 private static Log _log = LogFactoryUtil.getLog(MDRActionPersistenceImpl.class);
1904 private static MDRAction _nullMDRAction = new MDRActionImpl() {
1905 @Override
1906 public Object clone() {
1907 return this;
1908 }
1909
1910 @Override
1911 public CacheModel<MDRAction> toCacheModel() {
1912 return _nullMDRActionCacheModel;
1913 }
1914 };
1915
1916 private static CacheModel<MDRAction> _nullMDRActionCacheModel = new CacheModel<MDRAction>() {
1917 public MDRAction toEntityModel() {
1918 return _nullMDRAction;
1919 }
1920 };
1921 }