Skip to content

Commit

Permalink
DSC-1526 We now have a check for which if the workspace item is a cor…
Browse files Browse the repository at this point in the history
…rection request we check if it is submission correction or a simple submission
  • Loading branch information
Mattia Vianelli committed Feb 6, 2024
1 parent dc3e81c commit 20c67d4
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
import org.dspace.core.Context;
import org.dspace.discovery.SearchServiceException;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.services.RequestService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.versioning.ItemCorrectionService;
import org.dspace.web.ContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -58,6 +62,13 @@
*/

public class SubmissionConfigReader {

@Autowired
private ItemCorrectionService itemCorrectionService;

@Autowired
RequestService requestService;

/**
* The ID of the default collection. Will never be the ID of a named
* collection
Expand Down Expand Up @@ -430,6 +441,21 @@ private void doNodes(Node n) throws SAXException, SearchServiceException, Submis
}
}


private boolean isCorrectionItem(Item item) {
Context context = ContextUtil.obtainCurrentRequestContext();
ItemCorrectionService itemCorrectionService =
DSpaceServicesFactory.getInstance().getServiceManager()
.getServicesByType(ItemCorrectionService.class)
.get(0);
try {
return itemCorrectionService.checkIfIsCorrectionItem(context, item);
} catch (Exception ex) {
log.error("An error occurs checking if the given item is a correction item.", ex);
return false;
}
}

/**
* Process the submission-map section of the XML file. Each element looks
* like: <name-map collection-handle="hdl" submission-name="name" /> Extract
Expand Down Expand Up @@ -764,6 +790,13 @@ public SubmissionConfig getSubmissionConfigByInProgressSubmission(InProgressSubm
return getSubmissionConfigByName(submissionDefinition);
}

return getSubmissionConfigByCollection(object.getCollection());
if (isCorrectionItem(object.getItem())) {
return getCorrectionSubmissionConfigByCollection(object.getCollection());
} else {
return getSubmissionConfigByCollection(object.getCollection());
}

}


}

0 comments on commit 20c67d4

Please sign in to comment.