CST-5249 find Topic order by QAevent.key, means by the topic name

This commit is contained in:
frabacche
2023-12-14 17:04:16 +01:00
parent 5f992e0b71
commit 95056d509c
3 changed files with 25 additions and 9 deletions

View File

@@ -27,11 +27,9 @@ public interface QAEventService {
* Find all the event's topics.
*
* @param offset the offset to apply
* @param pageSize the page size
* @return the topics list
*/
public List<QATopic> findAllTopics(long offset, long pageSize);
public List<QATopic> findAllTopics(long offset, long count, String orderField, boolean ascending);
/**
* Find all the event's topics related to the given source.
*
@@ -40,7 +38,8 @@ public interface QAEventService {
* @param count the page size
* @return the topics list
*/
public List<QATopic> findAllTopicsBySource(String source, long offset, long count);
public List<QATopic> findAllTopicsBySource(String source, long offset, long count,
String orderField, boolean ascending);
/**
* Count all the event's topics.

View File

@@ -36,6 +36,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.FacetParams;
import org.dspace.content.Item;
import org.dspace.content.QAEvent;
import org.dspace.content.service.ItemService;
@@ -188,12 +189,13 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public List<QATopic> findAllTopics(long offset, long count) {
return findAllTopicsBySource(null, offset, count);
public List<QATopic> findAllTopics(long offset, long count, String orderField, boolean ascending) {
return findAllTopicsBySource(null, offset, count, orderField, ascending);
}
@Override
public List<QATopic> findAllTopicsBySource(String source, long offset, long count) {
public List<QATopic> findAllTopicsBySource(String source, long offset, long count,
String orderField, boolean ascending) {
if (source != null && isNotSupportedSource(source)) {
return null;
@@ -201,6 +203,8 @@ public class QAEventServiceImpl implements QAEventService {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(0);
solrQuery.setSort(orderField, ascending ? ORDER.asc : ORDER.desc);
solrQuery.setFacetSort(FacetParams.FACET_SORT_INDEX);
solrQuery.setQuery("*:*");
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);