Package org.olat.core.commons.persistence

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


        + " org.olat.group.BusinessGroupImpl as bgi" + " where bgi.ownerGroup = sgmi.securityGroup and sgmi.identity = :identId";
    if (bgContext != null) query = query + " and bgi.groupContext = :context";
    if (type != null) query = query + " and bgi.type = :type";

    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
    /*
     * query.append("select distinct v from" + "
     * org.olat.basesecurity.SecurityGroupMembershipImpl as sgmsi," + "
     * org.olat.repository.RepositoryEntry v" + " inner join fetch v.ownerGroup
     * as secGroup" + " inner join fetch v.olatResource as res where" + "
     * sgmsi.securityGroup = secGroup and sgmsi.identity.key=");
     */

    dbq.setLong("identId", identityP.getKey().longValue());
    if (bgContext != null) dbq.setEntity("context", bgContext);
    if (type != null) dbq.setString("type", type);

    List res = dbq.list();
    return res;
  }
View Full Code Here


    query = query + " and sgmi.identity = :identId";
    if (bgContext != null) query = query + " and bgi.groupContext = :context";
    if (type != null) query = query + " and bgi.type = :type";

    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
    dbq.setLong("identId", identityP.getKey().longValue());
    if (bgContext != null) dbq.setEntity("context", bgContext);
    if (type != null) dbq.setString("type", type);

    List res = dbq.list();
    return res;
  }
View Full Code Here

  /**
   *
   * @see org.olat.group.BusinessGroupManager#getAllBusinessGroups()
   */
  public List getAllBusinessGroups() {
    DBQuery dbq = DBFactory.getInstance().createQuery("select bgi from " + "  org.olat.group.BusinessGroupImpl as bgi ");
    return dbq.list();
  }
View Full Code Here

  /**
   * @see org.olat.group.context.BGContextManager#getGroupsOfBGContext(org.olat.group.context.BGContext)
   */
  public List<BusinessGroup> getGroupsOfBGContext(BGContext bgContext) {
    DB db = DBFactory.getInstance();
    DBQuery query;
    if (bgContext == null) {
      String q = "select bg from org.olat.group.BusinessGroupImpl bg where bg.groupContext is null";
      query = db.createQuery(q);
    } else {
      String q = "select bg from org.olat.group.BusinessGroupImpl bg where bg.groupContext = :context";
      query = db.createQuery(q);
      query.setEntity("context", bgContext);
    }
    return (List<BusinessGroup>) query.list();
  }
View Full Code Here

        + " where bgi.waitingGroup = sgmi.securityGroup and sgmi.identity = :identId";
    if (bgContext != null) query = query + " and bgi.groupContext = :context";
    if (type != null) query = query + " and bgi.type = :type";

    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
    dbq.setLong("identId", identityP.getKey().longValue());
    if (bgContext != null) dbq.setEntity("context", bgContext);
    if (type != null) dbq.setString("type", type);

    List res = dbq.list();
    return res;
  }
View Full Code Here

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

    if (groupContext != null) {
      q.append(" grp.groupContext = :context and");
    }
    q.append(" grp.name = :name").append(" and ((grp.partipiciantGroup = secgmemb.securityGroup").append(" and secgmemb.identity = :id) ")
        .append(" or (grp.ownerGroup = secgmemb.securityGroup").append(" and secgmemb.identity = :id)) ");
    DBQuery query = db.createQuery(q.toString());
    query.setEntity("id", identity);
    if (groupContext != null) {
      query.setEntity("context", groupContext);
    }
    query.setString("name", groupName);
    query.setCacheable(true);
    List result = query.list();
    if (result.size() == 0) return false;
    return ( ((Long) result.get(0)).intValue() > 0);
  }
View Full Code Here

   * @see org.olat.group.context.BGContextManager#countGroupsOfType(java.lang.String)
   */
  public int countGroupsOfType(String groupType) {
    DB db = DBFactory.getInstance();
    String q = "select count(bg) from org.olat.group.BusinessGroupImpl bg where bg.type = :type";
    DBQuery query = db.createQuery(q);
    query.setString("type", groupType);
    return ((Long) query.list().get(0)).intValue();
  }
View Full Code Here

   *      org.olat.group.context.BGContext)
   */
  public BusinessGroup findGroupOfBGContext(String groupName, BGContext bgContext) {
    DB db = DBFactory.getInstance();
    String q = "select bg from org.olat.group.BusinessGroupImpl bg where bg.groupContext = :context and bg.name = :name";
    DBQuery query = db.createQuery(q);
    query.setEntity("context", bgContext);
    query.setString("name", groupName);
    List results = query.list();
    if (results.size() == 0) return null;
    return (BusinessGroup) results.get(0);
  }
View Full Code Here

  public BusinessGroup findGroupAttendedBy(Identity identity, String groupName, BGContext bgContext) {
    String query = "select bgi from " + "  org.olat.group.BusinessGroupImpl as bgi "
        + ", org.olat.basesecurity.SecurityGroupMembershipImpl as sgmi" + " where bgi.name = :name "
        + " and bgi.partipiciantGroup =  sgmi.securityGroup" + " and sgmi.identity = :identId" + " and bgi.groupContext = :context";
    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query);
    dbq.setEntity("identId", identity);
    dbq.setString("name", groupName);
    dbq.setEntity("context", bgContext);
    List res = dbq.list();
    if (res.size() == 0) return null;
    else if (res.size() > 1) throw new AssertException("more than one result row found for (identity, groupname, context) ("
        + identity.getName() + ", " + groupName + ", " + bgContext.getName());
    return (BusinessGroup) res.get(0);
  }
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.