new structure for campaign labels

This commit is contained in:
gexce
2017-11-09 15:33:17 +01:00
parent d44924d00b
commit af6aa17ed6
3 changed files with 33 additions and 25 deletions
@@ -12,6 +12,7 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
@@ -19,7 +20,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -40,9 +40,9 @@ public class EntryDownloader implements CommandLineRunner {
/**
* If true, files are downloaded. If false, only the IDs are written into the outputfile.
*/
private final boolean downloadFiles = true;
private final boolean downloadFiles = false;
File outputfile = new File("C:\\Temp\\Migration AH\\files\\entrylist_2017-11-07.txt");
File outputfile = new File("C:\\Temp\\Migration AH\\files\\entrylist_2017-11-09.txt");
@Value("${mam.auth}")
@@ -99,8 +99,14 @@ public class EntryDownloader implements CommandLineRunner {
if (!downloadFiles) {
// only create a list with all IDs
try {
FileUtils.writeStringToFile(outputfile, entrylist.entries[i].mediaAssistantId + "\n", Charset.forName("utf-8"), true);
} catch (IOException e) {
log.info("Get " + i + "/" + entrylist.entries.length);
TimeUnit.SECONDS.sleep(1); // XXX
int id = Integer.parseInt(entrylist.entries[i].mediaAssistantId);
Entry entry = restTemplate.exchange(mamHost + "/rest/migration/entry/{id}", HttpMethod.GET, entity, Entry.class, id).getBody();
String entryJson = jsonMapper.writeValueAsString(entry);
FileUtils.writeStringToFile(outputfile, id + separator + entryJson + "\n", Charset.forName("utf-8"), true);
} catch (Exception e) {
log.error("Could not get entry " + entrylist.entries[i].mediaAssistantId);
e.printStackTrace();
}
}