+ // Select all documents published in the study and study's scenarios.
+ DetachedCriteria query = DetachedCriteria.forClass(
+ Publication.class, "pub");
+ query
+ .createCriteria("pub.owner", "projelem",
+ Criteria.INNER_JOIN)
+ .createAlias("projelem.owner", "study", Criteria.LEFT_JOIN)
+ .add(
+ Restrictions
+ .or(Restrictions.eq("projelem.rid", index),
+ Restrictions.eq("study.rid", index)))
+ .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Find study documents: " + query.toString());
+ }
+ for (Publication pub : getPublicationDAO().getFilteredList(query)) {
+ docums.add(pub.value());
+ // Find also all previous versions of the document
+ for (org.splat.dal.bo.som.Document prev = pub.value()
+ .getPreviousVersion(); prev != null; prev = prev
+ .getPreviousVersion()) {
+ docums.add(prev);
+ }
+ }
+
+ // Delete the study with its relations, scenarios and publications