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 {
17 private Scenario myscenario;
18 private String lasdate;
19 private String subject;
22 * The Scenario service.
24 private ScenarioService _scenarioService;
27 * The PojectElement service.
29 private ProjectElementService _projectElementService;
32 * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
34 private String _menuProperty;
37 * Value of the title bar property. It can be: study, knowledge.
39 private String _titleProperty;
42 * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
43 * menu also can be called. It is necessary for correct building the title bar.
45 private String _editDisabledProperty = "false";
48 * Value of the tool bar property. It can be: none, standard, study, back.
50 private String _toolProperty;
53 * Value of the left menu property. It can be: open, study, knowledge, scenario.
55 private String _leftMenuProperty;
60 private static final long serialVersionUID = 4964740932426016171L;
62 // ==============================================================================================================================
64 // ==============================================================================================================================
66 public String doInitialize() {
67 // -----------------------------
68 ResourceBundle label = ResourceBundle.getBundle("labels",
69 getApplicationSettings().getCurrentLocale());
70 ResourceBundle custom = ResourceBundle.getBundle("som",
71 getApplicationSettings().getCurrentLocale());
72 SimpleDateFormat datstring = new SimpleDateFormat(custom
73 .getString("date.format")); // Locale date display format
76 _openStudy = getOpenStudy();
77 step = _openStudy.getSelectedStep();
78 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
79 lasdate = datstring.format(myscenario.getLastModificationDate());
80 subject = label.getString("label.study") + " " + _openStudy.getTitle();
82 setMenuProperty(Constants.STUDY_MENU);
83 setTitleProperty(Constants.STUDY_MENU);
84 setEditDisabledProperty("true");
85 setToolProperty("back");
86 setLeftMenuProperty("open");
87 initializationFullScreenContext(_menuProperty, _titleProperty,
88 _editDisabledProperty, _toolProperty, _leftMenuProperty);
94 * Mark the scenario as checked in.
97 * @throws InvalidPropertyException
98 * if scenario is not found in the database
100 public String doCheckin() throws InvalidPropertyException {
103 _openStudy = getOpenStudy();
104 _selection = _openStudy.getSelection();
105 step = _openStudy.getSelectedStep();
106 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
108 getScenarioService().checkin(myscenario.getIndex());
109 // TODO: Do it in the business service after moving to DTO instead of id parameter
110 // or reread the scenario.
111 myscenario.setUser(null);
113 _openStudy.getMenu().refreshGivenStepItem(
114 getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
116 setMenuProperty(Constants.STUDY_MENU);
117 if ("true".equals(getWriteAccess())
118 && getUserRights().canCreateDocument()) {
119 setToolProperty(Constants.STUDY_MENU);
121 setToolProperty("standard");
123 setLeftMenuProperty(Constants.STUDY_MENU);
124 initializationFullScreenContext(_menuProperty, _toolProperty,
130 // ==============================================================================================================================
132 // ==============================================================================================================================
135 * Get current scenario editor or author if the scenario is not checked out.
137 * @return the scenario editor or author
139 public User getAuthor() {
141 if (myscenario.isCheckedout()) {
142 author = myscenario.getUser();
144 author = myscenario.getAuthor();
149 public String getLastModificationDate() {
153 public StepRights getSelectedStep() {
154 return _openStudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
157 public String getSubject() {
161 public String getTitle() {
162 return myscenario.getTitle();
165 public boolean isCheckedout() {
166 return myscenario.isCheckedout();
170 * Get the scenarioService.
172 * @return the scenarioService
174 public ScenarioService getScenarioService() {
175 return _scenarioService;
179 * Set the scenarioService.
181 * @param scenarioService
182 * the scenarioService to set
184 public void setScenarioService(final ScenarioService scenarioService) {
185 _scenarioService = scenarioService;
189 * Get the projectElementService.
191 * @return the projectElementService
193 public ProjectElementService getProjectElementService() {
194 return _projectElementService;
198 * Set the projectElementService.
200 * @param projectElementService
201 * the projectElementService to set
203 public void setProjectElementService(
204 final ProjectElementService projectElementService) {
205 _projectElementService = projectElementService;
209 * Get the menuProperty.
211 * @return the menuProperty
214 public String getMenuProperty() {
215 return _menuProperty;
219 * Set the menuProperty.
221 * @param menuProperty
222 * the menuProperty to set
225 public void setMenuProperty(final String menuProperty) {
226 this._menuProperty = menuProperty;
230 * Get the _titleProperty.
232 * @return the _titleProperty
235 public String getTitleProperty() {
236 return _titleProperty;
240 * Set the _titleProperty.
242 * @param _titleProperty
243 * the titleProperty to set
246 public void setTitleProperty(final String titleProperty) {
247 _titleProperty = titleProperty;
251 * Get the editDisabledProperty.
253 * @return the editDisabledProperty
256 public final String getEditDisabledProperty() {
257 return _editDisabledProperty;
261 * Set the editDisabledProperty.
263 * @param editDisabledProperty
264 * the editDisabledProperty to set
267 public final void setEditDisabledProperty(final String editDisabledProperty) {
268 _editDisabledProperty = editDisabledProperty;
272 * Get the toolProperty.
274 * @return the toolProperty
277 public String getToolProperty() {
278 return _toolProperty;
282 * Set the toolProperty.
284 * @param toolProperty
285 * the toolProperty to set
288 public void setToolProperty(final String toolProperty) {
289 _toolProperty = toolProperty;
293 * Get the leftMenuProperty.
295 * @return the leftMenuProperty
298 public String getLeftMenuProperty() {
299 return _leftMenuProperty;
303 * Set the leftMenuProperty.
305 * @param leftMenuProperty
306 * the leftMenuProperty to set
309 public void setLeftMenuProperty(final String leftMenuProperty) {
310 _leftMenuProperty = leftMenuProperty;