Skip to content

Commit

Permalink
SAK-49627 Lessons deleting comments tool should delete comments (saka…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkjanetschek authored Mar 21, 2024
1 parent 1b199ba commit d502aa7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,5 @@ public class PageData {

public void deleteQuestionResponsesForItem(SimplePageItem item);

public void deleteCommentsForLessonsItem(SimplePageItem item);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ public void deleteLogForLessonsItem(SimplePageItem item) {
}
}

public void deleteQuestionResponsesForItem(SimplePageItem item) {
public void deleteQuestionResponsesForItem(SimplePageItem item) {
try {
DetachedCriteria d = DetachedCriteria.forClass(SimplePageQuestionResponse.class).add(Restrictions.eq("questionId",item.getId()));
DetachedCriteria d2 = DetachedCriteria.forClass(SimplePageQuestionResponseTotals.class).add(Restrictions.eq("questionId",item.getId()));
Expand All @@ -1992,7 +1992,14 @@ public void deleteQuestionResponsesForItem(SimplePageItem item) {
} catch (DataAccessException e) {
log.error("Failed to delete SimplePageQuestion responses for item {}: {}", item.getId(), e.toString());
}

}

public void deleteCommentsForLessonsItem(SimplePageItem item) {
try {
DetachedCriteria d = DetachedCriteria.forClass(SimplePageComment.class).add(Restrictions.eq("itemId",item.getId()));
getHibernateTemplate().deleteAll(getHibernateTemplate().findByCriteria(d));
} catch (DataAccessException e) {
log.error("Failed to delete SimplePageComments for item {}: {}", item.getId(), e.toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,11 @@ public String deleteItem(SimplePageItem item, boolean updateSequence) {
simplePageToolDao.deleteQuestionResponsesForItem(item);
}

//delete comment entries
if(item.getType() == SimplePageItem.COMMENTS) {
simplePageToolDao.deleteCommentsForLessonsItem(item);
}

// delete lessonsItem log
simplePageToolDao.deleteLogForLessonsItem(item);

Expand Down

0 comments on commit d502aa7

Please sign in to comment.