Package com.walters.sms

Source Code of com.walters.sms.RoleService

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;
    }
}
TOP

Related Classes of com.walters.sms.RoleService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.