Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there is more than one org with no parent, we should not suggest a… #6925

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,11 +28,11 @@ public class EmailDomainToRorLoader {
private String filePath;
private EmailDomainManager emailDomainManager;
private List<List<String>> csvData;
private Set<String> invalidDomains = new HashSet<String>();
private Map<String, DomainToRorMap> map = new HashMap<String, DomainToRorMap>();

private int updatedEntries = 0;
private int createdEntries = 0;
private int invalidEntires = 0;

public EmailDomainToRorLoader(String filePath) {
this.filePath = filePath;
Expand Down Expand Up @@ -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++;
Expand All @@ -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 {
Expand Down