1
22
23 package com.liferay.portlet.documentlibrary.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderPath;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.kernel.util.Validator;
43 import com.liferay.portal.model.ModelListener;
44 import com.liferay.portal.service.persistence.BatchSessionUtil;
45 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
46
47 import com.liferay.portlet.documentlibrary.NoSuchFileRankException;
48 import com.liferay.portlet.documentlibrary.model.DLFileRank;
49 import com.liferay.portlet.documentlibrary.model.impl.DLFileRankImpl;
50 import com.liferay.portlet.documentlibrary.model.impl.DLFileRankModelImpl;
51
52 import java.util.ArrayList;
53 import java.util.Collections;
54 import java.util.List;
55
56
62 public class DLFileRankPersistenceImpl extends BasePersistenceImpl
63 implements DLFileRankPersistence {
64 public static final String FINDER_CLASS_NAME_ENTITY = DLFileRankImpl.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_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
68 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
69 "findByUserId", new String[] { Long.class.getName() });
70 public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
71 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
72 "findByUserId",
73 new String[] {
74 Long.class.getName(),
75
76 "java.lang.Integer", "java.lang.Integer",
77 "com.liferay.portal.kernel.util.OrderByComparator"
78 });
79 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
80 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81 "countByUserId", new String[] { Long.class.getName() });
82 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
83 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84 "findByG_U",
85 new String[] { Long.class.getName(), Long.class.getName() });
86 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
87 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
88 "findByG_U",
89 new String[] {
90 Long.class.getName(), Long.class.getName(),
91
92 "java.lang.Integer", "java.lang.Integer",
93 "com.liferay.portal.kernel.util.OrderByComparator"
94 });
95 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
96 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97 "countByG_U",
98 new String[] { Long.class.getName(), Long.class.getName() });
99 public static final FinderPath FINDER_PATH_FIND_BY_F_N = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
100 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "findByF_N",
102 new String[] { Long.class.getName(), String.class.getName() });
103 public static final FinderPath FINDER_PATH_FIND_BY_OBC_F_N = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
104 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "findByF_N",
106 new String[] {
107 Long.class.getName(), String.class.getName(),
108
109 "java.lang.Integer", "java.lang.Integer",
110 "com.liferay.portal.kernel.util.OrderByComparator"
111 });
112 public static final FinderPath FINDER_PATH_COUNT_BY_F_N = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
113 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114 "countByF_N",
115 new String[] { Long.class.getName(), String.class.getName() });
116 public static final FinderPath FINDER_PATH_FETCH_BY_C_U_F_N = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
117 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
118 "fetchByC_U_F_N",
119 new String[] {
120 Long.class.getName(), Long.class.getName(), Long.class.getName(),
121 String.class.getName()
122 });
123 public static final FinderPath FINDER_PATH_COUNT_BY_C_U_F_N = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
124 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
125 "countByC_U_F_N",
126 new String[] {
127 Long.class.getName(), Long.class.getName(), Long.class.getName(),
128 String.class.getName()
129 });
130 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
131 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
132 "findAll", new String[0]);
133 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
134 DLFileRankModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135 "countAll", new String[0]);
136
137 public void cacheResult(DLFileRank dlFileRank) {
138 EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
139 DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
140
141 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F_N,
142 new Object[] {
143 new Long(dlFileRank.getCompanyId()),
144 new Long(dlFileRank.getUserId()),
145 new Long(dlFileRank.getFolderId()),
146
147 dlFileRank.getName()
148 }, dlFileRank);
149 }
150
151 public void cacheResult(List<DLFileRank> dlFileRanks) {
152 for (DLFileRank dlFileRank : dlFileRanks) {
153 if (EntityCacheUtil.getResult(
154 DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
155 DLFileRankImpl.class, dlFileRank.getPrimaryKey(), this) == null) {
156 cacheResult(dlFileRank);
157 }
158 }
159 }
160
161 public void clearCache() {
162 CacheRegistry.clear(DLFileRankImpl.class.getName());
163 EntityCacheUtil.clearCache(DLFileRankImpl.class.getName());
164 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
166 }
167
168 public DLFileRank create(long fileRankId) {
169 DLFileRank dlFileRank = new DLFileRankImpl();
170
171 dlFileRank.setNew(true);
172 dlFileRank.setPrimaryKey(fileRankId);
173
174 return dlFileRank;
175 }
176
177 public DLFileRank remove(long fileRankId)
178 throws NoSuchFileRankException, SystemException {
179 Session session = null;
180
181 try {
182 session = openSession();
183
184 DLFileRank dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
185 new Long(fileRankId));
186
187 if (dlFileRank == null) {
188 if (_log.isWarnEnabled()) {
189 _log.warn("No DLFileRank exists with the primary key " +
190 fileRankId);
191 }
192
193 throw new NoSuchFileRankException(
194 "No DLFileRank exists with the primary key " + fileRankId);
195 }
196
197 return remove(dlFileRank);
198 }
199 catch (NoSuchFileRankException nsee) {
200 throw nsee;
201 }
202 catch (Exception e) {
203 throw processException(e);
204 }
205 finally {
206 closeSession(session);
207 }
208 }
209
210 public DLFileRank remove(DLFileRank dlFileRank) throws SystemException {
211 for (ModelListener<DLFileRank> listener : listeners) {
212 listener.onBeforeRemove(dlFileRank);
213 }
214
215 dlFileRank = removeImpl(dlFileRank);
216
217 for (ModelListener<DLFileRank> listener : listeners) {
218 listener.onAfterRemove(dlFileRank);
219 }
220
221 return dlFileRank;
222 }
223
224 protected DLFileRank removeImpl(DLFileRank dlFileRank)
225 throws SystemException {
226 Session session = null;
227
228 try {
229 session = openSession();
230
231 if (dlFileRank.isCachedModel() || BatchSessionUtil.isEnabled()) {
232 Object staleObject = session.get(DLFileRankImpl.class,
233 dlFileRank.getPrimaryKeyObj());
234
235 if (staleObject != null) {
236 session.evict(staleObject);
237 }
238 }
239
240 session.delete(dlFileRank);
241
242 session.flush();
243 }
244 catch (Exception e) {
245 throw processException(e);
246 }
247 finally {
248 closeSession(session);
249 }
250
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
252
253 DLFileRankModelImpl dlFileRankModelImpl = (DLFileRankModelImpl)dlFileRank;
254
255 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F_N,
256 new Object[] {
257 new Long(dlFileRankModelImpl.getOriginalCompanyId()),
258 new Long(dlFileRankModelImpl.getOriginalUserId()),
259 new Long(dlFileRankModelImpl.getOriginalFolderId()),
260
261 dlFileRankModelImpl.getOriginalName()
262 });
263
264 EntityCacheUtil.removeResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
265 DLFileRankImpl.class, dlFileRank.getPrimaryKey());
266
267 return dlFileRank;
268 }
269
270
273 public DLFileRank update(DLFileRank dlFileRank) throws SystemException {
274 if (_log.isWarnEnabled()) {
275 _log.warn(
276 "Using the deprecated update(DLFileRank dlFileRank) method. Use update(DLFileRank dlFileRank, boolean merge) instead.");
277 }
278
279 return update(dlFileRank, false);
280 }
281
282
295 public DLFileRank update(DLFileRank dlFileRank, boolean merge)
296 throws SystemException {
297 boolean isNew = dlFileRank.isNew();
298
299 for (ModelListener<DLFileRank> listener : listeners) {
300 if (isNew) {
301 listener.onBeforeCreate(dlFileRank);
302 }
303 else {
304 listener.onBeforeUpdate(dlFileRank);
305 }
306 }
307
308 dlFileRank = updateImpl(dlFileRank, merge);
309
310 for (ModelListener<DLFileRank> listener : listeners) {
311 if (isNew) {
312 listener.onAfterCreate(dlFileRank);
313 }
314 else {
315 listener.onAfterUpdate(dlFileRank);
316 }
317 }
318
319 return dlFileRank;
320 }
321
322 public DLFileRank updateImpl(
323 com.liferay.portlet.documentlibrary.model.DLFileRank dlFileRank,
324 boolean merge) throws SystemException {
325 boolean isNew = dlFileRank.isNew();
326
327 DLFileRankModelImpl dlFileRankModelImpl = (DLFileRankModelImpl)dlFileRank;
328
329 Session session = null;
330
331 try {
332 session = openSession();
333
334 BatchSessionUtil.update(session, dlFileRank, merge);
335
336 dlFileRank.setNew(false);
337 }
338 catch (Exception e) {
339 throw processException(e);
340 }
341 finally {
342 closeSession(session);
343 }
344
345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
346
347 EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
348 DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
349
350 if (!isNew &&
351 ((dlFileRank.getCompanyId() != dlFileRankModelImpl.getOriginalCompanyId()) ||
352 (dlFileRank.getUserId() != dlFileRankModelImpl.getOriginalUserId()) ||
353 (dlFileRank.getFolderId() != dlFileRankModelImpl.getOriginalFolderId()) ||
354 !Validator.equals(dlFileRank.getName(),
355 dlFileRankModelImpl.getOriginalName()))) {
356 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F_N,
357 new Object[] {
358 new Long(dlFileRankModelImpl.getOriginalCompanyId()),
359 new Long(dlFileRankModelImpl.getOriginalUserId()),
360 new Long(dlFileRankModelImpl.getOriginalFolderId()),
361
362 dlFileRankModelImpl.getOriginalName()
363 });
364 }
365
366 if (isNew ||
367 ((dlFileRank.getCompanyId() != dlFileRankModelImpl.getOriginalCompanyId()) ||
368 (dlFileRank.getUserId() != dlFileRankModelImpl.getOriginalUserId()) ||
369 (dlFileRank.getFolderId() != dlFileRankModelImpl.getOriginalFolderId()) ||
370 !Validator.equals(dlFileRank.getName(),
371 dlFileRankModelImpl.getOriginalName()))) {
372 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F_N,
373 new Object[] {
374 new Long(dlFileRank.getCompanyId()),
375 new Long(dlFileRank.getUserId()),
376 new Long(dlFileRank.getFolderId()),
377
378 dlFileRank.getName()
379 }, dlFileRank);
380 }
381
382 return dlFileRank;
383 }
384
385 public DLFileRank findByPrimaryKey(long fileRankId)
386 throws NoSuchFileRankException, SystemException {
387 DLFileRank dlFileRank = fetchByPrimaryKey(fileRankId);
388
389 if (dlFileRank == null) {
390 if (_log.isWarnEnabled()) {
391 _log.warn("No DLFileRank exists with the primary key " +
392 fileRankId);
393 }
394
395 throw new NoSuchFileRankException(
396 "No DLFileRank exists with the primary key " + fileRankId);
397 }
398
399 return dlFileRank;
400 }
401
402 public DLFileRank fetchByPrimaryKey(long fileRankId)
403 throws SystemException {
404 DLFileRank dlFileRank = (DLFileRank)EntityCacheUtil.getResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
405 DLFileRankImpl.class, fileRankId, this);
406
407 if (dlFileRank == null) {
408 Session session = null;
409
410 try {
411 session = openSession();
412
413 dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
414 new Long(fileRankId));
415 }
416 catch (Exception e) {
417 throw processException(e);
418 }
419 finally {
420 if (dlFileRank != null) {
421 cacheResult(dlFileRank);
422 }
423
424 closeSession(session);
425 }
426 }
427
428 return dlFileRank;
429 }
430
431 public List<DLFileRank> findByUserId(long userId) throws SystemException {
432 Object[] finderArgs = new Object[] { new Long(userId) };
433
434 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
435 finderArgs, this);
436
437 if (list == null) {
438 Session session = null;
439
440 try {
441 session = openSession();
442
443 StringBuilder query = new StringBuilder();
444
445 query.append(
446 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
447
448 query.append("userId = ?");
449
450 query.append(" ");
451
452 query.append("ORDER BY ");
453
454 query.append("createDate DESC");
455
456 Query q = session.createQuery(query.toString());
457
458 QueryPos qPos = QueryPos.getInstance(q);
459
460 qPos.add(userId);
461
462 list = q.list();
463 }
464 catch (Exception e) {
465 throw processException(e);
466 }
467 finally {
468 if (list == null) {
469 list = new ArrayList<DLFileRank>();
470 }
471
472 cacheResult(list);
473
474 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
475 finderArgs, list);
476
477 closeSession(session);
478 }
479 }
480
481 return list;
482 }
483
484 public List<DLFileRank> findByUserId(long userId, int start, int end)
485 throws SystemException {
486 return findByUserId(userId, start, end, null);
487 }
488
489 public List<DLFileRank> findByUserId(long userId, int start, int end,
490 OrderByComparator obc) throws SystemException {
491 Object[] finderArgs = new Object[] {
492 new Long(userId),
493
494 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
495 };
496
497 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
498 finderArgs, this);
499
500 if (list == null) {
501 Session session = null;
502
503 try {
504 session = openSession();
505
506 StringBuilder query = new StringBuilder();
507
508 query.append(
509 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
510
511 query.append("userId = ?");
512
513 query.append(" ");
514
515 if (obc != null) {
516 query.append("ORDER BY ");
517 query.append(obc.getOrderBy());
518 }
519
520 else {
521 query.append("ORDER BY ");
522
523 query.append("createDate DESC");
524 }
525
526 Query q = session.createQuery(query.toString());
527
528 QueryPos qPos = QueryPos.getInstance(q);
529
530 qPos.add(userId);
531
532 list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
533 end);
534 }
535 catch (Exception e) {
536 throw processException(e);
537 }
538 finally {
539 if (list == null) {
540 list = new ArrayList<DLFileRank>();
541 }
542
543 cacheResult(list);
544
545 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
546 finderArgs, list);
547
548 closeSession(session);
549 }
550 }
551
552 return list;
553 }
554
555 public DLFileRank findByUserId_First(long userId, OrderByComparator obc)
556 throws NoSuchFileRankException, SystemException {
557 List<DLFileRank> list = findByUserId(userId, 0, 1, obc);
558
559 if (list.isEmpty()) {
560 StringBuilder msg = new StringBuilder();
561
562 msg.append("No DLFileRank exists with the key {");
563
564 msg.append("userId=" + userId);
565
566 msg.append(StringPool.CLOSE_CURLY_BRACE);
567
568 throw new NoSuchFileRankException(msg.toString());
569 }
570 else {
571 return list.get(0);
572 }
573 }
574
575 public DLFileRank findByUserId_Last(long userId, OrderByComparator obc)
576 throws NoSuchFileRankException, SystemException {
577 int count = countByUserId(userId);
578
579 List<DLFileRank> list = findByUserId(userId, count - 1, count, obc);
580
581 if (list.isEmpty()) {
582 StringBuilder msg = new StringBuilder();
583
584 msg.append("No DLFileRank exists with the key {");
585
586 msg.append("userId=" + userId);
587
588 msg.append(StringPool.CLOSE_CURLY_BRACE);
589
590 throw new NoSuchFileRankException(msg.toString());
591 }
592 else {
593 return list.get(0);
594 }
595 }
596
597 public DLFileRank[] findByUserId_PrevAndNext(long fileRankId, long userId,
598 OrderByComparator obc) throws NoSuchFileRankException, SystemException {
599 DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
600
601 int count = countByUserId(userId);
602
603 Session session = null;
604
605 try {
606 session = openSession();
607
608 StringBuilder query = new StringBuilder();
609
610 query.append(
611 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
612
613 query.append("userId = ?");
614
615 query.append(" ");
616
617 if (obc != null) {
618 query.append("ORDER BY ");
619 query.append(obc.getOrderBy());
620 }
621
622 else {
623 query.append("ORDER BY ");
624
625 query.append("createDate DESC");
626 }
627
628 Query q = session.createQuery(query.toString());
629
630 QueryPos qPos = QueryPos.getInstance(q);
631
632 qPos.add(userId);
633
634 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
635 dlFileRank);
636
637 DLFileRank[] array = new DLFileRankImpl[3];
638
639 array[0] = (DLFileRank)objArray[0];
640 array[1] = (DLFileRank)objArray[1];
641 array[2] = (DLFileRank)objArray[2];
642
643 return array;
644 }
645 catch (Exception e) {
646 throw processException(e);
647 }
648 finally {
649 closeSession(session);
650 }
651 }
652
653 public List<DLFileRank> findByG_U(long groupId, long userId)
654 throws SystemException {
655 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
656
657 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
658 finderArgs, this);
659
660 if (list == null) {
661 Session session = null;
662
663 try {
664 session = openSession();
665
666 StringBuilder query = new StringBuilder();
667
668 query.append(
669 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
670
671 query.append("groupId = ?");
672
673 query.append(" AND ");
674
675 query.append("userId = ?");
676
677 query.append(" ");
678
679 query.append("ORDER BY ");
680
681 query.append("createDate DESC");
682
683 Query q = session.createQuery(query.toString());
684
685 QueryPos qPos = QueryPos.getInstance(q);
686
687 qPos.add(groupId);
688
689 qPos.add(userId);
690
691 list = q.list();
692 }
693 catch (Exception e) {
694 throw processException(e);
695 }
696 finally {
697 if (list == null) {
698 list = new ArrayList<DLFileRank>();
699 }
700
701 cacheResult(list);
702
703 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
704 list);
705
706 closeSession(session);
707 }
708 }
709
710 return list;
711 }
712
713 public List<DLFileRank> findByG_U(long groupId, long userId, int start,
714 int end) throws SystemException {
715 return findByG_U(groupId, userId, start, end, null);
716 }
717
718 public List<DLFileRank> findByG_U(long groupId, long userId, int start,
719 int end, OrderByComparator obc) throws SystemException {
720 Object[] finderArgs = new Object[] {
721 new Long(groupId), new Long(userId),
722
723 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
724 };
725
726 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
727 finderArgs, this);
728
729 if (list == null) {
730 Session session = null;
731
732 try {
733 session = openSession();
734
735 StringBuilder query = new StringBuilder();
736
737 query.append(
738 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
739
740 query.append("groupId = ?");
741
742 query.append(" AND ");
743
744 query.append("userId = ?");
745
746 query.append(" ");
747
748 if (obc != null) {
749 query.append("ORDER BY ");
750 query.append(obc.getOrderBy());
751 }
752
753 else {
754 query.append("ORDER BY ");
755
756 query.append("createDate DESC");
757 }
758
759 Query q = session.createQuery(query.toString());
760
761 QueryPos qPos = QueryPos.getInstance(q);
762
763 qPos.add(groupId);
764
765 qPos.add(userId);
766
767 list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
768 end);
769 }
770 catch (Exception e) {
771 throw processException(e);
772 }
773 finally {
774 if (list == null) {
775 list = new ArrayList<DLFileRank>();
776 }
777
778 cacheResult(list);
779
780 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
781 finderArgs, list);
782
783 closeSession(session);
784 }
785 }
786
787 return list;
788 }
789
790 public DLFileRank findByG_U_First(long groupId, long userId,
791 OrderByComparator obc) throws NoSuchFileRankException, SystemException {
792 List<DLFileRank> list = findByG_U(groupId, userId, 0, 1, obc);
793
794 if (list.isEmpty()) {
795 StringBuilder msg = new StringBuilder();
796
797 msg.append("No DLFileRank exists with the key {");
798
799 msg.append("groupId=" + groupId);
800
801 msg.append(", ");
802 msg.append("userId=" + userId);
803
804 msg.append(StringPool.CLOSE_CURLY_BRACE);
805
806 throw new NoSuchFileRankException(msg.toString());
807 }
808 else {
809 return list.get(0);
810 }
811 }
812
813 public DLFileRank findByG_U_Last(long groupId, long userId,
814 OrderByComparator obc) throws NoSuchFileRankException, SystemException {
815 int count = countByG_U(groupId, userId);
816
817 List<DLFileRank> list = findByG_U(groupId, userId, count - 1, count, obc);
818
819 if (list.isEmpty()) {
820 StringBuilder msg = new StringBuilder();
821
822 msg.append("No DLFileRank exists with the key {");
823
824 msg.append("groupId=" + groupId);
825
826 msg.append(", ");
827 msg.append("userId=" + userId);
828
829 msg.append(StringPool.CLOSE_CURLY_BRACE);
830
831 throw new NoSuchFileRankException(msg.toString());
832 }
833 else {
834 return list.get(0);
835 }
836 }
837
838 public DLFileRank[] findByG_U_PrevAndNext(long fileRankId, long groupId,
839 long userId, OrderByComparator obc)
840 throws NoSuchFileRankException, SystemException {
841 DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
842
843 int count = countByG_U(groupId, userId);
844
845 Session session = null;
846
847 try {
848 session = openSession();
849
850 StringBuilder query = new StringBuilder();
851
852 query.append(
853 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
854
855 query.append("groupId = ?");
856
857 query.append(" AND ");
858
859 query.append("userId = ?");
860
861 query.append(" ");
862
863 if (obc != null) {
864 query.append("ORDER BY ");
865 query.append(obc.getOrderBy());
866 }
867
868 else {
869 query.append("ORDER BY ");
870
871 query.append("createDate DESC");
872 }
873
874 Query q = session.createQuery(query.toString());
875
876 QueryPos qPos = QueryPos.getInstance(q);
877
878 qPos.add(groupId);
879
880 qPos.add(userId);
881
882 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
883 dlFileRank);
884
885 DLFileRank[] array = new DLFileRankImpl[3];
886
887 array[0] = (DLFileRank)objArray[0];
888 array[1] = (DLFileRank)objArray[1];
889 array[2] = (DLFileRank)objArray[2];
890
891 return array;
892 }
893 catch (Exception e) {
894 throw processException(e);
895 }
896 finally {
897 closeSession(session);
898 }
899 }
900
901 public List<DLFileRank> findByF_N(long folderId, String name)
902 throws SystemException {
903 Object[] finderArgs = new Object[] { new Long(folderId), name };
904
905 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_F_N,
906 finderArgs, this);
907
908 if (list == null) {
909 Session session = null;
910
911 try {
912 session = openSession();
913
914 StringBuilder query = new StringBuilder();
915
916 query.append(
917 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
918
919 query.append("folderId = ?");
920
921 query.append(" AND ");
922
923 if (name == null) {
924 query.append("name IS NULL");
925 }
926 else {
927 query.append("name = ?");
928 }
929
930 query.append(" ");
931
932 query.append("ORDER BY ");
933
934 query.append("createDate DESC");
935
936 Query q = session.createQuery(query.toString());
937
938 QueryPos qPos = QueryPos.getInstance(q);
939
940 qPos.add(folderId);
941
942 if (name != null) {
943 qPos.add(name);
944 }
945
946 list = q.list();
947 }
948 catch (Exception e) {
949 throw processException(e);
950 }
951 finally {
952 if (list == null) {
953 list = new ArrayList<DLFileRank>();
954 }
955
956 cacheResult(list);
957
958 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_F_N, finderArgs,
959 list);
960
961 closeSession(session);
962 }
963 }
964
965 return list;
966 }
967
968 public List<DLFileRank> findByF_N(long folderId, String name, int start,
969 int end) throws SystemException {
970 return findByF_N(folderId, name, start, end, null);
971 }
972
973 public List<DLFileRank> findByF_N(long folderId, String name, int start,
974 int end, OrderByComparator obc) throws SystemException {
975 Object[] finderArgs = new Object[] {
976 new Long(folderId),
977
978 name,
979
980 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
981 };
982
983 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_F_N,
984 finderArgs, this);
985
986 if (list == null) {
987 Session session = null;
988
989 try {
990 session = openSession();
991
992 StringBuilder query = new StringBuilder();
993
994 query.append(
995 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
996
997 query.append("folderId = ?");
998
999 query.append(" AND ");
1000
1001 if (name == null) {
1002 query.append("name IS NULL");
1003 }
1004 else {
1005 query.append("name = ?");
1006 }
1007
1008 query.append(" ");
1009
1010 if (obc != null) {
1011 query.append("ORDER BY ");
1012 query.append(obc.getOrderBy());
1013 }
1014
1015 else {
1016 query.append("ORDER BY ");
1017
1018 query.append("createDate DESC");
1019 }
1020
1021 Query q = session.createQuery(query.toString());
1022
1023 QueryPos qPos = QueryPos.getInstance(q);
1024
1025 qPos.add(folderId);
1026
1027 if (name != null) {
1028 qPos.add(name);
1029 }
1030
1031 list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1032 end);
1033 }
1034 catch (Exception e) {
1035 throw processException(e);
1036 }
1037 finally {
1038 if (list == null) {
1039 list = new ArrayList<DLFileRank>();
1040 }
1041
1042 cacheResult(list);
1043
1044 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_F_N,
1045 finderArgs, list);
1046
1047 closeSession(session);
1048 }
1049 }
1050
1051 return list;
1052 }
1053
1054 public DLFileRank findByF_N_First(long folderId, String name,
1055 OrderByComparator obc) throws NoSuchFileRankException, SystemException {
1056 List<DLFileRank> list = findByF_N(folderId, name, 0, 1, obc);
1057
1058 if (list.isEmpty()) {
1059 StringBuilder msg = new StringBuilder();
1060
1061 msg.append("No DLFileRank exists with the key {");
1062
1063 msg.append("folderId=" + folderId);
1064
1065 msg.append(", ");
1066 msg.append("name=" + name);
1067
1068 msg.append(StringPool.CLOSE_CURLY_BRACE);
1069
1070 throw new NoSuchFileRankException(msg.toString());
1071 }
1072 else {
1073 return list.get(0);
1074 }
1075 }
1076
1077 public DLFileRank findByF_N_Last(long folderId, String name,
1078 OrderByComparator obc) throws NoSuchFileRankException, SystemException {
1079 int count = countByF_N(folderId, name);
1080
1081 List<DLFileRank> list = findByF_N(folderId, name, count - 1, count, obc);
1082
1083 if (list.isEmpty()) {
1084 StringBuilder msg = new StringBuilder();
1085
1086 msg.append("No DLFileRank exists with the key {");
1087
1088 msg.append("folderId=" + folderId);
1089
1090 msg.append(", ");
1091 msg.append("name=" + name);
1092
1093 msg.append(StringPool.CLOSE_CURLY_BRACE);
1094
1095 throw new NoSuchFileRankException(msg.toString());
1096 }
1097 else {
1098 return list.get(0);
1099 }
1100 }
1101
1102 public DLFileRank[] findByF_N_PrevAndNext(long fileRankId, long folderId,
1103 String name, OrderByComparator obc)
1104 throws NoSuchFileRankException, SystemException {
1105 DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1106
1107 int count = countByF_N(folderId, name);
1108
1109 Session session = null;
1110
1111 try {
1112 session = openSession();
1113
1114 StringBuilder query = new StringBuilder();
1115
1116 query.append(
1117 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
1118
1119 query.append("folderId = ?");
1120
1121 query.append(" AND ");
1122
1123 if (name == null) {
1124 query.append("name IS NULL");
1125 }
1126 else {
1127 query.append("name = ?");
1128 }
1129
1130 query.append(" ");
1131
1132 if (obc != null) {
1133 query.append("ORDER BY ");
1134 query.append(obc.getOrderBy());
1135 }
1136
1137 else {
1138 query.append("ORDER BY ");
1139
1140 query.append("createDate DESC");
1141 }
1142
1143 Query q = session.createQuery(query.toString());
1144
1145 QueryPos qPos = QueryPos.getInstance(q);
1146
1147 qPos.add(folderId);
1148
1149 if (name != null) {
1150 qPos.add(name);
1151 }
1152
1153 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1154 dlFileRank);
1155
1156 DLFileRank[] array = new DLFileRankImpl[3];
1157
1158 array[0] = (DLFileRank)objArray[0];
1159 array[1] = (DLFileRank)objArray[1];
1160 array[2] = (DLFileRank)objArray[2];
1161
1162 return array;
1163 }
1164 catch (Exception e) {
1165 throw processException(e);
1166 }
1167 finally {
1168 closeSession(session);
1169 }
1170 }
1171
1172 public DLFileRank findByC_U_F_N(long companyId, long userId, long folderId,
1173 String name) throws NoSuchFileRankException, SystemException {
1174 DLFileRank dlFileRank = fetchByC_U_F_N(companyId, userId, folderId, name);
1175
1176 if (dlFileRank == null) {
1177 StringBuilder msg = new StringBuilder();
1178
1179 msg.append("No DLFileRank exists with the key {");
1180
1181 msg.append("companyId=" + companyId);
1182
1183 msg.append(", ");
1184 msg.append("userId=" + userId);
1185
1186 msg.append(", ");
1187 msg.append("folderId=" + folderId);
1188
1189 msg.append(", ");
1190 msg.append("name=" + name);
1191
1192 msg.append(StringPool.CLOSE_CURLY_BRACE);
1193
1194 if (_log.isWarnEnabled()) {
1195 _log.warn(msg.toString());
1196 }
1197
1198 throw new NoSuchFileRankException(msg.toString());
1199 }
1200
1201 return dlFileRank;
1202 }
1203
1204 public DLFileRank fetchByC_U_F_N(long companyId, long userId,
1205 long folderId, String name) throws SystemException {
1206 return fetchByC_U_F_N(companyId, userId, folderId, name, true);
1207 }
1208
1209 public DLFileRank fetchByC_U_F_N(long companyId, long userId,
1210 long folderId, String name, boolean retrieveFromCache)
1211 throws SystemException {
1212 Object[] finderArgs = new Object[] {
1213 new Long(companyId), new Long(userId), new Long(folderId),
1214
1215 name
1216 };
1217
1218 Object result = null;
1219
1220 if (retrieveFromCache) {
1221 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_F_N,
1222 finderArgs, this);
1223 }
1224
1225 if (result == null) {
1226 Session session = null;
1227
1228 try {
1229 session = openSession();
1230
1231 StringBuilder query = new StringBuilder();
1232
1233 query.append(
1234 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
1235
1236 query.append("companyId = ?");
1237
1238 query.append(" AND ");
1239
1240 query.append("userId = ?");
1241
1242 query.append(" AND ");
1243
1244 query.append("folderId = ?");
1245
1246 query.append(" AND ");
1247
1248 if (name == null) {
1249 query.append("name IS NULL");
1250 }
1251 else {
1252 query.append("name = ?");
1253 }
1254
1255 query.append(" ");
1256
1257 query.append("ORDER BY ");
1258
1259 query.append("createDate DESC");
1260
1261 Query q = session.createQuery(query.toString());
1262
1263 QueryPos qPos = QueryPos.getInstance(q);
1264
1265 qPos.add(companyId);
1266
1267 qPos.add(userId);
1268
1269 qPos.add(folderId);
1270
1271 if (name != null) {
1272 qPos.add(name);
1273 }
1274
1275 List<DLFileRank> list = q.list();
1276
1277 result = list;
1278
1279 DLFileRank dlFileRank = null;
1280
1281 if (list.isEmpty()) {
1282 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F_N,
1283 finderArgs, list);
1284 }
1285 else {
1286 dlFileRank = list.get(0);
1287
1288 cacheResult(dlFileRank);
1289
1290 if ((dlFileRank.getCompanyId() != companyId) ||
1291 (dlFileRank.getUserId() != userId) ||
1292 (dlFileRank.getFolderId() != folderId) ||
1293 (dlFileRank.getName() == null) ||
1294 !dlFileRank.getName().equals(name)) {
1295 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F_N,
1296 finderArgs, dlFileRank);
1297 }
1298 }
1299
1300 return dlFileRank;
1301 }
1302 catch (Exception e) {
1303 throw processException(e);
1304 }
1305 finally {
1306 if (result == null) {
1307 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F_N,
1308 finderArgs, new ArrayList<DLFileRank>());
1309 }
1310
1311 closeSession(session);
1312 }
1313 }
1314 else {
1315 if (result instanceof List) {
1316 return null;
1317 }
1318 else {
1319 return (DLFileRank)result;
1320 }
1321 }
1322 }
1323
1324 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1325 throws SystemException {
1326 Session session = null;
1327
1328 try {
1329 session = openSession();
1330
1331 dynamicQuery.compile(session);
1332
1333 return dynamicQuery.list();
1334 }
1335 catch (Exception e) {
1336 throw processException(e);
1337 }
1338 finally {
1339 closeSession(session);
1340 }
1341 }
1342
1343 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1344 int start, int end) throws SystemException {
1345 Session session = null;
1346
1347 try {
1348 session = openSession();
1349
1350 dynamicQuery.setLimit(start, end);
1351
1352 dynamicQuery.compile(session);
1353
1354 return dynamicQuery.list();
1355 }
1356 catch (Exception e) {
1357 throw processException(e);
1358 }
1359 finally {
1360 closeSession(session);
1361 }
1362 }
1363
1364 public List<DLFileRank> findAll() throws SystemException {
1365 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1366 }
1367
1368 public List<DLFileRank> findAll(int start, int end)
1369 throws SystemException {
1370 return findAll(start, end, null);
1371 }
1372
1373 public List<DLFileRank> findAll(int start, int end, OrderByComparator obc)
1374 throws SystemException {
1375 Object[] finderArgs = new Object[] {
1376 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1377 };
1378
1379 List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1380 finderArgs, this);
1381
1382 if (list == null) {
1383 Session session = null;
1384
1385 try {
1386 session = openSession();
1387
1388 StringBuilder query = new StringBuilder();
1389
1390 query.append(
1391 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank ");
1392
1393 if (obc != null) {
1394 query.append("ORDER BY ");
1395 query.append(obc.getOrderBy());
1396 }
1397
1398 else {
1399 query.append("ORDER BY ");
1400
1401 query.append("createDate DESC");
1402 }
1403
1404 Query q = session.createQuery(query.toString());
1405
1406 if (obc == null) {
1407 list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
1408 start, end, false);
1409
1410 Collections.sort(list);
1411 }
1412 else {
1413 list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
1414 start, end);
1415 }
1416 }
1417 catch (Exception e) {
1418 throw processException(e);
1419 }
1420 finally {
1421 if (list == null) {
1422 list = new ArrayList<DLFileRank>();
1423 }
1424
1425 cacheResult(list);
1426
1427 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1428
1429 closeSession(session);
1430 }
1431 }
1432
1433 return list;
1434 }
1435
1436 public void removeByUserId(long userId) throws SystemException {
1437 for (DLFileRank dlFileRank : findByUserId(userId)) {
1438 remove(dlFileRank);
1439 }
1440 }
1441
1442 public void removeByG_U(long groupId, long userId)
1443 throws SystemException {
1444 for (DLFileRank dlFileRank : findByG_U(groupId, userId)) {
1445 remove(dlFileRank);
1446 }
1447 }
1448
1449 public void removeByF_N(long folderId, String name)
1450 throws SystemException {
1451 for (DLFileRank dlFileRank : findByF_N(folderId, name)) {
1452 remove(dlFileRank);
1453 }
1454 }
1455
1456 public void removeByC_U_F_N(long companyId, long userId, long folderId,
1457 String name) throws NoSuchFileRankException, SystemException {
1458 DLFileRank dlFileRank = findByC_U_F_N(companyId, userId, folderId, name);
1459
1460 remove(dlFileRank);
1461 }
1462
1463 public void removeAll() throws SystemException {
1464 for (DLFileRank dlFileRank : findAll()) {
1465 remove(dlFileRank);
1466 }
1467 }
1468
1469 public int countByUserId(long userId) throws SystemException {
1470 Object[] finderArgs = new Object[] { new Long(userId) };
1471
1472 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1473 finderArgs, this);
1474
1475 if (count == null) {
1476 Session session = null;
1477
1478 try {
1479 session = openSession();
1480
1481 StringBuilder query = new StringBuilder();
1482
1483 query.append("SELECT COUNT(*) ");
1484 query.append(
1485 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
1486
1487 query.append("userId = ?");
1488
1489 query.append(" ");
1490
1491 Query q = session.createQuery(query.toString());
1492
1493 QueryPos qPos = QueryPos.getInstance(q);
1494
1495 qPos.add(userId);
1496
1497 count = (Long)q.uniqueResult();
1498 }
1499 catch (Exception e) {
1500 throw processException(e);
1501 }
1502 finally {
1503 if (count == null) {
1504 count = Long.valueOf(0);
1505 }
1506
1507 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1508 finderArgs, count);
1509
1510 closeSession(session);
1511 }
1512 }
1513
1514 return count.intValue();
1515 }
1516
1517 public int countByG_U(long groupId, long userId) throws SystemException {
1518 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1519
1520 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1521 finderArgs, this);
1522
1523 if (count == null) {
1524 Session session = null;
1525
1526 try {
1527 session = openSession();
1528
1529 StringBuilder query = new StringBuilder();
1530
1531 query.append("SELECT COUNT(*) ");
1532 query.append(
1533 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
1534
1535 query.append("groupId = ?");
1536
1537 query.append(" AND ");
1538
1539 query.append("userId = ?");
1540
1541 query.append(" ");
1542
1543 Query q = session.createQuery(query.toString());
1544
1545 QueryPos qPos = QueryPos.getInstance(q);
1546
1547 qPos.add(groupId);
1548
1549 qPos.add(userId);
1550
1551 count = (Long)q.uniqueResult();
1552 }
1553 catch (Exception e) {
1554 throw processException(e);
1555 }
1556 finally {
1557 if (count == null) {
1558 count = Long.valueOf(0);
1559 }
1560
1561 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1562 count);
1563
1564 closeSession(session);
1565 }
1566 }
1567
1568 return count.intValue();
1569 }
1570
1571 public int countByF_N(long folderId, String name) throws SystemException {
1572 Object[] finderArgs = new Object[] { new Long(folderId), name };
1573
1574 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_N,
1575 finderArgs, this);
1576
1577 if (count == null) {
1578 Session session = null;
1579
1580 try {
1581 session = openSession();
1582
1583 StringBuilder query = new StringBuilder();
1584
1585 query.append("SELECT COUNT(*) ");
1586 query.append(
1587 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
1588
1589 query.append("folderId = ?");
1590
1591 query.append(" AND ");
1592
1593 if (name == null) {
1594 query.append("name IS NULL");
1595 }
1596 else {
1597 query.append("name = ?");
1598 }
1599
1600 query.append(" ");
1601
1602 Query q = session.createQuery(query.toString());
1603
1604 QueryPos qPos = QueryPos.getInstance(q);
1605
1606 qPos.add(folderId);
1607
1608 if (name != null) {
1609 qPos.add(name);
1610 }
1611
1612 count = (Long)q.uniqueResult();
1613 }
1614 catch (Exception e) {
1615 throw processException(e);
1616 }
1617 finally {
1618 if (count == null) {
1619 count = Long.valueOf(0);
1620 }
1621
1622 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_N, finderArgs,
1623 count);
1624
1625 closeSession(session);
1626 }
1627 }
1628
1629 return count.intValue();
1630 }
1631
1632 public int countByC_U_F_N(long companyId, long userId, long folderId,
1633 String name) throws SystemException {
1634 Object[] finderArgs = new Object[] {
1635 new Long(companyId), new Long(userId), new Long(folderId),
1636
1637 name
1638 };
1639
1640 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_F_N,
1641 finderArgs, this);
1642
1643 if (count == null) {
1644 Session session = null;
1645
1646 try {
1647 session = openSession();
1648
1649 StringBuilder query = new StringBuilder();
1650
1651 query.append("SELECT COUNT(*) ");
1652 query.append(
1653 "FROM com.liferay.portlet.documentlibrary.model.DLFileRank WHERE ");
1654
1655 query.append("companyId = ?");
1656
1657 query.append(" AND ");
1658
1659 query.append("userId = ?");
1660
1661 query.append(" AND ");
1662
1663 query.append("folderId = ?");
1664
1665 query.append(" AND ");
1666
1667 if (name == null) {
1668 query.append("name IS NULL");
1669 }
1670 else {
1671 query.append("name = ?");
1672 }
1673
1674 query.append(" ");
1675
1676 Query q = session.createQuery(query.toString());
1677
1678 QueryPos qPos = QueryPos.getInstance(q);
1679
1680 qPos.add(companyId);
1681
1682 qPos.add(userId);
1683
1684 qPos.add(folderId);
1685
1686 if (name != null) {
1687 qPos.add(name);
1688 }
1689
1690 count = (Long)q.uniqueResult();
1691 }
1692 catch (Exception e) {
1693 throw processException(e);
1694 }
1695 finally {
1696 if (count == null) {
1697 count = Long.valueOf(0);
1698 }
1699
1700 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_F_N,
1701 finderArgs, count);
1702
1703 closeSession(session);
1704 }
1705 }
1706
1707 return count.intValue();
1708 }
1709
1710 public int countAll() throws SystemException {
1711 Object[] finderArgs = new Object[0];
1712
1713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1714 finderArgs, this);
1715
1716 if (count == null) {
1717 Session session = null;
1718
1719 try {
1720 session = openSession();
1721
1722 Query q = session.createQuery(
1723 "SELECT COUNT(*) FROM com.liferay.portlet.documentlibrary.model.DLFileRank");
1724
1725 count = (Long)q.uniqueResult();
1726 }
1727 catch (Exception e) {
1728 throw processException(e);
1729 }
1730 finally {
1731 if (count == null) {
1732 count = Long.valueOf(0);
1733 }
1734
1735 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1736 count);
1737
1738 closeSession(session);
1739 }
1740 }
1741
1742 return count.intValue();
1743 }
1744
1745 public void afterPropertiesSet() {
1746 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1747 com.liferay.portal.util.PropsUtil.get(
1748 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileRank")));
1749
1750 if (listenerClassNames.length > 0) {
1751 try {
1752 List<ModelListener<DLFileRank>> listenersList = new ArrayList<ModelListener<DLFileRank>>();
1753
1754 for (String listenerClassName : listenerClassNames) {
1755 listenersList.add((ModelListener<DLFileRank>)Class.forName(
1756 listenerClassName).newInstance());
1757 }
1758
1759 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1760 }
1761 catch (Exception e) {
1762 _log.error(e);
1763 }
1764 }
1765 }
1766
1767 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence.impl")
1768 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence dlFileEntryPersistence;
1769 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
1770 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
1771 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence.impl")
1772 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence dlFileShortcutPersistence;
1773 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence.impl")
1774 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence dlFileVersionPersistence;
1775 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence.impl")
1776 protected com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence dlFolderPersistence;
1777 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1778 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1779 private static Log _log = LogFactoryUtil.getLog(DLFileRankPersistenceImpl.class);
1780}