Examples of DBQuery


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

   */
  public BGArea findBGArea(String areaName, BGContext groupContext) {
    DB db = DBFactory.getInstance();
    String q = "select area from org.olat.group.area.BGAreaImpl area " + " where area.name = :areaName"
        + " and area.groupContext = :context";
    DBQuery query = db.createQuery(q);
    query.setString("areaName", areaName);
    query.setEntity("context", groupContext);
    List areas = query.list();
    if (areas.size() == 0) {
      return null;
    } else if (areas.size() > 1) { throw new OLATRuntimeException(BGAreaManagerImpl.class, "findBGArea(" + areaName
        + ") returned more than one row for BGContext with key " + groupContext.getKey(), null); }
    return (BGAreaImpl) areas.get(0);
View Full Code Here

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

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

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

    String query = "select bgi from " + "  org.olat.group.BusinessGroupImpl as bgi "
        + ", org.olat.basesecurity.SecurityGroupMembershipImpl as sgmi" + ", org.olat.group.area.BGtoAreaRelationImpl as bgarel"
        + ", org.olat.group.area.BGAreaImpl as area" + " where area.name = :name " + " and bgarel.businessGroup = bgi"
        + " and bgarel.groupArea = area" + " and bgi.partipiciantGroup = sgmi.securityGroup" + " and sgmi.identity = :identId"
        + " and bgi.groupContext = :context";
    DBQuery dbq = DBFactory.getInstance().createQuery(query);
    dbq.setEntity("identId", identity);
    dbq.setString("name", areaName);
    dbq.setEntity("context", context);
    List result = dbq.list();
    return result;
  }
View Full Code Here

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

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

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

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

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

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

    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

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

  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

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

    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

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

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