diff --git a/src/main/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdService.java b/src/main/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdService.java index c0e60611..135bf273 100644 --- a/src/main/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdService.java +++ b/src/main/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdService.java @@ -155,8 +155,12 @@ private Map getIdsAndHookIds() { while (rs.next()) { // if dmrecord, descri, and contri fields are not blank, // add dmrecord and descri_contri (hook id when combined) to map - if (!rs.getString(1).isBlank() && !rs.getString(2).isBlank() && !rs.getString(3).isBlank()) { - idsAndHookIds.put(rs.getString(1), rs.getString(2) + "_" + rs.getString(3)); + var dmrecord = rs.getString(1); + var descri = rs.getString(2); + var contri = rs.getString(3); + if (!dmrecord.isBlank() && !descri.isBlank() && !contri.isBlank()) { + // remove -v from descri for matching purposes + idsAndHookIds.put(dmrecord, descri.replace("-z", "") + "_" + contri); } } return idsAndHookIds; diff --git a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdServiceTest.java b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdServiceTest.java index 63ff07a0..8b1c993d 100644 --- a/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdServiceTest.java +++ b/src/test/java/edu/unc/lib/boxc/migration/cdm/services/AspaceRefIdServiceTest.java @@ -158,6 +158,29 @@ public void generateFromHookIdRefIdCsvNoRefIdTest() throws Exception { } } + @Test + public void generateFromHookIdRefIdCsvWithZTest() throws Exception { + // export collection with -z at the end of the collection ID + testHelper.indexExportData(Paths.get("src/test/resources/findingaid_fields.csv"), "03883-z"); + service.setHookIdRefIdMapPath(Paths.get("src/test/resources/hookid_to_refid_map.csv")); + service.generateAspaceRefIdMappingFromHookIdRefIdCsv(); + + assertTrue(Files.exists(project.getAspaceRefIdMappingPath())); + try (CSVParser csvParser = parser()) { + List rows = csvParser.getRecords(); + assertEquals("0", rows.get(0).get(AspaceRefIdInfo.RECORD_ID_FIELD)); + assertEquals("03883_folder_5", rows.get(0).get(AspaceRefIdInfo.HOOK_ID_FIELD)); + assertEquals("8578708eda77e378b3a844a2166b815b", rows.get(0).get(AspaceRefIdInfo.REF_ID_FIELD)); + assertEquals("548", rows.get(1).get(AspaceRefIdInfo.RECORD_ID_FIELD)); + assertEquals("03883_folder_9", rows.get(1).get(AspaceRefIdInfo.HOOK_ID_FIELD)); + assertEquals("4c1196b46a06b21b1184fba0de1e84bd", rows.get(1).get(AspaceRefIdInfo.REF_ID_FIELD)); + assertEquals("549", rows.get(2).get(AspaceRefIdInfo.RECORD_ID_FIELD)); + assertEquals("03883_folder_9", rows.get(2).get(AspaceRefIdInfo.HOOK_ID_FIELD)); + assertEquals("4c1196b46a06b21b1184fba0de1e84bd", rows.get(2).get(AspaceRefIdInfo.REF_ID_FIELD)); + assertEquals(3, rows.size()); + } + } + @Test public void generateFromHookIdRefIdCsvNoContriDescriTest() throws Exception { testHelper.indexExportData(Paths.get("src/test/resources/monograph_fields.csv"), "monograph"); diff --git a/src/test/resources/descriptions/03883-z/index/description/desc.all b/src/test/resources/descriptions/03883-z/index/description/desc.all new file mode 100644 index 00000000..b45a606d --- /dev/null +++ b/src/test/resources/descriptions/03883-z/index/description/desc.all @@ -0,0 +1,225 @@ +Roy M. Brown Papers, 1924-1956 +03883-z +http://finding-aids.lib.unc.edu/03883/ +Roy M. Brown Papers, 1924-1956 and undated. +Folder 5: 1950-1956: Scan 25 +[Identification of item], in the Roy M. Brown Papers, #3883, Southern Historical Collection, The Wilson Library, University of North Carolina at Chapel Hill. +folder +folder_5 +03883_0005_0025.tif +03883_0005_0025.tif + + + + + + + + + + + + + + + + + +For copyright information or permissions questions, see our intellectual property statement http://www.lib.unc.edu/wilson/shc/dshc/ipstatement.html + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +Volume1/03883_0005_0025.tif +231.jp2 + + + + + +2012-02-03 +2012-02-03 +0 +Roy M. Brown Papers, 1924-1956 +03883-z +http://finding-aids.lib.unc.edu/03883/ +Roy M. Brown Papers, 1924-1956 and undated. +Folder 9: Reports and writings on social work: Scan 51 +[Identification of item], in the Roy M. Brown Papers, #3883, Southern Historical Collection, The Wilson Library, University of North Carolina at Chapel Hill. +folder +folder_9 +03883_0009_0051.tif +03883_0009_0051.tif + + + + + + + + + + + + + + + + + +For copyright information or permissions questions, see our intellectual property statement http://www.lib.unc.edu/wilson/shc/dshc/ipstatement.html + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +Volume1/03883_0009_0051.tif +711.jp2 + + + + + +2012-03-03 +2012-03-03 +548 +Roy M. Brown Papers, 1924-1956 +03883-z +http://finding-aids.lib.unc.edu/03883/ +Roy M. Brown Papers, 1924-1956 and undated. +Folder 9: Reports and writings on social work: Scan 51 +[Identification of item], in the Roy M. Brown Papers, #3883, Southern Historical Collection, The Wilson Library, University of North Carolina at Chapel Hill. +folder +folder_9 +03883_0009_0051.tif +03883_0009_0051.tif + + + + + + + + + + + + + + + + + +For copyright information or permissions questions, see our intellectual property statement http://www.lib.unc.edu/wilson/shc/dshc/ipstatement.html + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +Volume1/03883_0009_0051.tif +711.jp2 + + + + + +2012-04-03 +2012-04-03 +549 \ No newline at end of file