Search in sources :

Example 1 with QueryByCriteria

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;
}
Also used : QueryByCriteria(org.kuali.kfs.core.api.criteria.QueryByCriteria) SecurityGroup(edu.cornell.kfs.ksr.businessobject.SecurityGroup)

Example 2 with QueryByCriteria

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;
}
Also used : QueryByCriteria(org.kuali.kfs.core.api.criteria.QueryByCriteria) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) RolePermission(org.kuali.kfs.kim.impl.role.RolePermission) Cache(org.springframework.cache.Cache)

Example 3 with QueryByCriteria

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();
}
Also used : QueryByCriteria(org.kuali.kfs.core.api.criteria.QueryByCriteria) Predicate(org.kuali.kfs.core.api.criteria.Predicate)

Aggregations

QueryByCriteria (org.kuali.kfs.core.api.criteria.QueryByCriteria)3 SecurityGroup (edu.cornell.kfs.ksr.businessobject.SecurityGroup)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Predicate (org.kuali.kfs.core.api.criteria.Predicate)1 RolePermission (org.kuali.kfs.kim.impl.role.RolePermission)1 Cache (org.springframework.cache.Cache)1