mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
Merge pull request #3037 from atmire/csv-import-empty-value-support
Supporting CSV import removing values
This commit is contained in:
@@ -1403,16 +1403,16 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
|||||||
//Populate the EntityRelationMap
|
//Populate the EntityRelationMap
|
||||||
populateEntityRelationMap(uuid, key, originId.toString());
|
populateEntityRelationMap(uuid, key, originId.toString());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
newLine.add(key, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (line.get(key).size() > 1) {
|
if (line.get(key).size() > 0) {
|
||||||
for (String value : line.get(key)) {
|
for (String value : line.get(key)) {
|
||||||
newLine.add(key, value);
|
newLine.add(key, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (line.get(key).size() > 0) {
|
newLine.add(key, null);
|
||||||
newLine.add(key, line.get(key).get(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -152,6 +152,26 @@ public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void metadataImportRemovingValueTest() throws Exception {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
Item item = ItemBuilder.createItem(context, collection).withAuthor("TestAuthorToRemove").withTitle("title")
|
||||||
|
.build();
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
StringUtils.equals(
|
||||||
|
itemService.getMetadata(item, "dc", "contributor", "author", Item.ANY).get(0).getValue(),
|
||||||
|
"TestAuthorToRemove"));
|
||||||
|
|
||||||
|
String[] csv = {"id,collection,dc.title,dc.contributor.author[*]",
|
||||||
|
item.getID().toString() + "," + collection.getHandle() + "," + item.getName() + ","};
|
||||||
|
performImportScript(csv);
|
||||||
|
item = findItemByName("title");
|
||||||
|
assertEquals(itemService.getMetadata(item, "dc", "contributor", "author", Item.ANY).size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
private Item findItemByName(String name) throws SQLException {
|
private Item findItemByName(String name) throws SQLException {
|
||||||
Item importedItem = null;
|
Item importedItem = null;
|
||||||
List<Item> allItems = IteratorUtils.toList(itemService.findAll(context));
|
List<Item> allItems = IteratorUtils.toList(itemService.findAll(context));
|
||||||
|
Reference in New Issue
Block a user