Package org.olat.core.commons.persistence

Examples of org.olat.core.commons.persistence.DB


   * @param key
   * @return the subscriber with this key or null if not found
   */
  @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 Publisher getPublisher(SubscriptionContext subsContext) {
    return getPublisher(subsContext.getResName(), subsContext.getResId(), subsContext.getSubidentifier());
  }
 
  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();
  }
View Full Code Here

   * return the publisher for the given composite primary key ores +
   * subidentifier.
   */
  @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

   * @param resId
   * @return a list of publishers belonging to the resource
   */
  @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

  /**
   * @param subscriber
   */
  private void deleteSubscriber(Subscriber subscriber) {
    DB db = DBFactory.getInstance();
    db.deleteObject(subscriber);
  }
View Full Code Here

   * @param subscriptionContext
   * @return true if this user is subscribed
   */
  @SuppressWarnings("unchecked")
  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

    c1.add(Calendar.DAY_OF_YEAR, -15);
    s3.setLastLogin(c1.getTime());
    c1.add(Calendar.DAY_OF_YEAR, -100);
    testAdmin.setLastLogin(c1.getTime());
 
    DB db = DBFactory.getInstance();
    db.updateObject(s1);
    db.updateObject(s2);
    db.updateObject(s3);
    db.updateObject(testAdmin);
    db.closeSession();
   
    Calendar c2 = Calendar.getInstance();   
    //daily:
    assertEquals(0, sm.countUniqueUserLoginsSince(new Date()).intValue());
    c2.add(Calendar.DAY_OF_YEAR, -1);
View Full Code Here

  /**
   * TearDown is called after each test
   */
  public void tearDown() {
    try {
      DB db = DBFactory.getInstance();
      db.closeSession();
    } catch (Exception e) {
      log.error("Exception in tearDown(): " + e);
    }
  }
View Full Code Here

        long searchms = (System.currentTimeMillis() - endms);
        startms = startms + searchms;
       
      }
    }
    DB db = DBFactory.getInstance();
    db.closeSession();
    }
  }
View Full Code Here

          secManager.removeIdentityFromSecurityGroup(identity, loginDeniedGroup);
          log.audit("Identity was in security-group 'Logon_denied' => set status of identity to 'logon_denied'; identity=" + identity);
        }
 
        // 2. Delete named group logon_denied
        DB db = DBFactory.getInstance();
        db.delete("from org.olat.basesecurity.NamedGroupImpl as ngroup where ngroup.groupName = ?", new Object[] { "logondenied" },// so far: Constants.GROUP_LOGON_DENIED
            new Type[] { Hibernate.STRING });
        // 3. Delete security-group 'Logon_denied'
        secManager.deleteSecurityGroup(loginDeniedGroup);
        log.audit("Delete security-group 'Logon_denied'");
      }
View Full Code Here

TOP

Related Classes of org.olat.core.commons.persistence.DB

Copyright © 2018 www.massapicom. 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.