Package org.olat.core.commons.persistence

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


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


    String query = "select bgi from " + " org.olat.basesecurity.SecurityGroupMembershipImpl as sgmi,"
        + " 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

  /**
   * @see org.olat.group.context.BGContextManager#getBGOwnersOfBGContext(org.olat.group.context.BGContext)
   */
  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

        + " where bgi.partipiciantGroup = sgmi.securityGroup";
    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

  /**
   * @see org.olat.group.context.BGContextManager#countBGOwnersOfBGContext(org.olat.group.context.BGContext)
   */
  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

        + ", org.olat.basesecurity.SecurityGroupMembershipImpl as sgmi"
        + " 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

  /**
   * @see org.olat.group.context.BGContextManager#getBGParticipantsOfBGContext(org.olat.group.context.BGContext)
   */
  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

  /**
   * @see org.olat.group.BusinessGroupManager#isIdentityInBusinessGroup(org.olat.core.id.Identity,
   *      java.lang.String, org.olat.group.context.BGContext)
   */
  public boolean isIdentityInBusinessGroup(Identity identity, String groupName, BGContext groupContext) {
    DB db = DBFactory.getInstance();
    StringBuilder q = new StringBuilder();
    q.append(" select count(grp) from").append(" org.olat.group.BusinessGroupImpl as grp,").append(
        " org.olat.basesecurity.SecurityGroupMembershipImpl as secgmemb").append(" where");
    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);
View Full Code Here

  /**
   * @see org.olat.group.context.BGContextManager#countBGParticipantsOfBGContext(org.olat.group.context.BGContext)
   */
  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
View Full Code Here

  /**
   * @see org.olat.group.context.BGContextManager#isIdentityInBGContext(org.olat.core.id.Identity,
   *      org.olat.group.context.BGContext, boolean, boolean)
   */
  public boolean isIdentityInBGContext(Identity identity, BGContext bgContext, boolean asOwner, boolean asParticipant) {
    DB db = DBFactory.getInstance();
    StringBuilder q = new StringBuilder();

    q.append(" select count(grp) from" + " org.olat.group.BusinessGroupImpl as grp,"
        + " org.olat.basesecurity.SecurityGroupMembershipImpl as secgmemb where grp.groupContext = :context" + " and ");
    // restricting where clause for participants
    String partRestr = "(grp.partipiciantGroup = secgmemb.securityGroup and secgmemb.identity = :id) ";
    // restricting where clause for owners
    String ownRestr = "(grp.ownerGroup = secgmemb.securityGroup and secgmemb.identity = :id)";

    if (asParticipant && asOwner) {
      q.append("(").append(partRestr).append(" or ").append(ownRestr).append(")");
    } else if (asParticipant && !asOwner) {
      q.append(partRestr);
    } else if (!asParticipant && asOwner) {
      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();

View Full Code Here

TOP

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

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.