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;
}
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);
}
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");
}
Aggregations