Skip to content

Commit

Permalink
Add eventType and startedAt fields to EventListDto and update convert…
Browse files Browse the repository at this point in the history
…er (#176)

* Add eventType and startedAt fields to EventListDto and update converter

* Move fields eventType and startedAt fields closer to related fields
  • Loading branch information
dqunbp authored Dec 11, 2024
1 parent 0ca72fa commit b43c131
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/kontur/disasterninja/dto/EventListDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ public class EventListDto {

private UUID eventId;
private String eventName;
private String eventType;
private String description;
private String location;
private Severity severity;
private Long affectedPopulation;
private Double settledArea;
private Long osmGaps;
private Long loss;
private OffsetDateTime startedAt;
private OffsetDateTime updatedAt;
private List<String> externalUrls;
private List<Double> bbox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static EventListDto convert(EventApiEventDto event) {
dto.setEventId(event.getEventId());

dto.setEventName(eventName(event));
dto.setEventType(eventType(event));
dto.setDescription(event.getDescription());
dto.setLocation(event.getLocation());
dto.setEpisodeCount(event.getEpisodeCount());
Expand All @@ -37,6 +38,7 @@ public static EventListDto convert(EventApiEventDto event) {
}
}
dto.setUpdatedAt(event.getUpdatedAt());
dto.setStartedAt(event.getStartedAt());

dto.setBbox(event.getBbox());
dto.setCentroid(event.getCentroid());
Expand Down Expand Up @@ -77,4 +79,14 @@ protected static String eventName(EventApiEventDto event) {
}
return eventType.getName();
}

protected static String eventType(EventApiEventDto event) {
EventType eventType;
try {
eventType = EventType.valueOf(event.getType());
} catch (IllegalArgumentException ex) {
eventType = EventType.OTHER;
}
return eventType.name();
}
}

0 comments on commit b43c131

Please sign in to comment.