Skip to content

Commit

Permalink
[CST-13444] configured date facet for LDN Message Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
steph-ieffam committed Jan 30, 2024
1 parent d05a5d6 commit 367048b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.solr.common.SolrInputDocument;
import org.dspace.app.ldn.LDNMessageEntity;
import org.dspace.app.ldn.NotifyServiceEntity;
Expand Down Expand Up @@ -120,13 +122,29 @@ public SolrInputDocument buildDocument(Context context, IndexableLDNNotification
addFacetIndex(doc, "coar_notify_type", ldnMessage.getCoarNotifyType(), ldnMessage.getCoarNotifyType());
doc.addField("queue_attempts", ldnMessage.getQueueAttempts());
doc.addField("queue_attempts_sort", ldnMessage.getQueueAttempts());
doc.addField("queue_last_start_time", ldnMessage.getQueueLastStartTime());
doc.addField("queue_last_start_time_dt", ldnMessage.getQueueLastStartTime());

indexDateFieldForFacet(doc, ldnMessage.getQueueLastStartTime());

doc.addField("queue_timeout", ldnMessage.getQueueTimeout());
String notificationType = LDNMessageEntity.getNotificationType(ldnMessage);
addFacetIndex(doc, "notification_type", notificationType, notificationType);

return doc;
}

private void indexDateFieldForFacet(SolrInputDocument doc, Date queueLastStartTime) {
if (queueLastStartTime != null) {
String value = DateFormatUtils.format(queueLastStartTime, "yyyy-MM-dd");
doc.addField("queue_last_start_time", value);
doc.addField("queue_last_start_time_dt", queueLastStartTime);
doc.addField("queue_last_start_time_keyword", value);
doc.addField("queue_last_start_time_min", value);
doc.addField("queue_last_start_time_min_sort", value);
doc.addField("queue_last_start_time_max", value);
doc.addField("queue_last_start_time_max_sort", value);
doc.addField("queue_last_start_time.year",
Integer.parseInt(DateFormatUtils.format(queueLastStartTime, "yyyy")));
}
}

}
18 changes: 18 additions & 0 deletions dspace/config/spring/api/discovery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,7 @@
<ref bean="searchFilterNotifyQueueStatus" />
<ref bean="searchFilterNotifyActivityStreamType" />
<ref bean="searchFilterNotifyCoarNotifyType" />
<ref bean="searchFilterNotifyLastStartTime" />
</list>
</property>
<!--The search filters which can be used on the discovery search page -->
Expand All @@ -2166,6 +2167,7 @@
<ref bean="searchFilterNotifyQueueStatus" />
<ref bean="searchFilterNotifyActivityStreamType" />
<ref bean="searchFilterNotifyCoarNotifyType" />
<ref bean="searchFilterNotifyLastStartTime" />
</list>
</property>
<!--The sort filters for the discovery search-->
Expand Down Expand Up @@ -3221,6 +3223,22 @@
<property name="isOpenByDefault" value="true"/>
<property name="pageSize" value="10"/>
</bean>

<bean id="searchFilterNotifyLastStartTime" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
<property name="indexFieldName" value="queue_last_start_time"/>
<property name="metadataFields">
<list>
<value></value>
</list>
</property>
<property name="type" value="date"/>
<property name="facetLimit" value="5"/>
<property name="sortOrderSidebar" value="COUNT"/>
<property name="sortOrderFilterPage" value="COUNT"/>
<property name="isOpenByDefault" value="false"/>
<property name="pageSize" value="10"/>
<property name="exposeMinAndMaxValue" value="true"/>
</bean>

<!--Sort properties-->
<bean id="sortScore" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
Expand Down

0 comments on commit 367048b

Please sign in to comment.