preparation for next step: checking existing campaigns via REST
This commit is contained in:
@@ -57,7 +57,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
|
|
||||||
static final String categoryJson = "C:\\Users\\gexce\\git\\mam-migration\\AH MAM Migration\\resources\\2017-10-19_categories.json";
|
static final String categoryJson = "C:\\Users\\gexce\\git\\mam-migration\\AH MAM Migration\\resources\\2017-10-19_categories.json";
|
||||||
static final String categoryMapping = "C:\\Users\\gexce\\git\\mam-migration\\AH MAM Migration\\resources\\Media_Assistant_Categories_131017_EDITED.csv";
|
static final String categoryMapping = "C:\\Users\\gexce\\git\\mam-migration\\AH MAM Migration\\resources\\Media_Assistant_Categories_131017_EDITED.csv";
|
||||||
static final String campaignList = "C:\\Temp\\Migration AH\\files\\campaigns.csv";
|
|
||||||
|
|
||||||
static final File entryLog = new File("C:\\Temp\\Migration AH\\files\\entry.log");
|
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 problemLog = new File("C:\\Temp\\Migration AH\\files\\problem.log");
|
||||||
@@ -83,16 +82,9 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
private List<String> locations = new ArrayList<String>();
|
private List<String> locations = new ArrayList<String>();
|
||||||
private CategoryTree mamCategoryTree;
|
private CategoryTree mamCategoryTree;
|
||||||
|
|
||||||
private CsvParserSettings parserSettings = new CsvParserSettings();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... strings) throws Exception {
|
public void run(String... strings) throws Exception {
|
||||||
|
|
||||||
parserSettings.getFormat().setLineSeparator("\r\n");
|
|
||||||
parserSettings.getFormat().setDelimiter(';');
|
|
||||||
parserSettings.getFormat().setCharToEscapeQuoteEscaping('"');
|
|
||||||
parserSettings.setHeaderExtractionEnabled(false);
|
|
||||||
|
|
||||||
log.info("Write log headers");
|
log.info("Write log headers");
|
||||||
FileUtils.writeStringToFile(entryLog, "Location" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
FileUtils.writeStringToFile(entryLog, "Location" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
||||||
FileUtils.writeStringToFile(problemLog, "entryId" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
FileUtils.writeStringToFile(problemLog, "entryId" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
|
||||||
@@ -101,7 +93,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
||||||
|
|
||||||
log.info("Read campaigns");
|
log.info("Read campaigns");
|
||||||
campaigns = readCsv(campaignList);
|
// TODO HIER GEHT'S WEITER - die vorhandenen Campaigns per REST aufrufen und in campaigns speichern
|
||||||
|
|
||||||
restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
|
restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
|
||||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
|
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
|
||||||
@@ -142,9 +134,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
// log.info("Deleted " + location + ": " + response.toString());
|
// log.info("Deleted " + location + ": " + response.toString());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
log.info("Write campaign list to " + campaignList);
|
|
||||||
writeCsv(campaigns, campaignList);
|
|
||||||
|
|
||||||
invalidateAdamToken();
|
invalidateAdamToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,23 +350,6 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
log.info("Logged out from adam API: " + response.toString());
|
log.info("Logged out from adam API: " + response.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String[]> readCsv(String csvFile) {
|
|
||||||
CsvParser parser = new CsvParser(parserSettings);
|
|
||||||
return parser.parseAll(new File(csvFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeCsv(List<String[]> contents, String csvFile) {
|
|
||||||
// FIXME Why oh why can't I just pass the contents list to writeRowsAndClose like here:
|
|
||||||
// https://github.com/uniVocity/univocity-parsers/blob/master/src/test/java/com/univocity/parsers/examples/WriterExamples.java
|
|
||||||
List<Object[]> csvOutputList;
|
|
||||||
csvOutputList = (List) contents;
|
|
||||||
|
|
||||||
CsvWriterSettings writerSettings = new CsvWriterSettings();
|
|
||||||
writerSettings.setFormat(parserSettings.getFormat());
|
|
||||||
CsvWriter writer = new CsvWriter(new File(csvFile), writerSettings);
|
|
||||||
writer.writeRowsAndClose(csvOutputList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* // Quoted "Z" to indicate UTC, no timezone offset private static SimpleDateFormat outputDateFormat = new
|
* // Quoted "Z" to indicate UTC, no timezone offset private static SimpleDateFormat outputDateFormat = new
|
||||||
* SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); private static SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
* SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); private static SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|||||||
Reference in New Issue
Block a user