From: rkv Date: Thu, 28 Feb 2013 11:22:35 +0000 (+0000) Subject: Refactoring of study and knowledge search actions and appropriate search pages. X-Git-Tag: Root_Delivery2_2013_04_22~125 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8e8300c8f11a0560fd92e29adf75b691ef340ee9;p=tools%2Fsiman.git Refactoring of study and knowledge search actions and appropriate search pages. --- diff --git a/Workspace/Siman/WebContent/study/searchKnowledge.jsp b/Workspace/Siman/WebContent/study/searchKnowledge.jsp index 301513c..22eec3f 100644 --- a/Workspace/Siman/WebContent/study/searchKnowledge.jsp +++ b/Workspace/Siman/WebContent/study/searchKnowledge.jsp @@ -11,6 +11,10 @@ @@ -22,36 +26,19 @@ $(document).ready(function () {
- - - @@ -81,7 +68,7 @@ $(document).ready(function () { - + - +
    - - -   - - - -   - - + |       - - -   - - - -   - - +
   " /> " />   " />" />
diff --git a/Workspace/Siman/WebContent/study/searchStudy.jsp b/Workspace/Siman/WebContent/study/searchStudy.jsp index 22499a3..0c9f091 100644 --- a/Workspace/Siman/WebContent/study/searchStudy.jsp +++ b/Workspace/Siman/WebContent/study/searchStudy.jsp @@ -1,19 +1,19 @@ <%@page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1" -%> + pageEncoding="ISO-8859-1"%> <%@taglib prefix="s" uri="/struts-tags"%> - + @@ -21,211 +21,202 @@ $(document).ready(function () { -
-
-
- - - - - +
+
+
+ - - - - - - -
-     - - -   - - - -   - - - |   -     - - -   - - - -   - - -
+ + + + + + + + +
    + |       +
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - -
  - -
  " />  " />
  " />  " />
- - - - - - - - -
" value="" onKeydown="changeFilter()" title="" />
" value="" onKeydown="changeFilter()" title="" />
-
- - - - - - - - +
')">  - - -
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  +
 
  " />  " />
  " />  " />
+ + + + + + + + + +
" onKeydown="changeFilter()" + title="" />
" + onKeydown="changeFilter()" + title="" />
+
+ + + + + + + + - - - - - - - -
')">  + +
- " border="none" title="" onClick="cancel()" />  - - - - - -
+ +
" + border="none" title="" + onClick="cancel()" />  + + +
- - - -
+ + + + + - - - - - -
" disabled/>
+ + + + + +
" disabled />
- -
-
+ +
+
-
-
-
-
- - - - - - - - - - - - - - - - - - -
" border="none"/>
" width=12 height=12 border="none" title=""/> - - - - -
-
- - - - -
-
-
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
" border="none" />
" + width="12" height="12" border="none" title="" /> + + + +
+
+ +
+
+
diff --git a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java index 0e76bba..b230240 100644 --- a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java +++ b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java @@ -4,7 +4,9 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.splat.dal.bo.kernel.User; import org.splat.dal.bo.som.SimulationContext; @@ -28,12 +30,10 @@ public abstract class AbstractSearchBaseAction extends Action { * Serial version ID. */ private static final long serialVersionUID = 7863055790228544510L; - /** * Search result key in the session. */ public static final String RESULT_KEY = "search.result"; - /** * Context type index, when selected. */ @@ -46,7 +46,13 @@ public abstract class AbstractSearchBaseAction extends Action { * Context index, when removed. */ protected transient String _cindex = ""; + /** + * Study author to search. + */ protected String _author = null; + /** + * List of users who can create studies. + */ protected List _candidates = null; /** * Context type to be valued. @@ -77,6 +83,18 @@ public abstract class AbstractSearchBaseAction extends Action { * Injected user service. */ private UserService _userService; + /** + * Simulation context match: "all" or "any". + */ + private String _contextMatch = null; + /** + * Criteria match: "all" or "any". + */ + private String _criteriaMatch = null; + /** + * Full text search words. + */ + private String _words = null; /** * Search action modes enumeration. @@ -319,6 +337,10 @@ public abstract class AbstractSearchBaseAction extends Action { this._cindex = value; } + /** + * Build the list of study authors. If the current user also can create
+ * a study then it is placed on the top of the list. + */ protected void setCandidates() { _candidates = new ArrayList(); List users = getUserService().selectAllUsers(); @@ -358,15 +380,13 @@ public abstract class AbstractSearchBaseAction extends Action { int to = 0; while (to < types.length - 1) { to += 1; - if (types[to].isAttachedTo(step)) { - continue; - } - - if (to > from + 1) { - Arrays.sort(types, from, to, compare); + if (!types[to].isAttachedTo(step)) { + if (to > from + 1) { + Arrays.sort(types, from, to, compare); + } + from = to; + step = getSimulationContextService().getAttachedStep(types[to]); } - from = to; - step = getSimulationContextService().getAttachedStep(types[to]); } if (to > from) { Arrays.sort(types, from, to + 1, compare); @@ -386,6 +406,22 @@ public abstract class AbstractSearchBaseAction extends Action { protected abstract void saveFilter(); + // ============================================================================================================================== + // Getters and Setters + // ============================================================================================================================== + + /** + * Get match options. + * + * @return array of options with key and value properties + */ + public Map getMatchOptions() { + Map options = new LinkedHashMap(); + options.put("all", getText("field.matchall")); + options.put("any", getText("field.matchany")); + return options; + } + /** * Get the simulationContextService. * @@ -424,4 +460,28 @@ public abstract class AbstractSearchBaseAction extends Action { public void setUserService(final UserService userService) { _userService = userService; } + + public String getContextMatch() { + return _contextMatch; + } + + public String getCriteriaMatch() { + return _criteriaMatch; + } + + public void setContextMatch(final String value) { + this._contextMatch = value; + } + + public void setCriteriaMatch(final String value) { + this._criteriaMatch = value; + } + + public String getWords() { + return _words; + } + + public void setWords(final String value) { + this._words = value; + } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java b/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java index 035efd1..5224806 100644 --- a/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java +++ b/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java @@ -29,22 +29,10 @@ public class SearchKnowledgeAction extends AbstractSearchBaseAction { * Knowledge type index when among all. */ private String _state = null; - /** - * Criteria match: "all" or "any". - */ - private String _criteriaMatch = null; - /** - * Simulation context match: "all" or "any". - */ - private String _contextMatch = null; /** * Knowledge reference when among ref. */ private String _reference = null; - /** - * Full text search words. - */ - private String _words = null; /** * Available knowledge types filter (initialized below). */ @@ -100,8 +88,8 @@ public class SearchKnowledgeAction extends AbstractSearchBaseAction { // Search matching all criteria sprop.setType(getKnowledgeElementTypeService().selectType( Integer.valueOf(_state))); - if (_words.length() > 0) { - sprop.setTitle(_words); + if (getWords().length() > 0) { + sprop.setTitle(getWords()); } if (_reference.length() > 0) { sprop.setReference(_reference); @@ -131,14 +119,6 @@ public class SearchKnowledgeAction extends AbstractSearchBaseAction { // Getters // ============================================================================================================================== - public String getContextMatch() { - return _contextMatch; - } - - public String getCriteriaMatch() { - return _criteriaMatch; - } - public List getKnowledgeTypes() { return _knowledgeTypes; } @@ -151,22 +131,6 @@ public class SearchKnowledgeAction 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; } @@ -175,14 +139,6 @@ public class SearchKnowledgeAction extends AbstractSearchBaseAction { this._state = value; } - public void setWords(final String value) { - this._words = value; - } - - // ============================================================================================================================== - // Implementation of abstract services - // ============================================================================================================================== - @Override protected List getInvolvedContexts() { return getSimulationContextService().selectAllTypes(); @@ -195,12 +151,12 @@ public class SearchKnowledgeAction extends AbstractSearchBaseAction { Map filter = (Map) session .get("knowledge.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("type"); _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"); } @@ -211,12 +167,12 @@ public class SearchKnowledgeAction extends AbstractSearchBaseAction { Map filter = (Map) session .get("knowledge.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("type", this._state); filter.put("author", this._author); filter.put("reference", ""); - filter.put("title", this._words); + filter.put("title", getWords()); _context = (List) filter.get("context"); // Only criteria not part of the form 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. *