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