This repository has been archived on 2026-07-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mam-migration/AH MAM Migration/src/com/bayer/edam/migration/EntryProcessor.java
T
2017-09-21 15:02:59 +02:00

66 lines
1.7 KiB
Java

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();
}
}
}