Skip to content

Commit

Permalink
Merged in DSC-1586 (pull request DSpace#1914)
Browse files Browse the repository at this point in the history
[DSC-1586] - Validation errors are not displayed on submission fields visible only in workflow

Approved-by: Francesco Pio Scognamiglio
  • Loading branch information
NikitaKr1vonosov authored and francescopioscognamiglio committed Mar 27, 2024
2 parents d873347 + 59f8669 commit 6b0b1d2
Show file tree
Hide file tree
Showing 10 changed files with 671 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.dspace.core.exception.SQLRuntimeException;
import org.dspace.services.ConfigurationService;
import org.dspace.validation.model.ValidationError;
import org.dspace.workflow.WorkflowItem;

/**
* Execute three validation check on fields validation: - mandatory metadata
Expand Down Expand Up @@ -100,12 +101,13 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o
} else {
validateMetadataValues(obj.getCollection(), mdv, input, config, isAuthorityControlled,
fieldKey, errors);
if (mdv.size() > 0 && input.isVisible(DCInput.SUBMISSION_SCOPE)) {
if (mdv.size() > 0 && (input.isVisible(DCInput.SUBMISSION_SCOPE) ||
input.isVisible(DCInput.WORKFLOW_SCOPE))) {
foundResult = true;
}
}
}
if (input.isRequired() && ! foundResult) {
if (input.isRequired() && !foundResult) {
// for this required qualdrop no value was found, add to the list of error fields
addError(errors, ERROR_VALIDATION_REQUIRED,
"/" + OPERATION_PATH_SECTIONS + "/" + config.getId() + "/" +
Expand Down Expand Up @@ -139,8 +141,10 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o
}
validateMetadataValues(obj.getCollection(), mdv, input, config,
isAuthorityControlled, fieldKey, errors);
if ((input.isRequired() && mdv.size() == 0) && input.isVisible(DCInput.SUBMISSION_SCOPE)
&& !valuesRemoved) {
if ((input.isRequired() && mdv.size() == 0)
&& (input.isVisible(DCInput.SUBMISSION_SCOPE)
|| (obj instanceof WorkflowItem && input.isVisible(DCInput.WORKFLOW_SCOPE)))
&& !valuesRemoved) {
// Is the input required for *this* type? In other words, are we looking at a required
// input that is also allowed for this document type
if (input.isAllowedFor(documentType)) {
Expand Down
12 changes: 12 additions & 0 deletions dspace-api/src/test/data/dspaceFolder/config/item-submission.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
<type>submission-form</type>
</step-definition>
<step-definition id="funding" mandatory="true">
<heading>submit.progressbar.describe.funding</heading>
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
<type>submission-form</type>
</step-definition>

</step-definitions>

Expand Down Expand Up @@ -479,6 +484,13 @@
<step id="upload" />
</submission-process>

<submission-process name="funding">
<step id="collection" />
<step id="funding" />
<step id="detect-duplicate" />
<step id="license" />
</submission-process>

</submission-definitions>

</item-submission>
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@
</bean>
</list>
</entry>
<entry key="funding">
<list>
<bean class="org.dspace.content.edit.EditItemMode">
<property name="name" value="FIRST" />
<property name="security">
<value type="org.dspace.content.security.CrisSecurity">
ADMIN
</value>
</property>
<property name="submissionDefinition" value="funding" />
</bean>
</list>
</entry>
</map>
</property>
</bean>
Expand Down
204 changes: 204 additions & 0 deletions dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,79 @@ it, please enter the types and the actual numbers or codes.</hint>
</field>
</row>
</form>

<form name="orgunit">
<row>
<field>
<dc-schema>dc</dc-schema>
<dc-element>title</dc-element>
<label>Organization name</label>
<input-type>onebox</input-type>
<repeatable>false</repeatable>
<required>You must enter the oganization name.</required>
<hint />
</field>
</row>
</form>

<form name="funding">
<row>
<field>
<dc-schema>dc</dc-schema>
<dc-element>title</dc-element>
<label>Title</label>
<input-type>onebox</input-type>
<repeatable>false</repeatable>
<required>You must enter the project title</required>
<hint />
</field>
</row>
<row>
<field>
<dc-schema>oairecerif</dc-schema>
<dc-element>funder</dc-element>
<label>Financing</label>
<input-type>inline-group</input-type>
<repeatable>true</repeatable>
<required>You must enter financing information</required>
<hint />
</field>
</row>
</form>

<form name="funding-oairecerif-funder">
<row>
<field>
<dc-schema>oairecerif</dc-schema>
<dc-element>funder</dc-element>
<label>Funder</label>
<input-type>onebox</input-type>
<repeatable>false</repeatable>
<required>You must enter the funder</required>
<style>col-xs-12 col-md-6 col-lg-3</style>
<hint />
</field>
<field>
<dc-schema>oairecerif</dc-schema>
<dc-element>amount</dc-element>
<label>Amount</label>
<input-type>onebox</input-type>
<repeatable>false</repeatable>
<required />
<hint />
</field>
<field>
<dc-schema>oairecerif</dc-schema>
<dc-element>amount</dc-element>
<dc-qualifier>currency</dc-qualifier>
<label>Currency</label>
<input-type value-pairs-name="currency">dropdown</input-type>
<repeatable>false</repeatable>
<required />
<hint />
</field>
</row>
</form>
</form-definitions>


Expand Down Expand Up @@ -2803,6 +2876,137 @@ it, please enter the types and the actual numbers or codes.</hint>
</pair>
</value-pairs>

<value-pairs value-pairs-name="currency" dc-term="currency">
<pair>
<displayed-value>Swiss franc</displayed-value>
<stored-value>Swiss franc</stored-value>
</pair>
<pair>
<displayed-value>Euro</displayed-value>
<stored-value>Euro</stored-value>
</pair>
<pair>
<displayed-value>US dollar</displayed-value>
<stored-value>US dollar</stored-value>
</pair>
<pair>
<displayed-value>Albanian lek</displayed-value>
<stored-value>Albanian lek</stored-value>
</pair>
<pair>
<displayed-value>Armenian dram</displayed-value>
<stored-value>Armenian dram</stored-value>
</pair>
<pair>
<displayed-value>Azerbaijan manat</displayed-value>
<stored-value>Azerbaijan manat</stored-value>
</pair>
<pair>
<displayed-value>Belarusian ruble</displayed-value>
<stored-value>Belarusian ruble</stored-value>
</pair>
<pair>
<displayed-value>Bosnia and Herzegovina convertible mark</displayed-value>
<stored-value>Bosnia and Herzegovina convertible mark</stored-value>
</pair>
<pair>
<displayed-value>Bulgarian lev</displayed-value>
<stored-value>Bulgarian lev</stored-value>
</pair>
<pair>
<displayed-value>Croatian kuna</displayed-value>
<stored-value>Croatian kuna</stored-value>
</pair>
<pair>
<displayed-value>Czech koruna</displayed-value>
<stored-value>Czech koruna</stored-value>
</pair>
<pair>
<displayed-value>Danish krone</displayed-value>
<stored-value>Danish krone</stored-value>
</pair>
<pair>
<displayed-value>Faroese krona</displayed-value>
<stored-value>Faroese krona</stored-value>
</pair>
<pair>
<displayed-value>Georgian lari</displayed-value>
<stored-value>Georgian lari</stored-value>
</pair>
<pair>
<displayed-value>Gibraltar pound</displayed-value>
<stored-value>Gibraltar pound</stored-value>
</pair>
<pair>
<displayed-value>Guernsey pound</displayed-value>
<stored-value>Guernsey pound</stored-value>
</pair>
<pair>
<displayed-value>Hungarian forint</displayed-value>
<stored-value>Hungarian forint</stored-value>
</pair>
<pair>
<displayed-value>Icelandic krona</displayed-value>
<stored-value>Icelandic krona</stored-value>
</pair>
<pair>
<displayed-value>Manx pound</displayed-value>
<stored-value>Manx pound</stored-value>
</pair>
<pair>
<displayed-value>Jersey pound</displayed-value>
<stored-value>Jersey pound</stored-value>
</pair>
<pair>
<displayed-value>Kazakhstani tenge</displayed-value>
<stored-value>Kazakhstani tenge</stored-value>
</pair>
<pair>
<displayed-value>Moldovan leu</displayed-value>
<stored-value>Moldovan leu</stored-value>
</pair>
<pair>
<displayed-value>Macedonian denar</displayed-value>
<stored-value>Macedonian denar</stored-value>
</pair>
<pair>
<displayed-value>Norwegian krone</displayed-value>
<stored-value>Norwegian krone</stored-value>
</pair>
<pair>
<displayed-value>Polish zloty</displayed-value>
<stored-value>Polish zloty</stored-value>
</pair>
<pair>
<displayed-value>Romanian leu</displayed-value>
<stored-value>Romanian leu</stored-value>
</pair>
<pair>
<displayed-value>Russian ruble</displayed-value>
<stored-value>Russian ruble</stored-value>
</pair>
<pair>
<displayed-value>Serbian dinar</displayed-value>
<stored-value>Serbian dinar</stored-value>
</pair>
<pair>
<displayed-value>Swedish krona</displayed-value>
<stored-value>Swedish krona</stored-value>
</pair>
<pair>
<displayed-value>Turkish lira</displayed-value>
<stored-value>Turkish lira</stored-value>
</pair>
<pair>
<displayed-value>Ukrainian hryvnia</displayed-value>
<stored-value>Ukrainian hryvnia</stored-value>
</pair>
<pair>
<displayed-value>Pound sterling</displayed-value>
<stored-value>Pound sterling</stored-value>
</pair>
</value-pairs>

</form-value-pairs>

</input-forms>
Loading

0 comments on commit 6b0b1d2

Please sign in to comment.