72387: Workflow minor fixes

This commit is contained in:
Marie Verdonck
2020-08-06 10:12:28 +02:00
parent 2027b03a8d
commit 4e48ff8de1
8 changed files with 16 additions and 20 deletions

View File

@@ -57,7 +57,6 @@ import org.dspace.harvest.HarvestedCollection;
import org.dspace.harvest.service.HarvestedCollectionService; import org.dspace.harvest.service.HarvestedCollectionService;
import org.dspace.workflow.factory.WorkflowServiceFactory; import org.dspace.workflow.factory.WorkflowServiceFactory;
import org.dspace.xmlworkflow.WorkflowConfigurationException; import org.dspace.xmlworkflow.WorkflowConfigurationException;
import org.dspace.xmlworkflow.XmlWorkflowFactoryImpl;
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory; import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
import org.dspace.xmlworkflow.state.Workflow; import org.dspace.xmlworkflow.state.Workflow;
import org.dspace.xmlworkflow.storedcomponents.CollectionRole; import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
@@ -387,7 +386,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
log.error(LogManager.getHeader(context, "setWorkflowGroup", log.error(LogManager.getHeader(context, "setWorkflowGroup",
"collection_id=" + collection.getID() + " " + e.getMessage()), e); "collection_id=" + collection.getID() + " " + e.getMessage()), e);
} }
if (!StringUtils.equals(XmlWorkflowFactoryImpl.LEGACY_WORKFLOW_NAME, workflow.getID())) { if (!StringUtils.equals(workflowFactory.getDefaultWorkflow().getID(), workflow.getID())) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"setWorkflowGroup can be used only on collection with the default basic dspace workflow. " "setWorkflowGroup can be used only on collection with the default basic dspace workflow. "
+ "Instead, the collection: " + "Instead, the collection: "

View File

@@ -265,7 +265,12 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
// Need to delete the workspaceitem row first since it refers // Need to delete the workspaceitem row first since it refers
// to item ID // to item ID
workspaceItem.getSupervisorGroups().clear(); try {
workspaceItem.getSupervisorGroups().clear();
} catch (Exception e) {
log.error("failed to clear supervisor group", e);
}
workspaceItemDAO.delete(context, workspaceItem); workspaceItemDAO.delete(context, workspaceItem);
} }

View File

