package org.splat.dal.bo.som;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.dal.bo.kernel.Persistent;
-
public class KnowledgeElementType extends Persistent {
-
- private String name;
- private ProgressState state;
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
+ private String name;
+ private ProgressState state;
- // Database fetch constructor
- protected KnowledgeElementType () {
- }
-// Initialization constructor
- public KnowledgeElementType (String name) {
-// --------------------------------------------
- super();
- this.name = name;
- this.state = ProgressState.inCHECK;
- }
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
+ // Database fetch constructor
+ protected KnowledgeElementType() {
+ }
- public boolean equals(Object entity) {
-// ------------------------------------
- if (entity == null) return false;
- if (entity instanceof String) {
- return this.name.equals((String)entity); // Names are unique
- } else
- if (entity instanceof KnowledgeElementType) {
- KnowledgeElementType object = (KnowledgeElementType)entity;
- long he = object.getIndex();
- long me = this.getIndex();
- if (me*he != 0) return (he == me);
- else return this.getName().equals(object.getName());
- } else {
- return false;
- }
- }
+ // Initialization constructor
+ public KnowledgeElementType(final String name) {
+ super();
+ this.name = name;
+ this.state = ProgressState.inCHECK;
+ }
- public String getName () {
-// ------------------------
- return name;
- }
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
- public boolean isApproved () {
-// ----------------------------
- return (state == ProgressState.APPROVED);
- }
+ @Override
+ public boolean equals(final Object entity) {
+ if (entity == null) {
+ return false;
+ }
+ if (entity instanceof String) {
+ return this.name.equals(entity); // Names are unique
+ } else if (entity instanceof KnowledgeElementType) {
+ KnowledgeElementType object = (KnowledgeElementType) entity;
+ long he = object.getIndex();
+ long me = this.getIndex();
+ if (me * he != 0) {
+ return (he == me);
+ } else {
+ return this.getName().equals(object.getName());
+ }
+ } else {
+ return false;
+ }
+ }
- public boolean isReserved () {
-// ----------------------------
- return (state == ProgressState.inWORK);
- }
- /**
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get i18n type name key.
+ *
+ * @return the i18n key
+ */
+ public String getKey() {
+ return "type.knowledge." + name;
+ }
+
+ public boolean isApproved() {
+ return (state == ProgressState.APPROVED);
+ }
+
+ public boolean isReserved() {
+ return (state == ProgressState.inWORK);
+ }
+
+ /**
* Get the state.
+ *
* @return the state
*/
public ProgressState getState() {
return state;
}
+
/**
* Set the state.
- * @param state the state to set
+ *
+ * @param state
+ * the state to set
*/
- public void setState(ProgressState state) {
+ public void setState(final ProgressState state) {
this.state = state;
}
}
\ No newline at end of file
import org.splat.dal.bo.som.Study;
import org.splat.service.dto.ImportedStudyDTO;
import org.splat.service.dto.Proxy;
+import org.splat.service.dto.StudySearchFilterDTO;
/**
* Search service interface.
* search filter parameters
* @return the list of found studies as proxy results
*/
- List<Proxy> selectStudiesWhere(boolean allCriteria, boolean allContexts,
- Study.Properties sprop);
+ List<Proxy> selectStudiesWhere(final StudySearchFilterDTO filter);
/**
* Refresh lucene index for a study.
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Visibility;
-import org.splat.dal.bo.som.Study.Properties;
import org.splat.dal.dao.som.StudyDAO;
import org.splat.service.dto.ImportedStudyDTO;
import org.splat.service.dto.Proxy;
import org.splat.service.dto.StudyDTO;
+import org.splat.service.dto.StudySearchFilterDTO;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.IndexServiceImpl;
import org.splat.service.technical.RepositoryService;
*
* @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
*/
- public List<Proxy> selectStudiesWhere(final boolean allCriteria,
- final boolean allContexts, final Study.Properties sprop) {
+ public List<Proxy> selectStudiesWhere(final StudySearchFilterDTO filter) {
List<Proxy> result = new ArrayList<Proxy>();
DetachedCriteria query = DetachedCriteria
.forClass(Study.class, "study");
+
// Creation of the query
- initQuery(query, sprop);
+ Junction topJunction = initQuery(filter);
- String title = sprop.getTitle(); // Title
+ String title = filter.getWords(); // Title
if (title != null) {
// Look for given words in study titles
Junction critext;
- if (allCriteria) { // AND
+ if (filter.isMatchAllCriteria()) { // AND
critext = Restrictions.conjunction();
} else { // OR
critext = Restrictions.disjunction();
for (int j = 0; j < word.length; j++) {
critext.add(Restrictions.like("title", "%" + word[j] + "%"));
}
- query.add(critext);
+ topJunction.add(critext);
}
- List<SimulationContext> context = sprop.getSimulationContexts();
+ List<SimulationContext> context = filter.getSimContexts();
if (context != null && (!context.isEmpty())) {
// Get only studies which have given contexts
query.createAlias("contex", "ctx", Criteria.INNER_JOIN);
Junction critctx;
- if (allContexts) { // AND
+ if (filter.isMatchAllContexts()) { // AND
critctx = Restrictions.conjunction();
} else { // OR
critctx = Restrictions.disjunction();
seltext.getType())));
}
- query.add(critctx);
+ topJunction.add(critctx);
}
+ query.add(topJunction);
// Group by study
query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
// Creation of the sort criteria
/**
* Initialize query with base criteria.
*
- * @param query
- * the query
- * @param sprop
+ * @param filter
* the criteria
+ * @return top junction of the search filter
*/
- private void initQuery(final DetachedCriteria query, final Properties sprop) {
- ProgressState state = sprop.getProgressState(); // State
- if (state != null) {
- query.add(Restrictions.eq("state", state));
+ private Junction initQuery(final StudySearchFilterDTO filter) {
+ Junction topJunction;
+ if (filter.isMatchAllCriteria()) { // AND
+ topJunction = Restrictions.conjunction();
+ } else { // OR
+ topJunction = Restrictions.disjunction();
+ }
+ if (!StudySearchFilterDTO.ANY_STATE.equals(filter.getState())) {
+ ProgressState state = ProgressState.valueOf(filter.getState()); // State
+ if (state != null) {
+ topJunction.add(Restrictions.eq("state", state));
+ }
}
- String refid = sprop.getReference(); // Reference
- if (refid != null) {
- query.add(Restrictions.eq("sid", refid));
+ String refid = filter.getReference(); // Reference
+ if (refid != null && !refid.isEmpty()) {
+ topJunction.add(Restrictions.eq("sid", refid));
}
- User manager = sprop.getManager(); // Author
- if (manager != null) {
- query.add(Restrictions.eq("manager", manager));
+
+ addDatesCriteria(topJunction, filter);
+
+ int authorId = Integer.valueOf(filter.getAuthor());
+ if (authorId > 0) { // Author
+ topJunction.add(Restrictions.eq("manager.rid", authorId));
}
- User actor = sprop.getActor(); // Contributor, Reviewer or Approver
- if (actor == null) {
+ long actorId = filter.getConnectedUserId(); // Contributor, Reviewer or Approver
+ if (actorId > 0) {
// User is not logged in - show only public studies
- query.add(Restrictions.eq("visibility", Visibility.PUBLIC));
+ topJunction.add(Restrictions.eq("visibility", Visibility.PUBLIC));
} else {
// User is loggen in - show public studies and studies where he is participating
Disjunction orCrit = Restrictions.disjunction();
- query
+ topJunction
.add(orCrit
.add(
/* If the user is a validation cycle participant */
Restrictions
.sqlRestriction(
"{alias}.rid in (select vcrel.owner from cycle_rel vcrel inner join cycle vc on vcrel.refer = vc.rid where {alias}.rid = vcrel.owner AND (vc.publisher = ? OR vc.reviewer = ? OR vc.approver = ? OR vc.signatory = ?) group by vcrel.owner)",
- new Object[] {
- actor.getIndex(),
- actor.getIndex(),
- actor.getIndex(),
- actor.getIndex() },
+ new Object[] { actorId,
+ actorId, actorId,
+ actorId },
new Type[] {
Hibernate.LONG,
Hibernate.LONG,
Restrictions
.sqlRestriction(
"{alias}.rid in (select rel.owner from contributor_rel rel where {alias}.rid = rel.owner AND rel.refer = ?)",
- actor.getIndex(),
- Hibernate.LONG)).add(
+ actorId, Hibernate.LONG))
+ .add(
/* If the user is author */
- Restrictions.eq("study.manager", actor)).add(
+ Restrictions.eq("study.manager.rid", actorId)).add(
/* If the study is public */
Restrictions.eq("study.visibility",
Visibility.PUBLIC)));
}
+ return topJunction;
+ }
+
+ /**
+ * Add search criteria by dates to the junction filter condition.
+ *
+ * @param topJunction
+ * the junction filter condition
+ * @param filter
+ * search criteria
+ */
+ private void addDatesCriteria(final Junction topJunction,
+ final StudySearchFilterDTO filter) {
+ // Filter by creation date
+ if (filter.getCreatedAfter() != null) {
+ topJunction.add(Restrictions
+ .gt("credate", filter.getCreatedAfter()));
+ }
+ if (filter.getCreatedBefore() != null) {
+ topJunction.add(Restrictions.lt("credate", filter
+ .getCreatedBefore()));
+ }
+ // Filter by modification date
+ if (filter.getUpdatedAfter() != null) {
+ topJunction.add(Restrictions
+ .gt("lasdate", filter.getUpdatedAfter()));
+ }
+ if (filter.getUpdatedBefore() != null) {
+ topJunction.add(Restrictions.lt("lasdate", filter
+ .getUpdatedBefore()));
+ }
+
}
/**
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 05.03.2013
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service.dto;
+
+/**
+ * Knowledge search criteria.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class KnowledgeSearchFilterDTO extends SearchFilterDTO {
+
+ /**
+ * Knowledge type index when among all.
+ */
+ private String _ktype = "0";
+
+ /**
+ * Get id of knowledge type to search.
+ *
+ * @return knowledge type id to search
+ */
+ public String getKtype() {
+ return _ktype;
+ }
+
+ /**
+ * Set id of knowledge type to search.
+ *
+ * @param value
+ * knowledge type id to search
+ */
+ public void setKtype(final String value) {
+ this._ktype = value;
+ }
+
+}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 04.03.2013
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service.dto;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.splat.dal.bo.som.SimulationContext;
+
+/**
+ * Base search criteria.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class SearchFilterDTO {
+
+ /**
+ * "all": match all criteria.
+ */
+ public final static String MATCH_ALL = "all";
+ /**
+ * "any": match any criteria.
+ */
+ public final static String MATCH_ANY = "any";
+ /**
+ * Study author id to search.
+ */
+ protected String _author = "0";
+ /**
+ * Current contexts search criteria.
+ */
+ protected transient List<SimulationContext> _simContexts = new ArrayList<SimulationContext>();
+ /**
+ * Simulation context match: "all" or "any".
+ */
+ private String _contextMatch = MATCH_ALL;
+ /**
+ * Criteria match: "all" or "any".
+ */
+ private String _criteriaMatch = MATCH_ALL;
+ /**
+ * Search studies created after this date.
+ */
+ private Date _createdAfter;
+ /**
+ * Search studies created before this date.
+ */
+ private Date _createdBefore;
+ /**
+ * Full text search words.
+ */
+ private String _words = "";
+ /**
+ * Study reference.
+ */
+ private String _reference = "";
+ /**
+ * Currently connected user id.
+ */
+ private long _connectedUserId = 0;
+
+ /**
+ * Get author id of objects to find.
+ *
+ * @return the author id criteria
+ */
+ public String getAuthor() {
+ return _author;
+ }
+
+ /**
+ * Get context criteria operation (all or any).
+ *
+ * @return the simulation context criteria operation value
+ */
+ public String getContextMatch() {
+ return _contextMatch;
+ }
+
+ /**
+ * Get the createdAfter.
+ *
+ * @return the createdAfter
+ */
+ public Date getCreatedAfter() {
+ return _createdAfter;
+ }
+
+ /**
+ * Get the createdBefore.
+ *
+ * @return the createdBefore
+ */
+ public Date getCreatedBefore() {
+ return _createdBefore;
+ }
+
+ /**
+ * Get main criteria operation (all or any).
+ *
+ * @return the main criteria operation value
+ */
+ public String getCriteriaMatch() {
+ return _criteriaMatch;
+ }
+
+ /**
+ * Get full text search criterion value.
+ *
+ * @return the full text search criterion value
+ */
+ public String getWords() {
+ return _words;
+ }
+
+ // ==============================================================================================================================
+ // Setters
+ // ==============================================================================================================================
+
+ /**
+ * Set author id to search.
+ *
+ * @param index
+ * persistent user id
+ */
+ public void setAuthor(final String index) {
+ this._author = index;
+ }
+
+ /**
+ * Set context criteria operation (all or any).
+ *
+ * @param value
+ * "all" or "any"
+ */
+ public void setContextMatch(final String value) {
+ this._contextMatch = value;
+ }
+
+ /**
+ * Set the createdAfter.
+ *
+ * @param createdAfter
+ * the createdAfter to set
+ */
+ public void setCreatedAfter(final Date createdAfter) {
+ _createdAfter = createdAfter;
+ }
+
+ /**
+ * Set the createdBefore.
+ *
+ * @param createdBefore
+ * the createdBefore to set
+ */
+ public void setCreatedBefore(final Date createdBefore) {
+ _createdBefore = createdBefore;
+ }
+
+ /**
+ * Set main criteria operation (all or any).
+ *
+ * @param value
+ * "all" or "any"
+ */
+ public void setCriteriaMatch(final String value) {
+ this._criteriaMatch = value;
+ }
+
+ /**
+ * Set full text search criterion value.
+ *
+ * @param value
+ * the full text search criterion value
+ */
+ public void setWords(final String value) {
+ this._words = value;
+ }
+
+ /**
+ * Get the context.
+ *
+ * @return the context
+ */
+ public List<SimulationContext> getSimContexts() {
+ return _simContexts;
+ }
+
+ /**
+ * Check if it is necessary to satisfy all main criteria.
+ *
+ * @return true if it is necessary to satisfy all main criteria
+ */
+ public boolean isMatchAllCriteria() {
+ return MATCH_ALL.equals(getCriteriaMatch());
+ }
+
+ /**
+ * Check if it is necessary to satisfy all simulation contexts criteria.
+ *
+ * @return true if it is necessary to satisfy all simulation contexts criteria
+ */
+ public boolean isMatchAllContexts() {
+ return MATCH_ALL.equals(getContextMatch());
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ /**
+ * Get study reference criteria.
+ *
+ * @return study reference to search
+ */
+ public String getReference() {
+ return _reference;
+ }
+
+ /**
+ * Set study reference criteria.
+ *
+ * @param value
+ * the study reference to search
+ */
+ public void setReference(final String value) {
+ this._reference = value;
+ }
+
+ /**
+ * Set the simContexts.
+ * @param simContexts the simContexts to set
+ */
+ public void setSimContexts(final List<SimulationContext> simContexts) {
+ _simContexts = simContexts;
+ }
+
+ /**
+ * Get the connectedUserId.
+ * @return the connectedUserId
+ */
+ public long getConnectedUserId() {
+ return _connectedUserId;
+ }
+
+ /**
+ * Set the connectedUserId.
+ * @param connectedUserId the connectedUserId to set
+ */
+ public void setConnectedUserId(final long connectedUserId) {
+ _connectedUserId = connectedUserId;
+ }
+}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 05.03.2013
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service.dto;
+
+import java.util.Date;
+
+/**
+ * Study search criteria.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class StudySearchFilterDTO extends SearchFilterDTO {
+
+ /**
+ * "ANY": match any status.
+ */
+ public final static String ANY_STATE = "ANY";
+ /**
+ * "In-Work", "In-Draft", "In-Check"...
+ */
+ private String _state = ANY_STATE;
+ /**
+ * Search studies updated after this date.
+ */
+ private Date _updatedAfter;
+ /**
+ * Search studies updated before this date.
+ */
+ private Date _updatedBefore;
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ /**
+ * Get progress state criteria.
+ *
+ * @return study progress state to search
+ */
+ public String getState() {
+ return _state;
+ }
+
+ /**
+ * Set progress state criteria.
+ *
+ * @param value
+ * the progress state to search
+ */
+ public void setState(final String value) {
+ this._state = value;
+ }
+
+ /**
+ * Get the updatedAfter.
+ *
+ * @return the updatedAfter
+ */
+ public Date getUpdatedAfter() {
+ return _updatedAfter;
+ }
+
+ /**
+ * Get the updatedBefore.
+ *
+ * @return the updatedBefore
+ */
+ public Date getUpdatedBefore() {
+ return _updatedBefore;
+ }
+
+ /**
+ * Set the updatedAfter.
+ *
+ * @param updatedAfter
+ * the updatedAfter to set
+ */
+ public void setUpdatedAfter(final Date updatedAfter) {
+ _updatedAfter = updatedAfter;
+ }
+
+ /**
+ * Set the updatedBefore.
+ *
+ * @param updatedBefore
+ * the updatedBefore to set
+ */
+ public void setUpdatedBefore(final Date updatedBefore) {
+ _updatedBefore = updatedBefore;
+ }
+
+}
<%@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 () {
<!-- 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-knowledge" method="post">
- <input type="hidden" name="contextIndex" />
- <s:set var="type" value="state"/>
+<div id=article-box>
+<div id=section><s:text name="title.criteria" /></div>
+<div id="article-body">
+<form name="search" action="refresh-knowledge" 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: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 height="20">
+ <td width="40%"><b><s:text name="field.among" /></b>
+ <s:radio theme="simple" list="matchOptions"
+ name="filter.criteriaMatch" onclick="changeFilter()" /></td>
+ <td width="60%">| <b><s:text name="field.context" /></b>
+ <s:radio theme="simple" list="matchOptions" name="filter.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.knowledge"/> </td>
- <td colspan="3" align="center">
- <select name="state" style="width: <s:text name="size.search.select"/>" onChange="changeFilter()">
- <s:iterator value="knowledgeTypes">
- <s:if test="%{index == #type}">
- <option value="<s:property value="index"/>" selected><s:text name="type.knowledge.%{name}" /></option>
- </s:if><s:else>
- <option value="<s:property value="index"/>"><s:text name="type.knowledge.%{name}" /></option>
- </s:else>
- </s:iterator>
- </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 == 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 height=26><td></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.knowledge" /> </td>
+ <td colspan="3" align="center"><s:select theme="simple"
+ name="filter.ktype" list="knowledgeTypes"
+ cssStyle="width: %{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="filter.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 == 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><s:textfield theme="simple" cssClass="dateinput"
+ onchange="changeFilter()" name="filter.createdAfter" size="7"
+ onkeydown="changeFilter()" title="%{#tipdate}" /> </td>
+ <td><s:text name="field.before" /> </td>
+ <td><s:textfield theme="simple" cssClass="dateinput"
+ onchange="changeFilter()" name="filter.createdBefore" size="7"
+ onkeydown="changeFilter()" title="%{#tipdate}" /></td>
+ </tr>
+ <tr height=26>
+ <td></td>
+ </tr>
+ </table>
+ <table cellpadding="0" cellspacing="0" border="0" class="text">
+ <tr>
+ <td><s:text name="field.contain" />: </td>
+ <td><s:textfield theme="simple" name="filter.words"
+ size="%{getText(size.search.input)}" onkeydown="changeFilter()"
+ title="%{getText(help.search.title)}" /></td>
+ </tr>
+ <tr>
+ <td><s:text name="field.reference" />: </td>
+ <td><s:textfield theme="simple" name="filter.reference"
+ size="%{getText(size.search.input)}" onkeydown="changeFilter()"
+ title="%{getText(help.search.refid)}" /></td>
+ </tr>
+ </table>
+ </td>
+ <td width="60%">
+ <table cellpadding="0" cellspacing="0" border="0" class="text">
+ <s:iterator value="filter.simContexts">
+ <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:set var="snum" value="null"/>
- <s:iterator value="contextTypeOptions">
- <s:if test="%{#snum != attachedStep.number}">
- <s:set var="snum" value="%{attachedStep.number}"/>
- <optgroup label=" <s:text name="folder.step.%{#snum}"/>">
- </s:if>
- <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:set var="snum" value="null" />
+ <s:iterator value="contextTypeOptions">
+ <s:if test="%{#snum != attachedStep.number}">
+ <s:set var="snum" value="%{attachedStep.number}" />
+ <optgroup label=" <s:text name="folder.step.%{#snum}"/>">
+ </s:if>
+ <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.author"/></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-knowledge?selection=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.noknowledge" />
- </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.author" /></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-knowledge?selection=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.noknowledge" />
+</s:else></div>
+</div>
+</div>
<%@page language="java" contentType="text/html; charset=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>
<!-- Search criteria section
- =============================================================================================================================
+ ===========================================================================
-->
<div id="article-box">
<div id="section"><s:text name="title.criteria" /></div>
class="text">
<tr height="20">
<td width="40%"><b><s:text name="field.among" /></b>
- <s:radio theme="simple" list="matchOptions" name="criteriaMatch"
+ <s:radio theme="simple" list="matchOptions" name="filter.criteriaMatch"
onclick="changeFilter()" /></td>
<td width="60%">| <b><s:text name="field.context" /></b>
- <s:radio theme="simple" list="matchOptions" name="contextMatch"
+ <s:radio theme="simple" list="matchOptions" name="filter.contextMatch"
onclick="changeFilter()" /></td>
</tr>
<tr height="1" bgcolor="#AAAAAA">
<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"
+ <td colspan="3" align="center"><s:select name="filter.state"
list="stateOptions" theme="simple"
- size="%{getText(size.search.select)}" onchange="changeFilter()" />
+ cssStyle="width: %{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()">
+ <td colspan="3" align="center"><select name="filter.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 == author}">
+ <s:if test="%{index == filter.author}">
<option value="<s:property value="index"/>" selected><s:property
value="toString()" /></option>
</s:if>
</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:textfield theme="simple" cssClass="dateinput"
+ onchange="changeFilter()" name="filter.createdAfter" size="7"
+ onkeydown="changeFilter()" title="%{#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>
+ <td><s:textfield theme="simple" cssClass="dateinput" onchange="changeFilter()"
+ name="filter.createdBefore" size="7" onkeydown="changeFilter()"
+ title="%{#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:textfield theme="simple" cssClass="dateinput"
+ onchange="changeFilter()" name="filter.updatedAfter" size="7"
+ onkeydown="changeFilter()" title="%{#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>
+ <td><s:textfield theme="simple" cssClass="dateinput"
+ onchange="changeFilter()" name="filter.updatedBefore" size="7"
+ onkeydown="changeFilter()" title="%{#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>
+ <td><s:textfield theme="simple" name="filter.words" size="%{getText(size.search.input)}"
+ onkeydown="changeFilter()"
+ title="%{getText(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>
+ <td><s:textfield theme="simple" name="filter.reference"
+ size="%{getText(size.search.input)}"
+ onkeydown="changeFilter()"
+ title="%{getText(help.search.refid)}" /></td>
</tr>
</table>
</td>
<td width="60%">
<table cellpadding="0" cellspacing="0" border="0" class="text">
- <s:iterator value="simulationContexts">
+ <s:iterator value="filter.simContexts">
<tr>
<td><input type="checkbox" checked
onClick="removeContext('<s:property value="index"/>')"> </td>
</div>
<!-- Result list
- =============================================================================================================================
+ ===========================================================================
-->
<div id="resulist">
<div id="article-box">
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 01.03.2013
+ * @author Author: Roman Kozlov
+ * @version Revision:
+ *****************************************************************************/
+
+package org.splat.conversion;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.struts2.util.StrutsTypeConverter;
+import org.splat.i18n.I18nUtils;
+
+import com.opensymphony.xwork2.ActionContext;
+
+/**
+ * Date conversion methods for Struts 2.<BR>
+ * To enable the date conversion for all action classes put into the classpath the file <code>xwork-conversion.properties</code>
+ * containing the following line:<BR>
+ * <code>java.util.Date=org.splat.conversion.DateConverter</code><BR>
+ * <BR>
+ * To enable the date conversion for the specific Struts 2 action class, place the file named
+ * <code>{ActionClassName}-conversion.properties</code> to the package of the action class.<BR>
+ *
+ * For example: <BR>
+ * class: <code>....CustomAction</code><BR>
+ * property file path: <code>classes/.../CustomAction-conversion.properties</code> <BR>
+ * This property file should contain a line for each form property.<BR>
+ * <BR>
+ * For example: <BR>
+ * <code>createdAfter=org.splat.conversion.DateConverter<BR>
+ * filter.createdAfter=org.splat.conversion.DateConverter</code>
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class DateConverter extends StrutsTypeConverter {
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object convertFromString(final Map context, final String[] values,
+ final Class toClass) { // NOPMD: extends StrutsTypeConverter
+ Object result = null;
+ String value = null;
+ if (null != values && values.length > 0) {
+ value = values[0];
+ }
+ if (StringUtils.isNotEmpty(value)) {
+ try {
+ result = DateUtils.parseDateStrictly(values[0], I18nUtils
+ .getMessage(ActionContext.getContext().getLocale(),
+ "date.format"));
+ if (result == null) {
+ // date can not be null so value is not in a good format
+ throw new ParseException("Bad format", 0);
+ }
+ } catch (ParseException e) {
+ throw new IllegalArgumentException(
+ "Cannot parse: " + values[0], e);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public String convertToString(final Map context, final Object o) { // NOPMD: extends StrutsTypeConverter
+ String result;
+ if (o instanceof Date) {
+ result = (new SimpleDateFormat(I18nUtils.getMessage(ActionContext
+ .getContext().getLocale(), "date.format"), ActionContext
+ .getContext().getLocale())).format((Date) o);
+ } else if (null == o) {
+ result = StringUtils.EMPTY;
+ } else {
+ result = o.toString();
+ }
+ return result;
+ }
+
+}
import org.splat.service.SimulationContextService;
import org.splat.service.UserService;
import org.splat.service.dto.Proxy;
+import org.splat.service.dto.SearchFilterDTO;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.ApplicationRights;
+import org.splat.wapp.Constants;
/**
* Base search action class used for searching studies and knowledge.
*
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
-public abstract class AbstractSearchBaseAction extends Action {
+public abstract class AbstractSearchBaseAction<FilterClass extends SearchFilterDTO>
+ extends Action {
/**
* Serial version ID.
*/
protected transient String _cindex = "";
/**
- * Study author to search.
+ * Search criteria.
*/
- protected String _author = null;
+ private FilterClass _filter;
/**
* List of users who can create studies.
*/
* Addable context types.
*/
protected transient List<SimulationContextType> _critext;
- /**
- * Current contexts search criteria.
- */
- protected transient List<SimulationContext> _context;
/**
* List of found objects.
*/
* 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.
*
* @return "selectype"
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings(Constants.UNCHECKED)
protected String doSelectContextType() {
SimulationContext.Properties sprop = new SimulationContext.Properties();
SimulationContext selected = getSimulationContextService()
.selectSimulationContext(Integer.valueOf(_cvalue));
- _context.add(selected);
+ getFilter().getSimContexts().add(selected);
setContextTypeOptions(getInvolvedContexts()); // Sets critext
getSession().remove(RESULT_KEY); // The current result is obsolete
return "refresh";
*/
protected String doRemoveContext() {
long index = Long.valueOf(_cindex);
- for (Iterator<SimulationContext> selected = _context.iterator(); selected
- .hasNext();) {
+ for (Iterator<SimulationContext> selected = getFilter()
+ .getSimContexts().iterator(); selected.hasNext();) {
if (selected.next().getIndex() == index) {
selected.remove();
break;
}
/**
+ * Cancel simulation context selection.
*
- * @return
+ * @return "refresh"
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings(Constants.UNCHECKED)
protected String doCancel() {
_result = (List<Proxy>) getSession().get(RESULT_KEY); // Current result search
setContextTypeOptions(getInvolvedContexts()); // Sets critext
return result;
}
- public String getAuthor() {
- return _author;
- }
-
public List<Name> getCandidates() {
return _candidates;
}
return _newtype;
}
- public List<SimulationContext> getSimulationContexts() {
- return _context;
- }
-
/**
* Get list of found objects.
*
// Setters
// ==============================================================================================================================
- /**
- * Set author id to search.
- *
- * @param index
- * persistent user id
- */
- public void setAuthor(final String index) {
- this._author = index;
- }
-
/**
* Set applied simulation context type id to search.
*
*/
protected void setContextTypeOptions(
final List<SimulationContextType> critext) {
- for (Iterator<SimulationContext> i = _context.iterator(); i.hasNext();) {
- critext.remove(i.next().getType()); // Already used context type
+ for (SimulationContext ctx : getFilter().getSimContexts()) {
+ critext.remove(ctx.getType()); // Already used context type
}
// Ordering by alphabetical order of localized context types
SimulationContextType[] types = critext
this._critext = Arrays.asList(types);
}
+ /**
+ * Load the search filter. The filter is taken from the session by its name.
+ *
+ * @see #getFilterName()
+ * @return the loaded filter
+ */
+ @SuppressWarnings(Constants.UNCHECKED)
+ protected Map<String, Object> loadFilter() {
+ Map<String, Object> filter = (Map<String, Object>) getSession().get(
+ getFilterName()); // A default filter is supposed being set at start
+
+ setFilter((FilterClass) filter.get("criteria"));
+ return filter;
+ }
+
+ /**
+ * Save search criteria in the session as a map with the defined name.
+ *
+ * @see #getFilterName()
+ * @return the saved filter
+ */
+ @SuppressWarnings(Constants.UNCHECKED)
+ protected Map<String, Object> saveFilter() {
+ Map<String, Object> filter = (Map<String, Object>) getSession().get(
+ getFilterName()); // A default filter is supposed being set at start
+
+ FilterClass savedCriteria = (FilterClass) filter.get("criteria");
+ FilterClass newCriteria = getFilter();
+ if (savedCriteria != null) {
+ // Only contexts are not part of the form so keep them between requests
+ newCriteria.setSimContexts(savedCriteria.getSimContexts());
+ }
+
+ filter.put("criteria", getFilter());
+ return filter;
+ }
+
// ==============================================================================================================================
// Abstract services
// ==============================================================================================================================
+ /**
+ * Search objects according to the given criteria.
+ *
+ * @return string result key
+ * @throws InvalidPropertyException
+ * if some criteria values are incorrect
+ */
protected abstract String doSearch() throws InvalidPropertyException;
+ /**
+ * List of context types available for filtering.
+ *
+ * @return list of simulation context types
+ */
protected abstract List<SimulationContextType> getInvolvedContexts();
- protected abstract void loadFilter();
+ /**
+ * Get the name of the search criteria filter saved as a map of objects in the session.
+ *
+ * @return the search filter name in the session
+ */
+ protected abstract String getFilterName();
- protected abstract void saveFilter();
+ /**
+ * Get search filter implementation.
+ *
+ * @return the search filter
+ */
+ protected abstract FilterClass getNewFilter();
// ==============================================================================================================================
// Getters and Setters
// ==============================================================================================================================
-
+
/**
* Get match options.
*
_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;
+ /**
+ * Get the filter.
+ *
+ * @return the filter
+ */
+ public FilterClass getFilter() {
+ if (_filter == null) {
+ _filter = getNewFilter();
+ }
+ return _filter;
}
- public void setWords(final String value) {
- this._words = value;
+ /**
+ * Set the filter.
+ *
+ * @param filter
+ * the filter to set
+ */
+ public void setFilter(final FilterClass filter) {
+ if (filter == null) {
+ _filter = getNewFilter();
+ } else {
+ _filter = filter;
+ }
}
}
\ No newline at end of file
package org.splat.simer;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Visibility;
import org.splat.kernel.InvalidPropertyException;
import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.SearchService;
+import org.splat.service.dto.KnowledgeSearchFilterDTO;
import org.splat.wapp.Constants;
/**
* Action for searching a knowledge in the database.
*/
-public class SearchKnowledgeAction extends AbstractSearchBaseAction {
+public class SearchKnowledgeAction extends
+ AbstractSearchBaseAction<KnowledgeSearchFilterDTO> {
/**
* Serial version ID.
*/
private static final long serialVersionUID = -3104321907432838476L;
- /**
- * Knowledge type index when among all.
- */
- private String _state = null;
- /**
- * Knowledge reference when among ref.
- */
- private String _reference = null;
/**
* Available knowledge types filter (initialized below).
*/
- private transient List<KnowledgeElementType> _knowledgeTypes;
+ private transient Map<Long, String> _knowledgeTypes;
/**
* Injected search service.
*/
doSearch();
// Final initialization of the form
- _knowledgeTypes = getKnowledgeElementTypeService()
- .selectTypesWhere(ProgressState.APPROVED);
+ _knowledgeTypes = buildKnowledgeTypesOptions();
+ getKnowledgeElementTypeService().selectTypesWhere(
+ ProgressState.APPROVED);
setCandidates();
setContextTypeOptions(getInvolvedContexts());
} catch (Exception error) {
return res;
}
+ /**
+ * Build the map of translated knowledge types available for selection.
+ *
+ * @return the map of translated knowledge types
+ */
+ private Map<Long, String> buildKnowledgeTypesOptions() {
+ Map<Long, String> options = new LinkedHashMap<Long, String>();
+ List<KnowledgeElementType> types = getKnowledgeElementTypeService()
+ .selectTypesWhere(ProgressState.APPROVED);
+ for (KnowledgeElementType ktype : types) {
+ options.put(ktype.getIndex(), getText(ktype.getKey()));
+ }
+ return options;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#doSearch()
+ */
@Override
protected String doSearch() throws InvalidPropertyException {
initializationScreenContext(Constants.OPEN);
- Map<String, Object> session = getSession();
KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
// Search matching all criteria
sprop.setType(getKnowledgeElementTypeService().selectType(
- Integer.valueOf(_state)));
- if (getWords().length() > 0) {
- sprop.setTitle(getWords());
+ Integer.valueOf(getFilter().getKtype())));
+ if (getFilter().getWords().length() > 0) {
+ sprop.setTitle(getFilter().getWords());
}
- if (_reference.length() > 0) {
- sprop.setReference(_reference);
+ if (getFilter().getReference().length() > 0) {
+ sprop.setReference(getFilter().getReference());
}
- if (_context.size() > 0) {
- sprop.setSimulationContexts(_context);
+ if (getFilter().getSimContexts().size() > 0) {
+ sprop.setSimulationContexts(getFilter().getSimContexts());
}
- int index = Integer.valueOf(_author);
+ int index = Integer.valueOf(getFilter().getAuthor());
if (index > 0) {
User him = getUserService().selectUser(index);
sprop.setAuthor(him);
}
// Set of the visibility
- KnowledgeElement.Properties other = sprop.copy();
+ KnowledgeElement.Properties other = sprop.copy();
- other.setVisibility(Visibility.PUBLIC);
- sprop.setVisibility(Visibility.PRIVATE);
- sprop.setActor(getConnectedUser());
+ other.setVisibility(Visibility.PUBLIC);
+ sprop.setVisibility(Visibility.PRIVATE);
+ sprop.setActor(getConnectedUser());
- _result = getSearchService().selectKnowledgeElementsWhere(sprop,
- other);
- session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
+ _result = getSearchService().selectKnowledgeElementsWhere(sprop, other);
+ getSession().put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
return "refresh";
}
// Getters
// ==============================================================================================================================
- public List<KnowledgeElementType> getKnowledgeTypes() {
+ public Map<Long, String> getKnowledgeTypes() {
return _knowledgeTypes;
}
- public String getReference() {
- return _reference;
- }
-
- public String getState() {
- return _state;
- }
-
- public void setReference(final String value) {
- this._reference = value;
- }
-
- public void setState(final String value) {
- this._state = value;
- }
-
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#getInvolvedContexts()
+ */
@Override
protected List<SimulationContextType> getInvolvedContexts() {
return getSimulationContextService().selectAllTypes();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#saveFilter()
+ */
@Override
- @SuppressWarnings("unchecked")
- protected void loadFilter() {
- Map<String, Object> session = getSession();
- Map<String, Object> filter = (Map<String, Object>) session
- .get("knowledge.filter"); // A default filter is supposed being set at start
-
- 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");
- setWords ((String) filter.get("title"));
- _context = (List<SimulationContext>) filter.get("context");
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected void saveFilter() {
- Map<String, Object> session = getSession();
- Map<String, Object> filter = (Map<String, Object>) session
- .get("knowledge.filter"); // A default filter is supposed being set at start
-
- filter.put("matchamong", getCriteriaMatch());
- filter.put("matcontext", getContextMatch());
- filter.put("type", this._state);
- filter.put("author", this._author);
- filter.put("reference", "");
- filter.put("title", getWords());
-
- _context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
+ protected Map<String, Object> saveFilter() {
+ Map<String, Object> filter = super.saveFilter();
// Initialization required by all do functions
- _knowledgeTypes = getKnowledgeElementTypeService().selectTypesWhere(
- ProgressState.APPROVED);
+ _knowledgeTypes = buildKnowledgeTypesOptions();
+ return filter;
}
/**
final KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#getFilterName()
+ */
+ @Override
+ protected String getFilterName() {
+ return "knowledge.filter";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#getNewFilter()
+ */
+ @Override
+ protected KnowledgeSearchFilterDTO getNewFilter() {
+ return new KnowledgeSearchFilterDTO();
+ }
}
\ No newline at end of file
import java.util.List;
import java.util.Map;
-import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
import org.splat.kernel.InvalidPropertyException;
import org.splat.service.SearchService;
+import org.splat.service.dto.StudySearchFilterDTO;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.wapp.Constants;
/**
* Search studies form action.
*/
-public class SearchStudyAction extends AbstractSearchBaseAction {
+public class SearchStudyAction extends
+ AbstractSearchBaseAction<StudySearchFilterDTO> {
/**
* Serial version ID.
*/
private static final long serialVersionUID = -1910481357051393077L;
- /**
- * "In-Work", "In-Draft", "In-Check"...
- */
- private String _state = null;
- /**
- * Study reference.
- */
- private String _reference = null;
/**
* Injected project settings service.
*/
*/
private SearchService _searchService;
- enum UserAction {
- refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
- }
-
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
*/
@Override
protected String doSearch() throws InvalidPropertyException {
- Map<String, Object> session = getSession();
- Study.Properties sprop = new Study.Properties();
-
- // Search matching all criteria
- if (!this._state.equals("ANY")) {
- sprop.setState(ProgressState.valueOf(this._state));
- }
- if (getWords().length() > 0) {
- sprop.setTitle(getWords());
- }
- if (_reference.length() > 0) {
- sprop.setReference(_reference);
- }
- if (_context.size() > 0) {
- sprop.setSimulationContexts(_context);
- }
- int index = Integer.valueOf(_author);
- if (index > 0) {
- User him = getUserService().selectUser(index);
- sprop.setManager(him);
+ if (getConnectedUser() != null) {
+ getFilter().setConnectedUserId(getConnectedUser().getIndex());
}
- sprop.setActor(getConnectedUser());
-
- _result = getSearchService().selectStudiesWhere(
- "all".equals(getCriteriaMatch()),
- "all".equals(getContextMatch()), sprop);
- session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
+ _result = getSearchService().selectStudiesWhere(getFilter());
+ getSession().put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
return "refresh";
}
// Getters
// ==============================================================================================================================
- public String getReference() {
- return _reference;
- }
-
- public String getState() {
- return _state;
- }
-
- public void setReference(final String value) {
- this._reference = value;
- }
-
- public void setState(final String value) {
- this._state = value;
- }
-
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#getInvolvedContexts()
+ */
@Override
protected List<SimulationContextType> getInvolvedContexts() {
List<ProjectSettingsService.Step> steps = getProjectSettings()
return getSimulationContextService().selectTypesOf(number);
}
- @Override
- @SuppressWarnings("unchecked")
- protected void loadFilter() {
- Map<String, Object> session = getSession();
- Map<String, Object> filter = (Map<String, Object>) session
- .get("study.filter"); // A default filter is supposed being set at start
-
- 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");
- setWords((String) filter.get("title"));
- _context = (List<SimulationContext>) filter.get("context");
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected void saveFilter() {
- Map<String, Object> session = getSession();
- Map<String, Object> filter = (Map<String, Object>) session
- .get("study.filter"); // A default filter is supposed being set at start
-
- 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", getWords());
-
- _context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
-
- }
-
/**
* Get match options.
*
final ProjectSettingsService projectSettingsService) {
_projectSettings = projectSettingsService;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#getFilterName()
+ */
+ @Override
+ protected String getFilterName() {
+ return "study.filter";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.simer.AbstractSearchBaseAction#getNewFilter()
+ */
+ @Override
+ protected StudySearchFilterDTO getNewFilter() {
+ return new StudySearchFilterDTO();
+ }
}
\ No newline at end of file
* Checked out element icon.
*/
public static final String IMG_CHECKEDOUT = "icon.checkedout.png";
+ /**
+ * "unchecked" literal constant for annotations.
+ */
+ public static final String UNCHECKED = "unchecked";
}
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
- <value>conf/log-messages</value>
+ <value>conf/log-messages</value>
+ <value>som</value>
</list>
</property>
</bean>
--- /dev/null
+java.util.Date=org.splat.conversion.DateConverter
\ No newline at end of file