1 package org.splat.simer;
3 import java.util.LinkedHashMap;
7 import org.splat.dal.bo.som.ProgressState;
8 import org.splat.dal.bo.som.SimulationContextType;
9 import org.splat.dal.bo.som.Study;
10 import org.splat.kernel.InvalidPropertyException;
11 import org.splat.service.SearchService;
12 import org.splat.service.dto.StudySearchFilterDTO;
13 import org.splat.service.technical.ProjectSettingsService;
14 import org.splat.service.technical.StepsConfigService;
15 import org.splat.wapp.Constants;
18 * Search studies form action.
20 public class SearchStudyAction extends
21 AbstractSearchBaseAction<StudySearchFilterDTO> {
26 private static final long serialVersionUID = -1910481357051393077L;
29 * Injected project settings service.
31 private StepsConfigService _stepsConfigService;
33 * Injected search service.
35 private SearchService _searchService;
37 // ==============================================================================================================================
39 // ==============================================================================================================================
42 * Initialize study search form.
44 * @return SUCCESS if no exception, otherwise return ERROR
46 public String doInitialize() {
52 // Final initialization of the form
54 setContextTypeOptions(getInvolvedContexts());
55 initializationFullScreenContext(Constants.OPEN, Constants.NONE,
58 } catch (Exception error) {
59 // No need to roll back the transaction as it is read only
60 LOG.error("Reason: ", error);
62 initializationScreenContext(Constants.NONE);
72 * @see org.splat.simer.AbstractSearchBaseAction#doSearch()
75 protected String doSearch() throws InvalidPropertyException {
76 if (getConnectedUser() != null) {
77 getFilter().setConnectedUserId(getConnectedUser().getIndex());
79 _result = getSearchService().selectStudiesWhere(getFilter());
80 getSession().put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
84 // ==============================================================================================================================
86 // ==============================================================================================================================
91 * @see org.splat.simer.AbstractSearchBaseAction#getInvolvedContexts()
94 protected List<SimulationContextType> getInvolvedContexts() {
95 List<ProjectSettingsService.Step> steps = getStepsConfigService()
96 .getStepsOf(Study.class);
97 ProjectSettingsService.Step[] number = steps
98 .toArray(new ProjectSettingsService.Step[steps.size()]);
100 return getSimulationContextService().selectTypesOf(number);
106 * @return array of options with key and value properties
108 public Map<String, String> getStateOptions() {
109 Map<String, String> options = new LinkedHashMap<String, String>();
110 addStateOption(options, "ANY");
111 if (getConnectedUser() != null) {
112 addStateOption(options, ProgressState.inWORK.name());
113 addStateOption(options, ProgressState.inDRAFT.name());
114 addStateOption(options, ProgressState.inCHECK.name());
116 addStateOption(options, ProgressState.APPROVED.name());
117 addStateOption(options, ProgressState.TEMPLATE.name());
122 * Add a state and its translation to the list (map) of options.
129 private void addStateOption(final Map<String, String> options,
130 final String state) {
131 options.put(state, getText("criterion." + state.toLowerCase()));
135 * Get the searchService.
137 * @return the searchService
139 public SearchService getSearchService() {
140 return _searchService;
144 * Set the searchService.
146 * @param searchService
147 * the searchService to set
149 public void setSearchService(final SearchService searchService) {
150 _searchService = searchService;
154 * Get StepsConfigService.
156 * @return StepsConfigService
158 private StepsConfigService getStepsConfigService() {
159 return _stepsConfigService;
163 * Set StepsConfigService.
165 * @param stepsConfigService
168 public void setStepsConfigService(
169 final StepsConfigService stepsConfigService) {
170 _stepsConfigService = stepsConfigService;
176 * @see org.splat.simer.AbstractSearchBaseAction#getFilterName()
179 protected String getFilterName() {
180 return "study.filter";
186 * @see org.splat.simer.AbstractSearchBaseAction#getNewFilter()
189 protected StudySearchFilterDTO getNewFilter() {
190 return new StudySearchFilterDTO();