forked from entur/tiamat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Info spot implementation Info spot poster implementation Info spot coordinates Database migration GraphQL API to read and write values GraphQL tests for info spots
- Loading branch information
Showing
26 changed files
with
1,765 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/org/rutebanken/tiamat/model/DisplayTypeEnumeration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
public enum DisplayTypeEnumeration { | ||
ELECTRIC_TFT("electricTFT"), | ||
BATTERY_ONE_ROW("batteryOneRow"), | ||
BATTERY_MULTI_ROW("batteryMultiRow"), | ||
BATTERY_E_INK("batteryEInk"), | ||
CHARGEABLE_E_INK("chargeableEInk"), | ||
NONE("none"); | ||
|
||
private final String value; | ||
|
||
DisplayTypeEnumeration(String v) { | ||
value = v; | ||
} | ||
|
||
public String value() { | ||
return value; | ||
} | ||
|
||
public static DisplayTypeEnumeration fromValue(String v) { | ||
|
||
for (DisplayTypeEnumeration c : DisplayTypeEnumeration.values()) { | ||
if (c.value.equals(v)) { | ||
return c; | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException(v + " is not a valid value of DisplayTypeEnumeration"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
import jakarta.persistence.UniqueConstraint; | ||
import org.hibernate.annotations.Cache; | ||
import org.hibernate.annotations.CacheConcurrencyStrategy; | ||
|
||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) | ||
@Entity | ||
@Table( | ||
uniqueConstraints = { | ||
@UniqueConstraint(name = "info_spot_netex_id_version_constraint", columnNames = {"netexId", "version"})} | ||
) | ||
public class InfoSpot extends InfoSpot_VersionStructure implements Serializable { | ||
|
||
|
||
@Serial | ||
private static final long serialVersionUID = 2459437438760752116L; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/rutebanken/tiamat/model/InfoSpotPoster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
import jakarta.persistence.Entity; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import org.hibernate.annotations.Cache; | ||
import org.hibernate.annotations.CacheConcurrencyStrategy; | ||
|
||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) | ||
@Entity | ||
public class InfoSpotPoster extends InfoSpotPoster_VersionStructure implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 504687562412240224L; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/rutebanken/tiamat/model/InfoSpotPosterRef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
import jakarta.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public class InfoSpotPosterRef extends VersionOfObjectRefStructure { | ||
|
||
public InfoSpotPosterRef() { | ||
|
||
} | ||
|
||
public InfoSpotPosterRef(InfoSpotPoster poster) { | ||
this.setRef(poster.getNetexId()); | ||
this.setVersion(String.valueOf(poster.getVersion())); | ||
} | ||
|
||
public InfoSpotPosterRef(String netexId) { | ||
this.setRef(netexId); | ||
} | ||
|
||
public InfoSpotPosterRef(String netexId, String version) { | ||
this.setRef(netexId); | ||
this.setVersion(version); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/org/rutebanken/tiamat/model/InfoSpotPoster_VersionStructure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.MappedSuperclass; | ||
|
||
@MappedSuperclass | ||
public class InfoSpotPoster_VersionStructure extends DataManagedObjectStructure { | ||
private String label; | ||
private String lines; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private PosterSizeEnumeration posterSize; | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
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; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/rutebanken/tiamat/model/InfoSpotTypeEnumeration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
public enum InfoSpotTypeEnumeration { | ||
STATIC("static"), | ||
DYNAMIC("dynamic"), | ||
SOUND_BEACON("sound_beacon"); | ||
|
||
private final String value; | ||
|
||
InfoSpotTypeEnumeration(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String value() { | ||
return value; | ||
} | ||
|
||
public static InfoSpotTypeEnumeration fromValue(String value) { | ||
for (var c : InfoSpotTypeEnumeration.values()) { | ||
if (c.value.equals(value)) { | ||
return c; | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException(value + " is not a valid value of InfoSpotTypeEnumeration"); | ||
} | ||
} |
151 changes: 151 additions & 0 deletions
151
src/main/java/org/rutebanken/tiamat/model/InfoSpot_VersionStructure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
import jakarta.persistence.CollectionTable; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.ElementCollection; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.MappedSuperclass; | ||
import java.io.Serial; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@MappedSuperclass | ||
public class InfoSpot_VersionStructure extends Zone_VersionStructure { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -4061319784665164923L; | ||
|
||
private InfoSpotTypeEnumeration infoSpotType; | ||
private String label; | ||
private String purpose; | ||
@Enumerated(EnumType.STRING) | ||
private PosterSizeEnumeration posterPlaceSize; | ||
private Boolean backlight; | ||
private String maintenance; | ||
private String zoneLabel; | ||
private String railInformation; | ||
private String floor; | ||
private Boolean speechProperty; | ||
@Enumerated(EnumType.STRING) | ||
private DisplayTypeEnumeration displayType; | ||
|
||
@ElementCollection | ||
@CollectionTable( | ||
name = "info_spot_location" | ||
) | ||
@Column(name="location_netex_id") | ||
private Set<String> infoSpotLocations = new HashSet<>(); | ||
|
||
@ElementCollection(targetClass = InfoSpotPosterRef.class, fetch = FetchType.EAGER) | ||
@CollectionTable( | ||
name = "info_spot_poster_ref" | ||
) | ||
private Set<InfoSpotPosterRef> posters = new HashSet<>(); | ||
|
||
public InfoSpotTypeEnumeration getInfoSpotType() { | ||
return infoSpotType; | ||
} | ||
|
||
public void setInfoSpotType(InfoSpotTypeEnumeration infoSpotType) { | ||
this.infoSpotType = infoSpotType; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public String getPurpose() { | ||
return purpose; | ||
} | ||
|
||
public void setPurpose(String purpose) { | ||
this.purpose = purpose; | ||
} | ||
|
||
public PosterSizeEnumeration getPosterPlaceSize() { | ||
return posterPlaceSize; | ||
} | ||
|
||
public void setPosterPlaceSize(PosterSizeEnumeration posterPlaceSize) { | ||
this.posterPlaceSize = posterPlaceSize; | ||
} | ||
|
||
public Boolean getBacklight() { | ||
return backlight; | ||
} | ||
|
||
public void setBacklight(Boolean backlight) { | ||
this.backlight = backlight; | ||
} | ||
|
||
public String getMaintenance() { | ||
return maintenance; | ||
} | ||
|
||
public void setMaintenance(String maintenance) { | ||
this.maintenance = maintenance; | ||
} | ||
|
||
public String getZoneLabel() { | ||
return zoneLabel; | ||
} | ||
|
||
public void setZoneLabel(String zoneLabel) { | ||
this.zoneLabel = zoneLabel; | ||
} | ||
|
||
public String getRailInformation() { | ||
return railInformation; | ||
} | ||
|
||
public void setRailInformation(String railInformation) { | ||
this.railInformation = railInformation; | ||
} | ||
|
||
public String getFloor() { | ||
return floor; | ||
} | ||
|
||
public void setFloor(String floor) { | ||
this.floor = floor; | ||
} | ||
|
||
public Boolean getSpeechProperty() { | ||
return speechProperty; | ||
} | ||
|
||
public void setSpeechProperty(Boolean speechProperty) { | ||
this.speechProperty = speechProperty; | ||
} | ||
|
||
public DisplayTypeEnumeration getDisplayType() { | ||
return displayType; | ||
} | ||
|
||
public void setDisplayType(DisplayTypeEnumeration displayType) { | ||
this.displayType = displayType; | ||
} | ||
|
||
public Set<String> getInfoSpotLocations() { | ||
return infoSpotLocations; | ||
} | ||
|
||
public void setInfoSpotLocations(Collection<String> infoSpotLocation) { | ||
this.infoSpotLocations = Set.copyOf(infoSpotLocation); | ||
} | ||
|
||
public Set<InfoSpotPosterRef> getPosters() { | ||
return posters; | ||
} | ||
|
||
public void setPosters(Set<InfoSpotPosterRef> posters) { | ||
this.posters = posters; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/rutebanken/tiamat/model/PosterSizeEnumeration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.rutebanken.tiamat.model; | ||
|
||
public enum PosterSizeEnumeration { | ||
A3("a3"), | ||
A4("a4"), | ||
CM80x120("cm80x120"); | ||
|
||
private final String value; | ||
|
||
PosterSizeEnumeration(String v) { | ||
value = v; | ||
} | ||
|
||
public String value() { | ||
return value; | ||
} | ||
|
||
public static PosterSizeEnumeration fromValue(String v) { | ||
|
||
for (PosterSizeEnumeration c : PosterSizeEnumeration.values()) { | ||
if (c.value.equals(v)) { | ||
return c; | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException(v + " is not a valid value of PosterSizeEnumeration"); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/org/rutebanken/tiamat/repository/InfoSpotPosterRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.rutebanken.tiamat.repository; | ||
|
||
import org.rutebanken.tiamat.model.InfoSpotPoster; | ||
|
||
public interface InfoSpotPosterRepository extends InfoSpotPosterRepositoryCustom, EntityInVersionRepository<InfoSpotPoster> { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/org/rutebanken/tiamat/repository/InfoSpotPosterRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.rutebanken.tiamat.repository; | ||
|
||
import org.rutebanken.tiamat.model.InfoSpotPoster; | ||
|
||
public interface InfoSpotPosterRepositoryCustom extends DataManagedObjectStructureRepository<InfoSpotPoster> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/rutebanken/tiamat/repository/InfoSpotPosterRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.rutebanken.tiamat.repository; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.NoResultException; | ||
import jakarta.persistence.PersistenceContext; | ||
import jakarta.persistence.Query; | ||
import jakarta.transaction.Transactional; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.apache.commons.lang3.NotImplementedException; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@Transactional | ||
public class InfoSpotPosterRepositoryImpl implements InfoSpotPosterRepositoryCustom { | ||
|
||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Override | ||
public String findFirstByKeyValues(String key, Set<String> originalIds) { | ||
throw new NotImplementedException("findFirstByKeyValues not implemented for " + this.getClass().getSimpleName()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/rutebanken/tiamat/repository/InfoSpotRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.rutebanken.tiamat.repository; | ||
|
||
import jakarta.persistence.QueryHint; | ||
import java.util.List; | ||
import org.rutebanken.tiamat.model.InfoSpot; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.jpa.repository.QueryHints; | ||
|
||
public interface InfoSpotRepository extends InfoSpotRepositoryCustom, EntityInVersionRepository<InfoSpot> { | ||
|
||
@QueryHints(value = { @QueryHint(name = "org.hibernate.cacheable", value = "true")}, forCounting = false) | ||
@Query("select spot from InfoSpot spot WHERE spot.version = (SELECT MAX(spotv.version) FROM InfoSpot spotv WHERE spotv.netexId = spot.netexId)") | ||
List<InfoSpot> findAllMaxVersion(); | ||
} |
Oops, something went wrong.