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 {
16 private static final long serialVersionUID = -4865668290514118396L;
18 private enum Execute { publish, promote }
20 private StudyService _studyService;
22 // ==============================================================================================================================
24 // ==============================================================================================================================
26 public String doEdition () {
27 // --------------------------
28 Session connex = Database.getSession();
29 Transaction transax = connex.beginTransaction();
31 mystudy = getOpenStudy();
33 Execute todo = Execute.valueOf(action);
34 Study study = mystudy.getStudyObject();
36 if (todo == Execute.publish) getStudyService().moveToPublic(study);
37 else if (todo == Execute.promote) getStudyService().moveToReference(study);
38 mystudy.getPopup().setContext("study", mystudy.getStudyRights()); // The context has changed
40 // Useless to update the open study
44 catch (RuntimeException saverror) {
45 logger.error("Reason:", saverror);
46 if (transax != null && transax.isActive()) {
47 // Second try-catch as the rollback could fail as well
50 } catch (HibernateException backerror) {
51 logger.debug("Error rolling back transaction", backerror);
58 * Get the studyService.
60 * @return the studyService
62 public StudyService getStudyService() {
67 * Set the studyService.
70 * the studyService to set
72 public void setStudyService(StudyService studyService) {
73 _studyService = studyService;