Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void closeCsv() {
* @param isSingleItem whether this work is a CDM single item type
* @throws IOException
*/
public void addWorkRow(String cdmObjectId, String boxcWorkId, int childCount, boolean isSingleItem)
public void addWorkRow(String cdmObjectId, String boxcWorkId, int childCount, boolean isSingleItem, String sipId)
throws IOException {
if (!enabled) {
return;
Expand All @@ -129,7 +129,7 @@ public void addWorkRow(String cdmObjectId, String boxcWorkId, int childCount, bo
}

addRow(cdmObjectId, cdmUrl, objType, boxcUrl, boxcTitle, matchingValue, sourceFile,
null, parentUrl, parentTitle, childCount, null, null);
null, parentUrl, parentTitle, childCount, sipId, null, null);
}

/**
Expand All @@ -142,7 +142,7 @@ public void addWorkRow(String cdmObjectId, String boxcWorkId, int childCount, bo
* @throws IOException
*/
public void addFileRow(String fileCdmId, String parentCdmId, String boxcWorkId, String boxcFileId,
boolean isSingleItem)
boolean isSingleItem, String sipId)
throws IOException {
if (!enabled) {
return;
Expand All @@ -165,14 +165,14 @@ public void addFileRow(String fileCdmId, String parentCdmId, String boxcWorkId,
}

addRow(fileCdmId, cdmUrl, objType, boxcUrl, boxcTitle, matchingValue, sourceFile,
null, parentUrl, parentTitle, null, null, null);
null, parentUrl, parentTitle, null, sipId, null, null);
}

protected void addRow(String cdmId, String cdmUrl, String objType, String boxcUrl, String boxcTitle,
String matchingValue, String sourceFile, String verified, String parentUrl,
String parentTitle, Integer childCount, String parentCollUrl, String parentCollTitle) throws IOException {
String parentTitle, Integer childCount, String sipId, String parentCollUrl, String parentCollTitle) throws IOException {
csvPrinter.printRecord(cdmId, cdmUrl, objType, boxcUrl, boxcTitle, matchingValue, sourceFile,
verified, parentUrl, parentTitle, childCount, parentCollUrl, parentCollTitle);
verified, parentUrl, parentTitle, childCount, sipId, parentCollUrl, parentCollTitle);
}

