Examples of DB


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

  /**
   * @see org.olat.core.commons.services.commentAndRating.UserRatingsManager#deleteAllRatings()
   */
  @Override
  public int deleteAllRatings() {
    DB db = DBFactory.getInstance();
    String query;
    Object[] values;
    Type[] types;
    // special query when sub path is null
    if (getOLATResourceableSubPath() == null) {
      query = "from UserRatingImpl where resName=? AND resId=? AND resSubPath is NULL";
      values = new Object[] { getOLATResourceable().getResourceableTypeName(),  getOLATResourceable().getResourceableId() };
      types = new Type[] {Hibernate.STRING, Hibernate.LONG};
    } else {
      query = "from UserRatingImpl where resName=? AND resId=? AND resSubPath=?";
      values = new Object[] { getOLATResourceable().getResourceableTypeName(),  getOLATResourceable().getResourceableId(), getOLATResourceableSubPath() };
      types = new Type[] {Hibernate.STRING, Hibernate.LONG, Hibernate.STRING};
    }
    return db.delete(query, values, types);
  }
View Full Code Here

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

  public int deleteAllRatingsIgnoringSubPath() {
    // Don't limit to subpath. Ignore if null or not, just delete on the resource
    String query = "from UserRatingImpl where resName=? AND resId=?";
    Object[] values = new Object[] { getOLATResourceable().getResourceableTypeName(),  getOLATResourceable().getResourceableId() };
    Type[] types = new Type[] {Hibernate.STRING, Hibernate.LONG};
    DB db = DBFactory.getInstance();
    return db.delete(query, values, types);   
  }
View Full Code Here

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

   * @see org.olat.core.commons.services.commentAndRating.UserRatingsManager#reloadRating(org.olat.core.commons.services.commentAndRating.model.UserRating)
   */
  @Override
  public UserRating reloadRating(UserRating rating) {
    try {
      DB db = DBFactory.getInstance();
      return (UserRating) db.loadObject(rating);     
    } catch (Exception e) {
      // Huh, most likely the given object does not exist anymore on the
      // db, probably deleted by someone else
      logWarn("Tried to reload a user rating but got an exception. Probably deleted in the meantime", e);
      return null;
View Full Code Here

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

      // Original rating has been deleted in the meantime. Don't update it
      return null;
    }
    // Update DB entry
    rating.setRating(newRatingValue);
    DB db = DBFactory.getInstance();
    db.updateObject(rating);
    return rating;
  }
View Full Code Here

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

  /**
   * @see org.olat.core.commons.services.commentAndRating.UserCommentsManager#reloadComment(org.olat.core.commons.services.commentAndRating.model.UserComment)
   */
  public UserComment reloadComment(UserComment comment) {
    try {
      DB db = DBFactory.getInstance();
      return (UserComment) db.loadObject(comment);     
    } catch (Exception e) {
      // Huh, most likely the given object does not exist anymore on the
      // db, probably deleted by someone else
      logWarn("Tried to reload a user comment but got an exception. Probably deleted in the meantime", e);
      return null;
View Full Code Here

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

      // Original comment has been deleted in the meantime. Don't update it
      return null;
    }
    // Update DB entry
    comment.setComment(newCommentText);
    DB db = DBFactory.getInstance();
    db.updateObject(comment);
    return comment;
  }
View Full Code Here

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

    comment = reloadComment(comment);
    if (comment == null) {
      // Original comment has been deleted in the meantime. Don't delete it again.
      return 0;
    }
    DB db = DBFactory.getInstance();
    // First deal with all direct replies
    DBQuery query = db.createQuery("select comment from UserCommentImpl as comment where parent=:parent");
    query.setEntity("parent", comment);
    List<UserComment> replies = query.list();
    if (deleteReplies) {
      // Since we have a many-to-one we first have to recursively delete
      // the replies to prevent foreign key constraints
      for (UserComment reply : replies) {
        counter += deleteComment(reply, true);
      }
    } else {
      // To not delete the replies we have to set the parent to the parent
      // of the original comment for each reply
      for (UserComment reply : replies) {
        reply.setParent(comment.getParent());
        db.updateObject(reply);
      }
    }
    // Now delete this comment and finish
    db.deleteObject(comment);
    return counter+1;
  }
View Full Code Here

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

 
  /**
   * @see org.olat.core.commons.services.commentAndRating.UserCommentsManager#deleteAllComments()
   */
  public int deleteAllComments() {
    DB db = DBFactory.getInstance();
    String query;
    Object[] values;
    Type[] types;
    // special query when sub path is null
    if (getOLATResourceableSubPath() == null) {
      query = "from UserCommentImpl where resName=? AND resId=? AND resSubPath is NULL";
      values = new Object[] { getOLATResourceable().getResourceableTypeName(),  getOLATResourceable().getResourceableId() };
      types = new Type[] {Hibernate.STRING, Hibernate.LONG};
    } else {
      query = "from UserCommentImpl where resName=? AND resId=? AND resSubPath=?";
      values = new Object[] { getOLATResourceable().getResourceableTypeName(),  getOLATResourceable().getResourceableId(), getOLATResourceableSubPath() };
      types = new Type[] {Hibernate.STRING, Hibernate.LONG, Hibernate.STRING};
    }
    return db.delete(query, values, types);
  }
View Full Code Here

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

  public int deleteAllCommentsIgnoringSubPath() {
    // Don't limit to subpath. Ignore if null or not, just delete on the resource
    String query = "from UserCommentImpl where resName=? AND resId=?";
    Object[] values = new Object[] { getOLATResourceable().getResourceableTypeName(),  getOLATResourceable().getResourceableId() };
    Type[] types = new Type[] {Hibernate.STRING, Hibernate.LONG};
    DB db = DBFactory.getInstance();
    return db.delete(query, values, types);   
  }
View Full Code Here

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

    query.append(" and p.identity is not null");
    query.append(" and ( p.name = '").append(AssessmentManager.SCORE);
    query.append("' or p.name = '").append(AssessmentManager.PASSED);
    query.append("' )");

    DB db = DBFactory.getInstance();
    DBQuery dbq = db.createQuery(query.toString());
    ICourse course = CourseFactory.loadCourse(ores);
    dbq.setLong("resid", course.getResourceableId().longValue());
    dbq.setString("resname", course.getResourceableTypeName());

    List res = dbq.list();
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.