1 package org.splat.simer;
3 import org.hibernate.HibernateException;
4 import org.hibernate.Session;
5 import org.hibernate.Transaction;
6 import org.splat.dal.dao.som.Database;
7 import org.splat.dal.bo.som.Study;
8 import org.splat.service.StudyService;
11 public class EditStudyAction extends DisplayStudyStepAction {
13 private static final long serialVersionUID = -4865668290514118396L;
15 private enum Execute { publish, promote }
17 private StudyService _studyService;
19 // ==============================================================================================================================
21 // ==============================================================================================================================
23 public String doEdition () {
24 // --------------------------
25 Session connex = Database.getSession();
26 Transaction transax = connex.beginTransaction();
28 mystudy = getOpenStudy();
30 Execute todo = Execute.valueOf(action);
31 Study study = mystudy.getStudyObject();
33 if (todo == Execute.publish) getStudyService().moveToPublic(study);
34 else if (todo == Execute.promote) getStudyService().moveToReference(study);
35 mystudy.getPopup().setContext("study", mystudy.getStudyRights()); // The context has changed
37 // Useless to update the open study
41 catch (RuntimeException saverror) {
42 logger.error("Reason:", saverror);
43 if (transax != null && transax.isActive()) {
44 // Second try-catch as the rollback could fail as well
47 } catch (HibernateException backerror) {
48 logger.debug("Error rolling back transaction", backerror);
55 * Get the studyService.
57 * @return the studyService
59 public StudyService getStudyService() {
64 * Set the studyService.
67 * the studyService to set
69 public void setStudyService(StudyService studyService) {
70 _studyService = studyService;