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

Droth 3938 add new side code value based on master #2891

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ class IntegrationApi(val massTransitStopService: MassTransitStopService, implici
"typeOfDamage" -> Try(trafficSignService.getProperty(trafficSign, "type_of_damage").map(_.propertyValue.toInt).get).getOrElse(""),
"urgencyOfRepair" -> Try(trafficSignService.getProperty(trafficSign, "urgency_of_repair").map(_.propertyValue.toInt).get).getOrElse(""),
"lifespanLeft" -> Try(trafficSignService.getProperty(trafficSign, "lifespan_left").map(_.propertyDisplayValue.get.toInt).get).getOrElse(""),
"trafficDirection" -> SideCode.toTrafficDirection(SideCode(trafficSign.validityDirection)).value,
"trafficDirection" -> SideCode.toTrafficDirectionForTrafficSign(SideCode(trafficSign.validityDirection)),
"additionalPanels" -> mapAdditionalPanels(trafficSignService.getAllProperties(trafficSign, "additional_panel").map(_.asInstanceOf[AdditionalPanel]))
)}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,12 @@ object PointAssetStructure {
case object Unknown extends PointAssetStructure { def value = 99; def description = "Ei tiedossa" }
}

case class SideCodeException(msg:String) extends Exception(msg)
sealed trait SideCode {
def value: Int
}
object SideCode {
val values = Set(BothDirections, TowardsDigitizing, AgainstDigitizing, Unknown)
val values = Set(BothDirections, TowardsDigitizing, AgainstDigitizing, Unknown, DoesNotAffectRoadLink)

def apply(intValue: Int): SideCode = {
values.find(_.value == intValue).getOrElse(Unknown)
Expand All @@ -252,9 +253,20 @@ object SideCode {
case AgainstDigitizing => TrafficDirection.AgainstDigitizing
case BothDirections => TrafficDirection.BothDirections
case Unknown => TrafficDirection.UnknownDirection
case DoesNotAffectRoadLink => throw SideCodeException("Cannot convert SideCode 0 into TrafficDirection")
}
}

def toTrafficDirectionForTrafficSign(sideCode: SideCode): Int = {
sideCode match {
case TowardsDigitizing => TrafficDirection.TowardsDigitizing.value
case AgainstDigitizing => TrafficDirection.AgainstDigitizing.value
case BothDirections => TrafficDirection.BothDirections.value
case Unknown => TrafficDirection.UnknownDirection.value
case DoesNotAffectRoadLink => DoesNotAffectRoadLink.value
}
}

case object DoesNotAffectRoadLink extends SideCode { def value = 0 }
case object BothDirections extends SideCode { def value = 1 }
case object TowardsDigitizing extends SideCode { def value = 2 }
case object AgainstDigitizing extends SideCode { def value = 3 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DynamicLinearAssetDao {
def apply(r: PositionedResult) : DynamicAssetRow = {
val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()
val propertyPublicId = r.nextString
Expand All @@ -147,7 +147,7 @@ class DynamicLinearAssetDao {
val verifiedDate = r.nextTimestampOption().map(timestamp => new DateTime(timestamp))
val informationSource = r.nextIntOption()

DynamicAssetRow(id, linkId, sideCode, value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, typeId, timeStamp, geomModifiedDate, linkSource, verifiedBy, verifiedDate, informationSource)
DynamicAssetRow(id, linkId, sideCode.getOrElse(99), value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, typeId, timeStamp, geomModifiedDate, linkSource, verifiedBy, verifiedDate, informationSource)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class LaneDao(){
def apply(r: PositionedResult) = {
val expired = r.nextBoolean()
val value = r.nextInt()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()

LightLane(value, expired, sideCode)
LightLane(value, expired, sideCode.getOrElse(99))
}
}

implicit val getLaneAsset: GetResult[LaneRow] = new GetResult[LaneRow] {
def apply(r: PositionedResult) : LaneRow = {
val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()
val createdBy = r.nextStringOption()
Expand All @@ -61,7 +61,7 @@ class LaneDao(){
val expiredBy = r.nextStringOption()
val expiredDate = r.nextTimestampOption().map(timestamp => new DateTime(timestamp))

LaneRow(id, linkId, sideCode, value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate,
LaneRow(id, linkId, sideCode.getOrElse(99), value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate,
expiredBy, expiredDate, expired, timeStamp, municipalityCode, laneCode, geomModifiedDate)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LaneHistoryDao() {
val newId = r.nextLong()
val oldId = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()
val createdBy = r.nextStringOption()
Expand All @@ -47,7 +47,7 @@ class LaneHistoryDao() {
val historyCreatedBy = r.nextString()
val changeEventOrderNumber = r.nextIntOption()

LaneHistoryRow(id, newId, oldId, linkId, sideCode, value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate,
LaneHistoryRow(id, newId, oldId, linkId, sideCode.getOrElse(99), value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate,
expired, timeStamp, municipalityCode, laneCode, geomModifiedDate, historyCreatedDate, historyCreatedBy, changeEventOrderNumber)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PostGISLinearAssetDao() {

val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val prohibitionId = r.nextLong()
val prohibitionType = r.nextInt()
val validityPeridoType = r.nextIntOption()
Expand All @@ -62,7 +62,7 @@ class PostGISLinearAssetDao() {
val informationSource = r.nextIntOption()
val isSuggested = r.nextBoolean()

ProhibitionsRow(id, linkId, sideCode, prohibitionId, prohibitionType, validityPeridoType, validityPeridoStartHour, validityPeridoEndHour,
ProhibitionsRow(id, linkId, sideCode.getOrElse(99), prohibitionId, prohibitionType, validityPeridoType, validityPeridoStartHour, validityPeridoEndHour,
exceptionType, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, timeStamp,
geomModifiedDate, validityPeridoStartMinute, validityPeridoEndMinute, prohibitionAdditionalInfo, linkSource,
verifiedBy, verifiedDate, informationSource, isSuggested)
Expand All @@ -74,7 +74,7 @@ class PostGISLinearAssetDao() {
def apply(r: PositionedResult) : PersistedLinearAsset = {
val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val value = r.nextIntOption().map(NumericValue)
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()
Expand All @@ -92,7 +92,7 @@ class PostGISLinearAssetDao() {
val informationSource = r.nextIntOption()


PersistedLinearAsset(id, linkId, sideCode, value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, typeId, timeStamp, geomModifiedDate,
PersistedLinearAsset(id, linkId, sideCode.getOrElse(99), value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, typeId, timeStamp, geomModifiedDate,
linkSource, verifiedBy, verifiedDate, informationSource.map(info => InformationSource.apply(info)))
}
}
Expand All @@ -101,7 +101,7 @@ class PostGISLinearAssetDao() {
def apply(r: PositionedResult) = {
val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val value = r.nextIntOption().map(NumericValue)
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()
Expand All @@ -124,8 +124,8 @@ class PostGISLinearAssetDao() {
val administrativeClass = AdministrativeClass(r.nextInt())

val geometry = Seq(Point(startPoint_x, startPoint_y), Point(endPoint_x, endPoint_y))
PieceWiseLinearAsset(id, linkId, SideCode(sideCode), value, geometry, expired, startMeasure, endMeasure,
geometry.toSet, modifiedBy, modifiedDate, createdBy, createdDate, typeId, SideCode.toTrafficDirection(SideCode(sideCode)), timeStamp,
PieceWiseLinearAsset(id, linkId, SideCode(sideCode.getOrElse(99)), value, geometry, expired, startMeasure, endMeasure,
geometry.toSet, modifiedBy, modifiedDate, createdBy, createdDate, typeId, SideCode.toTrafficDirection(SideCode(sideCode.getOrElse(99))), timeStamp,
geomModifiedDate, linkSource, administrativeClass, verifiedBy = verifiedBy, verifiedDate = verifiedDate, informationSource = informationSource.map(info => InformationSource.apply(info)))


Expand All @@ -142,8 +142,8 @@ class PostGISLinearAssetDao() {
val endPoint_x = r.nextDouble()
val endPoint_y = r.nextDouble()
val geometry = Seq(Point(startPoint_x, startPoint_y), Point(endPoint_x, endPoint_y))
val sideCode = r.nextInt()
LightLinearAsset(geometry, value, expired, typeId, sideCode)
val sideCode = r.nextIntOption()
LightLinearAsset(geometry, value, expired, typeId, sideCode.getOrElse(99))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PostGISMaintenanceDao() {
def apply(r: PositionedResult) : DynamicAssetRow = {
val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()

Expand All @@ -89,7 +89,7 @@ class PostGISMaintenanceDao() {
val verifiedDate = r.nextTimestampOption().map(timestamp => new DateTime(timestamp))
val informationSource = r.nextIntOption()

DynamicAssetRow(id, linkId, sideCode, value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, typeId, timeStamp, geomModifiedDate, linkSource, verifiedBy, verifiedDate, informationSource)
DynamicAssetRow(id, linkId, sideCode.getOrElse(99), value, startMeasure, endMeasure, createdBy, createdDate, modifiedBy, modifiedDate, expired, typeId, timeStamp, geomModifiedDate, linkSource, verifiedBy, verifiedDate, informationSource)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PostGISSpeedLimitDao(val roadLinkService: RoadLinkService) extends Dynamic
def apply(r: PositionedResult) : SpeedLimitRow = {
val id = r.nextLong()
val linkId = r.nextString()
val sideCode = r.nextInt()
val sideCode = r.nextIntOption()
val value = r.nextIntOption()
val startMeasure = r.nextDouble()
val endMeasure = r.nextDouble()
Expand All @@ -47,7 +47,7 @@ class PostGISSpeedLimitDao(val roadLinkService: RoadLinkService) extends Dynamic
val linkSource = r.nextInt()
val publicId = r.nextString()

SpeedLimitRow(id, linkId, SideCode(sideCode), value, startMeasure, endMeasure, modifiedBy, modifiedDateTime, createdBy, createdDateTime, timeStamp, geomModifiedDate, expired, linkSource = LinkGeomSource(linkSource), publicId)
SpeedLimitRow(id, linkId, SideCode(sideCode.getOrElse(99)), value, startMeasure, endMeasure, modifiedBy, modifiedDateTime, createdBy, createdDateTime, timeStamp, geomModifiedDate, expired, linkSource = LinkGeomSource(linkSource), publicId)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ object PostGISDirectionalTrafficSignDao {
propertyRequired = propertyRequired,
propertyValue = propertyValue.getOrElse(propertyDisplayValue.getOrElse("")).toString,
propertyDisplayValue = propertyDisplayValue.orNull)
val validityDirection = r.nextInt()
val validityDirection = r.nextIntOption()
val createdBy = r.nextStringOption()
val createdDateTime = r.nextTimestampOption().map(timestamp => new DateTime(timestamp))
val modifiedBy = r.nextStringOption()
Expand All @@ -142,7 +142,7 @@ object PostGISDirectionalTrafficSignDao {
val linkSource = r.nextInt()
val externalId = r.nextStringOption()

DirectionalTrafficSignRow(id, linkId, point.x, point.y, mValue, floating, timeStamp, municipalityCode, property, validityDirection,
DirectionalTrafficSignRow(id, linkId, point.x, point.y, mValue, floating, timeStamp, municipalityCode, property, validityDirection.getOrElse(99),
bearing, createdBy, createdDateTime, modifiedBy, modifiedDateTime, linkSource = LinkGeomSource(linkSource), externalId = externalId)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ object PostGISTrafficSignDao {
val modifiedAt = r.nextTimestampOption().map(timestamp => new DateTime(timestamp))
val linkSource = r.nextInt()
val bearing = r.nextIntOption()
val validityDirection = r.nextInt()
val validityDirection = r.nextIntOption()
val optPanelType = r.nextIntOption()
val panelValue = r.nextStringOption()
val panelInfo = r.nextStringOption()
Expand All @@ -244,7 +244,7 @@ object PostGISTrafficSignDao {
val externalId = r.nextStringOption()

TrafficSignRow(id, linkId, point.x, point.y, mValue, floating, timeStamp, municipalityCode, property,
validityDirection, bearing, createdBy, createdAt, modifiedBy, modifiedAt, LinkGeomSource(linkSource),
validityDirection.getOrElse(99), bearing, createdBy, createdAt, modifiedBy, modifiedAt, LinkGeomSource(linkSource),
additionalPanel, expired, externalId)
}
}
Expand Down