Skip to content
Snippets Groups Projects
Commit 12b5ff85 authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 8.3 to OpenOLAT default branch with fa515211225eba526fc9d65e34f979655249ead8

parents 7b2ed638 4b961abc
No related branches found
No related tags found
No related merge requests found
...@@ -39,3 +39,4 @@ c04c6d0e5c4eb486f95c62846c8f16869752497d OpenOLAT 8.3.3 ...@@ -39,3 +39,4 @@ c04c6d0e5c4eb486f95c62846c8f16869752497d OpenOLAT 8.3.3
c705216e80316b862757515d1a9f0f772393fbc8 OpenOLAT 8.3.4 c705216e80316b862757515d1a9f0f772393fbc8 OpenOLAT 8.3.4
c705216e80316b862757515d1a9f0f772393fbc8 OpenOLAT 8.3.4 c705216e80316b862757515d1a9f0f772393fbc8 OpenOLAT 8.3.4
138f584995d4a899f812e5a921ba079aed8d9e48 OpenOLAT 8.3.4 138f584995d4a899f812e5a921ba079aed8d9e48 OpenOLAT 8.3.4
f944e71e243fc3fd4b9af3538049373e7eb692b0 OpenOLAT 8.3.5
...@@ -25,6 +25,9 @@ import java.util.HashSet; ...@@ -25,6 +25,9 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.persistence.DBFactory; import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.DBQuery; import org.olat.core.commons.persistence.DBQuery;
...@@ -285,22 +288,37 @@ public class UserCommentsManagerImpl extends UserCommentsManager { ...@@ -285,22 +288,37 @@ public class UserCommentsManagerImpl extends UserCommentsManager {
public int deleteAllComments() { public int deleteAllComments() {
DB db = DBFactory.getInstance(); DB db = DBFactory.getInstance();
// special query when sub path is null // special query when sub path is null
List<UserCommentImpl> comments;
if (getOLATResourceableSubPath() == null) { if (getOLATResourceableSubPath() == null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(UserCommentImpl.class.getName()).append(" where resName=:resName and resId=:resId and resSubPath is null"); sb.append("select comment from ").append(UserCommentImpl.class.getName()).append(" comment")
return db.getCurrentEntityManager().createQuery(sb.toString()) .append(" where resName=:resName and resId=:resId and resSubPath is null")
.append(" order by creationDate desc");
comments = db.getCurrentEntityManager().createQuery(sb.toString(), UserCommentImpl.class)
.setParameter("resName", getOLATResourceable().getResourceableTypeName()) .setParameter("resName", getOLATResourceable().getResourceableTypeName())
.setParameter("resId", getOLATResourceable().getResourceableId()) .setParameter("resId", getOLATResourceable().getResourceableId())
.executeUpdate(); .getResultList();
} else { } else {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(UserCommentImpl.class.getName()).append(" where resName=:resName and resId=:resId and resSubPath=:resSubPath"); sb.append("select comment from ").append(UserCommentImpl.class.getName()).append(" comment")
return db.getCurrentEntityManager().createQuery(sb.toString()) .append(" where resName=:resName and resId=:resId and resSubPath=:resSubPath")
.append(" order by creationDate desc");
comments = db.getCurrentEntityManager().createQuery(sb.toString(), UserCommentImpl.class)
.setParameter("resName", getOLATResourceable().getResourceableTypeName()) .setParameter("resName", getOLATResourceable().getResourceableTypeName())
.setParameter("resId", getOLATResourceable().getResourceableId()) .setParameter("resId", getOLATResourceable().getResourceableId())
.setParameter("resSubPath", getOLATResourceableSubPath()) .setParameter("resSubPath", getOLATResourceableSubPath())
.executeUpdate(); .getResultList();
} }
if(comments != null && !comments.isEmpty()) {
for(UserCommentImpl comment:comments) {
db.getCurrentEntityManager().remove(comment);
}
}
return comments == null ? 0 : comments.size();
} }
/** /**
...@@ -310,11 +328,18 @@ public class UserCommentsManagerImpl extends UserCommentsManager { ...@@ -310,11 +328,18 @@ public class UserCommentsManagerImpl extends UserCommentsManager {
public int deleteAllCommentsIgnoringSubPath() { public int deleteAllCommentsIgnoringSubPath() {
DB db = DBFactory.getInstance(); DB db = DBFactory.getInstance();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(UserCommentImpl.class.getName()).append(" where resName=:resName and resId=:resId"); sb.append("select comment from ").append(UserCommentImpl.class.getName()).append(" comment")
return db.getCurrentEntityManager().createQuery(sb.toString()) .append(" where resName=:resName and resId=:resId")
.append(" order by creationDate desc");
List<UserCommentImpl> comments = db.getCurrentEntityManager().createQuery(sb.toString(), UserCommentImpl.class)
.setParameter("resName", getOLATResourceable().getResourceableTypeName()) .setParameter("resName", getOLATResourceable().getResourceableTypeName())
.setParameter("resId", getOLATResourceable().getResourceableId()) .setParameter("resId", getOLATResourceable().getResourceableId())
.executeUpdate(); .getResultList();
for(UserCommentImpl comment:comments) {
db.getCurrentEntityManager().remove(comment);
}
return comments.size();
} }
......
...@@ -157,7 +157,7 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements ...@@ -157,7 +157,7 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements
*/ */
private List<Property> loadPropertiesFor(List<Identity> identities) { private List<Property> loadPropertiesFor(List<Identity> identities) {
if(identities == null || identities.isEmpty()) return Collections.emptyList(); if(identities == null || identities.isEmpty()) return Collections.emptyList();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("from org.olat.properties.Property as p") sb.append("from org.olat.properties.Property as p")
.append(" inner join fetch p.identity as ident ") .append(" inner join fetch p.identity as ident ")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment