Browse Source

Added bodies and body request and corresponding objects

master
Jim Martens 10 months ago
parent
commit
9b570d53c6
  1. 3
      oparl-server/src/main/java/de/twomartens/oparlservice/configs/OParlServiceProperties.java
  2. 104
      oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java
  3. 134
      oparl-server/src/main/java/de/twomartens/oparlservice/entity/Body.java
  4. 64
      oparl-server/src/main/java/de/twomartens/oparlservice/entity/LegislativeTerm.java
  5. 82
      oparl-server/src/main/java/de/twomartens/oparlservice/entity/Location.java
  6. 23
      oparl-server/src/main/java/de/twomartens/oparlservice/entity/System.java
  7. BIN
      oparl-server/src/main/resources/application.yaml

3
oparl-server/src/main/java/de/twomartens/oparlservice/configs/OParlServiceProperties.java

@ -10,11 +10,10 @@ import org.springframework.context.annotation.Configuration;
public class OParlServiceProperties {
private final Template template = new Template();
private String url;
@Data
public static class Template {
private String greeting;
private String url;
}
}

104
oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java

@ -1,19 +1,24 @@
package de.twomartens.oparlservice.control;
import de.twomartens.oparlservice.configs.OParlServiceProperties;
import de.twomartens.oparlservice.entity.Body;
import de.twomartens.oparlservice.entity.LegislativeTerm;
import de.twomartens.oparlservice.entity.System;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.List;
@Slf4j
@RestController
@RequestMapping(path = "/oparl")
@RequestMapping(path = "/v1.1")
public class OParlController {
private final OParlServiceProperties properties;
@ -21,13 +26,12 @@ public class OParlController {
this.properties = properties;
}
@GetMapping("system/v1.1")
@GetMapping("/")
@Operation(summary = "System information", description = "returns information about the OParl system")
@ResponseBody
public System system() {
log.info("method invoked /oparl/system/v1.1");
log.info("method invoked /v1.1");
return System.builder()
.id(properties.getTemplate().getUrl() + "/oparl/system/v1.1")
.id(properties.getUrl() + "/v1.1")
.type("https://schema.oparl.org/1.1/System")
.license("https://www.govdata.de/dl-de/by-2-0")
.created(ZonedDateTime.now())
@ -39,7 +43,93 @@ public class OParlController {
.website("https://sitzungsdienst-eimsbuettel.hamburg.de/bi/")
.vendor("https://2martens.de")
.product("https://git.2martens.de/2martens/oparl-service")
.body(properties.getTemplate().getUrl() + "/oparl/listBodies/v1.1")
.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")
.build();
}
}

134
oparl-server/src/main/java/de/twomartens/oparlservice/entity/Body.java

@ -0,0 +1,134 @@
package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.ZonedDateTime;
import java.util.List;
@Builder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class Body {
// common fields
@NonNull
@Schema(required = true, description = "The unique identifier of the object")
private final String id;
@NonNull
@Schema(required = true, description = "Namespace URL to the object type schema")
private final String type;
@NonNull
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(required = true, description = "Date and time of the creation of the object")
private final ZonedDateTime created;
@NonNull
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(required = true, description = "Date and time of the last update of the object")
private final ZonedDateTime modified;
@Schema(description = "URL to the license", nullable = true)
private String license;
@Schema(description = "Categorization of the object", nullable = true)
private String keyword;
@Schema(description = "URL of a website that presents the object in the browser", nullable = true)
private String web;
@Schema(description = "True, if the object was deleted")
private final boolean deleted;
// bespoke fields
@Schema(description = "URL to the system this body belongs to", nullable = true)
private final String system;
@NonNull
@Schema(required = true, description = "official long name of the body")
private final String name;
@Schema(description = "short name of the body", nullable = true)
private final String shortName;
@Schema(description = "URL of the website of the body", nullable = true)
private final String website;
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(description = "Date and time from which the specified license is valid", nullable = true)
private final ZonedDateTime licenseValidSince;
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(description = "Date and time from which OParl API has been offered", nullable = true)
private final ZonedDateTime oparlSince;
@Schema(description = "The eight character long official body identifier", nullable = true)
private final String ags;
@Schema(description = "The 12 character long regional identifier", nullable = true)
private final String rgs;
@Schema(description = "list of additional URLs that represent this body", nullable = true)
private final List<String> equivalent;
@Schema(description = "E-Mail-Address for requests related to the body and the parliamentary information system", nullable = true)
private final String contactEmail;
@Schema(description = "Name of the contact person or office reachable by contactEmail", nullable = true)
private final String contactName;
@NonNull
@Schema(required = true, description = "URL to list of organizations in this body")
private final String organization;
@NonNull
@Schema(required = true, description = "URL to list of persons in this body")
private final String person;
@NonNull
@Schema(required = true, description = "URL to list of meetings in this body")
private final String meeting;
@NonNull
@Schema(required = true, description = "URL to list of papers (Drucksachen) in this body")
private final String paper;
@NonNull
@Schema(required = true, description = "List of all legislative terms of this body")
private final List<LegislativeTerm> legislativeTerm;
@NonNull
@Schema(required = true, description = "URL to list of all agenda items in this body")
private final String agendaItem;
@NonNull
@Schema(required = true, description = "URL to list of all consultations in this body")
private final String consultation;
@NonNull
@Schema(required = true, description = "URL to list of all files in this body")
private final String file;
@NonNull
@Schema(required = true, description = "URL to list of all locations in this body")
private final String locationList;
@NonNull
@Schema(required = true, description = "URL to list of all legislative terms in this body")
private final String legislativeTermList;
@NonNull
@Schema(required = true, description = "URL to list of all memberships in this body")
private final String membership;
@Schema(description = "physical location of the body", nullable = true)
private final Location location;
@Schema(description = "classification of the body")
private final String classification;
}

64
oparl-server/src/main/java/de/twomartens/oparlservice/entity/LegislativeTerm.java

@ -0,0 +1,64 @@
package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.swing.*;
import java.time.LocalDate;
import java.time.ZonedDateTime;
@Builder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class LegislativeTerm {
// common fields
@NonNull
@Schema(required = true, description = "The unique identifier of the object")
private final String id;
@NonNull
@Schema(required = true, description = "Namespace URL to the object type schema")
private final String type;
@NonNull
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(required = true, description = "Date and time of the creation of the object")
private final ZonedDateTime created;
@NonNull
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(required = true, description = "Date and time of the last update of the object")
private final ZonedDateTime modified;
@Schema(description = "URL to the license", nullable = true)
private String license;
@Schema(description = "Categorization of the object", nullable = true)
private String keyword;
@Schema(description = "URL of a website that presents the object in the browser", nullable = true)
private String web;
@Schema(description = "True, if the object was deleted")
private final boolean deleted;
// bespoke fields
@Schema(description = "URL to body this legislative term belongs to", nullable = true)
private final String body;
@Schema(description = "User friendly name of legislative term", nullable = true)
private final String name;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
@Schema(description = "First day of legislative term", nullable = true)
private final LocalDate startDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
@Schema(description = "Last day of legislative term", nullable = true)
private final LocalDate endDate;
}

82
oparl-server/src/main/java/de/twomartens/oparlservice/entity/Location.java

@ -0,0 +1,82 @@
package de.twomartens.oparlservice.entity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.ZonedDateTime;
import java.util.List;
@Builder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class Location {
// common fields
@NonNull
@Schema(required = true, description = "The unique identifier of the object")
private final String id;
@NonNull
@Schema(required = true, description = "Namespace URL to the object type schema")
private final String type;
@NonNull
@Schema(required = true, description = "Date and time of the creation of the object")
private final ZonedDateTime created;
@NonNull
@Schema(required = true, description = "Date and time of the last update of the object")
private final ZonedDateTime modified;
@Schema(description = "URL to the license", nullable = true)
private String license;
@Schema(description = "Categorization of the object", nullable = true)
private String keyword;
@Schema(description = "URL of a website that presents the object in the browser", nullable = true)
private String web;
@Schema(description = "True, if the object was deleted")
private final boolean deleted;
// bespoke fields
@Schema(description = "description of the location", nullable = true)
private final String description;
@Schema(description = "GeoJSON object of the location", nullable = true)
private final Object geojson;
@Schema(description = "street address of the location", nullable = true)
private final String streetAddress;
@Schema(description = "room information of the location", nullable = true)
private final String room;
@Schema(description = "postal code of the location", nullable = true)
private final String postalCode;
@Schema(description = "lower rank locality of the location", nullable = true)
private final String subLocality;
@Schema(description = "locality of the location", nullable = true)
private final String locality;
@Schema(description = "List of URLS to bodies this location is used for", nullable = true)
private final List<String> bodies;
@Schema(description = "List of URLS to organizations this location is used for", nullable = true)
private final List<String> organizations;
@Schema(description = "List of URLS to persons this location is used for", nullable = true)
private final List<String> persons;
@Schema(description = "List of URLS to meetings this location is used for", nullable = true)
private final List<String> meetings;
@Schema(description = "List of URLS to papers this location is used for", nullable = true)
private final List<String> papers;
}

23
oparl-server/src/main/java/de/twomartens/oparlservice/entity/System.java

@ -1,5 +1,6 @@
package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -23,20 +24,22 @@ public class System {
private final String type;
@NonNull
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(required = true, description = "Date and time of the creation of the object")
private final ZonedDateTime created;
@NonNull
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(required = true, description = "Date and time of the last update of the object")
private final ZonedDateTime modified;
@Schema(description = "URL to the license")
@Schema(description = "URL to the license", nullable = true)
private String license;
@Schema(description = "Categorization of the object")
@Schema(description = "Categorization of the object", nullable = true)
private String keyword;
@Schema(description = "URL of a website that presents the object in the browser")
@Schema(description = "URL of a website that presents the object in the browser", nullable = true)
private String web;
@Schema(description = "True, if the object was deleted")
@ -47,28 +50,28 @@ public class System {
@Schema(required = true, description = "URL to the OParl specification supported by this service")
private final String oparlVersion;
@Schema(description = "Contains a list of URLs to System objects supporting another Oparl version")
@Schema(description = "Contains a list of URLs to System objects supporting another Oparl version", nullable = true)
private final List<String> otherOparlVersions;
@NonNull
@Schema(required = true, description = "URL to the list of all bodies existing in this system")
private final String body;
@Schema(description = "User friendly name for this system")
@Schema(description = "User friendly name for this system", nullable = true)
private final String name;
@Schema(description = "E-Mail-Address for requests related to the OParl-API")
@Schema(description = "E-Mail-Address for requests related to the OParl-API", nullable = true)
private final String contactEmail;
@Schema(description = "Name of the contact person who can be reached by contactEmail")
@Schema(description = "Name of the contact person who can be reached by contactEmail", nullable = true)
private final String contactName;
@Schema(description = "URL of the website of the parliamentary information system")
@Schema(description = "URL of the website of the parliamentary information system", nullable = true)
private final String website;
@Schema(description = "URL to the website of the software creator of the OParl server software")
@Schema(description = "URL to the website of the software creator of the OParl server software", nullable = true)
private final String vendor;
@Schema(description = "URL to information about the OParl server software utilized by this system")
@Schema(description = "URL to information about the OParl server software utilized by this system", nullable = true)
private final String product;
}

BIN
oparl-server/src/main/resources/application.yaml

Loading…
Cancel
Save