Skip to content

Commit 724d050

Browse files
authored
Merge pull request #6925 from ORCID/FixBugOnOrgsSuggestionWhenThereAreMoreThanOneDomainWithNoParent
Is there is more than one org with no parent, we should not suggest a…
2 parents 0343b05 + d7e07ee commit 724d050

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

orcid-scheduler-web/src/main/java/org/orcid/scheduler/loader/cli/EmailDomainToRorLoader.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
import java.nio.file.Paths;
88
import java.util.ArrayList;
99
import java.util.HashMap;
10-
import java.util.HashSet;
1110
import java.util.List;
1211
import java.util.Map;
13-
import java.util.Set;
1412

1513
import org.orcid.core.common.manager.EmailDomainManager;
1614
import org.orcid.core.common.manager.impl.EmailDomainManagerImpl.STATUS;
@@ -30,11 +28,11 @@ public class EmailDomainToRorLoader {
3028
private String filePath;
3129
private EmailDomainManager emailDomainManager;
3230
private List<List<String>> csvData;
33-
private Set<String> invalidDomains = new HashSet<String>();
3431
private Map<String, DomainToRorMap> map = new HashMap<String, DomainToRorMap>();
3532

3633
private int updatedEntries = 0;
3734
private int createdEntries = 0;
35+
private int invalidEntires = 0;
3836

3937
public EmailDomainToRorLoader(String filePath) {
4038
this.filePath = filePath;
@@ -123,8 +121,8 @@ private void storeDomainToRorMap() {
123121
} else if (STATUS.UPDATED.equals(s)) {
124122
updatedEntries++;
125123
}
126-
} else if(element.getIdsWithParent().size() == 1) {
127-
// Else, if the domain has only one entry with parent, store that one
124+
} else if(element.getIdsWithNoParent().isEmpty() && element.getIdsWithParent().size() == 1) {
125+
// Else, if the domain doesn't have an org with no parents and only have one entry with parent, store that one
128126
STATUS s = emailDomainManager.createOrUpdateEmailDomain(element.getDomain(), element.getIdsWithParent().get(0));
129127
if(STATUS.CREATED.equals(s)) {
130128
createdEntries++;
@@ -133,17 +131,12 @@ private void storeDomainToRorMap() {
133131
}
134132
} else {
135133
// Else log a warning because there is no way to provide a suggestion
136-
invalidDomains.add(element.getDomain());
134+
LOG.warn("Domain {} couldnt be mapped, it have {} rows with parent and {} rows with no parent", element.getDomain(), element.getIdsWithParent().size(), element.getIdsWithNoParent().size());
135+
invalidEntires++;
137136
}
138137
}
139138

140-
if(!invalidDomains.isEmpty()) {
141-
LOG.warn("The following domains couldn't be mapped ({} In total):", invalidDomains.size());
142-
for(String invalidDomain : invalidDomains) {
143-
LOG.warn("{}", invalidDomain);
144-
}
145-
}
146-
LOG.info("Created entries: {}, updated entries: {}", createdEntries, updatedEntries);
139+
LOG.info("Created entries: {}, updated entries: {}, invalid entries {}", createdEntries, updatedEntries, invalidEntires);
147140
}
148141

149142
private class DomainToRorMap {

0 commit comments

Comments
 (0)