package com.walters.sms;
import com.walters.common.args.CheckArg;
import com.walters.sms.domain.Role;
import org.hibernate.HibernateException;
public class RoleService extends PersistenceService implements IRoleService
{
private static final String ROLE_NAME = "name";
@Override
public Role findRoleByName(final String roleName)
{
Role role = null;
if (CheckArg.isNotNull(roleName))
{
try
{
role = findByPropertyValue(ROLE_NAME, roleName, Role.class);
}
catch (final HibernateException ex)
{
throw new ApplicationException(String.format("Failed to retrieve role with name: %s", roleName), ex);
}
}
return role;
}
@Override
public int getRoleCount()
{
int roleCount = 0;
try
{
roleCount = count(Role.class);
}
catch (final HibernateException ex)
{
throw new ApplicationException("Failed to retrieve role count.", ex);
}
return roleCount;
}
}