Salome HOME
"Mark as reference" and "Remove as reference" functionality is implemented.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditStudyAction.java
1 package org.splat.simer;
2
3 import org.splat.dal.bo.som.Study;
4 import org.splat.service.StudyService;
5
6 public class EditStudyAction extends DisplayStudyStepAction {
7
8         /**
9          * Serial version ID.
10          */
11         private static final long serialVersionUID = -4865668290514118396L;
12         
13         /**
14          * Injected study service.
15          */
16         private StudyService _studyService;
17
18         private enum Execute {
19                 publish, promote
20         }
21
22         // ==============================================================================================================================
23         // Action methods
24         // ==============================================================================================================================
25
26         public String doEdition() {
27                 _openStudy = getOpenStudy();
28
29                 Execute todo = Execute.valueOf(_action);
30                 Study study = _openStudy.getStudyObject();
31
32                 if (todo == Execute.publish) {
33                         getStudyService().moveToPublic(study);
34                 } else if (todo == Execute.promote) {
35                         getStudyService().moveToReference(study);
36                 }
37                 _openStudy.getPopup().setContext("study", _openStudy.getStudyRights()); // The context has changed
38
39                 setMenu();
40
41                 return SUCCESS;
42         }
43         
44         /**
45          * Mark study as reference functionality.
46          * @return SUCCESS
47          */
48         public String doMarkAsReference() {
49                 
50                 _openStudy = getOpenStudy();
51                 Study study = _openStudy.getStudyObject();
52                 
53                 _studyService.markStudyAsReference(study);
54                 
55                 return SUCCESS;
56         }
57         
58         /**
59          * Remove study as reference functionality.
60          * @return SUCCESS
61          */
62         public String doRemoveAsReference() {
63                 
64                 _openStudy = getOpenStudy();
65                 Study study = _openStudy.getStudyObject();
66                 
67                 _studyService.removeStudyAsReference(study);
68                 
69                 return SUCCESS;
70         }
71         
72         /**
73          * Get the studyService.
74          * 
75          * @return the studyService
76          */
77         @Override
78         public StudyService getStudyService() {
79                 return _studyService;
80         }
81
82         /**
83          * Set the studyService.
84          * 
85          * @param studyService
86          *            the studyService to set
87          */
88         @Override
89         public void setStudyService(final StudyService studyService) {
90                 _studyService = studyService;
91         }
92
93 }