use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class ProfileKeywordDaoImpl method getProfileKeywors.
/**
* Return the list of keywords associated to a specific profile
* @param orcid
* @return
* the list of keywords associated with the orcid profile
* */
@Override
@SuppressWarnings("unchecked")
@Cacheable(value = "dao-keywords", key = "#orcid.concat('-').concat(#lastModified)")
public List<ProfileKeywordEntity> getProfileKeywors(String orcid, long lastModified) {
Query query = entityManager.createQuery("FROM ProfileKeywordEntity WHERE profile.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 LocaleManagerImpl method getJavascriptMessages.
@Cacheable(value = "locale-messages", key = "#locale.toString().concat('-javascript')")
public org.orcid.pojo.Local getJavascriptMessages(Locale locale) {
org.orcid.pojo.Local lPojo = new org.orcid.pojo.Local();
lPojo.setLocale(locale.toString());
ResourceBundle resource = ResourceBundle.getBundle("i18n/javascript", locale, new UTF8Control());
lPojo.setMessages(OrcidStringUtils.resourceBundleToMap(resource));
return lPojo;
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class LocaleManagerImpl method getCountries.
/*
* Get country names from i18n files
*/
@Cacheable(value = "locale-messages", key = "#locale.toString().concat('-countries-map')")
public Map<String, String> getCountries(Locale locale) {
ResourceBundle resource = ResourceBundle.getBundle("i18n/messages", locale, new UTF8Control());
Map<String, String> dbCountries = countryManager.retrieveCountriesAndIsoCodes();
Map<String, String> countries = new LinkedHashMap<String, String>();
for (String key : dbCountries.keySet()) {
countries.put(key, resource.getString(buildInternationalizationKey(CountryIsoEntity.class, key)));
}
FunctionsOverCollections.sortMapsByValues(countries);
return countries;
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class ActivityCacheManagerImpl method affiliationMap.
@Cacheable(value = "pub-affiliation-maps", key = "#orcid.concat('-').concat(#lastModified)")
public LinkedHashMap<Long, Affiliation> affiliationMap(String orcid, long lastModified) {
LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
List<Affiliation> affiliations = affiliationsManager.getAffiliations(orcid);
for (Affiliation affiliation : affiliations) {
if (Visibility.PUBLIC.equals(affiliation.getVisibility())) {
affiliationMap.put(affiliation.getPutCode(), affiliation);
}
}
return affiliationMap;
}
use of org.springframework.cache.annotation.Cacheable in project ORCID-Source by ORCID.
the class RecordCorrectionsManagerReadOnlyImpl method getInvalidRecordDataChangesAscending.
@Override
@Cacheable(value = "invalid-record-data-change-page-asc", key = "(#lastElement == null ? 'none' : #lastElement.toString()).concat('-').concat(#pageSize.toString())")
public RecordCorrectionsPage getInvalidRecordDataChangesAscending(Long lastElement, Long pageSize) {
List<InvalidRecordDataChangeEntity> entities = dao.getByDateCreated(lastElement, pageSize, ASCENDING);
if (entities == null || entities.isEmpty()) {
throw new IllegalArgumentException("Unable to find a page with the following params: lastElement=" + lastElement + " pageSize: " + pageSize + " ascending 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, ASCENDING);
Boolean havePrevious = dao.havePrevious(first, ASCENDING);
RecordCorrectionsPage page = new RecordCorrectionsPage();
page.setFirstElementId(first);
page.setLastElementId(last);
page.setHaveNext(haveNext);
page.setHavePrevious(havePrevious);
page.setRecordCorrections(elements);
return page;
}
Aggregations