mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
74186: CSV import error with virtual metadata bugfix
This commit is contained in:
@@ -113,14 +113,14 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
*
|
||||
* @see #populateRefAndRowMap(DSpaceCSVLine, UUID)
|
||||
*/
|
||||
protected static HashMap<UUID, String> entityTypeMap = new HashMap<>();
|
||||
protected HashMap<UUID, String> 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<String, HashMap<String, ArrayList<String>>> entityRelationMap = new HashMap<>();
|
||||
protected HashMap<String, HashMap<String, ArrayList<String>>> entityRelationMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -1517,6 +1517,9 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
throw new MetadataImportException("Error in CSV row " + rowCount + ":\n" +
|
||||
"Not a UUID or indirect entity reference: '" + reference + "'");
|
||||
}
|
||||
}
|
||||
if (reference.contains("::virtual::")) {
|
||||
return UUID.fromString(StringUtils.substringBefore(reference, "::virtual::"));
|
||||
} else if (!reference.startsWith("rowName:")) { // Not a rowName ref; so it's a metadata value reference
|
||||
MetadataValueService metadataValueService = ContentServiceFactory.getInstance().getMetadataValueService();
|
||||
MetadataFieldService metadataFieldService =
|
||||
|
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user