Package org.olat.core.commons.persistence

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


  /**
   * @see org.olat.group.context.BGContextManager#findBGContextsForResource(org.olat.resource.OLATResource,
   *      java.lang.String, boolean, boolean)
   */
  public List findBGContextsForResource(OLATResource resource, String groupType, boolean defaultContexts, boolean nonDefaultContexts) {
    DB db = DBFactory.getInstance();
    StringBuilder q = new StringBuilder();
    q.append(" select context from org.olat.group.context.BGContextImpl as context,");
    q.append(" org.olat.group.context.BGContext2Resource as bgcr");
    q.append(" where bgcr.resource = :resource");
    q.append(" and bgcr.groupContext = context");
    if (groupType != null) q.append(" and context.groupType = :gtype");

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


  /**
   * @see org.olat.group.context.BGContextManager#findBGContextsForIdentity(org.olat.core.id.Identity,
   *      boolean, boolean)
   */
  public List findBGContextsForIdentity(Identity identity, boolean defaultContexts, boolean nonDefaultContexts) {
    DB db = DBFactory.getInstance();
    StringBuilder q = new StringBuilder();
    q.append(" select context from org.olat.group.context.BGContextImpl as context,");
    q.append(" org.olat.basesecurity.SecurityGroupMembershipImpl as secgmemb");
    q.append(" where context.ownerGroup = secgmemb.securityGroup");
    q.append(" and secgmemb.identity = :identity");

    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);
    }
   
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

  /**
   * TearDown is called after each test
   */
  public void tearDown() {
    try {
      DB db = DBFactory.getInstance();
      db.closeSession();
    } catch (Exception e) {
      log.error("Exception in tearDown(): " + e);
    }
  }
View Full Code Here

    DBFactory.getInstance().updateObject(identity);
  }

 
  public List<SecurityGroup> getSecurityGroupsForIdentity(Identity identity) {
    DB db = DBFactory.getInstance();
    List<SecurityGroup> secGroups = db.find(
        "select sgi from"
        + " org.olat.basesecurity.SecurityGroupImpl as sgi,"
        + " org.olat.basesecurity.SecurityGroupMembershipImpl as sgmsi "
        + " where sgmsi.securityGroup = sgi and sgmsi.identity = ?",
        new Object[] { identity.getKey() },
View Full Code Here

    UpgradeHistoryData uhd = upgradeManager.getUpgradesHistory(VERSION);
    if (!uhd.getBooleanDataValue(TASK_CREATE_DISCLAIMER_CONFIRMATION)) {
      // Get all system users
      Manager secMgr = ManagerFactory.getManager();
      RegistrationManager regMgr = RegistrationManager.getInstance();
      DB db = DBFactory.getInstance();
      // Get all users
      List<Identity> identities = secMgr.getVisibleIdentitiesByPowerSearch(null, null, false, null, null, null, null, null);
      // Remove the users that did already confirm the disclaimer
      List<Identity> confirmedIdentities = regMgr.getIdentitiesWithConfirmedDisclaimer();
      PersistenceHelper.removeObjectsFromList(identities, confirmedIdentities);
      // Set the disclaimer property for the remaining users
      for (int i = 0; i < identities.size(); i++) {
        Identity identity = identities.get(i);
        regMgr.setHasConfirmedDislaimer(identity);
        // write something to the console after each 100 user, this can take a
        // while with many users and it is handy to know that the system is
        // doing something
        if (i % 250 == 0) {
          log.audit("Busy creating disclaimer confirmation. Done with " + i + " of a total of " + identities.size() + " users. Please wait ...");
          db.intermediateCommit();
        }
      }
      log.audit("Done with creating disclaimer confirmation for " + identities.size() + " users");
     
      uhd.setBooleanDataValue(TASK_CREATE_DISCLAIMER_CONFIRMATION, true);
View Full Code Here

   * Delete all qti-results and qti-result-set entry for certain result-set.
   * @param rSet
   */
  private void deleteResultSet(QTIResultSet rSet) {
    Long rSetKey = rSet.getKey();
    DB db = DBFactory.getInstance();
    db.delete("from res in class org.olat.ims.qti.QTIResult where res.resultSet.key = ?", rSetKey, Hibernate.LONG);
    db.delete("from rset in class org.olat.ims.qti.QTIResultSet where rset.key = ?", rSetKey, Hibernate.LONG);
  }
View Full Code Here

  /**
   * @param newBookmark
   */
  public void createAndPersistBookmark(Bookmark newBookmark) {
    DB db = DBFactory.getInstance();
    db.saveObject(newBookmark);
    if (log.isDebug()){
      log.debug("Bookmark has been created: " + newBookmark.getTitle());
    }
    fireBookmarkEvent(newBookmark.getOwner());   
  }
View Full Code Here

   *
   * @return TemporaryKey
   */
  public TemporaryKeyImpl createTemporaryKeyByEmail(String email, String ip, String action) {
    TemporaryKeyImpl tk = null;
    DB db = DBFactory.getInstance();
    // check if the user is already registered
    // we also try to find it in the temporarykey list
    List tks = db.find("from org.olat.registration.TemporaryKeyImpl as r where r.emailAddress = ?", email,
        Hibernate.STRING);
    if ((tks == null) || (tks.size() != 1)) { // no user found, create a new one
      tk = register(email, ip, action);
    } else {
      tk = (TemporaryKeyImpl) tks.get(0);
View Full Code Here

   * @param email
   *
   * @return the found temporary key or null if none is found
   */
  public TemporaryKeyImpl loadTemporaryKeyByEmail(String email) {
    DB db = DBFactory.getInstance();
    List tks = db.find("from r in class org.olat.registration.TemporaryKeyImpl where r.emailAddress = ?", email,
        Hibernate.STRING);
    if (tks.size() == 1) {
      return (TemporaryKeyImpl) tks.get(0);
    } else {
      return null;
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.