use of uk.ac.ebi.spot.goci.model.Country in project goci by EBISPOT.
the class AncestryController method populateCountryMap.
@ModelAttribute("countryMap")
public Map<String, Set<Country>> populateCountryMap(Model model) {
Map<String, Set<Country>> countryMap = new TreeMap<>();
List<Country> countries = countryRepository.findAll();
for (Country country : countries) {
Set<Country> countrySet = countryMap.get(country.getMajorArea());
if (countrySet == null) {
countrySet = new TreeSet<Country>(Comparator.comparing(Country::getCountryName));
countryMap.put(country.getMajorArea(), countrySet);
}
countrySet.add(country);
}
return countryMap;
}
use of uk.ac.ebi.spot.goci.model.Country in project goci by EBISPOT.
the class AncestryMappingService method processAncestries.
public void processAncestries() {
printOutOntologyContent();
;
List<Ancestry> allAncestries = getAllAncestries();
for (Ancestry ancestry : allAncestries) {
Long id = ancestry.getId();
String coo = null;
if (ancestry.getCountryOfOrigin() != null) {
for (Country c : ancestry.getCountryOfOrigin()) {
if (coo == null) {
coo = c.getCountryName();
} else {
coo = coo.concat(", ").concat(c.getCountryName());
}
}
} else {
coo = "NR";
}
String cor = null;
if (ancestry.getCountryOfRecruitment() != null) {
for (Country c : ancestry.getCountryOfRecruitment()) {
if (cor == null) {
cor = c.getCountryName();
} else {
cor = cor.concat(", ").concat(c.getCountryName());
}
}
} else {
cor = "NR";
}
String ancestralGroup = null;
if (ancestry.getAncestralGroups() != null) {
for (AncestralGroup a : ancestry.getAncestralGroups()) {
if (ancestralGroup == null) {
ancestralGroup = a.getAncestralGroup();
} else {
ancestralGroup = ancestralGroup.concat(", ").concat(a.getAncestralGroup());
}
}
} else {
ancestralGroup = "NR";
}
if (ancestralGroup != null) {
if (ancestralGroup.contains(",")) {
String[] groups = ancestralGroup.split(",");
for (String group : groups) {
mapAncestralGroup(id, group.toLowerCase());
}
} else {
mapAncestralGroup(id, ancestralGroup.toLowerCase());
}
}
if (coo != null) {
if (coo.contains(",")) {
String[] countries = coo.split(",");
for (String country : countries) {
mapCoO(id, country.toLowerCase());
}
} else {
mapCoO(id, coo.toLowerCase());
}
}
if (cor != null) {
if (cor.contains(",")) {
String[] countries = cor.split(",");
for (String country : countries) {
mapCoR(id, country.toLowerCase());
}
} else {
mapCoR(id, cor.toLowerCase());
}
}
}
getErrors().info("All ancestries processed");
printResult();
}
Aggregations