Search in sources :

Example 71 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.

the class ReleaseInfoServiceImpl method findReleaseStats.

@Override
@Cacheable("release-stats")
public ReleaseInfoStats findReleaseStats() {
    ReleaseInfoStats rs = new ReleaseInfoStats();
    List<ReleaseStatsTag> stats = releaseStatsDao.findTagStatistics();
    for (ReleaseStatsTag statsTag : stats) {
        if ("PROTEIN_LEVEL_MASTER".equals(statsTag.getTag())) {
            statsTag.setCount(masterIdentifierService.findEntryAccessionsByProteinExistence(ProteinExistence.PROTEIN_LEVEL).size());
        } else if ("TRANSCRIPT_LEVEL_MASTER".equals(statsTag.getTag())) {
            statsTag.setCount(masterIdentifierService.findEntryAccessionsByProteinExistence(ProteinExistence.TRANSCRIPT_LEVEL).size());
        } else if ("HOMOLOGY_MASTER".equals(statsTag.getTag())) {
            statsTag.setCount(masterIdentifierService.findEntryAccessionsByProteinExistence(ProteinExistence.HOMOLOGY).size());
        } else if ("PREDICTED_MASTER".equals(statsTag.getTag())) {
            statsTag.setCount(masterIdentifierService.findEntryAccessionsByProteinExistence(ProteinExistence.PREDICTED).size());
        } else if ("UNCERTAIN_MASTER".equals(statsTag.getTag())) {
            statsTag.setCount(masterIdentifierService.findEntryAccessionsByProteinExistence(ProteinExistence.UNCERTAIN).size());
        }
    }
    rs.setTagStatistics(stats);
    return rs;
}
Also used : ReleaseInfoStats(org.nextprot.api.core.domain.release.ReleaseInfoStats) ReleaseStatsTag(org.nextprot.api.core.domain.release.ReleaseStatsTag) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 72 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.

the class ReleaseInfoServiceImpl method findReleaseDatasources.

@Override
@Cacheable("release-data-sources")
public ReleaseInfoDataSources findReleaseDatasources() {
    ReleaseInfoDataSources sources = new ReleaseInfoDataSources();
    sources.setDatasources(releaseStatsDao.findReleaseInfoDataSources());
    return sources;
}
Also used : ReleaseInfoDataSources(org.nextprot.api.core.domain.release.ReleaseInfoDataSources) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 73 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.

the class StatisticsServiceImpl method getGlobalPublicationStatistics.

@Cacheable("global-publication-statistics")
@Override
public GlobalPublicationStatistics getGlobalPublicationStatistics() {
    GlobalPublicationStatistics globalPublicationStatistics = new GlobalPublicationStatistics();
    publicationService.findAllPublicationIds().forEach(pubId -> {
        List<EntryPublication> entryPublications = publicationService.getEntryPublications(pubId);
        GlobalPublicationStatistics.PublicationStatistics stats = new PublicationStatisticsAnalyser(pubId, entryPublications).analyse();
        globalPublicationStatistics.putPublicationStatisticsById(pubId, stats);
        if (stats.isCited()) {
            globalPublicationStatistics.incrementNumberOfCitedPublications();
        }
        if (stats.isComputed()) {
            globalPublicationStatistics.incrementNumberOfComputationallyMappedPublications();
        }
        if (stats.isLargeScale()) {
            globalPublicationStatistics.incrementNumberOfLargeScalePublications();
        }
        if (stats.isCurated()) {
            globalPublicationStatistics.incrementNumberOfCuratedPublications();
        }
        globalPublicationStatistics.incrementTotalNumberOfPublications();
    });
    return globalPublicationStatistics;
}
Also used : EntryPublication(org.nextprot.api.core.domain.publication.EntryPublication) GlobalPublicationStatistics(org.nextprot.api.core.domain.publication.GlobalPublicationStatistics) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 74 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.

the class ExperimentalContextDictionaryServiceImpl method getAllExperimentalContexts.

@Override
@Cacheable("experimental-context-dictionary")
public Map<Long, ExperimentalContext> getAllExperimentalContexts() {
    // long t0 = System.currentTimeMillis(); System.out.println("Building experimental context dictionary...");
    List<ExperimentalContext> ecs = ecDao.findAllExperimentalContexts();
    updateTerminologies(ecs);
    Map<Long, ExperimentalContext> dictionary = new TreeMap<>();
    for (ExperimentalContext ec : ecs) dictionary.put(ec.getContextId(), ec);
    ecs = null;
    return dictionary;
}
Also used : ExperimentalContext(org.nextprot.api.core.domain.ExperimentalContext) TreeMap(java.util.TreeMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 75 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.

the class FamilyServiceImpl method findFamilies.

@Override
@Cacheable("families")
public List<Family> findFamilies(String uniqueName) {
    List<Family> families = familyDao.findFamilies(uniqueName);
    for (Family child : families) {
        while (true) {
            Long childId = child.getFamilyId();
            // TODO can this be done with one query???
            Family parent = familyDao.findParentOfFamilyId(childId);
            if (parent == null)
                break;
            child.setParent(parent);
            // TODO setting a reference inside a for loop????
            child = parent;
        }
    }
    Collections.sort(families, FAMILY_COMPARATOR);
    // returns a immutable list when the result is cacheable (this prevents modifying the cache, since the cache returns a reference) copy on read and copy on write is too much time consuming
    return new ImmutableList.Builder<Family>().addAll(families).build();
}
Also used : Family(org.nextprot.api.core.domain.Family) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Cacheable (org.springframework.cache.annotation.Cacheable)94 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 Query (javax.persistence.Query)11 HashSet (java.util.HashSet)10 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)7 LinkedHashMap (java.util.LinkedHashMap)6 NextProtException (org.nextprot.api.commons.exception.NextProtException)6 AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)5 IOException (java.io.IOException)5 List (java.util.List)5 Set (java.util.Set)5 TypedQuery (javax.persistence.TypedQuery)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 Workbook (org.apache.poi.ss.usermodel.Workbook)4 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)3 Region (com.sequenceiq.cloudbreak.cloud.model.Region)3 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)3 Application (ai.elimu.model.admin.Application)2