]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Salome HOME
Refactoring of Database, replacing SQL by DAOs calls. Methods for search by criteria...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditScenarioPropertiesAction.java
1 package org.splat.simer;
2
3 import java.text.SimpleDateFormat;
4 import java.util.ResourceBundle;
5
6 import org.hibernate.Session;
7 import org.hibernate.Transaction;
8 import org.splat.dal.bo.kernel.User;
9 import org.splat.dal.dao.som.Database;
10 import org.splat.dal.bo.som.Scenario;
11 import org.splat.service.ProjectElementService;
12 import org.splat.service.ScenarioService;
13 import org.splat.som.Step;
14 import org.splat.som.StepRights;
15
16 public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
17
18         private Scenario myscenario;
19         private String lasdate;
20         private String subject;
21         private ScenarioService _scenarioService;
22         private ProjectElementService _projectElementService;
23
24         /**
25          * Serial version ID.
26          */
27         private static final long serialVersionUID = 4964740932426016171L;
28
29         // ==============================================================================================================================
30         // Action methods
31         // ==============================================================================================================================
32
33         public String doInitialize() {
34                 // -----------------------------
35                 ResourceBundle label = ResourceBundle.getBundle("labels",
36                                 ApplicationSettings.getCurrentLocale());
37                 ResourceBundle custom = ResourceBundle.getBundle("som",
38                                 ApplicationSettings.getCurrentLocale());
39                 SimpleDateFormat datstring = new SimpleDateFormat(
40                                 custom.getString("date.format")); // Locale date display format
41                 Step step;
42
43                 mystudy = getOpenStudy();
44                 step = mystudy.getSelectedStep();
45                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
46                 lasdate = datstring.format(myscenario.getLastModificationDate());
47                 subject = label.getString("label.study") + " " + mystudy.getTitle();
48
49                 return SUCCESS;
50         }
51
52         public String doCheckin() {
53                 // --------------------------
54                 Session connex = Database.getSession();
55                 Transaction transax = connex.beginTransaction();
56                 Step step;
57
58                 mystudy = getOpenStudy();
59                 selection = mystudy.getSelection();
60                 step = mystudy.getSelectedStep();
61                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
62
63                 getScenarioService().checkin(myscenario);
64                 transax.commit();
65
66                 mystudy.getMenu().refreshGivenStepItem(
67                                 getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
68                 return SUCCESS;
69         }
70
71         // ==============================================================================================================================
72         // Getters
73         // ==============================================================================================================================
74
75         public User getAuthor() {
76                 // ------------------------
77                 if (myscenario.isCheckedout())
78                         return myscenario.getUser();
79                 else
80                         return myscenario.getAuthor();
81         }
82
83         public String getLastModificationDate() {
84                 // ----------------------------------------
85                 return lasdate;
86         }
87
88         public StepRights getSelectedStep() {
89                 // ------------------------------------
90                 return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
91         }
92
93         public String getSubject() {
94                 // ---------------------------
95                 return subject;
96         }
97
98         public String getTitle() {
99                 // -------------------------
100                 return myscenario.getTitle();
101         }
102
103         public boolean isCheckedout() {
104                 // ------------------------------
105                 return myscenario.isCheckedout();
106         }
107
108         /**
109          * Get the scenarioService.
110          * 
111          * @return the scenarioService
112          */
113         public ScenarioService getScenarioService() {
114                 return _scenarioService;
115         }
116
117         /**
118          * Set the scenarioService.
119          * 
120          * @param scenarioService
121          *            the scenarioService to set
122          */
123         public void setScenarioService(ScenarioService scenarioService) {
124                 _scenarioService = scenarioService;
125         }
126
127         /**
128          * Get the projectElementService.
129          * 
130          * @return the projectElementService
131          */
132         public ProjectElementService getProjectElementService() {
133                 return _projectElementService;
134         }
135
136         /**
137          * Set the projectElementService.
138          * 
139          * @param projectElementService
140          *            the projectElementService to set
141          */
142         public void setProjectElementService(
143                         ProjectElementService projectElementService) {
144                 _projectElementService = projectElementService;
145         }
146 }