Package org.olat.core.commons.persistence

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


  public List getBGOwnersOfBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    String q = "select distinct id from org.olat.basesecurity.IdentityImpl as id inner join fetch id.user as iuser"
        + ", org.olat.basesecurity.SecurityGroupMembershipImpl sgm" + ", org.olat.group.BusinessGroupImpl bg"
        + " where bg.groupContext = :context" + " and bg.ownerGroup = sgm.securityGroup" + " and sgm.identity = id";
    DBQuery query = db.createQuery(q);
    query.setEntity("context", bgContext);
    return query.list();
  }
View Full Code Here


  public int countBGOwnersOfBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    String q = "select count(distinct id) from org.olat.basesecurity.IdentityImpl id"
        + ", org.olat.basesecurity.SecurityGroupMembershipImpl sgm" + ", org.olat.group.BusinessGroupImpl bg"
        + " where bg.groupContext = :context" + " and bg.ownerGroup = sgm.securityGroup" + " and sgm.identity = id";
    DBQuery query = db.createQuery(q);
    query.setEntity("context", bgContext);
    List resultList = query.list();

    int result = 0;
    // if no join/group by matches, result list size is 0 and count undefined ->
    // result is 0
    if (resultList.size() > 0) {
View Full Code Here

  public List getBGParticipantsOfBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    String q = "select distinct id from org.olat.basesecurity.IdentityImpl as id inner join fetch id.user as iuser"
        + ", org.olat.basesecurity.SecurityGroupMembershipImpl sgm" + ", org.olat.group.BusinessGroupImpl bg"
        + " where bg.groupContext = :context" + " and bg.partipiciantGroup = sgm.securityGroup" + " and sgm.identity = id";
    DBQuery query = db.createQuery(q);
    query.setEntity("context", bgContext);
    return query.list();
  }
View Full Code Here

  public int countBGParticipantsOfBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    String q = "select count(distinct id) from org.olat.basesecurity.IdentityImpl id"
        + ", org.olat.basesecurity.SecurityGroupMembershipImpl sgm" + ", org.olat.group.BusinessGroupImpl bg"
        + " where bg.groupContext = :context" + " and bg.partipiciantGroup = sgm.securityGroup" + " and sgm.identity = id";
    DBQuery query = db.createQuery(q);
    query.setEntity("context", bgContext);
    List resultList = query.list();
    int result = 0;
    // if no join/group by matches, result list size is 0 and count undefined ->
    // result is 0
    if (resultList.size() > 0) {
      Object obj = resultList.get(0);
View Full Code Here

      q.append(ownRestr);
    } else {
      throw new AssertException("illegal arguments: at leas one of asOwner or asParticipant must be true");
    }

    DBQuery query = db.createQuery(q.toString());
    query.setEntity("id", identity);
    query.setEntity("context", bgContext);
    query.setCacheable(true);
    List result = query.list();

    if (result.size() == 0) return false;
    return (((Long) result.get(0)).intValue() > 0);
  }
View Full Code Here

    boolean checkDefault = defaultContexts != nonDefaultContexts;
    if (checkDefault){
      q.append(" and context.defaultContext = :isDefault");
    }
    DBQuery query = db.createQuery(q.toString());
    query.setEntity("resource", resource);
    if (groupType != null) query.setString("gtype", groupType);
    if (checkDefault){
      query.setBoolean("isDefault", defaultContexts ? true : false);
    }
    return query.list();
  }
View Full Code Here

    boolean checkDefault = defaultContexts != nonDefaultContexts;
    if (checkDefault){
      q.append(" and context.defaultContext = :isDefault");
    }
    DBQuery query = db.createQuery(q.toString());
    query.setEntity("identity", identity);
    if (checkDefault){
      query.setBoolean("isDefault", defaultContexts ? true : false);
    }
   
    return query.list();
  }
View Full Code Here

   * @see org.olat.group.context.BGContextManager#findOLATResourcesForBGContext(org.olat.group.context.BGContext)
   */
  public List findOLATResourcesForBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    String q = " select bgcr.resource from org.olat.group.context.BGContext2Resource as bgcr where bgcr.groupContext = :context";
    DBQuery query = db.createQuery(q);
    query.setEntity("context", bgContext);
    return query.list();
  }
View Full Code Here

    }
   
    String query = "select v from org.olat.repository.RepositoryEntry v"+
      " inner join fetch v.olatResource as ores"+
      " where ores.key = :oreskey";
    DBQuery dbQuery = DBFactory.getInstance().createQuery(query);
    dbQuery.setLong("oreskey", ores.getKey().longValue());
    dbQuery.setCacheable(true);
   
    List result = dbQuery.list();
    int size = result.size();
    if (strict) {
      if (size != 1)
        throw new AssertException("Repository resourceable lookup returned zero or more than one result: " + size);
    }
View Full Code Here

  public RepositoryEntry lookupRepositoryEntryBySoftkey(String softkey, boolean strict) {
    String query = "select v from org.olat.repository.RepositoryEntry v" +
      " inner join fetch v.olatResource as ores"+
      " where v.softkey = :softkey";
   
    DBQuery dbQuery = DBFactory.getInstance().createQuery(query);
    dbQuery.setString("softkey", softkey);
    dbQuery.setCacheable(true);
    List result = dbQuery.list();
   
    int size = result.size();
    if (strict) {
      if (size != 1)
        throw new AssertException("Repository softkey lookup returned zero or more than one result: " + size+", softKey = "+softkey);
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.