mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[CST-5249] Community feedbacks
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.nbevent;
|
||||
|
||||
import org.dspace.app.nbevent.service.dto.NBMessage;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessageDTO;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
@@ -27,5 +27,5 @@ public interface NBAction {
|
||||
* @param relatedItem the related item, if any
|
||||
* @param message the message with the correction details
|
||||
*/
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessage message);
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessageDTO message);
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@ import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessage;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessage;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessageDTO;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessageDTO;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.EntityType;
|
||||
@@ -37,7 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
public class NBEntityMetadataAction implements NBAction {
|
||||
public class NBEntityOpenaireMetadataAction implements NBAction {
|
||||
private String relation;
|
||||
private String entityType;
|
||||
private Map<String, String> entityMetadata;
|
||||
@@ -103,7 +103,7 @@ public class NBEntityMetadataAction implements NBAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessage message) {
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessageDTO message) {
|
||||
try {
|
||||
if (relatedItem != null) {
|
||||
link(context, item, relatedItem);
|
||||
@@ -134,6 +134,10 @@ public class NBEntityMetadataAction implements NBAction {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new relationship between the two given item, based on the configured
|
||||
* relation.
|
||||
*/
|
||||
private void link(Context context, Item item, Item relatedItem) throws SQLException, AuthorizeException {
|
||||
EntityType project = entityTypeService.findByEntityType(context, entityType);
|
||||
RelationshipType relType = relationshipTypeService.findByEntityType(context, project).stream()
|
||||
@@ -151,12 +155,12 @@ public class NBEntityMetadataAction implements NBAction {
|
||||
relationshipService.update(context, persistedRelationship);
|
||||
}
|
||||
|
||||
private String getValue(NBMessage message, String key) {
|
||||
if (!(message instanceof OpenaireMessage)) {
|
||||
private String getValue(NBMessageDTO message, String key) {
|
||||
if (!(message instanceof OpenaireMessageDTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
OpenaireMessage openaireMessage = (OpenaireMessage) message;
|
||||
OpenaireMessageDTO openaireMessage = (OpenaireMessageDTO) message;
|
||||
|
||||
if (StringUtils.equals(key, "acronym")) {
|
||||
return openaireMessage.getAcronym();
|
@@ -79,7 +79,7 @@ public class NBEventActionServiceImpl implements NBEventActionService {
|
||||
topicsToActions.get(nbevent.getTopic()).applyCorrection(context, item, related,
|
||||
jsonMapper.readValue(nbevent.getMessage(), nbevent.getMessageDtoClass()));
|
||||
nbEventService.deleteEventByEventId(nbevent.getEventId());
|
||||
makeAcknowledgement(nbevent.getEventId(), NBEvent.ACCEPTED);
|
||||
makeAcknowledgement(nbevent.getEventId(), nbevent.getSource(), NBEvent.ACCEPTED);
|
||||
} catch (SQLException | JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -88,17 +88,20 @@ public class NBEventActionServiceImpl implements NBEventActionService {
|
||||
@Override
|
||||
public void discard(Context context, NBEvent nbevent) {
|
||||
nbEventService.deleteEventByEventId(nbevent.getEventId());
|
||||
makeAcknowledgement(nbevent.getEventId(), NBEvent.DISCARDED);
|
||||
makeAcknowledgement(nbevent.getEventId(), nbevent.getSource(), NBEvent.DISCARDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reject(Context context, NBEvent nbevent) {
|
||||
nbEventService.deleteEventByEventId(nbevent.getEventId());
|
||||
makeAcknowledgement(nbevent.getEventId(), NBEvent.REJECTED);
|
||||
makeAcknowledgement(nbevent.getEventId(), nbevent.getSource(), NBEvent.REJECTED);
|
||||
}
|
||||
|
||||
private void makeAcknowledgement(String eventId, String status) {
|
||||
String[] ackwnoledgeCallbacks = configurationService.getArrayProperty("oaire-nbevents.acknowledge-url");
|
||||
/**
|
||||
* Make acknowledgement to the configured urls for the event status.
|
||||
*/
|
||||
private void makeAcknowledgement(String eventId, String source, String status) {
|
||||
String[] ackwnoledgeCallbacks = configurationService.getArrayProperty(source + "-nbevents.acknowledge-url");
|
||||
if (ackwnoledgeCallbacks != null) {
|
||||
for (String ackwnoledgeCallback : ackwnoledgeCallbacks) {
|
||||
if (StringUtils.isNotBlank(ackwnoledgeCallback)) {
|
||||
|
@@ -10,8 +10,8 @@ package org.dspace.app.nbevent;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dspace.app.nbevent.service.dto.NBMessage;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessage;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessageDTO;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessageDTO;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
public class NBMetadataMapAction implements NBAction {
|
||||
public class NBOpenaireMetadataMapAction implements NBAction {
|
||||
public static final String DEFAULT = "default";
|
||||
|
||||
private Map<String, String> types;
|
||||
@@ -44,14 +44,18 @@ public class NBMetadataMapAction implements NBAction {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the correction on one metadata field of the given item based on the
|
||||
* openaire message type.
|
||||
*/
|
||||
@Override
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessage message) {
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessageDTO message) {
|
||||
|
||||
if (!(message instanceof OpenaireMessage)) {
|
||||
if (!(message instanceof OpenaireMessageDTO)) {
|
||||
throw new IllegalArgumentException("Unsupported message type: " + message.getClass());
|
||||
}
|
||||
|
||||
OpenaireMessage openaireMessage = (OpenaireMessage) message;
|
||||
OpenaireMessageDTO openaireMessage = (OpenaireMessageDTO) message;
|
||||
|
||||
try {
|
||||
String targetMetadata = types.get(openaireMessage.getType());
|
||||
@@ -65,6 +69,7 @@ public class NBMetadataMapAction implements NBAction {
|
||||
} catch (SQLException | AuthorizeException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String[] splitMetadata(String metadata) {
|
@@ -9,8 +9,8 @@ package org.dspace.app.nbevent;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.dspace.app.nbevent.service.dto.NBMessage;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessage;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessageDTO;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessageDTO;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
public class NBSimpleMetadataAction implements NBAction {
|
||||
public class NBOpenaireSimpleMetadataAction implements NBAction {
|
||||
private String metadata;
|
||||
private String metadataSchema;
|
||||
private String metadataElement;
|
||||
@@ -51,10 +51,10 @@ public class NBSimpleMetadataAction implements NBAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessage message) {
|
||||
public void applyCorrection(Context context, Item item, Item relatedItem, NBMessageDTO message) {
|
||||
try {
|
||||
itemService.addMetadata(context, item, metadataSchema, metadataElement, metadataQualifier, null,
|
||||
((OpenaireMessage) message).getAbstracts());
|
||||
((OpenaireMessageDTO) message).getAbstracts());
|
||||
itemService.update(context, item);
|
||||
} catch (SQLException | AuthorizeException e) {
|
||||
throw new RuntimeException(e);
|
@@ -10,7 +10,7 @@ package org.dspace.app.nbevent;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* This model class represent the notification broker source concept
|
||||
* This model class represent the source/provider of the NB events (as OpenAIRE).
|
||||
*
|
||||
* @author Luca Giamminonni (luca.giamminonni at 4Science)
|
||||
*
|
||||
|
@@ -15,7 +15,7 @@ import org.dspace.content.NBEvent;
|
||||
* @author Luca Giamminonni (luca.giamminonni at 4science.it)
|
||||
*
|
||||
*/
|
||||
public interface NBMessage {
|
||||
public interface NBMessageDTO {
|
||||
|
||||
|
||||
}
|
@@ -10,12 +10,12 @@ package org.dspace.app.nbevent.service.dto;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Implementation of {@link NBMessage} that model message coming from OPENAIRE.
|
||||
* Implementation of {@link NBMessageDTO} that model message coming from OPENAIRE.
|
||||
*
|
||||
* @author Luca Giamminonni (luca.giamminonni at 4science.it)
|
||||
*
|
||||
*/
|
||||
public class OpenaireMessage implements NBMessage {
|
||||
public class OpenaireMessageDTO implements NBMessageDTO {
|
||||
|
||||
@JsonProperty("pids[0].value")
|
||||
private String value;
|
@@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrQuery.ORDER;
|
||||
@@ -55,8 +54,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class NBEventServiceImpl implements NBEventService {
|
||||
|
||||
private static final Logger log = Logger.getLogger(NBEventServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
|
@@ -14,8 +14,8 @@ import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.dspace.app.nbevent.RawJsonDeserializer;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessage;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessage;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessageDTO;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessageDTO;
|
||||
|
||||
/**
|
||||
* This class represent the notification broker data as loaded in our solr
|
||||
@@ -192,10 +192,10 @@ public class NBEvent {
|
||||
|
||||
}
|
||||
|
||||
public Class<? extends NBMessage> getMessageDtoClass() {
|
||||
public Class<? extends NBMessageDTO> getMessageDtoClass() {
|
||||
switch (getSource()) {
|
||||
case OPENAIRE_SOURCE:
|
||||
return OpenaireMessage.class;
|
||||
return OpenaireMessageDTO.class;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown event's source: " + getSource());
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessage;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessage;
|
||||
import org.dspace.app.nbevent.service.dto.NBMessageDTO;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessageDTO;
|
||||
import org.dspace.app.rest.model.NBEventMessageRest;
|
||||
import org.dspace.app.rest.model.NBEventRest;
|
||||
import org.dspace.app.rest.model.OpenaireNBEventMessageRest;
|
||||
@@ -61,9 +61,9 @@ public class NBEventConverter implements DSpaceConverter<NBEvent, NBEventRest> {
|
||||
return rest;
|
||||
}
|
||||
|
||||
private NBEventMessageRest convertMessage(NBMessage dto) {
|
||||
if (dto instanceof OpenaireMessage) {
|
||||
OpenaireMessage openaireDto = (OpenaireMessage) dto;
|
||||
private NBEventMessageRest convertMessage(NBMessageDTO dto) {
|
||||
if (dto instanceof OpenaireMessageDTO) {
|
||||
OpenaireMessageDTO openaireDto = (OpenaireMessageDTO) dto;
|
||||
OpenaireNBEventMessageRest message = new OpenaireNBEventMessageRest();
|
||||
message.setAbstractValue(openaireDto.getAbstracts());
|
||||
message.setOpenaireId(openaireDto.getOpenaireId());
|
||||
|
@@ -18,7 +18,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessage;
|
||||
import org.dspace.app.nbevent.service.dto.OpenaireMessageDTO;
|
||||
import org.dspace.content.NBEvent;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
@@ -56,7 +56,7 @@ public class NBEventMatcher {
|
||||
hasJsonPath("$.status", Matchers.equalToIgnoringCase(event.getStatus())),
|
||||
hasJsonPath("$.message",
|
||||
matchMessage(event.getTopic(), jsonMapper.readValue(event.getMessage(),
|
||||
OpenaireMessage.class))),
|
||||
OpenaireMessageDTO.class))),
|
||||
hasJsonPath("$._links.target.href", Matchers.endsWith(event.getEventId() + "/target")),
|
||||
hasJsonPath("$._links.related.href", Matchers.endsWith(event.getEventId() + "/related")),
|
||||
hasJsonPath("$._links.topic.href", Matchers.endsWith(event.getEventId() + "/topic")),
|
||||
@@ -66,7 +66,7 @@ public class NBEventMatcher {
|
||||
}
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchMessage(String topic, OpenaireMessage message) {
|
||||
private static Matcher<? super Object> matchMessage(String topic, OpenaireMessageDTO message) {
|
||||
if (StringUtils.endsWith(topic, "/ABSTRACT")) {
|
||||
return allOf(hasJsonPath("$.abstract", is(message.getAbstracts())));
|
||||
} else if (StringUtils.endsWith(topic, "/PID")) {
|
||||
|
@@ -5,8 +5,8 @@
|
||||
#---------------------------------------------------------------#
|
||||
oaire-nbevents.solr.server = ${solr.server}/${solr.multicorePrefix}nbevent
|
||||
# A POST to these url(s) will be done to notify oaire of decision taken for each nbevents
|
||||
oaire-nbevents.acknowledge-url = https://beta.api-broker.openaire.eu/feedback/events
|
||||
#oaire-nbevents.acknowledge-url =
|
||||
openaire-nbevents.acknowledge-url = https://beta.api-broker.openaire.eu/feedback/events
|
||||
#openaire-nbevents.acknowledge-url =
|
||||
oaire-nbevents.import.topic = ENRICH/MISSING/ABSTRACT
|
||||
oaire-nbevents.import.topic = ENRICH/MISSING/PID
|
||||
oaire-nbevents.import.topic = ENRICH/MORE/PID
|
||||
|
@@ -29,7 +29,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="ProjectLinkedEntityAction" class="org.dspace.app.nbevent.NBEntityMetadataAction">
|
||||
<bean id="ProjectLinkedEntityAction" class="org.dspace.app.nbevent.NBEntityOpenaireMetadataAction">
|
||||
<!-- which metadata will hold the relation between the publication and the project -->
|
||||
<property name="relation" value="isPublicationOfProject" />
|
||||
<!-- the type of local entity used to store the project details -->
|
||||
@@ -47,10 +47,10 @@
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="AbstractMetadataAction" class="org.dspace.app.nbevent.NBSimpleMetadataAction">
|
||||
<bean id="AbstractMetadataAction" class="org.dspace.app.nbevent.NBOpenaireSimpleMetadataAction">
|
||||
<property name="metadata" value="dc.description.abstract" />
|
||||
</bean>
|
||||
<bean id="PIDMetadataAction" class="org.dspace.app.nbevent.NBMetadataMapAction">
|
||||
<bean id="PIDMetadataAction" class="org.dspace.app.nbevent.NBOpenaireMetadataMapAction">
|
||||
<property name="types">
|
||||
<map>
|
||||
<!--The key are the type of identifier (or subject) reported in the message, the value is the metadata in
|
||||
|
Reference in New Issue
Block a user