diff --git a/orcid-persistence/src/main/resources/db/updates/create_email_domain_mapping_tables.xml b/orcid-persistence/src/main/resources/db/updates/create_email_domain_mapping_tables.xml
index 5e5832934af..bd23c345b21 100644
--- a/orcid-persistence/src/main/resources/db/updates/create_email_domain_mapping_tables.xml
+++ b/orcid-persistence/src/main/resources/db/updates/create_email_domain_mapping_tables.xml
@@ -48,7 +48,7 @@
create index email_domain_domain_index on email_domain(email_domain);
- create index email_domain_domain_index on email_domain(ror);
+ create index email_domain_ror_id_index on email_domain(ror_id);
diff --git a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/loader/cli/EmailDomainToRorLoader.java b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/loader/cli/EmailDomainToRorLoader.java
index 6260f2e7adc..efd4cc6319a 100644
--- a/orcid-scheduler-web/src/main/java/org/orcid/scheduler/loader/cli/EmailDomainToRorLoader.java
+++ b/orcid-scheduler-web/src/main/java/org/orcid/scheduler/loader/cli/EmailDomainToRorLoader.java
@@ -5,12 +5,12 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.AbstractMap;
-import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.orcid.core.common.manager.EmailDomainManager;
import org.slf4j.Logger;
@@ -30,7 +30,7 @@ public class EmailDomainToRorLoader {
private EmailDomainManager emailDomainManager;
List> csvData;
- List invalidDomains = new ArrayList();
+ Set invalidDomains = new HashSet();
Map map = new HashMap();
@@ -42,6 +42,7 @@ public EmailDomainToRorLoader(String filePath) {
public void execute() throws IOException {
load(this.filePath);
processCsvData();
+ storeDomainToRorMap();
}
private void init(String filePath) {
@@ -106,15 +107,23 @@ private void processCsvData() {
private void storeDomainToRorMap() {
for(DomainToRorMap element : map.values()) {
+ LOG.debug("Processing domain {}", element.getDomain());
// If the domain has only one entry with no parent, store that one
if(element.getIdsWithNoParent().size() == 1) {
-
+ emailDomainManager.createOrUpdateEmailDomain(element.getDomain(), element.getIdsWithNoParent().get(0));
} else if(element.getIdsWithParent().size() == 1) {
// Else, if the domain has only one entry with parent, store that one
+ emailDomainManager.createOrUpdateEmailDomain(element.getDomain(), element.getIdsWithParent().get(0));
} else {
// Else log a warning because there is no way to provide a suggestion
+ invalidDomains.add(element.getDomain());
}
}
+
+ LOG.warn("The following domains couldn't be mapped");
+ for(String invalidDomain : invalidDomains) {
+ LOG.warn("{}", invalidDomain);
+ }
}
private class DomainToRorMap {
@@ -131,6 +140,7 @@ public String getDomain() {
}
public void addIdWithParent(String rorId) {
+ LOG.debug("Domain {} adding {} with parent flag", this.domain, rorId);
idsWithParent.add(rorId);
}
@@ -139,6 +149,7 @@ public List getIdsWithParent() {
}
public void addIdWithNoParent(String rorId) {
+ LOG.debug("Domain {} adding {} with NO parent flag", this.domain, rorId);
idsWithNoParent.add(rorId);
}
@@ -146,4 +157,10 @@ public List getIdsWithNoParent() {
return this.idsWithNoParent;
}
}
+
+ public static void main(String[] args) throws IOException {
+ String filePath = args[0];
+ EmailDomainToRorLoader edl = new EmailDomainToRorLoader(filePath);
+ edl.execute();
+ }
}