aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/compliance_control.rb4
-rw-r--r--app/models/compliance_control_block.rb3
-rw-r--r--app/models/concerns/stif_transport_mode_enumerations.rb7
-rw-r--r--app/models/concerns/stif_transport_submode_enumerations.rb7
-rw-r--r--app/models/generic_attribute_control/min_max.rb3
-rw-r--r--app/models/generic_attribute_control/pattern.rb3
-rw-r--r--app/models/generic_attribute_control/uniqueness.rb3
-rw-r--r--app/models/vehicle_journey_control/delta.rb2
-rw-r--r--app/models/vehicle_journey_control/speed.rb (renamed from app/models/route_control/speed.rb)3
-rw-r--r--app/models/vehicle_journey_control/waiting_time.rb1
10 files changed, 26 insertions, 10 deletions
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index e859aaba0..33a075e40 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -3,7 +3,7 @@ class ComplianceControl < ActiveRecord::Base
belongs_to :compliance_control_set
belongs_to :compliance_control_block
- enumerize :criticity, in: %i(info warning error), scope: true, default: :info
+ enumerize :criticity, in: %i(warning error), scope: true, default: :warning
hstore_accessor :control_attributes, {}
validates :criticity, presence: true
@@ -55,7 +55,6 @@ require_dependency 'route_control/minimum_length'
require_dependency 'route_control/omnibus_journey_pattern'
require_dependency 'route_control/opposite_route_terminus'
require_dependency 'route_control/opposite_route'
-require_dependency 'route_control/speed'
require_dependency 'route_control/stop_points_in_journey_pattern'
require_dependency 'route_control/time_table'
require_dependency 'route_control/unactivated_stop_points'
@@ -66,3 +65,4 @@ require_dependency 'routing_constraint_zone_control/minimum_length'
require_dependency 'routing_constraint_zone_control/unactivated_stop_point'
require_dependency 'vehicle_journey_control/delta'
require_dependency 'vehicle_journey_control/waiting_time'
+require_dependency 'vehicle_journey_control/speed'
diff --git a/app/models/compliance_control_block.rb b/app/models/compliance_control_block.rb
index 5721c00f4..2be8d98a0 100644
--- a/app/models/compliance_control_block.rb
+++ b/app/models/compliance_control_block.rb
@@ -12,4 +12,7 @@ class ComplianceControlBlock < ActiveRecord::Base
validates :transport_mode, presence: true
validates :compliance_control_set, presence: true
+ def label_method
+ [transport_mode, transport_submode].compact.map {|x| "[#{x}]"}.join
+ end
end
diff --git a/app/models/concerns/stif_transport_mode_enumerations.rb b/app/models/concerns/stif_transport_mode_enumerations.rb
index dc573b3a0..676154f73 100644
--- a/app/models/concerns/stif_transport_mode_enumerations.rb
+++ b/app/models/concerns/stif_transport_mode_enumerations.rb
@@ -1,10 +1,15 @@
module StifTransportModeEnumerations
extend ActiveSupport::Concern
extend Enumerize
+ extend self
enumerize :transport_mode, in: %w(air bus coach ferry metro rail trolleyBus tram water cableway funicular other)
def transport_modes
- StifTransportModeEnumerations.transport_mode.options.map(&:first)
+ StifTransportModeEnumerations.transport_mode.values
+ end
+
+ def sorted_transport_modes
+ self.transport_modes.sort_by{|m| I18n.t("enumerize.transport_mode.#{m}").parameterize }
end
end
diff --git a/app/models/concerns/stif_transport_submode_enumerations.rb b/app/models/concerns/stif_transport_submode_enumerations.rb
index a150381f3..6322b2dae 100644
--- a/app/models/concerns/stif_transport_submode_enumerations.rb
+++ b/app/models/concerns/stif_transport_submode_enumerations.rb
@@ -1,10 +1,15 @@
module StifTransportSubmodeEnumerations
extend ActiveSupport::Concern
extend Enumerize
+ extend self
enumerize :transport_submode, in: %w(unknown undefined internationalFlight domesticFlight intercontinentalFlight domesticScheduledFlight shuttleFlight intercontinentalCharterFlight internationalCharterFlight roundTripCharterFlight sightseeingFlight helicopterService domesticCharterFlight SchengenAreaFlight airshipService shortHaulInternationalFlight canalBarge localBus regionalBus expressBus nightBus postBus specialNeedsBus mobilityBus mobilityBusForRegisteredDisabled sightseeingBus shuttleBus highFrequencyBus dedicatedLaneBus schoolBus schoolAndPublicServiceBus railReplacementBus demandAndResponseBus airportLinkBus internationalCoach nationalCoach shuttleCoach regionalCoach specialCoach schoolCoach sightseeingCoach touristCoach commuterCoach metro tube urbanRailway local highSpeedRail suburbanRailway regionalRail interregionalRail longDistance intermational sleeperRailService nightRail carTransportRailService touristRailway railShuttle replacementRailService specialTrain crossCountryRail rackAndPinionRailway cityTram localTram regionalTram sightseeingTram shuttleTram trainTram internationalCarFerry nationalCarFerry regionalCarFerry localCarFerry internationalPassengerFerry nationalPassengerFerry regionalPassengerFerry localPassengerFerry postBoat trainFerry roadFerryLink airportBoatLink highSpeedVehicleService highSpeedPassengerService sightseeingService schoolBoat cableFerry riverBus scheduledFerry shuttleFerryService telecabin cableCar lift chairLift dragLift telecabinLink funicular streetCableCar allFunicularServices undefinedFunicular)
def transport_submodes
- StifTransportSubmodeEnumerations.transport_submode.options.map(&:first)
+ StifTransportSubmodeEnumerations.transport_submode.values
+ end
+
+ def sorted_transport_submodes
+ self.transport_submodes.sort_by{|m| I18n.t("enumerize.transport_submode.#{m}").parameterize }
end
end
diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb
index 452d1d889..876f56eed 100644
--- a/app/models/generic_attribute_control/min_max.rb
+++ b/app/models/generic_attribute_control/min_max.rb
@@ -1,6 +1,6 @@
module GenericAttributeControl
class MinMax < ComplianceControl
- hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
+ hstore_accessor :control_attributes, minimum: :integer, maximum: :integer, target: :string
validate :min_max_values
def min_max_values
@@ -8,6 +8,7 @@ module GenericAttributeControl
end
class << self
+ def attribute_type; :integer end
def default_criticity; :warning end
def default_code; "3-Generic-2" end
end
diff --git a/app/models/generic_attribute_control/pattern.rb b/app/models/generic_attribute_control/pattern.rb
index 72bb1770a..6796da84f 100644
--- a/app/models/generic_attribute_control/pattern.rb
+++ b/app/models/generic_attribute_control/pattern.rb
@@ -1,6 +1,6 @@
module GenericAttributeControl
class Pattern < ComplianceControl
- hstore_accessor :control_attributes, value: :string, pattern: :string
+ hstore_accessor :control_attributes, pattern: :string, target: :string
validate :pattern_match
def pattern_match
@@ -8,6 +8,7 @@ module GenericAttributeControl
end
class << self
+ def attribute_type; :string end
def default_criticity; :warning end
def default_code; "3-Generic-3" end
end
diff --git a/app/models/generic_attribute_control/uniqueness.rb b/app/models/generic_attribute_control/uniqueness.rb
index 6ffe78565..f227bf8b6 100644
--- a/app/models/generic_attribute_control/uniqueness.rb
+++ b/app/models/generic_attribute_control/uniqueness.rb
@@ -1,6 +1,6 @@
module GenericAttributeControl
class Uniqueness < ComplianceControl
- hstore_accessor :control_attributes, name: :string
+ hstore_accessor :control_attributes, target: :string
validate :unique_values
def unique_values
@@ -8,6 +8,7 @@ module GenericAttributeControl
end
class << self
+ def attribute_type; :string end
def default_criticity; :warning end
def default_code; "3-Generic-3" end
end
diff --git a/app/models/vehicle_journey_control/delta.rb b/app/models/vehicle_journey_control/delta.rb
index 797072fdd..7be0db261 100644
--- a/app/models/vehicle_journey_control/delta.rb
+++ b/app/models/vehicle_journey_control/delta.rb
@@ -1,7 +1,7 @@
module VehicleJourneyControl
class Delta < ComplianceControl
- hstore_accessor :control_attributes, delta: :integer
+ hstore_accessor :control_attributes, maximum: :integer
def self.default_code; "3-VehicleJourney-3" end
end
diff --git a/app/models/route_control/speed.rb b/app/models/vehicle_journey_control/speed.rb
index d5798d153..cc46ee1f9 100644
--- a/app/models/route_control/speed.rb
+++ b/app/models/vehicle_journey_control/speed.rb
@@ -1,6 +1,5 @@
-module RouteControl
+module VehicleJourneyControl
class Speed < ComplianceControl
-
hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
def self.default_code; "3-VehicleJourney-2" end
diff --git a/app/models/vehicle_journey_control/waiting_time.rb b/app/models/vehicle_journey_control/waiting_time.rb
index 614f401bb..da35bc4a1 100644
--- a/app/models/vehicle_journey_control/waiting_time.rb
+++ b/app/models/vehicle_journey_control/waiting_time.rb
@@ -1,5 +1,6 @@
module VehicleJourneyControl
class WaitingTime < ComplianceControl
+ hstore_accessor :control_attributes, maximum: :integer
def self.default_code; "3-VehicleJourney-1" end
end