aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/chouette/company.rb1
-rw-r--r--app/models/chouette/journey_pattern.rb1
-rw-r--r--app/models/chouette/line.rb3
-rw-r--r--app/models/chouette/network.rb1
-rw-r--r--app/models/chouette/route.rb1
-rw-r--r--app/models/chouette/stop_area.rb3
-rw-r--r--app/models/chouette/stop_point.rb1
-rw-r--r--app/models/chouette/time_table.rb1
-rw-r--r--app/models/chouette/vehicle_journey.rb1
-rw-r--r--app/models/concerns/object_id_format.rb5
-rw-r--r--app/models/line_referential.rb2
-rw-r--r--app/models/referential.rb3
-rw-r--r--app/models/stop_area_referential.rb2
-rw-r--r--app/models/workbench.rb2
14 files changed, 27 insertions, 0 deletions
diff --git a/app/models/chouette/company.rb b/app/models/chouette/company.rb
index a472020e1..ac7a7a0d9 100644
--- a/app/models/chouette/company.rb
+++ b/app/models/chouette/company.rb
@@ -2,6 +2,7 @@ class Chouette::Company < Chouette::ActiveRecord
include CompanyRestrictions
include StifCodifligneAttributesSupport
include LineReferentialSupport
+ include ObjectIdFormat
has_many :lines
diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb
index fa2a9c8bb..7c801794f 100644
--- a/app/models/chouette/journey_pattern.rb
+++ b/app/models/chouette/journey_pattern.rb
@@ -1,6 +1,7 @@
class Chouette::JourneyPattern < Chouette::TridentActiveRecord
include ChecksumSupport
include JourneyPatternRestrictions
+ include ObjectIdFormat
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index 0139bb6a4..ba48068c9 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -2,6 +2,7 @@ class Chouette::Line < Chouette::ActiveRecord
include StifCodifligneAttributesSupport
include LineRestrictions
include LineReferentialSupport
+ include ObjectIdFormat
extend StifTransportModeEnumerations
extend StifTransportSubmodeEnumerations
@@ -39,6 +40,8 @@ class Chouette::Line < Chouette::ActiveRecord
validates_presence_of :name
+ alias_method :line_referential, :referential
+
scope :by_text, ->(text) { where('lower(name) LIKE :t or lower(published_name) LIKE :t or lower(objectid) LIKE :t or lower(comment) LIKE :t or lower(number) LIKE :t',
t: "%#{text.downcase}%") }
diff --git a/app/models/chouette/network.rb b/app/models/chouette/network.rb
index 8df205789..69a0bd484 100644
--- a/app/models/chouette/network.rb
+++ b/app/models/chouette/network.rb
@@ -2,6 +2,7 @@ class Chouette::Network < Chouette::ActiveRecord
include StifCodifligneAttributesSupport
include NetworkRestrictions
include LineReferentialSupport
+ include ObjectIdFormat
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index 0bdccb36a..66743afbd 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -1,6 +1,7 @@
class Chouette::Route < Chouette::TridentActiveRecord
include RouteRestrictions
include ChecksumSupport
+ include ObjectIdFormat
extend Enumerize
extend ActiveModel::Naming
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index 43bc82f7f..de2d4b01c 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -10,6 +10,7 @@ class Chouette::StopArea < Chouette::ActiveRecord
include ProjectionFields
include StopAreaRestrictions
include StopAreaReferentialSupport
+ include ObjectIdFormat
extend Enumerize
enumerize :area_type, in: %i(zdep zder zdlp zdlr lda)
@@ -26,6 +27,8 @@ class Chouette::StopArea < Chouette::ActiveRecord
belongs_to :stop_area_referential
validates_presence_of :stop_area_referential_id
+ alias_method :stop_area_referential, :referential
+
acts_as_tree :foreign_key => 'parent_id', :order => "name"
attr_accessor :stop_area_type
diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb
index 89c492b91..7490d175b 100644
--- a/app/models/chouette/stop_point.rb
+++ b/app/models/chouette/stop_point.rb
@@ -7,6 +7,7 @@ module Chouette
include ForBoardingEnumerations
include ForAlightingEnumerations
+ include ObjectIdFormat
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb
index 72496273e..868b82f59 100644
--- a/app/models/chouette/time_table.rb
+++ b/app/models/chouette/time_table.rb
@@ -1,6 +1,7 @@
class Chouette::TimeTable < Chouette::TridentActiveRecord
include ChecksumSupport
include TimeTableRestrictions
+ include ObjectIdFormat
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index e534d2bde..ff7f4dc34 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -2,6 +2,7 @@ module Chouette
class VehicleJourney < TridentActiveRecord
include ChecksumSupport
include VehicleJourneyRestrictions
+ include ObjectIdFormat
extend StifTransportModeEnumerations
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/concerns/object_id_format.rb b/app/models/concerns/object_id_format.rb
new file mode 100644
index 000000000..55b93ec81
--- /dev/null
+++ b/app/models/concerns/object_id_format.rb
@@ -0,0 +1,5 @@
+module ObjectIdFormat
+ def object_id_format
+ self.referential.object_id_format
+ end
+end
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index 8bc6adec3..b841ea6a9 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -1,5 +1,6 @@
class LineReferential < ActiveRecord::Base
extend StifTransportModeEnumerations
+ extend Enumerize
has_many :line_referential_memberships
has_many :organisations, through: :line_referential_memberships
@@ -9,6 +10,7 @@ class LineReferential < ActiveRecord::Base
has_many :networks, class_name: 'Chouette::Network'
has_many :line_referential_syncs, -> { order created_at: :desc }
has_many :workbenches
+ enumerize :object_id_format, in: %w(netx netx_stif)
def add_member(organisation, options = {})
attributes = options.merge organisation: organisation
diff --git a/app/models/referential.rb b/app/models/referential.rb
index ed13cd077..37cad3c7d 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -1,5 +1,6 @@
class Referential < ActiveRecord::Base
include DataFormatEnumerations
+ extend Enumerize
validates_presence_of :name
validates_presence_of :slug
@@ -55,6 +56,8 @@ class Referential < ActiveRecord::Base
belongs_to :referential_suite
+ enumerize :object_id_format, in: %w(netx netx_stif)
+
scope :ready, -> { where(ready: true) }
scope :in_periode, ->(periode) { where(id: referential_ids_in_periode(periode)) }
scope :include_metadatas_lines, ->(line_ids) { where('referential_metadata.line_ids && ARRAY[?]::bigint[]', line_ids) }
diff --git a/app/models/stop_area_referential.rb b/app/models/stop_area_referential.rb
index dd206f9e9..a46dbd908 100644
--- a/app/models/stop_area_referential.rb
+++ b/app/models/stop_area_referential.rb
@@ -1,10 +1,12 @@
class StopAreaReferential < ActiveRecord::Base
+ extend Enumerize
has_many :stop_area_referential_memberships
has_many :organisations, through: :stop_area_referential_memberships
has_many :stop_areas, class_name: 'Chouette::StopArea'
has_many :stop_area_referential_syncs, -> {order created_at: :desc}
has_many :workbenches
+ enumerize :object_id_format, in: %w(netx netx_stif)
def add_member(organisation, options = {})
attributes = options.merge organisation: organisation
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index c304e8ba9..9b1bb7e09 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -1,8 +1,10 @@
class Workbench < ActiveRecord::Base
+ extend Enumerize
belongs_to :organisation
belongs_to :line_referential
belongs_to :stop_area_referential
belongs_to :output, class_name: 'ReferentialSuite'
+ enumerize :object_id_format, in: %w(netx netx_stif)
has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential
has_many :networks, through: :line_referential