EntryProcessor
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package com.bayer.edam.migration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.LineIterator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bayer.edam.migration.mam.Entry;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class EntryProcessor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EntryProcessor.class);
|
||||
|
||||
static final String fieldSeparator = "|~|";
|
||||
|
||||
private static final File entriesFile = new File("C:\\Temp\\Migration AH\\Entry Export\\migration.csv");
|
||||
|
||||
private ObjectMapper jsonMapper = new ObjectMapper();
|
||||
|
||||
public EntryProcessor() throws IOException {
|
||||
LineIterator iter = FileUtils.lineIterator(entriesFile, "UTF-8");
|
||||
|
||||
// skip header
|
||||
iter.next();
|
||||
|
||||
HashSet<String> orgSet = new HashSet<String>();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
String line = iter.next();
|
||||
line = line.substring(line.lastIndexOf(fieldSeparator) + fieldSeparator.length());
|
||||
Entry entry = jsonMapper.readValue(line, Entry.class);
|
||||
if (entry.copyright == null || entry.copyright.organization == null || !entry.copyright.organization.get("id").equals("3740")) {
|
||||
|
||||
String orgId = null;
|
||||
|
||||
if (entry.copyright != null && entry.copyright.organization != null) {
|
||||
orgId = entry.copyright.organization.get("id");
|
||||
orgSet.add(orgId);
|
||||
}
|
||||
|
||||
|
||||
log.warn("Entry " + entry.id + ": License Holder is not set to 'Bayer Animal Health GmbH' " + orgId);
|
||||
}
|
||||
}
|
||||
|
||||
for (String orgId : orgSet) {
|
||||
log.info(orgId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
new EntryProcessor();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user