Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<NotificationTypeListModel> getManualNotificationTypes(final Locale locale) {
- //Initialization
- final CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
- final CriteriaQuery<NotificationTypeListModel> query = builder.createQuery(NotificationTypeListModel.class);
- //From
- final Root<NotificationType> rootNotificationType = query.from(NotificationType.class);
- final Join<NotificationType, Label> joinLabelDescription = rootNotificationType.join(NotificationType_.descriptionLabel);
- final Path<String> description = this.getNotificationLabelPath(joinLabelDescription, locale);
- this.buildSelectForNotificationTypeList(query, rootNotificationType, description);
- //Order by
- query.orderBy(builder.asc(builder.lower(description)));
- final Predicate pActive = builder.equal(rootNotificationType.get(NotificationType_.active), true);
- final Predicate pManual = rootNotificationType.get(NotificationType_.code).in(NotificationTypeCode.MANUAL_NOTIFICATION_TYPES);
- final Predicate pUnknown = builder.not(rootNotificationType.get(NotificationType_.code).in(NotificationTypeCode.getAllNotificationTypes()));
- query.where(pActive, builder.or(pManual, pUnknown));
- final TypedQuery<NotificationTypeListModel> tq = this.entityManager.createQuery(query);
- return tq.getResultList();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement