Package org.olat.core.commons.persistence

Examples of org.olat.core.commons.persistence.DB.createQuery()


  @SuppressWarnings("unchecked")
  public List<Subscriber> getSubscribers(Identity identity) {
    DB db = DBFactory.getInstance();
    String q = "select sub from org.olat.notifications.SubscriberImpl sub"
        + " inner join fetch sub.publisher where sub.identity = :anIdentity";
    DBQuery query = db.createQuery(q);
    query.setEntity("anIdentity", identity);
    List<Subscriber> res = query.list();
    return res;
  }
View Full Code Here


  public List<Subscriber> getValidSubscribers(Identity identity) {
    //pub.getState() == PUB_STATE_OK;
    DB db = DBFactory.getInstance();
    String q = "select sub from org.olat.notifications.SubscriberImpl sub" + " inner join fetch sub.publisher as pub"
        + " where sub.identity = :anIdentity" + " and pub.state = :aState";
    DBQuery query = db.createQuery(q);
    query.setEntity("anIdentity", identity);
    query.setLong("aState", PUB_STATE_OK);
    List<Subscriber> res = query.list();
    return res;
  }
View Full Code Here

  public List<Subscriber> getValidSubscribersOf(Publisher publisher) {
    DB db = DBFactory.getInstance();
    String q = "select sub from org.olat.notifications.SubscriberImpl sub inner join fetch sub.identity"
        + " where sub.publisher = :publisher"
        + " and sub.publisher.state = "+PUB_STATE_OK;
    DBQuery query = db.createQuery(q);
    query.setEntity("publisher", publisher);
    List<Subscriber> res = query.list();
    return res;
  }
 
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<Subscriber> getAllValidSubscribers() {
    DB db = DBFactory.getInstance();
    String q = "select sub from org.olat.notifications.SubscriberImpl sub" + " inner join fetch sub.publisher as pub"
        + " where pub.state = :aState" + " order by sub.identity.name";
    DBQuery query = db.createQuery(q);
    query.setLong("aState", PUB_STATE_OK);
    List<Subscriber> res = query.list();
    return res;
  }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public Subscriber getSubscriber(Long key) {
    DB db = DBFactory.getInstance();
    String q = "select sub from org.olat.notifications.SubscriberImpl sub" + " inner join fetch sub.publisher " + " where sub.key = :aKey";
    DBQuery query = db.createQuery(q);
    query.setLong("aKey", key.longValue());
    List<Subscriber> res = query.list();
    int cnt = res.size();
    if (cnt == 0) return null;
    if (cnt > 1) throw new AssertException("more than one subscriber for key " + key);
View Full Code Here

  }
 
  public List<Publisher> getAllPublisher() {
    DB db = DBFactory.getInstance();
    String q = "select pub from org.olat.notifications.PublisherImpl pub";
    DBQuery query = db.createQuery(q);
    return query.list();
  }

  /**
   * return the publisher for the given composite primary key ores +
View Full Code Here

  @SuppressWarnings("unchecked")
  private Publisher getPublisher(String resName, Long resId, String subidentifier) {
    DB db = DBFactory.getInstance();
    String q = "select pub from org.olat.notifications.PublisherImpl pub" + " where pub.resName = :resName" + " and pub.resId = :resId"
        + " and pub.subidentifier = :subidentifier";
    DBQuery query = db.createQuery(q);
    query.setString("resName", resName);
    query.setLong("resId", resId.longValue());
    query.setString("subidentifier", subidentifier);
    List<Publisher> res = query.list();
    if (res.size() == 0) return null;
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  private List<Publisher> getPublishers(String resName, Long resId) {
    DB db = DBFactory.getInstance();
    String q = "select pub from org.olat.notifications.PublisherImpl pub" + " where pub.resName = :resName" + " and pub.resId = :resId";
    DBQuery query = db.createQuery(q);
    query.setString("resName", resName);
    query.setLong("resId", resId.longValue());
    List<Publisher> res = query.list();
    return res;
  }
View Full Code Here

  public boolean isSubscribed(Identity identity, SubscriptionContext subscriptionContext) {
    DB db = DBFactory.getInstance();
    String q = "select count(sub) from org.olat.notifications.SubscriberImpl sub inner join sub.publisher as pub "
        + " where sub.identity = :anIdentity and pub.resName = :resName and pub.resId = :resId"
        + " and pub.subidentifier = :subidentifier group by sub";
    DBQuery query = db.createQuery(q);
    query.setEntity("anIdentity", identity);
    query.setString("resName", subscriptionContext.getResName());
    query.setLong("resId", subscriptionContext.getResId().longValue());
    query.setString("subidentifier", subscriptionContext.getSubidentifier());
    List res = query.list();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.