ApplicationConfig.listPageSize,
new Sort(new Order(Direction.DESC, "createdAt")));
Iterable<Activity> acts = activityRepository.findByOwner(id, pageable);
Collection<ActivityVo> activities = new ArrayList<ActivityVo>();
for(Activity act : acts){
ActivityVo vo = ActivityVo.from(act);
if(act.getOwner()!=null){
User owner = userRepository.findOne(act.getOwner());
vo.setOwner(owner);
}
if(act.getTargetSpot()!=null){
Spot spot = spotRepository.findOne(act.getTargetSpot());
vo.setTargetSpot(spot);
}
if(act.getTargetUser()!=null){
User targetUser = userRepository.findOne(act.getTargetUser());
vo.setTargetUser(targetUser);
}
activities.add(vo);
}
model.addAttribute("activities", activities);
return "profiles/activities";