Salome HOME
Modifications to respect PMD rules.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / admin / DatabaseIndexingAction.java
1 package org.splat.simer.admin;
2
3 import java.util.List;
4 import java.util.Map;
5
6 import org.splat.service.SearchService;
7 import org.splat.service.dto.ImportedStudyDTO;
8 import org.splat.simer.Action;
9
10 /**
11  * Action for updating lucene index.
12  *
13  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
14  */
15 public class DatabaseIndexingAction extends Action {
16
17         /**
18          * Serial version ID.
19          */
20         private static final long serialVersionUID = 4194268823457749655L;
21
22         /**
23          * New studies which are not yet indexed by lucene.
24          */
25         private transient List<ImportedStudyDTO> _newstudies;
26         /**
27          * Id's of studies to reindex.
28          */
29         private String _indices;
30         /**
31          * Injected search service.
32          */
33         private SearchService _searchService;
34         
35         /**
36          * Value of the menu property. 
37          * It can be: none, create, open, study, knowledge, sysadmin, help.
38          */
39         private String _menuProperty;
40         
41         /**
42          * Value of the tool bar property. 
43          * It can be: none, standard, study, back.
44          */
45         private String _toolProperty;
46         
47         /**
48          * Value of the left menu property. 
49          * It can be: open, study, knowledge, scenario.
50          */
51         private String _leftMenuProperty;
52
53         // ==============================================================================================================================
54         // Action methods
55         // ==============================================================================================================================
56
57         /**
58          * Initialize the action.
59          * @return SUCCESS
60          */
61         public String doInitialize() {
62                 _newstudies = getSearchService().selectStudies();
63                 _indices = "";
64                 
65                 setMenuProperty("sysadmin");
66                 setToolProperty("none");
67                 setLeftMenuProperty("open");
68                 initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
69                 
70                 return SUCCESS;
71         }
72
73         /**
74          * Reindex studies.
75          * @return SUCCESS
76          */
77         public String doIndexing() {
78                 String[] ridlist = _indices.split(",");
79                 @SuppressWarnings("unchecked")
80                 Map<String, Object> filter = (Map<String, Object>) getSession().get(
81                                 "study.filter");
82                 getSearchService().reindexStudies(ridlist);
83                 filter.put("owner", "all"); // Just in case of 1st study search
84
85                 return SUCCESS;
86         }
87
88         // ==============================================================================================================================
89         // Getters and setters
90         // ==============================================================================================================================
91
92         /**
93          * Get the new studies.
94          * 
95          * @return the new studies
96          */
97         public List<ImportedStudyDTO> getNewStudies() {
98                 return _newstudies;
99         }
100
101         /**
102          * Get the indices.
103          * @return the indices
104          */
105         public String getIndices() {
106                 return _indices;
107         }
108
109         /**
110          * Set the indices.
111          * @param indices the indices to set
112          */
113         public void setIndices(final String indices) {
114                 this._indices = indices;
115         }
116
117         /**
118          * Get the searchService.
119          * 
120          * @return the searchService
121          */
122         public SearchService getSearchService() {
123                 return _searchService;
124         }
125
126         /**
127          * Set the searchService.
128          * 
129          * @param searchService
130          *            the searchService to set
131          */
132         public void setSearchService(final SearchService searchService) {
133                 _searchService = searchService;
134         }
135         
136         /**
137          * Get the menuProperty.
138          * @return the menuProperty
139          */
140         public String getMenuProperty() {
141                 return _menuProperty;
142         }
143
144         /**
145          * Set the menuProperty.
146          * @param menuProperty the menuProperty to set
147          */
148         public void setMenuProperty(final String menuProperty) {
149                 this._menuProperty = menuProperty;
150         }
151         
152         /**
153          * Get the toolProperty.
154          * @return the toolProperty
155          */
156         public String getToolProperty() {
157                 return _toolProperty;
158         }
159
160         /**
161          * Set the toolProperty.
162          * @param toolProperty the toolProperty to set
163          */
164         public void setToolProperty(final String toolProperty) {
165                 _toolProperty = toolProperty;
166         }
167         
168         /**
169          * Get the leftMenuProperty.
170          * @return the leftMenuProperty
171          */
172         public String getLeftMenuProperty() {
173                 return _leftMenuProperty;
174         }
175
176         /**
177          * Set the leftMenuProperty.
178          * @param leftMenuProperty the leftMenuProperty to set
179          */
180         public void setLeftMenuProperty(final String leftMenuProperty) {
181                 _leftMenuProperty = leftMenuProperty;
182         }
183 }