ncs_mdes_warehouse 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/Rakefile +15 -1
- data/lib/ncs_navigator/warehouse/configuration.rb +16 -0
- data/lib/ncs_navigator/warehouse/database_initializer.rb +1 -0
- data/lib/ncs_navigator/warehouse/transformers.rb +1 -0
- data/lib/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer.rb +98 -0
- data/lib/ncs_navigator/warehouse/version.rb +1 -1
- data/spec/ncs_navigator/warehouse/configuration_spec.rb +44 -0
- data/spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb +94 -0
- data/spec/spec_helper.rb +21 -30
- data/spec/spec_warehouse_config.rb +30 -0
- data/spec/warehouse_record_creation_helpers.rb +47 -0
- metadata +11 -4
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
NCS Navigator MDES Warehouse History
|
2
2
|
====================================
|
3
3
|
|
4
|
+
0.6.2
|
5
|
+
-----
|
6
|
+
|
7
|
+
- Added `Configuration#model` to find a model class for a particular
|
8
|
+
table name or unqualified class name in the current MDES version.
|
9
|
+
|
10
|
+
- Added transformer for automatically setting event start dates from
|
11
|
+
the earliest associated contact (if any). (#2194)
|
12
|
+
|
4
13
|
0.6.1
|
5
14
|
-----
|
6
15
|
|
data/Rakefile
CHANGED
@@ -21,6 +21,20 @@ namespace :spec do
|
|
21
21
|
RSpec::Core::RakeTask.new(:all) do |t|
|
22
22
|
t.pattern = ENV['SPEC_PATTERN'] || "spec/**/*_spec.rb"
|
23
23
|
end
|
24
|
+
|
25
|
+
task :load_path do
|
26
|
+
$LOAD_PATH.unshift File.expand_path('../spec', __FILE__)
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Creates the database for the specs'
|
30
|
+
task :db => :load_path do
|
31
|
+
require 'spec_warehouse_config'
|
32
|
+
NcsNavigator::Warehouse::Spec.database_initializer.tap do |init|
|
33
|
+
init.set_up_repository(:both)
|
34
|
+
init.replace_schema
|
35
|
+
init.clone_working_to_reporting
|
36
|
+
end
|
37
|
+
end
|
24
38
|
end
|
25
39
|
|
26
40
|
namespace :generate do
|
@@ -40,5 +54,5 @@ namespace :ci do
|
|
40
54
|
ENV['SPEC_OPTS'] = "#{ENV['SPEC_OPTS']} --format nested --no-color"
|
41
55
|
end
|
42
56
|
|
43
|
-
task :spec => [:spec_setup, 'ci:setup:rspecbase', 'rake:spec']
|
57
|
+
task :spec => [:spec_setup, 'ci:setup:rspecbase', 'rake:spec:db', 'rake:spec']
|
44
58
|
end
|
@@ -161,6 +161,22 @@ module NcsNavigator::Warehouse
|
|
161
161
|
end
|
162
162
|
private :set_default_mdes_version
|
163
163
|
|
164
|
+
##
|
165
|
+
# @param [String,Symbol] table_or_model_name either an MDES table
|
166
|
+
# name or the unqualified name of an MDES Warehouse model
|
167
|
+
#
|
168
|
+
# @return [Class,nil] the model in the current MDES version
|
169
|
+
# corresponding to the given model or table name, or nil if
|
170
|
+
# there is no such model
|
171
|
+
def model(table_or_model_name)
|
172
|
+
begin
|
173
|
+
models_module.const_get(table_or_model_name)
|
174
|
+
rescue NameError
|
175
|
+
models_module.mdes_order.
|
176
|
+
find { |model| model.mdes_table_name.to_s == table_or_model_name.to_s }
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
164
180
|
####
|
165
181
|
#### Suite configuration
|
166
182
|
####
|
@@ -15,6 +15,7 @@ module NcsNavigator::Warehouse
|
|
15
15
|
autoload :CodedAsMissingFilter, 'ncs_navigator/warehouse/transformers/coded_as_missing_filter'
|
16
16
|
autoload :Database, 'ncs_navigator/warehouse/transformers/database'
|
17
17
|
autoload :EnumTransformer, 'ncs_navigator/warehouse/transformers/enum_transformer'
|
18
|
+
autoload :EventStartFromContactTransformer, 'ncs_navigator/warehouse/transformers/event_start_from_contact_transformer'
|
18
19
|
autoload :Filters, 'ncs_navigator/warehouse/transformers/filters'
|
19
20
|
autoload :NoBlankForeignKeysFilter, 'ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter'
|
20
21
|
autoload :NoSsuOutreachAllSsusFilter, 'ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter'
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'ncs_navigator/warehouse'
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module NcsNavigator::Warehouse::Transformers
|
6
|
+
##
|
7
|
+
# This transformer finds all events without start dates and attempts
|
8
|
+
# to set them from the earliest associated contact.
|
9
|
+
class EventStartFromContactTransformer
|
10
|
+
extend Forwardable
|
11
|
+
attr_reader :configuration
|
12
|
+
|
13
|
+
def_delegators :@configuration, :log, :shell
|
14
|
+
|
15
|
+
def initialize(configuration)
|
16
|
+
@configuration = configuration
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Implements this transformer's behavior.
|
21
|
+
#
|
22
|
+
# @param [TransformStatus] status
|
23
|
+
# @return [void]
|
24
|
+
def transform(status)
|
25
|
+
configuration.model(:Event).all(:event_start_date.like => '9%').each do |event|
|
26
|
+
candidates = ::DataMapper.repository.adapter.select(%Q{
|
27
|
+
SELECT c.contact_date, c.contact_start_time
|
28
|
+
FROM link_contact lc INNER JOIN contact c ON lc.contact_id=c.contact_id
|
29
|
+
WHERE lc.event_id='#{event.event_id}'
|
30
|
+
ORDER BY c.contact_date, c.contact_start_time
|
31
|
+
})
|
32
|
+
|
33
|
+
start_date = candidates.
|
34
|
+
select { |dt| dt.contact_date !~ /^9/ }.collect { |dt| dt.contact_date }.uniq.first
|
35
|
+
start_time = candidates.
|
36
|
+
select { |dt| dt.contact_date == start_date && dt.contact_start_time !~ /^9/ }.
|
37
|
+
collect { |dt| dt.contact_start_time }.first
|
38
|
+
|
39
|
+
if start_date || start_time
|
40
|
+
event.event_start_date = start_date if start_date
|
41
|
+
event.event_start_time = start_time if start_time
|
42
|
+
|
43
|
+
save(event, status)
|
44
|
+
|
45
|
+
status.record_count += 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# TODO: share this stuff between here and EnumTransformer
|
53
|
+
|
54
|
+
def save(record, status)
|
55
|
+
if record.valid?
|
56
|
+
log.debug("Saving valid transformed event record #{record_ident record}.")
|
57
|
+
begin
|
58
|
+
unless record.save
|
59
|
+
msg = "Could not save valid record #{record.inspect}. #{record_messages(record).join(' ')}"
|
60
|
+
log.error msg
|
61
|
+
status.unsuccessful_record(record, msg)
|
62
|
+
end
|
63
|
+
rescue => e
|
64
|
+
msg = "Error on save. #{e.class}: #{e}."
|
65
|
+
log.error msg
|
66
|
+
status.unsuccessful_record(record, msg)
|
67
|
+
end
|
68
|
+
else
|
69
|
+
log.error "Event invalid after transformation. #{record_messages(record).join(' ')}"
|
70
|
+
record.errors.keys.each do |prop|
|
71
|
+
record.errors[prop].each do |e|
|
72
|
+
status.unsuccessful_record(
|
73
|
+
record, "Invalid after transformation: #{e}.",
|
74
|
+
:attribute_name => prop,
|
75
|
+
:attribute_value => record.send(prop).inspect
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def record_messages(record)
|
83
|
+
record.errors.keys.collect { |prop|
|
84
|
+
record.errors[prop].collect { |e|
|
85
|
+
v = record.send(prop)
|
86
|
+
"#{e} (#{prop}=#{v.inspect})."
|
87
|
+
}
|
88
|
+
}.flatten
|
89
|
+
end
|
90
|
+
|
91
|
+
def record_ident(rec)
|
92
|
+
# No composite keys in the MDES
|
93
|
+
'%s %s=%s' % [
|
94
|
+
rec.class.name.demodulize, rec.class.key.first.name, rec.key.try(:first).inspect]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -127,6 +127,50 @@ module NcsNavigator::Warehouse
|
|
127
127
|
# see above for test of non-default value
|
128
128
|
end
|
129
129
|
|
130
|
+
describe '#model' do
|
131
|
+
context 'for a known version', :slow, :use_mdes, :modifies_warehouse_state do
|
132
|
+
describe 'by table name' do
|
133
|
+
let(:actual) { config.model('link_contact') }
|
134
|
+
|
135
|
+
it 'finds the model' do
|
136
|
+
actual.to_s.should =~ /LinkContact$/
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'returns a class' do
|
140
|
+
actual.should be_a Class
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'returns a class in the models module' do
|
144
|
+
actual.to_s.should =~ %r[^#{config.models_module.to_s}]
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'returns nil if no match' do
|
148
|
+
config.model('quux').should be_nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe 'by model name' do
|
153
|
+
let(:actual) { config.model(:Person) }
|
154
|
+
|
155
|
+
it 'finds the model' do
|
156
|
+
actual.to_s.should =~ /Person$/
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'returns a class' do
|
160
|
+
actual.should be_a Class
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'returns a class in the models module' do
|
164
|
+
actual.to_s.should =~ %r[^#{config.models_module.to_s}]
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'returns nil if no match' do
|
168
|
+
config.model(:Foo).should be_nil
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
130
174
|
describe '#navigator' do
|
131
175
|
it 'defaults to the global default instance' do
|
132
176
|
config.navigator.should be(NcsNavigator.configuration)
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'warehouse_record_creation_helpers'
|
3
|
+
|
4
|
+
module NcsNavigator::Warehouse::Transformers
|
5
|
+
describe EventStartFromContactTransformer, :use_database, :slow do
|
6
|
+
include_context :warehouse_record_creation_helpers
|
7
|
+
|
8
|
+
let(:transformer) { EventStartFromContactTransformer.new(spec_config) }
|
9
|
+
let(:transform_status) { NcsNavigator::Warehouse::TransformStatus.memory_only('test') }
|
10
|
+
|
11
|
+
def create_contact_for_event(event, contact_attributes)
|
12
|
+
contact = create_warehouse_record_with_defaults(:Contact, contact_attributes)
|
13
|
+
create_warehouse_record_with_defaults(:LinkContact,
|
14
|
+
:contact_link_id => "LC_#{event.event_id}_#{contact.contact_id}",
|
15
|
+
:event => event, :contact => contact, :staff => staff
|
16
|
+
)
|
17
|
+
contact
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:staff) { create_warehouse_record_with_defaults(:Staff, :staff_id => 'foo') }
|
21
|
+
|
22
|
+
let!(:ok_event) {
|
23
|
+
create_warehouse_record_with_defaults(:Event,
|
24
|
+
:event_id => 'E_OK', :event_start_date => '2010-09-04')
|
25
|
+
}
|
26
|
+
let!(:ok_event_contact) {
|
27
|
+
create_contact_for_event(ok_event,
|
28
|
+
:contact_id => 'C_OK', :contact_date => '2010-09-01')
|
29
|
+
}
|
30
|
+
|
31
|
+
let!(:bare_event) {
|
32
|
+
create_warehouse_record_with_defaults(:Event,
|
33
|
+
:event_id => 'E_BARE', :event_start_date => '9666-96-96'
|
34
|
+
)
|
35
|
+
}
|
36
|
+
|
37
|
+
let!(:bad_event) {
|
38
|
+
create_warehouse_record_with_defaults(:Event,
|
39
|
+
:event_id => 'E_BAD', :event_start_date => '9666-96-96')
|
40
|
+
}
|
41
|
+
let!(:bad_event_contact_0) {
|
42
|
+
create_contact_for_event(bad_event,
|
43
|
+
:contact_id => 'C_BAD_0', :contact_date => '2010-02-07', :contact_start_time => '00:00')
|
44
|
+
}
|
45
|
+
let!(:bad_event_contact_1) {
|
46
|
+
create_contact_for_event(bad_event,
|
47
|
+
:contact_id => 'C_BAD_1', :contact_date => '2010-02-05', :contact_start_time => '96:96')
|
48
|
+
}
|
49
|
+
let!(:bad_event_contact_2) {
|
50
|
+
create_contact_for_event(bad_event,
|
51
|
+
:contact_id => 'C_BAD_2', :contact_date => '2010-02-05', :contact_start_time => '03:21')
|
52
|
+
}
|
53
|
+
let!(:bad_event_contact_3) {
|
54
|
+
create_contact_for_event(bad_event,
|
55
|
+
:contact_id => 'C_BAD_3', :contact_date => '2010-02-05', :contact_start_time => '02:34')
|
56
|
+
}
|
57
|
+
let!(:bad_event_contact_4) {
|
58
|
+
create_contact_for_event(bad_event,
|
59
|
+
:contact_id => 'C_BAD_4', :contact_date => '9666-97-97', :contact_start_time => '01:10')
|
60
|
+
}
|
61
|
+
|
62
|
+
def reload(record)
|
63
|
+
record.model.first(record.model.key.first => record.key.first)
|
64
|
+
end
|
65
|
+
|
66
|
+
before do
|
67
|
+
transformer.transform(transform_status)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'leaves events with start dates alone' do
|
71
|
+
reload(ok_event).event_start_date.should == '2010-09-04'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'leaves events without contacts alone' do
|
75
|
+
reload(bare_event).event_start_date.should == '9666-96-96'
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'for an event without a start date' do
|
79
|
+
let(:fixed_event) { reload(bad_event) }
|
80
|
+
|
81
|
+
it "takes the event start date from the earliest associated contact's start date" do
|
82
|
+
fixed_event.event_start_date.should == '2010-02-05'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "takes the event start time from the earliest associated contact's start time" do
|
86
|
+
fixed_event.event_start_time.should == '02:34'
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'records the number events changed' do
|
90
|
+
transform_status.record_count.should == 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,7 @@ require 'ncs_navigator/configuration'
|
|
9
9
|
$LOAD_PATH.push File.expand_path('..', __FILE__)
|
10
10
|
|
11
11
|
require 'global_state_helper'
|
12
|
+
require 'spec_warehouse_config'
|
12
13
|
|
13
14
|
require 'dm-core'
|
14
15
|
|
@@ -21,17 +22,11 @@ RSpec.configure do |config|
|
|
21
22
|
# multiple times. It also contains the configuration pointing to the
|
22
23
|
# test database schemas.
|
23
24
|
def spec_config
|
24
|
-
|
25
|
-
end
|
25
|
+
require 'spec_warehouse_config'
|
26
26
|
|
27
|
-
|
28
|
-
@spec_config ||= NcsNavigator::Warehouse::Configuration.new.tap do |c|
|
29
|
-
c.mdes_version = spec_mdes_version
|
27
|
+
@spec_config ||= NcsNavigator::Warehouse::Spec.configuration.tap do |c|
|
30
28
|
c.output_level = :quiet
|
31
29
|
c.log_file = tmpdir + 'spec.log'
|
32
|
-
c.bcdatabase_group = ENV['CI_RUBY'] ? :public_ci_postgresql9 : :local_postgresql
|
33
|
-
c.bcdatabase_entries[:working] = :mdes_warehouse_working_test
|
34
|
-
c.bcdatabase_entries[:reporting] = :mdes_warehouse_reporting_test
|
35
30
|
end
|
36
31
|
end
|
37
32
|
|
@@ -41,26 +36,18 @@ RSpec.configure do |config|
|
|
41
36
|
# @param name [Symbol] an MDES table name or a warehouse model name
|
42
37
|
# @return [Class]
|
43
38
|
def mdes_model(name)
|
44
|
-
|
45
|
-
spec_config.models_module.const_get(name)
|
46
|
-
rescue NameError
|
47
|
-
spec_config.models_module.mdes_order.find { |model| model.mdes_table_name.to_s == name.to_s }
|
48
|
-
end
|
39
|
+
spec_config.model(name)
|
49
40
|
end
|
50
41
|
|
51
42
|
###### MDES model loading
|
52
43
|
|
53
|
-
# Each test run can only operate against one version of the MDES at
|
54
|
-
# a time. The CI build is set up to run serially with this
|
55
|
-
# environment variable set with each supported version.
|
56
44
|
def spec_mdes_version
|
57
|
-
|
58
|
-
(ENV['SPEC_MDES_VERSION'] || NcsNavigator::Warehouse::DEFAULT_MDES_VERSION).
|
59
|
-
gsub(/[^\d\.]/, '')
|
45
|
+
NcsNavigator::Warehouse::Spec.mdes_version
|
60
46
|
end
|
61
47
|
|
62
48
|
config.before(:each, :use_mdes) do
|
63
|
-
|
49
|
+
# Specs with :use_mdes may expect the warehouse models to be loaded
|
50
|
+
spec_config
|
64
51
|
end
|
65
52
|
|
66
53
|
###### modifies_warehouse_state
|
@@ -80,24 +67,28 @@ RSpec.configure do |config|
|
|
80
67
|
###### use_database
|
81
68
|
|
82
69
|
config.before(:each, :use_database) do
|
83
|
-
init_spec_config
|
84
|
-
|
85
70
|
$db_init ||=
|
86
71
|
begin
|
87
72
|
init = NcsNavigator::Warehouse::DatabaseInitializer.new(spec_config)
|
88
73
|
init.set_up_repository(:both)
|
89
|
-
init.replace_schema
|
90
|
-
init.clone_working_to_reporting
|
91
74
|
end
|
92
75
|
end
|
93
76
|
|
94
77
|
config.after(:each, :use_database) do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
78
|
+
[:working, :reporting].each do |db|
|
79
|
+
repo_name = "mdes_warehouse_#{db}".to_sym
|
80
|
+
adapter = DataMapper.repository(repo_name).adapter
|
81
|
+
adapter.execute("SET client_min_messages = warning")
|
82
|
+
|
83
|
+
tables = adapter.
|
84
|
+
select("SELECT table_name FROM information_schema.tables WHERE table_schema='public'")
|
85
|
+
unless tables.empty?
|
86
|
+
begin
|
87
|
+
DataMapper.repository.adapter.execute("TRUNCATE TABLE #{tables.join(', ')} CASCADE")
|
88
|
+
rescue DataObjects::SyntaxError => e
|
89
|
+
# some table was never created
|
90
|
+
$stderr.puts "Post-spec truncation failed: #{e}. This may not indicate a problem; just letting you know."
|
91
|
+
end
|
101
92
|
end
|
102
93
|
end
|
103
94
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'ncs_navigator/warehouse'
|
2
|
+
|
3
|
+
module NcsNavigator::Warehouse
|
4
|
+
module Spec
|
5
|
+
# Each test run can only operate against one version of the MDES at
|
6
|
+
# a time. The CI build is set up to run serially with this
|
7
|
+
# environment variable set with each supported version.
|
8
|
+
def self.mdes_version
|
9
|
+
@mdes_version ||=
|
10
|
+
(ENV['SPEC_MDES_VERSION'] || NcsNavigator::Warehouse::DEFAULT_MDES_VERSION).
|
11
|
+
gsub(/[^\d\.]/, '')
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configuration
|
15
|
+
@configuration ||= NcsNavigator::Warehouse::Configuration.new.tap do |c|
|
16
|
+
c.mdes_version = self.mdes_version
|
17
|
+
# This is used for rake invocations only; within specs the log
|
18
|
+
# goes to the spec tmpdir for cleanup.
|
19
|
+
c.log_file = File.expand_path('../spec.log', __FILE__)
|
20
|
+
c.bcdatabase_group = ENV['CI_RUBY'] ? :public_ci_postgresql9 : :local_postgresql
|
21
|
+
c.bcdatabase_entries[:working] = :mdes_warehouse_working_test
|
22
|
+
c.bcdatabase_entries[:reporting] = :mdes_warehouse_reporting_test
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.database_initializer
|
27
|
+
@database_initializer ||= DatabaseInitializer.new(configuration)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_context :warehouse_record_creation_helpers do
|
4
|
+
def save_wh(record)
|
5
|
+
unless record.save
|
6
|
+
messages = record.errors.keys.collect { |prop|
|
7
|
+
record.errors[prop].collect { |e|
|
8
|
+
v = record.send(prop)
|
9
|
+
"#{e} (#{prop}=#{v.inspect})."
|
10
|
+
}
|
11
|
+
}.flatten
|
12
|
+
fail "Could not save #{record} due to validation failures: #{messages.join(', ')}"
|
13
|
+
end
|
14
|
+
record
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_warehouse_record_with_defaults(mdes_model, attributes={})
|
18
|
+
mdes_model = case mdes_model
|
19
|
+
when String, Symbol
|
20
|
+
mdes_model(mdes_model)
|
21
|
+
else
|
22
|
+
mdes_model
|
23
|
+
end
|
24
|
+
|
25
|
+
all_attrs = all_missing_attributes(mdes_model).
|
26
|
+
merge(attributes)
|
27
|
+
|
28
|
+
save_wh(mdes_model.new(all_attrs))
|
29
|
+
end
|
30
|
+
|
31
|
+
def all_missing_attributes(model)
|
32
|
+
model.properties.
|
33
|
+
select { |p| p.required? }.
|
34
|
+
inject({}) { |h, prop| h[prop.name] = missing_value_for_property(prop); h }.
|
35
|
+
merge(:psu_id => '20000030')
|
36
|
+
end
|
37
|
+
|
38
|
+
def missing_value_for_property(dm_prop)
|
39
|
+
if dm_prop.options[:set]
|
40
|
+
'-4'
|
41
|
+
elsif dm_prop.class < ::DataMapper::Property::Numeric
|
42
|
+
0
|
43
|
+
else
|
44
|
+
'NA'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncs_mdes_warehouse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ncs_mdes
|
@@ -1336,6 +1336,7 @@ files:
|
|
1336
1336
|
- lib/ncs_navigator/warehouse/transformers/coded_as_missing_filter.rb
|
1337
1337
|
- lib/ncs_navigator/warehouse/transformers/database.rb
|
1338
1338
|
- lib/ncs_navigator/warehouse/transformers/enum_transformer.rb
|
1339
|
+
- lib/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer.rb
|
1339
1340
|
- lib/ncs_navigator/warehouse/transformers/filters.rb
|
1340
1341
|
- lib/ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter.rb
|
1341
1342
|
- lib/ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter.rb
|
@@ -1369,6 +1370,7 @@ files:
|
|
1369
1370
|
- spec/ncs_navigator/warehouse/transformers/coded_as_missing_filter_spec.rb
|
1370
1371
|
- spec/ncs_navigator/warehouse/transformers/database_spec.rb
|
1371
1372
|
- spec/ncs_navigator/warehouse/transformers/enum_transformer_spec.rb
|
1373
|
+
- spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb
|
1372
1374
|
- spec/ncs_navigator/warehouse/transformers/filters_spec.rb
|
1373
1375
|
- spec/ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter_spec.rb
|
1374
1376
|
- spec/ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter_spec.rb
|
@@ -1381,7 +1383,9 @@ files:
|
|
1381
1383
|
- spec/ncs_navigator/warehouse/xml_emitter_spec.rb
|
1382
1384
|
- spec/ncs_navigator/warehouse_spec.rb
|
1383
1385
|
- spec/spec_helper.rb
|
1386
|
+
- spec/spec_warehouse_config.rb
|
1384
1387
|
- spec/test_samples.csv
|
1388
|
+
- spec/warehouse_record_creation_helpers.rb
|
1385
1389
|
homepage: ''
|
1386
1390
|
licenses: []
|
1387
1391
|
post_install_message:
|
@@ -1397,7 +1401,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1397
1401
|
version: '0'
|
1398
1402
|
segments:
|
1399
1403
|
- 0
|
1400
|
-
hash:
|
1404
|
+
hash: -1151294958631964744
|
1401
1405
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1402
1406
|
none: false
|
1403
1407
|
requirements:
|
@@ -1406,7 +1410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1406
1410
|
version: '0'
|
1407
1411
|
segments:
|
1408
1412
|
- 0
|
1409
|
-
hash:
|
1413
|
+
hash: -1151294958631964744
|
1410
1414
|
requirements: []
|
1411
1415
|
rubyforge_project:
|
1412
1416
|
rubygems_version: 1.8.24
|
@@ -1435,6 +1439,7 @@ test_files:
|
|
1435
1439
|
- spec/ncs_navigator/warehouse/transformers/coded_as_missing_filter_spec.rb
|
1436
1440
|
- spec/ncs_navigator/warehouse/transformers/database_spec.rb
|
1437
1441
|
- spec/ncs_navigator/warehouse/transformers/enum_transformer_spec.rb
|
1442
|
+
- spec/ncs_navigator/warehouse/transformers/event_start_from_contact_transformer_spec.rb
|
1438
1443
|
- spec/ncs_navigator/warehouse/transformers/filters_spec.rb
|
1439
1444
|
- spec/ncs_navigator/warehouse/transformers/no_blank_foreign_keys_filter_spec.rb
|
1440
1445
|
- spec/ncs_navigator/warehouse/transformers/no_ssu_outreach_all_ssus_filter_spec.rb
|
@@ -1447,5 +1452,7 @@ test_files:
|
|
1447
1452
|
- spec/ncs_navigator/warehouse/xml_emitter_spec.rb
|
1448
1453
|
- spec/ncs_navigator/warehouse_spec.rb
|
1449
1454
|
- spec/spec_helper.rb
|
1455
|
+
- spec/spec_warehouse_config.rb
|
1450
1456
|
- spec/test_samples.csv
|
1457
|
+
- spec/warehouse_record_creation_helpers.rb
|
1451
1458
|
has_rdoc:
|