Package org.olat.core.commons.persistence

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


   * @see org.olat.group.area.BGAreaManager#findBGAreasOfBusinessGroup(org.olat.group.BusinessGroup)
   */
  public List findBGAreasOfBusinessGroup(BusinessGroup group) {
    String q = " select area from org.olat.group.area.BGAreaImpl as area," + " org.olat.group.area.BGtoAreaRelationImpl as bgarel "
        + " where bgarel.groupArea = area" + " and bgarel.businessGroup = :group";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setEntity("group", group);
    List result = query.list();
    return result;
  }
View Full Code Here


  /**
   * @see org.olat.group.area.BGAreaManager#countBGAreasOfBGContext(org.olat.group.context.BGContext)
   */
  public int countBGAreasOfBGContext(BGContext groupContext) {
    String q = " select count(area) from org.olat.group.area.BGAreaImpl area where area.groupContext = :context";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setEntity("context", groupContext);
    return ((Long) query.list().get(0)).intValue();
  }
View Full Code Here

  /**
   * @see org.olat.group.area.BGAreaManager#findBGAreasOfBGContext(org.olat.group.context.BGContext)
   */
  public List findBGAreasOfBGContext(BGContext groupContext) {
    String q = " select area from org.olat.group.area.BGAreaImpl area where area.groupContext = :context ";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setEntity("context", groupContext);
    return query.list();
  }
View Full Code Here

    String q = " select count(grp) from" + " org.olat.group.BusinessGroupImpl as grp," + " org.olat.group.area.BGAreaImpl as area,"
        + " org.olat.group.area.BGtoAreaRelationImpl bgarel," + " org.olat.basesecurity.SecurityGroupMembershipImpl as secgmemb"
        + " where area.name = :name" + " and bgarel.groupArea = area" + " and bgarel.businessGroup = grp"
        + " and grp.groupContext = :context" + " and ((grp.partipiciantGroup = secgmemb.securityGroup and secgmemb.identity = :id) "
        + " or (grp.ownerGroup = secgmemb.securityGroup and secgmemb.identity = :id)) ";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setEntity("id", identity);
    query.setEntity("context", groupContext);
    query.setString("name", areaName);
    query.setCacheable(true);
    List result = query.list();
    if (result.size() == 0) return false;
    return ( ((Long) result.get(0)).intValue() > 0);
  }
View Full Code Here

  public boolean checkIfOneOrMoreNameExistsInContext(Set<String> allNames, BGContext bgContext) {
    String q = " select area from org.olat.group.area.BGAreaImpl area "
      +"where area.groupContext = :context "
      +"AND area.name in (:names) ";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setEntity("context", bgContext);
    query.setParameterList("names", allNames);

    List result = query.list();
    if (result.size() == 0) return false;
    return true;
   
  }
View Full Code Here

    String query = "select count(bgs) from "
      + "  org.olat.group.BusinessGroupImpl as bgs "
      + "  where "
      + "  bgs.groupContext = :context"
      + " and bgs.name in (:names)";
    DBQuery dbq = db.createQuery(query);
    dbq.setEntity("context", groupContext);   
    dbq.setParameterList("names", names);
    int result = ((Long) dbq.list().get(0)).intValue();
    //return false if none of the groups was found
    if (result == 0) return false;
    //true if one or more groups were found
    return true;
  }
View Full Code Here

   */
  private static boolean testIfGroupAlreadyExists(String name, String type, BGContext groupContext) {
    DB db = DBFactory.getInstance();
    String query = "select count(bgs) from " + "  org.olat.group.BusinessGroupImpl as bgs " + " where bgs.type = :type"
        + " and bgs.groupContext = :context" + " and bgs.name = :name";
    DBQuery dbq = db.createQuery(query);
    dbq.setString("type", type);
    dbq.setEntity("context", groupContext);
    dbq.setString("name", name);
    int result = ((Long) dbq.list().get(0)).intValue();
    if (result != 0) return true;
    return false;
  }
View Full Code Here

    Tracing.logDebug("lastLoginLimit=" + lastLoginLimit, this.getClass());
    // 1. get all 'active' identities with lastlogin > x
    String queryStr ="from org.olat.core.id.Identity as ident where ident.status = '"
      + Identity.STATUS_ACTIV
      + "' and (ident.lastLogin = null or ident.lastLogin < :lastLogin)"
    DBQuery dbq = DBFactory.getInstance().createQuery(queryStr);
    dbq.setDate("lastLogin", lastLoginLimit.getTime());
    List identities = dbq.list();
    // 2. get all 'active' identities in deletion process
    queryStr = "select ident from org.olat.core.id.Identity as ident"
      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where ident.key = le.persistentRef "
      + " and le.persistentTypeName ='" + IdentityImpl.class.getName() + "'"
      + " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' ";
    dbq = DBFactory.getInstance().createQuery(queryStr);
    List identitiesInProcess = dbq.list();
    // 3. Remove all identities in deletion-process from all inactive-identities
    identities.removeAll(identitiesInProcess);
    return identities;    
  }
View Full Code Here

      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where ident.key = le.persistentRef "
      + " and ident.status = '"  + Identity.STATUS_ACTIV + "'"
      + " and le.persistentTypeName ='" + IdentityImpl.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 dbq.list();
  }
View Full Code Here

      + " , org.olat.commons.lifecycle.LifeCycleEntry as le"
      + " where ident.key = le.persistentRef "
      + " and ident.status = '"  + Identity.STATUS_ACTIV + "'"
      + " and le.persistentTypeName ='" + IdentityImpl.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 dbq.list();
  }
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.