mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
DS-3851 community feedback: code cleanup
This commit is contained in:
@@ -462,13 +462,6 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
|
|||||||
return bitstreamDAO.getNotReferencedBitstreams(context);
|
return bitstreamDAO.getNotReferencedBitstreams(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addMetadata(Context context, Bitstream dso, MetadataField metadataField, String lang,
|
|
||||||
List<String> values, List<String> authorities, List<Integer> confidences)
|
|
||||||
throws SQLException {
|
|
||||||
addMetadata(context, dso, metadataField, lang, values, authorities, confidences, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getLastModified(Bitstream bitstream) {
|
public Long getLastModified(Bitstream bitstream) {
|
||||||
return bitstreamStorageService.getLastModified(bitstream);
|
return bitstreamStorageService.getLastModified(bitstream);
|
||||||
}
|
}
|
||||||
|
@@ -372,7 +372,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("default", workflow.getID())) {
|
if (!StringUtils.equals(XmlWorkflowFactory.LEGACY_WORKFLOW_NAME, 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: "
|
||||||
|
@@ -231,7 +231,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
||||||
List<String> authorities, List<Integer> confidences, List<Integer> places)
|
List<String> authorities, List<Integer> confidences)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
||||||
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
||||||
@@ -703,15 +703,4 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
|
||||||
List<String> authorities, List<Integer> confidences) throws SQLException {
|
|
||||||
addMetadata(context, dso, metadataField, lang, values, authorities, confidences, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
|
||||||
String authority, int confidence, int place) throws SQLException {
|
|
||||||
addMetadata(context, dso, metadataField, language, value, authority, confidence);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@ package org.dspace.content;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
|
||||||
@@ -29,11 +28,6 @@ public interface InProgressSubmission<ID extends Serializable> extends Browsable
|
|||||||
*/
|
*/
|
||||||
ID getID();
|
ID getID();
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the submission, including the unarchived item.
|
|
||||||
*/
|
|
||||||
void update() throws SQLException, AuthorizeException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the incomplete item object
|
* Get the incomplete item object
|
||||||
*
|
*
|
||||||
|
@@ -27,9 +27,7 @@ import javax.persistence.SequenceGenerator;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
@@ -245,20 +243,6 @@ public class WorkspaceItem
|
|||||||
supervisorGroups.add(group);
|
supervisorGroups.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() throws SQLException, AuthorizeException {
|
|
||||||
|
|
||||||
Context context = null;
|
|
||||||
try {
|
|
||||||
context = new Context();
|
|
||||||
ContentServiceFactory.getInstance().getWorkspaceItemService().update(context, this);
|
|
||||||
} finally {
|
|
||||||
if (context != null && context.isValid()) {
|
|
||||||
context.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return Constants.WORKSPACEITEM;
|
return Constants.WORKSPACEITEM;
|
||||||
|
@@ -239,26 +239,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableOb
|
|||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
||||||
List<String> authorities, List<Integer> confidences) throws SQLException;
|
List<String> authorities, List<Integer> confidences) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Add metadata fields. These are appended to existing values.
|
|
||||||
* Use <code>clearDC</code> to remove values. The values are insert in the
|
|
||||||
* positions passed in the places argument.
|
|
||||||
*
|
|
||||||
* @param context DSpace context
|
|
||||||
* @param dso DSpaceObject
|
|
||||||
* @param metadataField the metadata field to which the value is to be set
|
|
||||||
* @param lang the ISO639 language code, optionally followed by an underscore
|
|
||||||
* and the ISO3166 country code. <code>null</code> means the
|
|
||||||
* value has no language (for example, a date).
|
|
||||||
* @param values the values to add.
|
|
||||||
* @param authorities the external authority key for this value (or null)
|
|
||||||
* @param confidences the authority confidence (default 0)
|
|
||||||
* @param places the places to use for the supplied values
|
|
||||||
* @throws SQLException if database error
|
|
||||||
*/
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List<String> values,
|
|
||||||
List<String> authorities, List<Integer> confidences, List<Integer> places) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut for {@link #addMetadata(Context, DSpaceObject, MetadataField, String, List, List, List)} when a single
|
* Shortcut for {@link #addMetadata(Context, DSpaceObject, MetadataField, String, List, List, List)} when a single
|
||||||
* value need to be added
|
* value need to be added
|
||||||
@@ -275,23 +255,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableOb
|
|||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
||||||
String authority, int confidence) throws SQLException;
|
String authority, int confidence) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Shortcut for {@link #addMetadata(Context, DSpaceObject, MetadataField, String, List, List, List, List)} when a
|
|
||||||
* single value need to be added
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param dso
|
|
||||||
* @param metadataField
|
|
||||||
* @param language
|
|
||||||
* @param value
|
|
||||||
* @param authority
|
|
||||||
* @param confidence
|
|
||||||
* @param place
|
|
||||||
* @throws SQLException
|
|
||||||
*/
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value,
|
|
||||||
String authority, int confidence, int place) throws SQLException;
|
|
||||||
|
|
||||||
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value)
|
public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
|
@@ -21,14 +21,12 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing an item going through the workflow process in DSpace
|
* Class representing an item going through the workflow process in DSpace
|
||||||
@@ -188,20 +186,6 @@ public class BasicWorkflowItem implements WorkflowItem {
|
|||||||
this.publishedBefore = b;
|
this.publishedBefore = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() throws SQLException, AuthorizeException {
|
|
||||||
|
|
||||||
Context context = null;
|
|
||||||
try {
|
|
||||||
context = new Context();
|
|
||||||
WorkflowServiceFactory.getInstance().getWorkflowItemService().update(context, this);
|
|
||||||
} finally {
|
|
||||||
if (context != null && context.isValid()) {
|
|
||||||
context.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return Constants.WORKFLOWITEM;
|
return Constants.WORKFLOWITEM;
|
||||||
|
@@ -668,6 +668,8 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
removeUserItemPolicies(c, wi.getItem(), task.getOwner());
|
removeUserItemPolicies(c, wi.getItem(), task.getOwner());
|
||||||
claimedTaskService.delete(c, task);
|
claimedTaskService.delete(c, task);
|
||||||
}
|
}
|
||||||
|
c.addEvent(new Event(Event.MODIFY, Constants.ITEM, wi.getItem().getID(), null,
|
||||||
|
itemService.getIdentifiers(c, wi.getItem())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1058,17 +1060,10 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void revokeReviewerPolicies(Context context, Item item) throws SQLException, AuthorizeException {
|
protected void revokeReviewerPolicies(Context context, Item item) throws SQLException, AuthorizeException {
|
||||||
// get bundle "ORIGINAL"
|
List<Bundle> bundles = item.getBundles();
|
||||||
Bundle originalBundle;
|
|
||||||
try {
|
|
||||||
originalBundle = itemService.getBundles(item, "ORIGINAL").get(0);
|
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
|
||||||
originalBundle = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove bitstream and bundle level policies
|
for (Bundle originalBundle : bundles) {
|
||||||
if (originalBundle != null) {
|
// remove bitstream and bundle level policies
|
||||||
// We added policies for Bitstreams of the bundle "original" only
|
|
||||||
for (Bitstream bitstream : originalBundle.getBitstreams()) {
|
for (Bitstream bitstream : originalBundle.getBitstreams()) {
|
||||||
authorizeService.removeAllPoliciesByDSOAndType(context, bitstream, ResourcePolicy.TYPE_WORKFLOW);
|
authorizeService.removeAllPoliciesByDSOAndType(context, bitstream, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,8 @@ import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
|||||||
*/
|
*/
|
||||||
public interface XmlWorkflowFactory {
|
public interface XmlWorkflowFactory {
|
||||||
|
|
||||||
|
public final String LEGACY_WORKFLOW_NAME = "default";
|
||||||
|
|
||||||
public Workflow getWorkflow(Collection collection) throws IOException, WorkflowConfigurationException, SQLException;
|
public Workflow getWorkflow(Collection collection) throws IOException, WorkflowConfigurationException, SQLException;
|
||||||
|
|
||||||
public Step createStep(Workflow workflow, String stepID) throws WorkflowConfigurationException, IOException;
|
public Step createStep(Workflow workflow, String stepID) throws WorkflowConfigurationException, IOException;
|
||||||
|
@@ -7,9 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.storedcomponents;
|
package org.dspace.xmlworkflow.storedcomponents;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -20,7 +17,6 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Transient;
|
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -40,9 +36,6 @@ import org.dspace.eperson.EPerson;
|
|||||||
@Table(name = "cwf_claimtask")
|
@Table(name = "cwf_claimtask")
|
||||||
public class ClaimedTask implements ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
public class ClaimedTask implements ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
||||||
|
|
||||||
@Transient
|
|
||||||
public transient Map<String, Object> extraInfo = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "claimtask_id")
|
@Column(name = "claimtask_id")
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cwf_claimtask_seq")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cwf_claimtask_seq")
|
||||||
|
@@ -7,9 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.storedcomponents;
|
package org.dspace.xmlworkflow.storedcomponents;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -21,7 +18,6 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Transient;
|
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -42,9 +38,6 @@ import org.dspace.eperson.Group;
|
|||||||
@Table(name = "cwf_pooltask")
|
@Table(name = "cwf_pooltask")
|
||||||
public class PoolTask implements ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
public class PoolTask implements ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
||||||
|
|
||||||
@Transient
|
|
||||||
public transient Map<String, Object> extraInfo = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "pooltask_id")
|
@Column(name = "pooltask_id")
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cwf_pooltask_seq")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cwf_pooltask_seq")
|
||||||
|
@@ -21,7 +21,6 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -30,7 +29,6 @@ import org.dspace.core.Context;
|
|||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing an item going through the workflow process in DSpace
|
* Class representing an item going through the workflow process in DSpace
|
||||||
@@ -139,20 +137,6 @@ public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>,
|
|||||||
this.publishedBefore = b;
|
this.publishedBefore = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() throws SQLException, AuthorizeException {
|
|
||||||
|
|
||||||
Context context = null;
|
|
||||||
try {
|
|
||||||
context = new Context();
|
|
||||||
WorkflowServiceFactory.getInstance().getWorkflowItemService().update(context, this);
|
|
||||||
} finally {
|
|
||||||
if (context != null && context.isValid()) {
|
|
||||||
context.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getState() {
|
public int getState() {
|
||||||
// FIXME not used by the xml workflow, should be removed when the basic workflow is removed and the interfaces
|
// FIXME not used by the xml workflow, should be removed when the basic workflow is removed and the interfaces
|
||||||
|
@@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* 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.rest.converter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.app.rest.model.AInprogressSubmissionRest;
|
||||||
|
import org.dspace.app.rest.model.ErrorRest;
|
||||||
|
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||||
|
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||||
|
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||||
|
import org.dspace.app.rest.submit.SubmissionService;
|
||||||
|
import org.dspace.app.util.SubmissionConfigReader;
|
||||||
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
|
import org.dspace.app.util.SubmissionStepConfig;
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract implementation providing the common functionalities for all the inprogressSubmission Converter
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* the DSpace API inprogressSubmission object
|
||||||
|
* @param <R>
|
||||||
|
* the DSpace REST inprogressSubmission representation
|
||||||
|
* @param <ID>
|
||||||
|
* the Serializable class used as primary key
|
||||||
|
*/
|
||||||
|
public abstract class AInprogressItemConverter<T extends InProgressSubmission<ID>,
|
||||||
|
R extends AInprogressSubmissionRest<ID>, ID extends Serializable>
|
||||||
|
extends BrowsableDSpaceObjectConverter<T, R> {
|
||||||
|
|
||||||
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AInprogressItemConverter.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EPersonConverter epersonConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ItemConverter itemConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CollectionConverter collectionConverter;
|
||||||
|
|
||||||
|
protected SubmissionConfigReader submissionConfigReader;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SubmissionDefinitionConverter submissionDefinitionConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SubmissionSectionConverter submissionSectionConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SubmissionService submissionService;
|
||||||
|
|
||||||
|
public AInprogressItemConverter() throws SubmissionConfigReaderException {
|
||||||
|
submissionConfigReader = new SubmissionConfigReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fillFromModel(T obj, R witem) {
|
||||||
|
Collection collection = obj.getCollection();
|
||||||
|
Item item = obj.getItem();
|
||||||
|
EPerson submitter = null;
|
||||||
|
try {
|
||||||
|
submitter = obj.getSubmitter();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
witem.setId(obj.getID());
|
||||||
|
witem.setCollection(collection != null ? collectionConverter.convert(collection) : null);
|
||||||
|
witem.setItem(itemConverter.convert(item));
|
||||||
|
witem.setSubmitter(epersonConverter.convert(submitter));
|
||||||
|
|
||||||
|
// 1. retrieve the submission definition
|
||||||
|
// 2. iterate over the submission section to allow to plugin additional
|
||||||
|
// info
|
||||||
|
|
||||||
|
if (collection != null) {
|
||||||
|
SubmissionDefinitionRest def = submissionDefinitionConverter
|
||||||
|
.convert(submissionConfigReader.getSubmissionConfigByCollection(collection.getHandle()));
|
||||||
|
witem.setSubmissionDefinition(def);
|
||||||
|
for (SubmissionSectionRest sections : def.getPanels()) {
|
||||||
|
SubmissionStepConfig stepConfig = submissionSectionConverter.toModel(sections);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First, load the step processing class (using the current
|
||||||
|
* class loader)
|
||||||
|
*/
|
||||||
|
ClassLoader loader = this.getClass().getClassLoader();
|
||||||
|
Class stepClass;
|
||||||
|
try {
|
||||||
|
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||||
|
|
||||||
|
Object stepInstance = stepClass.newInstance();
|
||||||
|
|
||||||
|
if (stepInstance instanceof AbstractRestProcessingStep) {
|
||||||
|
// load the interface for this step
|
||||||
|
AbstractRestProcessingStep stepProcessing =
|
||||||
|
(AbstractRestProcessingStep) stepClass.newInstance();
|
||||||
|
for (ErrorRest error : stepProcessing.validate(submissionService, obj, stepConfig)) {
|
||||||
|
addError(witem.getErrors(), error);
|
||||||
|
}
|
||||||
|
witem.getSections()
|
||||||
|
.put(sections.getId(), stepProcessing.getData(submissionService, obj, stepConfig));
|
||||||
|
} else {
|
||||||
|
log.warn("The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||||
|
"' does not extend the class org.dspace.app.rest.submit.AbstractRestProcessingStep!" +
|
||||||
|
" Therefore it cannot be used by the Configurable Submission as the " +
|
||||||
|
"<processing-class>!");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("An error occurred during the unmarshal of the data for the section " + sections.getId()
|
||||||
|
+ " - reported error: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addError(List<ErrorRest> errors, ErrorRest toAdd) {
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
String i18nKey = toAdd.getMessage();
|
||||||
|
if (StringUtils.isNotBlank(i18nKey)) {
|
||||||
|
for (ErrorRest error : errors) {
|
||||||
|
if (i18nKey.equals(error.getMessage())) {
|
||||||
|
error.getPaths().addAll(toAdd.getPaths());
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
errors.add(toAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.app.rest.model.ClaimedTaskRest;
|
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
@@ -25,11 +24,12 @@ import org.springframework.stereotype.Component;
|
|||||||
public class ClaimedTaskConverter
|
public class ClaimedTaskConverter
|
||||||
extends BrowsableDSpaceObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
extends BrowsableDSpaceObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(ClaimedTaskConverter.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkflowItemConverter workflowItemConverter;
|
private WorkflowItemConverter workflowItemConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EPersonConverter epersonConverter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimedTaskRest fromModel(ClaimedTask obj) {
|
public ClaimedTaskRest fromModel(ClaimedTask obj) {
|
||||||
ClaimedTaskRest taskRest = new ClaimedTaskRest();
|
ClaimedTaskRest taskRest = new ClaimedTaskRest();
|
||||||
@@ -39,6 +39,7 @@ public class ClaimedTaskConverter
|
|||||||
taskRest.setWorkflowitem(workflowItemConverter.convert(witem));
|
taskRest.setWorkflowitem(workflowItemConverter.convert(witem));
|
||||||
taskRest.setAction(obj.getActionID());
|
taskRest.setAction(obj.getActionID());
|
||||||
taskRest.setStep(obj.getStepID());
|
taskRest.setStep(obj.getStepID());
|
||||||
|
taskRest.setOwner(epersonConverter.convert(obj.getOwner()));
|
||||||
return taskRest;
|
return taskRest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,26 +7,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.app.rest.model.ErrorRest;
|
|
||||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
|
||||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
|
||||||
import org.dspace.app.rest.model.WorkflowItemRest;
|
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
|
||||||
import org.dspace.app.rest.submit.SubmissionService;
|
|
||||||
import org.dspace.app.util.SubmissionConfigReader;
|
|
||||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.content.Collection;
|
|
||||||
import org.dspace.content.Item;
|
|
||||||
import org.dspace.eperson.EPerson;
|
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,95 +22,16 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class WorkflowItemConverter
|
public class WorkflowItemConverter
|
||||||
extends BrowsableDSpaceObjectConverter<XmlWorkflowItem, org.dspace.app.rest.model.WorkflowItemRest> {
|
extends AInprogressItemConverter<XmlWorkflowItem, org.dspace.app.rest.model.WorkflowItemRest, Integer> {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(WorkflowItemConverter.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EPersonConverter epersonConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ItemConverter itemConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CollectionConverter collectionConverter;
|
|
||||||
|
|
||||||
private SubmissionConfigReader submissionConfigReader;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SubmissionDefinitionConverter submissionDefinitionConverter;
|
|
||||||
@Autowired
|
|
||||||
private SubmissionSectionConverter submissionSectionConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
SubmissionService submissionService;
|
|
||||||
|
|
||||||
public WorkflowItemConverter() throws SubmissionConfigReaderException {
|
public WorkflowItemConverter() throws SubmissionConfigReaderException {
|
||||||
submissionConfigReader = new SubmissionConfigReader();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkflowItemRest fromModel(XmlWorkflowItem obj) {
|
public WorkflowItemRest fromModel(XmlWorkflowItem obj) {
|
||||||
WorkflowItemRest witem = new WorkflowItemRest();
|
WorkflowItemRest witem = new WorkflowItemRest();
|
||||||
|
fillFromModel(obj, witem);
|
||||||
Collection collection = obj.getCollection();
|
|
||||||
Item item = obj.getItem();
|
|
||||||
EPerson submitter = null;
|
|
||||||
try {
|
|
||||||
submitter = obj.getSubmitter();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
witem.setId(obj.getID());
|
|
||||||
witem.setCollection(collection != null ? collectionConverter.convert(collection) : null);
|
|
||||||
witem.setItem(itemConverter.convert(item));
|
|
||||||
witem.setSubmitter(epersonConverter.convert(submitter));
|
|
||||||
|
|
||||||
// 1. retrieve the submission definition
|
|
||||||
// 2. iterate over the submission section to allow to plugin additional
|
|
||||||
// info
|
|
||||||
|
|
||||||
if (collection != null) {
|
|
||||||
SubmissionDefinitionRest def = submissionDefinitionConverter
|
|
||||||
.convert(submissionConfigReader.getSubmissionConfigByCollection(collection.getHandle()));
|
|
||||||
witem.setSubmissionDefinition(def);
|
|
||||||
for (SubmissionSectionRest sections : def.getPanels()) {
|
|
||||||
SubmissionStepConfig stepConfig = submissionSectionConverter.toModel(sections);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First, load the step processing class (using the current
|
|
||||||
* class loader)
|
|
||||||
*/
|
|
||||||
ClassLoader loader = this.getClass().getClassLoader();
|
|
||||||
Class stepClass;
|
|
||||||
try {
|
|
||||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
|
||||||
|
|
||||||
Object stepInstance = stepClass.newInstance();
|
|
||||||
|
|
||||||
if (stepInstance instanceof AbstractRestProcessingStep) {
|
|
||||||
// load the interface for this step
|
|
||||||
AbstractRestProcessingStep stepProcessing =
|
|
||||||
(AbstractRestProcessingStep) stepClass.newInstance();
|
|
||||||
for (ErrorRest error : stepProcessing.validate(submissionService, obj, stepConfig)) {
|
|
||||||
addError(witem.getErrors(), error);
|
|
||||||
}
|
|
||||||
witem.getSections()
|
|
||||||
.put(sections.getId(), stepProcessing.getData(submissionService, obj, stepConfig));
|
|
||||||
} else {
|
|
||||||
log.warn("The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
|
||||||
"' does not extend the class org.dspace.app.rest.submit.AbstractRestProcessingStep!" +
|
|
||||||
" Therefore it cannot be used by the Configurable Submission as the " +
|
|
||||||
"<processing-class>!");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return witem;
|
return witem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,25 +40,6 @@ public class WorkflowItemConverter
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addError(List<ErrorRest> errors, ErrorRest toAdd) {
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
String i18nKey = toAdd.getMessage();
|
|
||||||
if (StringUtils.isNotBlank(i18nKey)) {
|
|
||||||
for (ErrorRest error : errors) {
|
|
||||||
if (i18nKey.equals(error.getMessage())) {
|
|
||||||
error.getPaths().addAll(toAdd.getPaths());
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
errors.add(toAdd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsModel(BrowsableObject object) {
|
public boolean supportsModel(BrowsableObject object) {
|
||||||
return object instanceof XmlWorkflowItem;
|
return object instanceof XmlWorkflowItem;
|
||||||
|
@@ -7,24 +7,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.dspace.app.rest.model.ErrorRest;
|
|
||||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
|
||||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
|
||||||
import org.dspace.app.rest.model.WorkspaceItemRest;
|
import org.dspace.app.rest.model.WorkspaceItemRest;
|
||||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
|
||||||
import org.dspace.app.rest.submit.SubmissionService;
|
|
||||||
import org.dspace.app.util.SubmissionConfigReader;
|
|
||||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
import org.dspace.app.util.SubmissionStepConfig;
|
import org.dspace.browse.BrowsableObject;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.Item;
|
|
||||||
import org.dspace.eperson.EPerson;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,95 +21,17 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class WorkspaceItemConverter
|
public class WorkspaceItemConverter
|
||||||
extends DSpaceConverter<org.dspace.content.WorkspaceItem, org.dspace.app.rest.model.WorkspaceItemRest> {
|
extends AInprogressItemConverter<WorkspaceItem, WorkspaceItemRest, Integer> {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(WorkspaceItemConverter.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EPersonConverter epersonConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ItemConverter itemConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CollectionConverter collectionConverter;
|
|
||||||
|
|
||||||
private SubmissionConfigReader submissionConfigReader;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SubmissionDefinitionConverter submissionDefinitionConverter;
|
|
||||||
@Autowired
|
|
||||||
private SubmissionSectionConverter submissionSectionConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
SubmissionService submissionService;
|
|
||||||
|
|
||||||
public WorkspaceItemConverter() throws SubmissionConfigReaderException {
|
public WorkspaceItemConverter() throws SubmissionConfigReaderException {
|
||||||
submissionConfigReader = new SubmissionConfigReader();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceItemRest fromModel(org.dspace.content.WorkspaceItem obj) {
|
public WorkspaceItemRest fromModel(org.dspace.content.WorkspaceItem obj) {
|
||||||
WorkspaceItemRest witem = new WorkspaceItemRest();
|
WorkspaceItemRest witem = new WorkspaceItemRest();
|
||||||
|
|
||||||
Collection collection = obj.getCollection();
|
fillFromModel(obj, witem);
|
||||||
Item item = obj.getItem();
|
|
||||||
EPerson submitter = null;
|
|
||||||
try {
|
|
||||||
submitter = obj.getSubmitter();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
witem.setId(obj.getID());
|
|
||||||
witem.setCollection(collection != null ? collectionConverter.convert(collection) : null);
|
|
||||||
witem.setItem(itemConverter.convert(item));
|
|
||||||
witem.setSubmitter(epersonConverter.convert(submitter));
|
|
||||||
|
|
||||||
// 1. retrieve the submission definition
|
|
||||||
// 2. iterate over the submission section to allow to plugin additional
|
|
||||||
// info
|
|
||||||
|
|
||||||
if (collection != null) {
|
|
||||||
SubmissionDefinitionRest def = submissionDefinitionConverter
|
|
||||||
.convert(submissionConfigReader.getSubmissionConfigByCollection(collection.getHandle()));
|
|
||||||
witem.setSubmissionDefinition(def);
|
|
||||||
for (SubmissionSectionRest sections : def.getPanels()) {
|
|
||||||
SubmissionStepConfig stepConfig = submissionSectionConverter.toModel(sections);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First, load the step processing class (using the current
|
|
||||||
* class loader)
|
|
||||||
*/
|
|
||||||
ClassLoader loader = this.getClass().getClassLoader();
|
|
||||||
Class stepClass;
|
|
||||||
try {
|
|
||||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
|
||||||
|
|
||||||
Object stepInstance = stepClass.newInstance();
|
|
||||||
|
|
||||||
if (stepInstance instanceof AbstractRestProcessingStep) {
|
|
||||||
// load the interface for this step
|
|
||||||
AbstractRestProcessingStep stepProcessing =
|
|
||||||
(AbstractRestProcessingStep) stepClass.newInstance();
|
|
||||||
for (ErrorRest error : stepProcessing.validate(submissionService, obj, stepConfig)) {
|
|
||||||
addError(witem.getErrors(), error);
|
|
||||||
}
|
|
||||||
witem.getSections()
|
|
||||||
.put(sections.getId(), stepProcessing.getData(submissionService, obj, stepConfig));
|
|
||||||
} else {
|
|
||||||
log.warn("The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
|
||||||
"' does not extend the class org.dspace.app.rest.submit.AbstractRestProcessingStep!" +
|
|
||||||
" Therefore it cannot be used by the Configurable Submission as the " +
|
|
||||||
"<processing-class>!");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return witem;
|
return witem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,22 +40,8 @@ public class WorkspaceItemConverter
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
private void addError(List<ErrorRest> errors, ErrorRest toAdd) {
|
public boolean supportsModel(BrowsableObject object) {
|
||||||
|
return object instanceof WorkspaceItem;
|
||||||
boolean found = false;
|
|
||||||
String i18nKey = toAdd.getMessage();
|
|
||||||
if (StringUtils.isNotBlank(i18nKey)) {
|
|
||||||
for (ErrorRest error : errors) {
|
|
||||||
if (i18nKey.equals(error.getMessage())) {
|
|
||||||
error.getPaths().addAll(toAdd.getPaths());
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
errors.add(toAdd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
* 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.rest.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class to share common aspects between the REST representation of inprogressSubmission
|
||||||
|
*
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* the serializable class used as primary key
|
||||||
|
*/
|
||||||
|
public abstract class AInprogressSubmissionRest<T extends Serializable> extends BaseObjectRest<T> {
|
||||||
|
|
||||||
|
private Date lastModified = new Date();
|
||||||
|
private Map<String, Serializable> sections;
|
||||||
|
@JsonIgnore
|
||||||
|
private CollectionRest collection;
|
||||||
|
@JsonIgnore
|
||||||
|
private ItemRest item;
|
||||||
|
@JsonIgnore
|
||||||
|
private SubmissionDefinitionRest submissionDefinition;
|
||||||
|
@JsonIgnore
|
||||||
|
private EPersonRest submitter;
|
||||||
|
|
||||||
|
public AInprogressSubmissionRest() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastModified() {
|
||||||
|
return lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModified(Date lastModified) {
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemRest getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(ItemRest item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubmissionDefinitionRest getSubmissionDefinition() {
|
||||||
|
return submissionDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmissionDefinition(SubmissionDefinitionRest submissionDefinition) {
|
||||||
|
this.submissionDefinition = submissionDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EPersonRest getSubmitter() {
|
||||||
|
return submitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmitter(EPersonRest submitter) {
|
||||||
|
this.submitter = submitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Serializable> getSections() {
|
||||||
|
if (sections == null) {
|
||||||
|
sections = new HashMap<String, Serializable>();
|
||||||
|
}
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSections(Map<String, Serializable> sections) {
|
||||||
|
this.sections = sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionRest getCollection() {
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollection(CollectionRest collection) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -24,6 +24,9 @@ public class ClaimedTaskRest extends BaseObjectRest<Integer> {
|
|||||||
|
|
||||||
private String action;
|
private String action;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private EPersonRest owner;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private WorkflowItemRest workflowitem;
|
private WorkflowItemRest workflowitem;
|
||||||
|
|
||||||
@@ -66,6 +69,18 @@ public class ClaimedTaskRest extends BaseObjectRest<Integer> {
|
|||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ClaimedTaskRest#getOwner()
|
||||||
|
* @return the owner of the task
|
||||||
|
*/
|
||||||
|
public EPersonRest getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(EPersonRest owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the WorkflowItemRest that belong to this claimed task
|
* @return the WorkflowItemRest that belong to this claimed task
|
||||||
|
@@ -7,12 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.model;
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import org.dspace.app.rest.RestResourceController;
|
import org.dspace.app.rest.RestResourceController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,26 +14,10 @@ import org.dspace.app.rest.RestResourceController;
|
|||||||
*
|
*
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
public class WorkflowItemRest extends BaseObjectRest<Integer> {
|
public class WorkflowItemRest extends AInprogressSubmissionRest<Integer> {
|
||||||
public static final String NAME = "workflowitem";
|
public static final String NAME = "workflowitem";
|
||||||
public static final String CATEGORY = RestAddressableModel.WORKFLOW;
|
public static final String CATEGORY = RestAddressableModel.WORKFLOW;
|
||||||
|
|
||||||
private Date lastModified = new Date();
|
|
||||||
|
|
||||||
private Map<String, Serializable> sections;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private CollectionRest collection;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private ItemRest item;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private SubmissionDefinitionRest submissionDefinition;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private EPersonRest submitter;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return CATEGORY;
|
return CATEGORY;
|
||||||
@@ -50,83 +28,8 @@ public class WorkflowItemRest extends BaseObjectRest<Integer> {
|
|||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the timestamp of the last modification done to the workflowitem
|
|
||||||
*/
|
|
||||||
public Date getLastModified() {
|
|
||||||
return lastModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastModified(Date lastModified) {
|
|
||||||
this.lastModified = lastModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the item wrapped by the workflowitem
|
|
||||||
*/
|
|
||||||
public ItemRest getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(ItemRest item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the SubmissionDefinition used by the workflowitem
|
|
||||||
*/
|
|
||||||
public SubmissionDefinitionRest getSubmissionDefinition() {
|
|
||||||
return submissionDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubmissionDefinition(SubmissionDefinitionRest submissionDefinition) {
|
|
||||||
this.submissionDefinition = submissionDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the submitter
|
|
||||||
*/
|
|
||||||
public EPersonRest getSubmitter() {
|
|
||||||
return submitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubmitter(EPersonRest submitter) {
|
|
||||||
this.submitter = submitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getController() {
|
public Class getController() {
|
||||||
return RestResourceController.class;
|
return RestResourceController.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the data of the workflowitem organized according to the submission definition
|
|
||||||
*/
|
|
||||||
public Map<String, Serializable> getSections() {
|
|
||||||
if (sections == null) {
|
|
||||||
sections = new HashMap<String, Serializable>();
|
|
||||||
}
|
|
||||||
return sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSections(Map<String, Serializable> sections) {
|
|
||||||
this.sections = sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the collection where the workflow is in progress
|
|
||||||
*/
|
|
||||||
public CollectionRest getCollection() {
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCollection(CollectionRest collection) {
|
|
||||||
this.collection = collection;
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -7,12 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.model;
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import org.dspace.app.rest.RestResourceController;
|
import org.dspace.app.rest.RestResourceController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,26 +14,10 @@ import org.dspace.app.rest.RestResourceController;
|
|||||||
*
|
*
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
public class WorkspaceItemRest extends BaseObjectRest<Integer> {
|
public class WorkspaceItemRest extends AInprogressSubmissionRest<Integer> {
|
||||||
public static final String NAME = "workspaceitem";
|
public static final String NAME = "workspaceitem";
|
||||||
public static final String CATEGORY = RestAddressableModel.SUBMISSION;
|
public static final String CATEGORY = RestAddressableModel.SUBMISSION;
|
||||||
|
|
||||||
private Date lastModified = new Date();
|
|
||||||
|
|
||||||
private Map<String, Serializable> sections;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private CollectionRest collection;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private ItemRest item;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private SubmissionDefinitionRest submissionDefinition;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private EPersonRest submitter;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return CATEGORY;
|
return CATEGORY;
|
||||||
@@ -50,59 +28,8 @@ public class WorkspaceItemRest extends BaseObjectRest<Integer> {
|
|||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getLastModified() {
|
|
||||||
return lastModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastModified(Date lastModified) {
|
|
||||||
this.lastModified = lastModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemRest getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(ItemRest item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubmissionDefinitionRest getSubmissionDefinition() {
|
|
||||||
return submissionDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubmissionDefinition(SubmissionDefinitionRest submissionDefinition) {
|
|
||||||
this.submissionDefinition = submissionDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EPersonRest getSubmitter() {
|
|
||||||
return submitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubmitter(EPersonRest submitter) {
|
|
||||||
this.submitter = submitter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getController() {
|
public Class getController() {
|
||||||
return RestResourceController.class;
|
return RestResourceController.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Serializable> getSections() {
|
|
||||||
if (sections == null) {
|
|
||||||
sections = new HashMap<String, Serializable>();
|
|
||||||
}
|
|
||||||
return sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSections(Map<String, Serializable> sections) {
|
|
||||||
this.sections = sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectionRest getCollection() {
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCollection(CollectionRest collection) {
|
|
||||||
this.collection = collection;
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -28,11 +28,9 @@ import org.dspace.app.rest.model.PoolTaskRest;
|
|||||||
import org.dspace.app.rest.model.hateoas.ClaimedTaskResource;
|
import org.dspace.app.rest.model.hateoas.ClaimedTaskResource;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.service.EPersonService;
|
import org.dspace.eperson.service.EPersonService;
|
||||||
import org.dspace.event.Event;
|
|
||||||
import org.dspace.workflow.WorkflowException;
|
import org.dspace.workflow.WorkflowException;
|
||||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
@@ -136,10 +134,6 @@ public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskR
|
|||||||
throw new UnprocessableEntityException(
|
throw new UnprocessableEntityException(
|
||||||
"Missing required fields: " + StringUtils.join(Action.getErrorFields(request), ","));
|
"Missing required fields: " + StringUtils.join(Action.getErrorFields(request), ","));
|
||||||
}
|
}
|
||||||
// workflowRequirementsService.removeClaimedUser(context, task.getWorkflowItem(), task.getOwner(), task
|
|
||||||
// .getStepID());
|
|
||||||
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, task.getWorkflowItem().getItem().getID(), null,
|
|
||||||
itemService.getIdentifiers(context, task.getWorkflowItem().getItem())));
|
|
||||||
} catch (AuthorizeException e) {
|
} catch (AuthorizeException e) {
|
||||||
throw new RESTAuthorizationException(e);
|
throw new RESTAuthorizationException(e);
|
||||||
} catch (WorkflowException e) {
|
} catch (WorkflowException e) {
|
||||||
@@ -164,8 +158,6 @@ public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskR
|
|||||||
XmlWorkflowItem workflowItem = task.getWorkflowItem();
|
XmlWorkflowItem workflowItem = task.getWorkflowItem();
|
||||||
workflowService.deleteClaimedTask(context, workflowItem, task);
|
workflowService.deleteClaimedTask(context, workflowItem, task);
|
||||||
workflowRequirementsService.removeClaimedUser(context, workflowItem, task.getOwner(), task.getStepID());
|
workflowRequirementsService.removeClaimedUser(context, workflowItem, task.getOwner(), task.getStepID());
|
||||||
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, workflowItem.getItem().getID(), null,
|
|
||||||
itemService.getIdentifiers(context, workflowItem.getItem())));
|
|
||||||
} catch (AuthorizeException e) {
|
} catch (AuthorizeException e) {
|
||||||
throw new RESTAuthorizationException(e);
|
throw new RESTAuthorizationException(e);
|
||||||
} catch (SQLException | IOException | WorkflowConfigurationException e) {
|
} catch (SQLException | IOException | WorkflowConfigurationException e) {
|
||||||
|
@@ -24,6 +24,7 @@ import org.dspace.app.rest.builder.CommunityBuilder;
|
|||||||
import org.dspace.app.rest.builder.EPersonBuilder;
|
import org.dspace.app.rest.builder.EPersonBuilder;
|
||||||
import org.dspace.app.rest.builder.PoolTaskBuilder;
|
import org.dspace.app.rest.builder.PoolTaskBuilder;
|
||||||
import org.dspace.app.rest.builder.WorkflowItemBuilder;
|
import org.dspace.app.rest.builder.WorkflowItemBuilder;
|
||||||
|
import org.dspace.app.rest.matcher.EPersonMatcher;
|
||||||
import org.dspace.app.rest.matcher.PoolTaskMatcher;
|
import org.dspace.app.rest.matcher.PoolTaskMatcher;
|
||||||
import org.dspace.app.rest.matcher.WorkflowItemMatcher;
|
import org.dspace.app.rest.matcher.WorkflowItemMatcher;
|
||||||
import org.dspace.app.rest.matcher.WorkspaceItemMatcher;
|
import org.dspace.app.rest.matcher.WorkspaceItemMatcher;
|
||||||
@@ -344,6 +345,8 @@ public class TaskRestRepositoriesIT extends AbstractControllerIntegrationTest {
|
|||||||
Matchers.allOf(
|
Matchers.allOf(
|
||||||
hasJsonPath("$._links.self.href", Matchers.containsString("/api/workflow/claimedtasks/")),
|
hasJsonPath("$._links.self.href", Matchers.containsString("/api/workflow/claimedtasks/")),
|
||||||
hasJsonPath("$.type", Matchers.is("claimedtask")),
|
hasJsonPath("$.type", Matchers.is("claimedtask")),
|
||||||
|
hasJsonPath("$._embedded.owner",
|
||||||
|
Matchers.is(EPersonMatcher.matchEPersonOnEmail(reviewer.getEmail()))),
|
||||||
hasJsonPath("$._embedded.workflowitem",
|
hasJsonPath("$._embedded.workflowitem",
|
||||||
Matchers.is(WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(
|
Matchers.is(WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(
|
||||||
witem, "Workflow Item 1", "2017-10-17", "ExtraEntry")))
|
witem, "Workflow Item 1", "2017-10-17", "ExtraEntry")))
|
||||||
|
Reference in New Issue
Block a user