Skip to content

Commit

Permalink
Ny datatype: Event
Browse files Browse the repository at this point in the history
På norsk, arrangement. Denne er noe lik Appointment, men vi trenger å
differensiere på avtale, som har et spesifikt oppmøtetidspunkt med
noe som er løsere knyttet til tid, som en konferanse eller et valg.

Appointment er mer oppmøtetidspunkt til MR, sesjon ol.
Event er konferanse, valg ol. som gjerne går over flere dager og
hvor mottager kan komme når en selv vil i et lengre tidsrom.
  • Loading branch information
eivinhb committed May 23, 2019
1 parent ea2a09b commit 7fbb72d
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/no/digipost/api/datatypes/types/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import javax.xml.bind.annotation.XmlRootElement;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.List;

import static java.util.Collections.singletonList;

@XmlRootElement
@Value
@AllArgsConstructor
Expand Down Expand Up @@ -67,10 +68,12 @@ public Appointment withDefaultsForMissingOptionalValues() {
}

public static Appointment EXAMPLE = new Appointment(
ZonedDateTime.of(2017, 6, 27, 10, 0, 0, 0, ZoneId.systemDefault()),
ZonedDateTime.of(2017, 6, 27, 11, 0, 0, 0, ZoneId.systemDefault()),
"Oppmøte senest 15 minutter før timen",
"Oslo City Røntgen", Address.EXAMPLE,
"Undersøke smerter i ryggen", Collections.singletonList(
new Info("Informasjon om Oslo City Røntgen", "Oslo City Røntgen er et spesialistsenter for avansert bildediagnostikk.")));
ZonedDateTime.of(2017, 6, 27, 10, 0, 0, 0, ZoneId.systemDefault())
, ZonedDateTime.of(2017, 6, 27, 11, 0, 0, 0, ZoneId.systemDefault())
, "Oppmøte senest 15 minutter før timen"
, "Oslo City Røntgen"
, Address.EXAMPLE
, "Undersøke smerter i ryggen"
, singletonList(new Info("Informasjon om Oslo City Røntgen", "Oslo City Røntgen er et spesialistsenter for avansert bildediagnostikk."))
);
}
90 changes: 90 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package no.digipost.api.datatypes.types;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;
import no.digipost.api.datatypes.DataType;
import no.digipost.api.datatypes.documentation.Description;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

import static java.util.Collections.singletonList;

@XmlRootElement
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Wither
@Description("Event represents an event that occurs over a time period or several days. Eg. a conference or an election")
public class Event implements DataType {

@XmlElement(name = "sub-title")
@Size(max = 150)
@Description("Example: 'Kommunestyre- og fylkestingvalg'")
String subTitle;

@XmlElement(name = "start-time", required = true)
@NotNull
@NotEmpty
@Description("List of time intervals")
List<TimeInterval> time;

@XmlElement
@Description("Optional label for time. null yield default in gui, eg. 'Opening hours'")
@Size(max = 150)
String timeLabel;

@XmlElement(name = "arrival-time")
@Description("Free text but can contain a ISO8601 DateTime. Example: 'Please use entrance from street'")
@Size(max = 150)
String arrivalTime;

@XmlElement
@Description("The name of the place. Example: 'Sagene skole'")
@Size(max = 150)
String place;

@XmlElement
@Description("Optional label for place. null yield default in gui, eg. 'Venue location'")
@Size(max = 150)
String placeLabel;

@XmlElement
@Valid
Address address;

@XmlElement
@Valid
@Size(max = 2)
@Description("Additional sections of information (max 2) with a title and text.")
List<Info> info;

@XmlElement(name = "barcode")
@Description("Barcode")
Barcode barcode;

@XmlElement(name = "links")
@Description("Links for releated information to the appointment")
List<Link> links;

public static Event EXAMPLE = new Event(
"Kommunestyre- og fylkestingvalg"
, singletonList(TimeInterval.EXAMPLE)
, "Opening hours"
, "Husk legitimasjon"
, "Sagene skole"
, "Election venue"
, Address.EXAMPLE
, singletonList(new Info("Forhåndsstemming", "Du kan forhåndsstemme fra 10. august"))
, Barcode.EXAMPLE
, singletonList(Link.EXAMPLE)
);
}
3 changes: 3 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import no.digipost.api.datatypes.documentation.Description;

import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlElement;
Expand All @@ -20,5 +21,7 @@ public class Info {
String title;

@XmlElement
@Description("The body of the information. Newlines \\n and tabs \\t will be printed formatted.")
String text;

}
36 changes: 36 additions & 0 deletions src/main/java/no/digipost/api/datatypes/types/TimeInterval.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package no.digipost.api.datatypes.types;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;
import no.digipost.api.datatypes.documentation.Description;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.time.ZoneId;
import java.time.ZonedDateTime;

@XmlType
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@Wither
public class TimeInterval {

@XmlElement(name = "start-time", required = true)
@NotNull
@Description("ISO8601 full DateTime")
ZonedDateTime startTime;

@XmlElement(name = "end-time", required = true)
@Description("ISO8601 full DateTime")
ZonedDateTime endTime;

public static TimeInterval EXAMPLE = new TimeInterval(
ZonedDateTime.of(2019, 5, 23, 10, 0, 0, 0, ZoneId.systemDefault())
, ZonedDateTime.of(2019, 5, 23, 16, 0, 0, 0, ZoneId.systemDefault())
);
}

0 comments on commit 7fbb72d

Please sign in to comment.