Let's go to production, weekend edition

This commit is contained in:
gexce
2017-11-10 14:09:09 +01:00
parent e53745e72c
commit 86f51a97ca
3 changed files with 25 additions and 26 deletions
@@ -48,7 +48,7 @@ public class Definitions {
fieldIDs = new HashMap<String, String>();
users = new HashMap<String, String>();
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));
@@ -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<Integer> entrySelection = new ArrayList<Integer>(Arrays.asList( /*71725, 71263, 71048, 70778, 70746, 70745, 70440, 70361, 70340, 70288, 70161, 70142, 63924, */63201, 57641, 56942 ));
private List<Integer> entrySelection = new ArrayList<Integer>(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<String> campaignGuids = new HashSet<String>();
// 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<MultiValueMap<String, Object>>(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();
}