Search in sources :

Example 51 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project webapp by elimu-ai.

the class JsonService method getApplications.

@Cacheable("applications")
public JSONArray getApplications(Locale locale) {
    logger.info("getApplications");
    Date dateStart = new Date();
    JSONArray applications = new JSONArray();
    for (Application application : applicationDao.readAll(locale)) {
        ApplicationGson applicationGson = JavaToGsonConverter.getApplicationGson(application);
        List<ApplicationVersionGson> applicationVersions = new ArrayList<>();
        logger.info("applicationVersionDao.readAll(" + application.getPackageName() + ") - " + new Date());
        for (ApplicationVersion applicationVersion : applicationVersionDao.readAll(application)) {
            logger.info("applicationVersion: " + applicationVersion.getVersionCode() + " - " + new Date());
            ApplicationVersionGson applicationVersionGson = JavaToGsonConverter.getApplicationVersionGson(applicationVersion);
            applicationVersions.add(applicationVersionGson);
        }
        applicationGson.setApplicationVersions(applicationVersions);
        String json = new Gson().toJson(applicationGson);
        applications.put(new JSONObject(json));
    }
    Date dateEnd = new Date();
    logger.info("getApplications duration: " + (dateEnd.getTime() - dateStart.getTime()) + " ms");
    return applications;
}
Also used : ApplicationVersion(ai.elimu.model.admin.ApplicationVersion) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) ApplicationVersionGson(ai.elimu.model.gson.admin.ApplicationVersionGson) ApplicationGson(ai.elimu.model.gson.admin.ApplicationGson) Gson(com.google.gson.Gson) ApplicationVersionGson(ai.elimu.model.gson.admin.ApplicationVersionGson) Application(ai.elimu.model.admin.Application) Date(java.util.Date) ApplicationGson(ai.elimu.model.gson.admin.ApplicationGson) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 52 with Cacheable

use of org.springframework.cache.annotation.Cacheable in project commons-dao by reportportal.

the class LaunchRepositoryCustomImpl method findGroupedLaunchesByOwner.

@Cacheable(value = { CacheConfiguration.PROJECT_INFO_CACHE })
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map<String, Integer> findGroupedLaunchesByOwner(String projectName, String mode, Date from) {
    Map<String, Integer> output = new HashMap<>();
    Aggregation aggregation = newAggregation(match(where(PROJECT_ID_REFERENCE).is(projectName)), match(where(MODE).is(mode)), match(where(STATUS).ne(IN_PROGRESS.name())), match(where(START_TIME).gt(from)), group("$userRef").count().as("count"));
    AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, Launch.class, Map.class);
    for (Map<String, String> entry : result.getMappedResults()) {
        String username = entry.get("_id");
        String count = String.valueOf(entry.get("count"));
        output.put(username, Integer.valueOf(count));
    }
    return output;
}
Also used : Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 53 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 54 with Cacheable

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

the class SecurityQuestionManagerImpl method retrieveSecurityQuestionsAsMap.

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

Example 55 with Cacheable

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

the class OrgDisambiguatedDaoImpl method getOrgs.

@SuppressWarnings("unchecked")
@Override
@Cacheable("orgs")
public List<OrgDisambiguatedEntity> getOrgs(String searchTerm, int firstResult, int maxResults) {
    String qStr = "select od.*, COUNT(*) as countAll from org_disambiguated od left join org_affiliation_relation oa on od.id = oa.org_id" + " where lower(name) like '%' || lower(:searchTerm) || '%' group by od.id " + " order by position(lower(:searchTerm) in lower(name)), char_length(name), countAll DESC, od.name";
    Query query = entityManager.createNativeQuery(qStr, OrgDisambiguatedEntity.class);
    query.setParameter("searchTerm", searchTerm);
    query.setFirstResult(firstResult);
    query.setMaxResults(maxResults);
    return query.getResultList();
}
Also used : TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) 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