@@ -97,7 +97,7 @@ public class XmlWorkflowFactoryImpl implements XmlWorkflowFactory {
} }
@Override @Override
public List<Collection> getCollectionHandlesMappedToWorklow(Context context, String workflowName) { public List<Collection> getCollectionHandlesMappedToWorkflow(Context context, String workflowName) {
List<Collection> collectionsMapped = new ArrayList<>(); List<Collection> collectionsMapped = new ArrayList<>();
for (String handle : this.workflowMapping.keySet()) { for (String handle : this.workflowMapping.keySet()) {
if (this.workflowMapping.get(handle).getID().equals(workflowName)) { if (this.workflowMapping.get(handle).getID().equals(workflowName)) {
@@ -107,7 +107,7 @@ public class XmlWorkflowFactoryImpl implements XmlWorkflowFactory {
collectionsMapped.add(collection); collectionsMapped.add(collection);
} }
} catch (SQLException e) { } catch (SQLException e) {
log.error("SQLException in XmlWorkflowFactoryImpl.getCollectionHandlesMappedToWorklow trying to " + log.error("SQLException in XmlWorkflowFactoryImpl.getCollectionHandlesMappedToWorkflow trying to " +
"retrieve collection with handle: " + handle, e); "retrieve collection with handle: " + handle, e);
} }
} }

View File

@@ -86,7 +86,7 @@ public interface XmlWorkflowFactory {
* @param workflowName Name of workflow we want the collections of that are mapped to is * @param workflowName Name of workflow we want the collections of that are mapped to is
* @return List of collections mapped to the requested workflow * @return List of collections mapped to the requested workflow
*/ */
public List<Collection> getCollectionHandlesMappedToWorklow(Context context, String workflowName); public List<Collection> getCollectionHandlesMappedToWorkflow(Context context, String workflowName);
/** /**
* Returns list of collections that are not mapped to any configured workflow, and thus use the default workflow * Returns list of collections that are not mapped to any configured workflow, and thus use the default workflow

View File

@@ -81,7 +81,7 @@ public class Step implements BeanNameAware {
/** /**
* Get the next step based on out the outcome * Get the next step based on out the outcome
* @param outcome the outcome of the previous step * @param outcome the outcome of the previous step
* @return the next stepp or NULL if there is no step configured for this outcome * @return the next step or NULL if there is no step configured for this outcome
*/ */
public Step getNextStep(int outcome) { public Step getNextStep(int outcome) {
return outcomes.get(outcome); return outcomes.get(outcome);

View File

@@ -116,12 +116,12 @@ public class XmlWorkflowFactoryTest extends AbstractUnitTest {
@Test @Test
public void workflowMapping_NonMappedCollection() throws WorkflowConfigurationException { public void workflowMapping_NonMappedCollection() throws WorkflowConfigurationException {
Workflow workflow = xmlWorkflowFactory.getWorkflow(this.nonMappedCollection); Workflow workflow = xmlWorkflowFactory.getWorkflow(this.nonMappedCollection);
assertEquals("defaultWorkflow", workflow.getID()); assertEquals(XmlWorkflowFactoryImpl.LEGACY_WORKFLOW_NAME, workflow.getID());
} }
@Test @Test
public void workflowMapping_MappedCollection() throws WorkflowConfigurationException { public void workflowMapping_MappedCollection() throws WorkflowConfigurationException {
Workflow workflow = xmlWorkflowFactory.getWorkflow(this.mappedCollection); Workflow workflow = xmlWorkflowFactory.getWorkflow(this.mappedCollection);
assertEquals("selectSingleReviewer", workflow.getID()); assertEquals( "selectSingleReviewer", workflow.getID());
} }
} }

View File

@@ -12,13 +12,11 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.dspace.app.rest.converter.ConverterService;
import org.dspace.app.rest.model.CollectionRest; import org.dspace.app.rest.model.CollectionRest;
import org.dspace.app.rest.model.WorkflowDefinitionRest; import org.dspace.app.rest.model.WorkflowDefinitionRest;
import org.dspace.app.rest.projection.Projection; import org.dspace.app.rest.projection.Projection;
import org.dspace.app.rest.repository.AbstractDSpaceRestRepository; import org.dspace.app.rest.repository.AbstractDSpaceRestRepository;
import org.dspace.app.rest.repository.LinkRestRepository; import org.dspace.app.rest.repository.LinkRestRepository;
import org.dspace.app.rest.utils.Utils;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory; import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
@@ -43,12 +41,6 @@ public class WorkflowDefinitionCollectionsLinkRepository extends AbstractDSpaceR
@Autowired @Autowired
protected XmlWorkflowFactory xmlWorkflowFactory; protected XmlWorkflowFactory xmlWorkflowFactory;
@Autowired
protected ConverterService converter;
@Autowired
protected Utils utils;
/** /**
* GET endpoint that returns the list of collections that make an explicit use of the workflow-definition. * GET endpoint that returns the list of collections that make an explicit use of the workflow-definition.
* If a collection doesn't specify the workflow-definition to be used, the default mapping applies, * If a collection doesn't specify the workflow-definition to be used, the default mapping applies,
@@ -69,10 +61,10 @@ public class WorkflowDefinitionCollectionsLinkRepository extends AbstractDSpaceR
if (xmlWorkflowFactory.isDefaultWorkflow(workflowName)) { if (xmlWorkflowFactory.isDefaultWorkflow(workflowName)) {
collectionsMappedToWorkflow.addAll(xmlWorkflowFactory.getAllNonMappedCollectionsHandles(context)); collectionsMappedToWorkflow.addAll(xmlWorkflowFactory.getAllNonMappedCollectionsHandles(context));
} }
collectionsMappedToWorkflow.addAll(xmlWorkflowFactory.getCollectionHandlesMappedToWorklow(context, collectionsMappedToWorkflow.addAll(xmlWorkflowFactory.getCollectionHandlesMappedToWorkflow(context,
workflowName)); workflowName));
Pageable pageable = optionalPageable != null ? optionalPageable : PageRequest.of(0, 20); Pageable pageable = optionalPageable != null ? optionalPageable : PageRequest.of(0, 20);
return converter.toRestPage(collectionsMappedToWorkflow, pageable, return super.converter.toRestPage(collectionsMappedToWorkflow, pageable,
projection); projection);
} else { } else {
throw new ResourceNotFoundException("No workflow with name " + workflowName + " is configured"); throw new ResourceNotFoundException("No workflow with name " + workflowName + " is configured");

View File

@@ -349,7 +349,7 @@ public class WorkflowDefinitionRestRepositoryIT extends AbstractControllerIntegr
if (StringUtils.isNotBlank(firstNonDefaultWorkflowName)) { if (StringUtils.isNotBlank(firstNonDefaultWorkflowName)) {
List<Collection> mappedCollections List<Collection> mappedCollections
= xmlWorkflowFactory.getCollectionHandlesMappedToWorklow(context, firstNonDefaultWorkflowName); = xmlWorkflowFactory.getCollectionHandlesMappedToWorkflow(context, firstNonDefaultWorkflowName);
//When we call this facets endpoint //When we call this facets endpoint
if (mappedCollections.size() > 0) { if (mappedCollections.size() > 0) {
//returns array of collection jsons that are mapped to given workflow //returns array of collection jsons that are mapped to given workflow