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