]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/EditStudyAction.java
Salome HOME
79c48426aa4e590ffaf8be83e9ffbbf1a750f455
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditStudyAction.java
1 package org.splat.simer;
2
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;
9
10
11 public class EditStudyAction extends DisplayStudyStepAction {
12     
13     private static final long serialVersionUID = -4865668290514118396L;
14
15         private enum Execute { publish, promote }
16
17         private StudyService _studyService;
18
19 //  ==============================================================================================================================
20 //  Action methods
21 //  ==============================================================================================================================
22
23     public String doEdition () {
24 //  --------------------------
25       Session      connex  = Database.getSession();
26           Transaction  transax = connex.beginTransaction();
27           try {
28         mystudy = getOpenStudy();
29
30         Execute  todo   = Execute.valueOf(action);
31         Study    study  = mystudy.getStudyObject();
32         
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
36
37 //      Useless to update the open study
38         transax.commit();
39         return SUCCESS;
40           }
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
45           try {
46             transax.rollback();
47           } catch (HibernateException backerror) {
48             logger.debug("Error rolling back transaction", backerror);
49           }
50         }
51         return ERROR;
52       }
53     }
54         /**
55          * Get the studyService.
56          * 
57          * @return the studyService
58          */
59         public StudyService getStudyService() {
60                 return _studyService;
61         }
62
63         /**
64          * Set the studyService.
65          * 
66          * @param studyService
67          *            the studyService to set
68          */
69         public void setStudyService(StudyService studyService) {
70                 _studyService = studyService;
71         }
72 }