From d7e07eed9d97a449b5e867d9ab93e4380ec54e75 Mon Sep 17 00:00:00 2001 From: amontenegro Date: Fri, 3 Nov 2023 14:45:52 -0600 Subject: [PATCH] Is there is more than one org with no parent, we should not suggest any org for that domain --- .../loader/cli/EmailDomainToRorLoader.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) 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 8037f5d62d0..7dce97592fa 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 @@ -7,10 +7,8 @@ import java.nio.file.Paths; 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.orcid.core.common.manager.impl.EmailDomainManagerImpl.STATUS; @@ -30,11 +28,11 @@ public class EmailDomainToRorLoader { private String filePath; private EmailDomainManager emailDomainManager; private List> csvData; - private Set invalidDomains = new HashSet(); private Map map = new HashMap(); private int updatedEntries = 0; private int createdEntries = 0; + private int invalidEntires = 0; public EmailDomainToRorLoader(String filePath) { this.filePath = filePath; @@ -123,8 +121,8 @@ private void storeDomainToRorMap() { } else if (STATUS.UPDATED.equals(s)) { updatedEntries++; } - } else if(element.getIdsWithParent().size() == 1) { - // Else, if the domain has only one entry with parent, store that one + } else if(element.getIdsWithNoParent().isEmpty() && element.getIdsWithParent().size() == 1) { + // Else, if the domain doesn't have an org with no parents and only have one entry with parent, store that one STATUS s = emailDomainManager.createOrUpdateEmailDomain(element.getDomain(), element.getIdsWithParent().get(0)); if(STATUS.CREATED.equals(s)) { createdEntries++; @@ -133,17 +131,12 @@ private void storeDomainToRorMap() { } } else { // Else log a warning because there is no way to provide a suggestion - invalidDomains.add(element.getDomain()); + LOG.warn("Domain {} couldnt be mapped, it have {} rows with parent and {} rows with no parent", element.getDomain(), element.getIdsWithParent().size(), element.getIdsWithNoParent().size()); + invalidEntires++; } } - if(!invalidDomains.isEmpty()) { - LOG.warn("The following domains couldn't be mapped ({} In total):", invalidDomains.size()); - for(String invalidDomain : invalidDomains) { - LOG.warn("{}", invalidDomain); - } - } - LOG.info("Created entries: {}, updated entries: {}", createdEntries, updatedEntries); + LOG.info("Created entries: {}, updated entries: {}, invalid entries {}", createdEntries, updatedEntries, invalidEntires); } private class DomainToRorMap {