diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java index 869c7d13fc..6139649a5d 100644 --- a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java +++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java @@ -113,14 +113,14 @@ public class MetadataImport extends DSpaceRunnable entityTypeMap = new HashMap<>(); + protected HashMap entityTypeMap = new HashMap<>(); /** * Map of UUIDs to their relations that are referenced within any import with their referers. * * @see #populateEntityRelationMap(String, String, String) */ - protected static HashMap>> entityRelationMap = new HashMap<>(); + protected HashMap>> entityRelationMap = new HashMap<>(); /** @@ -1403,16 +1403,16 @@ public class MetadataImport extends DSpaceRunnable 1) { + if (line.get(key).size() > 0) { for (String value : line.get(key)) { newLine.add(key, value); } } else { - if (line.get(key).size() > 0) { - newLine.add(key, line.get(key).get(0)); - } + newLine.add(key, null); } } } @@ -1517,6 +1517,9 @@ public class MetadataImport extends DSpaceRunnable allItems = IteratorUtils.toList(itemService.findAll(context)); diff --git a/dspace-api/src/test/java/org/dspace/app/csv/CSVMetadataImportReferenceIT.java b/dspace-api/src/test/java/org/dspace/app/csv/CSVMetadataImportReferenceIT.java index 2dfe3a781f..e4bc630cc1 100644 --- a/dspace-api/src/test/java/org/dspace/app/csv/CSVMetadataImportReferenceIT.java +++ b/dspace-api/src/test/java/org/dspace/app/csv/CSVMetadataImportReferenceIT.java @@ -539,6 +539,26 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat assertRelationship(items[2], items[0], 1, "left", 0); } + @Test + public void testRelationToVirtualDataInReferences() throws Exception { + + Item testItem = ItemBuilder.createItem(context, col1) + .withTitle("Person") + .withIssueDate("2017-10-17") + .withAuthor("Smith, Donald") + .withPersonIdentifierLastName("Smith") + .withPersonIdentifierFirstName("Donald") + .withRelationshipType("Person") + .withIdentifierOther("testItemOne") + .build(); + + + String[] csv = {"id,relationship.type,relation.isAuthorOfPublication,collection,dc.identifier.other,rowName", + "+,Publication," + testItem.getID() + "::virtual::4::600," + col1.getHandle() + ",0,1"}; + Item[] items = runImport(csv); + assertRelationship(items[0], testItem, 1, "left", 0); + } + /** * Test relationship validation with invalid relationship definition by incorrect typeName usage */