Search in sources :

Example 1 with StaffPerson

use of gov.ca.cwds.data.persistence.auth.StaffPerson in project perry by ca-cwds.

the class UserAuthorizationService method find.

/**
 * {@inheritDoc}
 *
 * @see CrudsService#find(Serializable)
 */
public UserAuthorization find(Serializable primaryKey) {
    final String userId = ((String) primaryKey).trim();
    LOGGER.info(userId);
    List<UserId> userList = userIdDao.findActiveByLogonId(userId);
    if (userList == null || userList.isEmpty()) {
        LOGGER.warn("No user id found for {}", primaryKey);
        return null;
    }
    final UserId user = userList.get(0);
    String userIdentifier = user.getId();
    String staffPersonIdentifier = user.getStaffPersonId();
    boolean socialWorker = !staffAuthorityPrivilegeDao.findSocialWorkerPrivileges(userIdentifier).isEmpty();
    Set<StaffAuthorityPrivilege> userAuthPrivs = getStaffAuthorityPriveleges(userIdentifier);
    Set<StaffUnitAuthority> setStaffUnitAuths = getStaffUnitAuthorities(staffPersonIdentifier);
    StaffPerson staffPerson = staffPersonDao.findOne(staffPersonIdentifier);
    if (staffPerson == null) {
        LOGGER.warn("No staff person found for {}", staffPersonIdentifier);
        return null;
    }
    CwsOffice cwsOffice = cwsOfficeDao.findOne(staffPerson.getCwsOffice());
    if (cwsOffice == null) {
        LOGGER.warn("No cws office found for {}", staffPerson.getCwsOffice());
        return null;
    }
    return new UserAuthorization(user.getLogonId(), socialWorker, false, true, userAuthPrivs, setStaffUnitAuths, cwsOffice, staffPerson);
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.auth.StaffPerson) StaffAuthorityPrivilege(gov.ca.cwds.rest.api.domain.auth.StaffAuthorityPrivilege) UserAuthorization(gov.ca.cwds.rest.api.domain.auth.UserAuthorization) UserId(gov.ca.cwds.data.persistence.auth.UserId) CwsOffice(gov.ca.cwds.data.persistence.auth.CwsOffice) StaffUnitAuthority(gov.ca.cwds.rest.api.domain.auth.StaffUnitAuthority)

Aggregations

CwsOffice (gov.ca.cwds.data.persistence.auth.CwsOffice)1 StaffPerson (gov.ca.cwds.data.persistence.auth.StaffPerson)1 UserId (gov.ca.cwds.data.persistence.auth.UserId)1 StaffAuthorityPrivilege (gov.ca.cwds.rest.api.domain.auth.StaffAuthorityPrivilege)1 StaffUnitAuthority (gov.ca.cwds.rest.api.domain.auth.StaffUnitAuthority)1 UserAuthorization (gov.ca.cwds.rest.api.domain.auth.UserAuthorization)1