aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/referentials_controller.rb2
-rw-r--r--app/exporters/chouette/hub/exporter.rb4
-rw-r--r--app/exporters/chouette/hub/group_of_lines_exporter.rb35
-rw-r--r--app/exporters/chouette/hub/line_exporter.rb3
-rw-r--r--app/views/api/hub/groupe_de_lignes.hub.erb1
-rw-r--r--app/views/api/hub/lignes.hub.erb2
-rw-r--r--config/locales/exports.yml2
7 files changed, 47 insertions, 2 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index bf8a2f1ef..9cf4a5f62 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -26,7 +26,7 @@ class ReferentialsController < BreadcrumbController
@referential ||= current_organisation.referentials.find_by_id(params[:id])
end
def collection
- @referentials ||= current_organisation.referentials
+ @referentials ||= current_organisation.referentials.order(:name)
end
def build_resource
super.tap do |referential|
diff --git a/app/exporters/chouette/hub/exporter.rb b/app/exporters/chouette/hub/exporter.rb
index 091fa75c2..4dcc00045 100644
--- a/app/exporters/chouette/hub/exporter.rb
+++ b/app/exporters/chouette/hub/exporter.rb
@@ -133,6 +133,10 @@ class Chouette::Hub::Exporter
Chouette::Hub::LineExporter.save(@lines, temp_dir, hub_export)
networks = Chouette::Network.where( :id => @lines.map(&:network_id))
companies = Chouette::Network.where( :id => @lines.map(&:company_id))
+ groups_of_lines = []
+ @lines.each { |l| groups_of_lines << l.group_of_lines }
+ groups_of_lines = groups_of_lines.flatten.uniq
+ Chouette::Hub::GroupOfLinesExporter.save(groups_of_lines, temp_dir, hub_export)
Chouette::Hub::NetworkExporter.save(networks, temp_dir, hub_export)
Chouette::Hub::CompanyExporter.save(companies, temp_dir, hub_export)
else
diff --git a/app/exporters/chouette/hub/group_of_lines_exporter.rb b/app/exporters/chouette/hub/group_of_lines_exporter.rb
new file mode 100644
index 000000000..129913c8b
--- /dev/null
+++ b/app/exporters/chouette/hub/group_of_lines_exporter.rb
@@ -0,0 +1,35 @@
+class Chouette::Hub::GroupOfLinesExporter
+ include ERB::Util
+ attr_accessor :group_of_lines, :directory, :template
+
+ def initialize(group_of_lines, directory)
+ @group_of_lines = group_of_lines
+ @directory = directory
+ @template = File.open('app/views/api/hub/groupe_de_lignes.hub.erb' ){ |f| f.read }
+ end
+
+ def render()
+ ERB.new(@template).result(binding)
+ end
+
+ def hub_name
+ "/GROUPELIGNE.TXT"
+ end
+
+ def self.save( groups_of_lines, directory, hub_export)
+ groups_of_lines.each do |group_of_lines|
+ self.new( group_of_lines, directory).tap do |specific_exporter|
+ specific_exporter.save
+ end
+ end
+ hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|GROUP_OF_LINES_COUNT", :arguments => {"0" => groups_of_lines.size})
+ end
+
+ def save
+ File.open(directory + hub_name , "a") do |f|
+ f.write("GROUPELIGNE\n") if f.size == 0
+ f.write(render)
+ end if group_of_lines.present?
+ end
+end
+
diff --git a/app/exporters/chouette/hub/line_exporter.rb b/app/exporters/chouette/hub/line_exporter.rb
index 0d58f3757..f8cf07b60 100644
--- a/app/exporters/chouette/hub/line_exporter.rb
+++ b/app/exporters/chouette/hub/line_exporter.rb
@@ -6,6 +6,9 @@ class Chouette::Hub::LineExporter
@line = line
@directory = directory
@template = File.open('app/views/api/hub/lignes.hub.erb' ){ |f| f.read }
+ if (line.group_of_lines.count > 0)
+ @group_of_line = line.group_of_lines[0].objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ end
end
def render()
diff --git a/app/views/api/hub/groupe_de_lignes.hub.erb b/app/views/api/hub/groupe_de_lignes.hub.erb
new file mode 100644
index 000000000..f098b7a5e
--- /dev/null
+++ b/app/views/api/hub/groupe_de_lignes.hub.erb
@@ -0,0 +1 @@
+<%= @group_of_lines.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @group_of_lines.name %>;<%= @group_of_lines.id %>
diff --git a/app/views/api/hub/lignes.hub.erb b/app/views/api/hub/lignes.hub.erb
index e5d2c4c4c..f8b007044 100644
--- a/app/views/api/hub/lignes.hub.erb
+++ b/app/views/api/hub/lignes.hub.erb
@@ -1 +1 @@
-<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @line.number %>;<%= @line.name %>;;;<%= Chouette::Company.find(@line.company_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= Chouette::Network.find(@line.network_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;;<%= @line.id %>
+<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @line.number %>;<%= @line.name %>;;;<%= Chouette::Company.find(@line.company_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= Chouette::Network.find(@line.network_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @group_of_line %>;<%= @line.id %>
diff --git a/config/locales/exports.yml b/config/locales/exports.yml
index c94dd8d8e..207ec2dc7 100644
--- a/config/locales/exports.yml
+++ b/config/locales/exports.yml
@@ -32,6 +32,7 @@ en:
undefined: "%{key} undefined"
overflow: "Can't export more than %{count} %{data} in a single KML export operation. You should proceed with some exports, each one based on less selected lines."
LINE_COUNT: "Exported line count : %{0}"
+ GROUP_OF_LINES_COUNT: "Exported group of lines count : %{0}"
ROUTE_COUNT: "Route count : %{0}"
JOURNEY_PATTERN_COUNT: "Journey pattern count : %{0}"
QUAY_AND_BOARDING_POSITION_COUNT: "Quays and Boarding positions count : %{0}"
@@ -149,6 +150,7 @@ fr:
undefined: "%{key} non défini"
overflow: "Impossible d'exporter plus de %{count} %{data} en un seul export. Veuillez procéder par exports successifs en sélectionnant une moindre quantité de lignes."
LINE_COUNT: "Nombre de lignes exportées : %{0}"
+ GROUP_OF_LINES_COUNT: "Nombre de groupe de lignes exportés : %{0}"
ROUTE_COUNT: "Nombre de séquences d'arrêts exportées : %{0}"
QUAY_AND_BOARDING_POSITION_COUNT: "Nombre d'arrêts physiques exportés : %{0}"
COMMERCIAL_COUNT: "Nombre d'arrêts commerciaux exportés : %{0}"