Search in sources :

Example 6 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.

the class ActivityCacheManagerImpl method fundingMap.

@Cacheable(value = "pub-funding-maps", key = "#orcid.concat('-').concat(#lastModified)")
public LinkedHashMap<Long, Funding> fundingMap(String orcid, long lastModified) {
    List<Funding> fundings = profileFundingManager.getFundingList(orcid, lastModified);
    LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
    if (fundings != null) {
        for (Funding funding : fundings) {
            if (funding.getVisibility().equals(Visibility.PUBLIC))
                fundingMap.put(Long.valueOf(funding.getPutCode()), funding);
        }
    }
    return fundingMap;
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) LinkedHashMap(java.util.LinkedHashMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 7 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.

the class IdentifierTypeManagerImpl method fetchIdentifierTypesByAPITypeName.

/**
     * Returns an immutable map of API Type Name->identifierType objects.
     * Null locale will result in Locale.ENGLISH
     * 
     */
@Override
@Cacheable("identifier-types-map")
public Map<String, IdentifierType> fetchIdentifierTypesByAPITypeName(Locale loc) {
    loc = (loc == null) ? Locale.ENGLISH : loc;
    List<IdentifierTypeEntity> entities = idTypeDao.getEntities();
    Map<String, IdentifierType> ids = new HashMap<String, IdentifierType>();
    for (IdentifierTypeEntity e : entities) {
        IdentifierType id = adapter.fromEntity(e);
        id.setDescription(getMessage(id.getName(), loc));
        ids.put(id.getName(), id);
    }
    return Collections.unmodifiableMap(ids);
}
Also used : HashMap(java.util.HashMap) IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) IdentifierType(org.orcid.pojo.IdentifierType) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 8 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.

the class AddressManagerReadOnlyImpl method getPrimaryAddress.

@Override
@Cacheable(value = "primary-address", key = "#orcid.concat('-').concat(#lastModified)")
public Address getPrimaryAddress(String orcid, long lastModified) {
    List<AddressEntity> addresses = addressDao.getAddresses(orcid, getLastModified(orcid));
    Address address = null;
    if (addresses != null) {
        //Look for the address with the largest display index
        for (AddressEntity entity : addresses) {
            if (address == null || address.getDisplayIndex() < entity.getDisplayIndex()) {
                address = adapter.toAddress(entity);
            }
        }
    }
    return address;
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 9 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.

the class SecurityQuestionManagerImpl method retrieveSecurityQuestionsAsInternationalizedMap.

@Override
@Cacheable("security-questions")
public Map<String, String> retrieveSecurityQuestionsAsInternationalizedMap() {
    List<SecurityQuestionEntity> questions = securityQuestionDao.getAll();
    Map<String, String> map = new LinkedHashMap<String, String>();
    for (SecurityQuestionEntity question : questions) {
        map.put(String.valueOf(question.getId()), question.getKey());
    }
    return map;
}
Also used : SecurityQuestionEntity(org.orcid.persistence.jpa.entities.SecurityQuestionEntity) LinkedHashMap(java.util.LinkedHashMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 10 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.

the class ExternalIdentifierDaoImpl method getExternalIdentifiers.

@SuppressWarnings("unchecked")
@Override
@Cacheable(value = "dao-external-identifiers", key = "#orcid.concat('-').concat(#lastModified)")
public List<ExternalIdentifierEntity> getExternalIdentifiers(String orcid, long lastModified) {
    Query query = entityManager.createQuery("FROM ExternalIdentifierEntity WHERE owner.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)

Aggregations

Cacheable (org.springframework.cache.annotation.Cacheable)27 Query (javax.persistence.Query)8 LinkedHashMap (java.util.LinkedHashMap)6 TypedQuery (javax.persistence.TypedQuery)4 HashMap (java.util.HashMap)3 IdentifierType (org.orcid.pojo.IdentifierType)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ResourceBundle (java.util.ResourceBundle)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 RecordCorrection (org.orcid.model.record_correction.RecordCorrection)2 RecordCorrectionsPage (org.orcid.model.record_correction.RecordCorrectionsPage)2 IdentifierTypeEntity (org.orcid.persistence.jpa.entities.IdentifierTypeEntity)2 InvalidRecordDataChangeEntity (org.orcid.persistence.jpa.entities.InvalidRecordDataChangeEntity)2 SecurityQuestionEntity (org.orcid.persistence.jpa.entities.SecurityQuestionEntity)2 UTF8Control (org.orcid.utils.UTF8Control)2 RoleResource (com.baidu.disconf.web.service.roleres.bo.RoleResource)1 Builder (com.google.common.collect.ImmutableList.Builder)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1