From: mka Date: Thu, 19 Sep 2013 09:27:46 +0000 (+0000) Subject: Sort study and knowledge results functionalities are implemented X-Git-Tag: V7_3_0b1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=02928e5520a5f70bd5556239ce9f9ba1c7ada0eb;p=tools%2Fsiman.git Sort study and knowledge results functionalities are implemented --- diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java index 2baaf40..96bff1b 100644 --- a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java @@ -201,9 +201,11 @@ public class SearchServiceImpl implements SearchService { // Construction of the result list for (KnowledgeElement kelm : found) { - result.add(new StudyDTO(kelm.getIndex(), kelm.getReference(), kelm + StudyDTO studyDTO = new StudyDTO(kelm.getIndex(), kelm.getReference(), kelm .getProgressState(), kelm.getTitle(), kelm.getAuthor() - .getDisplayName())); + .getDisplayName()); + studyDTO.setDate(kelm.getDate()); + result.add(studyDTO); } return result; } @@ -308,9 +310,12 @@ public class SearchServiceImpl implements SearchService { // Construction of the result list for (Study std : found) { - result.add(new StudyDTO(std.getIndex(), std.getReference(), std + StudyDTO studyDTO = new StudyDTO(std.getIndex(), std.getReference(), std .getProgressState(), std.getTitle(), std.getAuthor() - .getDisplayName())); + .getDisplayName()); + studyDTO.setDate(std.getDate()); + studyDTO.setLastModificationDate(std.getLastModificationDate()); + result.add(studyDTO); } return result; } diff --git a/Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java b/Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java index 6221a38..cd0ad8c 100644 --- a/Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java +++ b/Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java @@ -11,6 +11,7 @@ package org.splat.service.dto; import java.io.Serializable; +import java.util.Date; import org.splat.dal.bo.som.ProgressState; @@ -44,13 +45,21 @@ public class StudyDTO implements Proxy, Serializable { * Type. */ private transient String _type; + /** + * Creation date. + */ + private transient Date _date; + /** + * Last modification date. + */ + private Date _lastModificationDate; /** * Serialization version id. */ private static final long serialVersionUID = -4386494192709562221L; /** - * Costructor from properties. + * Constructor from properties except for creation and modification dates. * * @param id * study persistent id @@ -125,4 +134,36 @@ public class StudyDTO implements Proxy, Serializable { public String getType() { return _type; } + + /** + * Get the date. + * @return the date + */ + public Date getDate() { + return _date; + } + + /** + * Set the date. + * @param date the date to set + */ + public void setDate(final Date date) { + _date = date; + } + + /** + * Get the lastModificationDate. + * @return the lastModificationDate + */ + public Date getLastModificationDate() { + return _lastModificationDate; + } + + /** + * Set the lastModificationDate. + * @param lastModificationDate the lastModificationDate to set + */ + public void setLastModificationDate(final Date lastModificationDate) { + _lastModificationDate = lastModificationDate; + } } diff --git a/Workspace/Siman/WebContent/study/searchKnowledge.jsp b/Workspace/Siman/WebContent/study/searchKnowledge.jsp index 50e641a..229a332 100644 --- a/Workspace/Siman/WebContent/study/searchKnowledge.jsp +++ b/Workspace/Siman/WebContent/study/searchKnowledge.jsp @@ -187,14 +187,56 @@ $(document).ready(function () { - - - - - + + + + + + + + + + + + + + + + - + @@ -207,6 +249,7 @@ $(document).ready(function () { + diff --git a/Workspace/Siman/WebContent/study/searchStudy.jsp b/Workspace/Siman/WebContent/study/searchStudy.jsp index aa73faf..2d4c909 100644 --- a/Workspace/Siman/WebContent/study/searchStudy.jsp +++ b/Workspace/Siman/WebContent/study/searchStudy.jsp @@ -191,13 +191,65 @@ $(document).ready(function () { class="text"> - - - + + + + + + + + + + + + + + + + - + @@ -210,6 +262,8 @@ $(document).ready(function () { + + diff --git a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java index 0ddb11e..4b3808e 100644 --- a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java +++ b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java @@ -3,6 +3,8 @@ package org.splat.simer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -17,6 +19,7 @@ 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.dto.StudyDTO; import org.splat.service.technical.ProjectSettingsService; import org.splat.som.ApplicationRights; import org.splat.wapp.Constants; @@ -92,10 +95,126 @@ public abstract class AbstractSearchBaseAction { + + /** + * The criteria by which studies are compared. + */ + SortCriterion _criterion = SortCriterion.NAME; + + /** + * Constructor from comparison criteria. + * @param criterion + * the criteria + */ + public StudyComparator(final SortCriterion criterion) { + _criterion = criterion; + } + + /** + * {@inheritDoc} + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + public int compare(final StudyDTO first, final StudyDTO second) { + switch (_criterion) { + case REFERENCE: + return first.getReference().compareTo(second.getReference()); + case CREATEDATE: + return first.getDate().compareTo(second.getDate()); + case MODIFDATE: + return first.getLastModificationDate().compareTo( + second.getLastModificationDate()); + case RESPONSIBLE: + return getText(first.getAuthorName()) + .compareTo(getText(second.getAuthorName())); + default: + return first.getTitle().compareTo(second.getTitle()); + } + } + } + + /** + * Set search results sort order. + * @return + * SUCCESS if successfully found and sorted search results; + * ERROR otherwise + */ + public String doSetOrder() { + String res = ERROR; + _result = (List) getSession().get(RESULT_KEY); + Boolean order = (Boolean) getSession().get(ORDER_KEY); + SortCriterion oldSortedBy = (SortCriterion) getSession().get(CRITERION_KEY); + + if (_result != null) { + + if (_newSortedBy != null && !_newSortedBy.equals(oldSortedBy)) { // Sort by new criterion + // Direct cast into collection of another type just won't work in Java + Collections.sort((List)(List) _result, new StudyComparator(_newSortedBy)); + getSession().put(CRITERION_KEY, _newSortedBy); + getSession().put(ORDER_KEY, false); + } else { + if (order == null) { + order = false; + } else { // need to change the order + order = !order; + } + getSession().put(ORDER_KEY, order); + Collections.reverse(_result); + } + res = SUCCESS; + } + + return res; + } + /** * Perform actions according to the current mode. * @@ -517,4 +636,20 @@ public abstract class AbstractSearchBaseAction page.home + + + page.searchstudy + + + page.searchstudy + + @@ -245,6 +254,15 @@ page.searchknowledge + + + page.searchknowledge + + + page.searchknowledge + +
" border="none" />
+ + + + + " border="none" /> + + + + + + + + " border="none" /> + + + + + + + + " border="none" /> + + + + + + + + " border="none" /> + + +
" border="none" /> + + + + + " border="none" /> + + + + + + + + " border="none" /> + + + + + + + + " border="none" /> + + + + + + + + " border="none" /> + + + + + + + + " border="none" /> + + +