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