use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method buildUserDetail.
private UserDetail buildUserDetail(User user) {
UserDetail userDetail = new UserDetail();
userDetail.setId(user.getId());
for (UserIndex userIndex : user.getUserIndices()) {
userDetail.setUsername(userIndex.getId().getValue());
}
for (UserRole role : user.getRoles()) {
// There should be only one role
userDetail.setRole(role.getName());
}
UserBean bean = userService.getUserAsBean(user);
userDetail.setDisabled(bean.isDisabled());
return userDetail;
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method getUserDetails.
@Override
public List<UserDetail> getUserDetails(final int start, final int maxResults) {
List<UserDetail> userDetails = new ArrayList<UserDetail>();
List<User> users = hibernateTemplate.execute(new HibernateCallback<List<User>>() {
@SuppressWarnings("unchecked")
@Override
public List<User> doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(User.class).createCriteria("userIndices").add(Restrictions.eq("id.type", UserIndexTypes.USERNAME)).setFirstResult(start).setMaxResults(maxResults);
List<User> users = criteria.list();
return users;
}
});
if (!users.isEmpty()) {
for (User user : users) {
if (!user.getUserIndices().isEmpty()) {
UserDetail userDetail = buildUserDetail(user);
userDetails.add(userDetail);
}
}
}
log.debug("Returning user details");
return userDetails;
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method getUserDetail.
@Override
public UserDetail getUserDetail(final String userName) {
List<User> users = hibernateTemplate.execute(new HibernateCallback<List<User>>() {
@SuppressWarnings("unchecked")
@Override
public List<User> doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(User.class).createCriteria("userIndices").add(Restrictions.like("id.value", userName));
List<User> users = criteria.list();
return users;
}
});
UserDetail userDetail = null;
if (!users.isEmpty()) {
userDetail = buildUserDetail(users.get(0));
}
log.debug("Returning user details for user : {}", userName);
return userDetail;
}
Aggregations