mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 03:53:07 +00:00
CST-12850 Announce Relationship first implementation w/o tests
This commit is contained in:
@@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.ldn.action;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.github.jsonldjava.utils.JsonUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.app.ldn.NotifyServiceEntity;
|
||||||
|
import org.dspace.app.ldn.model.Notification;
|
||||||
|
import org.dspace.app.ldn.service.LDNMessageService;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.QAEvent;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.handle.service.HandleService;
|
||||||
|
import org.dspace.qaevent.service.QAEventService;
|
||||||
|
import org.dspace.qaevent.service.dto.NotifyMessageDTO;
|
||||||
|
import org.dspace.services.ConfigurationService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation for LDN Correction Action. It creates a QA Event according to the LDN Message received *
|
||||||
|
* @author Francesco Bacchelli (francesco.bacchelli at 4science.it)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LDNRelationCorrectionAction implements LDNAction {
|
||||||
|
|
||||||
|
private static final Logger log = LogManager.getLogger(LDNEmailAction.class);
|
||||||
|
|
||||||
|
private String qaEventTopic;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfigurationService configurationService;
|
||||||
|
@Autowired
|
||||||
|
protected ItemService itemService;
|
||||||
|
@Autowired
|
||||||
|
private QAEventService qaEventService;
|
||||||
|
@Autowired
|
||||||
|
private LDNMessageService ldnMessageService;
|
||||||
|
@Autowired
|
||||||
|
private HandleService handleService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionStatus execute(Context context, Notification notification, Item item) throws Exception {
|
||||||
|
ActionStatus result = ActionStatus.ABORT;
|
||||||
|
String itemName = itemService.getName(item);
|
||||||
|
QAEvent qaEvent = null;
|
||||||
|
if (notification.getObject() != null) {
|
||||||
|
NotifyMessageDTO message = new NotifyMessageDTO();
|
||||||
|
/*relationFormat.replace("[0]", notification.getObject().getAsRelationship());
|
||||||
|
hrefValue = hrefValue.replace("[1]", notification.getObject().getAsSubject());*/
|
||||||
|
message.setHref(notification.getObject().getAsSubject());
|
||||||
|
message.setRelationship(notification.getObject().getAsRelationship());
|
||||||
|
if (notification.getOrigin() != null) {
|
||||||
|
message.setServiceId(notification.getOrigin().getId());
|
||||||
|
message.setServiceName(notification.getOrigin().getInbox());
|
||||||
|
}
|
||||||
|
BigDecimal score = getScore(context, notification);
|
||||||
|
double doubleScoreValue = score != null ? score.doubleValue() : 0d;
|
||||||
|
qaEvent = new QAEvent(QAEvent.COAR_NOTIFY_SOURCE,
|
||||||
|
handleService.findHandle(context, item), item.getID().toString(), itemName,
|
||||||
|
this.getQaEventTopic(), doubleScoreValue,
|
||||||
|
JsonUtils.toString(message)
|
||||||
|
, new Date());
|
||||||
|
qaEventService.store(context, qaEvent);
|
||||||
|
result = ActionStatus.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal getScore(Context context, Notification notification) throws SQLException {
|
||||||
|
|
||||||
|
if (notification.getOrigin() == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotifyServiceEntity service = ldnMessageService.findNotifyService(context, notification.getOrigin());
|
||||||
|
|
||||||
|
if (service == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return service.getScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQaEventTopic() {
|
||||||
|
return qaEventTopic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQaEventTopic(String qaEventTopic) {
|
||||||
|
this.qaEventTopic = qaEventTopic;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -21,6 +21,7 @@ public class QANotifyPatterns {
|
|||||||
public static final String TOPIC_ENRICH_MORE_ENDORSEMENT = "ENRICH/MORE/ENDORSEMENT";
|
public static final String TOPIC_ENRICH_MORE_ENDORSEMENT = "ENRICH/MORE/ENDORSEMENT";
|
||||||
public static final String TOPIC_ENRICH_MORE_PID = "ENRICH/MORE/PID";
|
public static final String TOPIC_ENRICH_MORE_PID = "ENRICH/MORE/PID";
|
||||||
public static final String TOPIC_ENRICH_MISSING_PID = "ENRICH/MISSING/PID";
|
public static final String TOPIC_ENRICH_MISSING_PID = "ENRICH/MISSING/PID";
|
||||||
|
public static final String TOPIC_ENRICH_MORE_LINK = "ENRICH/MORE/LINK";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
|
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.qaevent.action;
|
||||||
|
|
||||||
|
import org.dspace.qaevent.QualityAssuranceAction;
|
||||||
|
import org.dspace.qaevent.service.dto.NotifyMessageDTO;
|
||||||
|
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of {@link QualityAssuranceAction} that add a simple metadata to the given
|
||||||
|
* item.
|
||||||
|
*
|
||||||
|
* @author Francesco Bacchelli (francesco.bacchelli at 4science.it)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class QANotifyFormattedMetadataAction extends ASimpleMetadataAction {
|
||||||
|
|
||||||
|
private String format;
|
||||||
|
|
||||||
|
public String extractMetadataValue(QAMessageDTO message) {
|
||||||
|
NotifyMessageDTO mDTO = (NotifyMessageDTO) message;
|
||||||
|
String result = format.replace("[0]", mDTO.getRelationship());
|
||||||
|
result = result.replace("[1]", mDTO.getHref());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFormat() {
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFormat(String format) {
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -259,7 +259,7 @@
|
|||||||
<property name="actionSendFilter" value="${ldn.notification.email}" />
|
<property name="actionSendFilter" value="${ldn.notification.email}" />
|
||||||
<property name="actionSendEmailTextFile" value="coar_notify_relationship" />
|
<property name="actionSendEmailTextFile" value="coar_notify_relationship" />
|
||||||
</bean>
|
</bean>
|
||||||
<bean class="org.dspace.app.ldn.action.LDNCorrectionAction">
|
<bean class="org.dspace.app.ldn.action.LDNRelationCorrectionAction">
|
||||||
<property name="qaEventTopic" value="ENRICH/MORE/LINK"/>
|
<property name="qaEventTopic" value="ENRICH/MORE/LINK"/>
|
||||||
</bean>
|
</bean>
|
||||||
</list>
|
</list>
|
||||||
|
@@ -44,6 +44,9 @@
|
|||||||
<entry value-ref="PIDMetadataAction">
|
<entry value-ref="PIDMetadataAction">
|
||||||
<key><util:constant static-field="org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MISSING_PID"/></key>
|
<key><util:constant static-field="org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MISSING_PID"/></key>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry value-ref="AddLinkMetadataAction">
|
||||||
|
<key><util:constant static-field="org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MORE_LINK"/></key>
|
||||||
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
@@ -74,6 +77,10 @@
|
|||||||
<bean id="AddReviewMetadataAction" class="org.dspace.qaevent.action.QANotifySimpleMetadataAction">
|
<bean id="AddReviewMetadataAction" class="org.dspace.qaevent.action.QANotifySimpleMetadataAction">
|
||||||
<property name="metadata" value="datacite.relation.isReviewedBy" />
|
<property name="metadata" value="datacite.relation.isReviewedBy" />
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="AddLinkMetadataAction" class="org.dspace.qaevent.action.QANotifyFormatMetadataAction">
|
||||||
|
<property name="metadata" value="datacite.relation.isSupplementedBy" />
|
||||||
|
<property name="format" value="Relation type: [0] - Subject: [1]" />
|
||||||
|
</bean>
|
||||||
<bean id="AddEndorsedMetadataAction" class="org.dspace.qaevent.action.QANotifySimpleMetadataAction">
|
<bean id="AddEndorsedMetadataAction" class="org.dspace.qaevent.action.QANotifySimpleMetadataAction">
|
||||||
<property name="metadata" value="notify.relation.endorsedBy"/>
|
<property name="metadata" value="notify.relation.endorsedBy"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
Reference in New Issue
Block a user