use of org.springframework.cache.annotation.Cacheable in project fw-cloud-framework by liuweijw.
the class UserServiceImpl method findByUserId.
@Override
@Cacheable(value = AdminCacheKey.USER_INFO_USERID, key = AdminCacheKey.USER_INFO_USERID_KEY_USERID)
public AuthUser findByUserId(String userId) {
User user = userRepository.findUserByUserId(Integer.valueOf(userId));
if (null == user)
return null;
user.setRoleList(findRoleListByUserId(user.getUserId()));
return buildAuthUserByUser(user);
}
use of org.springframework.cache.annotation.Cacheable in project herd by FINRAOS.
the class SecurityFunctionDaoImpl method getUnrestrictedSecurityFunctions.
@Override
@Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME)
public List<String> getUnrestrictedSecurityFunctions() {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<String> criteria = builder.createQuery(String.class);
// The criteria root is the security function.
Root<SecurityFunctionEntity> securityFunctionEntityRoot = criteria.from(SecurityFunctionEntity.class);
// Build a subquery to eliminate security functions that are mapped to security roles.
Subquery<SecurityFunctionEntity> subquery = criteria.subquery(SecurityFunctionEntity.class);
Root<SecurityRoleFunctionEntity> subSecurityRoleFunctionEntityRoot = subquery.from(SecurityRoleFunctionEntity.class);
subquery.select(subSecurityRoleFunctionEntityRoot.get(SecurityRoleFunctionEntity_.securityFunction)).where(builder.equal(subSecurityRoleFunctionEntityRoot.get(SecurityRoleFunctionEntity_.securityFunction), securityFunctionEntityRoot));
// Get the security function code column.
Path<String> functionCodeColumn = securityFunctionEntityRoot.get(SecurityFunctionEntity_.code);
// Add the clauses for the query.
criteria.select(functionCodeColumn).where(builder.not(builder.exists(subquery))).orderBy(builder.asc(functionCodeColumn));
// Run the query to get a list of unrestricted security functions.
return entityManager.createQuery(criteria).getResultList();
}
use of org.springframework.cache.annotation.Cacheable in project herd by FINRAOS.
the class SecurityFunctionDaoImpl method getSecurityFunctionsForRole.
@Override
@Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME)
public List<String> getSecurityFunctionsForRole(String roleCd) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<String> criteria = builder.createQuery(String.class);
// The criteria root is the security role function mapping.
Root<SecurityRoleFunctionEntity> securityRoleFunctionEntity = criteria.from(SecurityRoleFunctionEntity.class);
// Join to the other tables we can filter on.
Join<SecurityRoleFunctionEntity, SecurityRoleEntity> securityRoleEntity = securityRoleFunctionEntity.join(SecurityRoleFunctionEntity_.securityRole);
Join<SecurityRoleFunctionEntity, SecurityFunctionEntity> securityFunctionEntity = securityRoleFunctionEntity.join(SecurityRoleFunctionEntity_.securityFunction);
// Get the columns.
Path<String> functionCodeColumn = securityFunctionEntity.get(SecurityFunctionEntity_.code);
// Add the select clause.
criteria.select(functionCodeColumn);
// Add the where clause.
criteria.where(builder.equal(builder.upper(securityRoleEntity.get(SecurityRoleEntity_.code)), roleCd.toUpperCase()));
// Add the order by clause.
criteria.orderBy(builder.asc(functionCodeColumn));
// Run the query to get a list of functions.
return entityManager.createQuery(criteria).getResultList();
}
use of org.springframework.cache.annotation.Cacheable in project openmrs-core by openmrs.
the class AdministrationServiceImpl method getSearchLocales.
@Override
@Cacheable(value = "userSearchLocales")
public List<Locale> getSearchLocales(Locale currentLocale, User user) throws APIException {
Set<Locale> locales = new LinkedHashSet<>();
// the currently used full locale
locales.add(currentLocale);
locales.add(new Locale(currentLocale.getLanguage()));
if (user != null) {
List<Locale> proficientLocales = user.getProficientLocales();
if (proficientLocales != null) {
locales.addAll(proficientLocales);
}
}
// limit locales to only allowed locales
List<Locale> allowedLocales = Context.getAdministrationService().getAllowedLocales();
if (allowedLocales != null) {
Set<Locale> retainLocales = new HashSet<>();
for (Locale allowedLocale : allowedLocales) {
retainLocales.add(allowedLocale);
retainLocales.add(new Locale(allowedLocale.getLanguage()));
}
locales.retainAll(retainLocales);
}
return new ArrayList<>(locales);
}
use of org.springframework.cache.annotation.Cacheable in project ocvn by devgateway.
the class ExcelChartGenerator method getExcelChart.
/**
* Generate an Excel Chart based on (categories, values)
*/
@Cacheable
public byte[] getExcelChart(final ChartType type, final String title, final List<String> seriesTitle, final List<?> categories, final List<List<? extends Number>> values) throws IOException {
final ExcelChart excelChart = new ExcelChartDefault(title, type, categories, values);
excelChart.configureSeriesTitle(seriesTitle);
final Workbook workbook = excelChart.createWorkbook();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
workbook.write(baos);
return baos.toByteArray();
}
Aggregations