Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. public List<NotificationTypeListModel> getManualNotificationTypes(final Locale locale) {
  2.         //Initialization
  3.         final CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
  4.         final CriteriaQuery<NotificationTypeListModel> query = builder.createQuery(NotificationTypeListModel.class);
  5.  
  6.         //From
  7.         final Root<NotificationType> rootNotificationType = query.from(NotificationType.class);
  8.         final Join<NotificationType, Label> joinLabelDescription = rootNotificationType.join(NotificationType_.descriptionLabel);
  9.  
  10.         final Path<String> description = this.getNotificationLabelPath(joinLabelDescription, locale);
  11.         this.buildSelectForNotificationTypeList(query, rootNotificationType, description);
  12.  
  13.         //Order by
  14.         query.orderBy(builder.asc(builder.lower(description)));
  15.         final Predicate pActive = builder.equal(rootNotificationType.get(NotificationType_.active), true);
  16.         final Predicate pManual = rootNotificationType.get(NotificationType_.code).in(NotificationTypeCode.MANUAL_NOTIFICATION_TYPES);
  17.         final Predicate pUnknown = builder.not(rootNotificationType.get(NotificationType_.code).in(NotificationTypeCode.getAllNotificationTypes()));
  18.         query.where(pActive, builder.or(pManual, pUnknown));
  19.  
  20.         final TypedQuery<NotificationTypeListModel> tq = this.entityManager.createQuery(query);
  21.         return tq.getResultList();
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement