Search in sources :

Example 16 with EntityName

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;
}
Also used : EntityName(org.nextprot.api.core.domain.EntityName) ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform)

Example 17 with EntityName

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;
                }
        }
    }
}
Also used : EntityName(org.nextprot.api.core.domain.EntityName) ArrayList(java.util.ArrayList) EntityNameClass(org.nextprot.api.core.domain.Overview.EntityNameClass)

Example 18 with EntityName

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());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntityName(org.nextprot.api.core.domain.EntityName) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) Overview(org.nextprot.api.core.domain.Overview) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 19 with EntityName

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) EntityName(org.nextprot.api.core.domain.EntityName) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)

Aggregations

EntityName (org.nextprot.api.core.domain.EntityName)19 Overview (org.nextprot.api.core.domain.Overview)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)5 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)4 Isoform (org.nextprot.api.core.domain.Isoform)3 Entry (org.nextprot.api.core.domain.Entry)2 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)2 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)2 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)2 List (java.util.List)1 Family (org.nextprot.api.core.domain.Family)1 EntityNameClass (org.nextprot.api.core.domain.Overview.EntityNameClass)1 History (org.nextprot.api.core.domain.Overview.History)1 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 NodeList (org.w3c.dom.NodeList)1