X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman%2Fsrc%2Forg%2Fsplat%2Fsimer%2FSearchStudyAction.java;fp=Workspace%2FSiman%2Fsrc%2Forg%2Fsplat%2Fsimer%2FSearchStudyAction.java;h=070c1de8773c6e23fbcf6a4f13adf64b56e839c5;hb=8e8300c8f11a0560fd92e29adf75b691ef340ee9;hp=b331929ba5a7540eeccd5a38af463feec97f18ea;hpb=372a66bfd3072d7b810acddb9c58eca24baf5b9e;p=tools%2Fsiman.git diff --git a/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java b/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java index b331929..070c1de 100644 --- a/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java @@ -1,5 +1,6 @@ package org.splat.simer; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -27,22 +28,10 @@ public class SearchStudyAction extends AbstractSearchBaseAction { * "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. */ @@ -102,8 +91,8 @@ public class SearchStudyAction extends AbstractSearchBaseAction { 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); @@ -119,8 +108,8 @@ public class SearchStudyAction extends AbstractSearchBaseAction { 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"; } @@ -129,14 +118,6 @@ public class SearchStudyAction extends AbstractSearchBaseAction { // Getters // ============================================================================================================================== - public String getContextMatch() { - return _contextMatch; - } - - public String getCriteriaMatch() { - return _criteriaMatch; - } - public String getReference() { return _reference; } @@ -145,22 +126,6 @@ public class SearchStudyAction extends AbstractSearchBaseAction { 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; } @@ -169,14 +134,6 @@ public class SearchStudyAction extends AbstractSearchBaseAction { this._state = value; } - public void setWords(final String value) { - this._words = value; - } - - // ============================================================================================================================== - // Implementation of abstract services - // ============================================================================================================================== - @Override protected List getInvolvedContexts() { List steps = getProjectSettings() @@ -194,12 +151,12 @@ public class SearchStudyAction extends AbstractSearchBaseAction { Map filter = (Map) 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) filter.get("context"); } @@ -210,17 +167,48 @@ public class SearchStudyAction extends AbstractSearchBaseAction { Map filter = (Map) 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) filter.get("context"); // Only criteria not part of the form } + /** + * Get match options. + * + * @return array of options with key and value properties + */ + public Map getStateOptions() { + Map options = new LinkedHashMap(); + 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 options, + final String state) { + options.put(state, getText("criterion." + state.toLowerCase())); + } + /** * Get the searchService. *