Salome HOME
Tool bar is improved.
[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 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         // Action methods
49         // ==============================================================================================================================
50
51         /**
52          * Initialize the action.
53          * @return SUCCESS
54          */
55         public String doInitialize() {
56                 newstudies = getSearchService().selectStudies();
57                 indices = "";
58                 
59                 setMenuProperty("sysadmin");
60                 setToolProperty("none");
61         initializationScreenContext(_menuProperty, _toolProperty);
62                 
63                 return SUCCESS;
64         }
65
66         /**
67          * Reindex studies.
68          * @return SUCCESS
69          */
70         public String doIndexing() {
71                 String[] ridlist = indices.split(",");
72                 @SuppressWarnings("unchecked")
73                 Map<String, Object> filter = (Map<String, Object>) getSession().get(
74                                 "study.filter");
75                 getSearchService().reindexStudies(ridlist);
76                 filter.put("owner", "all"); // Just in case of 1st study search
77
78                 return SUCCESS;
79         }
80
81         // ==============================================================================================================================
82         // Getters and setters
83         // ==============================================================================================================================
84
85         /**
86          * Get the new studies.
87          * 
88          * @return the new studies
89          */
90         public List<ImportedStudyDTO> getNewStudies() {
91                 return newstudies;
92         }
93
94         /**
95          * Get the indices.
96          * @return the indices
97          */
98         public String getIndices() {
99                 return indices;
100         }
101
102         /**
103          * Set the indices.
104          * @param indices the indices to set
105          */
106         public void setIndices(String indices) {
107                 this.indices = indices;
108         }
109
110         /**
111          * Get the searchService.
112          * 
113          * @return the searchService
114          */
115         public SearchService getSearchService() {
116                 return _searchService;
117         }
118
119         /**
120          * Set the searchService.
121          * 
122          * @param searchService
123          *            the searchService to set
124          */
125         public void setSearchService(SearchService searchService) {
126                 _searchService = searchService;
127         }
128         
129         /**
130          * Get the menuProperty.
131          * @return the menuProperty
132          */
133         public String getMenuProperty() {
134                 return _menuProperty;
135         }
136
137         /**
138          * Set the menuProperty.
139          * @param menuProperty the menuProperty to set
140          */
141         public void setMenuProperty(String menuProperty) {
142                 this._menuProperty = menuProperty;
143         }
144         
145         /**
146          * Get the toolProperty.
147          * @return the toolProperty
148          */
149         public String getToolProperty() {
150                 return _toolProperty;
151         }
152
153         /**
154          * Set the toolProperty.
155          * @param toolProperty the toolProperty to set
156          */
157         public void setToolProperty(final String toolProperty) {
158                 _toolProperty = toolProperty;
159         }
160 }