2020-07-08 00:06:57 +02:00
|
|
|
package de.twomartens.oparlservice.control;
|
|
|
|
|
|
|
|
import de.twomartens.oparlservice.configs.OParlServiceProperties;
|
2020-07-08 23:01:22 +02:00
|
|
|
import de.twomartens.oparlservice.entity.Body;
|
|
|
|
import de.twomartens.oparlservice.entity.LegislativeTerm;
|
2020-07-08 00:06:57 +02:00
|
|
|
import de.twomartens.oparlservice.entity.System;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2020-07-08 23:01:22 +02:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
2020-07-08 00:06:57 +02:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
2020-07-08 23:01:22 +02:00
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
2020-07-08 00:06:57 +02:00
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
2020-07-08 23:01:22 +02:00
|
|
|
import java.time.LocalDate;
|
2020-07-08 00:06:57 +02:00
|
|
|
import java.time.ZonedDateTime;
|
2020-07-08 23:01:22 +02:00
|
|
|
import java.util.List;
|
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 {
|
|
|
|
private final OParlServiceProperties properties;
|
|
|
|
|
|
|
|
OParlController(OParlServiceProperties properties) {
|
|
|
|
this.properties = properties;
|
|
|
|
}
|
|
|
|
|
2020-07-08 23:01:22 +02:00
|
|
|
@GetMapping("/")
|
2020-07-08 00:06:57 +02:00
|
|
|
@Operation(summary = "System information", description = "returns information about the OParl system")
|
|
|
|
public System system() {
|
2020-07-08 23:01:22 +02:00
|
|
|
log.info("method invoked /v1.1");
|
2020-07-08 00:06:57 +02:00
|
|
|
return System.builder()
|
2020-07-08 23:01:22 +02:00
|
|
|
.id(properties.getUrl() + "/v1.1")
|
2020-07-08 00:06:57 +02:00
|
|
|
.type("https://schema.oparl.org/1.1/System")
|
|
|
|
.license("https://www.govdata.de/dl-de/by-2-0")
|
|
|
|
.created(ZonedDateTime.now())
|
|
|
|
.modified(ZonedDateTime.now())
|
|
|
|
.oparlVersion("https://schema.oparl.org/1.1/")
|
|
|
|
.name("OParl interface for ALLRIS of Hamburg Eimsbüttel")
|
|
|
|
.contactEmail("github@2martens.de")
|
|
|
|
.contactName("Jim Martens")
|
|
|
|
.website("https://sitzungsdienst-eimsbuettel.hamburg.de/bi/")
|
|
|
|
.vendor("https://2martens.de")
|
|
|
|
.product("https://git.2martens.de/2martens/oparl-service")
|
2020-07-08 23:01:22 +02:00
|
|
|
.body(properties.getUrl() + "/bodies")
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/bodies")
|
|
|
|
@Operation(summary = "List of available bodies", description = "returns a list of available bodies in this OParl system")
|
|
|
|
public List<Body> bodies() {
|
|
|
|
log.info("method invoked /v1.1/bodies");
|
|
|
|
LegislativeTerm term = LegislativeTerm.builder()
|
|
|
|
.id(properties.getUrl() + "/v1.1/term/21")
|
|
|
|
.type("https://schema.oparl.org/1.1/LegislativeTerm")
|
|
|
|
.body(properties.getUrl() + "/v1.1/body/0")
|
|
|
|
.name("21. Wahlperiode")
|
|
|
|
.startDate(LocalDate.parse("2019-05-27"))
|
|
|
|
.endDate(LocalDate.parse("2024-05-26"))
|
|
|
|
.created(ZonedDateTime.now())
|
|
|
|
.modified(ZonedDateTime.now())
|
|
|
|
.build();
|
|
|
|
Body eimsbuettel = Body.builder()
|
|
|
|
.id(properties.getUrl() + "/v1.1/body/0")
|
|
|
|
.type("https://schema.oparl.org/1.1/Body")
|
|
|
|
.created(ZonedDateTime.now())
|
|
|
|
.modified(ZonedDateTime.now())
|
|
|
|
.shortName("Hamburg")
|
|
|
|
.name("Bezirk Eimsbüttel")
|
|
|
|
.system(properties.getUrl() + "/v1.1")
|
|
|
|
.legislativeTerm(List.of(term))
|
|
|
|
.website("https://www.hamburg.de/eimsbuettel")
|
|
|
|
.ags("02000000")
|
|
|
|
.rgs("020000000000")
|
|
|
|
.equivalent(List.of("http://dbpedia.org/page/Eimsb%C3%BCttel", "http://d-nb.info/1208293575"))
|
|
|
|
.organization(properties.getUrl() + "/v1.1/organizations/0")
|
|
|
|
.person(properties.getUrl() + "/v1.1/persons/0")
|
|
|
|
.meeting(properties.getUrl() + "/v1.1/meetings/0")
|
|
|
|
.paper(properties.getUrl() + "/v1.1/papers/0")
|
|
|
|
.agendaItem(properties.getUrl() + "/v1.1/agendaItems/0")
|
|
|
|
.consultation(properties.getUrl() + "/v1.1/consultations/0")
|
|
|
|
.file(properties.getUrl() + "/v1.1/files/0")
|
|
|
|
.locationList(properties.getUrl() + "/v1.1/locations/0")
|
|
|
|
.legislativeTermList(properties.getUrl() + "/v1.1/terms")
|
|
|
|
.membership(properties.getUrl() + "/v1.1/memberships/0")
|
|
|
|
.classification("Bezirk")
|
|
|
|
.build();
|
|
|
|
return List.of(eimsbuettel);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/body/{id}")
|
|
|
|
@Operation(summary = "information about body", description = "returns information about the requested body")
|
|
|
|
public Body body(
|
|
|
|
@PathVariable
|
|
|
|
@Parameter(description = "body ID", example = "0")
|
|
|
|
String id) {
|
|
|
|
log.info("method invoked /v1.1/body/{}", id);
|
|
|
|
LegislativeTerm term = LegislativeTerm.builder()
|
|
|
|
.id(properties.getUrl() + "/v1.1/term/21")
|
|
|
|
.type("https://schema.oparl.org/1.1/LegislativeTerm")
|
|
|
|
.body(properties.getUrl() + "/v1.1/body/0")
|
|
|
|
.name("21. Wahlperiode")
|
|
|
|
.startDate(LocalDate.parse("2019-05-27"))
|
|
|
|
.endDate(LocalDate.parse("2024-05-26"))
|
|
|
|
.created(ZonedDateTime.now())
|
|
|
|
.modified(ZonedDateTime.now())
|
|
|
|
.build();
|
|
|
|
return Body.builder()
|
|
|
|
.id(properties.getUrl() + "/v1.1/body/0")
|
|
|
|
.type("https://schema.oparl.org/1.1/Body")
|
|
|
|
.created(ZonedDateTime.now())
|
|
|
|
.modified(ZonedDateTime.now())
|
|
|
|
.shortName("Hamburg")
|
|
|
|
.name("Bezirk Eimsbüttel")
|
|
|
|
.system(properties.getUrl() + "/v1.1")
|
|
|
|
.legislativeTerm(List.of(term))
|
|
|
|
.website("https://www.hamburg.de/eimsbuettel")
|
|
|
|
.ags("02000000")
|
|
|
|
.rgs("020000000000")
|
|
|
|
.equivalent(List.of("http://dbpedia.org/page/Eimsb%C3%BCttel", "http://d-nb.info/1208293575"))
|
|
|
|
.organization(properties.getUrl() + "/v1.1/organizations/0")
|
|
|
|
.person(properties.getUrl() + "/v1.1/persons/0")
|
|
|
|
.meeting(properties.getUrl() + "/v1.1/meetings/0")
|
|
|
|
.paper(properties.getUrl() + "/v1.1/papers/0")
|
|
|
|
.agendaItem(properties.getUrl() + "/v1.1/agendaItems/0")
|
|
|
|
.consultation(properties.getUrl() + "/v1.1/consultations/0")
|
|
|
|
.file(properties.getUrl() + "/v1.1/files/0")
|
|
|
|
.locationList(properties.getUrl() + "/v1.1/locations/0")
|
|
|
|
.legislativeTermList(properties.getUrl() + "/v1.1/terms")
|
|
|
|
.membership(properties.getUrl() + "/v1.1/memberships/0")
|
|
|
|
.classification("Bezirk")
|
2020-07-08 00:06:57 +02:00
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|