Package org.olat.core.commons.persistence

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


        + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
        + " where gr.key = le.persistentRef "
        + " and le.persistentTypeName ='org.olat.group.BusinessGroupImpl'"
        + " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' and le.lcTimestamp >= :deleteEmailDate "
        + " and gr.type = :type ";
    DBQuery dbq = DBFactory.getInstance().createQuery(queryStr);
    dbq.setDate("deleteEmailDate", deleteEmailLimit.getTime());
    dbq.setString("type", BusinessGroup.TYPE_BUDDYGROUP);
    return dbq.list();
  }
View Full Code Here


      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where gr.key = le.persistentRef "
      + " and le.persistentTypeName ='org.olat.group.BusinessGroupImpl'"
      + " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' and le.lcTimestamp < :deleteEmailDate "
      + " and gr.type = :type ";
    DBQuery dbq = DBFactory.getInstance().createQuery(queryStr);
    dbq.setDate("deleteEmailDate", deleteEmailLimit.getTime());
    dbq.setString("type", BusinessGroup.TYPE_BUDDYGROUP);
    return dbq.list();
  }
View Full Code Here

    // 1. get all ReprositoryEntries with lastusage > x
    String query = "select re from org.olat.repository.RepositoryEntry as re "
        + " where (re.lastUsage = null or re.lastUsage < :lastUsage)"
        + " and re.olatResource != null ";
    DBQuery dbq = DBFactory.getInstance().createQuery(query);
    dbq.setDate("lastUsage", lastUsageLimit.getTime());
    List reprositoryEntries = dbq.list();
    // 2. get all ReprositoryEntries in deletion-process (email send)
    query = "select re from org.olat.repository.RepositoryEntry as re"
      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where re.key = le.persistentRef "
      + " and re.olatResource != null "
      + " and le.persistentTypeName ='" + RepositoryEntry.class.getName() + "'"
      + " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' ";
    dbq = DBFactory.getInstance().createQuery(query);
    List groupsInProcess = dbq.list();
    // 3. Remove all ReprositoryEntries in deletion-process from all unused-ReprositoryEntries
    reprositoryEntries.removeAll(groupsInProcess);
    return filterRepositoryWithReferences(reprositoryEntries);
  }
View Full Code Here

      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where re.key = le.persistentRef "
      + " and re.olatResource != null "
      + " and le.persistentTypeName ='" + RepositoryEntry.class.getName() + "'"
      + " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' and le.lcTimestamp >= :deleteEmailDate ";
    DBQuery dbq = DBFactory.getInstance().createQuery(queryStr);
    dbq.setDate("deleteEmailDate", deleteEmailLimit.getTime());
    return filterRepositoryWithReferences(dbq.list());
  }
View Full Code Here

      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where re.key = le.persistentRef "
      + " and re.olatResource != null "
      + " and le.persistentTypeName ='" + RepositoryEntry.class.getName() + "'"
      + " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' and le.lcTimestamp < :deleteEmailDate ";
    DBQuery dbq = DBFactory.getInstance().createQuery(queryStr);
    dbq.setDate("deleteEmailDate", deleteEmailLimit.getTime());
    return filterRepositoryWithReferences(dbq.list());
  }
View Full Code Here

      + " org.olat.resource.OLATResourceImpl as ori"
      + " where sgmsi.identity = :identitykey and sgmsi.securityGroup =  poi.securityGroup"
      + " and poi.permission = :permission and poi.olatResource = ori"
      + " and (ori.resId = :resid) and ori.resName = :resname";
    }
    DBQuery query = DBFactory.getInstance().createQuery(queryString);
    query.setLong("identitykey", iimpl.getKey());
    query.setString("permission", permission);   
    query.setLong("resid", oresid);
    query.setString("resname", oresName);
    query.setCacheable(true);
    List res = query.list();
    Long cntL = (Long) res.get(0);
    return (cntL.longValue() > 0); // can be > 1 if identity is in more the one group having
    // the permission on the olatresourceable
  }
View Full Code Here

   * @see org.olat.basesecurity.Manager#isIdentityInSecurityGroup(org.olat.core.id.Identity, org.olat.basesecurity.SecurityGroup)
   */
  public boolean isIdentityInSecurityGroup(Identity identity, SecurityGroup secGroup) {
    if (secGroup == null) return false;
    String queryString = "select count(sgmsi) from  org.olat.basesecurity.SecurityGroupMembershipImpl as sgmsi where sgmsi.identity = :identitykey and sgmsi.securityGroup = :securityGroup";
    DBQuery query = DBFactory.getInstance().createQuery(queryString);
    query.setLong("identitykey", identity.getKey());
    query.setLong("securityGroup", secGroup.getKey());
    query.setCacheable(true);
    List res = query.list();
    Long cntL = (Long) res.get(0);
    if (cntL.longValue() != 0 && cntL.longValue() != 1) throw new AssertException("unique n-to-n must always yield 0 or 1");
    return (cntL.longValue() == 1);
  }
View Full Code Here

  public Date getSecurityGroupJoinDateForIdentity(SecurityGroup secGroup, Identity identity){
    String query = "select creationDate from " + "  org.olat.basesecurity.SecurityGroupMembershipImpl as sgi "
        + " where sgi.securityGroup = :secGroup and sgi.identity = :identId";
   
    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
    dbq.setLong("identId", identity.getKey().longValue());
    dbq.setLong("secGroup", secGroup.getKey());
    List result = dbq.list();
    if (result.size()==0){
      return null;
    }
    else {
      return (Date)result.get(0);
View Full Code Here

   * @see org.olat.basesecurity.Manager#countIdentitiesOfSecurityGroup(org.olat.basesecurity.SecurityGroup)
   */
  public int countIdentitiesOfSecurityGroup(SecurityGroup secGroup) {
    DB db = DBFactory.getInstance();
    String q = "select count(sgm) from org.olat.basesecurity.SecurityGroupMembershipImpl sgm where sgm.securityGroup = :group";
    DBQuery query = db.createQuery(q);
    query.setEntity("group", secGroup);
    int result = ((Long) query.list().get(0)).intValue();
    return result;
  }
View Full Code Here

   * @see org.olat.basesecurity.Manager#countUniqueUserLoginsSince(java.util.Date)
   */
  public Long countUniqueUserLoginsSince (Date lastLoginLimit){
    String queryStr ="Select count(ident) from org.olat.core.id.Identity as ident where "
      + "ident.lastLogin > :lastLoginLimit and ident.lastLogin != ident.creationDate"
    DBQuery dbq = DBFactory.getInstance().createQuery(queryStr);
    dbq.setDate("lastLoginLimit", lastLoginLimit);
    List res = dbq.list();
    Long cntL = (Long) res.get(0);
    return cntL;
 
View Full Code Here

TOP

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

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.