Search in sources :

Example 1 with UserIndexBean

use of org.onebusaway.users.client.model.UserIndexBean in project onebusaway-application-modules by camsys.

the class UserServiceImpl method getUserAsBean.

@Override
public UserBean getUserAsBean(User user) {
    UserBean bean = new UserBean();
    bean.setUserId(Integer.toString(user.getId()));
    UserRole anonymous = _authoritiesService.getAnonymousRole();
    boolean isAnonymous = user.getRoles().contains(anonymous);
    bean.setAnonymous(isAnonymous);
    UserRole admin = _authoritiesService.getAdministratorRole();
    boolean isAdmin = user.getRoles().contains(admin);
    bean.setAdmin(isAdmin);
    List<UserIndexBean> indices = new ArrayList<UserIndexBean>();
    bean.setIndices(indices);
    for (UserIndex index : user.getUserIndices()) {
        UserIndexKey key = index.getId();
        UserIndexBean indexBean = new UserIndexBean();
        indexBean.setType(key.getType());
        indexBean.setValue(key.getValue());
        indices.add(indexBean);
    }
    _userPropertiesService.getUserAsBean(user, bean);
    return bean;
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexBean(org.onebusaway.users.client.model.UserIndexBean) UserIndexKey(org.onebusaway.users.model.UserIndexKey) UserBean(org.onebusaway.users.client.model.UserBean) UserRole(org.onebusaway.users.model.UserRole) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 UserBean (org.onebusaway.users.client.model.UserBean)1 UserIndexBean (org.onebusaway.users.client.model.UserIndexBean)1 UserIndex (org.onebusaway.users.model.UserIndex)1 UserIndexKey (org.onebusaway.users.model.UserIndexKey)1 UserRole (org.onebusaway.users.model.UserRole)1