Check-in Monday: Excel updates, Baytril, delivery date, drafts
This commit is contained in:
@@ -57,8 +57,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
static final String categoryJson = "resources/2017-10-19_categories.json";
|
||||
static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv";
|
||||
|
||||
static final File entryLog = new File("C:\\Temp\\Migration AH\\files\\entry.log");
|
||||
static final File problemLog = new File("C:\\Temp\\Migration AH\\files\\problem.log");
|
||||
static final File entryLog = new File("entry.log");
|
||||
|
||||
static final String fieldSeparator = "|~|";
|
||||
static final String lineSeparator = "\r\n";
|
||||
@@ -88,9 +87,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
// readEntryIDsFromFile();
|
||||
|
||||
log.info("Write log headers for " + entryLog.getAbsolutePath());
|
||||
FileUtils.writeStringToFile(entryLog, "Location" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
||||
log.info("Write log headers for " + problemLog.getAbsolutePath());
|
||||
FileUtils.writeStringToFile(problemLog, "entryId" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
||||
FileUtils.writeStringToFile(entryLog, "entryId" + fieldSeparator + "Location" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
||||
|
||||
log.info("Read categories");
|
||||
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
||||
@@ -210,7 +207,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
// Status "Released" is weaker than the other statuses
|
||||
if (p.startsWith("Status.")) {
|
||||
if (p.equals("Status.Released") && record.hasClassificationStartingWith("Status.")) {
|
||||
log.warn("Classification Status.Released not added, different status already set");
|
||||
log.warn("Classification " + p + " not added, different status already set");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@@ -221,7 +218,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
// Business unit "General" is weaker than the other business units
|
||||
if (p.startsWith("BusinessUnit.")) {
|
||||
if (p.equals("BusinessUnit.General") && record.hasClassificationStartingWith("BusinessUnit.")) {
|
||||
log.warn("Classification BusinessUnit.General not added, different business unit already set");
|
||||
log.warn("Classification " + p + " not added, different business unit already set");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@@ -229,10 +226,10 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
}
|
||||
}
|
||||
|
||||
// Brand "General" is weaker than the other brands
|
||||
// Brands "General" and "Others" are weaker than the other brands
|
||||
if (p.startsWith("Brand.")) {
|
||||
if (p.equals("Brand.General") && record.hasClassificationStartingWith("Brand.")) {
|
||||
log.warn("Classification Brand.General not added, different brand already set");
|
||||
if ((p.equals("Brand.General") || p.equals("Brand.CAP.Others") || p.equals("Brand.FAP.Others"))&& record.hasClassificationStartingWith("Brand.")) {
|
||||
log.warn("Classification " + p + " not added, different brand already set");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@@ -244,10 +241,15 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
record.removeClassification("MediaType.");
|
||||
}
|
||||
|
||||
if (p.startsWith("Motive.")) {
|
||||
record.removeClassification("Motive.");
|
||||
}
|
||||
|
||||
record.addClassification(p);
|
||||
}
|
||||
}
|
||||
else if (n.action.equals("brand")) {
|
||||
record.removeClassificationsStartingWith("Brand.");
|
||||
String brandClassificationId = "Brand." + n.name.trim();
|
||||
record.addClassification(brandClassificationId);
|
||||
}
|
||||
@@ -348,7 +350,8 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
record.addField("byr_Title", "No title");
|
||||
}
|
||||
|
||||
record.addField("byr_ah_deliveryDate", isoDate.format(entry.creationDate));
|
||||
if (entry.creationDate != null)
|
||||
record.addField("byr_ah_deliveryDate", isoDate.format(entry.creationDate));
|
||||
|
||||
// Project lead
|
||||
if (entry.user != null && entry.user.get("id") != null) {
|
||||
@@ -382,6 +385,15 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
if (entry.creationDate != null)
|
||||
migrationDescription += "\nDate of Issue: " + stringDate.format(entry.creationDate);
|
||||
|
||||
if (entry.categories.size() == 1)
|
||||
migrationDescription += "\nCategory:";
|
||||
else
|
||||
migrationDescription += "\nCategories:";
|
||||
for (int categoryId : entry.categories) {
|
||||
migrationDescription += "\n" + mamCategoryTree.getNode(categoryId).toString();
|
||||
}
|
||||
|
||||
|
||||
description += migrationDescription;
|
||||
record.addField("byr_ah_description", description);
|
||||
|
||||
@@ -422,13 +434,12 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
URI location = restTemplate.postForLocation(adamHost + "/records", httpEntity, UploadRecord.class);
|
||||
log.info("RESULT Entry " + entry.id + " migrated to record " + location);
|
||||
|
||||
FileUtils.writeStringToFile(entryLog, location.toString() + fieldSeparator + entryJson + lineSeparator,
|
||||
FileUtils.writeStringToFile(entryLog, entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson + lineSeparator,
|
||||
Charset.forName("utf-8"), true);
|
||||
}
|
||||
catch (HttpStatusCodeException hsce) {
|
||||
log.error("RESULT Skipping entry " + entry.id + ": Error while creating record " + hsce.getStatusCode().toString());
|
||||
log.error(hsce.getResponseBodyAsString());
|
||||
FileUtils.writeStringToFile(problemLog, entry.id + fieldSeparator + entryJson + lineSeparator, Charset.forName("utf-8"), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user