new structure for campaign labels
This commit is contained in:
@@ -65,7 +65,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:\\";
|
||||
|
||||
@@ -104,7 +104,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
log.info("Read categories");
|
||||
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
||||
|
||||
// XXX
|
||||
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
requestFactory.setBufferRequestBody(false);
|
||||
fileTransferTemplate = new RestTemplate(requestFactory);
|
||||
@@ -126,7 +125,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
for (Classification yearClassification : campaignYears) {
|
||||
List<Classification> campaignClassifications = restTemplate.exchange(Definitions.adamHost + "/classification/" + yearClassification.id + "/children", HttpMethod.GET, adamHeadersEntity, ClassificationList.class).getBody().items;
|
||||
for (Classification campaignClassification : campaignClassifications) {
|
||||
//log.debug(yearClassification.name + ": " + campaignClassification.name + ", " + campaignClassification.labels[0].value + ", " + campaignClassification.id);
|
||||
Campaign campaign = new Campaign(campaignClassification.name, campaignClassification.labels[0].value, yearClassification.name);
|
||||
campaign.guid = campaignClassification.id;
|
||||
campaigns.add(campaign);
|
||||
@@ -142,6 +140,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
// continue;
|
||||
|
||||
|
||||
|
||||
log.info("GET entry " + id);
|
||||
|
||||
Entry entry = restTemplate.exchange(mamHost + "/rest/migration/entry/{id}", HttpMethod.GET, entity, Entry.class, id).getBody();
|
||||
@@ -171,7 +170,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
|
||||
while (openUploads.size() > 0) {
|
||||
log.debug("Sleeping...");
|
||||
TimeUnit.SECONDS.sleep(5); // XXX
|
||||
TimeUnit.SECONDS.sleep(10); // XXX
|
||||
|
||||
log.debug("Checking back on open uploads");
|
||||
attachOpenUploads();
|
||||
@@ -215,6 +214,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
List<Node> path = new LinkedList<Node>();
|
||||
|
||||
Node tmpNode = node;
|
||||
String currentBrand = null;
|
||||
while (tmpNode.id != CategoryTree.ROOT_NODE_ID) {
|
||||
if (tmpNode.id == 0) {
|
||||
log.info("RESULT Skipping entry " + entry.id + ": Node outside of category tree (" + node.toString() + ")");
|
||||
@@ -263,17 +263,16 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
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 XXX
|
||||
// if ((p.equals("Brand.General") && record.hasClassificationStartingWith("BusinessUnit.General")) ||
|
||||
// (p.equals("Brand.CAP.Others") && record.hasClassificationStartingWith("BusinessUnit.CAP")) ||
|
||||
// (p.equals("Brand.FAP.Others") && record.hasClassificationStartingWith("BusinessUnit.FAP")))
|
||||
|
||||
log.warn("Classification " + p + " not added, different brand already set");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
record.removeClassificationsStartingWith("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;
|
||||
}
|
||||
}
|
||||
|
||||
record.removeClassificationsStartingWith("Brand.");
|
||||
currentBrand = p.substring(p.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
if (p.startsWith("MediaType.")) {
|
||||
@@ -287,16 +286,22 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
record.removeClassificationsStartingWith("Brand.");
|
||||
String brandClassificationId = "Brand." + n.name.trim();
|
||||
record.addClassification(brandClassificationId);
|
||||
currentBrand = n.name.trim();
|
||||
}
|
||||
else if (n.action.equals("campaign")) {
|
||||
String campaignName = n.name;
|
||||
String campaignLabel = n.name;
|
||||
String campaignYear;
|
||||
if (n.parameter != null && !n.parameter.trim().equals("")) {
|
||||
campaignLabel = campaignLabel + " " + n.parameter;
|
||||
campaignYear = n.parameter.substring(1, 5);
|
||||
if (currentBrand != null)
|
||||
campaignLabel = currentBrand + " - " + campaignLabel + " " + n.parameter;
|
||||
else
|
||||
campaignLabel = campaignLabel + " " + n.parameter;
|
||||
} else {
|
||||
campaignYear = n.name.substring(0, 4);
|
||||
if (currentBrand != null)
|
||||
campaignLabel = currentBrand + " - " + campaignLabel;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -542,8 +547,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX E:\71725 wieder herstellen
|
||||
|
||||
filesForUpload.add(masterFile);
|
||||
hrefsForUpload.add(selectedDownload.href);
|
||||
}
|
||||
@@ -618,10 +621,9 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
UploadFileRecord fileRecord = new UploadFileRecord();
|
||||
fileRecord.addFile(reference.token, reference.isMaster);
|
||||
|
||||
log.debug("Attach uploaded file to " + reference.targetRecord);
|
||||
log.debug("Attach " + reference.filename + " to " + reference.targetRecord);
|
||||
HttpEntity<UploadFileRecord> httpEntity = new HttpEntity<UploadFileRecord>(fileRecord, adamHeaders);
|
||||
|
||||
// TODO E:\56942 wieder herstellen
|
||||
try {
|
||||
ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class);
|
||||
log.debug("Response: " + response.toString());
|
||||
|
||||
Reference in New Issue
Block a user