Search in sources :

Example 56 with Cacheable

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

Example 57 with Cacheable

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;
}
Also used : ResourceBundle(java.util.ResourceBundle) UTF8Control(org.orcid.utils.UTF8Control) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 58 with Cacheable

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;
}
Also used : ResourceBundle(java.util.ResourceBundle) UTF8Control(org.orcid.utils.UTF8Control) LinkedHashMap(java.util.LinkedHashMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 59 with Cacheable

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

Example 60 with Cacheable

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

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