This commit is contained in:
gexce
2017-10-30 12:18:45 +01:00
parent dead0739f4
commit 8083dfc45c
6 changed files with 178 additions and 85 deletions
@@ -52,7 +52,7 @@ public class MamMigrationSelective implements CommandLineRunner {
static final String adamHost = "https://edam-q.bayer.com:2015";
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
private List<Integer> entrySelection = new ArrayList<Integer>(Arrays.asList( 72048, 60984 ));
private List<Integer> entrySelection = new ArrayList<Integer>(Arrays.asList( 63701, 63711, 43182 )); // 72048, 60984
static final String categoryJson = "resources/2017-10-19_categories.json";
static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv";
@@ -73,7 +73,7 @@ public class MamMigrationSelective implements CommandLineRunner {
HttpHeaders adamHeaders, mamHeaders;
HttpEntity<String> adamHeadersEntity;
// private SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
private SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
private SimpleDateFormat stringDate = new SimpleDateFormat("yyyy-MM-dd");
private ObjectMapper jsonMapper = new ObjectMapper();
@@ -85,7 +85,7 @@ public class MamMigrationSelective implements CommandLineRunner {
public void run(String... strings) throws Exception {
// XXX
readEntryIDsFromFile();
// readEntryIDsFromFile();
log.info("Write log headers for " + entryLog.getAbsolutePath());
FileUtils.writeStringToFile(entryLog, "Location" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
@@ -161,7 +161,7 @@ public class MamMigrationSelective implements CommandLineRunner {
Set<String> keywords = new HashSet<String>();
// globally applicable classifications
record.addClassification("MediaAssistant-Migration");
record.addClassification("Migration");
record.addClassification("Country.Global");
record.addClassification("Agencies.Bayer AH");
record.addClassification("Usage.Restricted");
@@ -209,31 +209,41 @@ public class MamMigrationSelective implements CommandLineRunner {
// Status "Released" is weaker than the other statuses
if (p.startsWith("Status.")) {
if (!p.equals("Status.Released"))
record.removeClassification("Status.Released");
else if (record.hasClassificationStartingWith("Status.Draft")
|| record.hasClassificationStartingWith("Status.Archived")) {
if (p.equals("Status.Released") && record.hasClassificationStartingWith("Status.")) {
log.warn("Classification Status.Released not added, different status already set");
continue;
}
else {
record.removeClassificationsStartingWith("Status.");
}
}
// Business unit "General" is weaker than the other business units
if (p.startsWith("BusinessUnit.")) {
record.removeClassification("BusinessUnit.CAP");
record.removeClassification("BusinessUnit.FAP");
record.removeClassification("BusinessUnit.General");
if (p.equals("BusinessUnit.General") && record.hasClassificationStartingWith("BusinessUnit.")) {
log.warn("Classification BusinessUnit.General not added, different business unit already set");
continue;
}
else {
record.removeClassificationsStartingWith("BusinessUnit.");
}
}
// Brand "General" is 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");
continue;
}
else {
record.removeClassification("Brand.General");
record.removeClassificationsStartingWith("Brand.");
}
}
if (p.startsWith("MediaType.")) {
record.removeClassification("MediaType.");
}
record.addClassification(p);
}
}
@@ -322,6 +332,13 @@ public class MamMigrationSelective implements CommandLineRunner {
}
// Set Status.Draft for entries with stateId == 5 (Created) or 4 (Assigned)
if (entry.stateId == 4 || entry.stateId == 5) {
log.debug("Entry has status " + entry.stateId + ", setting record status to 'Draft'");
record.removeClassification("Status.Released");
record.addClassification("Status.Draft");
}
// Fields
if (entry.name.get("en") != null) {
record.addField("byr_Title", entry.name.get("en"));
@@ -331,6 +348,8 @@ public class MamMigrationSelective implements CommandLineRunner {
record.addField("byr_Title", "No title");
}
record.addField("byr_ah_deliveryDate", isoDate.format(entry.creationDate));
// Project lead
if (entry.user != null && entry.user.get("id") != null) {
if (Definitions.users.get(entry.user.get("id")) != null) {