Search in sources :

Example 31 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project ocvn by devgateway.

the class ExcelGenerator method getExcelDownload.

/**
     * Method that returns a byte array with excel export.
     *
     * @param filter
     * @return
     * @throws IOException
     */
@Cacheable
public byte[] getExcelDownload(final YearFilterPagingRequest filter) throws IOException {
    PageRequest pageRequest = new PageRequest(filter.getPageNumber(), filter.getPageSize(), Sort.Direction.ASC, "id");
    List<Release> releases = mongoTemplate.find(query(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)).with(pageRequest), Release.class);
    ExcelFile releaseExcelFile = new ReleaseExportFile(releases);
    Workbook workbook = releaseExcelFile.createWorkbook();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    workbook.write(baos);
    byte[] bytes = baos.toByteArray();
    return bytes;
}
Also used : ReleaseExportFile(org.devgateway.ocds.persistence.mongo.excel.ReleaseExportFile) PageRequest(org.springframework.data.domain.PageRequest) ExcelFile(org.devgateway.ocds.persistence.mongo.excel.ExcelFile) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Release(org.devgateway.ocds.persistence.mongo.Release) Workbook(org.apache.poi.ss.usermodel.Workbook) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 32 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project tesla by linking12.

the class MenuServiceImpl method getSysMenuTree.

@Cacheable
@Override
public Tree<MenuDO> getSysMenuTree(Long id) {
    List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
    List<MenuDO> menuDOs = menuMapper.listMenuByUserId(id);
    for (MenuDO sysMenuDO : menuDOs) {
        Tree<MenuDO> tree = new Tree<MenuDO>();
        tree.setId(sysMenuDO.getMenuId().toString());
        tree.setParentId(sysMenuDO.getParentId().toString());
        tree.setText(sysMenuDO.getName());
        Map<String, Object> attributes = new HashMap<>(16);
        attributes.put("url", sysMenuDO.getUrl());
        attributes.put("icon", sysMenuDO.getIcon());
        tree.setAttributes(attributes);
        trees.add(tree);
    }
    Tree<MenuDO> t = BuildTree.build(trees);
    return t;
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Tree(io.github.tesla.ops.system.domain.Tree) BuildTree(io.github.tesla.ops.utils.BuildTree) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 33 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project mica2 by obiba.

the class OpalServiceHelper method getTaxonomies.

// opal root url as key
@Cacheable(value = "opal-taxonomies", key = "#opalJavaClient.newUri().build()")
public Map<String, Taxonomy> getTaxonomies(OpalJavaClient opalJavaClient) {
    log.info("Fetching opal taxonomies");
    URI uri = opalJavaClient.newUri().segment("system", "conf", "taxonomies").build();
    List<Opal.TaxonomyDto> taxonomies = opalJavaClient.getResources(Opal.TaxonomyDto.class, uri, Opal.TaxonomyDto.newBuilder());
    ConcurrentMap<String, Taxonomy> taxonomiesList = taxonomies.stream().collect(Collectors.toConcurrentMap(Opal.TaxonomyDto::getName, this::fromDto));
    eventBus.post(new OpalTaxonomiesUpdatedEvent(taxonomiesList));
    return taxonomiesList;
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Opal(org.obiba.opal.web.model.Opal) URI(java.net.URI) OpalTaxonomiesUpdatedEvent(org.obiba.mica.micaConfig.event.OpalTaxonomiesUpdatedEvent) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Cacheable (org.springframework.cache.annotation.Cacheable)33 Query (javax.persistence.Query)8 LinkedHashMap (java.util.LinkedHashMap)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 HashMap (java.util.HashMap)4 TypedQuery (javax.persistence.TypedQuery)4 Workbook (org.apache.poi.ss.usermodel.Workbook)4 IdentifierType (org.orcid.pojo.IdentifierType)3 PageRequest (org.springframework.data.domain.PageRequest)3 ArrayList (java.util.ArrayList)2 ResourceBundle (java.util.ResourceBundle)2 Release (org.devgateway.ocds.persistence.mongo.Release)2 ExcelFile (org.devgateway.ocds.persistence.mongo.excel.ExcelFile)2 ReleaseExportFile (org.devgateway.ocds.persistence.mongo.excel.ReleaseExportFile)2 ExcelChart (org.devgateway.toolkit.web.excelcharts.ExcelChart)2 ExcelChartDefault (org.devgateway.toolkit.web.excelcharts.ExcelChartDefault)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