Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS-3699 expose submission configuration over REST #1852

Merged
merged 54 commits into from Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5247bc8
DS-3699 Expose the item-submission configuration over the new REST
abollini Sep 28, 2017
d9fc8be
DS-3699 flag the default submission config
abollini Sep 28, 2017
a54d0ba
DS-3699 add findByCollection to the submission definition repository
abollini Sep 28, 2017
a42a18c
DS-3699 renamed getInputs in getInputsByCollection
abollini Oct 3, 2017
2594415
DS-3699 code cleanup
abollini Oct 3, 2017
d026d72
DS-3699 add support for regex validation, page heading and mandatory …
abollini Oct 3, 2017
8c83c2d
DS-3699 first implementation input-form endpoint
abollini Oct 3, 2017
2ef05eb
DS-3699 embedding authority information in the inputform
abollini Oct 5, 2017
3bc94a2
add rebel.xml to the gitignore
lap82 Oct 4, 2017
a05f6a6
DS-3699 add community service with autowired
lap82 Oct 13, 2017
23eb15c
D4CRIS-336 add authority rest endpoint; add stub for retrieve authori…
lap82 Oct 5, 2017
424541f
D4CRIS-335 change naming convention to receive suggestion from abollini
lap82 Oct 5, 2017
d890cbb
Refactoring (create package and move annotation); fix typo
lap82 Oct 5, 2017
e13b6fe
D4CRIS-336 finalize authority rest resource; starting point for autho…
lap82 Oct 5, 2017
6dc5e19
D4CRIS-336 try to inject body request parameter
lap82 Oct 5, 2017
9545ed5
D4CRIS-336 remove requestbody parameter
lap82 Oct 6, 2017
6a46863
D4CRIS-336 remove requestbody parameter
lap82 Oct 6, 2017
e7c3c9d
D4CRIS-336 improving endpoint; Add wrapper for authority derived from…
lap82 Oct 6, 2017
7b21429
D4CRIS-336 refactoring endpoint to retrieve authority; finalize dynam…
lap82 Oct 9, 2017
d0aee26
D4CRIS-342 respect the new contract for submission definition and inp…
lap82 Oct 9, 2017
0678b91
D4CRIS-342 start point to develop panel rest endpoint
lap82 Oct 10, 2017
dbddc1f
D4CRIS-342 finalize endpoint to expose link from panel to inputform
lap82 Oct 12, 2017
8023675
D4CRIS-336 exposition of vocabulary as authority
lap82 Oct 12, 2017
f875c33
D4CRIS-342 change named endpoint from panel to submission-panel
lap82 Oct 12, 2017
d941883
D4CRIS-342 change named link from panel to inputform (was input-form …
lap82 Oct 13, 2017
88365cc
add comment in the gitignore to explain rebel.xml rule
lap82 Oct 13, 2017
e3aeb3d
D4CRIS-342 cleanup item-submission; add required attribute "id" into …
lap82 Oct 13, 2017
129824b
D4CRIS-342 cleanup item-submission; remove collection and complete re…
lap82 Oct 13, 2017
114aad0
D4CRIS-342 control input-type with custom rule
lap82 Oct 13, 2017
b447f89
D4CRIS-342 enable authority for value-pairs common_types (for test sc…
lap82 Oct 13, 2017
fde9032
fix throw exception
lap82 Oct 16, 2017
e5a97ff
remove unused object
lap82 Oct 16, 2017
8df24f8
DS-3699 renamed endpoint and file for input-forms (now is called subm…
lap82 Oct 16, 2017
ba5ccb1
DS-3699 changed file name (NOW submission-forms.xml WAS input-forms.xml)
lap82 Oct 17, 2017
e7254cf
DS-3699 auto register choice plugin for value-pairs and controlled vo…
lap82 Oct 17, 2017
94cf2bd
[DS-3699] refactoring class name
lap82 Oct 20, 2017
74539f3
[DS-3699] finalizing refactoring; improved authority endpoint;
lap82 Oct 20, 2017
2770a13
[DS-3699] change name to input-forms.dtd; replace all occurance of in…
lap82 Oct 23, 2017
14808d7
[DS-3699] remove model rest page for input form; add use of constant …
lap82 Oct 23, 2017
90b916f
[DS-3699] renamed attibute submission section
lap82 Oct 23, 2017
5ce58f4
[DS-3699] renamed endpoint (remove the dash from the name)
lap82 Oct 23, 2017
2f5d18a
[DS-3699] misc refactoring; fix typo; add logger; remove test configu…
lap82 Oct 25, 2017
22e9844
[DS-3699] manage valuepairs and vocabulary authority both controlled …
lap82 Oct 25, 2017
3a96b94
[DS-3699] change name of the DTD into submission-forms.xml test file
lap82 Oct 25, 2017
f2c8574
DS-3699 use stringutils
lap82 Oct 31, 2017
779f561
DS-3699 use authorities.keySet() here and get rid of the authorityNam…
lap82 Oct 31, 2017
377fefb
DS-3724: Missing readonly in input-forms.dtd
AlexanderS Oct 23, 2017
f755f59
Merge pull request #19 from AlexanderS/DS-3699
lap82 Nov 2, 2017
ea79d17
DS-3699 replace with the standardize method
lap82 Nov 3, 2017
4014c31
DS-3699 minor adjust comment; add javadoc to tokenize and standardize…
lap82 Nov 3, 2017
cdd9049
Merge branch 'master' into DS-3699
lap82 Nov 3, 2017
216d748
DS-3699 enhance wrapper to pass integration test;
lap82 Nov 3, 2017
e6f6866
DS-3699 Add comment about the scope of the SelectableMetadata class
abollini Nov 8, 2017
6b63b6e
DS-3699 Introduce a dedicated exception for the SubmissionConfigReade…
abollini Nov 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -39,3 +39,6 @@ META-INF/

##Mac noise
.DS_Store

##Ignore JRebel project configuration
rebel.xml
19 changes: 18 additions & 1 deletion dspace-api/src/main/java/org/dspace/app/util/DCInput.java
Expand Up @@ -74,6 +74,9 @@ public class DCInput
/** is the entry closed to vocabulary terms? */
private boolean closedVocabulary = false;

/** the regex to comply with, null if nothing */
private String regex = null;

/** allowed document types */
private List<String> typeBind = null;

Expand Down Expand Up @@ -137,6 +140,7 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
visibility = fieldMap.get("visibility");
readOnly = fieldMap.get("readonly");
vocabulary = fieldMap.get("vocabulary");
regex = fieldMap.get("regex");
String closedVocabularyStr = fieldMap.get("closedVocabulary");
closedVocabulary = "true".equalsIgnoreCase(closedVocabularyStr)
|| "yes".equalsIgnoreCase(closedVocabularyStr);
Expand Down Expand Up @@ -415,7 +419,7 @@ public String getStoredString(String pairTypeName, String displayedString)

/**
* The closed attribute of the vocabulary tag for this field as set in
* input-forms.xml
* submission-forms.xml
*
* {@code
* <field>
Expand All @@ -441,5 +445,18 @@ public boolean isAllowedFor(String typeName) {

return typeBind.contains(typeName);
}

public String getScope() {
return visibility;
}

public String getRegex() {
return regex;
}

public String getFieldName() {
return this.getSchema() +"."+ this.getElement() + "." +
this.getQualifier();
}

}
113 changes: 45 additions & 68 deletions dspace-api/src/main/java/org/dspace/app/util/DCInputSet.java
Expand Up @@ -7,7 +7,6 @@
*/
package org.dspace.app.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand All @@ -22,26 +21,31 @@ public class DCInputSet
{
/** name of the input set */
private String formName = null;
/** the inputs ordered by page and row position */
private DCInput[][] inputPages = null;
/** the inputs ordered by row position */
private DCInput[] inputs = null;

/** constructor
* @param formName form name
* @param pages pages
* @param listMap map
*/
public DCInputSet(String formName, List<List<Map<String, String>>> pages, Map<String, List<String>> listMap)
/**
* constructor
*
* @param formName
* form name
* @param headings
* @param mandatoryFlags
* @param fields
* fields
* @param listMap
* map
*/
public DCInputSet(String formName,
List<Map<String, String>> fields, Map<String, List<String>> listMap)
{
this.formName = formName;
inputPages = new DCInput[pages.size()][];
for ( int i = 0; i < inputPages.length; i++ )
this.inputs = new DCInput[fields.size()];
for ( int i = 0; i < inputs.length; i++ )
{
List<Map<String, String>> page = pages.get(i);
inputPages[i] = new DCInput[page.size()];
for ( int j = 0; j < inputPages[i].length; j++ )
{
inputPages[i][j] = new DCInput(page.get(j), listMap);
}
Map<String, String> field = fields.get(i);
inputs[i] = new DCInput(field, listMap);

}
}

Expand All @@ -55,43 +59,23 @@ public String getFormName()
}

/**
* Return the number of pages in this input set
* Return the number of fields in this input set
* @return number of pages
*/
public int getNumberPages()
public int getNumberFields()
{
return inputPages.length;
return inputs.length;
}

/**
* Get all the rows for a page from the form definition
* Get all the fields
*
* @param pageNum desired page within set
* @param addTitleAlternative flag to add the additional title row
* @param addPublishedBefore flag to add the additional published info
*
* @return an array containing the page's displayable rows
* @return an array containing the fields
*/

public DCInput[] getPageRows(int pageNum, boolean addTitleAlternative,
boolean addPublishedBefore)
public DCInput[] getFields()
{
List<DCInput> filteredInputs = new ArrayList<DCInput>();
if ( pageNum < inputPages.length )
{
for (int i = 0; i < inputPages[pageNum].length; i++ )
{
DCInput input = inputPages[pageNum][i];
if (doField(input, addTitleAlternative, addPublishedBefore))
{
filteredInputs.add(input);
}
}
}

// Convert list into an array
DCInput[] inputArray = new DCInput[filteredInputs.size()];
return filteredInputs.toArray(inputArray);
return inputs;
}

/**
Expand All @@ -101,7 +85,7 @@ public DCInput[] getPageRows(int pageNum, boolean addTitleAlternative,
*/
public boolean isDefinedMultTitles()
{
return isFieldPresent("title.alternative");
return isFieldPresent("dc.title.alternative");
}

/**
Expand All @@ -111,9 +95,9 @@ public boolean isDefinedMultTitles()
*/
public boolean isDefinedPubBefore()
{
return ( isFieldPresent("date.issued") &&
isFieldPresent("identifier.citation") &&
isFieldPresent("publisher.null") );
return ( isFieldPresent("dc.date.issued") &&
isFieldPresent("dc.identifier.citation") &&
isFieldPresent("dc.publisher.null") );
}

/**
Expand All @@ -125,18 +109,14 @@ public boolean isDefinedPubBefore()
*/
public boolean isFieldPresent(String fieldName)
{
for (int i = 0; i < inputPages.length; i++)
for (int i = 0; i < inputs.length; i++)
{
DCInput[] pageInputs = inputPages[i];
for (int row = 0; row < pageInputs.length; row++)
{
String fullName = pageInputs[row].getElement() + "." +
pageInputs[row].getQualifier();
DCInput field = inputs[i];
String fullName = field.getFieldName();
if (fullName.equals(fieldName))
{
return true;
}
}
}
return false;
}
Expand All @@ -155,45 +135,42 @@ public boolean isFieldPresent(String fieldName, String documentType)
if (documentType == null) {
documentType = "";
}
for (int i = 0; i < inputPages.length; i++)
for (int i = 0; i < inputs.length; i++)
{
DCInput[] pageInputs = inputPages[i];
for (int row = 0; row < pageInputs.length; row++)
{
String fullName = pageInputs[row].getElement() + "." +
pageInputs[row].getQualifier();
DCInput field = inputs[i];
String fullName = field.getFieldName();
if (fullName.equals(fieldName) )
{
if (pageInputs[row].isAllowedFor(documentType)) {
if (field.isAllowedFor(documentType)) {
return true;
}
}
}
}
return false;
}

protected boolean doField(DCInput dcf, boolean addTitleAlternative,
boolean addPublishedBefore)
{
String rowName = dcf.getElement() + "." + dcf.getQualifier();
if ( rowName.equals("title.alternative") && ! addTitleAlternative )
String rowName = dcf.getFieldName();
if ( rowName.equals("dc.title.alternative") && ! addTitleAlternative )
{
return false;
}
if (rowName.equals("date.issued") && ! addPublishedBefore )
if (rowName.equals("dc.date.issued") && ! addPublishedBefore )
{
return false;
}
if (rowName.equals("publisher.null") && ! addPublishedBefore )
if (rowName.equals("dc.publisher.null") && ! addPublishedBefore )
{
return false;
}
if (rowName.equals("identifier.citation") && ! addPublishedBefore )
if (rowName.equals("dc.identifier.citation") && ! addPublishedBefore )
{
return false;
}

return true;
}

}