diff options
| author | Xinhui | 2016-11-29 15:09:54 +0100 |
|---|---|---|
| committer | Xinhui | 2016-11-29 15:52:39 +0100 |
| commit | bea0f42a318c17878fa99a0adaf3d3e2d2811a06 (patch) | |
| tree | 51d332b4630e5b1ad9afcdbdc6f1e20bd533275b /lib/stif/reflex_synchronization.rb | |
| parent | ac92d7020fe98f43381fc896a5c499e0029c7ac8 (diff) | |
| download | chouette-core-bea0f42a318c17878fa99a0adaf3d3e2d2811a06.tar.bz2 | |
Refactoring stop_area area_type as enumerize
Diffstat (limited to 'lib/stif/reflex_synchronization.rb')
| -rw-r--r-- | lib/stif/reflex_synchronization.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/stif/reflex_synchronization.rb b/lib/stif/reflex_synchronization.rb index c62cbe94f..9408d2c7b 100644 --- a/lib/stif/reflex_synchronization.rb +++ b/lib/stif/reflex_synchronization.rb @@ -45,8 +45,9 @@ module Stif time = Benchmark.measure do stop_areas.each do |entry| next unless is_valid_type_of_place_ref?(method, entry) - self.processed << entry['id'] + entry['TypeOfPlaceRef'] = self.stop_area_area_type entry, method self.create_or_update_stop_area entry + self.processed << entry['id'] end end log_processing_time("Create or update StopArea", time.real) @@ -66,7 +67,15 @@ module Stif def is_valid_type_of_place_ref? method, entry return true if entry["TypeOfPlaceRef"].nil? return true if method == 'getOR' && ['ZDL', 'LDA', 'ZDE'].include?(entry["TypeOfPlaceRef"]) - return true if method == 'getOP' && ['ZDE'].include?(entry["TypeOfPlaceRef"]) + return true if method == 'getOP' && ['ZDE', 'ZDL'].include?(entry["TypeOfPlaceRef"]) + end + + def stop_area_area_type entry, method + type = entry['TypeOfPlaceRef'] + if type + type = "#{type}#{method.last}" unless type == 'LDA' + type.downcase + end end def set_deleted_stop_area @@ -128,7 +137,7 @@ module Stif stop.stop_area_referential = self.defaut_referential { :name => 'Name', - :area_type => 'type', + :area_type => 'TypeOfPlaceRef', :object_version => 'version', :zip_code => 'PostalRegion', :city_name => 'Town' |
