Examples of DB


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

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

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

  public List getResultSets(Long olatResource, String olatResourceDetail, Long repositoryRef, Identity identity) {
    Long olatRes = olatResource;
    String olatResDet = olatResourceDetail;
    Long repRef = repositoryRef;

    DB db = DBFactory.getInstance();

    StringBuilder slct = new StringBuilder();
    slct.append("select rset from ");
    slct.append("org.olat.ims.qti.QTIResultSet rset ");
    slct.append("where ");
    slct.append("rset.olatResource=? ");
    slct.append("and rset.olatResourceDetail=? ");
    slct.append("and rset.repositoryRef=? ");
    if (identity != null) {
      slct.append("and rset.identity.key=? ");
      return db.find(slct.toString(), new Object[] { olatRes, olatResDet, repRef, identity.getKey() }, new Type[] { Hibernate.LONG, Hibernate.STRING,
          Hibernate.LONG, Hibernate.LONG });
    } else {
      return db.find(slct.toString(), new Object[] { olatRes, olatResDet, repRef }, new Type[] { Hibernate.LONG, Hibernate.STRING,
          Hibernate.LONG });
    }
  }
View Full Code Here

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

  public List selectResults(Long olatResource, String olatResourceDetail, Long repositoryRef, int type) {
    Long olatRes = olatResource;
    String olatResDet = olatResourceDetail;
    Long repRef = repositoryRef;

    DB db = DBFactory.getInstance();
    // join with user to sort by name
    StringBuilder slct = new StringBuilder();
    slct.append("select res from ");
    slct.append("org.olat.ims.qti.QTIResultSet rset, ");
    slct.append("org.olat.ims.qti.QTIResult res, ");
    slct.append("org.olat.core.id.Identity identity, ");
    slct.append("org.olat.user.UserImpl usr ");
    slct.append("where ");
    slct.append("rset.key = res.resultSet ");
    slct.append("and rset.identity = identity.key ");
    slct.append("and identity.user = usr.key ");
    slct.append("and rset.olatResource=? ");
    slct.append("and rset.olatResourceDetail=? ");
    slct.append("and rset.repositoryRef=? ");
     // 1 -> iqtest, 2 -> iqself
    if(type == 1 || type == 2)
        slct.append("order by usr.properties['").append(UserConstants.LASTNAME).append("'] , rset.assessmentID, res.itemIdent");
      //3 -> iqsurv: the alphabetical assortment above could destroy the anonymization
      // if names and quantity of the persons is well-known
    else
        slct.append("order by rset.creationDate, rset.assessmentID, res.itemIdent");

    List results = null;
    results = db.find(slct.toString(), new Object[] { olatRes, olatResDet, repRef }, new Type[] { Hibernate.LONG, Hibernate.STRING,
        Hibernate.LONG });
   
    return results;
  }
View Full Code Here

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

   * @param olatResDet
   * @param repRef
   * @return deleted ResultSets
   */
  public int deleteAllResults(Long olatRes, String olatResDet, Long repRef) {
    DB db = DBFactory.getInstance();

    StringBuilder slct = new StringBuilder();
    slct.append("select rset from ");
    slct.append("org.olat.ims.qti.QTIResultSet rset ");
    slct.append("where ");
    slct.append("rset.olatResource=? ");
    slct.append("and rset.olatResourceDetail=? ");
    slct.append("and rset.repositoryRef=? ");

    List results = null;
    results = db.find(slct.toString(), new Object[] { olatRes, olatResDet, repRef }, new Type[] { Hibernate.LONG, Hibernate.STRING,
        Hibernate.LONG });

    String delRes = "from res in class org.olat.ims.qti.QTIResult where res.resultSet.key = ?";
    String delRset = "from rset in class org.olat.ims.qti.QTIResultSet where rset.key = ?";

    int deletedRset = 0;

    for (Iterator iter = results.iterator(); iter.hasNext();) {
      QTIResultSet rSet = (QTIResultSet) iter.next();
      Long rSetKey = rSet.getKey();
      db.delete(delRes, rSetKey, Hibernate.LONG);
      db.delete(delRset, rSetKey, Hibernate.LONG);
      deletedRset++;
    }
    return deletedRset;
  }
View Full Code Here

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

    pm.saveProperty(p2);
    getWindowControl().setInfo("Properties<br />TestTransactionalKey-1=doTestNonTransactional_1,<br />TestTransactionalKey-2=doTestNonTransactional_2 created");
  }

  private void doTestTransactional() {
    DB db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    Property p1 = pm.createPropertyInstance(null, null, null, propertyCategory, propertyKey1, null, null, "doTestTransactional_1", null);
    pm.saveProperty(p1);
    Property p2 = pm.createPropertyInstance(null, null, null, propertyCategory, propertyKey2, null, null, "doTestTransactional_2", null);
    pm.saveProperty(p2);
View Full Code Here

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

    pm.saveProperty(p2);
    getWindowControl().setInfo("Properties<br />TestTransactionalKey-1=doTestTransactional_1,<br />TestTransactionalKey-2=doTestTransactional_2 created");
  }

  private void doTestMixTransactional() {
    DB db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    Property p1 = pm.createPropertyInstance(null, null, null, propertyCategory, propertyKey1, null, null, "doTestMixTransactional_1", null);
    pm.saveProperty(p1);
    Property p2 = pm.createPropertyInstance(null, null, null, propertyCategory, propertyKey2, null, null, "doTestMixTransactional_2", null);
    pm.saveProperty(p2);
View Full Code Here

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

    getWindowControl().setError("Should generate error for rollback!");
    Tracing.logError("Should generate error and not reach this code",getClass());
  }

  private void doTestTransactionalError() {
    DB db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    Property p1 = pm.createPropertyInstance(null, null, null, propertyCategory, propertyKey1, null, null, "doTestTransactionalError_1", null);
    pm.saveProperty(p1);
    // name is null => generated DB error => rollback
    Property p2 = pm.createPropertyInstance(null, null, null, propertyCategory, null, null, null, "doTestTransactionalError_2", null);
View Full Code Here

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

    getWindowControl().setError("Should generate error for rollback!");
    Tracing.logError("Should generate error for rollback and not reach this code",getClass());
  }
 
  private void doTestMixTransactionalError() {
    DB db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    Property p1 = pm.createPropertyInstance(null, null, null, propertyCategory, propertyKey1, null, null, "doTestMixTransactional_1", null);
    pm.saveProperty(p1);
    // name is null => generated DB error => rollback
    Property p2 = pm.createPropertyInstance(null, null, null, propertyCategory, null, null, null, "doTestMixTransactional_2", null);
View Full Code Here

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

    ForumImpl fo = (ForumImpl) DBFactory.getInstance().loadObject(ForumImpl.class, forumKey);
    return fo;
  }

  private Forum saveForum(Forum forum) {
    DB db = DBFactory.getInstance();
    db.saveObject(forum);
    return forum;
  }
View Full Code Here

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

   *
   * @param forum
   */
  private void doDeleteForum(Forum forum) {
    Long forumKey = forum.getKey();
    DB db = DBFactory.getInstance();
    //delete read messsages
    db.delete("from readMsg in class org.olat.modules.fo.ReadMessageImpl where readMsg.forum = ? ", forumKey, Hibernate.LONG);
    // delete messages
    db.delete("from message in class org.olat.modules.fo.MessageImpl where message.forum = ?", forumKey, Hibernate.LONG);
    // delete forum
    db.delete("from forum in class org.olat.modules.fo.ForumImpl where forum.key = ?", forumKey, Hibernate.LONG);
    // delete properties   
  }
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.