<script>
$(document).ready(function () {
initialize('<s:property value="resultState"/>');
+ // Apply jQueryUI datepicker to appropriate input fields
+ $(".dateinput").datepicker({
+ dateFormat: "<s:text name="date.format"/>".replace("MM","mm").replace("yyyy","yy")
+ });
});
</script>
<div id="article-body">
<form name="search" action="refresh-knowledge" method="post">
<input type="hidden" name="contextIndex" />
- <s:set var="match1" value="criteriaMatch"/>
- <s:set var="match2" value="contextMatch"/>
<s:set var="type" value="state"/>
- <s:set var="him" value="author"/>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="text">
<tr height="20">
<td width="40%">
<b><s:text name="field.among"/></b>
- <s:if test="%{#match1 == 'all'}">
- <input type="radio" name="criteriaMatch" value="all" checked onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="criteriaMatch" value="any" onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:if><s:else>
- <input type="radio" name="criteriaMatch" value="all" onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="criteriaMatch" value="any" checked onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:else>
+ <s:radio theme="simple" list="matchOptions" name="criteriaMatch"
+ onclick="changeFilter()" />
</td>
<td width="60%">|
<b><s:text name="field.context"/></b>
- <s:if test="%{#match2 == 'all'}">
- <input type="radio" name="contextMatch" value="all" checked onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="contextMatch" value="any" onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:if><s:else>
- <input type="radio" name="contextMatch" value="all" onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="contextMatch" value="any" checked onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:else>
+ <s:radio theme="simple" list="matchOptions" name="contextMatch"
+ onclick="changeFilter()" />
</td>
</tr>
<tr height="1" bgcolor="#AAAAAA"><td colspan="2"></td></tr>
<select name="author" style="width: <s:text name="size.search.select"/>" onChange="changeFilter()">
<option value="0"><s:text name="criterion.anybody" /></option>
<s:iterator value="candidates">
- <s:if test="%{index == #him}">
+ <s:if test="%{index == author}">
<option value="<s:property value="index"/>" selected><s:property value="toString()"/></option>
</s:if><s:else>
<option value="<s:property value="index"/>"><s:property value="toString()"/></option>
</s:set>
<td><s:text name="field.credate"/> </td>
<td><s:text name="field.after"/> </td>
- <td><input type="text" name="after" size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /> </td>
+ <td><input class="dateinput" onChange="changeFilter()" type="text" name="after" size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /> </td>
<td><s:text name="field.before"/> </td>
- <td><input type="text" name="before" size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /></td>
+ <td><input class="dateinput" onChange="changeFilter()" type="text" name="before" size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /></td>
</tr>
<tr height=26><td></td></tr>
</table>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"
-%>
+ pageEncoding="ISO-8859-1"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!-- Initialization of the context
=============================================================================================================================
-->
-<script language="JavaScript" type="text/javascript" src="../js/search.js"></script>
+<script language="JavaScript" type="text/javascript"
+ src="../js/search.js"></script>
<script>
$(document).ready(function () {
initialize('<s:property value="resultState"/>');
// Apply jQueryUI datepicker to appropriate input fields
$(".dateinput").datepicker({
- dateFormat: "<s:text name="%{format}"/>".replace("yyyy","yy")
+ dateFormat: "<s:text name="date.format"/>".replace("MM","mm").replace("yyyy","yy")
});
});
</script>
<!-- Search criteria section
=============================================================================================================================
-->
- <div id="article-box">
- <div id="section"><s:text name="title.criteria"/></div>
- <div id="article-body">
- <form name="search" action="refresh-study" method="post">
- <input type="hidden" name="contextIndex" />
- <s:set var="match1" value="criteriaMatch"/>
- <s:set var="match2" value="contextMatch"/>
- <s:set var="him" value="author"/>
+<div id="article-box">
+<div id="section"><s:text name="title.criteria" /></div>
+<div id="article-body">
+<form name="search" action="refresh-study" method="post"><input
+ type="hidden" name="contextIndex" />
- <table width="100%" cellpadding="0" cellspacing="0" border="0" class="text">
- <tr height="20">
- <td width="40%">
- <b><s:text name="field.among"/></b>
- <s:if test="%{#match1 == 'all'}">
- <input type="radio" name="criteriaMatch" value="all" checked onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="criteriaMatch" value="any" onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:if><s:else>
- <input type="radio" name="criteriaMatch" value="all" onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="criteriaMatch" value="any" checked onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:else>
- </td>
- <td width="60%">|
- <b><s:text name="field.context"/></b>
- <s:if test="%{#match2 == 'all'}">
- <input type="radio" name="contextMatch" value="all" checked onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="contextMatch" value="any" onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:if><s:else>
- <input type="radio" name="contextMatch" value="all" onClick="changeFilter()"><s:text name="field.matchall"/>
-
- <input type="radio" name="contextMatch" value="any" checked onClick="changeFilter()"><s:text name="field.matchany"/>
- </s:else>
- </td>
- </tr>
- <tr height="1" bgcolor="#AAAAAA"><td colspan="2"></td></tr>
- </table>
+<table width="100%" cellpadding="0" cellspacing="0" border="0"
+ class="text">
+ <tr height="20">
+ <td width="40%"><b><s:text name="field.among" /></b>
+ <s:radio theme="simple" list="matchOptions" name="criteriaMatch"
+ onclick="changeFilter()" /></td>
+ <td width="60%">| <b><s:text name="field.context" /></b>
+ <s:radio theme="simple" list="matchOptions" name="contextMatch"
+ onclick="changeFilter()" /></td>
+ </tr>
+ <tr height="1" bgcolor="#AAAAAA">
+ <td colspan="2"></td>
+ </tr>
+</table>
- <table width="100%" cellpadding="0" cellspacing="0" border="0" class="text">
- <tr valign="top">
- <td width="40%">
- <table cellpadding="0" cellspacing="0" border="0" class="text">
- <tr>
- <td colspan="2"><s:text name="criterion.study"/> </td>
- <td colspan="3" align="center">
- <select name="state" style="width: <s:text name="size.search.select"/>" onChange="changeFilter()">
- <s:if test="state == 'ANY'"> <option value="ANY" selected><s:text name="criterion.any" /></option></s:if>
- <s:else> <option value="ANY" ><s:text name="criterion.any" /></option></s:else>
- <s:if test="connectedUser != null">
- <s:if test="state == 'inWORK'"> <option value="inWORK" selected><s:text name="criterion.inwork" /></option></s:if>
- <s:else> <option value="inWORK" ><s:text name="criterion.inwork" /></option></s:else>
- <s:if test="state == 'inDRAFT'"> <option value="inDRAFT" selected><s:text name="criterion.indraft" /></option></s:if>
- <s:else> <option value="inDRAFT" ><s:text name="criterion.indraft" /></option></s:else>
- <s:if test="state == 'inCHECK'"> <option value="inCHECK" selected><s:text name="criterion.incheck" /></option></s:if>
- <s:else> <option value="inCHECK" ><s:text name="criterion.incheck" /></option></s:else>
- </s:if>
- <s:if test="state == 'APPROVED'"> <option value="APPROVED" selected><s:text name="criterion.approved" /></option></s:if>
- <s:else> <option value="APPROVED" ><s:text name="criterion.approved" /></option></s:else>
- <s:if test="state == 'TEMPLATE'"> <option value="TEMPLATE" selected><s:text name="criterion.template" /></option></s:if>
- <s:else> <option value="TEMPLATE" ><s:text name="criterion.template" /></option></s:else>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan="2"><s:text name="criterion.author"/> </td>
- <td colspan="3" align="center">
- <select name="author" style="width: <s:text name="size.search.select"/>" onChange="changeFilter()">
- <option value="0"><s:text name="criterion.anybody" /></option>
- <s:iterator value="candidates">
- <s:if test="%{index == #him}">
- <option value="<s:property value="index"/>" selected><s:property value="toString()"/></option>
- </s:if><s:else>
- <option value="<s:property value="index"/>"><s:property value="toString()"/></option>
- </s:else>
- </s:iterator>
- </select>
- </td>
- </tr>
- <tr>
- <s:set var="tipdate">
- <s:text name="help.search.date">
- <s:param><s:text name="%{format}"/></s:param>
- <s:param><s:text name="%{today}"/></s:param>
- </s:text>
- </s:set>
- <td><s:text name="field.credate"/> </td>
- <td><s:text name="field.after"/> </td>
- <td><input class="dateinput" onChange="changeFilter()" type="text" name=after size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /> </td>
- <td><s:text name="field.before"/> </td>
- <td><input class="dateinput" onChange="changeFilter()" type="text" name=before size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /></td>
- </tr><tr>
- <td><s:text name="field.lasdate"/> </td>
- <td><s:text name="field.after"/> </td>
- <td><input class="dateinput" onChange="changeFilter()" type="text" name=after size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /> </td>
- <td><s:text name="field.before"/> </td>
- <td><input class="dateinput" onChange="changeFilter()" type="text" name="before" size="7" onKeydown="changeFilter()" title="<s:property value="%{#tipdate}"/>" /></td>
- </tr>
- </table>
- <table cellpadding="0" cellspacing="0" border="0" class="text">
- <tr>
- <td><s:text name="field.contain"/>: </td>
- <td><input type="text" name=words style="width: <s:text name="size.search.input"/>" value="<s:property value="%{words}"/>" onKeydown="changeFilter()" title="<s:text name="help.search.title"/>" /></td>
- </tr><tr>
- <td><s:text name="field.reference"/>: </td>
- <td><input type="text" name="reference" style="width: <s:text name="size.search.input"/>" value="<s:property value="%{reference}"/>" onKeydown="changeFilter()" title="<s:text name="help.search.refid"/>" /></td>
- </tr>
- </table>
- </td>
- <td width="60%">
- <table cellpadding="0" cellspacing="0" border="0" class="text">
- <s:iterator value="simulationContexts">
- <tr>
- <td><input type="checkbox" checked onClick="removeContext('<s:property value="index"/>')"> </td>
- <td>
- <s:if test="%{type.isApproved()}"><s:text name="type.context.%{type.name}"/>: </s:if>
- <s:else><s:property value="%{type.name}"/>: </s:else>
- </td>
- <td><s:property value="value"/></td>
- </tr>
- </s:iterator>
+<table width="100%" cellpadding="0" cellspacing="0" border="0"
+ class="text">
+ <tr valign="top">
+ <td width="40%">
+ <table cellpadding="0" cellspacing="0" border="0" class="text">
+ <tr>
+ <td colspan="2"><s:text name="criterion.study" /> </td>
+ <td colspan="3" align="center"><s:select name="state"
+ list="stateOptions" theme="simple"
+ size="%{getText(size.search.select)}" onchange="changeFilter()" />
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><s:text name="criterion.author" /> </td>
+ <td colspan="3" align="center"><select name="author"
+ style='width: & lt;' onChange="changeFilter()">
+ <option value="0"><s:text name="criterion.anybody" /></option>
+ <s:iterator value="candidates">
+ <s:if test="%{index == author}">
+ <option value="<s:property value="index"/>" selected><s:property
+ value="toString()" /></option>
+ </s:if>
+ <s:else>
+ <option value="<s:property value="index"/>"><s:property
+ value="toString()" /></option>
+ </s:else>
+ </s:iterator>
+ </select></td>
+ </tr>
+ <tr>
+ <s:set var="tipdate">
+ <s:text name="help.search.date">
+ <s:param>
+ <s:text name="%{format}" />
+ </s:param>
+ <s:param>
+ <s:text name="%{today}" />
+ </s:param>
+ </s:text>
+ </s:set>
+ <td><s:text name="field.credate" /> </td>
+ <td><s:text name="field.after" /> </td>
+ <td><input class="dateinput" onChange="changeFilter()"
+ type="text" name=after size="7" onKeydown="changeFilter()"
+ title="<s:property value="%{#tipdate}"/>" /> </td>
+ <td><s:text name="field.before" /> </td>
+ <td><input class="dateinput" onChange="changeFilter()"
+ type="text" name=before size="7" onKeydown="changeFilter()"
+ title="<s:property value="%{#tipdate}"/>" /></td>
+ </tr>
+ <tr>
+ <td><s:text name="field.lasdate" /> </td>
+ <td><s:text name="field.after" /> </td>
+ <td><input class="dateinput" onChange="changeFilter()"
+ type="text" name=after size="7" onKeydown="changeFilter()"
+ title="<s:property value="%{#tipdate}"/>" /> </td>
+ <td><s:text name="field.before" /> </td>
+ <td><input class="dateinput" onChange="changeFilter()"
+ type="text" name="before" size="7" onKeydown="changeFilter()"
+ title="<s:property value="%{#tipdate}"/>" /></td>
+ </tr>
+ </table>
+ <table cellpadding="0" cellspacing="0" border="0" class="text">
+ <tr>
+ <td><s:text name="field.contain" />: </td>
+ <td><input type="text" name=words style='width: & lt;'
+ value="<s:property value="%{words}"/>" onKeydown="changeFilter()"
+ title="<s:text name="help.search.title"/>" /></td>
+ </tr>
+ <tr>
+ <td><s:text name="field.reference" />: </td>
+ <td><input type="text" name="reference"
+ style='width: & lt;' value="<s:property value="%{reference}"/>"
+ onKeydown="changeFilter()"
+ title="<s:text name="help.search.refid"/>" /></td>
+ </tr>
+ </table>
+ </td>
+ <td width="60%">
+ <table cellpadding="0" cellspacing="0" border="0" class="text">
+ <s:iterator value="simulationContexts">
+ <tr>
+ <td><input type="checkbox" checked
+ onClick="removeContext('<s:property value="index"/>')"> </td>
+ <td><s:if test="%{type.isApproved()}">
+ <s:text name="type.context.%{type.name}" />: </s:if> <s:else>
+ <s:property value="%{type.name}" />: </s:else></td>
+ <td><s:property value="value" /></td>
+ </tr>
+ </s:iterator>
- <s:if test="%{actionType == 'setContext'}">
- <tr>
- <td>
- <img src="<s:url value="/skin/icon.undo.png"/>" border="none" title="<s:text name="tooltip.cancel"/>" onClick="cancel()" />
- </td>
- <td>
- <s:if test="%{selectedContextType.isApproved()}"><s:text name="type.context.%{selectedContextType.name}"/>: </s:if>
- <s:else><s:property value="%{selectedContextType.name}"/>: </s:else>
- </td>
- <td>
- <select name="contextValue" onChange="submit()">
- <option value="-1"><s:text name="menu.select"/></option>
- <s:iterator value="contextValueOptions">
- <option value="<s:property value="index"/>"> <s:property value="value" /></option>
- </s:iterator>
- </select>
- </td>
- </tr>
- </s:if>
- </table>
+ <s:if test="%{actionType == 'setContext'}">
+ <tr>
+ <td><img src="<s:url value="/skin/icon.undo.png"/>"
+ border="none" title="<s:text name="tooltip.cancel"/>"
+ onClick="cancel()" /> </td>
+ <td><s:if test="%{selectedContextType.isApproved()}">
+ <s:text name="type.context.%{selectedContextType.name}" />: </s:if>
+ <s:else>
+ <s:property value="%{selectedContextType.name}" />: </s:else></td>
+ <td><select name="contextValue" onChange="submit()">
+ <option value="-1"><s:text name="menu.select" /></option>
+ <s:iterator value="contextValueOptions">
+ <option value="<s:property value="index"/>"> <s:property
+ value="value" /></option>
+ </s:iterator>
+ </select></td>
+ </tr>
+ </s:if>
+ </table>
- <s:if test="%{actionType != 'setContext'}">
- <select name="contextType" onChange="submit()">
- <option value="-1"><s:text name="menu.addcontext"/></option>
- <s:iterator value="contextTypeOptions">
- <option value="<s:property value="index"/>">
- <s:if test="%{isApproved()}"> <s:text name="type.context.%{name}" /></s:if>
- <s:else> <s:property value="%{name}" /></s:else>
- </option>
- </s:iterator>
- </select>
- </s:if>
- </td>
- </tr>
- </table>
+ <s:if test="%{actionType != 'setContext'}">
+ <select name="contextType" onChange="submit()">
+ <option value="-1"><s:text name="menu.addcontext" /></option>
+ <s:iterator value="contextTypeOptions">
+ <option value="<s:property value="index"/>"><s:if
+ test="%{isApproved()}"> <s:text
+ name="type.context.%{name}" />
+ </s:if> <s:else> <s:property value="%{name}" />
+ </s:else></option>
+ </s:iterator>
+ </select>
+ </s:if></td>
+ </tr>
+</table>
- <table width="100%" cellpadding="0" cellspacing="0" border="0" class="text">
- <tr>
- <td width="40%"></td>
- <td width="60%" align="left"><input type="submit" name="refresh" value="<s:text name="button.result"/>" disabled/></td>
- </tr>
- </table>
+<table width="100%" cellpadding="0" cellspacing="0" border="0"
+ class="text">
+ <tr>
+ <td width="40%"></td>
+ <td width="60%" align="left"><input type="submit" name="refresh"
+ value="<s:text name="button.result"/>" disabled /></td>
+ </tr>
+</table>
- </form>
- </div>
- </div>
+</form>
+</div>
+</div>
<!-- Result list
=============================================================================================================================
-->
- <div id="resulist">
- <div id="article-box">
- <div id="section"><s:text name="title.result"/></div>
- <div id="article-body" class="text">
-
- <s:if test="result.size > 0">
- <table width="100%" cellpadding="0" cellspacing="0" border="0" class="text">
- <tr height="20" valign="bottom">
- <td width="20"></td>
- <td width="80"><s:text name="label.reference"/></td>
- <td><s:text name="label.title"/><img src="<s:url value="/skin/icon.sortup.png"/>" border="none"/></td>
- <td width="150"><s:text name="label.manager"/></td>
- </tr>
- <tr height="1" bgcolor="#AAAAAA"><td colspan="4"></td></tr>
- <s:iterator value="result">
- <tr>
- <td><img src="<s:url value="/skin/icon.%{progressState}.png"/>" width=12 height=12 border="none" title=""/></td>
- <td><s:property value="reference"/></td>
- <td>
- <s:url id="open" namespace="/study" action="open-study?selection=0.0">
- <s:param name="index" value="%{index}"/>
- </s:url>
- <s:a href="%{open}" cssClass="link"><s:property value="title"/></s:a>
- </td>
- <td><s:property value="authorName"/></td>
- </tr>
- </s:iterator>
- </table>
- </s:if>
-
- <s:else>
- <s:text name="message.nostudy" />
- </s:else>
- </div>
- </div>
- </div>
+<div id="resulist">
+<div id="article-box">
+<div id="section"><s:text name="title.result" /></div>
+<div id="article-body" class="text"><s:if test="result.size > 0">
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"
+ class="text">
+ <tr height="20" valign="bottom">
+ <td width="20"></td>
+ <td width="80"><s:text name="label.reference" /></td>
+ <td><s:text name="label.title" /><img
+ src="<s:url value="/skin/icon.sortup.png"/>" border="none" /></td>
+ <td width="150"><s:text name="label.manager" /></td>
+ </tr>
+ <tr height="1" bgcolor="#AAAAAA">
+ <td colspan="4"></td>
+ </tr>
+ <s:iterator value="result">
+ <tr>
+ <td><img src="<s:url value="/skin/icon.%{progressState}.png"/>"
+ width="12" height="12" border="none" title="" /></td>
+ <td><s:property value="reference" /></td>
+ <td><s:url id="open" namespace="/study"
+ action="open-study?selection=0.0">
+ <s:param name="index" value="%{index}" />
+ </s:url> <s:a href="%{open}" cssClass="link">
+ <s:property value="title" />
+ </s:a></td>
+ <td><s:property value="authorName" /></td>
+ </tr>
+ </s:iterator>
+ </table>
+</s:if> <s:else>
+ <s:text name="message.nostudy" />
+</s:else></div>
+</div>
+</div>
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;
* 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.
*/
* 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<Name> _candidates = null;
/**
* Context type to be valued.
* 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.
this._cindex = value;
}
+ /**
+ * Build the list of study authors. If the current user also can create <BR>
+ * a study then it is placed on the top of the list.
+ */
protected void setCandidates() {
_candidates = new ArrayList<Name>();
List<User> users = getUserService().selectAllUsers();
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);
protected abstract void saveFilter();
+ // ==============================================================================================================================
+ // Getters and Setters
+ // ==============================================================================================================================
+
+ /**
+ * Get match options.
+ *
+ * @return array of options with key and value properties
+ */
+ public Map<String, String> getMatchOptions() {
+ Map<String, String> options = new LinkedHashMap<String, String>();
+ options.put("all", getText("field.matchall"));
+ options.put("any", getText("field.matchany"));
+ return options;
+ }
+
/**
* Get the simulationContextService.
*
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
* 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).
*/
// 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);
// Getters
// ==============================================================================================================================
- public String getContextMatch() {
- return _contextMatch;
- }
-
- public String getCriteriaMatch() {
- return _criteriaMatch;
- }
-
public List<KnowledgeElementType> getKnowledgeTypes() {
return _knowledgeTypes;
}
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() {
return getSimulationContextService().selectAllTypes();
Map<String, Object> filter = (Map<String, Object>) 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<SimulationContext>) filter.get("context");
}
Map<String, Object> filter = (Map<String, Object>) 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<SimulationContext>) filter.get("context"); // Only criteria not part of the form
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.
*