Package org.olat.core.commons.persistence

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


   * @param versionID
   * @param itemIdent
   * @return
   */
  public List findQtiResults(long assessmentID, long versionID, String itemIdent) {
    DB persister = DBFactory.getInstance();
    return persister.find("from q in class org.olat.ims.qti.QTIResult where "
        + "q.assessmentID = ? and q.versionid = ? and q.itemident = ?", new Object[]{new Long(assessmentID),
        new Long(versionID), itemIdent}, new Type[]{Hibernate.LONG, Hibernate.LONG, Hibernate.STRING});
  }
View Full Code Here


   * @param olatResourceDetail
   * @return Returns the last recorded QTIResultSet
   */
  public QTIResultSet getLastResultSet(Identity identity, long olatResource, String olatResourceDetail) {
    QTIResultSet returnQTIResultSet=null;
    DB persister = DBFactory.getInstance();
    List resultSetList =  persister.find("from q in class org.olat.ims.qti.QTIResultSet where "
        + "q.identity = ? and q.olatResource = ? and q.olatResourceDetail = ? order by q.creationDate desc", new Object[]{identity.getKey(), new Long(olatResource), new String(olatResourceDetail)},
        new Type[]{Hibernate.LONG, Hibernate.LONG, Hibernate.STRING});
    Iterator resultSetIterator = resultSetList.iterator();
    while(resultSetIterator.hasNext()) {
      returnQTIResultSet = (QTIResultSet)resultSetIterator.next();
View Full Code Here

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

  /**
   * Delete checklist.
   * @param checklist
   */
  public void deleteChecklist(final Checklist cl) {
    final DB db = DBFactory.getInstance();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Checklist.class, cl.getKey());
    CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
        public void execute() {
          Checklist checklist = (Checklist) db.loadObject(cl);
          db.deleteObject(checklist);
        }
    });
  }
View Full Code Here

   * @param type
   * @param groupContext
   * @return
   */
  public static boolean checkIfOneOrMoreNameExistsInContext(Set names, BGContext groupContext) {
    DB db = DBFactory.getInstance();
    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;
View Full Code Here

  /**
   * @see org.olat.group.area.BGAreaManager#findBGArea(java.lang.String,
   *      org.olat.group.context.BGContext)
   */
  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;
View Full Code Here

      DBFactory.getJunitInstance().clearDatabase();
      id1 = JunitTestHelper.createAndPersistIdentityAsUser("one");
      id2 = JunitTestHelper.createAndPersistIdentityAsUser("twoo");
      id3 = JunitTestHelper.createAndPersistIdentityAsUser("three");
     
      DB db = DBFactory.getInstance();
      OLATResourceManager rm = OLATResourceManager.getInstance();
      // create course and persist as OLATResourceImpl
      OLATResourceable resourceable = OresHelper.createOLATResourceableInstance("junitcourse",new Long(456));
      course1 =  rm.createOLATResourceInstance(resourceable);
      db.saveObject(course1);
     
     
      DBFactory.getInstance().closeSession();
    } catch (Exception e) {
      log.error("Exception in setUp(): " + e);
View Full Code Here

   * @param groupContext The group context of null
   * @return true if a group in such a context with the given name exists false
   *         otherwhise
   */
  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;
View Full Code Here

      //import "Demo course" into the bcroot_junittest
      RepositoryEntry repositoryEntry = JunitTestHelper.deployDemoCourse();
      Long resourceableId = repositoryEntry.getOlatResource().getResourceableId();
      System.out.println("Demo course imported - resourceableId: " + resourceableId);
         
      DB db = DBFactory.getInstance();     
      course = CourseFactory.loadCourse(resourceableId);
      DBFactory.getInstance().closeSession();
           
      course.getCourseEnvironment().getCourseConfig().setEfficencyStatementIsEnabled(true);
      course = CourseFactory.loadCourse(resourceableId);
View Full Code Here

   * @see org.olat.basesecurity.Manager#deleteSecurityGroup(org.olat.basesecurity.SecurityGroup)
   */
  public void deleteSecurityGroup(SecurityGroup secGroup) {
    // we do not use hibernate cascade="delete", but implement our own (to be
    // sure to understand our code)
    DB db = DBFactory.getInstance();
    //FIXME: fj: Please review: Create rep entry, restart olat, delete the rep
    // entry. previous implementation resulted in orange screen
    // secGroup = (SecurityGroup)db.loadObject(secGroup); // so we can later
    // delete it (hibernate needs an associated session)
    secGroup = (SecurityGroup) db.loadObject(secGroup);
    //o_clusterREVIEW
    //db.reputInHibernateSessionCache(secGroup);

    /*
     * if (!db.contains(secGroup)) { secGroup = (SecurityGroupImpl)
     * db.loadObject(SecurityGroupImpl.class, secGroup.getKey()); }
     */
    // 1) delete associated users (need to do it manually, hibernate knows
    // nothing about
    // the membership, modeled manually via many-to-one and not via set)
    db.delete("from org.olat.basesecurity.SecurityGroupMembershipImpl as msi where msi.securityGroup.key = ?", new Object[] { secGroup
        .getKey() }, new Type[] { Hibernate.LONG });
    // 2) delete all policies
    db.delete("from org.olat.basesecurity.PolicyImpl as poi where poi.securityGroup = ?", new Object[] { secGroup.getKey() },
        new Type[] { Hibernate.LONG });
    // 3) delete security group
    db.deleteObject(secGroup);
  }
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.