Search in sources :

Example 1 with Cacheable

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;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Biography(org.orcid.jaxb.model.record_v2.Biography) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) BiographyEntity(org.orcid.persistence.jpa.entities.BiographyEntity) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with Cacheable

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;
}
Also used : InvalidRecordDataChangeEntity(org.orcid.persistence.jpa.entities.InvalidRecordDataChangeEntity) RecordCorrectionsPage(org.orcid.model.record_correction.RecordCorrectionsPage) RecordCorrection(org.orcid.model.record_correction.RecordCorrection) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 3 with Cacheable

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;
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) LinkedHashMap(java.util.LinkedHashMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with Cacheable

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();
}
Also used : Query(javax.persistence.Query) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 5 with Cacheable

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();
}
Also used : TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) 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