Merge pull request #3039 from atmire/w2p-74186_CSV-import-error-with-virtual-metadata-bugfix

CSV Import error with Virtual Metadata fix
This commit is contained in:
Tim Donohue
2020-11-18 14:35:17 -06:00
committed by GitHub
2 changed files with 25 additions and 2 deletions

View File

@@ -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 =

View File

@@ -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
*/