use of org.broadleafcommerce.openadmin.server.security.domain.AdminPermissionImpl in project BroadleafCommerce by BroadleafCommerce.
the class AdminPermissionDaoImpl method readAdminPermissionByNameAndType.
@Override
public AdminPermission readAdminPermissionByNameAndType(String name, String type) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<AdminPermission> criteria = builder.createQuery(AdminPermission.class);
Root<AdminPermissionImpl> adminPerm = criteria.from(AdminPermissionImpl.class);
criteria.select(adminPerm);
List<Predicate> restrictions = new ArrayList<Predicate>();
restrictions.add(builder.equal(adminPerm.get("name"), name));
restrictions.add(builder.equal(adminPerm.get("type"), type));
// Execute the query with the restrictions
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
TypedQuery<AdminPermission> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "blAdminSecurityQuery");
List<AdminPermission> results = query.getResultList();
if (results == null || results.size() == 0) {
return null;
} else {
return results.get(0);
}
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminPermissionImpl in project BroadleafCommerce by BroadleafCommerce.
the class AdminPermissionDataProvider method createAdminUser.
@DataProvider(name = "setupAdminPermission")
public static Object[][] createAdminUser() {
AdminPermission adminPermission = new AdminPermissionImpl();
adminPermission.setName("TestAdminPermissionName");
adminPermission.setDescription("Test Admin Permission Description");
adminPermission.setType(PermissionType.ALL);
return new Object[][] { new Object[] { adminPermission } };
}
use of org.broadleafcommerce.openadmin.server.security.domain.AdminPermissionImpl in project BroadleafCommerce by BroadleafCommerce.
the class AdminPermissionDaoImpl method readAdminPermissionByName.
@Override
public AdminPermission readAdminPermissionByName(String name) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<AdminPermission> criteria = builder.createQuery(AdminPermission.class);
Root<AdminPermissionImpl> adminPerm = criteria.from(AdminPermissionImpl.class);
criteria.select(adminPerm);
List<Predicate> restrictions = new ArrayList<Predicate>();
restrictions.add(builder.equal(adminPerm.get("name"), name));
// Execute the query with the restrictions
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
TypedQuery<AdminPermission> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "blAdminSecurityQuery");
List<AdminPermission> results = query.getResultList();
if (results == null || results.size() == 0) {
return null;
} else {
return results.get(0);
}
}
Aggregations