generated from 2martens/template-service
Added pagination support to object list requests
This commit is contained in:
parent
e6501cba83
commit
4022711f1a
|
@ -1,7 +1,7 @@
|
||||||
package de.twomartens.oparlservice.control;
|
package de.twomartens.oparlservice.control;
|
||||||
|
|
||||||
import de.twomartens.oparlservice.entity.dto.*;
|
|
||||||
import de.twomartens.oparlservice.entity.dto.System;
|
import de.twomartens.oparlservice.entity.dto.System;
|
||||||
|
import de.twomartens.oparlservice.entity.dto.*;
|
||||||
import de.twomartens.oparlservice.service.OParlService;
|
import de.twomartens.oparlservice.service.OParlService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
@ -25,44 +25,50 @@ public class OParlController {
|
||||||
|
|
||||||
@GetMapping("/agendaItem/{id}")
|
@GetMapping("/agendaItem/{id}")
|
||||||
@Operation(summary = "information about agenda item", description = "returns the requested agenda item", responses = {
|
@Operation(summary = "information about agenda item", description = "returns the requested agenda item", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Body.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Body.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public AgendaItem agendaItem(
|
public AgendaItem agendaItem(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "agendaItem ID", example = "0")
|
@Parameter(description = "agendaItem ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/agendaItem/{}", id);
|
log.info("invoked method /v1.1/agendaItem/{}", id);
|
||||||
return service.getAgendaItem(id).orElseThrow(() -> {
|
return service.getAgendaItem(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Kein Tagesordnungspunkt mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Kein Tagesordnungspunkt mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/agendaItems")
|
@GetMapping(value = {"/body/{id}/agendaItems", "/body/{id}/agendaItems/{pageNumber}"})
|
||||||
@Operation(summary = "List of all agenda items in body",
|
@Operation(summary = "List of all agenda items in body",
|
||||||
description = "returns a list of all agenda items in requested body", responses = {
|
description = "returns a list of all agenda items in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListAgendaItem.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListAgendaItem.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<AgendaItem> agendaItemsInBody(
|
public ObjectList<AgendaItem> agendaItemsInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
log.info("invoked method /v1.1/body/{}/agendaItems", id);
|
@PathVariable(required = false)
|
||||||
return service.getAgendaItemsInBody(id).orElseThrow(() -> {
|
@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(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/bodies")
|
@GetMapping("/bodies")
|
||||||
@Operation(summary = "List of available bodies",
|
@Operation(summary = "List of available bodies",
|
||||||
description = "returns a list of available bodies in this OParl system", responses = {
|
description = "returns a list of available bodies in this OParl system", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListBody.class)))
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListBody.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Body> bodies() {
|
public ObjectList<Body> bodies() {
|
||||||
log.info("method invoked /v1.1/bodies");
|
log.info("method invoked /v1.1/bodies");
|
||||||
|
@ -71,15 +77,15 @@ public class OParlController {
|
||||||
|
|
||||||
@GetMapping("/body/{id}")
|
@GetMapping("/body/{id}")
|
||||||
@Operation(summary = "information about body", description = "returns information about the requested body", responses = {
|
@Operation(summary = "information about body", description = "returns information about the requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Body.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Body.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Body body(
|
public Body body(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("method invoked /v1.1/body/{}", id);
|
log.info("method invoked /v1.1/body/{}", id);
|
||||||
return service.getBody(id).orElseThrow(() -> {
|
return service.getBody(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Körperschaft mit angefragter ID existiert nicht");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Körperschaft mit angefragter ID existiert nicht");
|
||||||
|
@ -88,244 +94,292 @@ public class OParlController {
|
||||||
|
|
||||||
@GetMapping("/consultation/{id}")
|
@GetMapping("/consultation/{id}")
|
||||||
@Operation(summary = "information about consultation", description = "returns the requested consultation", responses = {
|
@Operation(summary = "information about consultation", description = "returns the requested consultation", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Consultation.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Consultation.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Consultation consultation(
|
public Consultation consultation(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "consultation ID", example = "0")
|
@Parameter(description = "consultation ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/consultation/{}", id);
|
log.info("invoked method /v1.1/consultation/{}", id);
|
||||||
return service.getConsultation(id).orElseThrow(() -> {
|
return service.getConsultation(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Beratung mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Beratung mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/consultations")
|
@GetMapping(value = {"/body/{id}/consultations", "/body/{id}/consultations/{pageNumber}"})
|
||||||
@Operation(summary = "List of all consultations in body",
|
@Operation(summary = "List of all consultations in body",
|
||||||
description = "returns a list of all consultations in requested body", responses = {
|
description = "returns a list of all consultations in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListConsultation.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListConsultation.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Consultation> consultationsInBody(
|
public ObjectList<Consultation> consultationsInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/consultations", id);
|
log.info("invoked method /v1.1/body/{}/consultations", id);
|
||||||
return service.getConsultationsInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getConsultationsInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/file/{id}")
|
@GetMapping("/file/{id}")
|
||||||
@Operation(summary = "information about file", description = "returns the requested file", responses = {
|
@Operation(summary = "information about file", description = "returns the requested file", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = File.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = File.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public File file(
|
public File file(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "file ID", example = "0")
|
@Parameter(description = "file ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/file/{}", id);
|
log.info("invoked method /v1.1/file/{}", id);
|
||||||
return service.getFile(id).orElseThrow(() -> {
|
return service.getFile(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Datei mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Datei mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/files")
|
@GetMapping(value = {"/body/{id}/files", "/body/{id}/files/{pageNumber}"})
|
||||||
@Operation(summary = "List of all files in body",
|
@Operation(summary = "List of all files in body",
|
||||||
description = "returns a list of all files in requested body", responses = {
|
description = "returns a list of all files in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListFile.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListFile.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<File> filesInBody(
|
public ObjectList<File> filesInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/files", id);
|
log.info("invoked method /v1.1/body/{}/files", id);
|
||||||
return service.getFilesInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getFilesInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/legislativeTerm/{id}")
|
@GetMapping("/legislativeTerm/{id}")
|
||||||
@Operation(summary = "information about legislative term", description = "returns information about the requested legislative term", responses = {
|
@Operation(summary = "information about legislative term", description = "returns information about the requested legislative term", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = LegislativeTerm.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = LegislativeTerm.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public LegislativeTerm legislativeTerm(
|
public LegislativeTerm legislativeTerm(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "legislative term ID", example = "21")
|
@Parameter(description = "legislative term ID", example = "21")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("method invoked /v1.1/legislativeTerm/{}", id);
|
log.info("method invoked /v1.1/legislativeTerm/{}", id);
|
||||||
return service.getLegislativeTerm(id).orElseThrow(() -> {
|
return service.getLegislativeTerm(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Legislaturperiode mit angefragter ID existiert nicht");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Legislaturperiode mit angefragter ID existiert nicht");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/legislativeTerms")
|
@GetMapping(value = {"/body/{id}/legislativeTerms", "/body/{id}/legislativeTerms/{pageNumber}"})
|
||||||
@Operation(summary = "List of all legislative terms of a body", description = "returns a list of all legislative terms of requested body", responses = {
|
@Operation(summary = "List of all legislative terms of a body", description = "returns a list of all legislative terms of requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListLegislativeTerm.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListLegislativeTerm.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<LegislativeTerm> legislativeTermsOfBody(
|
public ObjectList<LegislativeTerm> legislativeTermsOfBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/legislativeTerms", id);
|
log.info("invoked method /v1.1/body/{}/legislativeTerms", id);
|
||||||
return service.getLegislativeTermsOfBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getLegislativeTermsOfBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/location/{id}")
|
@GetMapping("/location/{id}")
|
||||||
@Operation(summary = "information about location", description = "returns the requested location", responses = {
|
@Operation(summary = "information about location", description = "returns the requested location", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Location.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Location.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Location location(
|
public Location location(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "location ID", example = "0")
|
@Parameter(description = "location ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/location/{}", id);
|
log.info("invoked method /v1.1/location/{}", id);
|
||||||
return service.getLocation(id).orElseThrow(() -> {
|
return service.getLocation(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Kein Ort mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Kein Ort mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/locations")
|
@GetMapping(value = {"/body/{id}/locations", "/body/{id}/locations/{pageNumber}"})
|
||||||
@Operation(summary = "List of all locations in body",
|
@Operation(summary = "List of all locations in body",
|
||||||
description = "returns a list of all locations in requested body", responses = {
|
description = "returns a list of all locations in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListLocation.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListLocation.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Location> locationsInBody(
|
public ObjectList<Location> locationsInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/locations", id);
|
log.info("invoked method /v1.1/body/{}/locations", id);
|
||||||
return service.getLocationsInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getLocationsInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/meeting/{id}")
|
@GetMapping("/meeting/{id}")
|
||||||
@Operation(summary = "information about meeting", description = "returns the requested meeting", responses = {
|
@Operation(summary = "information about meeting", description = "returns the requested meeting", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Meeting.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Meeting.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Meeting meeting(
|
public Meeting meeting(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "meeting ID", example = "0")
|
@Parameter(description = "meeting ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/meeting/{}", id);
|
log.info("invoked method /v1.1/meeting/{}", id);
|
||||||
return service.getMeeting(id).orElseThrow(() -> {
|
return service.getMeeting(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Sitzung mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Sitzung mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/meetings")
|
@GetMapping(value = {"/body/{id}/meetings", "/body/{id}/meetings/{pageNumber}"})
|
||||||
@Operation(summary = "List of all meetings in body",
|
@Operation(summary = "List of all meetings in body",
|
||||||
description = "returns a list of all meetings in requested body", responses = {
|
description = "returns a list of all meetings in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMeeting.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMeeting.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Meeting> meetingsInBody(
|
public ObjectList<Meeting> meetingsInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/meetings", id);
|
log.info("invoked method /v1.1/body/{}/meetings", id);
|
||||||
return service.getMeetingsInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getMeetingsInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/organization/{id}/meetings")
|
@GetMapping(value = {"/organization/{id}/meetings", "/organization/{id}/meetings/{pageNumber}"})
|
||||||
@Operation(summary = "List of all meetings in organization",
|
@Operation(summary = "List of all meetings in organization",
|
||||||
description = "returns a list of all meetings in requested organization", responses = {
|
description = "returns a list of all meetings in requested organization", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMeeting.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMeeting.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Meeting> meetingsInOrganization(
|
public ObjectList<Meeting> meetingsInOrganization(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "organization ID", example = "0")
|
@Parameter(description = "organization ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/organization/{}/meetings", id);
|
log.info("invoked method /v1.1/organization/{}/meetings", id);
|
||||||
return service.getMeetingsInOrganization(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getMeetingsInOrganization(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Organisation mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Organisation mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/membership/{id}")
|
@GetMapping("/membership/{id}")
|
||||||
@Operation(summary = "information about membership", description = "returns the requested membership", responses = {
|
@Operation(summary = "information about membership", description = "returns the requested membership", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Membership.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Membership.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Membership membership(
|
public Membership membership(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "membership ID", example = "0")
|
@Parameter(description = "membership ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/membership/{}", id);
|
log.info("invoked method /v1.1/membership/{}", id);
|
||||||
return service.getMembership(id).orElseThrow(() -> {
|
return service.getMembership(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Mitgliedschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Mitgliedschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/memberships")
|
@GetMapping(value = {"/body/{id}/memberships", "/body/{id}/memberships/{pageNumber}"})
|
||||||
@Operation(summary = "List of all memberships in body", description = "returns a list of all memberships in requested body", responses = {
|
@Operation(summary = "List of all memberships in body", description = "returns a list of all memberships in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMembership.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMembership.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Membership> membershipsInBody(
|
public ObjectList<Membership> membershipsInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/memberships", id);
|
log.info("invoked method /v1.1/body/{}/memberships", id);
|
||||||
return service.getMembershipsInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getMembershipsInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/organization/{id}/memberships")
|
@GetMapping(value = {"/organization/{id}/memberships", "/organization/{id}/memberships/{pageNumber}"})
|
||||||
@Operation(summary = "List of all memberships in organization",
|
@Operation(summary = "List of all memberships in organization",
|
||||||
description = "returns a list of all memberships in requested organization", responses = {
|
description = "returns a list of all memberships in requested organization", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMembership.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListMembership.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Membership> membershipsInOrganization(
|
public ObjectList<Membership> membershipsInOrganization(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "organization ID", example = "0")
|
@Parameter(description = "organization ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/organization/{}/memberships", id);
|
log.info("invoked method /v1.1/organization/{}/memberships", id);
|
||||||
return service.getMembershipsInOrganization(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getMembershipsInOrganization(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Organisation mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Organisation mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -334,119 +388,137 @@ public class OParlController {
|
||||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||||
public ErrorObject notFound(ResponseStatusException exception) {
|
public ErrorObject notFound(ResponseStatusException exception) {
|
||||||
return ErrorObject.builder()
|
return ErrorObject.builder()
|
||||||
.message(exception.getReason())
|
.message(exception.getReason())
|
||||||
.debug(exception.getLocalizedMessage())
|
.debug(exception.getLocalizedMessage())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/organization/{id}")
|
@GetMapping("/organization/{id}")
|
||||||
@Operation(summary = "information about organization", description = "returns the requested organization", responses = {
|
@Operation(summary = "information about organization", description = "returns the requested organization", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Organization.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Organization.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Organization organization(
|
public Organization organization(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "organization ID", example = "0")
|
@Parameter(description = "organization ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/organization/{}", id);
|
log.info("invoked method /v1.1/organization/{}", id);
|
||||||
return service.getOrganization(id).orElseThrow(() -> {
|
return service.getOrganization(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Organisation mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Organisation mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/organizations")
|
@GetMapping(value = {"/body/{id}/organizations", "/body/{id}/organizations/{pageNumber}"})
|
||||||
@Operation(summary = "List of all organizations in body", description = "returns a list of all organizations in requested body", responses = {
|
@Operation(summary = "List of all organizations in body", description = "returns a list of all organizations in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListOrganization.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListOrganization.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Organization> organizationsInBody(
|
public ObjectList<Organization> organizationsInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/organizations", id);
|
log.info("invoked method /v1.1/body/{}/organizations", id);
|
||||||
return service.getOrganizationsInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getOrganizationsInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/paper/{id}")
|
@GetMapping("/paper/{id}")
|
||||||
@Operation(summary = "information about paper", description = "returns the requested paper", responses = {
|
@Operation(summary = "information about paper", description = "returns the requested paper", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Paper.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Paper.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Paper paper(
|
public Paper paper(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "paper ID", example = "0")
|
@Parameter(description = "paper ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/paper/{}", id);
|
log.info("invoked method /v1.1/paper/{}", id);
|
||||||
return service.getPaper(id).orElseThrow(() -> {
|
return service.getPaper(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Drucksache mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Drucksache mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/papers")
|
@GetMapping(value = {"/body/{id}/papers", "/body/{id}/papers/{pageNumber}"})
|
||||||
@Operation(summary = "List of all papers in body",
|
@Operation(summary = "List of all papers in body",
|
||||||
description = "returns a list of all papers in requested body", responses = {
|
description = "returns a list of all papers in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListPaper.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListPaper.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Paper> papersInBody(
|
public ObjectList<Paper> papersInBody(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/papers", id);
|
log.info("invoked method /v1.1/body/{}/papers", id);
|
||||||
return service.getPapersInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getPapersInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/person/{id}")
|
@GetMapping("/person/{id}")
|
||||||
@Operation(summary = "information about person", description = "returns the requested person", responses = {
|
@Operation(summary = "information about person", description = "returns the requested person", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Person.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = Person.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public Person person(
|
public Person person(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "person ID", example = "0")
|
@Parameter(description = "person ID", example = "0")
|
||||||
String id) {
|
String id) {
|
||||||
log.info("invoked method /v1.1/person/{}", id);
|
log.info("invoked method /v1.1/person/{}", id);
|
||||||
return service.getPerson(id).orElseThrow(() -> {
|
return service.getPerson(id).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Person mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Person mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/body/{id}/persons")
|
@GetMapping(value = {"/body/{id}/persons", "/body/{id}/persons/{pageNumber}"})
|
||||||
@Operation(summary = "List of all persons in body", description = "returns a list of all persons in requested body", responses = {
|
@Operation(summary = "List of all persons in body", description = "returns a list of all persons in requested body", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
@ApiResponse(description = "Successful Operation", responseCode = "200",
|
||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListPerson.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectList.ObjectListPerson.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
@ApiResponse(responseCode = "404", description = "Not found", content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = ErrorObject.class)))
|
schema = @Schema(implementation = ErrorObject.class)))
|
||||||
})
|
})
|
||||||
public ObjectList<Person> persons(
|
public ObjectList<Person> persons(
|
||||||
@PathVariable
|
@PathVariable
|
||||||
@Parameter(description = "body ID", example = "0")
|
@Parameter(description = "body ID", example = "0")
|
||||||
String id) {
|
String id,
|
||||||
|
@PathVariable(required = false)
|
||||||
|
@Parameter(description = "page number", example = "1")
|
||||||
|
Integer pageNumber) {
|
||||||
log.info("invoked method /v1.1/body/{}/persons", id);
|
log.info("invoked method /v1.1/body/{}/persons", id);
|
||||||
return service.getPersonsInBody(id).orElseThrow(() -> {
|
if (pageNumber == null) {
|
||||||
|
pageNumber = 1;
|
||||||
|
}
|
||||||
|
return service.getPersonsInBody(id, pageNumber).orElseThrow(() -> {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Keine Körperschaft mit angefragter ID existiert");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
@Operation(summary = "System information", description = "returns information about the OParl system", responses = {
|
@Operation(summary = "System information", description = "returns information about the OParl system", responses = {
|
||||||
@ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(
|
@ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(
|
||||||
mediaType = "application/json", schema = @Schema(implementation = System.class)
|
mediaType = "application/json", schema = @Schema(implementation = System.class)
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
public System system() {
|
public System system() {
|
||||||
log.info("method invoked /v1.1");
|
log.info("method invoked /v1.1");
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class OParlService {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<AgendaItem>> getAgendaItemsInBody(String bodyID) {
|
public Optional<ObjectList<AgendaItem>> getAgendaItemsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Consultation>> getConsultationsInBody(String bodyID) {
|
public Optional<ObjectList<Consultation>> getConsultationsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<File>> getFilesInBody(String bodyID) {
|
public Optional<ObjectList<File>> getFilesInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<LegislativeTerm>> getLegislativeTermsOfBody(String bodyID) {
|
public Optional<ObjectList<LegislativeTerm>> getLegislativeTermsOfBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Location>> getLocationsInBody(String bodyID) {
|
public Optional<ObjectList<Location>> getLocationsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Meeting>> getMeetingsInBody(String bodyID) {
|
public Optional<ObjectList<Meeting>> getMeetingsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Meeting>> getMeetingsInOrganization(String organizationID) {
|
public Optional<ObjectList<Meeting>> getMeetingsInOrganization(String organizationID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,15 +80,15 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Membership>> getMembershipsInBody(String bodyID) {
|
public Optional<ObjectList<Membership>> getMembershipsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Membership>> getMembershipsInOrganization(String organizationID) {
|
public Optional<ObjectList<Membership>> getMembershipsInOrganization(String organizationID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Organization>> getOrganizationsInBody(String bodyID) {
|
public Optional<ObjectList<Organization>> getOrganizationsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Paper>> getPapersInBody(String bodyID) {
|
public Optional<ObjectList<Paper>> getPapersInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class OParlService {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ObjectList<Person>> getPersonsInBody(String bodyID) {
|
public Optional<ObjectList<Person>> getPersonsInBody(String bodyID, int pageNumber) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnAgendaItemsInBody() throws Exception {
|
void shouldReturnAgendaItemsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getAgendaItemsInBody("0"))
|
BDDMockito.given(service.getAgendaItemsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<AgendaItem>builder().data(List.of(testItem)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<AgendaItem>builder().data(List.of(testItem)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -83,6 +83,34 @@ class OParlControllerTest {
|
||||||
.andReturn();
|
.andReturn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldAssumeFirstPage_WhenNoPageNumberGiven() throws Exception {
|
||||||
|
BDDMockito.given(service.getAgendaItemsInBody("0", 1))
|
||||||
|
.willReturn(Optional.of(
|
||||||
|
ObjectList.<AgendaItem>builder().data(List.of(testItem)).pagination(testPagination).links(testLinks).build()
|
||||||
|
));
|
||||||
|
|
||||||
|
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/agendaItems")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(11)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/AgendaItem")))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
|
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/0/agendaItems/1")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.aMapWithSize(3)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data", Matchers.hasSize(1)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0]", Matchers.aMapWithSize(11)))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0].type", Matchers.equalTo("https://schema.oparl.org/1.1/AgendaItem")))
|
||||||
|
.andExpect(MockMvcResultMatchers.jsonPath("$.data[0].deleted", Matchers.equalTo(false)))
|
||||||
|
.andReturn();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnBody() throws Exception {
|
void shouldReturnBody() throws Exception {
|
||||||
BDDMockito.given(service.getBody("0"))
|
BDDMockito.given(service.getBody("0"))
|
||||||
|
@ -116,7 +144,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnConsultationsInBody() throws Exception {
|
void shouldReturnConsultationsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getConsultationsInBody("0"))
|
BDDMockito.given(service.getConsultationsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Consultation>builder().data(List.of(testConsultation)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Consultation>builder().data(List.of(testConsultation)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -137,7 +165,7 @@ class OParlControllerTest {
|
||||||
BDDMockito.given(service.getBody("2"))
|
BDDMockito.given(service.getBody("2"))
|
||||||
.willReturn(Optional.empty());
|
.willReturn(Optional.empty());
|
||||||
|
|
||||||
BDDMockito.given(service.getMembershipsInBody("2"))
|
BDDMockito.given(service.getMembershipsInBody("2", 1))
|
||||||
.willReturn(Optional.empty());
|
.willReturn(Optional.empty());
|
||||||
|
|
||||||
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/2")
|
mvc.perform(MockMvcRequestBuilders.get("/v1.1/body/2")
|
||||||
|
@ -172,7 +200,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnFilesInBody() throws Exception {
|
void shouldReturnFilesInBody() throws Exception {
|
||||||
BDDMockito.given(service.getFilesInBody("0"))
|
BDDMockito.given(service.getFilesInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<File>builder().data(List.of(testFile)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<File>builder().data(List.of(testFile)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -205,8 +233,8 @@ class OParlControllerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnLegislativeTermsOFBody() throws Exception {
|
void shouldReturnLegislativeTermsOfBody() throws Exception {
|
||||||
BDDMockito.given(service.getLegislativeTermsOfBody("0"))
|
BDDMockito.given(service.getLegislativeTermsOfBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<LegislativeTerm>builder().data(List.of(testTerm)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<LegislativeTerm>builder().data(List.of(testTerm)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -258,7 +286,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnLocationsInBody() throws Exception {
|
void shouldReturnLocationsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getLocationsInBody("0"))
|
BDDMockito.given(service.getLocationsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Location>builder().data(List.of(testLocation)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Location>builder().data(List.of(testLocation)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -290,7 +318,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnMeetingsInBody() throws Exception {
|
void shouldReturnMeetingsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getMeetingsInBody("0"))
|
BDDMockito.given(service.getMeetingsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Meeting>builder().data(List.of(testMeeting)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Meeting>builder().data(List.of(testMeeting)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -308,7 +336,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnMeetingsInOrganization() throws Exception {
|
void shouldReturnMeetingsInOrganization() throws Exception {
|
||||||
BDDMockito.given(service.getMeetingsInOrganization("0"))
|
BDDMockito.given(service.getMeetingsInOrganization("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Meeting>builder().data(List.of(testMeeting)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Meeting>builder().data(List.of(testMeeting)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -341,7 +369,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnMembershipsInBody() throws Exception {
|
void shouldReturnMembershipsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getMembershipsInBody("0"))
|
BDDMockito.given(service.getMembershipsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Membership>builder().data(List.of(testMembership)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Membership>builder().data(List.of(testMembership)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -359,7 +387,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnMembershipsInOrganization() throws Exception {
|
void shouldReturnMembershipsInOrganization() throws Exception {
|
||||||
BDDMockito.given(service.getMembershipsInOrganization("0"))
|
BDDMockito.given(service.getMembershipsInOrganization("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Membership>builder().data(List.of(testMembership)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Membership>builder().data(List.of(testMembership)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -391,7 +419,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnOrganizationsInBody() throws Exception {
|
void shouldReturnOrganizationsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getOrganizationsInBody("0"))
|
BDDMockito.given(service.getOrganizationsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Organization>builder().data(List.of(testOrganization, testPartyOrganization)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Organization>builder().data(List.of(testOrganization, testPartyOrganization)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -423,7 +451,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnPapersInBody() throws Exception {
|
void shouldReturnPapersInBody() throws Exception {
|
||||||
BDDMockito.given(service.getPapersInBody("0"))
|
BDDMockito.given(service.getPapersInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Paper>builder().data(List.of(testPaper)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Paper>builder().data(List.of(testPaper)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
@ -455,7 +483,7 @@ class OParlControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnPersonsInBody() throws Exception {
|
void shouldReturnPersonsInBody() throws Exception {
|
||||||
BDDMockito.given(service.getPersonsInBody("0"))
|
BDDMockito.given(service.getPersonsInBody("0", 1))
|
||||||
.willReturn(Optional.of(
|
.willReturn(Optional.of(
|
||||||
ObjectList.<Person>builder().data(List.of(testPerson)).pagination(testPagination).links(testLinks).build()
|
ObjectList.<Person>builder().data(List.of(testPerson)).pagination(testPagination).links(testLinks).build()
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue