use of org.kuali.kfs.core.api.criteria.QueryByCriteria in project cu-kfs by CU-CommunityApps.
the class SecurityGroupRule method retrieveSecurityGroupByName.
private SecurityGroup retrieveSecurityGroupByName(String securityGroupName) {
if (StringUtils.isBlank(securityGroupName)) {
return null;
}
SecurityGroup securityGroup = null;
QueryByCriteria criteria = QueryByCriteria.Builder.fromPredicates(PredicateFactory.equalIgnoreCase(KSRPropertyConstants.SECURITY_GROUP_NAME, securityGroupName));
List<SecurityGroup> securityGroups = getCriteriaLookupService().lookup(SecurityGroup.class, criteria).getResults();
if (CollectionUtils.isNotEmpty(securityGroups)) {
if (securityGroups.size() > 1) {
throw new IllegalStateException("Found multiple security groups with name '" + securityGroupName + "' (case-insensitive); this should NEVER happen!");
}
securityGroup = securityGroups.get(0);
}
return securityGroup;
}
use of org.kuali.kfs.core.api.criteria.QueryByCriteria in project cu-kfs by CU-CommunityApps.
the class PermissionServiceImpl method getRoleIdsForPermissionIds.
private List<String> getRoleIdsForPermissionIds(Collection<String> permissionIds) {
if (CollectionUtils.isEmpty(permissionIds)) {
return Collections.emptyList();
}
String cacheKey = "{getRoleIdsForPermissionIds}permissionIds=" + CacheKeyUtils.key(permissionIds);
Cache.ValueWrapper cachedValue = cacheManager.getCache(Permission.CACHE_NAME).get(cacheKey);
if (cachedValue != null && cachedValue.get() instanceof List) {
return (List<String>) cachedValue.get();
}
QueryByCriteria query = QueryByCriteria.Builder.fromPredicates(PredicateFactory.equal("active", "true"), PredicateFactory.in("permissionId", permissionIds.toArray(new String[] {})));
GenericQueryResults<RolePermission> results = criteriaLookupService.lookup(RolePermission.class, query);
List<String> roleIds = new ArrayList<>();
for (RolePermission bo : results.getResults()) {
roleIds.add(bo.getRoleId());
}
roleIds = Collections.unmodifiableList(roleIds);
cacheManager.getCache(Permission.CACHE_NAME).put(cacheKey, roleIds);
return roleIds;
}
use of org.kuali.kfs.core.api.criteria.QueryByCriteria in project cu-kfs by CU-CommunityApps.
the class ResponsibilityServiceImpl method buildWorkflowResponsibilitiesQueryByCriteria.
private QueryByCriteria buildWorkflowResponsibilitiesQueryByCriteria(String documentTypeName, String exceptionRoutingResponsibilityTemplateName) {
QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
Predicate p = PredicateFactory.and(PredicateFactory.equal("template.namespaceCode", KFSConstants.CoreModuleNamespaces.WORKFLOW), PredicateFactory.equal("template.name", exceptionRoutingResponsibilityTemplateName), PredicateFactory.equal("active", "Y"), PredicateFactory.equal("attributes[documentTypeName]", documentTypeName));
builder.setPredicates(p);
return builder.build();
}
Aggregations