Package org.olat.core.commons.persistence

Examples of org.olat.core.commons.persistence.DB.createQuery()


    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


   * @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

   * @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;
View Full Code Here

        + " 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" + "
View Full Code Here

  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

    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();
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 ->
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();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.