Search in sources :

Example 1 with RestModelMapper

use of com.infiniteautomation.mango.rest.latest.model.RestModelMapper in project ma-modules-public by infiniteautomation.

the class UserModelMapping method map.

@Override
public UserModel map(Object o, PermissionHolder currentUser, RestModelMapper mapper) {
    User user = (User) o;
    UserModel model = new UserModel(user);
    List<LinkedAccountModel> linkedAccounts = usersService.getLinkedAccounts(user).stream().map(account -> mapper.map(account, LinkedAccountModel.class, currentUser)).collect(Collectors.toList());
    model.setLinkedAccounts(linkedAccounts);
    return model;
}
Also used : List(java.util.List) Component(org.springframework.stereotype.Component) RestModelMapping(com.infiniteautomation.mango.rest.latest.model.RestModelMapping) UsersService(com.infiniteautomation.mango.spring.service.UsersService) Autowired(org.springframework.beans.factory.annotation.Autowired) PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder) Collectors(java.util.stream.Collectors) User(com.serotonin.m2m2.vo.User) RestModelMapper(com.infiniteautomation.mango.rest.latest.model.RestModelMapper) User(com.serotonin.m2m2.vo.User)

Aggregations

RestModelMapper (com.infiniteautomation.mango.rest.latest.model.RestModelMapper)1 RestModelMapping (com.infiniteautomation.mango.rest.latest.model.RestModelMapping)1 UsersService (com.infiniteautomation.mango.spring.service.UsersService)1 User (com.serotonin.m2m2.vo.User)1 PermissionHolder (com.serotonin.m2m2.vo.permission.PermissionHolder)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1