use of org.nextprot.api.core.domain.EntityName in project nextprot-api by calipho-sib.
the class OverviewServiceImpl method convertIsoNamestoOverviewName.
private static List<EntityName> convertIsoNamestoOverviewName(List<Isoform> isoforms) {
List<EntityName> isoNames = new ArrayList<>();
for (Isoform isoform : isoforms) {
EntityName name = new EntityName();
name.setMain(true);
name.setName(isoform.getMainEntityName().getValue());
name.setType(isoform.getMainEntityName().getType());
name.setQualifier(isoform.getMainEntityName().getQualifier());
for (EntityName syn : isoform.getSynonyms()) {
EntityName s = new EntityName();
s.setMain(false);
s.setName(syn.getValue());
name.setType(syn.getType());
name.setQualifier(syn.getQualifier());
name.getSynonyms().add(s);
}
name.getSynonyms().sort(Comparator.comparing(EntityName::getName));
isoNames.add(name);
}
return isoNames;
}
use of org.nextprot.api.core.domain.EntityName 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;
}
}
}
}
use of org.nextprot.api.core.domain.EntityName in project nextprot-api by calipho-sib.
the class EntryOverviewXMLUnitTest method shouldContainOverviewWithGeneNameList.
// Tests issue CALIPHOMISC-330
// https://issues.isb-sib.ch/browse/CALIPHOMISC-330
@Test
public void shouldContainOverviewWithGeneNameList() throws Exception {
// Create an entry for test purposes
Entry entry = new Entry("my-test-entry");
Overview overview = new Overview();
entry.setOverview(overview);
List<EntityName> names = new ArrayList<EntityName>();
overview.setGeneNames(names);
EntityName mainName = new EntityName();
mainName.setMain(true);
mainName.setName("ABCD");
EntityName synonym = new EntityName();
synonym.setMain(false);
synonym.setName("EFGH");
EntityName orf = new EntityName();
orf.setMain(false);
orf.setName("IJKL");
orf.setCategory("ORF");
mainName.addAllSynonyms(Arrays.asList(synonym, orf));
names.add(mainName);
// Gets the velocity output
String output = this.getVelocityOutput(entry);
NodeList nodes = XMLUnitUtils.getMatchingNodes(output, "entry/overview");
assertEquals(1, nodes.getLength());
// Test the content using xmlunit
NodeList recommendedNodes = XMLUnitUtils.getMatchingNodes(output, "entry/overview/gene-list/gene/gene-name[@type='primary']");
assertEquals("ABCD", recommendedNodes.item(0).getTextContent());
NodeList alternativeNodeList = XMLUnitUtils.getMatchingNodes(output, "entry/overview/gene-list/gene/gene-name[@type='synonym']");
assertEquals("EFGH", alternativeNodeList.item(0).getTextContent());
NodeList orfNodeList = XMLUnitUtils.getMatchingNodes(output, "entry/overview/gene-list/gene/gene-name[@type='ORF']");
assertEquals("IJKL", orfNodeList.item(0).getTextContent());
}
use of org.nextprot.api.core.domain.EntityName in project nextprot-api by calipho-sib.
the class EntityNameDaoImpl method findNames.
@Override
public List<EntityName> findNames(String uniqueName) {
SqlParameterSource namedParameters = new MapSqlParameterSource("uniqueName", uniqueName);
List<EntityName> entityNames = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("entity-names"), namedParameters, new EntryNameRowMapper());
return entityNames;
}
Aggregations