Search in sources :

Example 16 with Publication

use of org.nextprot.api.core.domain.Publication in project nextprot-api by calipho-sib.

the class PublicationServiceImpl method findPublicationById.

@Cacheable("publications-get-by-id")
public Publication findPublicationById(long id) {
    // Basic fields
    Publication publication = this.publicationDao.findPublicationById(id);
    // add non-basic fields to object
    loadAuthorsAndXrefs(publication);
    return publication;
}
Also used : Publication(org.nextprot.api.core.domain.Publication) EntryPublication(org.nextprot.api.core.domain.publication.EntryPublication) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 17 with Publication

use of org.nextprot.api.core.domain.Publication in project nextprot-api by calipho-sib.

the class SolrIndexingServiceImpl method indexPublications.

@Override
public String indexPublications() {
    long seconds = System.currentTimeMillis() / 1000;
    StringBuilder info = new StringBuilder();
    logAndCollect(info, "publications indexing...STARTING at " + new Date());
    String serverUrl = getServerUrl(PublicationIndex.NAME);
    logAndCollect(info, "Solr server: " + serverUrl);
    logAndCollect(info, "clearing publication index");
    SolrIndexer<Publication> indexer = new PublicationSolrindexer(serverUrl, publicationService);
    List<Long> allpubids;
    indexer.clearDatabase("");
    logAndCollect(info, "getting publications");
    allpubids = publicationService.findAllPublicationIds();
    logAndCollect(info, "start indexing of " + allpubids.size() + " publications");
    int pubcnt = 0;
    for (Long id : allpubids) {
        Publication currpub = publicationService.findPublicationById(id);
        if (currpub.getPublicationType().equals(PublicationType.ARTICLE)) {
            indexer.add(currpub);
            pubcnt++;
        }
        if ((pubcnt % 5000) == 0)
            logAndCollect(info, pubcnt + "/" + allpubids.size() + " publications done");
    }
    indexer.addRemaing();
    logAndCollect(info, "comitting");
    indexer.commit();
    seconds = (System.currentTimeMillis() / 1000 - seconds);
    logAndCollect(info, pubcnt + " publications indexed in " + seconds + " seconds ...END at " + new Date());
    return info.toString();
}
Also used : Publication(org.nextprot.api.core.domain.Publication) Date(java.util.Date)

Example 18 with Publication

use of org.nextprot.api.core.domain.Publication in project nextprot-api by calipho-sib.

the class ConsistencyServiceImpl method findMissingPublications.

@Override
public List<String> findMissingPublications() {
    List<String> missingPublications = new ArrayList<>();
    Arrays.asList(XrefDatabase.PUB_MED, XrefDatabase.DOI).forEach(referenceDB -> {
        List<String> ids = statementDao.findAllDistinctValuesforFieldWhereFieldEqualsValues(StatementField.REFERENCE_ACCESSION, new StatementSimpleWhereClauseQueryDSL(StatementField.REFERENCE_DATABASE, referenceDB.getName()));
        for (String id : ids) {
            if (id != null) {
                Publication pub = publicationService.findPublicationByDatabaseAndAccession(referenceDB.getName(), id);
                if (pub == null) {
                    missingPublications.add(referenceDB + id);
                }
            }
        }
        ;
    });
    return missingPublications;
}
Also used : ArrayList(java.util.ArrayList) Publication(org.nextprot.api.core.domain.Publication) StatementSimpleWhereClauseQueryDSL(org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL)

Example 19 with Publication

use of org.nextprot.api.core.domain.Publication in project nextprot-api by calipho-sib.

the class PublicationServiceTest method verifyFindPublicationsByMasterUniqueName.

@Test
public void verifyFindPublicationsByMasterUniqueName() {
    Publication publication = mock(Publication.class);
    when(publication.getPublicationId()).thenReturn(1L);
    when(masterIdentifierService.findIdByUniqueName("NX_P12345")).thenReturn(100L);
    when(publicationDao.findSortedPublicationsByMasterId(100L)).thenReturn(Arrays.asList(publication));
    publicationService.findPublicationsByEntryName("NX_P12345");
    verify(masterIdentifierService).findIdByUniqueName("NX_P12345");
    verify(publicationDao).findSortedPublicationsByMasterId(100L);
    verify(dbXrefService).findDbXRefByPublicationIds(Arrays.asList(1L));
    verify(authorService).findAuthorsByPublicationIds(Arrays.asList(1L));
}
Also used : Publication(org.nextprot.api.core.domain.Publication) Test(org.junit.Test)

Example 20 with Publication

use of org.nextprot.api.core.domain.Publication in project nextprot-api by calipho-sib.

the class PublicationServiceIntegrationTest method testPublicationByDOI.

@Test
public void testPublicationByDOI() {
    Publication publication = publicationService.findPublicationByDatabaseAndAccession("DOI", "10.1111/j.1349-7006.2012.02267.x");
    Assert.assertEquals("High levels of DJ-1 protein in nipple fluid of patients with breast cancer.", publication.getTitle());
}
Also used : Publication(org.nextprot.api.core.domain.Publication) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Aggregations

Publication (org.nextprot.api.core.domain.Publication)33 Test (org.junit.Test)17 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)13 EntryPublication (org.nextprot.api.core.domain.publication.EntryPublication)6 Ignore (org.junit.Ignore)4 StatementSimpleWhereClauseQueryDSL (org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL)4 ImmutableList (com.google.common.collect.ImmutableList)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 PublicationAuthor (org.nextprot.api.core.domain.PublicationAuthor)2 PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)2 GlobalPublicationStatistics (org.nextprot.api.core.domain.publication.GlobalPublicationStatistics)2 Service (org.springframework.stereotype.Service)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Sets (com.google.common.collect.Sets)1 Argument (graphql.language.Argument)1 Field (graphql.language.Field)1