use of org.nextprot.api.core.domain.Overview.EntityNameClass in project nextprot-api by calipho-sib.
the class OverviewServiceImpl method setNamesInOverview.
private void setNamesInOverview(List<EntityName> entityNames, Overview overview) {
Map<String, EntityName> entityMap = Maps.uniqueIndex(entityNames, EntityName::getId);
Map<String, EntityName> mutableEntityMap = Maps.newHashMap(entityMap);
String parentId;
for (EntityName entityName : entityMap.values()) {
parentId = entityName.getParentId();
if (parentId != null && mutableEntityMap.containsKey(parentId)) {
if (entityName.isMain()) {
mutableEntityMap.get(parentId).addOtherRecommendedEntityName(entityName);
} else {
mutableEntityMap.get(parentId).addSynonym(entityName);
}
} else {
mutableEntityMap.put(entityName.getId(), entityName);
}
}
List<EntityName> mutableEntityNames = new ArrayList<>(mutableEntityMap.values());
for (EntityName entityName : mutableEntityMap.values()) if (entityName.getParentId() != null)
mutableEntityNames.remove(entityName);
Multimap<Overview.EntityNameClass, EntityName> entryNameMap = Multimaps.index(mutableEntityNames, EntityName::getClazz);
for (EntityNameClass en : entryNameMap.keySet()) {
switch(en) {
case PROTEIN_NAMES:
{
overview.setProteinNames(getSortedList(entryNameMap, en));
break;
}
case GENE_NAMES:
{
overview.setGeneNames(getSortedList(entryNameMap, en, Comparator.comparing(EntityName::getName)));
break;
}
case CLEAVED_REGION_NAMES:
{
overview.setCleavedRegionNames(getSortedList(entryNameMap, en));
break;
}
case ADDITIONAL_NAMES:
{
overview.setAdditionalNames(getSortedList(entryNameMap, en));
break;
}
case FUNCTIONAL_REGION_NAMES:
{
overview.setFunctionalRegionNames(getSortedList(entryNameMap, en));
break;
}
}
}
}
Aggregations