mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #9554 from DSpace/backport-9551-to-dspace-7_x
[Port dspace-7_x] Ensure Process `user_id` is nullified when referenced EPerson is deleted
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
--
|
||||
-- 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/
|
||||
--
|
||||
|
||||
-- If Process references an EPerson that no longer exists, set the "user_id" to null.
|
||||
UPDATE process SET user_id = null WHERE NOT EXISTS (SELECT * FROM EPerson where uuid = process.user_id);
|
||||
|
||||
-- Add new constraint where process.user_id is nullified if referenced EPerson is deleted.
|
||||
ALTER TABLE process ADD CONSTRAINT process_eperson FOREIGN KEY (user_id) REFERENCES EPerson(uuid) ON DELETE SET NULL;
|
@@ -0,0 +1,13 @@
|
||||
--
|
||||
-- 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/
|
||||
--
|
||||
|
||||
-- If Process references an EPerson that no longer exists, set the "user_id" to null.
|
||||
UPDATE process SET user_id = null WHERE NOT EXISTS (SELECT * FROM EPerson where uuid = process.user_id);
|
||||
|
||||
-- Add new constraint where process.user_id is nullified if referenced EPerson is deleted.
|
||||
ALTER TABLE process ADD CONSTRAINT process_eperson FOREIGN KEY (user_id) REFERENCES EPerson(uuid) ON DELETE SET NULL;
|
@@ -14,7 +14,6 @@ import org.dspace.app.rest.model.ProcessRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.scripts.Process;
|
||||
import org.dspace.scripts.service.ProcessService;
|
||||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -40,10 +39,8 @@ public class ProcessConverter implements DSpaceConverter<Process, ProcessRest> {
|
||||
processRest.setId(process.getID());
|
||||
processRest.setScriptName(process.getName());
|
||||
processRest.setProcessId(process.getID());
|
||||
try {
|
||||
if (process.getEPerson() != null) {
|
||||
processRest.setUserId(process.getEPerson().getID());
|
||||
} catch (ObjectNotFoundException e ) {
|
||||
processRest.setUserId(null);
|
||||
}
|
||||
processRest.setProcessStatus(process.getProcessStatus());
|
||||
processRest.setStartTime(process.getStartTime());
|
||||
|
Reference in New Issue
Block a user