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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations