aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLuc Donnet2017-12-20 10:26:07 +0100
committerGitHub2017-12-20 10:26:07 +0100
commit3df4c7feb809fc6e8eeeec5010147c42447388d8 (patch)
treed121af6b31090bcbb46320cbb3c15e6af3d2cf89 /app
parent2f4094c28cb5f7b32cf40f231e904dafbac7eafb (diff)
parent443de38df52143f72d97308c28ac68f99e009757 (diff)
downloadchouette-core-3df4c7feb809fc6e8eeeec5010147c42447388d8.tar.bz2
Merge pull request #151 from af83/5281-workbench-import-structural-bug-reading-zip
5281 workbench import structural bug reading zip
Diffstat (limited to 'app')
-rw-r--r--app/helpers/common_helper.rb8
-rw-r--r--app/helpers/common_helpers.rb26
-rw-r--r--app/services/zip_service.rb6
-rw-r--r--app/views/imports/_import_messages.html.slim10
-rw-r--r--app/views/imports/show.html.slim3
-rw-r--r--app/workers/workbench_import_worker/object_state_updater.rb4
6 files changed, 26 insertions, 31 deletions
diff --git a/app/helpers/common_helper.rb b/app/helpers/common_helper.rb
new file mode 100644
index 000000000..b515f681b
--- /dev/null
+++ b/app/helpers/common_helper.rb
@@ -0,0 +1,8 @@
+
+module CommonHelper
+ def string_keys_to_symbols enumerable_pairs
+ enumerable_pairs.inject({}){ | hashy, (k, v) |
+ hashy.merge k.to_sym => v
+ }
+ end
+end
diff --git a/app/helpers/common_helpers.rb b/app/helpers/common_helpers.rb
deleted file mode 100644
index 29cabddac..000000000
--- a/app/helpers/common_helpers.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-
-module CommonHelpers
- # TODO: Needs refactoring, but does not seem to be under test
- # so let us refactor this **after** test coverage.
- def access_links_pairs(access_links)
- hpairs = Hash.new
- pairs = Array.new
- access_links.each do |link|
- key = pair_key(link)
- pair = nil
- if (hpairs.has_key? key)
- pair = hpairs[key]
- else
- pair = AccessLinkPair.new
- pairs << pair
- hpairs[key] = pair
- end
- if (link.link_orientation_type == "access_point_to_stop_area")
- pair.from_access_point = link
- else
- pair.to_access_point = link
- end
- end
- pairs
- end
-end
diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb
index a34dd97cc..7166e6448 100644
--- a/app/services/zip_service.rb
+++ b/app/services/zip_service.rb
@@ -57,7 +57,7 @@ class ZipService
current_key,
# Second part of the solution, yield the closed stream
current_output.close_buffer,
- current_spurious,
+ current_spurious.to_a,
foreign_lines)
end
end
@@ -66,7 +66,7 @@ class ZipService
@current_key = entry_key
# First piece of the solution, use internal way to create a Zip::OutputStream
@current_output = Zip::OutputStream.new(StringIO.new(''), true, nil)
- @current_spurious = []
+ @current_spurious = Set.new
@foreign_lines = []
end
@@ -84,7 +84,7 @@ class ZipService
end
def is_foreign_line! entry_name
- STIF::NetexFile::Frame.get_line_object_id(entry_name).tap do | line_object_id |
+ STIF::NetexFile::Frame.get_short_id(entry_name).tap do | line_object_id |
return nil unless line_object_id
return nil if line_object_id.in? allowed_lines
foreign_lines << line_object_id
diff --git a/app/views/imports/_import_messages.html.slim b/app/views/imports/_import_messages.html.slim
new file mode 100644
index 000000000..9ab9226f7
--- /dev/null
+++ b/app/views/imports/_import_messages.html.slim
@@ -0,0 +1,10 @@
+
+- if import_messages.any?
+ dl#import_messages
+ - import_messages.each do | import_message |
+ dt.import_message
+ = import_message.criticity
+ dd.import_message
+ = t( ['import_messages',
+ 'compliance_check_messages',
+ import_message.message_key].join('.'), string_keys_to_symbols(import_message.message_attributes))
diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim
index 5e22e03e0..90c638d78 100644
--- a/app/views/imports/show.html.slim
+++ b/app/views/imports/show.html.slim
@@ -11,6 +11,9 @@
- page_header_content_for @import
+.error_messages
+ = render 'import_messages', import_messages: @import.messages
+
.page_content
.container-fluid
.row
diff --git a/app/workers/workbench_import_worker/object_state_updater.rb b/app/workers/workbench_import_worker/object_state_updater.rb
index e9cc081b7..67bdc0654 100644
--- a/app/workers/workbench_import_worker/object_state_updater.rb
+++ b/app/workers/workbench_import_worker/object_state_updater.rb
@@ -14,7 +14,7 @@ class WorkbenchImportWorker
def update_foreign_lines entry
return if entry.foreign_lines.empty?
workbench_import.messages.create(
- criticity: :warning,
+ criticity: :error,
message_key: 'foreign_lines_in_referential',
message_attributes: {
'source_filename' => workbench_import.file.file.file,
@@ -25,7 +25,7 @@ class WorkbenchImportWorker
def update_spurious entry
return if entry.spurious.empty?
workbench_import.messages.create(
- criticity: :warning,
+ criticity: :error,
message_key: 'inconsistent_zip_file',
message_attributes: {
'source_filename' => workbench_import.file.file.file,