Search in sources :

Example 1 with LocalUser

use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser in project muikku by otavanopisto.

the class LocalUserSchoolDataBridge method findUserEnvironmentRole.

/**
 * {@inheritDoc}
 */
public Role findUserEnvironmentRole(String userIdentifier) {
    LocalUser user = localUserSchoolDataController.findUser(userIdentifier);
    if (user == null) {
        throw new SchoolDataBridgeInternalException("User not found");
    }
    Long roleId = user.getRoleId();
    if (roleId != null) {
        RoleEntity roleEntity = localUserSchoolDataController.findCoreRoleEntityById(roleId);
        if (roleEntity == null) {
            throw new SchoolDataBridgeInternalException("User role could not be found");
        }
        return toLocalRoleEntity(roleEntity);
    }
    return null;
}
Also used : WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity) RoleEntity(fi.otavanopisto.muikku.model.users.RoleEntity) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) SchoolDataBridgeInternalException(fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException) LocalUser(fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser)

Example 2 with LocalUser

use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser in project muikku by otavanopisto.

the class LocalUserDAO method create.

public LocalUser create(String firstName, String lastName, Long roleId, Boolean archived) {
    LocalUser localUser = new LocalUser();
    localUser.setFirstName(firstName);
    localUser.setLastName(lastName);
    localUser.setRoleId(roleId);
    localUser.setArchived(archived);
    return persist(localUser);
}
Also used : LocalUser(fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser)

Example 3 with LocalUser

use of fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser in project muikku by otavanopisto.

the class LocalUserSchoolDataBridge method updateUser.

/**
 * {@inheritDoc}
 */
@Override
public User updateUser(User user) {
    if (StringUtils.isNotBlank(user.getFirstName())) {
        throw new SchoolDataBridgeInternalException("firstName is required");
    }
    if (StringUtils.isNotBlank(user.getLastName())) {
        throw new SchoolDataBridgeInternalException("lastName is required");
    }
    LocalUser localUser = localUserSchoolDataController.findUser(user.getIdentifier());
    if (localUser != null) {
        localUserSchoolDataController.updateUserFirstName(localUser, user.getFirstName());
        localUserSchoolDataController.updateUserLastName(localUser, user.getLastName());
        return toLocalUserImpl(localUser);
    }
    throw new SchoolDataBridgeInternalException("Unexpected error occured while creating LocalUser");
}
Also used : SchoolDataBridgeInternalException(fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException) LocalUser(fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser)

Aggregations

LocalUser (fi.otavanopisto.muikku.plugins.schooldatalocal.model.LocalUser)3 SchoolDataBridgeInternalException (fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException)2 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)1 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)1 WorkspaceRoleEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)1