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