1 package org.splat.simer;
3 import java.text.SimpleDateFormat;
4 import java.util.ResourceBundle;
6 import org.splat.dal.bo.kernel.User;
7 import org.splat.dal.bo.som.Scenario;
8 import org.splat.kernel.InvalidPropertyException;
9 import org.splat.service.ProjectElementService;
10 import org.splat.service.ScenarioService;
11 import org.splat.som.Step;
12 import org.splat.som.StepRights;
13 import org.splat.wapp.Constants;
15 public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
20 private static final long serialVersionUID = 4964740932426016171L;
22 private transient Scenario _myscenario;
23 private transient String _lasdate;
24 private transient String _subject;
27 * The Scenario service.
29 private ScenarioService _scenarioService;
32 * The PojectElement service.
34 private ProjectElementService _projectElementService;
36 // ==============================================================================================================================
38 // ==============================================================================================================================
40 public String doInitialize() {
41 ResourceBundle label = ResourceBundle.getBundle("labels",
42 getApplicationSettings().getCurrentLocale());
43 ResourceBundle custom = ResourceBundle.getBundle("som",
44 getApplicationSettings().getCurrentLocale());
45 SimpleDateFormat datstring = new SimpleDateFormat(custom
46 .getString("date.format")); // Locale date display format
49 _openStudy = getOpenStudy();
50 step = _openStudy.getSelectedStep();
51 _myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
52 _lasdate = datstring.format(_myscenario.getLastModificationDate());
53 _subject = label.getString("label.study") + " " + _openStudy.getTitle();
55 initializationFullScreenContext(Constants.STUDY_MENU,
56 Constants.STUDY_MENU, "true", "back", "open");
62 * Mark the scenario as checked in.
65 * @throws InvalidPropertyException
66 * if scenario is not found in the database
68 public String doCheckin() throws InvalidPropertyException {
71 _openStudy = getOpenStudy();
72 _selection = _openStudy.getSelection();
73 step = _openStudy.getSelectedStep();
74 _myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
76 getScenarioService().checkin(_myscenario.getIndex());
77 // TODO: Do it in the business service after moving to DTO instead of id parameter
78 // or reread the scenario.
79 _myscenario.setUser(null);
81 _openStudy.getMenu().refreshGivenStepItem(
82 getProjectElementService().getFirstStep(_myscenario)); // For updating the scenario icon
84 if ("true".equals(getWriteAccess())
85 && getUserRights().canCreateDocument()) {
86 setToolProperty(Constants.STUDY_MENU);
88 setToolProperty(Constants.STANDARD_MENU);
90 initializationFullScreenContext(Constants.STUDY_MENU,
91 getToolProperty(), Constants.STUDY_MENU);
96 // ==============================================================================================================================
98 // ==============================================================================================================================
101 * Get current scenario editor or author if the scenario is not checked out.
103 * @return the scenario editor or author
105 public User getAuthor() {
107 if (_myscenario.isCheckedout()) {
108 author = _myscenario.getUser();
110 author = _myscenario.getAuthor();
115 public String getLastModificationDate() {
119 public StepRights getSelectedStep() {
120 return _openStudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
123 public String getSubject() {
127 public String getTitle() {
128 return _myscenario.getTitle();
131 public boolean isCheckedout() {
132 return _myscenario.isCheckedout();
136 * Get the scenarioService.
138 * @return the scenarioService
140 public ScenarioService getScenarioService() {
141 return _scenarioService;
145 * Set the scenarioService.
147 * @param scenarioService
148 * the scenarioService to set
150 public void setScenarioService(final ScenarioService scenarioService) {
151 _scenarioService = scenarioService;
155 * Get the projectElementService.
157 * @return the projectElementService
159 public ProjectElementService getProjectElementService() {
160 return _projectElementService;
164 * Set the projectElementService.
166 * @param projectElementService
167 * the projectElementService to set
169 public void setProjectElementService(
170 final ProjectElementService projectElementService) {
171 _projectElementService = projectElementService;