1
22
23 package com.liferay.portlet.journal.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.kernel.uuid.PortalUUIDUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.journal.NoSuchStructureException;
49 import com.liferay.portlet.journal.model.JournalStructure;
50 import com.liferay.portlet.journal.model.impl.JournalStructureImpl;
51 import com.liferay.portlet.journal.model.impl.JournalStructureModelImpl;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
63 public class JournalStructurePersistenceImpl extends BasePersistenceImpl
64 implements JournalStructurePersistence {
65 public static final String FINDER_CLASS_NAME_ENTITY = JournalStructureImpl.class.getName();
66 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
67 ".List";
68 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
69 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
70 FINDER_CLASS_NAME_LIST, "findByUuid",
71 new String[] { String.class.getName() });
72 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
73 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
74 FINDER_CLASS_NAME_LIST, "findByUuid",
75 new String[] {
76 String.class.getName(),
77
78 "java.lang.Integer", "java.lang.Integer",
79 "com.liferay.portal.kernel.util.OrderByComparator"
80 });
81 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
82 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_LIST, "countByUuid",
84 new String[] { String.class.getName() });
85 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
86 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
87 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
88 new String[] { String.class.getName(), Long.class.getName() });
89 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
90 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countByUUID_G",
92 new String[] { String.class.getName(), Long.class.getName() });
93 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
94 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
95 FINDER_CLASS_NAME_LIST, "findByGroupId",
96 new String[] { Long.class.getName() });
97 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
98 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "findByGroupId",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
107 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "countByGroupId",
109 new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FIND_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
111 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "findByStructureId",
113 new String[] { String.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_OBC_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
115 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "findByStructureId",
117 new String[] {
118 String.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
124 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
125 FINDER_CLASS_NAME_LIST, "countByStructureId",
126 new String[] { String.class.getName() });
127 public static final FinderPath FINDER_PATH_FETCH_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
128 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
129 FINDER_CLASS_NAME_ENTITY, "fetchByG_S",
130 new String[] { Long.class.getName(), String.class.getName() });
131 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
132 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "countByG_S",
134 new String[] { Long.class.getName(), String.class.getName() });
135 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
136 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
137 FINDER_CLASS_NAME_LIST, "findByG_P",
138 new String[] { Long.class.getName(), String.class.getName() });
139 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
140 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
141 FINDER_CLASS_NAME_LIST, "findByG_P",
142 new String[] {
143 Long.class.getName(), String.class.getName(),
144
145 "java.lang.Integer", "java.lang.Integer",
146 "com.liferay.portal.kernel.util.OrderByComparator"
147 });
148 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
149 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
150 FINDER_CLASS_NAME_LIST, "countByG_P",
151 new String[] { Long.class.getName(), String.class.getName() });
152 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
153 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
154 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
155 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
156 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
157 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
158
159 public void cacheResult(JournalStructure journalStructure) {
160 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
161 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
162 journalStructure);
163
164 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
165 new Object[] {
166 journalStructure.getUuid(),
167 new Long(journalStructure.getGroupId())
168 }, journalStructure);
169
170 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
171 new Object[] {
172 new Long(journalStructure.getGroupId()),
173
174 journalStructure.getStructureId()
175 }, journalStructure);
176 }
177
178 public void cacheResult(List<JournalStructure> journalStructures) {
179 for (JournalStructure journalStructure : journalStructures) {
180 if (EntityCacheUtil.getResult(
181 JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
182 JournalStructureImpl.class,
183 journalStructure.getPrimaryKey(), this) == null) {
184 cacheResult(journalStructure);
185 }
186 }
187 }
188
189 public void clearCache() {
190 CacheRegistry.clear(JournalStructureImpl.class.getName());
191 EntityCacheUtil.clearCache(JournalStructureImpl.class.getName());
192 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
193 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
194 }
195
196 public JournalStructure create(long id) {
197 JournalStructure journalStructure = new JournalStructureImpl();
198
199 journalStructure.setNew(true);
200 journalStructure.setPrimaryKey(id);
201
202 String uuid = PortalUUIDUtil.generate();
203
204 journalStructure.setUuid(uuid);
205
206 return journalStructure;
207 }
208
209 public JournalStructure remove(long id)
210 throws NoSuchStructureException, SystemException {
211 Session session = null;
212
213 try {
214 session = openSession();
215
216 JournalStructure journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
217 new Long(id));
218
219 if (journalStructure == null) {
220 if (_log.isWarnEnabled()) {
221 _log.warn(
222 "No JournalStructure exists with the primary key " +
223 id);
224 }
225
226 throw new NoSuchStructureException(
227 "No JournalStructure exists with the primary key " + id);
228 }
229
230 return remove(journalStructure);
231 }
232 catch (NoSuchStructureException nsee) {
233 throw nsee;
234 }
235 catch (Exception e) {
236 throw processException(e);
237 }
238 finally {
239 closeSession(session);
240 }
241 }
242
243 public JournalStructure remove(JournalStructure journalStructure)
244 throws SystemException {
245 for (ModelListener<JournalStructure> listener : listeners) {
246 listener.onBeforeRemove(journalStructure);
247 }
248
249 journalStructure = removeImpl(journalStructure);
250
251 for (ModelListener<JournalStructure> listener : listeners) {
252 listener.onAfterRemove(journalStructure);
253 }
254
255 return journalStructure;
256 }
257
258 protected JournalStructure removeImpl(JournalStructure journalStructure)
259 throws SystemException {
260 Session session = null;
261
262 try {
263 session = openSession();
264
265 if (journalStructure.isCachedModel() ||
266 BatchSessionUtil.isEnabled()) {
267 Object staleObject = session.get(JournalStructureImpl.class,
268 journalStructure.getPrimaryKeyObj());
269
270 if (staleObject != null) {
271 session.evict(staleObject);
272 }
273 }
274
275 session.delete(journalStructure);
276
277 session.flush();
278 }
279 catch (Exception e) {
280 throw processException(e);
281 }
282 finally {
283 closeSession(session);
284 }
285
286 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
287
288 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
289
290 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
291 new Object[] {
292 journalStructureModelImpl.getOriginalUuid(),
293 new Long(journalStructureModelImpl.getOriginalGroupId())
294 });
295
296 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
297 new Object[] {
298 new Long(journalStructureModelImpl.getOriginalGroupId()),
299
300 journalStructureModelImpl.getOriginalStructureId()
301 });
302
303 EntityCacheUtil.removeResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
304 JournalStructureImpl.class, journalStructure.getPrimaryKey());
305
306 return journalStructure;
307 }
308
309
312 public JournalStructure update(JournalStructure journalStructure)
313 throws SystemException {
314 if (_log.isWarnEnabled()) {
315 _log.warn(
316 "Using the deprecated update(JournalStructure journalStructure) method. Use update(JournalStructure journalStructure, boolean merge) instead.");
317 }
318
319 return update(journalStructure, false);
320 }
321
322
335 public JournalStructure update(JournalStructure journalStructure,
336 boolean merge) throws SystemException {
337 boolean isNew = journalStructure.isNew();
338
339 for (ModelListener<JournalStructure> listener : listeners) {
340 if (isNew) {
341 listener.onBeforeCreate(journalStructure);
342 }
343 else {
344 listener.onBeforeUpdate(journalStructure);
345 }
346 }
347
348 journalStructure = updateImpl(journalStructure, merge);
349
350 for (ModelListener<JournalStructure> listener : listeners) {
351 if (isNew) {
352 listener.onAfterCreate(journalStructure);
353 }
354 else {
355 listener.onAfterUpdate(journalStructure);
356 }
357 }
358
359 return journalStructure;
360 }
361
362 public JournalStructure updateImpl(
363 com.liferay.portlet.journal.model.JournalStructure journalStructure,
364 boolean merge) throws SystemException {
365 boolean isNew = journalStructure.isNew();
366
367 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
368
369 if (Validator.isNull(journalStructure.getUuid())) {
370 String uuid = PortalUUIDUtil.generate();
371
372 journalStructure.setUuid(uuid);
373 }
374
375 Session session = null;
376
377 try {
378 session = openSession();
379
380 BatchSessionUtil.update(session, journalStructure, merge);
381
382 journalStructure.setNew(false);
383 }
384 catch (Exception e) {
385 throw processException(e);
386 }
387 finally {
388 closeSession(session);
389 }
390
391 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
392
393 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
394 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
395 journalStructure);
396
397 if (!isNew &&
398 (!Validator.equals(journalStructure.getUuid(),
399 journalStructureModelImpl.getOriginalUuid()) ||
400 (journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()))) {
401 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
402 new Object[] {
403 journalStructureModelImpl.getOriginalUuid(),
404 new Long(journalStructureModelImpl.getOriginalGroupId())
405 });
406 }
407
408 if (isNew ||
409 (!Validator.equals(journalStructure.getUuid(),
410 journalStructureModelImpl.getOriginalUuid()) ||
411 (journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()))) {
412 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
413 new Object[] {
414 journalStructure.getUuid(),
415 new Long(journalStructure.getGroupId())
416 }, journalStructure);
417 }
418
419 if (!isNew &&
420 ((journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()) ||
421 !Validator.equals(journalStructure.getStructureId(),
422 journalStructureModelImpl.getOriginalStructureId()))) {
423 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
424 new Object[] {
425 new Long(journalStructureModelImpl.getOriginalGroupId()),
426
427 journalStructureModelImpl.getOriginalStructureId()
428 });
429 }
430
431 if (isNew ||
432 ((journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()) ||
433 !Validator.equals(journalStructure.getStructureId(),
434 journalStructureModelImpl.getOriginalStructureId()))) {
435 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
436 new Object[] {
437 new Long(journalStructure.getGroupId()),
438
439 journalStructure.getStructureId()
440 }, journalStructure);
441 }
442
443 return journalStructure;
444 }
445
446 public JournalStructure findByPrimaryKey(long id)
447 throws NoSuchStructureException, SystemException {
448 JournalStructure journalStructure = fetchByPrimaryKey(id);
449
450 if (journalStructure == null) {
451 if (_log.isWarnEnabled()) {
452 _log.warn("No JournalStructure exists with the primary key " +
453 id);
454 }
455
456 throw new NoSuchStructureException(
457 "No JournalStructure exists with the primary key " + id);
458 }
459
460 return journalStructure;
461 }
462
463 public JournalStructure fetchByPrimaryKey(long id)
464 throws SystemException {
465 JournalStructure journalStructure = (JournalStructure)EntityCacheUtil.getResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
466 JournalStructureImpl.class, id, this);
467
468 if (journalStructure == null) {
469 Session session = null;
470
471 try {
472 session = openSession();
473
474 journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
475 new Long(id));
476 }
477 catch (Exception e) {
478 throw processException(e);
479 }
480 finally {
481 if (journalStructure != null) {
482 cacheResult(journalStructure);
483 }
484
485 closeSession(session);
486 }
487 }
488
489 return journalStructure;
490 }
491
492 public List<JournalStructure> findByUuid(String uuid)
493 throws SystemException {
494 Object[] finderArgs = new Object[] { uuid };
495
496 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
497 finderArgs, this);
498
499 if (list == null) {
500 Session session = null;
501
502 try {
503 session = openSession();
504
505 StringBuilder query = new StringBuilder();
506
507 query.append(
508 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
509
510 if (uuid == null) {
511 query.append("uuid_ IS NULL");
512 }
513 else {
514 query.append("uuid_ = ?");
515 }
516
517 query.append(" ");
518
519 query.append("ORDER BY ");
520
521 query.append("structureId ASC");
522
523 Query q = session.createQuery(query.toString());
524
525 QueryPos qPos = QueryPos.getInstance(q);
526
527 if (uuid != null) {
528 qPos.add(uuid);
529 }
530
531 list = q.list();
532 }
533 catch (Exception e) {
534 throw processException(e);
535 }
536 finally {
537 if (list == null) {
538 list = new ArrayList<JournalStructure>();
539 }
540
541 cacheResult(list);
542
543 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
544 list);
545
546 closeSession(session);
547 }
548 }
549
550 return list;
551 }
552
553 public List<JournalStructure> findByUuid(String uuid, int start, int end)
554 throws SystemException {
555 return findByUuid(uuid, start, end, null);
556 }
557
558 public List<JournalStructure> findByUuid(String uuid, int start, int end,
559 OrderByComparator obc) throws SystemException {
560 Object[] finderArgs = new Object[] {
561 uuid,
562
563 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
564 };
565
566 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
567 finderArgs, this);
568
569 if (list == null) {
570 Session session = null;
571
572 try {
573 session = openSession();
574
575 StringBuilder query = new StringBuilder();
576
577 query.append(
578 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
579
580 if (uuid == null) {
581 query.append("uuid_ IS NULL");
582 }
583 else {
584 query.append("uuid_ = ?");
585 }
586
587 query.append(" ");
588
589 if (obc != null) {
590 query.append("ORDER BY ");
591 query.append(obc.getOrderBy());
592 }
593
594 else {
595 query.append("ORDER BY ");
596
597 query.append("structureId ASC");
598 }
599
600 Query q = session.createQuery(query.toString());
601
602 QueryPos qPos = QueryPos.getInstance(q);
603
604 if (uuid != null) {
605 qPos.add(uuid);
606 }
607
608 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
609 start, end);
610 }
611 catch (Exception e) {
612 throw processException(e);
613 }
614 finally {
615 if (list == null) {
616 list = new ArrayList<JournalStructure>();
617 }
618
619 cacheResult(list);
620
621 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
622 finderArgs, list);
623
624 closeSession(session);
625 }
626 }
627
628 return list;
629 }
630
631 public JournalStructure findByUuid_First(String uuid, OrderByComparator obc)
632 throws NoSuchStructureException, SystemException {
633 List<JournalStructure> list = findByUuid(uuid, 0, 1, obc);
634
635 if (list.isEmpty()) {
636 StringBuilder msg = new StringBuilder();
637
638 msg.append("No JournalStructure exists with the key {");
639
640 msg.append("uuid=" + uuid);
641
642 msg.append(StringPool.CLOSE_CURLY_BRACE);
643
644 throw new NoSuchStructureException(msg.toString());
645 }
646 else {
647 return list.get(0);
648 }
649 }
650
651 public JournalStructure findByUuid_Last(String uuid, OrderByComparator obc)
652 throws NoSuchStructureException, SystemException {
653 int count = countByUuid(uuid);
654
655 List<JournalStructure> list = findByUuid(uuid, count - 1, count, obc);
656
657 if (list.isEmpty()) {
658 StringBuilder msg = new StringBuilder();
659
660 msg.append("No JournalStructure exists with the key {");
661
662 msg.append("uuid=" + uuid);
663
664 msg.append(StringPool.CLOSE_CURLY_BRACE);
665
666 throw new NoSuchStructureException(msg.toString());
667 }
668 else {
669 return list.get(0);
670 }
671 }
672
673 public JournalStructure[] findByUuid_PrevAndNext(long id, String uuid,
674 OrderByComparator obc) throws NoSuchStructureException, SystemException {
675 JournalStructure journalStructure = findByPrimaryKey(id);
676
677 int count = countByUuid(uuid);
678
679 Session session = null;
680
681 try {
682 session = openSession();
683
684 StringBuilder query = new StringBuilder();
685
686 query.append(
687 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
688
689 if (uuid == null) {
690 query.append("uuid_ IS NULL");
691 }
692 else {
693 query.append("uuid_ = ?");
694 }
695
696 query.append(" ");
697
698 if (obc != null) {
699 query.append("ORDER BY ");
700 query.append(obc.getOrderBy());
701 }
702
703 else {
704 query.append("ORDER BY ");
705
706 query.append("structureId ASC");
707 }
708
709 Query q = session.createQuery(query.toString());
710
711 QueryPos qPos = QueryPos.getInstance(q);
712
713 if (uuid != null) {
714 qPos.add(uuid);
715 }
716
717 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
718 journalStructure);
719
720 JournalStructure[] array = new JournalStructureImpl[3];
721
722 array[0] = (JournalStructure)objArray[0];
723 array[1] = (JournalStructure)objArray[1];
724 array[2] = (JournalStructure)objArray[2];
725
726 return array;
727 }
728 catch (Exception e) {
729 throw processException(e);
730 }
731 finally {
732 closeSession(session);
733 }
734 }
735
736 public JournalStructure findByUUID_G(String uuid, long groupId)
737 throws NoSuchStructureException, SystemException {
738 JournalStructure journalStructure = fetchByUUID_G(uuid, groupId);
739
740 if (journalStructure == null) {
741 StringBuilder msg = new StringBuilder();
742
743 msg.append("No JournalStructure exists with the key {");
744
745 msg.append("uuid=" + uuid);
746
747 msg.append(", ");
748 msg.append("groupId=" + groupId);
749
750 msg.append(StringPool.CLOSE_CURLY_BRACE);
751
752 if (_log.isWarnEnabled()) {
753 _log.warn(msg.toString());
754 }
755
756 throw new NoSuchStructureException(msg.toString());
757 }
758
759 return journalStructure;
760 }
761
762 public JournalStructure fetchByUUID_G(String uuid, long groupId)
763 throws SystemException {
764 return fetchByUUID_G(uuid, groupId, true);
765 }
766
767 public JournalStructure fetchByUUID_G(String uuid, long groupId,
768 boolean retrieveFromCache) throws SystemException {
769 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
770
771 Object result = null;
772
773 if (retrieveFromCache) {
774 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
775 finderArgs, this);
776 }
777
778 if (result == null) {
779 Session session = null;
780
781 try {
782 session = openSession();
783
784 StringBuilder query = new StringBuilder();
785
786 query.append(
787 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
788
789 if (uuid == null) {
790 query.append("uuid_ IS NULL");
791 }
792 else {
793 query.append("uuid_ = ?");
794 }
795
796 query.append(" AND ");
797
798 query.append("groupId = ?");
799
800 query.append(" ");
801
802 query.append("ORDER BY ");
803
804 query.append("structureId ASC");
805
806 Query q = session.createQuery(query.toString());
807
808 QueryPos qPos = QueryPos.getInstance(q);
809
810 if (uuid != null) {
811 qPos.add(uuid);
812 }
813
814 qPos.add(groupId);
815
816 List<JournalStructure> list = q.list();
817
818 result = list;
819
820 JournalStructure journalStructure = null;
821
822 if (list.isEmpty()) {
823 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
824 finderArgs, list);
825 }
826 else {
827 journalStructure = list.get(0);
828
829 cacheResult(journalStructure);
830
831 if ((journalStructure.getUuid() == null) ||
832 !journalStructure.getUuid().equals(uuid) ||
833 (journalStructure.getGroupId() != groupId)) {
834 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
835 finderArgs, journalStructure);
836 }
837 }
838
839 return journalStructure;
840 }
841 catch (Exception e) {
842 throw processException(e);
843 }
844 finally {
845 if (result == null) {
846 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
847 finderArgs, new ArrayList<JournalStructure>());
848 }
849
850 closeSession(session);
851 }
852 }
853 else {
854 if (result instanceof List) {
855 return null;
856 }
857 else {
858 return (JournalStructure)result;
859 }
860 }
861 }
862
863 public List<JournalStructure> findByGroupId(long groupId)
864 throws SystemException {
865 Object[] finderArgs = new Object[] { new Long(groupId) };
866
867 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
868 finderArgs, this);
869
870 if (list == null) {
871 Session session = null;
872
873 try {
874 session = openSession();
875
876 StringBuilder query = new StringBuilder();
877
878 query.append(
879 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
880
881 query.append("groupId = ?");
882
883 query.append(" ");
884
885 query.append("ORDER BY ");
886
887 query.append("structureId ASC");
888
889 Query q = session.createQuery(query.toString());
890
891 QueryPos qPos = QueryPos.getInstance(q);
892
893 qPos.add(groupId);
894
895 list = q.list();
896 }
897 catch (Exception e) {
898 throw processException(e);
899 }
900 finally {
901 if (list == null) {
902 list = new ArrayList<JournalStructure>();
903 }
904
905 cacheResult(list);
906
907 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
908 finderArgs, list);
909
910 closeSession(session);
911 }
912 }
913
914 return list;
915 }
916
917 public List<JournalStructure> findByGroupId(long groupId, int start, int end)
918 throws SystemException {
919 return findByGroupId(groupId, start, end, null);
920 }
921
922 public List<JournalStructure> findByGroupId(long groupId, int start,
923 int end, OrderByComparator obc) throws SystemException {
924 Object[] finderArgs = new Object[] {
925 new Long(groupId),
926
927 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
928 };
929
930 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
931 finderArgs, this);
932
933 if (list == null) {
934 Session session = null;
935
936 try {
937 session = openSession();
938
939 StringBuilder query = new StringBuilder();
940
941 query.append(
942 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
943
944 query.append("groupId = ?");
945
946 query.append(" ");
947
948 if (obc != null) {
949 query.append("ORDER BY ");
950 query.append(obc.getOrderBy());
951 }
952
953 else {
954 query.append("ORDER BY ");
955
956 query.append("structureId ASC");
957 }
958
959 Query q = session.createQuery(query.toString());
960
961 QueryPos qPos = QueryPos.getInstance(q);
962
963 qPos.add(groupId);
964
965 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
966 start, end);
967 }
968 catch (Exception e) {
969 throw processException(e);
970 }
971 finally {
972 if (list == null) {
973 list = new ArrayList<JournalStructure>();
974 }
975
976 cacheResult(list);
977
978 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
979 finderArgs, list);
980
981 closeSession(session);
982 }
983 }
984
985 return list;
986 }
987
988 public JournalStructure findByGroupId_First(long groupId,
989 OrderByComparator obc) throws NoSuchStructureException, SystemException {
990 List<JournalStructure> list = findByGroupId(groupId, 0, 1, obc);
991
992 if (list.isEmpty()) {
993 StringBuilder msg = new StringBuilder();
994
995 msg.append("No JournalStructure exists with the key {");
996
997 msg.append("groupId=" + groupId);
998
999 msg.append(StringPool.CLOSE_CURLY_BRACE);
1000
1001 throw new NoSuchStructureException(msg.toString());
1002 }
1003 else {
1004 return list.get(0);
1005 }
1006 }
1007
1008 public JournalStructure findByGroupId_Last(long groupId,
1009 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1010 int count = countByGroupId(groupId);
1011
1012 List<JournalStructure> list = findByGroupId(groupId, count - 1, count,
1013 obc);
1014
1015 if (list.isEmpty()) {
1016 StringBuilder msg = new StringBuilder();
1017
1018 msg.append("No JournalStructure exists with the key {");
1019
1020 msg.append("groupId=" + groupId);
1021
1022 msg.append(StringPool.CLOSE_CURLY_BRACE);
1023
1024 throw new NoSuchStructureException(msg.toString());
1025 }
1026 else {
1027 return list.get(0);
1028 }
1029 }
1030
1031 public JournalStructure[] findByGroupId_PrevAndNext(long id, long groupId,
1032 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1033 JournalStructure journalStructure = findByPrimaryKey(id);
1034
1035 int count = countByGroupId(groupId);
1036
1037 Session session = null;
1038
1039 try {
1040 session = openSession();
1041
1042 StringBuilder query = new StringBuilder();
1043
1044 query.append(
1045 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1046
1047 query.append("groupId = ?");
1048
1049 query.append(" ");
1050
1051 if (obc != null) {
1052 query.append("ORDER BY ");
1053 query.append(obc.getOrderBy());
1054 }
1055
1056 else {
1057 query.append("ORDER BY ");
1058
1059 query.append("structureId ASC");
1060 }
1061
1062 Query q = session.createQuery(query.toString());
1063
1064 QueryPos qPos = QueryPos.getInstance(q);
1065
1066 qPos.add(groupId);
1067
1068 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1069 journalStructure);
1070
1071 JournalStructure[] array = new JournalStructureImpl[3];
1072
1073 array[0] = (JournalStructure)objArray[0];
1074 array[1] = (JournalStructure)objArray[1];
1075 array[2] = (JournalStructure)objArray[2];
1076
1077 return array;
1078 }
1079 catch (Exception e) {
1080 throw processException(e);
1081 }
1082 finally {
1083 closeSession(session);
1084 }
1085 }
1086
1087 public List<JournalStructure> findByStructureId(String structureId)
1088 throws SystemException {
1089 Object[] finderArgs = new Object[] { structureId };
1090
1091 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_STRUCTUREID,
1092 finderArgs, this);
1093
1094 if (list == null) {
1095 Session session = null;
1096
1097 try {
1098 session = openSession();
1099
1100 StringBuilder query = new StringBuilder();
1101
1102 query.append(
1103 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1104
1105 if (structureId == null) {
1106 query.append("structureId IS NULL");
1107 }
1108 else {
1109 query.append("structureId = ?");
1110 }
1111
1112 query.append(" ");
1113
1114 query.append("ORDER BY ");
1115
1116 query.append("structureId ASC");
1117
1118 Query q = session.createQuery(query.toString());
1119
1120 QueryPos qPos = QueryPos.getInstance(q);
1121
1122 if (structureId != null) {
1123 qPos.add(structureId);
1124 }
1125
1126 list = q.list();
1127 }
1128 catch (Exception e) {
1129 throw processException(e);
1130 }
1131 finally {
1132 if (list == null) {
1133 list = new ArrayList<JournalStructure>();
1134 }
1135
1136 cacheResult(list);
1137
1138 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_STRUCTUREID,
1139 finderArgs, list);
1140
1141 closeSession(session);
1142 }
1143 }
1144
1145 return list;
1146 }
1147
1148 public List<JournalStructure> findByStructureId(String structureId,
1149 int start, int end) throws SystemException {
1150 return findByStructureId(structureId, start, end, null);
1151 }
1152
1153 public List<JournalStructure> findByStructureId(String structureId,
1154 int start, int end, OrderByComparator obc) throws SystemException {
1155 Object[] finderArgs = new Object[] {
1156 structureId,
1157
1158 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1159 };
1160
1161 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_STRUCTUREID,
1162 finderArgs, this);
1163
1164 if (list == null) {
1165 Session session = null;
1166
1167 try {
1168 session = openSession();
1169
1170 StringBuilder query = new StringBuilder();
1171
1172 query.append(
1173 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1174
1175 if (structureId == null) {
1176 query.append("structureId IS NULL");
1177 }
1178 else {
1179 query.append("structureId = ?");
1180 }
1181
1182 query.append(" ");
1183
1184 if (obc != null) {
1185 query.append("ORDER BY ");
1186 query.append(obc.getOrderBy());
1187 }
1188
1189 else {
1190 query.append("ORDER BY ");
1191
1192 query.append("structureId ASC");
1193 }
1194
1195 Query q = session.createQuery(query.toString());
1196
1197 QueryPos qPos = QueryPos.getInstance(q);
1198
1199 if (structureId != null) {
1200 qPos.add(structureId);
1201 }
1202
1203 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1204 start, end);
1205 }
1206 catch (Exception e) {
1207 throw processException(e);
1208 }
1209 finally {
1210 if (list == null) {
1211 list = new ArrayList<JournalStructure>();
1212 }
1213
1214 cacheResult(list);
1215
1216 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_STRUCTUREID,
1217 finderArgs, list);
1218
1219 closeSession(session);
1220 }
1221 }
1222
1223 return list;
1224 }
1225
1226 public JournalStructure findByStructureId_First(String structureId,
1227 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1228 List<JournalStructure> list = findByStructureId(structureId, 0, 1, obc);
1229
1230 if (list.isEmpty()) {
1231 StringBuilder msg = new StringBuilder();
1232
1233 msg.append("No JournalStructure exists with the key {");
1234
1235 msg.append("structureId=" + structureId);
1236
1237 msg.append(StringPool.CLOSE_CURLY_BRACE);
1238
1239 throw new NoSuchStructureException(msg.toString());
1240 }
1241 else {
1242 return list.get(0);
1243 }
1244 }
1245
1246 public JournalStructure findByStructureId_Last(String structureId,
1247 OrderByComparator obc) throws NoSuchStructureException, SystemException {
1248 int count = countByStructureId(structureId);
1249
1250 List<JournalStructure> list = findByStructureId(structureId, count - 1,
1251 count, obc);
1252
1253 if (list.isEmpty()) {
1254 StringBuilder msg = new StringBuilder();
1255
1256 msg.append("No JournalStructure exists with the key {");
1257
1258 msg.append("structureId=" + structureId);
1259
1260 msg.append(StringPool.CLOSE_CURLY_BRACE);
1261
1262 throw new NoSuchStructureException(msg.toString());
1263 }
1264 else {
1265 return list.get(0);
1266 }
1267 }
1268
1269 public JournalStructure[] findByStructureId_PrevAndNext(long id,
1270 String structureId, OrderByComparator obc)
1271 throws NoSuchStructureException, SystemException {
1272 JournalStructure journalStructure = findByPrimaryKey(id);
1273
1274 int count = countByStructureId(structureId);
1275
1276 Session session = null;
1277
1278 try {
1279 session = openSession();
1280
1281 StringBuilder query = new StringBuilder();
1282
1283 query.append(
1284 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1285
1286 if (structureId == null) {
1287 query.append("structureId IS NULL");
1288 }
1289 else {
1290 query.append("structureId = ?");
1291 }
1292
1293 query.append(" ");
1294
1295 if (obc != null) {
1296 query.append("ORDER BY ");
1297 query.append(obc.getOrderBy());
1298 }
1299
1300 else {
1301 query.append("ORDER BY ");
1302
1303 query.append("structureId ASC");
1304 }
1305
1306 Query q = session.createQuery(query.toString());
1307
1308 QueryPos qPos = QueryPos.getInstance(q);
1309
1310 if (structureId != null) {
1311 qPos.add(structureId);
1312 }
1313
1314 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1315 journalStructure);
1316
1317 JournalStructure[] array = new JournalStructureImpl[3];
1318
1319 array[0] = (JournalStructure)objArray[0];
1320 array[1] = (JournalStructure)objArray[1];
1321 array[2] = (JournalStructure)objArray[2];
1322
1323 return array;
1324 }
1325 catch (Exception e) {
1326 throw processException(e);
1327 }
1328 finally {
1329 closeSession(session);
1330 }
1331 }
1332
1333 public JournalStructure findByG_S(long groupId, String structureId)
1334 throws NoSuchStructureException, SystemException {
1335 JournalStructure journalStructure = fetchByG_S(groupId, structureId);
1336
1337 if (journalStructure == null) {
1338 StringBuilder msg = new StringBuilder();
1339
1340 msg.append("No JournalStructure exists with the key {");
1341
1342 msg.append("groupId=" + groupId);
1343
1344 msg.append(", ");
1345 msg.append("structureId=" + structureId);
1346
1347 msg.append(StringPool.CLOSE_CURLY_BRACE);
1348
1349 if (_log.isWarnEnabled()) {
1350 _log.warn(msg.toString());
1351 }
1352
1353 throw new NoSuchStructureException(msg.toString());
1354 }
1355
1356 return journalStructure;
1357 }
1358
1359 public JournalStructure fetchByG_S(long groupId, String structureId)
1360 throws SystemException {
1361 return fetchByG_S(groupId, structureId, true);
1362 }
1363
1364 public JournalStructure fetchByG_S(long groupId, String structureId,
1365 boolean retrieveFromCache) throws SystemException {
1366 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
1367
1368 Object result = null;
1369
1370 if (retrieveFromCache) {
1371 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_S,
1372 finderArgs, this);
1373 }
1374
1375 if (result == null) {
1376 Session session = null;
1377
1378 try {
1379 session = openSession();
1380
1381 StringBuilder query = new StringBuilder();
1382
1383 query.append(
1384 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1385
1386 query.append("groupId = ?");
1387
1388 query.append(" AND ");
1389
1390 if (structureId == null) {
1391 query.append("structureId IS NULL");
1392 }
1393 else {
1394 query.append("structureId = ?");
1395 }
1396
1397 query.append(" ");
1398
1399 query.append("ORDER BY ");
1400
1401 query.append("structureId ASC");
1402
1403 Query q = session.createQuery(query.toString());
1404
1405 QueryPos qPos = QueryPos.getInstance(q);
1406
1407 qPos.add(groupId);
1408
1409 if (structureId != null) {
1410 qPos.add(structureId);
1411 }
1412
1413 List<JournalStructure> list = q.list();
1414
1415 result = list;
1416
1417 JournalStructure journalStructure = null;
1418
1419 if (list.isEmpty()) {
1420 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1421 finderArgs, list);
1422 }
1423 else {
1424 journalStructure = list.get(0);
1425
1426 cacheResult(journalStructure);
1427
1428 if ((journalStructure.getGroupId() != groupId) ||
1429 (journalStructure.getStructureId() == null) ||
1430 !journalStructure.getStructureId()
1431 .equals(structureId)) {
1432 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1433 finderArgs, journalStructure);
1434 }
1435 }
1436
1437 return journalStructure;
1438 }
1439 catch (Exception e) {
1440 throw processException(e);
1441 }
1442 finally {
1443 if (result == null) {
1444 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1445 finderArgs, new ArrayList<JournalStructure>());
1446 }
1447
1448 closeSession(session);
1449 }
1450 }
1451 else {
1452 if (result instanceof List) {
1453 return null;
1454 }
1455 else {
1456 return (JournalStructure)result;
1457 }
1458 }
1459 }
1460
1461 public List<JournalStructure> findByG_P(long groupId,
1462 String parentStructureId) throws SystemException {
1463 Object[] finderArgs = new Object[] { new Long(groupId), parentStructureId };
1464
1465 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1466 finderArgs, this);
1467
1468 if (list == null) {
1469 Session session = null;
1470
1471 try {
1472 session = openSession();
1473
1474 StringBuilder query = new StringBuilder();
1475
1476 query.append(
1477 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1478
1479 query.append("groupId = ?");
1480
1481 query.append(" AND ");
1482
1483 if (parentStructureId == null) {
1484 query.append("parentStructureId IS NULL");
1485 }
1486 else {
1487 query.append("parentStructureId = ?");
1488 }
1489
1490 query.append(" ");
1491
1492 query.append("ORDER BY ");
1493
1494 query.append("structureId ASC");
1495
1496 Query q = session.createQuery(query.toString());
1497
1498 QueryPos qPos = QueryPos.getInstance(q);
1499
1500 qPos.add(groupId);
1501
1502 if (parentStructureId != null) {
1503 qPos.add(parentStructureId);
1504 }
1505
1506 list = q.list();
1507 }
1508 catch (Exception e) {
1509 throw processException(e);
1510 }
1511 finally {
1512 if (list == null) {
1513 list = new ArrayList<JournalStructure>();
1514 }
1515
1516 cacheResult(list);
1517
1518 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1519 list);
1520
1521 closeSession(session);
1522 }
1523 }
1524
1525 return list;
1526 }
1527
1528 public List<JournalStructure> findByG_P(long groupId,
1529 String parentStructureId, int start, int end) throws SystemException {
1530 return findByG_P(groupId, parentStructureId, start, end, null);
1531 }
1532
1533 public List<JournalStructure> findByG_P(long groupId,
1534 String parentStructureId, int start, int end, OrderByComparator obc)
1535 throws SystemException {
1536 Object[] finderArgs = new Object[] {
1537 new Long(groupId),
1538
1539 parentStructureId,
1540
1541 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1542 };
1543
1544 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P,
1545 finderArgs, this);
1546
1547 if (list == null) {
1548 Session session = null;
1549
1550 try {
1551 session = openSession();
1552
1553 StringBuilder query = new StringBuilder();
1554
1555 query.append(
1556 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1557
1558 query.append("groupId = ?");
1559
1560 query.append(" AND ");
1561
1562 if (parentStructureId == null) {
1563 query.append("parentStructureId IS NULL");
1564 }
1565 else {
1566 query.append("parentStructureId = ?");
1567 }
1568
1569 query.append(" ");
1570
1571 if (obc != null) {
1572 query.append("ORDER BY ");
1573 query.append(obc.getOrderBy());
1574 }
1575
1576 else {
1577 query.append("ORDER BY ");
1578
1579 query.append("structureId ASC");
1580 }
1581
1582 Query q = session.createQuery(query.toString());
1583
1584 QueryPos qPos = QueryPos.getInstance(q);
1585
1586 qPos.add(groupId);
1587
1588 if (parentStructureId != null) {
1589 qPos.add(parentStructureId);
1590 }
1591
1592 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1593 start, end);
1594 }
1595 catch (Exception e) {
1596 throw processException(e);
1597 }
1598 finally {
1599 if (list == null) {
1600 list = new ArrayList<JournalStructure>();
1601 }
1602
1603 cacheResult(list);
1604
1605 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P,
1606 finderArgs, list);
1607
1608 closeSession(session);
1609 }
1610 }
1611
1612 return list;
1613 }
1614
1615 public JournalStructure findByG_P_First(long groupId,
1616 String parentStructureId, OrderByComparator obc)
1617 throws NoSuchStructureException, SystemException {
1618 List<JournalStructure> list = findByG_P(groupId, parentStructureId, 0,
1619 1, obc);
1620
1621 if (list.isEmpty()) {
1622 StringBuilder msg = new StringBuilder();
1623
1624 msg.append("No JournalStructure exists with the key {");
1625
1626 msg.append("groupId=" + groupId);
1627
1628 msg.append(", ");
1629 msg.append("parentStructureId=" + parentStructureId);
1630
1631 msg.append(StringPool.CLOSE_CURLY_BRACE);
1632
1633 throw new NoSuchStructureException(msg.toString());
1634 }
1635 else {
1636 return list.get(0);
1637 }
1638 }
1639
1640 public JournalStructure findByG_P_Last(long groupId,
1641 String parentStructureId, OrderByComparator obc)
1642 throws NoSuchStructureException, SystemException {
1643 int count = countByG_P(groupId, parentStructureId);
1644
1645 List<JournalStructure> list = findByG_P(groupId, parentStructureId,
1646 count - 1, count, obc);
1647
1648 if (list.isEmpty()) {
1649 StringBuilder msg = new StringBuilder();
1650
1651 msg.append("No JournalStructure exists with the key {");
1652
1653 msg.append("groupId=" + groupId);
1654
1655 msg.append(", ");
1656 msg.append("parentStructureId=" + parentStructureId);
1657
1658 msg.append(StringPool.CLOSE_CURLY_BRACE);
1659
1660 throw new NoSuchStructureException(msg.toString());
1661 }
1662 else {
1663 return list.get(0);
1664 }
1665 }
1666
1667 public JournalStructure[] findByG_P_PrevAndNext(long id, long groupId,
1668 String parentStructureId, OrderByComparator obc)
1669 throws NoSuchStructureException, SystemException {
1670 JournalStructure journalStructure = findByPrimaryKey(id);
1671
1672 int count = countByG_P(groupId, parentStructureId);
1673
1674 Session session = null;
1675
1676 try {
1677 session = openSession();
1678
1679 StringBuilder query = new StringBuilder();
1680
1681 query.append(
1682 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1683
1684 query.append("groupId = ?");
1685
1686 query.append(" AND ");
1687
1688 if (parentStructureId == null) {
1689 query.append("parentStructureId IS NULL");
1690 }
1691 else {
1692 query.append("parentStructureId = ?");
1693 }
1694
1695 query.append(" ");
1696
1697 if (obc != null) {
1698 query.append("ORDER BY ");
1699 query.append(obc.getOrderBy());
1700 }
1701
1702 else {
1703 query.append("ORDER BY ");
1704
1705 query.append("structureId ASC");
1706 }
1707
1708 Query q = session.createQuery(query.toString());
1709
1710 QueryPos qPos = QueryPos.getInstance(q);
1711
1712 qPos.add(groupId);
1713
1714 if (parentStructureId != null) {
1715 qPos.add(parentStructureId);
1716 }
1717
1718 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1719 journalStructure);
1720
1721 JournalStructure[] array = new JournalStructureImpl[3];
1722
1723 array[0] = (JournalStructure)objArray[0];
1724 array[1] = (JournalStructure)objArray[1];
1725 array[2] = (JournalStructure)objArray[2];
1726
1727 return array;
1728 }
1729 catch (Exception e) {
1730 throw processException(e);
1731 }
1732 finally {
1733 closeSession(session);
1734 }
1735 }
1736
1737 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1738 throws SystemException {
1739 Session session = null;
1740
1741 try {
1742 session = openSession();
1743
1744 dynamicQuery.compile(session);
1745
1746 return dynamicQuery.list();
1747 }
1748 catch (Exception e) {
1749 throw processException(e);
1750 }
1751 finally {
1752 closeSession(session);
1753 }
1754 }
1755
1756 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1757 int start, int end) throws SystemException {
1758 Session session = null;
1759
1760 try {
1761 session = openSession();
1762
1763 dynamicQuery.setLimit(start, end);
1764
1765 dynamicQuery.compile(session);
1766
1767 return dynamicQuery.list();
1768 }
1769 catch (Exception e) {
1770 throw processException(e);
1771 }
1772 finally {
1773 closeSession(session);
1774 }
1775 }
1776
1777 public List<JournalStructure> findAll() throws SystemException {
1778 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1779 }
1780
1781 public List<JournalStructure> findAll(int start, int end)
1782 throws SystemException {
1783 return findAll(start, end, null);
1784 }
1785
1786 public List<JournalStructure> findAll(int start, int end,
1787 OrderByComparator obc) throws SystemException {
1788 Object[] finderArgs = new Object[] {
1789 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1790 };
1791
1792 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1793 finderArgs, this);
1794
1795 if (list == null) {
1796 Session session = null;
1797
1798 try {
1799 session = openSession();
1800
1801 StringBuilder query = new StringBuilder();
1802
1803 query.append(
1804 "FROM com.liferay.portlet.journal.model.JournalStructure ");
1805
1806 if (obc != null) {
1807 query.append("ORDER BY ");
1808 query.append(obc.getOrderBy());
1809 }
1810
1811 else {
1812 query.append("ORDER BY ");
1813
1814 query.append("structureId ASC");
1815 }
1816
1817 Query q = session.createQuery(query.toString());
1818
1819 if (obc == null) {
1820 list = (List<JournalStructure>)QueryUtil.list(q,
1821 getDialect(), start, end, false);
1822
1823 Collections.sort(list);
1824 }
1825 else {
1826 list = (List<JournalStructure>)QueryUtil.list(q,
1827 getDialect(), start, end);
1828 }
1829 }
1830 catch (Exception e) {
1831 throw processException(e);
1832 }
1833 finally {
1834 if (list == null) {
1835 list = new ArrayList<JournalStructure>();
1836 }
1837
1838 cacheResult(list);
1839
1840 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1841
1842 closeSession(session);
1843 }
1844 }
1845
1846 return list;
1847 }
1848
1849 public void removeByUuid(String uuid) throws SystemException {
1850 for (JournalStructure journalStructure : findByUuid(uuid)) {
1851 remove(journalStructure);
1852 }
1853 }
1854
1855 public void removeByUUID_G(String uuid, long groupId)
1856 throws NoSuchStructureException, SystemException {
1857 JournalStructure journalStructure = findByUUID_G(uuid, groupId);
1858
1859 remove(journalStructure);
1860 }
1861
1862 public void removeByGroupId(long groupId) throws SystemException {
1863 for (JournalStructure journalStructure : findByGroupId(groupId)) {
1864 remove(journalStructure);
1865 }
1866 }
1867
1868 public void removeByStructureId(String structureId)
1869 throws SystemException {
1870 for (JournalStructure journalStructure : findByStructureId(structureId)) {
1871 remove(journalStructure);
1872 }
1873 }
1874
1875 public void removeByG_S(long groupId, String structureId)
1876 throws NoSuchStructureException, SystemException {
1877 JournalStructure journalStructure = findByG_S(groupId, structureId);
1878
1879 remove(journalStructure);
1880 }
1881
1882 public void removeByG_P(long groupId, String parentStructureId)
1883 throws SystemException {
1884 for (JournalStructure journalStructure : findByG_P(groupId,
1885 parentStructureId)) {
1886 remove(journalStructure);
1887 }
1888 }
1889
1890 public void removeAll() throws SystemException {
1891 for (JournalStructure journalStructure : findAll()) {
1892 remove(journalStructure);
1893 }
1894 }
1895
1896 public int countByUuid(String uuid) throws SystemException {
1897 Object[] finderArgs = new Object[] { uuid };
1898
1899 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1900 finderArgs, this);
1901
1902 if (count == null) {
1903 Session session = null;
1904
1905 try {
1906 session = openSession();
1907
1908 StringBuilder query = new StringBuilder();
1909
1910 query.append("SELECT COUNT(*) ");
1911 query.append(
1912 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1913
1914 if (uuid == null) {
1915 query.append("uuid_ IS NULL");
1916 }
1917 else {
1918 query.append("uuid_ = ?");
1919 }
1920
1921 query.append(" ");
1922
1923 Query q = session.createQuery(query.toString());
1924
1925 QueryPos qPos = QueryPos.getInstance(q);
1926
1927 if (uuid != null) {
1928 qPos.add(uuid);
1929 }
1930
1931 count = (Long)q.uniqueResult();
1932 }
1933 catch (Exception e) {
1934 throw processException(e);
1935 }
1936 finally {
1937 if (count == null) {
1938 count = Long.valueOf(0);
1939 }
1940
1941 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1942 finderArgs, count);
1943
1944 closeSession(session);
1945 }
1946 }
1947
1948 return count.intValue();
1949 }
1950
1951 public int countByUUID_G(String uuid, long groupId)
1952 throws SystemException {
1953 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1954
1955 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1956 finderArgs, this);
1957
1958 if (count == null) {
1959 Session session = null;
1960
1961 try {
1962 session = openSession();
1963
1964 StringBuilder query = new StringBuilder();
1965
1966 query.append("SELECT COUNT(*) ");
1967 query.append(
1968 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
1969
1970 if (uuid == null) {
1971 query.append("uuid_ IS NULL");
1972 }
1973 else {
1974 query.append("uuid_ = ?");
1975 }
1976
1977 query.append(" AND ");
1978
1979 query.append("groupId = ?");
1980
1981 query.append(" ");
1982
1983 Query q = session.createQuery(query.toString());
1984
1985 QueryPos qPos = QueryPos.getInstance(q);
1986
1987 if (uuid != null) {
1988 qPos.add(uuid);
1989 }
1990
1991 qPos.add(groupId);
1992
1993 count = (Long)q.uniqueResult();
1994 }
1995 catch (Exception e) {
1996 throw processException(e);
1997 }
1998 finally {
1999 if (count == null) {
2000 count = Long.valueOf(0);
2001 }
2002
2003 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2004 finderArgs, count);
2005
2006 closeSession(session);
2007 }
2008 }
2009
2010 return count.intValue();
2011 }
2012
2013 public int countByGroupId(long groupId) throws SystemException {
2014 Object[] finderArgs = new Object[] { new Long(groupId) };
2015
2016 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2017 finderArgs, this);
2018
2019 if (count == null) {
2020 Session session = null;
2021
2022 try {
2023 session = openSession();
2024
2025 StringBuilder query = new StringBuilder();
2026
2027 query.append("SELECT COUNT(*) ");
2028 query.append(
2029 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
2030
2031 query.append("groupId = ?");
2032
2033 query.append(" ");
2034
2035 Query q = session.createQuery(query.toString());
2036
2037 QueryPos qPos = QueryPos.getInstance(q);
2038
2039 qPos.add(groupId);
2040
2041 count = (Long)q.uniqueResult();
2042 }
2043 catch (Exception e) {
2044 throw processException(e);
2045 }
2046 finally {
2047 if (count == null) {
2048 count = Long.valueOf(0);
2049 }
2050
2051 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2052 finderArgs, count);
2053
2054 closeSession(session);
2055 }
2056 }
2057
2058 return count.intValue();
2059 }
2060
2061 public int countByStructureId(String structureId) throws SystemException {
2062 Object[] finderArgs = new Object[] { structureId };
2063
2064 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
2065 finderArgs, this);
2066
2067 if (count == null) {
2068 Session session = null;
2069
2070 try {
2071 session = openSession();
2072
2073 StringBuilder query = new StringBuilder();
2074
2075 query.append("SELECT COUNT(*) ");
2076 query.append(
2077 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
2078
2079 if (structureId == null) {
2080 query.append("structureId IS NULL");
2081 }
2082 else {
2083 query.append("structureId = ?");
2084 }
2085
2086 query.append(" ");
2087
2088 Query q = session.createQuery(query.toString());
2089
2090 QueryPos qPos = QueryPos.getInstance(q);
2091
2092 if (structureId != null) {
2093 qPos.add(structureId);
2094 }
2095
2096 count = (Long)q.uniqueResult();
2097 }
2098 catch (Exception e) {
2099 throw processException(e);
2100 }
2101 finally {
2102 if (count == null) {
2103 count = Long.valueOf(0);
2104 }
2105
2106 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
2107 finderArgs, count);
2108
2109 closeSession(session);
2110 }
2111 }
2112
2113 return count.intValue();
2114 }
2115
2116 public int countByG_S(long groupId, String structureId)
2117 throws SystemException {
2118 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
2119
2120 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
2121 finderArgs, this);
2122
2123 if (count == null) {
2124 Session session = null;
2125
2126 try {
2127 session = openSession();
2128
2129 StringBuilder query = new StringBuilder();
2130
2131 query.append("SELECT COUNT(*) ");
2132 query.append(
2133 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
2134
2135 query.append("groupId = ?");
2136
2137 query.append(" AND ");
2138
2139 if (structureId == null) {
2140 query.append("structureId IS NULL");
2141 }
2142 else {
2143 query.append("structureId = ?");
2144 }
2145
2146 query.append(" ");
2147
2148 Query q = session.createQuery(query.toString());
2149
2150 QueryPos qPos = QueryPos.getInstance(q);
2151
2152 qPos.add(groupId);
2153
2154 if (structureId != null) {
2155 qPos.add(structureId);
2156 }
2157
2158 count = (Long)q.uniqueResult();
2159 }
2160 catch (Exception e) {
2161 throw processException(e);
2162 }
2163 finally {
2164 if (count == null) {
2165 count = Long.valueOf(0);
2166 }
2167
2168 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
2169 count);
2170
2171 closeSession(session);
2172 }
2173 }
2174
2175 return count.intValue();
2176 }
2177
2178 public int countByG_P(long groupId, String parentStructureId)
2179 throws SystemException {
2180 Object[] finderArgs = new Object[] { new Long(groupId), parentStructureId };
2181
2182 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2183 finderArgs, this);
2184
2185 if (count == null) {
2186 Session session = null;
2187
2188 try {
2189 session = openSession();
2190
2191 StringBuilder query = new StringBuilder();
2192
2193 query.append("SELECT COUNT(*) ");
2194 query.append(
2195 "FROM com.liferay.portlet.journal.model.JournalStructure WHERE ");
2196
2197 query.append("groupId = ?");
2198
2199 query.append(" AND ");
2200
2201 if (parentStructureId == null) {
2202 query.append("parentStructureId IS NULL");
2203 }
2204 else {
2205 query.append("parentStructureId = ?");
2206 }
2207
2208 query.append(" ");
2209
2210 Query q = session.createQuery(query.toString());
2211
2212 QueryPos qPos = QueryPos.getInstance(q);
2213
2214 qPos.add(groupId);
2215
2216 if (parentStructureId != null) {
2217 qPos.add(parentStructureId);
2218 }
2219
2220 count = (Long)q.uniqueResult();
2221 }
2222 catch (Exception e) {
2223 throw processException(e);
2224 }
2225 finally {
2226 if (count == null) {
2227 count = Long.valueOf(0);
2228 }
2229
2230 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2231 count);
2232
2233 closeSession(session);
2234 }
2235 }
2236
2237 return count.intValue();
2238 }
2239
2240 public int countAll() throws SystemException {
2241 Object[] finderArgs = new Object[0];
2242
2243 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2244 finderArgs, this);
2245
2246 if (count == null) {
2247 Session session = null;
2248
2249 try {
2250 session = openSession();
2251
2252 Query q = session.createQuery(
2253 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalStructure");
2254
2255 count = (Long)q.uniqueResult();
2256 }
2257 catch (Exception e) {
2258 throw processException(e);
2259 }
2260 finally {
2261 if (count == null) {
2262 count = Long.valueOf(0);
2263 }
2264
2265 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2266 count);
2267
2268 closeSession(session);
2269 }
2270 }
2271
2272 return count.intValue();
2273 }
2274
2275 public void afterPropertiesSet() {
2276 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2277 com.liferay.portal.util.PropsUtil.get(
2278 "value.object.listener.com.liferay.portlet.journal.model.JournalStructure")));
2279
2280 if (listenerClassNames.length > 0) {
2281 try {
2282 List<ModelListener<JournalStructure>> listenersList = new ArrayList<ModelListener<JournalStructure>>();
2283
2284 for (String listenerClassName : listenerClassNames) {
2285 listenersList.add((ModelListener<JournalStructure>)Class.forName(
2286 listenerClassName).newInstance());
2287 }
2288
2289 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2290 }
2291 catch (Exception e) {
2292 _log.error(e);
2293 }
2294 }
2295 }
2296
2297 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence.impl")
2298 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
2299 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence.impl")
2300 protected com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence journalArticleImagePersistence;
2301 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence.impl")
2302 protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
2303 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence.impl")
2304 protected com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence journalContentSearchPersistence;
2305 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalFeedPersistence.impl")
2306 protected com.liferay.portlet.journal.service.persistence.JournalFeedPersistence journalFeedPersistence;
2307 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence.impl")
2308 protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
2309 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence.impl")
2310 protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
2311 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2312 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2313 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2314 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2315 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
2316 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
2317 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
2318 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
2319 private static Log _log = LogFactoryUtil.getLog(JournalStructurePersistenceImpl.class);
2320}