From 86f51a97cacecd1eaa495e2757a9b71d1ab15df1 Mon Sep 17 00:00:00 2001 From: gexce Date: Fri, 10 Nov 2017 14:09:09 +0100 Subject: [PATCH] Let's go to production, weekend edition --- .../resources/application.properties | 2 +- .../com/bayer/edam/migration/Definitions.java | 2 +- .../edam/migration/MamMigrationSelective.java | 47 +++++++++---------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/AH MAM Migration/resources/application.properties b/AH MAM Migration/resources/application.properties index 024b527..69fca94 100644 --- a/AH MAM Migration/resources/application.properties +++ b/AH MAM Migration/resources/application.properties @@ -2,4 +2,4 @@ logging.level.com.bayer=DEBUG #logging.level.com.bayer.edam.migration.interceptors=INFO logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n -logging.file=application_2017-11-10_PROD.log +logging.file=application_2017-11-10_Weekend_PROD.log diff --git a/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java b/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java index 4b3c378..129b539 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java @@ -48,7 +48,7 @@ public class Definitions { fieldIDs = new HashMap(); users = new HashMap(); - classifications.put("Migration.Test", new WriteClassification("f1d058987a3043d5b021a819007ff3c0", 1)); + classifications.put("Migration.Test", new WriteClassification("704deb515e024874a4a0a82700a4dc78", 1)); // XXX QA values // classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1)); diff --git a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java index 78eaca6..cad1464 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java @@ -66,7 +66,7 @@ public class MamMigrationSelective implements CommandLineRunner { private static final Logger log = LoggerFactory.getLogger(MamMigrationSelective.class); static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com"; - private List entrySelection = new ArrayList(Arrays.asList( /*71725, 71263, 71048, 70778, 70746, 70745, 70440, 70361, 70340, 70288, 70161, 70142, 63924, */63201, 57641, 56942 )); + private List entrySelection = new ArrayList(Arrays.asList( 71725, 71263, 71048, 70778, 70746, 70745, 70440, 70361, 70340, 70288, 70161, 70142, 63924, 63201, 57641, 56942 )); static final String fileCache = "E:\\"; @@ -74,8 +74,8 @@ public class MamMigrationSelective implements CommandLineRunner { static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv"; // XXX -// static final String entryListPath = "resources/entrylist_2017-10-25.txt"; - static final String entryListPath = "resources/lottery.txt"; + static final String entryListPath = "resources/entrylist_2017-10-25.txt"; +// static final String entryListPath = "resources/lottery.txt"; @Value("${mam.auth}") private String mamAuth; @@ -140,9 +140,9 @@ public class MamMigrationSelective implements CommandLineRunner { for (int id : entrySelection) { // XXX - // if needed start from a certain ID - if (id > 70746) - continue; +// // if needed start from a certain ID +// if (id == 70440) +// continue; @@ -191,7 +191,7 @@ public class MamMigrationSelective implements CommandLineRunner { HashSet campaignGuids = new HashSet(); // XXX - record.addClassification("Migration.Test"); +// record.addClassification("Migration.Test"); // globally applicable classifications record.addClassification("Migration"); @@ -244,7 +244,8 @@ 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 " + p + " not added, different status already set"); + if (!record.hasClassificationStartingWith("Status.Released")) + log.warn("Classification " + p + " not added, different status already set"); continue; } else { @@ -255,7 +256,8 @@ 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 " + p + " not added, different business unit already set"); + if (!record.hasClassificationStartingWith("BusinessUnit.General")) + log.warn("Classification " + p + " not added, different business unit already set"); continue; } else { @@ -265,16 +267,16 @@ public class MamMigrationSelective implements CommandLineRunner { // Brands "General" and "Others" are weaker than the other brands if (p.startsWith("Brand.")) { - if ((p.equals("Brand.General") || p.equals("Brand.CAP.Others") || p.equals("Brand.FAP.Others")) - && record.hasClassificationStartingWith("Brand.")) { - - // Check if the brand matches the business unit - if (record.hasClassificationStartingWith("Brand.General") - && !record.hasClassificationStartingWith("BusinessUnit.General")) { - log.warn("Classification " + p + " not added, different brand already set"); - continue; - } - } +// if ((p.equals("Brand.General") || p.equals("Brand.CAP.Others") || p.equals("Brand.FAP.Others")) +// && record.hasClassificationStartingWith("Brand.")) { +// +// // FIXME Check if the brand matches the business unit +// if (record.hasClassificationStartingWith("Brand.General") +// && !record.hasClassificationStartingWith("BusinessUnit.General")) { +// log.warn("Classification " + p + " not added, different brand already set"); +// continue; +// } +// } record.removeClassificationsStartingWith("Brand."); currentBrand = p.substring(p.lastIndexOf('.')); @@ -510,12 +512,10 @@ public class MamMigrationSelective implements CommandLineRunner { catch (HttpStatusCodeException hsce) { log.error("RESULT Skipping entry " + entry.id + ": Error while creating record " + hsce.getStatusCode().toString()); log.error(hsce.getResponseBodyAsString()); - log.error(hsce.getRootCause().toString()); hsce.printStackTrace(); } catch (ResourceAccessException rae) { log.error("RESULT Could not create record for entry " + entry.id + ": " + rae.getMessage()); - log.error(rae.getRootCause().toString()); rae.printStackTrace(); } } @@ -591,7 +591,7 @@ public class MamMigrationSelective implements CommandLineRunner { new HttpEntity>(parameters, adamUploadHeaders), UploadResult.class).getBody(); if (result.token != null) { - log.debug("Storing upload token " + result.token); + log.debug("Storing upload token " + result.token + "(" + isMaster + ") for " + recordLocation + " from entry " + entry.id); UploadReference reference = new UploadReference(); reference.targetRecord = recordLocation; reference.isMaster = isMaster; @@ -600,7 +600,7 @@ public class MamMigrationSelective implements CommandLineRunner { openUploads.add(reference); } else if (result.uri != null) { - log.debug("Storing upload reference " + result.uri); + log.debug("Storing upload reference " + result.uri + "(" + isMaster + ") for " + recordLocation + " from entry " + entry.id); UploadReference reference = new UploadReference(); reference.targetRecord = recordLocation; reference.isMaster = isMaster; @@ -615,7 +615,6 @@ public class MamMigrationSelective implements CommandLineRunner { } catch (ResourceAccessException rae) { log.error("Could not upload " + file.getAbsolutePath() + "(" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rae.getMessage()); - log.error(rae.getRootCause().toString()); rae.printStackTrace(); }