Extracted common fields into parent class

This commit is contained in:
Jim Martens 2020-07-08 23:48:33 +02:00
parent 9b570d53c6
commit 21f04fa6e2
6 changed files with 127 additions and 140 deletions

View File

@ -3,49 +3,19 @@ package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
@Builder @SuperBuilder
@Getter @Getter
@ToString @ToString
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class Body { public class Body extends CommonFields {
// 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) @Schema(description = "URL to the system this body belongs to", nullable = true)
private final String system; private final String system;

View File

@ -0,0 +1,44 @@
package de.twomartens.oparlservice.entity;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
import java.time.ZonedDateTime;
@SuperBuilder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@NoArgsConstructor(force = true, access = AccessLevel.PROTECTED)
public class CommonFields {
@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;
}

View File

@ -3,50 +3,19 @@ package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.swing.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
@Builder @SuperBuilder
@Getter @Getter
@ToString @ToString
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class LegislativeTerm { @Schema(allOf = CommonFields.class)
// common fields public class LegislativeTerm extends CommonFields {
@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) @Schema(description = "URL to body this legislative term belongs to", nullable = true)
private final String body; private final String body;

View File

@ -2,47 +2,18 @@ package de.twomartens.oparlservice.entity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder;
import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
@Builder @SuperBuilder
@Getter @Getter
@ToString @ToString
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class Location { @Schema(allOf = CommonFields.class)
// common fields public class Location extends CommonFields {
@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) @Schema(description = "description of the location", nullable = true)
private final String description; private final String description;

View File

@ -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 lombok.experimental.SuperBuilder;
import java.time.LocalDate;
import java.util.List;
@SuperBuilder
@Getter
@ToString
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Schema(allOf = CommonFields.class)
public class Organization extends CommonFields {
@Schema(description = "URL to body this legislative term belongs to", nullable = true)
private final String body;
@Schema(description = "official long name of the organization", nullable = true)
private final String name;
@Schema(description = "short name of the organization", nullable = true)
private final String shortName;
@Schema(description = "List of URLs to memberships", nullable = true)
private final List<String> membership;
@Schema(description = "URL to list of meetings of this organization", nullable = true)
private final String meeting;
@Schema(description = "URL to list of consultations of this organization", nullable = true)
private final String consultation;
@Schema(description = "List of positions available in this organization", nullable = true)
private final List<String> post;
@Schema(description = "URL to a parent organization", nullable = true)
private final String subOrganizationOf;
@Schema(description = "rough categorization of the organization", nullable = true,
allowableValues = "Gremium, Partei, Fraktion, Verwaltungsbereich, externes Gremium, Institution, Sonstiges")
private final String organizationType;
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(description = "founding date of the organization", nullable = true)
private final LocalDate startDate;
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(description = "date of the last day of existance of the organization", nullable = true)
private final LocalDate endDate;
@Schema(description = "URL to the website of the organization", nullable = true)
private final String website;
@Schema(description = "location of the organization", nullable = true)
private final Location location;
@Schema(description = "URL to external OParl body describing this organization", nullable = true)
private final String externalBody;
}

View File

@ -1,51 +1,20 @@
package de.twomartens.oparlservice.entity; package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder;
import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
@Builder @SuperBuilder
@Getter @Getter
@ToString @ToString
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
public class System { @Schema(allOf = CommonFields.class)
// common fields public class System extends CommonFields {
@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
@NonNull @NonNull
@Schema(required = true, description = "URL to the OParl specification supported by this service") @Schema(required = true, description = "URL to the OParl specification supported by this service")
private final String oparlVersion; private final String oparlVersion;