import java.util.List;
import java.util.Map;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.service.SearchService;
-import org.splat.service.SearchServiceImpl;
-import org.splat.service.StudyService;
import org.splat.simer.Action;
-import org.splat.dal.dao.som.Database;
-import org.splat.dal.bo.som.Study;
-
+/**
+ * Action for updating lucene index.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
public class DatabaseIndexingAction extends Action {
/**
* Serial version ID.
*/
- private static final long serialVersionUID = 4194268823457749655L;
+ private static final long serialVersionUID = 4194268823457749655L;
- private List<ImportedStudy> newstudies;
- private String indices;
- private SearchService _searchService;
+ private List<ImportedStudy> newstudies;
+ private String indices;
private ImportedStudy _importedStudy;
- private StudyService _studyService;
-
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doInitialize () {
-// -----------------------------
- Session connex = Database.getCurSession();
- Transaction transax = connex.beginTransaction();
-
- newstudies = getImportedStudy().selectAll();
- indices = "";
-
- transax.commit();
- return SUCCESS;
- }
-
- public String doIndexing () {
-// ---------------------------
- Session connex = Database.getCurSession();
- Transaction transax = connex.beginTransaction();
- String[] ridlist = indices.split(",");
- @SuppressWarnings("unchecked")
- Map<String, Object> filter = (Map<String, Object>)getSession().get("study.filter");
-
- for (int i=0; i<ridlist.length; i++) {
- int index = Integer.valueOf(ridlist[i].trim());
- Study study = getStudyService().selectStudy(index);
- getSearchService().indexStudy(study);
- }
- filter.put("owner", "all"); // Just in case of 1st study search
-
- transax.commit();
- return SUCCESS;
- }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public List<ImportedStudy> getNewStudies () {
-// -------------------------------------------
- return newstudies;
- }
- public String getIndices () {
-// ---------------------------
- return indices;
- }
-
- public void setIndices (String indices) {
-// ---------------------------------------
- this.indices = indices;
- }
+ /**
+ * Injected search service.
+ */
+ private SearchService _searchService;
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
/**
- * Get the searchService.
- * @return the searchService
+ * Initialize the action.
+ * @return SUCCESS
*/
- public SearchService getSearchService() {
- return _searchService;
+ public String doInitialize() {
+ newstudies = getImportedStudy().selectAll();
+ indices = "";
+ return SUCCESS;
}
/**
- * Set the searchService.
- * @param searchService the searchService to set
+ * Reindex studies.
+ * @return SUCCESS
*/
- public void setSearchService(SearchService searchService) {
- _searchService = searchService;
+ public String doIndexing() {
+ String[] ridlist = indices.split(",");
+ @SuppressWarnings("unchecked")
+ Map<String, Object> filter = (Map<String, Object>) getSession().get(
+ "study.filter");
+ getSearchService().reindexStudies(ridlist);
+ filter.put("owner", "all"); // Just in case of 1st study search
+
+ return SUCCESS;
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ /**
+ * Get the new studies.
+ *
+ * @return the new studies
+ */
+ public List<ImportedStudy> getNewStudies() {
+ // -------------------------------------------
+ return newstudies;
}
/**
* Get the importedStudy.
+ *
* @return the importedStudy
*/
public ImportedStudy getImportedStudy() {
/**
* Set the importedStudy.
- * @param importedStudy the importedStudy to set
+ *
+ * @param importedStudy
+ * the importedStudy to set
*/
public void setImportedStudy(ImportedStudy importedStudy) {
_importedStudy = importedStudy;
}
/**
- * Get the studyService.
+ * Get the indices.
+ * @return the indices
+ */
+ public String getIndices() {
+ return indices;
+ }
+
+ /**
+ * Set the indices.
+ * @param indices the indices to set
+ */
+ public void setIndices(String indices) {
+ this.indices = indices;
+ }
+
+ /**
+ * Get the searchService.
*
- * @return the studyService
+ * @return the searchService
*/
- public StudyService getStudyService() {
- return _studyService;
+ public SearchService getSearchService() {
+ return _searchService;
}
/**
- * Set the studyService.
+ * Set the searchService.
*
- * @param studyService
- * the studyService to set
+ * @param searchService
+ * the searchService to set
*/
- public void setStudyService(StudyService studyService) {
- _studyService = studyService;
+ public void setSearchService(SearchService searchService) {
+ _searchService = searchService;
}
}
\ No newline at end of file