mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 21:43:11 +00:00
[CST-14901][DSC-1357][#8662] Handles versioning for ORCID publications.
feat: - ORCID publications waiting to be published are removed whenever a new version is created - ORCID publications already published will be updated with the ref to the last item version - ORCID consumer will process only latest item versions, ignoring all the other ones
This commit is contained in:
@@ -81,6 +81,9 @@ import org.dspace.orcid.service.OrcidTokenService;
|
||||
import org.dspace.profile.service.ResearcherProfileService;
|
||||
import org.dspace.qaevent.dao.QAEventsDAO;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.versioning.Version;
|
||||
import org.dspace.versioning.VersionHistory;
|
||||
import org.dspace.versioning.service.VersionHistoryService;
|
||||
import org.dspace.versioning.service.VersioningService;
|
||||
import org.dspace.workflow.WorkflowItemService;
|
||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
@@ -176,6 +179,9 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
@Autowired
|
||||
private QAEventsDAO qaEventsDao;
|
||||
|
||||
@Autowired
|
||||
private VersionHistoryService versionHistoryService;
|
||||
|
||||
protected ItemServiceImpl() {
|
||||
}
|
||||
|
||||
@@ -1931,4 +1937,40 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLatestVersion(Context context, Item item) throws SQLException {
|
||||
|
||||
VersionHistory history = versionHistoryService.findByItem(context, item);
|
||||
if (history == null) {
|
||||
// not all items have a version history
|
||||
// if an item does not have a version history, it is by definition the latest
|
||||
// version
|
||||
return true;
|
||||
}
|
||||
|
||||
// start with the very latest version of the given item (may still be in
|
||||
// workspace)
|
||||
Version latestVersion = versionHistoryService.getLatestVersion(context, history);
|
||||
|
||||
// find the latest version of the given item that is archived
|
||||
while (latestVersion != null && !latestVersion.getItem().isArchived()) {
|
||||
latestVersion = versionHistoryService.getPrevious(context, history, latestVersion);
|
||||
}
|
||||
|
||||
// could not find an archived version of the given item
|
||||
if (latestVersion == null) {
|
||||
// this scenario should never happen, but let's err on the side of showing too
|
||||
// many items vs. to little
|
||||
// (see discovery.xml, a lot of discovery configs filter out all items that are
|
||||
// not the latest version)
|
||||
return true;
|
||||
}
|
||||
|
||||
// sanity check
|
||||
assert latestVersion.getItem().isArchived();
|
||||
|
||||
return item.equals(latestVersion.getItem());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user