mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
[TLC-254] Make type bind config dynamic, fix test comments
This commit is contained in:
@@ -31,6 +31,7 @@ import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
@@ -44,11 +45,11 @@ public class DescribeStep extends AbstractProcessingStep {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(DescribeStep.class);
|
||||
|
||||
// Input reader for form configuration
|
||||
private DCInputsReader inputReader;
|
||||
|
||||
private static final String DOCUMENT_TYPE_FIELD =
|
||||
DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("submit.type-bind.field",
|
||||
"dc.type");
|
||||
// Configuration service
|
||||
private final ConfigurationService configurationService =
|
||||
DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
public DescribeStep() throws DCInputsReaderException {
|
||||
inputReader = new DCInputsReader();
|
||||
@@ -70,7 +71,8 @@ public class DescribeStep extends AbstractProcessingStep {
|
||||
private void readField(InProgressSubmission obj, SubmissionStepConfig config, DataDescribe data,
|
||||
DCInputSet inputConfig) throws DCInputsReaderException {
|
||||
String documentTypeValue = "";
|
||||
List<MetadataValue> documentType = itemService.getMetadataByMetadataString(obj.getItem(), DOCUMENT_TYPE_FIELD);
|
||||
List<MetadataValue> documentType = itemService.getMetadataByMetadataString(obj.getItem(),
|
||||
configurationService.getProperty("submit.type-bind.field", "dc.type"));
|
||||
if (documentType.size() > 0) {
|
||||
documentTypeValue = documentType.get(0).getValue();
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
|
||||
/**
|
||||
* Execute three validation check on fields validation:
|
||||
@@ -44,10 +44,6 @@ public class MetadataValidation extends AbstractValidation {
|
||||
|
||||
private static final String ERROR_VALIDATION_REGEX = "error.validation.regex";
|
||||
|
||||
private static final String DOCUMENT_TYPE_FIELD =
|
||||
DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("submit.type-bind.field",
|
||||
"dc.type");
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(MetadataValidation.class);
|
||||
|
||||
private DCInputsReader inputReader;
|
||||
@@ -56,6 +52,8 @@ public class MetadataValidation extends AbstractValidation {
|
||||
|
||||
private MetadataAuthorityService metadataAuthorityService;
|
||||
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
@Override
|
||||
public List<ErrorRest> validate(SubmissionService submissionService, InProgressSubmission obj,
|
||||
SubmissionStepConfig config) throws DCInputsReaderException, SQLException {
|
||||
@@ -63,7 +61,8 @@ public class MetadataValidation extends AbstractValidation {
|
||||
List<ErrorRest> errors = new ArrayList<>();
|
||||
String documentTypeValue = "";
|
||||
DCInputSet inputConfig = getInputReader().getInputsByFormName(config.getId());
|
||||
List<MetadataValue> documentType = itemService.getMetadataByMetadataString(obj.getItem(), DOCUMENT_TYPE_FIELD);
|
||||
List<MetadataValue> documentType = itemService.getMetadataByMetadataString(obj.getItem(),
|
||||
configurationService.getProperty("submit.type-bind.field", "dc.type"));
|
||||
if (documentType.size() > 0) {
|
||||
documentTypeValue = documentType.get(0).getValue();
|
||||
}
|
||||
@@ -150,6 +149,10 @@ public class MetadataValidation extends AbstractValidation {
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfigurationService(ConfigurationService configurationService) {
|
||||
this.configurationService = configurationService;
|
||||
}
|
||||
|
||||
public void setItemService(ItemService itemService) {
|
||||
this.itemService = itemService;
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
<bean name="metadataValidation" class="org.dspace.app.rest.submit.step.validation.MetadataValidation"
|
||||
scope="prototype">
|
||||
<property name="name" value="submission-form"/>
|
||||
<property name="configurationService" ref="org.dspace.services.ConfigurationService"/>
|
||||
<property name="itemService" ref="org.dspace.content.ItemServiceImpl"/>
|
||||
<property name="metadataAuthorityService" ref="org.dspace.content.authority.MetadataAuthorityServiceImpl"/>
|
||||
</bean>
|
||||
|
@@ -2030,7 +2030,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.errors").doesNotExist())
|
||||
.andExpect(jsonPath("$",
|
||||
// Check this - we should match an item with no series or type
|
||||
// Check this - we should match an item with the expected series and type
|
||||
Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem,
|
||||
"Technical Report", "New Series"))));
|
||||
|
||||
@@ -2039,7 +2039,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.errors").doesNotExist())
|
||||
.andExpect(jsonPath("$",
|
||||
// Check this - we should match an item with no series or type
|
||||
// Check this - we should match an item with the expected series and type
|
||||
Matchers.is(WorkspaceItemMatcher.matchItemWithTypeAndSeries(witem,
|
||||
"Technical Report", "New Series"))));
|
||||
|
||||
|
Reference in New Issue
Block a user