diff options
Diffstat (limited to 'app/models/chouette')
| -rw-r--r-- | app/models/chouette/journey_pattern.rb | 34 | ||||
| -rw-r--r-- | app/models/chouette/objectid/netex.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/objectid/stif_codifligne.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/objectid/stif_netex.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/objectid/stif_reflex.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/objectid_formater/netex.rb | 18 | ||||
| -rw-r--r-- | app/models/chouette/objectid_formater/stif_codifligne.rb | 18 | ||||
| -rw-r--r-- | app/models/chouette/objectid_formater/stif_netex.rb | 20 | ||||
| -rw-r--r-- | app/models/chouette/objectid_formater/stif_reflex.rb | 18 | ||||
| -rw-r--r-- | app/models/chouette/stop_area.rb | 1 |
10 files changed, 78 insertions, 39 deletions
diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb index dce674791..797b6adb1 100644 --- a/app/models/chouette/journey_pattern.rb +++ b/app/models/chouette/journey_pattern.rb @@ -146,39 +146,5 @@ module Chouette vjas.destroy end end - - def control_route_sections - stop_area_ids = self.stop_points.map(&:stop_area_id) - control_route_sections_by_stop_areas(stop_area_ids) - end - - def control_route_sections_by_stop_areas(stop_area_ids) - journey_pattern_section_all - i = 0 - to_control = false - stop_area_ids.each_cons(2) do |a| - jps = @route_sections_orders[i] - i += 1 - unless jps - to_control = true - next - end - unless [jps.route_section.departure.id, jps.route_section.arrival.id] == a - jps.destroy - to_control = true - end - end - self.control_checked = true - to_control ? self.control! : self.completed! - end - - protected - - def journey_pattern_section_all - @route_sections_orders = {} - self.journey_pattern_sections.all.map do |journey_pattern_section| - @route_sections_orders[journey_pattern_section.rank] = journey_pattern_section - end - end end end diff --git a/app/models/chouette/objectid/netex.rb b/app/models/chouette/objectid/netex.rb index 7953c6b12..0013de7c8 100644 --- a/app/models/chouette/objectid/netex.rb +++ b/app/models/chouette/objectid/netex.rb @@ -30,4 +30,4 @@ module Chouette end end end -end
\ No newline at end of file +end diff --git a/app/models/chouette/objectid/stif_codifligne.rb b/app/models/chouette/objectid/stif_codifligne.rb index a1e40f0a1..c3c19e418 100644 --- a/app/models/chouette/objectid/stif_codifligne.rb +++ b/app/models/chouette/objectid/stif_codifligne.rb @@ -21,4 +21,4 @@ module Chouette end end end -end
\ No newline at end of file +end diff --git a/app/models/chouette/objectid/stif_netex.rb b/app/models/chouette/objectid/stif_netex.rb index 80208af56..4894daac7 100644 --- a/app/models/chouette/objectid/stif_netex.rb +++ b/app/models/chouette/objectid/stif_netex.rb @@ -12,4 +12,4 @@ module Chouette end end end -end
\ No newline at end of file +end diff --git a/app/models/chouette/objectid/stif_reflex.rb b/app/models/chouette/objectid/stif_reflex.rb index 69a3f52fa..711308541 100644 --- a/app/models/chouette/objectid/stif_reflex.rb +++ b/app/models/chouette/objectid/stif_reflex.rb @@ -20,4 +20,4 @@ module Chouette end end end -end
\ No newline at end of file +end diff --git a/app/models/chouette/objectid_formater/netex.rb b/app/models/chouette/objectid_formater/netex.rb new file mode 100644 index 000000000..0736b6ff9 --- /dev/null +++ b/app/models/chouette/objectid_formater/netex.rb @@ -0,0 +1,18 @@ +module Chouette + module ObjectidFormater + class Netex + def before_validation(model) + model.objectid ||= Chouette::Objectid::Netex.new(local_id: SecureRandom.uuid, object_type: model.class.name.gsub(/Chouette::/,'')).to_s + end + + def after_commit(model) + # unused method in this context + end + + def parse_objectid(definition) + parts = definition.split(":") + Chouette::Objectid::Netex.new(provider_id: parts[0], object_type: parts[1], local_id: parts[2], creation_id: parts[3]).to_s rescue nil + end + end + end +end
\ No newline at end of file diff --git a/app/models/chouette/objectid_formater/stif_codifligne.rb b/app/models/chouette/objectid_formater/stif_codifligne.rb new file mode 100644 index 000000000..53fd28c82 --- /dev/null +++ b/app/models/chouette/objectid_formater/stif_codifligne.rb @@ -0,0 +1,18 @@ +module Chouette + module ObjectidFormater + class StifCodifligne + def before_validation(model) + # unused method in this context + end + + def after_commit(model) + # unused method in this context + end + + def parse_objectid(definition) + parts = definition.split(":") + Chouette::Objectid::StifCodifligne.new(provider_id: parts[0], sync_id: parts[1], object_type: parts[2], local_id: parts[3]).to_s rescue nil + end + end + end +end
\ No newline at end of file diff --git a/app/models/chouette/objectid_formater/stif_netex.rb b/app/models/chouette/objectid_formater/stif_netex.rb new file mode 100644 index 000000000..88995dd05 --- /dev/null +++ b/app/models/chouette/objectid_formater/stif_netex.rb @@ -0,0 +1,20 @@ +module Chouette + module ObjectidFormater + class StifNetex + def before_validation(model) + model.objectid ||= "__pending_id__#{rand(50)+ rand(50)}" + end + + def after_commit(model) + if model.objectid.include? ':__pending_id__' + model.objectid = Chouette::Objectid::StifNetex.new(provider_id: "stif", object_type: model.class.name.gsub(/Chouette::/,''), local_id: model.local_id).to_s + end + end + + def parse_objectid(definition) + parts = definition.split(":") + Chouette::Objectid::StifNetex.new(provider_id: parts[0], object_type: parts[1], local_id: parts[2], creation_id: parts[3]).to_s rescue nil + end + end + end +end
\ No newline at end of file diff --git a/app/models/chouette/objectid_formater/stif_reflex.rb b/app/models/chouette/objectid_formater/stif_reflex.rb new file mode 100644 index 000000000..e6c6a6a70 --- /dev/null +++ b/app/models/chouette/objectid_formater/stif_reflex.rb @@ -0,0 +1,18 @@ +module Chouette + module ObjectidFormater + class StifReflex + def before_validation(model) + # unused method in this context + end + + def after_commit(model) + # unused method in this context + end + + def parse_objectid(definition) + parts = definition.split(":") + Chouette::Objectid::StifReflex.new(country_code: parts[0], zip_code: parts[1], object_type: parts[2], local_id: parts[3], provider_id: parts[4]).to_s rescue nil + end + end + end +end
\ No newline at end of file diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index f907f6777..d96381ee8 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -26,7 +26,6 @@ module Chouette has_and_belongs_to_many :routing_stops, :class_name => 'Chouette::StopArea', :foreign_key => "parent_id", :association_foreign_key => "child_id", :join_table => "stop_areas_stop_areas", :order => "stop_areas.name" belongs_to :stop_area_referential - validates_presence_of :stop_area_referential_id acts_as_tree :foreign_key => 'parent_id', :order => "name" |
