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