Пример #1
0
 @RequestMapping(
     value = "/speakers/{id}/speeches",
     method = GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public Set<Speech> findBySpeakerId(@PathVariable("id") Long speakerId) {
   Speaker speaker = speakerService.findById(speakerId);
   return speechService.findBySpeaker(speaker);
 }
Пример #2
0
 @RequestMapping(
     value = "/events/{eventId}/speakers/{speakerId}/speeches",
     method = GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public Set<Speech> findByEventAndSpeaker(
     @PathVariable("speakerId") Long speakerId, @PathVariable("eventId") Long eventId) {
   Event event = eventService.findById(eventId);
   Speaker speaker = speakerService.findById(speakerId);
   return speechService.findByEventAndSpeaker(event, speaker);
 }
Пример #3
0
 @RequestMapping(
     value = "/speakers/{speakerId}/speeches/{speechId}",
     method = PUT,
     consumes = MediaType.APPLICATION_JSON_VALUE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public void linkToSpeaker(
     @PathVariable("speechId") Long speechId, @PathVariable("speakerId") Long speakerId) {
   Speaker speaker = speakerService.findById(speakerId);
   Speech speech = speechService.findById(speechId);
   speechService.linkToSpeaker(speech, speaker);
 }
Пример #4
0
 @RequestMapping(
     value = {
       "/speakers/{speakerId}/speeches/{speechId}",
       "/speeches/{speechId}/speakers/{speakerId}"
     },
     method = DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public void unlinkFromSpeaker(
     @PathVariable("speakerId") Long speakerId, @PathVariable("speechId") Long speechId) {
   Speaker speaker = speakerService.findById(speakerId);
   speechService.unlinkFromSpeaker(speechId, speaker);
 }
Пример #5
0
 @RequestMapping(
     value = "/speakers/{id}/speeches",
     method = POST,
     consumes = MediaType.APPLICATION_JSON_VALUE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseStatus(HttpStatus.CREATED)
 public Speech createAndLinkToSpeaker(
     @PathVariable("id") Long speakerId, @RequestBody @Validated Speech speech) {
   speech.setId(null);
   Speaker speaker = speakerService.findById(speakerId);
   return speechService.createAndLinkToSpeaker(speech, speaker);
 }
Пример #6
0
 @RequestMapping(
     value = "/events/{eventId}/speakers/{speakerId}/speeches",
     method = POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public Speech createAndLinkToEventSpeaker(
     @PathVariable("speakerId") Long speakerId,
     @PathVariable("eventId") Long eventId,
     @RequestBody @Validated Speech speech) {
   Event event = eventService.findById(eventId);
   Speaker speaker = speakerService.findById(speakerId);
   return speechService.createAndLinkToEventSpeaker(speech, speaker, event);
 }
Пример #7
0
 @RequestMapping(
     value = "/events/{eventId}/speakers/{speakerId}/speeches/{speechId}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public void removeFromEventSpeaker(
     @PathVariable("eventId") Long eventId,
     @PathVariable("speakerId") Long speakerId,
     @PathVariable("speechId") Long speechId) {
   Event event = eventService.findById(eventId);
   Speaker speaker = speakerService.findById(speakerId);
   Speech speech = speechService.findById(speechId);
   speechService.unlinkFromEventSpeaker(speech, speaker, event);
 }