Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
importddi API does not work at present since during dataset creation it tries to validate required fields but DDI (xml) does not have fields that Dataverse deems to be required, for example "Subject". DDI does not have such field. DDI has keywords but they correspond to dataverse keywords.
There is also sometimes a situation when XML files do not have all the fields that user wants to import to Dataverse, in this case editing of XML is needed before import or updating metadata after import.
This API tries to resolve both situations. API submits xml file and json file. Json file consists of missing fields, for example it can be Subject, Language etc. Json file is similar to a json file for edit dataset metadata API https://guides.dataverse.org/en/latest/api/native-api.html#edit-dataset-metadata
Which issue(s) this PR closes:
Resolves #8210
Suggestions on how to test this:
Integration test DataversesIT#testImportDDI is introduced.
The API can be checked with curl:
curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DATAVERSE_ID/datasets/importddiwithjson?replace=true -F 'xml=@src/test/resources/xml/example.xml' -F 'jsonData=@src/test/resources/json/missing-fields.json'
API has following optional parameters:
replace =true/false - if true then replace fields of xml by json fields if the field is in both and creates dataset. If false then add missing files from json to xml and creates dataset. If field exists in both then error is shown.
release=true/false if true then after creation, dataset is published.
pid - import dataset with existing persistentId
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No