national_admin_functions #1
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.lbs.openaire;
|
package eu.dnetlib.lbs.openaire;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -20,9 +21,8 @@ import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
|
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticSearchScrollUtils;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHit;
|
import org.springframework.data.elasticsearch.core.SearchHit;
|
||||||
import org.springframework.data.elasticsearch.core.SearchHits;
|
import org.springframework.data.elasticsearch.core.SearchHits;
|
||||||
import org.springframework.data.elasticsearch.core.SearchScrollHits;
|
import org.springframework.data.elasticsearch.core.SearchScrollHits;
|
||||||
|
@ -69,6 +69,8 @@ public class OpenaireBrokerController extends AbstractLbsController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ElasticSearchProperties props;
|
private ElasticSearchProperties props;
|
||||||
|
|
||||||
|
private static final long SCROLL_TIMEOUT_IN_MILLIS = 5 * 60 * 1000;
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(OpenaireBrokerController.class);
|
private static final Log log = LogFactory.getLog(OpenaireBrokerController.class);
|
||||||
|
|
||||||
@ApiOperation("Return the datasources having events")
|
@ApiOperation("Return the datasources having events")
|
||||||
|
@ -230,7 +232,7 @@ public class OpenaireBrokerController extends AbstractLbsController {
|
||||||
|
|
||||||
if (optSub.isPresent()) {
|
if (optSub.isPresent()) {
|
||||||
|
|
||||||
final AbstractElasticsearchTemplate esTemplate = (AbstractElasticsearchTemplate) esOperations;
|
final ElasticsearchRestTemplate esTemplate = (ElasticsearchRestTemplate) esOperations;
|
||||||
|
|
||||||
final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
|
final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
|
||||||
.withQuery(QueryBuilders.matchQuery("subscriptionId", subscrId))
|
.withQuery(QueryBuilders.matchQuery("subscriptionId", subscrId))
|
||||||
|
@ -239,13 +241,12 @@ public class OpenaireBrokerController extends AbstractLbsController {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final SearchScrollHits<Notification> scroll =
|
final SearchScrollHits<Notification> scroll =
|
||||||
ElasticSearchScrollUtils.startScroll(esTemplate, IndexCoordinates.of(props.getNotificationsIndexName()), searchQuery, Notification.class);
|
esTemplate.searchScrollStart(SCROLL_TIMEOUT_IN_MILLIS, searchQuery, Notification.class, IndexCoordinates.of(props.getNotificationsIndexName()));
|
||||||
|
|
||||||
if (scroll.hasSearchHits()) {
|
if (scroll.hasSearchHits()) {
|
||||||
final List<OaBrokerEventPayload> values = calculateEventPayloads(scroll);
|
final List<OaBrokerEventPayload> values = calculateEventPayloads(scroll);
|
||||||
return new ScrollPage(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
|
return new ScrollPage(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
|
||||||
} else {
|
} else {
|
||||||
ElasticSearchScrollUtils.clearScroll(esTemplate, scroll.getScrollId());
|
esTemplate.searchScrollClear(Arrays.asList(scroll.getScrollId()));
|
||||||
return new ScrollPage(null, true, new ArrayList<>());
|
return new ScrollPage(null, true, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,16 +261,15 @@ public class OpenaireBrokerController extends AbstractLbsController {
|
||||||
@GetMapping("/scroll/notifications/{scrollId}")
|
@GetMapping("/scroll/notifications/{scrollId}")
|
||||||
public ScrollPage scrollNotifications(@PathVariable final String scrollId) {
|
public ScrollPage scrollNotifications(@PathVariable final String scrollId) {
|
||||||
|
|
||||||
final AbstractElasticsearchTemplate esTemplate = (AbstractElasticsearchTemplate) esOperations;
|
final ElasticsearchRestTemplate esTemplate = (ElasticsearchRestTemplate) esOperations;
|
||||||
|
|
||||||
final SearchScrollHits<Notification> scroll =
|
final SearchScrollHits<Notification> scroll =
|
||||||
ElasticSearchScrollUtils.continueScroll(esTemplate, IndexCoordinates.of(props.getNotificationsIndexName()), scrollId, Notification.class);
|
esTemplate.searchScrollContinue(scrollId, SCROLL_TIMEOUT_IN_MILLIS, Notification.class, IndexCoordinates.of(props.getNotificationsIndexName()));
|
||||||
|
|
||||||
if (scroll.hasSearchHits()) {
|
if (scroll.hasSearchHits()) {
|
||||||
final List<OaBrokerEventPayload> values = calculateEventPayloads(scroll);
|
final List<OaBrokerEventPayload> values = calculateEventPayloads(scroll);
|
||||||
return new ScrollPage(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
|
return new ScrollPage(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
|
||||||
} else {
|
} else {
|
||||||
ElasticSearchScrollUtils.clearScroll(esTemplate, scroll.getScrollId());
|
esTemplate.searchScrollClear(Arrays.asList(scroll.getScrollId()));
|
||||||
return new ScrollPage(null, true, new ArrayList<>());
|
return new ScrollPage(null, true, new ArrayList<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package org.springframework.data.elasticsearch.core;
|
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.Query;
|
|
||||||
|
|
||||||
public class ElasticSearchScrollUtils {
|
|
||||||
|
|
||||||
private static final long SCROLL_TIMEOUT_IN_MILLIS = 5 * 60 * 1000;
|
|
||||||
|
|
||||||
public static <T> SearchScrollHits<T> startScroll(final AbstractElasticsearchTemplate esTemplate,
|
|
||||||
final IndexCoordinates index,
|
|
||||||
final Query searchQuery,
|
|
||||||
final Class<T> clazz) {
|
|
||||||
|
|
||||||
return esTemplate.searchScrollStart(SCROLL_TIMEOUT_IN_MILLIS, searchQuery, clazz, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> SearchScrollHits<T> continueScroll(final AbstractElasticsearchTemplate esTemplate,
|
|
||||||
final IndexCoordinates index,
|
|
||||||
final String scrollId,
|
|
||||||
final Class<T> clazz) {
|
|
||||||
return esTemplate.searchScrollContinue(scrollId, SCROLL_TIMEOUT_IN_MILLIS, clazz, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearScroll(final AbstractElasticsearchTemplate esTemplate, final String scrollId) {
|
|
||||||
esTemplate.searchScrollClear(scrollId);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,14 +26,14 @@ lbs.elastic.eventsIndexType = event
|
||||||
lbs.elastic.notificationsIndexName = notifications_beta_michele
|
lbs.elastic.notificationsIndexName = notifications_beta_michele
|
||||||
lbs.elastic.notificationsIndexType = notification
|
lbs.elastic.notificationsIndexType = notification
|
||||||
|
|
||||||
lbs.mail.from = lbs-noreply@research-infrastructures.eu
|
lbs.mail.from = notifications-noreply@openaire.eu
|
||||||
lbs.mail.fromName = Literature Broker Service
|
lbs.mail.fromName = Literature Broker Service
|
||||||
lbs.mail.cc = michele.artini@isti.cnr.it
|
lbs.mail.cc = michele.artini@isti.cnr.it
|
||||||
lbs.mail.smtpHost = smtp.isti.cnr.it
|
lbs.mail.smtpHost = smtp.isti.cnr.it
|
||||||
lbs.mail.smtpPort = 587
|
lbs.mail.smtpPort = 587
|
||||||
lbs.mail.smtpUser = smtp-dnet
|
lbs.mail.smtpUser = smtp-dnet
|
||||||
lbs.mail.smtpPassword = hhr*7932
|
lbs.mail.smtpPassword = hhr*7932
|
||||||
lbs.mail.message.template = classpath:/templates/mail.st
|
lbs.mail.message.template = classpath:/templates/openaire_mail.st
|
||||||
|
|
||||||
|
|
||||||
lbs.queues.maxReturnedValues = 1000
|
lbs.queues.maxReturnedValues = 1000
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
You have received this mail because you are owner of the following subscription:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><b>Topic: </b>$sub.topic$</li>
|
||||||
|
<li><b>Frequency: </b>$sub.frequency$</li>
|
||||||
|
<li><b>Mode: </b>$sub.mode$</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<p>
|
||||||
|
There are $total$ event(s) related to the following publications<br />
|
||||||
|
(The list is limited to $max$ events, see the Content Provider Dashboard for all):
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
$events:{e|
|
||||||
|
<li>
|
||||||
|
<b>$e.map.targetResultTitle$</b><br/>
|
||||||
|
<small style="color: grey">$e.map.targetAuthors$</small>
|
||||||
|
</li>
|
||||||
|
}$
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
This email message was auto-generated. Please do not respond.
|
Loading…
Reference in New Issue