Lottery upload
This commit is contained in:
@@ -71,6 +71,10 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
|
||||
static final String categoryJson = "resources/2017-10-19_categories.json";
|
||||
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";
|
||||
|
||||
@Value("${mam.auth}")
|
||||
private String mamAuth;
|
||||
@@ -99,7 +103,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
public void run(String... strings) throws Exception {
|
||||
|
||||
// XXX
|
||||
// readEntryIDsFromFile();
|
||||
readEntryIDsFromFile();
|
||||
|
||||
log.info("Read categories");
|
||||
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
||||
@@ -683,7 +687,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
}
|
||||
|
||||
private void readEntryIDsFromFile() throws IOException {
|
||||
File entryIdListFile = new File("resources/entrylist_2017-10-25.txt");
|
||||
File entryIdListFile = new File(entryListPath);
|
||||
log.debug("Reading entry IDs from " + entryIdListFile.getAbsolutePath());
|
||||
List<String> entryIdList = FileUtils.readLines(entryIdListFile, Charset.forName("utf-8"));
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.bayer.edam.migration.attic;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bayer.edam.migration.EntryDownloader;
|
||||
|
||||
public class Lottery {
|
||||
private static final Logger log = LoggerFactory.getLogger(Lottery.class);
|
||||
|
||||
private static final String idFile = "C:\\Users\\gexce\\git\\mam-migration\\AH MAM Migration\\resources\\entrylist_2017-10-25.txt";
|
||||
private static final File outputFile = new File("lottery.txt");
|
||||
|
||||
private static final String[] entrySelection = new String[] {"00071725", "00071263", "00071048", "00070778", "00070746", "00070745", "00070440", "00070361", "00070340",
|
||||
"00070288", "00070161", "00070142", "00063924", "00063201", "00057641", "00056942"};
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
List<String> lines = FileUtils.readLines(new File(idFile), "UTF-8");
|
||||
List<Integer> drawn = new ArrayList<Integer>();
|
||||
Random generator = new Random();
|
||||
|
||||
for (int i = 0; i < entrySelection.length; i++) {
|
||||
Integer id = Integer.parseInt(entrySelection[i]);
|
||||
drawn.add(id);
|
||||
FileUtils.writeStringToFile(outputFile, entrySelection[i] + "\n", Charset.forName("utf-8"), true);
|
||||
}
|
||||
|
||||
log.info("Start draw");
|
||||
for (int i = 0; i < 150; i++) {
|
||||
int ticket;
|
||||
do {
|
||||
ticket = generator.nextInt(lines.size());
|
||||
} while (drawn.contains(ticket));
|
||||
|
||||
drawn.add(ticket);
|
||||
if (lines.get(ticket).length() > 0)
|
||||
FileUtils.writeStringToFile(outputFile, lines.get(ticket) + "\n", Charset.forName("utf-8"), true);
|
||||
log.info(i + "...");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user