1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.NoSuchWorkflowDefinitionLinkException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24 import com.liferay.portal.kernel.dao.orm.FinderPath;
25 import com.liferay.portal.kernel.dao.orm.Query;
26 import com.liferay.portal.kernel.dao.orm.QueryPos;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.dao.orm.Session;
29 import com.liferay.portal.kernel.exception.SystemException;
30 import com.liferay.portal.kernel.log.Log;
31 import com.liferay.portal.kernel.log.LogFactoryUtil;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.OrderByComparator;
34 import com.liferay.portal.kernel.util.StringBundler;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.model.WorkflowDefinitionLink;
39 import com.liferay.portal.model.impl.WorkflowDefinitionLinkImpl;
40 import com.liferay.portal.model.impl.WorkflowDefinitionLinkModelImpl;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import java.io.Serializable;
44
45 import java.util.ArrayList;
46 import java.util.Collections;
47 import java.util.List;
48
49
62 public class WorkflowDefinitionLinkPersistenceImpl extends BasePersistenceImpl<WorkflowDefinitionLink>
63 implements WorkflowDefinitionLinkPersistence {
64 public static final String FINDER_CLASS_NAME_ENTITY = WorkflowDefinitionLinkImpl.class.getName();
65 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66 ".List";
67 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
68 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
69 FINDER_CLASS_NAME_LIST, "findByCompanyId",
70 new String[] { Long.class.getName() });
71 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
72 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
73 FINDER_CLASS_NAME_LIST, "findByCompanyId",
74 new String[] {
75 Long.class.getName(),
76
77 "java.lang.Integer", "java.lang.Integer",
78 "com.liferay.portal.kernel.util.OrderByComparator"
79 });
80 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
81 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
82 FINDER_CLASS_NAME_LIST, "countByCompanyId",
83 new String[] { Long.class.getName() });
84 public static final FinderPath FINDER_PATH_FETCH_BY_G_C_C = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
85 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
86 FINDER_CLASS_NAME_ENTITY, "fetchByG_C_C",
87 new String[] {
88 Long.class.getName(), Long.class.getName(), Long.class.getName()
89 });
90 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
91 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_LIST, "countByG_C_C",
93 new String[] {
94 Long.class.getName(), Long.class.getName(), Long.class.getName()
95 });
96 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
97 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
99 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
100 WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
101 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
102
103 public void cacheResult(WorkflowDefinitionLink workflowDefinitionLink) {
104 EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
105 WorkflowDefinitionLinkImpl.class,
106 workflowDefinitionLink.getPrimaryKey(), workflowDefinitionLink);
107
108 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C,
109 new Object[] {
110 new Long(workflowDefinitionLink.getGroupId()),
111 new Long(workflowDefinitionLink.getCompanyId()),
112 new Long(workflowDefinitionLink.getClassNameId())
113 }, workflowDefinitionLink);
114 }
115
116 public void cacheResult(
117 List<WorkflowDefinitionLink> workflowDefinitionLinks) {
118 for (WorkflowDefinitionLink workflowDefinitionLink : workflowDefinitionLinks) {
119 if (EntityCacheUtil.getResult(
120 WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
121 WorkflowDefinitionLinkImpl.class,
122 workflowDefinitionLink.getPrimaryKey(), this) == null) {
123 cacheResult(workflowDefinitionLink);
124 }
125 }
126 }
127
128 public void clearCache() {
129 CacheRegistry.clear(WorkflowDefinitionLinkImpl.class.getName());
130 EntityCacheUtil.clearCache(WorkflowDefinitionLinkImpl.class.getName());
131 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
132 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
133 }
134
135 public WorkflowDefinitionLink create(long workflowDefinitionLinkId) {
136 WorkflowDefinitionLink workflowDefinitionLink = new WorkflowDefinitionLinkImpl();
137
138 workflowDefinitionLink.setNew(true);
139 workflowDefinitionLink.setPrimaryKey(workflowDefinitionLinkId);
140
141 return workflowDefinitionLink;
142 }
143
144 public WorkflowDefinitionLink remove(Serializable primaryKey)
145 throws NoSuchModelException, SystemException {
146 return remove(((Long)primaryKey).longValue());
147 }
148
149 public WorkflowDefinitionLink remove(long workflowDefinitionLinkId)
150 throws NoSuchWorkflowDefinitionLinkException, SystemException {
151 Session session = null;
152
153 try {
154 session = openSession();
155
156 WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)session.get(WorkflowDefinitionLinkImpl.class,
157 new Long(workflowDefinitionLinkId));
158
159 if (workflowDefinitionLink == null) {
160 if (_log.isWarnEnabled()) {
161 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
162 workflowDefinitionLinkId);
163 }
164
165 throw new NoSuchWorkflowDefinitionLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
166 workflowDefinitionLinkId);
167 }
168
169 return remove(workflowDefinitionLink);
170 }
171 catch (NoSuchWorkflowDefinitionLinkException nsee) {
172 throw nsee;
173 }
174 catch (Exception e) {
175 throw processException(e);
176 }
177 finally {
178 closeSession(session);
179 }
180 }
181
182 public WorkflowDefinitionLink remove(
183 WorkflowDefinitionLink workflowDefinitionLink)
184 throws SystemException {
185 for (ModelListener<WorkflowDefinitionLink> listener : listeners) {
186 listener.onBeforeRemove(workflowDefinitionLink);
187 }
188
189 workflowDefinitionLink = removeImpl(workflowDefinitionLink);
190
191 for (ModelListener<WorkflowDefinitionLink> listener : listeners) {
192 listener.onAfterRemove(workflowDefinitionLink);
193 }
194
195 return workflowDefinitionLink;
196 }
197
198 protected WorkflowDefinitionLink removeImpl(
199 WorkflowDefinitionLink workflowDefinitionLink)
200 throws SystemException {
201 workflowDefinitionLink = toUnwrappedModel(workflowDefinitionLink);
202
203 Session session = null;
204
205 try {
206 session = openSession();
207
208 if (workflowDefinitionLink.isCachedModel() ||
209 BatchSessionUtil.isEnabled()) {
210 Object staleObject = session.get(WorkflowDefinitionLinkImpl.class,
211 workflowDefinitionLink.getPrimaryKeyObj());
212
213 if (staleObject != null) {
214 session.evict(staleObject);
215 }
216 }
217
218 session.delete(workflowDefinitionLink);
219
220 session.flush();
221 }
222 catch (Exception e) {
223 throw processException(e);
224 }
225 finally {
226 closeSession(session);
227 }
228
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
230
231 WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
232
233 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C,
234 new Object[] {
235 new Long(workflowDefinitionLinkModelImpl.getOriginalGroupId()),
236 new Long(workflowDefinitionLinkModelImpl.getOriginalCompanyId()),
237 new Long(workflowDefinitionLinkModelImpl.getOriginalClassNameId())
238 });
239
240 EntityCacheUtil.removeResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
241 WorkflowDefinitionLinkImpl.class,
242 workflowDefinitionLink.getPrimaryKey());
243
244 return workflowDefinitionLink;
245 }
246
247 public WorkflowDefinitionLink updateImpl(
248 com.liferay.portal.model.WorkflowDefinitionLink workflowDefinitionLink,
249 boolean merge) throws SystemException {
250 workflowDefinitionLink = toUnwrappedModel(workflowDefinitionLink);
251
252 boolean isNew = workflowDefinitionLink.isNew();
253
254 WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
255
256 Session session = null;
257
258 try {
259 session = openSession();
260
261 BatchSessionUtil.update(session, workflowDefinitionLink, merge);
262
263 workflowDefinitionLink.setNew(false);
264 }
265 catch (Exception e) {
266 throw processException(e);
267 }
268 finally {
269 closeSession(session);
270 }
271
272 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
273
274 EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
275 WorkflowDefinitionLinkImpl.class,
276 workflowDefinitionLink.getPrimaryKey(), workflowDefinitionLink);
277
278 if (!isNew &&
279 ((workflowDefinitionLink.getGroupId() != workflowDefinitionLinkModelImpl.getOriginalGroupId()) ||
280 (workflowDefinitionLink.getCompanyId() != workflowDefinitionLinkModelImpl.getOriginalCompanyId()) ||
281 (workflowDefinitionLink.getClassNameId() != workflowDefinitionLinkModelImpl.getOriginalClassNameId()))) {
282 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C,
283 new Object[] {
284 new Long(workflowDefinitionLinkModelImpl.getOriginalGroupId()),
285 new Long(workflowDefinitionLinkModelImpl.getOriginalCompanyId()),
286 new Long(workflowDefinitionLinkModelImpl.getOriginalClassNameId())
287 });
288 }
289
290 if (isNew ||
291 ((workflowDefinitionLink.getGroupId() != workflowDefinitionLinkModelImpl.getOriginalGroupId()) ||
292 (workflowDefinitionLink.getCompanyId() != workflowDefinitionLinkModelImpl.getOriginalCompanyId()) ||
293 (workflowDefinitionLink.getClassNameId() != workflowDefinitionLinkModelImpl.getOriginalClassNameId()))) {
294 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C,
295 new Object[] {
296 new Long(workflowDefinitionLink.getGroupId()),
297 new Long(workflowDefinitionLink.getCompanyId()),
298 new Long(workflowDefinitionLink.getClassNameId())
299 }, workflowDefinitionLink);
300 }
301
302 return workflowDefinitionLink;
303 }
304
305 protected WorkflowDefinitionLink toUnwrappedModel(
306 WorkflowDefinitionLink workflowDefinitionLink) {
307 if (workflowDefinitionLink instanceof WorkflowDefinitionLinkImpl) {
308 return workflowDefinitionLink;
309 }
310
311 WorkflowDefinitionLinkImpl workflowDefinitionLinkImpl = new WorkflowDefinitionLinkImpl();
312
313 workflowDefinitionLinkImpl.setNew(workflowDefinitionLink.isNew());
314 workflowDefinitionLinkImpl.setPrimaryKey(workflowDefinitionLink.getPrimaryKey());
315
316 workflowDefinitionLinkImpl.setWorkflowDefinitionLinkId(workflowDefinitionLink.getWorkflowDefinitionLinkId());
317 workflowDefinitionLinkImpl.setGroupId(workflowDefinitionLink.getGroupId());
318 workflowDefinitionLinkImpl.setCompanyId(workflowDefinitionLink.getCompanyId());
319 workflowDefinitionLinkImpl.setUserId(workflowDefinitionLink.getUserId());
320 workflowDefinitionLinkImpl.setUserName(workflowDefinitionLink.getUserName());
321 workflowDefinitionLinkImpl.setCreateDate(workflowDefinitionLink.getCreateDate());
322 workflowDefinitionLinkImpl.setModifiedDate(workflowDefinitionLink.getModifiedDate());
323 workflowDefinitionLinkImpl.setClassNameId(workflowDefinitionLink.getClassNameId());
324 workflowDefinitionLinkImpl.setWorkflowDefinitionName(workflowDefinitionLink.getWorkflowDefinitionName());
325 workflowDefinitionLinkImpl.setWorkflowDefinitionVersion(workflowDefinitionLink.getWorkflowDefinitionVersion());
326
327 return workflowDefinitionLinkImpl;
328 }
329
330 public WorkflowDefinitionLink findByPrimaryKey(Serializable primaryKey)
331 throws NoSuchModelException, SystemException {
332 return findByPrimaryKey(((Long)primaryKey).longValue());
333 }
334
335 public WorkflowDefinitionLink findByPrimaryKey(
336 long workflowDefinitionLinkId)
337 throws NoSuchWorkflowDefinitionLinkException, SystemException {
338 WorkflowDefinitionLink workflowDefinitionLink = fetchByPrimaryKey(workflowDefinitionLinkId);
339
340 if (workflowDefinitionLink == null) {
341 if (_log.isWarnEnabled()) {
342 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
343 workflowDefinitionLinkId);
344 }
345
346 throw new NoSuchWorkflowDefinitionLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
347 workflowDefinitionLinkId);
348 }
349
350 return workflowDefinitionLink;
351 }
352
353 public WorkflowDefinitionLink fetchByPrimaryKey(Serializable primaryKey)
354 throws SystemException {
355 return fetchByPrimaryKey(((Long)primaryKey).longValue());
356 }
357
358 public WorkflowDefinitionLink fetchByPrimaryKey(
359 long workflowDefinitionLinkId) throws SystemException {
360 WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)EntityCacheUtil.getResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
361 WorkflowDefinitionLinkImpl.class, workflowDefinitionLinkId, this);
362
363 if (workflowDefinitionLink == null) {
364 Session session = null;
365
366 try {
367 session = openSession();
368
369 workflowDefinitionLink = (WorkflowDefinitionLink)session.get(WorkflowDefinitionLinkImpl.class,
370 new Long(workflowDefinitionLinkId));
371 }
372 catch (Exception e) {
373 throw processException(e);
374 }
375 finally {
376 if (workflowDefinitionLink != null) {
377 cacheResult(workflowDefinitionLink);
378 }
379
380 closeSession(session);
381 }
382 }
383
384 return workflowDefinitionLink;
385 }
386
387 public List<WorkflowDefinitionLink> findByCompanyId(long companyId)
388 throws SystemException {
389 Object[] finderArgs = new Object[] { new Long(companyId) };
390
391 List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
392 finderArgs, this);
393
394 if (list == null) {
395 Session session = null;
396
397 try {
398 session = openSession();
399
400 StringBundler query = new StringBundler(3);
401
402 query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
403
404 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
405
406 query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
407
408 String sql = query.toString();
409
410 Query q = session.createQuery(sql);
411
412 QueryPos qPos = QueryPos.getInstance(q);
413
414 qPos.add(companyId);
415
416 list = q.list();
417 }
418 catch (Exception e) {
419 throw processException(e);
420 }
421 finally {
422 if (list == null) {
423 list = new ArrayList<WorkflowDefinitionLink>();
424 }
425
426 cacheResult(list);
427
428 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
429 finderArgs, list);
430
431 closeSession(session);
432 }
433 }
434
435 return list;
436 }
437
438 public List<WorkflowDefinitionLink> findByCompanyId(long companyId,
439 int start, int end) throws SystemException {
440 return findByCompanyId(companyId, start, end, null);
441 }
442
443 public List<WorkflowDefinitionLink> findByCompanyId(long companyId,
444 int start, int end, OrderByComparator obc) throws SystemException {
445 Object[] finderArgs = new Object[] {
446 new Long(companyId),
447
448 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
449 };
450
451 List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
452 finderArgs, this);
453
454 if (list == null) {
455 Session session = null;
456
457 try {
458 session = openSession();
459
460 StringBundler query = null;
461
462 if (obc != null) {
463 query = new StringBundler(3 +
464 (obc.getOrderByFields().length * 3));
465 }
466 else {
467 query = new StringBundler(3);
468 }
469
470 query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
471
472 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
473
474 if (obc != null) {
475 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
476 }
477
478 else {
479 query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
480 }
481
482 String sql = query.toString();
483
484 Query q = session.createQuery(sql);
485
486 QueryPos qPos = QueryPos.getInstance(q);
487
488 qPos.add(companyId);
489
490 list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
491 getDialect(), start, end);
492 }
493 catch (Exception e) {
494 throw processException(e);
495 }
496 finally {
497 if (list == null) {
498 list = new ArrayList<WorkflowDefinitionLink>();
499 }
500
501 cacheResult(list);
502
503 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
504 finderArgs, list);
505
506 closeSession(session);
507 }
508 }
509
510 return list;
511 }
512
513 public WorkflowDefinitionLink findByCompanyId_First(long companyId,
514 OrderByComparator obc)
515 throws NoSuchWorkflowDefinitionLinkException, SystemException {
516 List<WorkflowDefinitionLink> list = findByCompanyId(companyId, 0, 1, obc);
517
518 if (list.isEmpty()) {
519 StringBundler msg = new StringBundler(4);
520
521 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
522
523 msg.append("companyId=");
524 msg.append(companyId);
525
526 msg.append(StringPool.CLOSE_CURLY_BRACE);
527
528 throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
529 }
530 else {
531 return list.get(0);
532 }
533 }
534
535 public WorkflowDefinitionLink findByCompanyId_Last(long companyId,
536 OrderByComparator obc)
537 throws NoSuchWorkflowDefinitionLinkException, SystemException {
538 int count = countByCompanyId(companyId);
539
540 List<WorkflowDefinitionLink> list = findByCompanyId(companyId,
541 count - 1, count, obc);
542
543 if (list.isEmpty()) {
544 StringBundler msg = new StringBundler(4);
545
546 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
547
548 msg.append("companyId=");
549 msg.append(companyId);
550
551 msg.append(StringPool.CLOSE_CURLY_BRACE);
552
553 throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
554 }
555 else {
556 return list.get(0);
557 }
558 }
559
560 public WorkflowDefinitionLink[] findByCompanyId_PrevAndNext(
561 long workflowDefinitionLinkId, long companyId, OrderByComparator obc)
562 throws NoSuchWorkflowDefinitionLinkException, SystemException {
563 WorkflowDefinitionLink workflowDefinitionLink = findByPrimaryKey(workflowDefinitionLinkId);
564
565 int count = countByCompanyId(companyId);
566
567 Session session = null;
568
569 try {
570 session = openSession();
571
572 StringBundler query = null;
573
574 if (obc != null) {
575 query = new StringBundler(3 +
576 (obc.getOrderByFields().length * 3));
577 }
578 else {
579 query = new StringBundler(3);
580 }
581
582 query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
583
584 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
585
586 if (obc != null) {
587 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
588 }
589
590 else {
591 query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
592 }
593
594 String sql = query.toString();
595
596 Query q = session.createQuery(sql);
597
598 QueryPos qPos = QueryPos.getInstance(q);
599
600 qPos.add(companyId);
601
602 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
603 workflowDefinitionLink);
604
605 WorkflowDefinitionLink[] array = new WorkflowDefinitionLinkImpl[3];
606
607 array[0] = (WorkflowDefinitionLink)objArray[0];
608 array[1] = (WorkflowDefinitionLink)objArray[1];
609 array[2] = (WorkflowDefinitionLink)objArray[2];
610
611 return array;
612 }
613 catch (Exception e) {
614 throw processException(e);
615 }
616 finally {
617 closeSession(session);
618 }
619 }
620
621 public WorkflowDefinitionLink findByG_C_C(long groupId, long companyId,
622 long classNameId)
623 throws NoSuchWorkflowDefinitionLinkException, SystemException {
624 WorkflowDefinitionLink workflowDefinitionLink = fetchByG_C_C(groupId,
625 companyId, classNameId);
626
627 if (workflowDefinitionLink == null) {
628 StringBundler msg = new StringBundler(8);
629
630 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
631
632 msg.append("groupId=");
633 msg.append(groupId);
634
635 msg.append(", companyId=");
636 msg.append(companyId);
637
638 msg.append(", classNameId=");
639 msg.append(classNameId);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 if (_log.isWarnEnabled()) {
644 _log.warn(msg.toString());
645 }
646
647 throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
648 }
649
650 return workflowDefinitionLink;
651 }
652
653 public WorkflowDefinitionLink fetchByG_C_C(long groupId, long companyId,
654 long classNameId) throws SystemException {
655 return fetchByG_C_C(groupId, companyId, classNameId, true);
656 }
657
658 public WorkflowDefinitionLink fetchByG_C_C(long groupId, long companyId,
659 long classNameId, boolean retrieveFromCache) throws SystemException {
660 Object[] finderArgs = new Object[] {
661 new Long(groupId), new Long(companyId), new Long(classNameId)
662 };
663
664 Object result = null;
665
666 if (retrieveFromCache) {
667 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_C,
668 finderArgs, this);
669 }
670
671 if (result == null) {
672 Session session = null;
673
674 try {
675 session = openSession();
676
677 StringBundler query = new StringBundler(5);
678
679 query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
680
681 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
682
683 query.append(_FINDER_COLUMN_G_C_C_COMPANYID_2);
684
685 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
686
687 query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
688
689 String sql = query.toString();
690
691 Query q = session.createQuery(sql);
692
693 QueryPos qPos = QueryPos.getInstance(q);
694
695 qPos.add(groupId);
696
697 qPos.add(companyId);
698
699 qPos.add(classNameId);
700
701 List<WorkflowDefinitionLink> list = q.list();
702
703 result = list;
704
705 WorkflowDefinitionLink workflowDefinitionLink = null;
706
707 if (list.isEmpty()) {
708 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C,
709 finderArgs, list);
710 }
711 else {
712 workflowDefinitionLink = list.get(0);
713
714 cacheResult(workflowDefinitionLink);
715
716 if ((workflowDefinitionLink.getGroupId() != groupId) ||
717 (workflowDefinitionLink.getCompanyId() != companyId) ||
718 (workflowDefinitionLink.getClassNameId() != classNameId)) {
719 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C,
720 finderArgs, workflowDefinitionLink);
721 }
722 }
723
724 return workflowDefinitionLink;
725 }
726 catch (Exception e) {
727 throw processException(e);
728 }
729 finally {
730 if (result == null) {
731 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C,
732 finderArgs, new ArrayList<WorkflowDefinitionLink>());
733 }
734
735 closeSession(session);
736 }
737 }
738 else {
739 if (result instanceof List<?>) {
740 return null;
741 }
742 else {
743 return (WorkflowDefinitionLink)result;
744 }
745 }
746 }
747
748 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
749 throws SystemException {
750 Session session = null;
751
752 try {
753 session = openSession();
754
755 dynamicQuery.compile(session);
756
757 return dynamicQuery.list();
758 }
759 catch (Exception e) {
760 throw processException(e);
761 }
762 finally {
763 closeSession(session);
764 }
765 }
766
767 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
768 int start, int end) throws SystemException {
769 Session session = null;
770
771 try {
772 session = openSession();
773
774 dynamicQuery.setLimit(start, end);
775
776 dynamicQuery.compile(session);
777
778 return dynamicQuery.list();
779 }
780 catch (Exception e) {
781 throw processException(e);
782 }
783 finally {
784 closeSession(session);
785 }
786 }
787
788 public List<WorkflowDefinitionLink> findAll() throws SystemException {
789 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
790 }
791
792 public List<WorkflowDefinitionLink> findAll(int start, int end)
793 throws SystemException {
794 return findAll(start, end, null);
795 }
796
797 public List<WorkflowDefinitionLink> findAll(int start, int end,
798 OrderByComparator obc) throws SystemException {
799 Object[] finderArgs = new Object[] {
800 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
801 };
802
803 List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
804 finderArgs, this);
805
806 if (list == null) {
807 Session session = null;
808
809 try {
810 session = openSession();
811
812 StringBundler query = null;
813 String sql = null;
814
815 if (obc != null) {
816 query = new StringBundler(2 +
817 (obc.getOrderByFields().length * 3));
818
819 query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK);
820
821 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
822
823 sql = query.toString();
824 }
825
826 else {
827 sql = _SQL_SELECT_WORKFLOWDEFINITIONLINK.concat(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
828 }
829
830 Query q = session.createQuery(sql);
831
832 if (obc == null) {
833 list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
834 getDialect(), start, end, false);
835
836 Collections.sort(list);
837 }
838 else {
839 list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
840 getDialect(), start, end);
841 }
842 }
843 catch (Exception e) {
844 throw processException(e);
845 }
846 finally {
847 if (list == null) {
848 list = new ArrayList<WorkflowDefinitionLink>();
849 }
850
851 cacheResult(list);
852
853 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
854
855 closeSession(session);
856 }
857 }
858
859 return list;
860 }
861
862 public void removeByCompanyId(long companyId) throws SystemException {
863 for (WorkflowDefinitionLink workflowDefinitionLink : findByCompanyId(
864 companyId)) {
865 remove(workflowDefinitionLink);
866 }
867 }
868
869 public void removeByG_C_C(long groupId, long companyId, long classNameId)
870 throws NoSuchWorkflowDefinitionLinkException, SystemException {
871 WorkflowDefinitionLink workflowDefinitionLink = findByG_C_C(groupId,
872 companyId, classNameId);
873
874 remove(workflowDefinitionLink);
875 }
876
877 public void removeAll() throws SystemException {
878 for (WorkflowDefinitionLink workflowDefinitionLink : findAll()) {
879 remove(workflowDefinitionLink);
880 }
881 }
882
883 public int countByCompanyId(long companyId) throws SystemException {
884 Object[] finderArgs = new Object[] { new Long(companyId) };
885
886 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
887 finderArgs, this);
888
889 if (count == null) {
890 Session session = null;
891
892 try {
893 session = openSession();
894
895 StringBundler query = new StringBundler(2);
896
897 query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
898
899 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
900
901 String sql = query.toString();
902
903 Query q = session.createQuery(sql);
904
905 QueryPos qPos = QueryPos.getInstance(q);
906
907 qPos.add(companyId);
908
909 count = (Long)q.uniqueResult();
910 }
911 catch (Exception e) {
912 throw processException(e);
913 }
914 finally {
915 if (count == null) {
916 count = Long.valueOf(0);
917 }
918
919 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
920 finderArgs, count);
921
922 closeSession(session);
923 }
924 }
925
926 return count.intValue();
927 }
928
929 public int countByG_C_C(long groupId, long companyId, long classNameId)
930 throws SystemException {
931 Object[] finderArgs = new Object[] {
932 new Long(groupId), new Long(companyId), new Long(classNameId)
933 };
934
935 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
936 finderArgs, this);
937
938 if (count == null) {
939 Session session = null;
940
941 try {
942 session = openSession();
943
944 StringBundler query = new StringBundler(4);
945
946 query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
947
948 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
949
950 query.append(_FINDER_COLUMN_G_C_C_COMPANYID_2);
951
952 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
953
954 String sql = query.toString();
955
956 Query q = session.createQuery(sql);
957
958 QueryPos qPos = QueryPos.getInstance(q);
959
960 qPos.add(groupId);
961
962 qPos.add(companyId);
963
964 qPos.add(classNameId);
965
966 count = (Long)q.uniqueResult();
967 }
968 catch (Exception e) {
969 throw processException(e);
970 }
971 finally {
972 if (count == null) {
973 count = Long.valueOf(0);
974 }
975
976 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
977 finderArgs, count);
978
979 closeSession(session);
980 }
981 }
982
983 return count.intValue();
984 }
985
986 public int countAll() throws SystemException {
987 Object[] finderArgs = new Object[0];
988
989 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
990 finderArgs, this);
991
992 if (count == null) {
993 Session session = null;
994
995 try {
996 session = openSession();
997
998 Query q = session.createQuery(_SQL_COUNT_WORKFLOWDEFINITIONLINK);
999
1000 count = (Long)q.uniqueResult();
1001 }
1002 catch (Exception e) {
1003 throw processException(e);
1004 }
1005 finally {
1006 if (count == null) {
1007 count = Long.valueOf(0);
1008 }
1009
1010 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1011 count);
1012
1013 closeSession(session);
1014 }
1015 }
1016
1017 return count.intValue();
1018 }
1019
1020 public void afterPropertiesSet() {
1021 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1022 com.liferay.portal.util.PropsUtil.get(
1023 "value.object.listener.com.liferay.portal.model.WorkflowDefinitionLink")));
1024
1025 if (listenerClassNames.length > 0) {
1026 try {
1027 List<ModelListener<WorkflowDefinitionLink>> listenersList = new ArrayList<ModelListener<WorkflowDefinitionLink>>();
1028
1029 for (String listenerClassName : listenerClassNames) {
1030 listenersList.add((ModelListener<WorkflowDefinitionLink>)Class.forName(
1031 listenerClassName).newInstance());
1032 }
1033
1034 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1035 }
1036 catch (Exception e) {
1037 _log.error(e);
1038 }
1039 }
1040 }
1041
1042 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
1043 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1044 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
1045 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1046 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
1047 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1048 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
1049 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1050 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
1051 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1052 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
1053 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1054 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
1055 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1056 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
1057 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1058 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1059 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1060 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
1061 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1062 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
1063 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1064 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPrototypePersistence")
1065 protected com.liferay.portal.service.persistence.LayoutPrototypePersistence layoutPrototypePersistence;
1066 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
1067 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1068 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPrototypePersistence")
1069 protected com.liferay.portal.service.persistence.LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1070 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
1071 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1072 @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
1073 protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
1074 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
1075 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1076 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
1077 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1078 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
1079 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1080 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
1081 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1082 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
1083 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1084 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
1085 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1086 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
1087 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1088 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
1089 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1090 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
1091 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1092 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
1093 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1094 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
1095 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1096 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
1097 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1098 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
1099 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1100 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
1101 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1102 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
1103 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1104 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
1105 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1106 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1107 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1108 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
1109 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1110 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
1111 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1112 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
1113 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1114 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
1115 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1116 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
1117 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1118 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
1119 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1120 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
1121 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1122 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1123 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1124 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
1125 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1126 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence")
1127 protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1128 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
1129 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1130 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
1131 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1132 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
1133 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1134 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
1135 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1136 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
1137 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1138 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
1139 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1140 @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence")
1141 protected com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1142 @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence")
1143 protected com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1144 private static final String _SQL_SELECT_WORKFLOWDEFINITIONLINK = "SELECT workflowDefinitionLink FROM WorkflowDefinitionLink workflowDefinitionLink";
1145 private static final String _SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE = "SELECT workflowDefinitionLink FROM WorkflowDefinitionLink workflowDefinitionLink WHERE ";
1146 private static final String _SQL_COUNT_WORKFLOWDEFINITIONLINK = "SELECT COUNT(workflowDefinitionLink) FROM WorkflowDefinitionLink workflowDefinitionLink";
1147 private static final String _SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE = "SELECT COUNT(workflowDefinitionLink) FROM WorkflowDefinitionLink workflowDefinitionLink WHERE ";
1148 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "workflowDefinitionLink.companyId = ?";
1149 private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "workflowDefinitionLink.groupId = ? AND ";
1150 private static final String _FINDER_COLUMN_G_C_C_COMPANYID_2 = "workflowDefinitionLink.companyId = ? AND ";
1151 private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "workflowDefinitionLink.classNameId = ?";
1152 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowDefinitionLink.";
1153 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowDefinitionLink exists with the primary key ";
1154 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowDefinitionLink exists with the key {";
1155 private static Log _log = LogFactoryUtil.getLog(WorkflowDefinitionLinkPersistenceImpl.class);
1156}