]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java
Salome HOME
05b593179906b3accdf29a642dee55c6e8415835
[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         // Action methods
37         // ==============================================================================================================================
38
39         /**
40          * Initialize the action.
41          * @return SUCCESS
42          */
43         public String doInitialize() {
44                 _newstudies = getSearchService().selectStudies();
45                 _indices = "";
46                 
47                 initializationFullScreenContext("sysadmin", "none", "open");
48                 
49                 return SUCCESS;
50         }
51
52         /**
53          * Reindex studies.
54          * @return SUCCESS
55          */
56         public String doIndexing() {
57                 String[] ridlist = _indices.split(",");
58                 @SuppressWarnings("unchecked")
59                 Map<String, Object> filter = (Map<String, Object>) getSession().get(
60                                 "study.filter");
61                 getSearchService().reindexStudies(ridlist);
62                 filter.put("owner", "all"); // Just in case of 1st study search
63
64                 return SUCCESS;
65         }
66
67         // ==============================================================================================================================
68         // Getters and setters
69         // ==============================================================================================================================
70
71         /**
72          * Get the new studies.
73          * 
74          * @return the new studies
75          */
76         public List<ImportedStudyDTO> getNewStudies() {
77                 return _newstudies;
78         }
79
80         /**
81          * Get the indices.
82          * @return the indices
83          */
84         public String getIndices() {
85                 return _indices;
86         }
87
88         /**
89          * Set the indices.
90          * @param indices the indices to set
91          */
92         public void setIndices(final String indices) {
93                 this._indices = indices;
94         }
95
96         /**
97          * Get the searchService.
98          * 
99          * @return the searchService
100          */
101         public SearchService getSearchService() {
102                 return _searchService;
103         }
104
105         /**
106          * Set the searchService.
107          * 
108          * @param searchService
109          *            the searchService to set
110          */
111         public void setSearchService(final SearchService searchService) {
112                 _searchService = searchService;
113         }
114 }