001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchWorkflowInstanceLinkException;
019 import com.liferay.portal.kernel.annotation.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.model.WorkflowInstanceLink;
039 import com.liferay.portal.model.impl.WorkflowInstanceLinkImpl;
040 import com.liferay.portal.model.impl.WorkflowInstanceLinkModelImpl;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import java.io.Serializable;
044
045 import java.util.ArrayList;
046 import java.util.Collections;
047 import java.util.List;
048
049
065 public class WorkflowInstanceLinkPersistenceImpl extends BasePersistenceImpl<WorkflowInstanceLink>
066 implements WorkflowInstanceLinkPersistence {
067 public static final String FINDER_CLASS_NAME_ENTITY = WorkflowInstanceLinkImpl.class.getName();
068 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
069 ".List";
070 public static final FinderPath FINDER_PATH_FIND_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
071 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
072 FINDER_CLASS_NAME_LIST, "findByG_C_C_C",
073 new String[] {
074 Long.class.getName(), Long.class.getName(), Long.class.getName(),
075 Long.class.getName(),
076
077 "java.lang.Integer", "java.lang.Integer",
078 "com.liferay.portal.kernel.util.OrderByComparator"
079 });
080 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
081 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
082 FINDER_CLASS_NAME_LIST, "countByG_C_C_C",
083 new String[] {
084 Long.class.getName(), Long.class.getName(), Long.class.getName(),
085 Long.class.getName()
086 });
087 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
088 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
089 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
091 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
092 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
093
094
099 public void cacheResult(WorkflowInstanceLink workflowInstanceLink) {
100 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
101 WorkflowInstanceLinkImpl.class,
102 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
103 }
104
105
110 public void cacheResult(List<WorkflowInstanceLink> workflowInstanceLinks) {
111 for (WorkflowInstanceLink workflowInstanceLink : workflowInstanceLinks) {
112 if (EntityCacheUtil.getResult(
113 WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
114 WorkflowInstanceLinkImpl.class,
115 workflowInstanceLink.getPrimaryKey(), this) == null) {
116 cacheResult(workflowInstanceLink);
117 }
118 }
119 }
120
121
128 public void clearCache() {
129 CacheRegistryUtil.clear(WorkflowInstanceLinkImpl.class.getName());
130 EntityCacheUtil.clearCache(WorkflowInstanceLinkImpl.class.getName());
131 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
132 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
133 }
134
135
142 public void clearCache(WorkflowInstanceLink workflowInstanceLink) {
143 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
144 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
145 }
146
147
153 public WorkflowInstanceLink create(long workflowInstanceLinkId) {
154 WorkflowInstanceLink workflowInstanceLink = new WorkflowInstanceLinkImpl();
155
156 workflowInstanceLink.setNew(true);
157 workflowInstanceLink.setPrimaryKey(workflowInstanceLinkId);
158
159 return workflowInstanceLink;
160 }
161
162
170 public WorkflowInstanceLink remove(Serializable primaryKey)
171 throws NoSuchModelException, SystemException {
172 return remove(((Long)primaryKey).longValue());
173 }
174
175
183 public WorkflowInstanceLink remove(long workflowInstanceLinkId)
184 throws NoSuchWorkflowInstanceLinkException, SystemException {
185 Session session = null;
186
187 try {
188 session = openSession();
189
190 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
191 new Long(workflowInstanceLinkId));
192
193 if (workflowInstanceLink == null) {
194 if (_log.isWarnEnabled()) {
195 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
196 workflowInstanceLinkId);
197 }
198
199 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
200 workflowInstanceLinkId);
201 }
202
203 return remove(workflowInstanceLink);
204 }
205 catch (NoSuchWorkflowInstanceLinkException nsee) {
206 throw nsee;
207 }
208 catch (Exception e) {
209 throw processException(e);
210 }
211 finally {
212 closeSession(session);
213 }
214 }
215
216 protected WorkflowInstanceLink removeImpl(
217 WorkflowInstanceLink workflowInstanceLink) throws SystemException {
218 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
219
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 BatchSessionUtil.delete(session, workflowInstanceLink);
226 }
227 catch (Exception e) {
228 throw processException(e);
229 }
230 finally {
231 closeSession(session);
232 }
233
234 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
235
236 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
237 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
238
239 return workflowInstanceLink;
240 }
241
242 public WorkflowInstanceLink updateImpl(
243 com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink,
244 boolean merge) throws SystemException {
245 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
246
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 BatchSessionUtil.update(session, workflowInstanceLink, merge);
253
254 workflowInstanceLink.setNew(false);
255 }
256 catch (Exception e) {
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264
265 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
266 WorkflowInstanceLinkImpl.class,
267 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
268
269 return workflowInstanceLink;
270 }
271
272 protected WorkflowInstanceLink toUnwrappedModel(
273 WorkflowInstanceLink workflowInstanceLink) {
274 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
275 return workflowInstanceLink;
276 }
277
278 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
279
280 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
281 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
282
283 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
284 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
285 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
286 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
287 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
288 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
289 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
290 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
291 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
292 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
293
294 return workflowInstanceLinkImpl;
295 }
296
297
305 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
306 throws NoSuchModelException, SystemException {
307 return findByPrimaryKey(((Long)primaryKey).longValue());
308 }
309
310
318 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
319 throws NoSuchWorkflowInstanceLinkException, SystemException {
320 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
321
322 if (workflowInstanceLink == null) {
323 if (_log.isWarnEnabled()) {
324 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
325 workflowInstanceLinkId);
326 }
327
328 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329 workflowInstanceLinkId);
330 }
331
332 return workflowInstanceLink;
333 }
334
335
342 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
343 throws SystemException {
344 return fetchByPrimaryKey(((Long)primaryKey).longValue());
345 }
346
347
354 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
355 throws SystemException {
356 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
357 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId, this);
358
359 if (workflowInstanceLink == null) {
360 Session session = null;
361
362 try {
363 session = openSession();
364
365 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
366 new Long(workflowInstanceLinkId));
367 }
368 catch (Exception e) {
369 throw processException(e);
370 }
371 finally {
372 if (workflowInstanceLink != null) {
373 cacheResult(workflowInstanceLink);
374 }
375
376 closeSession(session);
377 }
378 }
379
380 return workflowInstanceLink;
381 }
382
383
393 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
394 long companyId, long classNameId, long classPK)
395 throws SystemException {
396 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
397 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
398 }
399
400
416 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
417 long companyId, long classNameId, long classPK, int start, int end)
418 throws SystemException {
419 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
420 end, null);
421 }
422
423
440 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
441 long companyId, long classNameId, long classPK, int start, int end,
442 OrderByComparator orderByComparator) throws SystemException {
443 Object[] finderArgs = new Object[] {
444 groupId, companyId, classNameId, classPK,
445
446 String.valueOf(start), String.valueOf(end),
447 String.valueOf(orderByComparator)
448 };
449
450 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_C_C,
451 finderArgs, this);
452
453 if (list == null) {
454 Session session = null;
455
456 try {
457 session = openSession();
458
459 StringBundler query = null;
460
461 if (orderByComparator != null) {
462 query = new StringBundler(6 +
463 (orderByComparator.getOrderByFields().length * 3));
464 }
465 else {
466 query = new StringBundler(6);
467 }
468
469 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
470
471 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
472
473 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
474
475 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
476
477 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
478
479 if (orderByComparator != null) {
480 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
481 orderByComparator);
482 }
483
484 else {
485 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
486 }
487
488 String sql = query.toString();
489
490 Query q = session.createQuery(sql);
491
492 QueryPos qPos = QueryPos.getInstance(q);
493
494 qPos.add(groupId);
495
496 qPos.add(companyId);
497
498 qPos.add(classNameId);
499
500 qPos.add(classPK);
501
502 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
503 getDialect(), start, end);
504 }
505 catch (Exception e) {
506 throw processException(e);
507 }
508 finally {
509 if (list == null) {
510 list = new ArrayList<WorkflowInstanceLink>();
511 }
512
513 cacheResult(list);
514
515 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_C_C,
516 finderArgs, list);
517
518 closeSession(session);
519 }
520 }
521
522 return list;
523 }
524
525
541 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
542 long companyId, long classNameId, long classPK,
543 OrderByComparator orderByComparator)
544 throws NoSuchWorkflowInstanceLinkException, SystemException {
545 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
546 classNameId, classPK, 0, 1, orderByComparator);
547
548 if (list.isEmpty()) {
549 StringBundler msg = new StringBundler(10);
550
551 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
552
553 msg.append("groupId=");
554 msg.append(groupId);
555
556 msg.append(", companyId=");
557 msg.append(companyId);
558
559 msg.append(", classNameId=");
560 msg.append(classNameId);
561
562 msg.append(", classPK=");
563 msg.append(classPK);
564
565 msg.append(StringPool.CLOSE_CURLY_BRACE);
566
567 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
568 }
569 else {
570 return list.get(0);
571 }
572 }
573
574
590 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
591 long companyId, long classNameId, long classPK,
592 OrderByComparator orderByComparator)
593 throws NoSuchWorkflowInstanceLinkException, SystemException {
594 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
595
596 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
597 classNameId, classPK, count - 1, count, orderByComparator);
598
599 if (list.isEmpty()) {
600 StringBundler msg = new StringBundler(10);
601
602 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
603
604 msg.append("groupId=");
605 msg.append(groupId);
606
607 msg.append(", companyId=");
608 msg.append(companyId);
609
610 msg.append(", classNameId=");
611 msg.append(classNameId);
612
613 msg.append(", classPK=");
614 msg.append(classPK);
615
616 msg.append(StringPool.CLOSE_CURLY_BRACE);
617
618 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
619 }
620 else {
621 return list.get(0);
622 }
623 }
624
625
642 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
643 long workflowInstanceLinkId, long groupId, long companyId,
644 long classNameId, long classPK, OrderByComparator orderByComparator)
645 throws NoSuchWorkflowInstanceLinkException, SystemException {
646 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
647
648 Session session = null;
649
650 try {
651 session = openSession();
652
653 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
654
655 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
656 groupId, companyId, classNameId, classPK,
657 orderByComparator, true);
658
659 array[1] = workflowInstanceLink;
660
661 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
662 groupId, companyId, classNameId, classPK,
663 orderByComparator, false);
664
665 return array;
666 }
667 catch (Exception e) {
668 throw processException(e);
669 }
670 finally {
671 closeSession(session);
672 }
673 }
674
675 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
676 WorkflowInstanceLink workflowInstanceLink, long groupId,
677 long companyId, long classNameId, long classPK,
678 OrderByComparator orderByComparator, boolean previous) {
679 StringBundler query = null;
680
681 if (orderByComparator != null) {
682 query = new StringBundler(6 +
683 (orderByComparator.getOrderByFields().length * 6));
684 }
685 else {
686 query = new StringBundler(3);
687 }
688
689 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
690
691 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
692
693 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
694
695 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
696
697 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
698
699 if (orderByComparator != null) {
700 String[] orderByFields = orderByComparator.getOrderByFields();
701
702 if (orderByFields.length > 0) {
703 query.append(WHERE_AND);
704 }
705
706 for (int i = 0; i < orderByFields.length; i++) {
707 query.append(_ORDER_BY_ENTITY_ALIAS);
708 query.append(orderByFields[i]);
709
710 if ((i + 1) < orderByFields.length) {
711 if (orderByComparator.isAscending() ^ previous) {
712 query.append(WHERE_GREATER_THAN_HAS_NEXT);
713 }
714 else {
715 query.append(WHERE_LESSER_THAN_HAS_NEXT);
716 }
717 }
718 else {
719 if (orderByComparator.isAscending() ^ previous) {
720 query.append(WHERE_GREATER_THAN);
721 }
722 else {
723 query.append(WHERE_LESSER_THAN);
724 }
725 }
726 }
727
728 query.append(ORDER_BY_CLAUSE);
729
730 for (int i = 0; i < orderByFields.length; i++) {
731 query.append(_ORDER_BY_ENTITY_ALIAS);
732 query.append(orderByFields[i]);
733
734 if ((i + 1) < orderByFields.length) {
735 if (orderByComparator.isAscending() ^ previous) {
736 query.append(ORDER_BY_ASC_HAS_NEXT);
737 }
738 else {
739 query.append(ORDER_BY_DESC_HAS_NEXT);
740 }
741 }
742 else {
743 if (orderByComparator.isAscending() ^ previous) {
744 query.append(ORDER_BY_ASC);
745 }
746 else {
747 query.append(ORDER_BY_DESC);
748 }
749 }
750 }
751 }
752
753 else {
754 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
755 }
756
757 String sql = query.toString();
758
759 Query q = session.createQuery(sql);
760
761 q.setFirstResult(0);
762 q.setMaxResults(2);
763
764 QueryPos qPos = QueryPos.getInstance(q);
765
766 qPos.add(groupId);
767
768 qPos.add(companyId);
769
770 qPos.add(classNameId);
771
772 qPos.add(classPK);
773
774 if (orderByComparator != null) {
775 Object[] values = orderByComparator.getOrderByValues(workflowInstanceLink);
776
777 for (Object value : values) {
778 qPos.add(value);
779 }
780 }
781
782 List<WorkflowInstanceLink> list = q.list();
783
784 if (list.size() == 2) {
785 return list.get(1);
786 }
787 else {
788 return null;
789 }
790 }
791
792
798 public List<WorkflowInstanceLink> findAll() throws SystemException {
799 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
800 }
801
802
814 public List<WorkflowInstanceLink> findAll(int start, int end)
815 throws SystemException {
816 return findAll(start, end, null);
817 }
818
819
832 public List<WorkflowInstanceLink> findAll(int start, int end,
833 OrderByComparator orderByComparator) throws SystemException {
834 Object[] finderArgs = new Object[] {
835 String.valueOf(start), String.valueOf(end),
836 String.valueOf(orderByComparator)
837 };
838
839 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
840 finderArgs, this);
841
842 if (list == null) {
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 StringBundler query = null;
849 String sql = null;
850
851 if (orderByComparator != null) {
852 query = new StringBundler(2 +
853 (orderByComparator.getOrderByFields().length * 3));
854
855 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
856
857 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
858 orderByComparator);
859
860 sql = query.toString();
861 }
862 else {
863 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
864 }
865
866 Query q = session.createQuery(sql);
867
868 if (orderByComparator == null) {
869 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
870 getDialect(), start, end, false);
871
872 Collections.sort(list);
873 }
874 else {
875 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
876 getDialect(), start, end);
877 }
878 }
879 catch (Exception e) {
880 throw processException(e);
881 }
882 finally {
883 if (list == null) {
884 list = new ArrayList<WorkflowInstanceLink>();
885 }
886
887 cacheResult(list);
888
889 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
890
891 closeSession(session);
892 }
893 }
894
895 return list;
896 }
897
898
907 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
908 long classPK) throws SystemException {
909 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
910 groupId, companyId, classNameId, classPK)) {
911 remove(workflowInstanceLink);
912 }
913 }
914
915
920 public void removeAll() throws SystemException {
921 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
922 remove(workflowInstanceLink);
923 }
924 }
925
926
936 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
937 long classPK) throws SystemException {
938 Object[] finderArgs = new Object[] {
939 groupId, companyId, classNameId, classPK
940 };
941
942 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
943 finderArgs, this);
944
945 if (count == null) {
946 Session session = null;
947
948 try {
949 session = openSession();
950
951 StringBundler query = new StringBundler(5);
952
953 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
954
955 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
956
957 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
958
959 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
960
961 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
962
963 String sql = query.toString();
964
965 Query q = session.createQuery(sql);
966
967 QueryPos qPos = QueryPos.getInstance(q);
968
969 qPos.add(groupId);
970
971 qPos.add(companyId);
972
973 qPos.add(classNameId);
974
975 qPos.add(classPK);
976
977 count = (Long)q.uniqueResult();
978 }
979 catch (Exception e) {
980 throw processException(e);
981 }
982 finally {
983 if (count == null) {
984 count = Long.valueOf(0);
985 }
986
987 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
988 finderArgs, count);
989
990 closeSession(session);
991 }
992 }
993
994 return count.intValue();
995 }
996
997
1003 public int countAll() throws SystemException {
1004 Object[] finderArgs = new Object[0];
1005
1006 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1007 finderArgs, this);
1008
1009 if (count == null) {
1010 Session session = null;
1011
1012 try {
1013 session = openSession();
1014
1015 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1016
1017 count = (Long)q.uniqueResult();
1018 }
1019 catch (Exception e) {
1020 throw processException(e);
1021 }
1022 finally {
1023 if (count == null) {
1024 count = Long.valueOf(0);
1025 }
1026
1027 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1028 count);
1029
1030 closeSession(session);
1031 }
1032 }
1033
1034 return count.intValue();
1035 }
1036
1037
1040 public void afterPropertiesSet() {
1041 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1042 com.liferay.portal.util.PropsUtil.get(
1043 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1044
1045 if (listenerClassNames.length > 0) {
1046 try {
1047 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1048
1049 for (String listenerClassName : listenerClassNames) {
1050 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1051 listenerClassName));
1052 }
1053
1054 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1055 }
1056 catch (Exception e) {
1057 _log.error(e);
1058 }
1059 }
1060 }
1061
1062 public void destroy() {
1063 EntityCacheUtil.removeCache(WorkflowInstanceLinkImpl.class.getName());
1064 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1065 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1066 }
1067
1068 @BeanReference(type = AccountPersistence.class)
1069 protected AccountPersistence accountPersistence;
1070 @BeanReference(type = AddressPersistence.class)
1071 protected AddressPersistence addressPersistence;
1072 @BeanReference(type = BrowserTrackerPersistence.class)
1073 protected BrowserTrackerPersistence browserTrackerPersistence;
1074 @BeanReference(type = ClassNamePersistence.class)
1075 protected ClassNamePersistence classNamePersistence;
1076 @BeanReference(type = ClusterGroupPersistence.class)
1077 protected ClusterGroupPersistence clusterGroupPersistence;
1078 @BeanReference(type = CompanyPersistence.class)
1079 protected CompanyPersistence companyPersistence;
1080 @BeanReference(type = ContactPersistence.class)
1081 protected ContactPersistence contactPersistence;
1082 @BeanReference(type = CountryPersistence.class)
1083 protected CountryPersistence countryPersistence;
1084 @BeanReference(type = EmailAddressPersistence.class)
1085 protected EmailAddressPersistence emailAddressPersistence;
1086 @BeanReference(type = GroupPersistence.class)
1087 protected GroupPersistence groupPersistence;
1088 @BeanReference(type = ImagePersistence.class)
1089 protected ImagePersistence imagePersistence;
1090 @BeanReference(type = LayoutPersistence.class)
1091 protected LayoutPersistence layoutPersistence;
1092 @BeanReference(type = LayoutPrototypePersistence.class)
1093 protected LayoutPrototypePersistence layoutPrototypePersistence;
1094 @BeanReference(type = LayoutSetPersistence.class)
1095 protected LayoutSetPersistence layoutSetPersistence;
1096 @BeanReference(type = LayoutSetPrototypePersistence.class)
1097 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1098 @BeanReference(type = ListTypePersistence.class)
1099 protected ListTypePersistence listTypePersistence;
1100 @BeanReference(type = LockPersistence.class)
1101 protected LockPersistence lockPersistence;
1102 @BeanReference(type = MembershipRequestPersistence.class)
1103 protected MembershipRequestPersistence membershipRequestPersistence;
1104 @BeanReference(type = OrganizationPersistence.class)
1105 protected OrganizationPersistence organizationPersistence;
1106 @BeanReference(type = OrgGroupPermissionPersistence.class)
1107 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1108 @BeanReference(type = OrgGroupRolePersistence.class)
1109 protected OrgGroupRolePersistence orgGroupRolePersistence;
1110 @BeanReference(type = OrgLaborPersistence.class)
1111 protected OrgLaborPersistence orgLaborPersistence;
1112 @BeanReference(type = PasswordPolicyPersistence.class)
1113 protected PasswordPolicyPersistence passwordPolicyPersistence;
1114 @BeanReference(type = PasswordPolicyRelPersistence.class)
1115 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1116 @BeanReference(type = PasswordTrackerPersistence.class)
1117 protected PasswordTrackerPersistence passwordTrackerPersistence;
1118 @BeanReference(type = PermissionPersistence.class)
1119 protected PermissionPersistence permissionPersistence;
1120 @BeanReference(type = PhonePersistence.class)
1121 protected PhonePersistence phonePersistence;
1122 @BeanReference(type = PluginSettingPersistence.class)
1123 protected PluginSettingPersistence pluginSettingPersistence;
1124 @BeanReference(type = PortletPersistence.class)
1125 protected PortletPersistence portletPersistence;
1126 @BeanReference(type = PortletItemPersistence.class)
1127 protected PortletItemPersistence portletItemPersistence;
1128 @BeanReference(type = PortletPreferencesPersistence.class)
1129 protected PortletPreferencesPersistence portletPreferencesPersistence;
1130 @BeanReference(type = RegionPersistence.class)
1131 protected RegionPersistence regionPersistence;
1132 @BeanReference(type = ReleasePersistence.class)
1133 protected ReleasePersistence releasePersistence;
1134 @BeanReference(type = ResourcePersistence.class)
1135 protected ResourcePersistence resourcePersistence;
1136 @BeanReference(type = ResourceActionPersistence.class)
1137 protected ResourceActionPersistence resourceActionPersistence;
1138 @BeanReference(type = ResourceCodePersistence.class)
1139 protected ResourceCodePersistence resourceCodePersistence;
1140 @BeanReference(type = ResourcePermissionPersistence.class)
1141 protected ResourcePermissionPersistence resourcePermissionPersistence;
1142 @BeanReference(type = RolePersistence.class)
1143 protected RolePersistence rolePersistence;
1144 @BeanReference(type = ServiceComponentPersistence.class)
1145 protected ServiceComponentPersistence serviceComponentPersistence;
1146 @BeanReference(type = ShardPersistence.class)
1147 protected ShardPersistence shardPersistence;
1148 @BeanReference(type = SubscriptionPersistence.class)
1149 protected SubscriptionPersistence subscriptionPersistence;
1150 @BeanReference(type = TicketPersistence.class)
1151 protected TicketPersistence ticketPersistence;
1152 @BeanReference(type = TeamPersistence.class)
1153 protected TeamPersistence teamPersistence;
1154 @BeanReference(type = UserPersistence.class)
1155 protected UserPersistence userPersistence;
1156 @BeanReference(type = UserGroupPersistence.class)
1157 protected UserGroupPersistence userGroupPersistence;
1158 @BeanReference(type = UserGroupGroupRolePersistence.class)
1159 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1160 @BeanReference(type = UserGroupRolePersistence.class)
1161 protected UserGroupRolePersistence userGroupRolePersistence;
1162 @BeanReference(type = UserIdMapperPersistence.class)
1163 protected UserIdMapperPersistence userIdMapperPersistence;
1164 @BeanReference(type = UserTrackerPersistence.class)
1165 protected UserTrackerPersistence userTrackerPersistence;
1166 @BeanReference(type = UserTrackerPathPersistence.class)
1167 protected UserTrackerPathPersistence userTrackerPathPersistence;
1168 @BeanReference(type = WebDAVPropsPersistence.class)
1169 protected WebDAVPropsPersistence webDAVPropsPersistence;
1170 @BeanReference(type = WebsitePersistence.class)
1171 protected WebsitePersistence websitePersistence;
1172 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1173 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1174 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1175 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1176 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
1177 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1178 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
1179 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1180 private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
1181 private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
1182 private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
1183 private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
1184 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
1185 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
1186 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
1187 private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
1188 }