From 9994dd8d7cf815f467a420532c7207d3f8cf2dcb Mon Sep 17 00:00:00 2001 From: Marie Verdonck Date: Mon, 14 Oct 2019 13:49:55 +0200 Subject: [PATCH 1/4] w2p-65570 - Configuring whether name variants should be used --- .../main/java/org/dspace/app/util/DCInput.java | 17 +++++++++++++++++ .../dspaceFolder/config/submission-forms.xml | 8 +++++--- .../rest/converter/SubmissionFormConverter.java | 1 + .../model/submit/SelectableRelationship.java | 9 +++++++++ dspace/config/submission-forms.dtd | 3 ++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/app/util/DCInput.java b/dspace-api/src/main/java/org/dspace/app/util/DCInput.java index cbc3986dab2..a6444a3890d 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DCInput.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DCInput.java @@ -89,6 +89,11 @@ public class DCInput { */ private boolean repeatable = false; + /** + * should name-variants be used? + */ + private boolean nameVariants = false; + /** * 'hint' text to display */ @@ -183,6 +188,9 @@ public DCInput(Map fieldMap, Map> listMap) String repStr = fieldMap.get("repeatable"); repeatable = "true".equalsIgnoreCase(repStr) || "yes".equalsIgnoreCase(repStr); + String nameVariantsString = fieldMap.get("name-variants"); + nameVariants = (StringUtils.isNotBlank(nameVariantsString)) ? + nameVariantsString.equalsIgnoreCase("true") : false; label = fieldMap.get("label"); inputType = fieldMap.get("input-type"); // these types are list-controlled @@ -269,6 +277,15 @@ public boolean getRepeatable() { return isRepeatable(); } + /** + * Get the nameVariants flag for this row + * + * @return the nameVariants flag + */ + public boolean areNameVariantsAllowed() { + return nameVariants; + } + /** * Get the input type for this row * diff --git a/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml b/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml index 81ab1f1c4f0..3c59c115318 100644 --- a/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml +++ b/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml @@ -14,11 +14,12 @@ - + - - + + +
@@ -53,6 +54,7 @@ isAuthorOfPublication personConfiguration true + true Add an author diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/SubmissionFormConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/SubmissionFormConverter.java index 485d68f7705..749a5edbe5b 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/SubmissionFormConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/SubmissionFormConverter.java @@ -170,6 +170,7 @@ private SelectableRelationship getSelectableRelationships(DCInput dcinput) { selectableRelationship.setRelationshipType(dcinput.getRelationshipType()); selectableRelationship.setFilter(dcinput.getFilter()); selectableRelationship.setSearchConfiguration(dcinput.getSearchConfiguration()); + selectableRelationship.setNameVariants(String.valueOf(dcinput.areNameVariantsAllowed())); return selectableRelationship; } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/submit/SelectableRelationship.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/submit/SelectableRelationship.java index cfc6aa8d718..97117321f10 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/submit/SelectableRelationship.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/submit/SelectableRelationship.java @@ -23,6 +23,7 @@ public class SelectableRelationship { private String relationshipType; private String filter; private String searchConfiguration; + private String nameVariants; public void setRelationshipType(String relationshipType) { this.relationshipType = relationshipType; @@ -47,4 +48,12 @@ public void setSearchConfiguration(String searchConfiguration) { public String getSearchConfiguration() { return searchConfiguration; } + + public void setNameVariants(String nameVariants) { + this.nameVariants = nameVariants; + } + + public String getNameVariants() { + return nameVariants; + } } diff --git a/dspace/config/submission-forms.dtd b/dspace/config/submission-forms.dtd index 6533dcfc47e..6f277ce2087 100644 --- a/dspace/config/submission-forms.dtd +++ b/dspace/config/submission-forms.dtd @@ -22,6 +22,7 @@ + @@ -59,5 +60,5 @@ - + From df7ee6410c01ec2587817e6787c8ca65a6a32c12 Mon Sep 17 00:00:00 2001 From: Marie Verdonck Date: Mon, 14 Oct 2019 13:51:02 +0200 Subject: [PATCH 2/4] w2p-65570 - Tests modified for name variants configuration check --- .../app/rest/SubmissionFormsControllerIT.java | 18 +++++------ .../matcher/SubmissionFormFieldMatcher.java | 31 ++++++++++++++----- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java index 26252b37314..756d86d798a 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/SubmissionFormsControllerIT.java @@ -78,7 +78,7 @@ public void findTraditionalPageOne() throws Exception { // check the first two rows .andExpect(jsonPath("$.rows[0].fields", contains( SubmissionFormFieldMatcher.matchFormFieldDefinition("name", "Author", - null, true, "Add an author", "dc.contributor.author")))) + null, true,"Add an author", "dc.contributor.author")))) .andExpect(jsonPath("$.rows[1].fields", contains( SubmissionFormFieldMatcher.matchFormFieldDefinition("onebox", "Title", "You must enter a main title for this item.", false, @@ -90,9 +90,9 @@ public void findTraditionalPageOne() throws Exception { "You must enter at least the year.", false, "Please give the date", "col-sm-4", "dc.date.issued"), - SubmissionFormFieldMatcher.matchFormFieldDefinition("onebox", "Publisher", null, false, - "Enter the name of", "col-sm-8", - "dc.publisher")))) + SubmissionFormFieldMatcher.matchFormFieldDefinition("onebox", "Publisher", + null, false,"Enter the name of", + "col-sm-8","dc.publisher")))) ; } @@ -114,9 +114,9 @@ public void findOpenRelationshipConfig() throws Exception { // check the first two rows .andExpect(jsonPath("$.rows[0].fields", contains( SubmissionFormFieldMatcher.matchFormOpenRelationshipFieldDefinition("name", - "Author", null, true, "Add an author", + "Author", null, true,"Add an author", "dc.contributor.author", "isAuthorOfPublication", null, - "personConfiguration")))) + "personConfiguration", true)))) ; } @@ -138,8 +138,8 @@ public void findClosedRelationshipConfig() throws Exception { // check the first two rows .andExpect(jsonPath("$.rows[0].fields", contains( SubmissionFormFieldMatcher.matchFormClosedRelationshipFieldDefinition("Journal", null, - false, "Select the journal related to this volume.", "isVolumeOfJournal", - "creativework.publisher:somepublishername", "periodicalConfiguration")))) + false,"Select the journal related to this volume.", "isVolumeOfJournal", + "creativework.publisher:somepublishername", "periodicalConfiguration", false)))) ; } -} \ No newline at end of file +} diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java index 724957ff3f7..bf070d582c6 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java @@ -13,6 +13,8 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; +import javax.annotation.Nullable; + import org.hamcrest.Matcher; /** @@ -47,7 +49,8 @@ private SubmissionFormFieldMatcher() { * @return a Matcher for all the condition above */ public static Matcher matchFormFieldDefinition(String type, String label, String mandatoryMessage, - boolean repeatable, String hints, String metadata) { + boolean repeatable, + String hints, String metadata) { return matchFormFieldDefinition(type, label, mandatoryMessage, repeatable, hints, null, metadata); } @@ -73,8 +76,8 @@ public static Matcher matchFormFieldDefinition(String type, Stri * @return a Matcher for all the condition above */ public static Matcher matchFormFieldDefinition(String type, String label, String mandatoryMessage, - boolean repeatable, String hints, String style, - String metadata) { + boolean repeatable, + String hints, String style, String metadata) { return allOf( // check each field definition hasJsonPath("$.input.type", is(type)), @@ -113,19 +116,26 @@ public static Matcher matchFormFieldDefinition(String type, Stri * the optional filter to be used for the lookup * @param searchConfiguration * the searchConfiguration to be used for the lookup + * @param nameVariants + * the optional name variants allowed flag * @return a Matcher for all the condition above */ public static Matcher matchFormOpenRelationshipFieldDefinition(String type, String label, String mandatoryMessage, - boolean repeatable, String hints, + boolean repeatable, + String hints, String metadata, String relationshipType, String filter, - String searchConfiguration) { + String searchConfiguration, + @Nullable Boolean nameVariants) { return allOf( hasJsonPath("$.selectableRelationship.relationshipType", is(relationshipType)), hasJsonPath("$.selectableRelationship.filter", is(filter)), hasJsonPath("$.selectableRelationship.searchConfiguration", is(searchConfiguration)), + nameVariants != null ? + hasJsonPath("$.selectableRelationship.nameVariants", is(nameVariants.toString())) + : hasNoJsonPath("$.selectableRelationship.nameVariants"), matchFormFieldDefinition(type, label, mandatoryMessage, repeatable, hints, metadata)); } @@ -148,18 +158,25 @@ public static Matcher matchFormOpenRelationshipFieldDefinition(S * the optional filter to be used for the lookup * @param searchConfiguration * the searchConfiguration to be used for the lookup + * @param nameVariants + * the optional name variants allowed flag * @return a Matcher for all the condition above */ public static Matcher matchFormClosedRelationshipFieldDefinition(String label, String mandatoryMessage, - boolean repeatable, String hints, + boolean repeatable, + String hints, String relationshipType, String filter, - String searchConfiguration) { + String searchConfiguration, + @Nullable Boolean nameVariants) { return allOf( hasJsonPath("$.selectableRelationship.relationshipType", is(relationshipType)), hasJsonPath("$.selectableRelationship.filter", is(filter)), hasJsonPath("$.selectableRelationship.searchConfiguration", is(searchConfiguration)), + nameVariants != null ? + hasJsonPath("$.selectableRelationship.nameVariants", is(nameVariants.toString())) + : hasNoJsonPath("$.selectableRelationship.nameVariants"), hasJsonPath("$.label", is(label)), mandatoryMessage != null ? hasJsonPath("$.mandatoryMessage", containsString(mandatoryMessage)) : hasNoJsonPath("$.mandatoryMessage"), From 7a847db62b1dc06be40d173f94eeca99ef017df4 Mon Sep 17 00:00:00 2001 From: Marie Verdonck Date: Fri, 8 Nov 2019 09:02:39 +0100 Subject: [PATCH 3/4] Feedback on PR 2561 --- .../rest/matcher/SubmissionFormFieldMatcher.java | 14 ++++---------- dspace/config/submission-forms.xml | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java index bf070d582c6..67f2494cf36 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/matcher/SubmissionFormFieldMatcher.java @@ -13,8 +13,6 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; -import javax.annotation.Nullable; - import org.hamcrest.Matcher; /** @@ -128,14 +126,12 @@ public static Matcher matchFormOpenRelationshipFieldDefinition(S String relationshipType, String filter, String searchConfiguration, - @Nullable Boolean nameVariants) { + boolean nameVariants) { return allOf( hasJsonPath("$.selectableRelationship.relationshipType", is(relationshipType)), hasJsonPath("$.selectableRelationship.filter", is(filter)), hasJsonPath("$.selectableRelationship.searchConfiguration", is(searchConfiguration)), - nameVariants != null ? - hasJsonPath("$.selectableRelationship.nameVariants", is(nameVariants.toString())) - : hasNoJsonPath("$.selectableRelationship.nameVariants"), + hasJsonPath("$.selectableRelationship.nameVariants", is(String.valueOf(nameVariants))), matchFormFieldDefinition(type, label, mandatoryMessage, repeatable, hints, metadata)); } @@ -169,14 +165,12 @@ public static Matcher matchFormClosedRelationshipFieldDefinition String relationshipType, String filter, String searchConfiguration, - @Nullable Boolean nameVariants) { + boolean nameVariants) { return allOf( hasJsonPath("$.selectableRelationship.relationshipType", is(relationshipType)), hasJsonPath("$.selectableRelationship.filter", is(filter)), hasJsonPath("$.selectableRelationship.searchConfiguration", is(searchConfiguration)), - nameVariants != null ? - hasJsonPath("$.selectableRelationship.nameVariants", is(nameVariants.toString())) - : hasNoJsonPath("$.selectableRelationship.nameVariants"), + hasJsonPath("$.selectableRelationship.nameVariants", is(String.valueOf(nameVariants))), hasJsonPath("$.label", is(label)), mandatoryMessage != null ? hasJsonPath("$.mandatoryMessage", containsString(mandatoryMessage)) : hasNoJsonPath("$.mandatoryMessage"), diff --git a/dspace/config/submission-forms.xml b/dspace/config/submission-forms.xml index c3296d4df95..52d4cf4ce9f 100644 --- a/dspace/config/submission-forms.xml +++ b/dspace/config/submission-forms.xml @@ -14,7 +14,7 @@ - + From 082dd94aefc8d8b2908f0d311ba2f01ddce9139a Mon Sep 17 00:00:00 2001 From: Ben Bosman Date: Tue, 12 Nov 2019 10:58:33 +0100 Subject: [PATCH 4/4] docs --- .../src/test/data/dspaceFolder/config/submission-forms.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml b/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml index 3c59c115318..e0ec2dc60a8 100644 --- a/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml +++ b/dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml @@ -18,7 +18,7 @@ - +