use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class BiographyManagerReadOnlyImpl method getBiography.
@Override
@Cacheable(value = "biography", key = "#orcid.concat('-').concat(#lastModified)")
public Biography getBiography(String orcid, long lastModified) {
BiographyEntity biographyEntity = null;
try {
biographyEntity = biographyDao.getBiography(orcid);
} catch (Exception e) {
LOGGER.warn("Couldn't find biography for " + orcid);
}
if (biographyEntity != null) {
Biography bio = new Biography();
bio.setContent(biographyEntity.getBiography());
bio.setVisibility(biographyEntity.getVisibility());
bio.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getLastModified())));
bio.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getDateCreated())));
return bio;
}
return null;
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class RecordCorrectionsManagerReadOnlyImpl method getInvalidRecordDataChangesDescending.
@Override
@Cacheable(value = "invalid-record-data-change-page-desc", key = "(#lastElement == null ? 'none' : #lastElement.toString()).concat('-').concat(#pageSize.toString())")
public RecordCorrectionsPage getInvalidRecordDataChangesDescending(Long lastElement, Long pageSize) {
List<InvalidRecordDataChangeEntity> entities = dao.getByDateCreated(lastElement, pageSize, DESCENDING);
if (entities == null || entities.isEmpty()) {
throw new IllegalArgumentException("Unable to find a page with the following params: lastElement=" + lastElement + " pageSize: " + pageSize + " descending order");
}
List<RecordCorrection> elements = adapter.toInvalidRecordDataChanges(entities);
Long first = null;
Long last = null;
for (RecordCorrection element : elements) {
if (first == null || element.getSequence() > first) {
first = element.getSequence();
}
if (last == null || element.getSequence() < last) {
last = element.getSequence();
}
}
Boolean haveNext = dao.haveNext(last, DESCENDING);
Boolean havePrevious = dao.havePrevious(first, DESCENDING);
RecordCorrectionsPage page = new RecordCorrectionsPage();
page.setFirstElementId(first);
page.setLastElementId(last);
page.setHaveNext(haveNext);
page.setHavePrevious(havePrevious);
page.setRecordCorrections(elements);
return page;
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class ActivityCacheManagerImpl method pubPeerReviewsMap.
@Cacheable(value = "pub-peer-reviews-maps", key = "#orcid.concat('-').concat(#lastModified)")
public LinkedHashMap<Long, PeerReview> pubPeerReviewsMap(String orcid, long lastModified) {
List<PeerReview> peerReviews = peerReviewManager.findPeerReviews(orcid, lastModified);
LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
if (peerReviews != null) {
if (!peerReviews.isEmpty()) {
for (PeerReview peerReview : peerReviews) {
if (peerReview.getVisibility().equals(Visibility.PUBLIC)) {
peerReviewMap.put(peerReview.getPutCode(), peerReview);
}
}
}
}
return peerReviewMap;
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class AddressDaoImpl method getAddresses.
@SuppressWarnings("unchecked")
@Override
@Cacheable(value = "dao-address", key = "#orcid.concat('-').concat(#lastModified)")
public List<AddressEntity> getAddresses(String orcid, long lastModified) {
Query query = entityManager.createQuery("FROM AddressEntity WHERE user.id = :orcid order by displayIndex desc, dateCreated asc");
query.setParameter("orcid", orcid);
return query.getResultList();
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class WorkDaoImpl method findPublicWorks.
/**
* @deprepcated Use {@link org.orcid.core.manager.WorkEntityCacheManager#retrievePublicMinimizedWorks(String, long)} instead
*
* Find the public works for a specific user
*
* @param orcid
* the Id of the user
* @return the list of works associated to the specific user
* */
@SuppressWarnings("unchecked")
@Cacheable(value = "dao-public-works", key = "#orcid.concat('-').concat(#lastModified)")
@Deprecated
public List<MinimizedWorkEntity> findPublicWorks(String orcid, long lastModified) {
Query query = entityManager.createQuery("from MinimizedWorkEntity w " + "where w.visibility='PUBLIC' and w.orcid=:orcid " + "order by w.displayIndex desc, w.dateCreated asc");
query.setParameter("orcid", orcid);
return query.getResultList();
}
Aggregations