package org.splat.simer;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
* "In-Work", "In-Draft", "In-Check"...
*/
private String _state = null;
- /**
- * Criteria match: "all" or "any".
- */
- private String _criteriaMatch = null;
- /**
- * Simulation context match: "all" or "any".
- */
- private String _contextMatch = null;
/**
* Study reference.
*/
private String _reference = null;
- /**
- * Full text search words.
- */
- private String _words = null;
/**
* Injected project settings service.
*/
if (!this._state.equals("ANY")) {
sprop.setState(ProgressState.valueOf(this._state));
}
- if (_words.length() > 0) {
- sprop.setTitle(_words);
+ if (getWords().length() > 0) {
+ sprop.setTitle(getWords());
}
if (_reference.length() > 0) {
sprop.setReference(_reference);
sprop.setActor(getConnectedUser());
_result = getSearchService().selectStudiesWhere(
- "all".equals(_criteriaMatch), "all".equals(_contextMatch),
- sprop);
+ "all".equals(getCriteriaMatch()),
+ "all".equals(getContextMatch()), sprop);
session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
return "refresh";
}
// Getters
// ==============================================================================================================================
- public String getContextMatch() {
- return _contextMatch;
- }
-
- public String getCriteriaMatch() {
- return _criteriaMatch;
- }
-
public String getReference() {
return _reference;
}
return _state;
}
- public String getWords() {
- return _words;
- }
-
- // ==============================================================================================================================
- // Setters
- // ==============================================================================================================================
-
- public void setContextMatch(final String value) {
- this._contextMatch = value;
- }
-
- public void setCriteriaMatch(final String value) {
- this._criteriaMatch = value;
- }
-
public void setReference(final String value) {
this._reference = value;
}
this._state = value;
}
- public void setWords(final String value) {
- this._words = value;
- }
-
- // ==============================================================================================================================
- // Implementation of abstract services
- // ==============================================================================================================================
-
@Override
protected List<SimulationContextType> getInvolvedContexts() {
List<ProjectSettingsService.Step> steps = getProjectSettings()
Map<String, Object> filter = (Map<String, Object>) session
.get("study.filter"); // A default filter is supposed being set at start
- _criteriaMatch = (String) filter.get("matchamong");
- _contextMatch = (String) filter.get("matcontext");
+ setCriteriaMatch((String) filter.get("matchamong"));
+ setContextMatch((String) filter.get("matcontext"));
_state = (String) filter.get("state");
_author = (String) filter.get("author");
_reference = (String) filter.get("reference");
- _words = (String) filter.get("title");
+ setWords((String) filter.get("title"));
_context = (List<SimulationContext>) filter.get("context");
}
Map<String, Object> filter = (Map<String, Object>) session
.get("study.filter"); // A default filter is supposed being set at start
- filter.put("matchamong", this._criteriaMatch);
- filter.put("matcontext", this._contextMatch);
+ filter.put("matchamong", getCriteriaMatch());
+ filter.put("matcontext", getContextMatch());
filter.put("state", this._state);
filter.put("author", this._author);
filter.put("reference", this._reference);
- filter.put("title", this._words);
+ filter.put("title", getWords());
_context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
}
+ /**
+ * Get match options.
+ *
+ * @return array of options with key and value properties
+ */
+ public Map<String, String> getStateOptions() {
+ Map<String, String> options = new LinkedHashMap<String, String>();
+ addStateOption(options, "ANY");
+ if (getConnectedUser() != null) {
+ addStateOption(options, ProgressState.inWORK.name());
+ addStateOption(options, ProgressState.inDRAFT.name());
+ addStateOption(options, ProgressState.inCHECK.name());
+ }
+ addStateOption(options, ProgressState.APPROVED.name());
+ addStateOption(options, ProgressState.TEMPLATE.name());
+ return options;
+ }
+
+ /**
+ * Add a state and its translation to the list (map) of options.
+ *
+ * @param options
+ * the map of options
+ * @param state
+ * the state to add
+ */
+ private void addStateOption(final Map<String, String> options,
+ final String state) {
+ options.put(state, getText("criterion." + state.toLowerCase()));
+ }
+
/**
* Get the searchService.
*