use of won.owner.model.UserNeed in project webofneeds by researchstudio-sat.
the class WonWebSocketHandler method saveNeedUriWithUser.
private void saveNeedUriWithUser(final WonMessage wonMessage, final WebSocketSession session) {
User user = getUserForSession(session);
URI needURI = wonMessage.getReceiverNeedURI();
UserNeed userNeed = new UserNeed(needURI);
// reload the user so we can save it
// (the user object we get from getUserForSession is detached)
user = userRepository.findOne(user.getId());
userNeedRepository.save(userNeed);
user.addNeedUri(userNeed);
userRepository.save(user);
}
use of won.owner.model.UserNeed in project webofneeds by researchstudio-sat.
the class RestNeedController method getAllNeedsOfUser.
/**
* returns a List containing needs belonging to the user
* @return JSON List of need objects
*/
@ResponseBody
@RequestMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
public List<URI> getAllNeedsOfUser() {
logger.info("Getting all needs of user: ");
User user = getCurrentUser();
List<UserNeed> userNeeds = user.getUserNeeds();
List<URI> needUris = new ArrayList(userNeeds.size());
for (UserNeed userNeed : userNeeds) {
needUris.add(userNeed.getUri());
}
return needUris;
}
Aggregations