2020-07-08 00:06:57 +02:00
package de.twomartens.oparlservice.control ;
2020-07-18 12:42:24 +02:00
import de.twomartens.oparlservice.entity.dto.System ;
2020-07-18 13:41:13 +02:00
import de.twomartens.oparlservice.entity.dto.* ;
2020-07-08 23:48:45 +02:00
import de.twomartens.oparlservice.service.OParlService ;
2020-07-08 00:06:57 +02:00
import io.swagger.v3.oas.annotations.Operation ;
2020-07-08 23:01:22 +02:00
import io.swagger.v3.oas.annotations.Parameter ;
2020-07-11 21:00:28 +02:00
import io.swagger.v3.oas.annotations.media.Content ;
import io.swagger.v3.oas.annotations.media.Schema ;
import io.swagger.v3.oas.annotations.responses.ApiResponse ;
2020-07-08 00:06:57 +02:00
import lombok.extern.slf4j.Slf4j ;
2020-07-11 20:43:31 +02:00
import org.springframework.http.HttpStatus ;
import org.springframework.web.bind.annotation.* ;
import org.springframework.web.server.ResponseStatusException ;
2020-07-08 00:06:57 +02:00
@Slf4j
@RestController
2020-07-08 23:01:22 +02:00
@RequestMapping ( path = " /v1.1 " )
2020-07-08 00:06:57 +02:00
public class OParlController {
2020-07-08 23:48:45 +02:00
private final OParlService service ;
2020-07-08 00:06:57 +02:00
2020-07-08 23:48:45 +02:00
OParlController ( OParlService service ) {
this . service = service ;
2020-07-08 00:06:57 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /agendaItem/{id} " )
@Operation ( summary = " information about agenda item " , description = " returns the requested agenda item " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Body . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public AgendaItem agendaItem (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " agendaItem ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/agendaItem/{} " , id ) ;
return service . getAgendaItem ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Kein Tagesordnungspunkt mit angefragter ID existiert " ) ;
} ) ;
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/agendaItems " , " /body/{id}/agendaItems/{pageNumber} " } )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " List of all agenda items in body " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all agenda items in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListAgendaItem . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public ObjectList < AgendaItem > agendaItemsInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
log . info ( " invoked method /v1.1/body/{}/agendaItems/{} " , id , pageNumber ) ;
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getAgendaItemsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 22:09:26 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
2020-07-08 23:01:22 +02:00
}
@GetMapping ( " /bodies " )
2020-07-11 21:00:28 +02:00
@Operation ( summary = " List of available bodies " ,
2020-07-18 13:41:13 +02:00
description = " returns a list of available bodies in this OParl system " , responses = {
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListBody . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 19:58:13 +02:00
public ObjectList < Body > bodies ( ) {
2020-07-08 23:01:22 +02:00
log . info ( " method invoked /v1.1/bodies " ) ;
2020-07-08 23:48:45 +02:00
return this . service . getBodies ( ) ;
2020-07-08 23:01:22 +02:00
}
@GetMapping ( " /body/{id} " )
2020-07-11 21:00:28 +02:00
@Operation ( summary = " information about body " , description = " returns information about the requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Body . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-08 23:01:22 +02:00
public Body body (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ) {
2020-07-08 23:01:22 +02:00
log . info ( " method invoked /v1.1/body/{} " , id ) ;
2020-07-11 20:43:31 +02:00
return service . getBody ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Körperschaft mit angefragter ID existiert nicht " ) ;
} ) ;
2020-07-08 23:48:45 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /consultation/{id} " )
@Operation ( summary = " information about consultation " , description = " returns the requested consultation " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Consultation . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public Consultation consultation (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " consultation ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/consultation/{} " , id ) ;
return service . getConsultation ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Beratung mit angefragter ID existiert " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/consultations " , " /body/{id}/consultations/{pageNumber} " } )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " List of all consultations in body " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all consultations in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListConsultation . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public ObjectList < Consultation > consultationsInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/consultations/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getConsultationsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 20:43:31 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /file/{id} " )
@Operation ( summary = " information about file " , description = " returns the requested file " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = File . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public File file (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " file ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/file/{} " , id ) ;
return service . getFile ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Datei mit angefragter ID existiert " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/files " , " /body/{id}/files/{pageNumber} " } )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " List of all files in body " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all files in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListFile . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public ObjectList < File > filesInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/files/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getFilesInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 20:43:31 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-11 22:12:16 +02:00
@GetMapping ( " /legislativeTerm/{id} " )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " information about legislative term " , description = " returns information about the requested legislative term " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = LegislativeTerm . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public LegislativeTerm legislativeTerm (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " legislative term ID " , example = " 21 " )
String id ) {
2020-07-11 22:12:16 +02:00
log . info ( " method invoked /v1.1/legislativeTerm/{} " , id ) ;
2020-07-11 22:09:26 +02:00
return service . getLegislativeTerm ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Legislaturperiode mit angefragter ID existiert nicht " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/legislativeTerms " , " /body/{id}/legislativeTerms/{pageNumber} " } )
2020-07-18 13:46:24 +02:00
@Operation ( summary = " List of all legislative terms of a body " , description = " returns a paginated list of all legislative terms of requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListLegislativeTerm . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public ObjectList < LegislativeTerm > legislativeTermsOfBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/legislativeTerms/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getLegislativeTermsOfBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 20:43:31 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /location/{id} " )
@Operation ( summary = " information about location " , description = " returns the requested location " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Location . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public Location location (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " location ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/location/{} " , id ) ;
return service . getLocation ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Kein Ort mit angefragter ID existiert " ) ;
} ) ;
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/locations " , " /body/{id}/locations/{pageNumber} " } )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " List of all locations in body " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all locations in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListLocation . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public ObjectList < Location > locationsInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/locations/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getLocationsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 22:09:26 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /meeting/{id} " )
@Operation ( summary = " information about meeting " , description = " returns the requested meeting " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Meeting . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public Meeting meeting (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " meeting ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/meeting/{} " , id ) ;
return service . getMeeting ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Sitzung mit angefragter ID existiert " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/meetings " , " /body/{id}/meetings/{pageNumber} " } )
2020-07-11 21:00:28 +02:00
@Operation ( summary = " List of all meetings in body " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all meetings in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListMeeting . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 19:58:13 +02:00
public ObjectList < Meeting > meetingsInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/meetings/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getMeetingsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 20:43:31 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /organization/{id}/meetings " , " /organization/{id}/meetings/{pageNumber} " } )
2020-07-11 21:00:28 +02:00
@Operation ( summary = " List of all meetings in organization " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all meetings in requested organization " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListMeeting . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 19:58:13 +02:00
public ObjectList < Meeting > meetingsInOrganization (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " organization ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/organization/{}/meetings/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getMeetingsInOrganization ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 20:43:31 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Organisation mit angefragter ID existiert " ) ;
} ) ;
2020-07-10 22:52:51 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /membership/{id} " )
@Operation ( summary = " information about membership " , description = " returns the requested membership " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Membership . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public Membership membership (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " membership ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/membership/{} " , id ) ;
return service . getMembership ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Mitgliedschaft mit angefragter ID existiert " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
2020-07-08 00:06:57 +02:00
}
2020-07-11 19:33:11 +02:00
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/memberships " , " /body/{id}/memberships/{pageNumber} " } )
2020-07-18 13:46:24 +02:00
@Operation ( summary = " List of all memberships in body " , description = " returns a paginated list of all memberships in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListMembership . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:11:36 +02:00
} )
2020-07-11 22:09:26 +02:00
public ObjectList < Membership > membershipsInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/memberships/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getMembershipsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 21:11:36 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /organization/{id}/memberships " , " /organization/{id}/memberships/{pageNumber} " } )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " List of all memberships in organization " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all memberships in requested organization " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListMembership . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 21:00:28 +02:00
} )
2020-07-11 22:09:26 +02:00
public ObjectList < Membership > membershipsInOrganization (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " organization ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/organization/{}/memberships/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getMembershipsInOrganization ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 22:09:26 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Organisation mit angefragter ID existiert " ) ;
2020-07-11 20:43:31 +02:00
} ) ;
}
@ExceptionHandler ( { ResponseStatusException . class } )
@ResponseStatus ( HttpStatus . NOT_FOUND )
public ErrorObject notFound ( ResponseStatusException exception ) {
return ErrorObject . builder ( )
2020-07-18 13:41:13 +02:00
. message ( exception . getReason ( ) )
. debug ( exception . getLocalizedMessage ( ) )
. build ( ) ;
2020-07-11 19:33:11 +02:00
}
2020-07-11 22:09:26 +02:00
@GetMapping ( " /organization/{id} " )
@Operation ( summary = " information about organization " , description = " returns the requested organization " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Organization . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public Organization organization (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " organization ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/organization/{} " , id ) ;
return service . getOrganization ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Organisation mit angefragter ID existiert " ) ;
} ) ;
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/organizations " , " /body/{id}/organizations/{pageNumber} " } )
2020-07-18 13:46:24 +02:00
@Operation ( summary = " List of all organizations in body " , description = " returns a paginated list of all organizations in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListOrganization . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public ObjectList < Organization > organizationsInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/organizations/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getOrganizationsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 22:09:26 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
}
@GetMapping ( " /paper/{id} " )
@Operation ( summary = " information about paper " , description = " returns the requested paper " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Paper . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public Paper paper (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " paper ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/paper/{} " , id ) ;
return service . getPaper ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Drucksache mit angefragter ID existiert " ) ;
} ) ;
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/papers " , " /body/{id}/papers/{pageNumber} " } )
2020-07-11 22:09:26 +02:00
@Operation ( summary = " List of all papers in body " ,
2020-07-18 13:46:24 +02:00
description = " returns a paginated list of all papers in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListPaper . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public ObjectList < Paper > papersInBody (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/papers/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getPapersInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 22:09:26 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
}
@GetMapping ( " /person/{id} " )
@Operation ( summary = " information about person " , description = " returns the requested person " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = Person . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public Person person (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " person ID " , example = " 0 " )
String id ) {
2020-07-11 22:09:26 +02:00
log . info ( " invoked method /v1.1/person/{} " , id ) ;
return service . getPerson ( id ) . orElseThrow ( ( ) - > {
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Person mit angefragter ID existiert " ) ;
} ) ;
}
2020-07-18 13:41:13 +02:00
@GetMapping ( value = { " /body/{id}/persons " , " /body/{id}/persons/{pageNumber} " } )
2020-07-18 13:46:24 +02:00
@Operation ( summary = " List of all persons in body " , description = " returns a paginated list of all persons in requested body " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " ,
content = @Content ( mediaType = " application/json " , schema = @Schema ( implementation = ObjectList . ObjectListPerson . class ) ) ) ,
@ApiResponse ( responseCode = " 404 " , description = " Not found " , content = @Content ( mediaType = " application/json " ,
schema = @Schema ( implementation = ErrorObject . class ) ) )
2020-07-11 22:09:26 +02:00
} )
public ObjectList < Person > persons (
2020-07-18 13:41:13 +02:00
@PathVariable
@Parameter ( description = " body ID " , example = " 0 " )
String id ,
@PathVariable ( required = false )
@Parameter ( description = " page number " , example = " 1 " )
Integer pageNumber ) {
2020-07-18 13:45:03 +02:00
log . info ( " invoked method /v1.1/body/{}/persons/{} " , id , pageNumber ) ;
2020-07-18 13:41:13 +02:00
if ( pageNumber = = null ) {
pageNumber = 1 ;
}
return service . getPersonsInBody ( id , pageNumber ) . orElseThrow ( ( ) - > {
2020-07-11 22:09:26 +02:00
throw new ResponseStatusException ( HttpStatus . NOT_FOUND , " Keine Körperschaft mit angefragter ID existiert " ) ;
} ) ;
}
@GetMapping ( " / " )
@Operation ( summary = " System information " , description = " returns information about the OParl system " , responses = {
2020-07-18 13:41:13 +02:00
@ApiResponse ( description = " Successful Operation " , responseCode = " 200 " , content = @Content (
mediaType = " application/json " , schema = @Schema ( implementation = System . class )
) )
2020-07-11 22:09:26 +02:00
} )
public System system ( ) {
log . info ( " method invoked /v1.1 " ) ;
return service . getSystem ( ) ;
}
2020-07-08 00:06:57 +02:00
}