1 package org.splat.simer;
5 import org.splat.service.KnowledgeElementService;
6 import org.splat.service.dto.KnowledgeElementDTO;
7 import org.splat.som.Step;
8 import org.splat.wapp.Constants;
10 public class DisplayKnowledgeAction extends AbstractDisplayAction {
15 private static final long serialVersionUID = 8473504456981431762L;
18 * Current knowledge element details.
20 protected transient OpenKnowledge _myknelm = null;
23 * Injected knowledge element service.
25 private KnowledgeElementService _knowledgeElementService;
28 * Value of the menu property.
29 * It can be: none, create, open, study, knowledge, sysadmin, help.
31 private String _menuProperty;
34 * Value of the title bar property.
35 * It can be: study, knowledge.
37 private String _titleProperty;
40 * Value of the tool bar property.
41 * It can be: none, standard, study, back.
43 private String _toolProperty;
46 * Value of the left menu property.
47 * It can be: open, study, knowledge, scenario.
49 private String _leftMenuProperty;
52 * Property that indicates whether the current open study is editable or not.
53 * On the screen it looks like pen on the status icon, pop-up menu also can be called.
54 * It is necessary for correct building the title bar.
56 private String _editDisabledProperty = "false";
58 // ==============================================================================================================================
60 // ==============================================================================================================================
62 public String doOpen() {
63 _myknelm = getOpenKnowledge();
64 if (_myindex == null) {
65 if (_selection != null) { // Re-opening (refreshing) the currently open knowledge
66 KnowledgeElementDTO kelm = getKnowledgeElementService()
67 .getKnowledgeElement(_myknelm.getIndex());
68 _myknelm = open(kelm); // Closes the previously open knowledge
69 _myknelm.setSelection(_selection);
72 try { // Opening a knowledge from the search result
73 int index = Integer.valueOf(_myindex);
74 if (_myknelm != null && _myknelm.getIndex() == index) { // - The selected knowledge is currently open
75 _selection = _myknelm.getSelection(); // Current selection
76 } else { // - The selected knowledge is new
77 KnowledgeElementDTO kelm = getKnowledgeElementService()
78 .getKnowledgeElement(index);
79 _myknelm = open(kelm);
80 _selection = _myknelm.getSelection(); // Default selection
82 } catch (Exception error) {
83 LOG.error("Reason:", error);
87 getSession().put("menu.knowledge", _myknelm.getMenu());
89 setMenuProperty(Constants.KNOWLEDGE_MENU);
90 setTitleProperty(Constants.KNOWLEDGE_MENU);
91 setToolProperty(Constants.NONE);
92 setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
93 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
98 public String doSelectStep() {
99 _myknelm = getOpenKnowledge();
101 if (_selection == null) { // Switch back to the current study
102 _selection = _myknelm.getSelection();
103 } else { // Selection of a step of current study
104 _myknelm.setSelection(_selection);
107 setMenuProperty(Constants.KNOWLEDGE_MENU);
108 setTitleProperty(Constants.KNOWLEDGE_MENU);
109 setToolProperty(Constants.NONE);
110 setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
111 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
116 public String doSelectDocument() {
117 Execute todo = Execute.valueOf(_action);
118 _myknelm = getOpenKnowledge();
119 if (todo == Execute.develop) {
120 _myknelm.developDocument(_myindex);
121 } else if (todo == Execute.reduce) {
122 _myknelm.reduceHistory(_myindex);
123 } else if (todo == Execute.reduceall) {
124 _myknelm.reduceDocument(_myindex);
127 setMenuProperty(Constants.KNOWLEDGE_MENU);
128 setTitleProperty(Constants.KNOWLEDGE_MENU);
129 setToolProperty(Constants.NONE);
130 setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
131 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
136 public String doSelectKnowledge() {
137 Execute todo = Execute.valueOf(_action);
138 _myknelm = getOpenKnowledge();
139 if (todo == Execute.develop) {
140 _myknelm.developKnowledge(_myindex);
141 } else if (todo == Execute.reduce) {
142 _myknelm.reduceKnowledge(_myindex);
145 setMenuProperty(Constants.KNOWLEDGE_MENU);
146 setTitleProperty(Constants.KNOWLEDGE_MENU);
147 setToolProperty(Constants.NONE);
148 setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
149 initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
154 public String doClose() {
157 setMenuProperty(Constants.NONE);
158 initializationScreenContext(_menuProperty);
163 // ==============================================================================================================================
165 // ==============================================================================================================================
167 public List<DocumentFacade> getDocuments() {
168 return _myknelm.getDisplayedDocuments();
171 public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
172 return _myknelm.getDisplayedKnowledges();
175 public List<SimulationContextFacade> getSimulationContexts() {
176 return _myknelm.getDisplayedSimulationContexts();
179 public Step getSelectedStep() {
180 return _myknelm.getSelectedStep();
184 public String getWriteAccess() {
189 * Get the knowledgeElementService.
191 * @return the knowledgeElementService
193 public KnowledgeElementService getKnowledgeElementService() {
194 return _knowledgeElementService;
198 * Set the knowledgeElementService.
200 * @param knowledgeElementService
201 * the knowledgeElementService to set
203 public void setKnowledgeElementService(
204 final KnowledgeElementService knowledgeElementService) {
205 _knowledgeElementService = knowledgeElementService;
209 * Get the menuProperty.
210 * @return the menuProperty
212 public String getMenuProperty() {
213 return _menuProperty;
217 * Set the menuProperty.
218 * @param menuProperty the menuProperty to set
220 public void setMenuProperty(final String menuProperty) {
221 this._menuProperty = menuProperty;
225 * Get the _titleProperty.
226 * @return the _titleProperty
228 public String getTitleProperty() {
229 return _titleProperty;
233 * Set the _titleProperty.
234 * @param _titleProperty the titleProperty to set
236 public void setTitleProperty(final String titleProperty) {
237 _titleProperty = titleProperty;
241 * Get the _editDisabledProperty.
242 * @return the _editDisabledProperty
244 public final String getEditDisabledProperty() {
245 return _editDisabledProperty;
249 * Set the editDisabledProperty.
250 * @param editDisabledProperty the editDisabledProperty to set
252 public final void setEditDisabledProperty(final String editDisabledProperty) {
253 this._editDisabledProperty = editDisabledProperty;
257 * Get the toolProperty.
258 * @return the toolProperty
260 public String getToolProperty() {
261 return _toolProperty;
265 * Set the toolProperty.
266 * @param toolProperty the toolProperty to set
268 public void setToolProperty(final String toolProperty) {
269 _toolProperty = toolProperty;
273 * Get the leftMenuProperty.
274 * @return the leftMenuProperty
276 public String getLeftMenuProperty() {
277 return _leftMenuProperty;
281 * Set the leftMenuProperty.
282 * @param leftMenuProperty the leftMenuProperty to set
284 public void setLeftMenuProperty(final String leftMenuProperty) {
285 _leftMenuProperty = leftMenuProperty;