Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add info spots #27

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Poster support WIP
  • Loading branch information
culka authored and Leitsi committed Jul 1, 2024
commit dedb736891104b6f7ba4cbdffa2ddc0dea6d5471
20 changes: 17 additions & 3 deletions src/main/java/org/rutebanken/tiamat/model/InfoSpot.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.Cache;
Expand Down Expand Up @@ -39,11 +43,13 @@ public class InfoSpot extends DataManagedObjectStructure implements Serializable
protected DisplayTypeEnumeration displayType;

@ElementCollection(targetClass = StopPlaceReference.class, fetch = FetchType.EAGER)
@CollectionTable(
name = "info_spot_stop_place"
)
@CollectionTable(name = "info_spot_stop_place")
private Set<StopPlaceReference> stopPlaces = new HashSet<>();

@ElementCollection(targetClass = InfoSpotPoster.class, fetch = FetchType.EAGER)
@CollectionTable(name = "info_spot_poster")
private Set<InfoSpotPoster> posters = new HashSet<>();

public String getLabel() {
return label;
}
Expand Down Expand Up @@ -147,4 +153,12 @@ public Set<StopPlaceReference> getStopPlaces() {
public void setStopPlaces(Set<StopPlaceReference> stopPlaces) {
this.stopPlaces = stopPlaces;
}

public Set<InfoSpotPoster> getPosters() {
return posters;
}

public void setPosters(Set<InfoSpotPoster> posters) {
this.posters = posters;
}
}
48 changes: 48 additions & 0 deletions src/main/java/org/rutebanken/tiamat/model/InfoSpotPoster.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.rutebanken.tiamat.model;

import javax.persistence.Embeddable;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

@Embeddable
public class InfoSpotPoster {

private String label;
private String posterType;
private String lines;

@Enumerated(EnumType.STRING)
private PosterSizeEnumeration posterSize;

public String getLabel() {
return label;
}

public void setLabel(String label) {
this.label = label;
}

public String getPosterType() {
return posterType;
}

public void setPosterType(String posterType) {
this.posterType = posterType;
}

public String getLines() {
return lines;
}

public void setLines(String lines) {
this.lines = lines;
}

public PosterSizeEnumeration getPosterSize() {
return posterSize;
}

public void setPosterSize(PosterSizeEnumeration posterSize) {
this.posterSize = posterSize;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.rutebanken.tiamat.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.jvnet.hk2.annotations.Service;
import org.rutebanken.tiamat.model.InfoSpot;
import org.rutebanken.tiamat.model.StopPlace;
import org.rutebanken.tiamat.repository.reference.ReferenceResolver;
import org.springframework.beans.factory.annotation.Autowired;

import static java.util.stream.Collectors.toList;

public class InfoSpotStopPlaceResolver {


private ReferenceResolver referenceResolver;

public List<StopPlace> resolve(InfoSpot infoSpot) {
if(infoSpot.getStopPlaces() != null) {

return infoSpot.getStopPlaces()
.stream()
.map(ref -> {
StopPlace stopPlace = referenceResolver.resolve(ref);
return stopPlace;
})
.filter(Objects::nonNull)
.collect(toList());
}
return new ArrayList<>();
}
}
3 changes: 1 addition & 2 deletions src/main/resources/db/migration/V50__add_info_spots.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ create table info_spot

create table info_spot_poster
(
id bigint primary key,
label character varying(255) primary key,
info_spot_id bigint not null,
label character varying(255),
poster_type character varying(255),
poster_size character varying(255),
lines character varying(255),
Expand Down