private String buildCdmUrl(String cdmObjectId, boolean isWorkObject, boolean isSingleItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected List<PID> addChildObjects() throws IOException {
PID filePid = addFileObject(fileCdmId, cdmCreated, sourceMapping);
addChildDescription(fileCdmId, filePid);
postMigrationReportService.addFileRow(fileCdmId, cdmId, workPid.getId(),
filePid.getId(), isSingleItem());
filePid.getId(), isSingleItem(), sipId);

childPids.add(filePid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class WorkGenerator {

protected String cdmId;
protected String cdmCreated;

protected String sipId;
protected PID workPid;
protected Bag workBag;
protected List<PID> fileObjPids;
Expand Down Expand Up @@ -119,9 +119,10 @@ protected void generateWork() throws IOException {

// Copy description to SIP
copyDescriptionToSip(workPid, expDescPath);
sipId = destEntry.getDepositPid().getId();

fileObjPids = addChildObjects();
postMigrationReportService.addWorkRow(cdmId, workPid.getId(), fileObjPids.size(), isSingleItem());
postMigrationReportService.addWorkRow(cdmId, workPid.getId(), fileObjPids.size(), isSingleItem(), sipId);
}

protected List<PID> addChildObjects() throws IOException {
Expand All @@ -130,7 +131,7 @@ protected List<PID> addChildObjects() throws IOException {
// in a single file object, the cdm id refers to the new work, so add suffix to reference the child file
addChildDescription(cdmId + "/original_file", fileObjectPid);
postMigrationReportService.addFileRow(cdmId + "/original_file", cdmId, workPid.getId(),
fileObjectPid.getId(), isSingleItem());
fileObjectPid.getId(), isSingleItem(), sipId);
return Collections.singletonList(fileObjectPid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ public class PostMigrationReportConstants {
public static final String VERIFIED_HEADER = "verified";
public static final String PARENT_COLL_URL_HEADER = "parent_collection_url";
public static final String PARENT_COLL_TITLE_HEADER = "parent_collection_title";
public static final String SIP_ID = "sip_id";
public static final String RECORD_PATH = "record/";
public static final String API_PATH = "api/" + RECORD_PATH;

public static final String[] CSV_HEADERS = new String[] {
"cdm_id", "cdm_url", "boxc_obj_type", "boxc_url", "boxc_title", "matching_value", "source_file",
VERIFIED_HEADER, "boxc_parent_work_url", "boxc_parent_work_title", "children_count", PARENT_COLL_URL_HEADER,
PARENT_COLL_TITLE_HEADER };
VERIFIED_HEADER, "boxc_parent_work_url", "boxc_parent_work_title", "children_count",
SIP_ID, PARENT_COLL_URL_HEADER, PARENT_COLL_TITLE_HEADER };
public static final CSVFormat CSV_OUTPUT_FORMAT = CSVFormat.Builder.create()
.setHeader(CSV_HEADERS)
.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void setup() throws Exception {
public void reportCountWorksTest() throws Exception {
reportGenerator.init();
reportGenerator.addRow("25", CDM_URL_1, "Work", BOXC_URL_1, "Redoubt C",
null, null, null, "", "", 1, null, null);
null, null, null, "", "", 1, null, null, null);
reportGenerator.addRow("26", CDM_URL_2, "File", BOXC_URL_2, "A file",
null, null, null, BOXC_URL_1, "Redoubt C", null, null, null);
null, null, null, BOXC_URL_1, "Redoubt C", null, null, null, null);
reportGenerator.closeCsv();

long numWorks = service.countWorks();
Expand All @@ -64,11 +64,11 @@ public void reportCountWorksTest() throws Exception {
public void reportCountFilesTest() throws Exception {
reportGenerator.init();
reportGenerator.addRow("25", CDM_URL_1, "Work", BOXC_URL_1, "Redoubt C",
null, null, null, "", "", 1, null, null);
null, null, null, "", "", 1, null, null, null);
reportGenerator.addRow("26", CDM_URL_2, "File", BOXC_URL_2, "A file",
null, null, null, BOXC_URL_1, "Redoubt C", null, null, null);
null, null, null, BOXC_URL_1, "Redoubt C", null, null,null, null);
reportGenerator.addRow("27", CDM_URL_3, "File", BOXC_URL_3, "A file",
null, null, null, BOXC_URL_1, "Redoubt C", null, null, null);
null, null, null, BOXC_URL_1, "Redoubt C", null, null,null, null);
reportGenerator.closeCsv();

long numFiles = service.countFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static edu.unc.lib.boxc.migration.cdm.test.PostMigrationReportTestHelper.assertContainsRow;
import static edu.unc.lib.boxc.migration.cdm.test.PostMigrationReportTestHelper.parseReport;
import static edu.unc.lib.boxc.migration.cdm.util.PostMigrationReportConstants.SIP_ID;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.MockitoAnnotations.openMocks;

Expand Down Expand Up @@ -72,8 +73,8 @@ public void addSingleItemTest() throws Exception {
writeSourceFileCsv(mappingBody("25,," + srcPath1 +","));
testHelper.populateDescriptions("gilmer_mods1.xml");

service.addWorkRow("25", BOXC_ID_1, 1, true);
service.addFileRow("25/original_file", "25", BOXC_ID_1, BOXC_ID_2, true);
service.addWorkRow("25", BOXC_ID_1, 1, true, SIP_ID);
service.addFileRow("25/original_file", "25", BOXC_ID_1, BOXC_ID_2, true, SIP_ID);
service.closeCsv();

var rows = parseReport(project);
Expand All @@ -88,6 +89,7 @@ public void addSingleItemTest() throws Exception {
"",
"",
"1",
SIP_ID,
"",
"");
assertContainsRow(rows, "25/original_file",
Expand All @@ -101,6 +103,7 @@ public void addSingleItemTest() throws Exception {
BOXC_URL_1,
"Redoubt C",
"",
SIP_ID,
"",
"");
}
Expand All @@ -113,8 +116,8 @@ public void addSingleItemWithFileDescTest() throws Exception {
writeSourceFileCsv(mappingBody("25,," + srcPath1 +","));
testHelper.populateDescriptions("gilmer_mods1.xml", "gilmer_mods_children.xml");

service.addWorkRow("25", BOXC_ID_1, 1, true);
service.addFileRow("25/original_file", "25", BOXC_ID_1, BOXC_ID_2, true);
service.addWorkRow("25", BOXC_ID_1, 1, true, SIP_ID);
service.addFileRow("25/original_file", "25", BOXC_ID_1, BOXC_ID_2, true, SIP_ID);
service.closeCsv();

var rows = parseReport(project);
Expand All @@ -129,6 +132,7 @@ public void addSingleItemWithFileDescTest() throws Exception {
"",
"",
"1",
SIP_ID,
"",
"");
assertContainsRow(rows, "25/original_file",
Expand All @@ -142,6 +146,7 @@ public void addSingleItemWithFileDescTest() throws Exception {
BOXC_URL_1,
"Redoubt C",
"",
SIP_ID,
"",
"");
}
Expand All @@ -155,9 +160,9 @@ public void addGroupedTest() throws Exception {
writeSourceFileCsv(mappingBody("26,," + srcPath1 +",", "27,," + srcPath2 +","));
testHelper.populateDescriptions("grouped_mods.xml");

service.addWorkRow("grp:groupa:group1", BOXC_ID_1, 2, false);
service.addFileRow("26", "grp:groupa:group1", BOXC_ID_1, BOXC_ID_2, false);
service.addFileRow("27", "grp:groupa:group1", BOXC_ID_1, BOXC_ID_3, false);
service.addWorkRow("grp:groupa:group1", BOXC_ID_1, 2, false, SIP_ID);
service.addFileRow("26", "grp:groupa:group1", BOXC_ID_1, BOXC_ID_2, false, SIP_ID);
service.addFileRow("27", "grp:groupa:group1", BOXC_ID_1, BOXC_ID_3, false, SIP_ID);
service.closeCsv();

var rows = parseReport(project);
Expand All @@ -172,6 +177,7 @@ public void addGroupedTest() throws Exception {
"",
"",
"2",
SIP_ID,
"",
"");
assertContainsRow(rows, "26",
Expand All @@ -185,6 +191,7 @@ public void addGroupedTest() throws Exception {
BOXC_URL_1,
"Folder Group 1",
"",
SIP_ID,
"",
"");
assertContainsRow(rows, "27",
Expand All @@ -198,6 +205,7 @@ public void addGroupedTest() throws Exception {
BOXC_URL_1,
"Folder Group 1",
"",
SIP_ID,
"",
"");
}
Expand All @@ -212,9 +220,9 @@ public void addCompoundTest() throws Exception {
descriptionsService.generateDocuments(true);
descriptionsService.expandDescriptions();

service.addWorkRow("605", BOXC_ID_1, 2, false);
service.addFileRow("602", "605", BOXC_ID_1, BOXC_ID_2, false);
service.addFileRow("603", "605", BOXC_ID_1, BOXC_ID_3, false);
service.addWorkRow("605", BOXC_ID_1, 2, false, SIP_ID);
service.addFileRow("602", "605", BOXC_ID_1, BOXC_ID_2, false, SIP_ID);
service.addFileRow("603", "605", BOXC_ID_1, BOXC_ID_3, false, SIP_ID);
service.closeCsv();

var rows = parseReport(project);
Expand All @@ -229,6 +237,7 @@ public void addCompoundTest() throws Exception {
"",
"",
"2",
SIP_ID,
"",
"");
assertContainsRow(rows, "602",
Expand All @@ -242,6 +251,7 @@ public void addCompoundTest() throws Exception {
BOXC_URL_1,
"Tiffany's pillbox commemorating UNC's bicentennial (closed, in box)",
"",
SIP_ID,
"",
"");
assertContainsRow(rows, "603",
Expand All @@ -255,6 +265,7 @@ public void addCompoundTest() throws Exception {
BOXC_URL_1,
"Tiffany's pillbox commemorating UNC's bicentennial (closed, in box)",
"",
SIP_ID,
"",
"");
}
Expand All @@ -272,8 +283,8 @@ public void addSingleItemNonCdmProjectTest() throws Exception {
writeSourceFileCsv(mappingBody("25,," + srcPath1 +","));
testHelper.populateDescriptions("gilmer_mods1.xml");

service.addWorkRow("25", BOXC_ID_1, 1, true);
service.addFileRow("25/original_file", "25", BOXC_ID_1, BOXC_ID_2, true);
service.addWorkRow("25", BOXC_ID_1, 1, true, SIP_ID);
service.addFileRow("25/original_file", "25", BOXC_ID_1, BOXC_ID_2, true, SIP_ID);
service.closeCsv();

assertFalse(Files.exists(project.getPostMigrationReportPath()));
Expand Down
Loading