caruby-tissue 1.5.6 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +17 -0
- data/History.md +5 -1
- data/README.md +2 -2
- data/bin/crtdump +2 -8
- data/bin/crtexample +2 -5
- data/bin/crtmigrate +3 -6
- data/bin/crtsmoke +3 -8
- data/conf/wustl/{log4j.properties → linux/log4j.properties} +3 -3
- data/conf/wustl/windows/log4j.properties +40 -0
- data/examples/galena/Gemfile +16 -0
- data/examples/galena/Gemfile.lock +88 -0
- data/examples/galena/README.md +16 -16
- data/examples/galena/Rakefile +30 -0
- data/examples/galena/bin/seed +5 -11
- data/examples/galena/conf/annotation/defaults.yaml +2 -0
- data/examples/galena/conf/{migration/annotation_fields.yaml → annotation/fields.yaml} +2 -4
- data/examples/galena/conf/defaults.yaml +9 -0
- data/examples/galena/conf/{migration/filter_fields.yaml → filter/fields.yaml} +0 -1
- data/examples/galena/conf/filter/values.yaml +8 -0
- data/examples/galena/conf/{migration/frozen_defaults.yaml → frozen/defaults.yaml} +0 -0
- data/examples/galena/conf/{migration/frozen_fields.yaml → frozen/fields.yaml} +0 -2
- data/examples/galena/conf/{migration/general_fields.yaml → general/fields.yaml} +0 -24
- data/examples/galena/conf/registration/fields.yaml +6 -0
- data/examples/galena/conf/{migration/simple_fields.yaml → simple/fields.yaml} +1 -6
- data/examples/galena/data/annotation.csv +1 -1
- data/examples/galena/data/filter.csv +1 -1
- data/examples/galena/data/frozen.csv +1 -1
- data/examples/galena/data/general.csv +1 -1
- data/examples/galena/data/registration.csv +1 -1
- data/examples/galena/data/simple.csv +1 -1
- data/examples/galena/galena.gemspec +24 -0
- data/examples/galena/lib/galena/filter.rb +25 -0
- data/examples/galena/lib/galena/{tissue/migration/frozen_shims.rb → frozen.rb} +6 -10
- data/examples/galena/lib/galena/seed.rb +126 -0
- data/examples/galena/lib/galena/version.rb +3 -0
- data/examples/galena/lib/galena.rb +18 -7
- data/examples/galena/log/galena.log +37351 -0
- data/examples/galena/log/galena.log.0 +147830 -0
- data/examples/galena/spec/annotation_spec.rb +46 -0
- data/examples/galena/spec/filter_spec.rb +94 -0
- data/examples/galena/spec/frozen_spec.rb +39 -0
- data/examples/galena/spec/general_spec.rb +62 -0
- data/examples/galena/spec/registration_spec.rb +37 -0
- data/examples/galena/spec/seed.rb +107 -0
- data/examples/galena/spec/simple_spec.rb +58 -0
- data/examples/galena/spec/spec_helper.rb +11 -0
- data/examples/galena/spec/support/migration.rb +70 -0
- data/lib/catissue/annotation/annotatable.rb +10 -8
- data/lib/catissue/annotation/annotation.rb +7 -7
- data/lib/catissue/annotation/de_integration.rb +9 -20
- data/lib/catissue/annotation/importer.rb +148 -0
- data/lib/catissue/annotation/introspector.rb +32 -0
- data/lib/catissue/annotation/metadata.rb +422 -0
- data/lib/catissue/annotation/proxy.rb +2 -2
- data/lib/catissue/annotation/proxy_class.rb +45 -30
- data/lib/catissue/annotation/record_entry_proxy.rb +2 -2
- data/lib/catissue/cli/command.rb +14 -24
- data/lib/catissue/cli/example.rb +5 -3
- data/lib/catissue/cli/migrate.rb +45 -37
- data/lib/catissue/cli/smoke.rb +2 -3
- data/lib/catissue/database/annotation/annotation_service.rb +8 -17
- data/lib/catissue/database/annotation/entity_facade.rb +33 -30
- data/lib/catissue/database/annotation/id_generator.rb +1 -1
- data/lib/catissue/database/annotation/integration_service.rb +11 -4
- data/lib/catissue/database/annotation/reference_writer.rb +38 -38
- data/lib/catissue/database/controlled_value_finder.rb +13 -28
- data/lib/catissue/database/controlled_values.rb +73 -45
- data/lib/catissue/database.rb +637 -277
- data/lib/catissue/domain/abstract_domain_object.rb +5 -0
- data/lib/catissue/domain/abstract_position.rb +3 -5
- data/lib/catissue/domain/abstract_specimen.rb +79 -65
- data/lib/catissue/domain/abstract_specimen_collection_group.rb +3 -6
- data/lib/catissue/domain/address.rb +0 -2
- data/lib/catissue/domain/cancer_research_group.rb +0 -3
- data/lib/catissue/domain/capacity.rb +2 -4
- data/lib/catissue/domain/check_in_check_out_event_parameter.rb +0 -3
- data/lib/catissue/domain/collection_event_parameters.rb +2 -7
- data/lib/catissue/domain/collection_protocol.rb +11 -16
- data/lib/catissue/domain/collection_protocol_event.rb +19 -12
- data/lib/catissue/domain/collection_protocol_registration.rb +8 -12
- data/lib/catissue/domain/consent_tier_response.rb +0 -4
- data/lib/catissue/domain/consent_tier_status.rb +1 -4
- data/lib/catissue/domain/container.rb +10 -10
- data/lib/catissue/domain/container_position.rb +4 -7
- data/lib/catissue/domain/container_type.rb +4 -7
- data/lib/catissue/domain/department.rb +0 -3
- data/lib/catissue/domain/disposal_event_parameters.rb +5 -5
- data/lib/catissue/domain/embedded_event_parameters.rb +1 -4
- data/lib/catissue/domain/external_identifier.rb +0 -12
- data/lib/catissue/domain/frozen_event_parameters.rb +1 -4
- data/lib/catissue/domain/institution.rb +0 -3
- data/lib/catissue/domain/new_specimen_array_order_item.rb +0 -5
- data/lib/catissue/domain/order_details.rb +0 -2
- data/lib/catissue/domain/participant/clinical/chemotherapy.rb +1 -3
- data/lib/catissue/domain/participant/clinical/duration.rb +2 -4
- data/lib/catissue/domain/participant/clinical/radiation_therapy.rb +2 -4
- data/lib/catissue/domain/participant.rb +22 -24
- data/lib/catissue/domain/participant_medical_identifier.rb +0 -4
- data/lib/catissue/domain/password.rb +0 -4
- data/lib/catissue/domain/race.rb +0 -3
- data/lib/catissue/domain/received_event_parameters.rb +3 -6
- data/lib/catissue/domain/site.rb +1 -4
- data/lib/catissue/domain/specimen/pathology/additional_finding.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/details.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/gleason_score.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/histologic_grade.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/histologic_type.rb +19 -0
- data/lib/catissue/domain/specimen/pathology/histologic_variant_type.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/invasion.rb +12 -0
- data/lib/catissue/domain/specimen/pathology/prostate_specimen_gleason_score.rb +5 -11
- data/lib/catissue/domain/specimen/pathology/prostate_specimen_pathology_annotation.rb +12 -12
- data/lib/catissue/domain/specimen/pathology/specimen_additional_finding.rb +5 -14
- data/lib/catissue/domain/specimen/pathology/specimen_base_solid_tissue_pathology_annotation.rb +6 -21
- data/lib/catissue/domain/specimen/pathology/specimen_details.rb +4 -10
- data/lib/catissue/domain/specimen/pathology/specimen_histologic_grade.rb +4 -10
- data/lib/catissue/domain/specimen/pathology/specimen_histologic_type.rb +6 -14
- data/lib/catissue/domain/specimen/pathology/specimen_histologic_variant_type.rb +5 -11
- data/lib/catissue/domain/specimen/pathology/specimen_invasion.rb +5 -11
- data/lib/catissue/domain/specimen.rb +113 -76
- data/lib/catissue/domain/specimen_array.rb +0 -3
- data/lib/catissue/domain/specimen_array_content.rb +1 -4
- data/lib/catissue/domain/specimen_array_type.rb +1 -4
- data/lib/catissue/domain/specimen_characteristics.rb +0 -3
- data/lib/catissue/domain/specimen_collection_group/pathology/base_pathology_annotation.rb +2 -4
- data/lib/catissue/domain/specimen_collection_group/pathology/base_solid_tissue_pathology_annotation.rb +2 -4
- data/lib/catissue/domain/specimen_collection_group.rb +43 -53
- data/lib/catissue/domain/specimen_event_parameters.rb +24 -32
- data/lib/catissue/domain/specimen_position.rb +8 -5
- data/lib/catissue/domain/specimen_protocol.rb +3 -6
- data/lib/catissue/domain/specimen_requirement.rb +22 -20
- data/lib/catissue/domain/storage_container.rb +9 -12
- data/lib/catissue/domain/storage_type.rb +6 -10
- data/lib/catissue/domain/transfer_event_parameters.rb +3 -6
- data/lib/catissue/domain/user.rb +22 -29
- data/lib/catissue/{util → helpers}/collectible.rb +23 -18
- data/lib/catissue/helpers/collectible_event_parameters.rb +68 -0
- data/lib/catissue/helpers/controlled_value.rb +35 -0
- data/lib/catissue/{domain → helpers}/hash_code.rb +0 -0
- data/lib/catissue/{util → helpers}/location.rb +6 -5
- data/lib/catissue/helpers/log.rb +4 -0
- data/lib/catissue/{util → helpers}/person.rb +1 -1
- data/lib/catissue/{util → helpers}/position.rb +10 -8
- data/lib/catissue/helpers/properties_loader.rb +143 -0
- data/lib/catissue/{util → helpers}/storable.rb +2 -1
- data/lib/catissue/{util → helpers}/storage_type_holder.rb +9 -3
- data/lib/catissue/{annotation/annotatable_class.rb → metadata.rb} +73 -95
- data/lib/catissue/migration/migratable.rb +93 -44
- data/lib/catissue/migration/migrator.rb +26 -42
- data/lib/catissue/migration/shims.rb +1 -1
- data/lib/catissue/migration/unique.rb +76 -0
- data/lib/catissue/resource.rb +16 -20
- data/lib/catissue/version.rb +1 -1
- data/lib/catissue/wustl/logger.rb +52 -32
- data/lib/catissue.rb +38 -20
- data/test/lib/catissue/database/controlled_values_test.rb +22 -27
- data/test/lib/catissue/database/database_test.rb +18 -0
- data/test/lib/catissue/domain/address_test.rb +9 -11
- data/test/lib/catissue/domain/ca_tissue_test_defaults_test.rb +5 -16
- data/test/lib/catissue/domain/capacity_test.rb +2 -2
- data/test/lib/catissue/domain/collection_event_parameters_test.rb +16 -8
- data/test/lib/catissue/domain/collection_protocol_event_test.rb +1 -1
- data/test/lib/catissue/domain/collection_protocol_registration_test.rb +26 -16
- data/test/lib/catissue/domain/collection_protocol_test.rb +2 -2
- data/test/lib/catissue/domain/container_position_test.rb +7 -4
- data/test/lib/catissue/domain/department_test.rb +3 -3
- data/test/lib/catissue/domain/disposal_event_parameters_test.rb +1 -1
- data/test/lib/catissue/domain/external_identifier_test.rb +5 -1
- data/test/lib/catissue/domain/location_test.rb +4 -4
- data/test/lib/catissue/domain/participant_medical_identifier_test.rb +3 -3
- data/test/lib/catissue/domain/participant_test.rb +33 -20
- data/test/lib/catissue/domain/received_event_parameters_test.rb +19 -0
- data/test/lib/catissue/domain/site_test.rb +2 -2
- data/test/lib/catissue/domain/specimen_array_test.rb +3 -3
- data/test/lib/catissue/domain/specimen_array_type_test.rb +6 -6
- data/test/lib/catissue/domain/specimen_characteristics_test.rb +1 -1
- data/test/lib/catissue/domain/specimen_collection_group_test.rb +49 -13
- data/test/lib/catissue/domain/specimen_event_parameters_test.rb +4 -4
- data/test/lib/catissue/domain/specimen_position_test.rb +1 -1
- data/test/lib/catissue/domain/specimen_requirement_test.rb +2 -2
- data/test/lib/catissue/domain/specimen_test.rb +58 -24
- data/test/lib/catissue/domain/storage_container_test.rb +3 -16
- data/test/lib/catissue/domain/storage_type_test.rb +3 -3
- data/test/lib/catissue/domain/transfer_event_parameters_test.rb +17 -17
- data/test/lib/catissue/domain/user_test.rb +32 -34
- data/test/lib/catissue/helpers/properties_loader_test.rb +19 -0
- data/test/lib/catissue/migration/{test_case.rb → helpers/test_case.rb} +30 -20
- data/test/lib/examples/galena/tissue/domain/examples_test.rb +28 -38
- data/test/lib/examples/galena/tissue/helpers/test_case.rb +24 -0
- metadata +175 -99
- data/bin/crtextract +0 -47
- data/examples/galena/conf/extract/simple_fields.yaml +0 -4
- data/examples/galena/conf/migration/annotation_defaults.yaml +0 -2
- data/examples/galena/conf/migration/filter_defaults.yaml +0 -1
- data/examples/galena/conf/migration/filter_values.yaml +0 -13
- data/examples/galena/conf/migration/participant_fields.yaml +0 -4
- data/examples/galena/conf/migration/registration_fields.yaml +0 -5
- data/examples/galena/data/participant.csv +0 -1
- data/examples/galena/lib/galena/tissue/migration/filter_shims.rb +0 -41
- data/examples/galena/lib/galena/tissue/seed/defaults.rb +0 -127
- data/examples/psbin/README.md +0 -45
- data/examples/psbin/conf/adjuvant_hormone_defaults.yaml +0 -2
- data/examples/psbin/conf/adjuvant_radiation_defaults.yaml +0 -3
- data/examples/psbin/conf/biopsy_defaults.yaml +0 -3
- data/examples/psbin/conf/biopsy_fields.yaml +0 -9
- data/examples/psbin/conf/neoadjuvant_hormone_defaults.yaml +0 -2
- data/examples/psbin/conf/neoadjuvant_radiation_defaults.yaml +0 -3
- data/examples/psbin/conf/patient_defaults.yaml +0 -3
- data/examples/psbin/conf/patient_fields.yaml +0 -5
- data/examples/psbin/conf/surgery_defaults.yaml +0 -4
- data/examples/psbin/conf/surgery_fields.yaml +0 -15
- data/examples/psbin/conf/t_stage_defaults.yaml +0 -1
- data/examples/psbin/conf/t_stage_fields.yaml +0 -4
- data/examples/psbin/conf/therapy_fields.yaml +0 -5
- data/examples/psbin/data/adjuvant_hormone.csv +0 -1
- data/examples/psbin/data/adjuvant_radiation.csv +0 -1
- data/examples/psbin/data/biopsy.csv +0 -1
- data/examples/psbin/data/neoadjuvant_hormone.csv +0 -1
- data/examples/psbin/data/neoadjuvant_radiation.csv +0 -1
- data/examples/psbin/data/patient.csv +0 -1
- data/examples/psbin/data/surgery.csv +0 -1
- data/examples/psbin/data/t_stage.csv +0 -1
- data/examples/psbin/lib/psbin/biopsy_shims.rb +0 -15
- data/examples/psbin/lib/psbin/surgery_shims.rb +0 -15
- data/lib/catissue/annotation/annotation_class.rb +0 -406
- data/lib/catissue/annotation/annotation_module.rb +0 -106
- data/lib/catissue/domain.rb +0 -26
- data/lib/catissue/extract/command.rb +0 -31
- data/lib/catissue/extract/delta.rb +0 -58
- data/lib/catissue/extract/extractor.rb +0 -99
- data/lib/catissue/migration/uniquify.rb +0 -2
- data/lib/catissue/util/collectible_event_parameters.rb +0 -71
- data/lib/catissue/util/controlled_value.rb +0 -29
- data/lib/catissue/util/uniquify.rb +0 -86
- data/test/fixtures/catissue/domain/conf/catissue_override.yaml +0 -9
- data/test/fixtures/catissue/extract/conf/scg_extract.yaml +0 -3
- data/test/fixtures/catissue/extract/conf/scg_fields.yaml +0 -3
- data/test/fixtures/catissue/extract/conf/spc_extract.yaml +0 -3
- data/test/fixtures/catissue/extract/conf/spc_fields.yaml +0 -4
- data/test/fixtures/lib/catissue/defaults_test_fixture.rb +0 -206
- data/test/fixtures/lib/examples/galena/migration/alt_key_shims.rb +0 -7
- data/test/lib/catissue/domain/base_haemotology_pathology_test.rb +0 -24
- data/test/lib/catissue/extract/delta_test.rb +0 -25
- data/test/lib/catissue/extract/extractor_test.rb +0 -43
- data/test/lib/catissue/import/importable_module_test.rb +0 -14
- data/test/lib/catissue/test_case.rb +0 -247
- data/test/lib/examples/galena/tissue/migration/annotation_test.rb +0 -29
- data/test/lib/examples/galena/tissue/migration/filter_test.rb +0 -29
- data/test/lib/examples/galena/tissue/migration/frozen_test.rb +0 -36
- data/test/lib/examples/galena/tissue/migration/general_test.rb +0 -56
- data/test/lib/examples/galena/tissue/migration/participant_test.rb +0 -61
- data/test/lib/examples/galena/tissue/migration/registration_test.rb +0 -17
- data/test/lib/examples/galena/tissue/migration/seedify.rb +0 -119
- data/test/lib/examples/galena/tissue/migration/simple_test.rb +0 -30
- data/test/lib/examples/galena/tissue/migration/test_case.rb +0 -72
- data/test/lib/examples/psbin/migration_test.rb +0 -153
data/lib/catissue/domain.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'caruby/domain'
|
2
|
-
require 'catissue/resource'
|
3
|
-
require 'catissue/annotation/annotatable_class'
|
4
|
-
require 'catissue/wustl/logger'
|
5
|
-
|
6
|
-
module CaTissue
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
# The required Java package name.
|
11
|
-
PKG = 'edu.wustl.catissuecore.domain'
|
12
|
-
|
13
|
-
# The domain class definitions.
|
14
|
-
SRC_DIR = File.join(File.dirname(__FILE__), 'domain')
|
15
|
-
|
16
|
-
# Enable the resource metadata aspect.
|
17
|
-
md_proc = Proc.new { |klass| AnnotatableClass.extend_class(klass) }
|
18
|
-
CaRuby::Domain.extend_module(self, :mixin => Resource, :metadata => md_proc, :package => PKG)
|
19
|
-
|
20
|
-
# Set up the caTissue client logger before loading the class definitions.
|
21
|
-
Wustl::Logger.configure
|
22
|
-
|
23
|
-
# Load the class definitions.
|
24
|
-
load_dir(SRC_DIR)
|
25
|
-
end
|
26
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'catissue/cli/command'
|
2
|
-
require 'catissue/extract/delta'
|
3
|
-
require 'catissue/extract/extractor'
|
4
|
-
|
5
|
-
module CaTissue
|
6
|
-
# ExtractCommand extracts target CaTissue domain class objects whose modification date is
|
7
|
-
# within a time interval to a CSV file based on a CSV mapping file.
|
8
|
-
class ExtractCommand < CaTissue::Command
|
9
|
-
# Creates a new ExtractCommand.
|
10
|
-
# The delta range is given by the required :since option and optional :before option.
|
11
|
-
# The default before value is the current DateTime. These are used to build a Delta
|
12
|
-
# which is passed to {CaRuby::Command#initialize} as the :ids option.
|
13
|
-
# The :log option specifies a log file.
|
14
|
-
# Other supported options are described in {Extractor#initialize}.
|
15
|
-
def initialize
|
16
|
-
# prep the options
|
17
|
-
since = opts.delete(:since)
|
18
|
-
raise ArgumentError.new("Missing required beginning of date selection range option") unless since
|
19
|
-
before = opts.delete(:before) || DateTime.now
|
20
|
-
# the data acquirer
|
21
|
-
opts[:ids] = Delta.new(@target, since, before)
|
22
|
-
# make the command
|
23
|
-
super(opts)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Starts an Extractor with the command-line options.
|
27
|
-
def run
|
28
|
-
super { |opts| Extractor.new(opts) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'caruby/csv/csvio'
|
3
|
-
require 'caruby/util/log'
|
4
|
-
require 'caruby/util/collection'
|
5
|
-
require 'caruby/util/pretty_print'
|
6
|
-
require 'catissue/database'
|
7
|
-
|
8
|
-
module CaTissue
|
9
|
-
# Delta determines caTissue objects which changed within a time interval.
|
10
|
-
class Delta
|
11
|
-
include Enumerable
|
12
|
-
|
13
|
-
# Creates a new Delta for objects of the given target type which changed
|
14
|
-
# at or after the since Date and earlier but not at the before Date.
|
15
|
-
# The default before Date is now.
|
16
|
-
def initialize(target, since, before=nil)
|
17
|
-
# convert the required target to a CaTissue class if necessary
|
18
|
-
@matcher = create_table_regex(target)
|
19
|
-
@since = since
|
20
|
-
@before = before || DateTime.now
|
21
|
-
end
|
22
|
-
|
23
|
-
# Calls the given block on each caTissue identifier satisfying the delta condition.
|
24
|
-
# This method submits the delta SQL and filters the result on the target class.
|
25
|
-
# This method always submits the query; the caller is responsible for preserving
|
26
|
-
# the result if necessary using {#to_a}.
|
27
|
-
def each(&block)
|
28
|
-
execute_query(&block)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
SQL_FILE = File.join(File.dirname(__FILE__), '..', '..', '..', 'sql', 'delta.sql')
|
34
|
-
|
35
|
-
# Returns the result of running the delta SQL on the target CaTissue domain class.
|
36
|
-
def execute_query
|
37
|
-
sql = File.open(SQL_FILE) { |file| file.read }
|
38
|
-
logger.debug { "Executing identifier change set selection range #{@since} - #{@before}, SQL:\n#{sql}" }
|
39
|
-
CaTissue::Database.executor.execute do |dbh|
|
40
|
-
dbh.select_all(sql, @since, @before) do |row|
|
41
|
-
table, identifier = row
|
42
|
-
yield identifier.to_i if table =~ @matcher
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Returns the table match REs for the given target class.
|
48
|
-
def create_table_regex(target)
|
49
|
-
# The class => table RE hash. Make this hash rather than defining a constant in order to enable
|
50
|
-
# logging before touching a domain class.
|
51
|
-
@cls_tbl_hash ||= {
|
52
|
-
CaTissue::Specimen => /catissue_[[:alpha:]]+_specimen/i,
|
53
|
-
CaTissue::SpecimenCollectionGroup => /catissue_specimen_coll_group/i
|
54
|
-
}
|
55
|
-
@cls_tbl_hash.detect_value { |klass, table| table if target <= klass }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'caruby/util/properties'
|
2
|
-
require 'caruby/csv/csv_mapper'
|
3
|
-
require 'caruby/csv/csvio'
|
4
|
-
|
5
|
-
module CaTissue
|
6
|
-
# Extracts caTissue objects.
|
7
|
-
class Extractor
|
8
|
-
include Enumerable
|
9
|
-
|
10
|
-
# The default name of this migrator.
|
11
|
-
DEF_NAME = 'caTissue Extractor'
|
12
|
-
|
13
|
-
# The extract output file
|
14
|
-
attr_reader :output
|
15
|
-
|
16
|
-
# Creates a new Extractor with the given options.
|
17
|
-
#
|
18
|
-
# @option options [String] :file the extract configuration file name
|
19
|
-
# @option options [String] :name name of this Migrator (default is +caTissue Migrator+)
|
20
|
-
# @option options [String] :output optional output CSV file name
|
21
|
-
# @option options [String] :target required target domain class or class name
|
22
|
-
# @option options [String] :ids the database identifiers of the target objects to extract
|
23
|
-
# @option options [String] :log log file (default +log/extract.log+)
|
24
|
-
def initialize(options={})
|
25
|
-
conf_file = options.delete(:file)
|
26
|
-
if conf_file then
|
27
|
-
CaRuby::Properties.new(conf_file, :array => [:shims]).each { |key, value| options[key.to_sym] ||= value }
|
28
|
-
end
|
29
|
-
# tailor the options
|
30
|
-
name = options[:name] || DEF_NAME
|
31
|
-
super(name)
|
32
|
-
@ids = options[:ids]
|
33
|
-
raise ArgumentError.new("Missing required ids option") unless @ids
|
34
|
-
# convert the required target to a CaTissue class if necessary
|
35
|
-
@target = target_class_from_option(options[:target])
|
36
|
-
@target ||= CaTissue::Specimen
|
37
|
-
# the CSV output file
|
38
|
-
@output = options[:output]
|
39
|
-
raise ArgumentError.new("Missing required extract output file option") unless @output
|
40
|
-
# the field mapping configuration
|
41
|
-
fld_conf = options[:mapping]
|
42
|
-
mapper = CaRuby::CsvMapper.new(fld_conf, @target, @output, :mode => "w")
|
43
|
-
@csvio = mapper.csvio
|
44
|
-
@fld_path_hash = {}
|
45
|
-
mapper.paths.each do |path|
|
46
|
-
fld = mapper.header(path)
|
47
|
-
# the path node is either an attribute symbol or attribute metadata;
|
48
|
-
# if metadata, then use the reader method.
|
49
|
-
@fld_path_hash[fld] = path.map { |attr_or_md| CaRuby::Domain::Attribute === attr_or_md ? attr_or_md.reader : attr_or_md }
|
50
|
-
end
|
51
|
-
logger.debug { "Extract field => path map: #{@fld_path_hash.transform { |path| path.join('.') }.pp_s}" }
|
52
|
-
end
|
53
|
-
|
54
|
-
# Exports the selected target records from the database to the output file.
|
55
|
-
def run
|
56
|
-
begin
|
57
|
-
extract { |obj| write(obj) }
|
58
|
-
ensure
|
59
|
-
@csvio.close
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# Executes this extractor CSV file and calls the block given to this method on each target domain object.
|
64
|
-
def extract
|
65
|
-
logger.debug { "Found #{@ids.size} extract targets." }
|
66
|
-
CaTissue::Database.instance.open do
|
67
|
-
@ids.each do |identifier|
|
68
|
-
obj = @target.new(:identifier => identifier)
|
69
|
-
logger.debug { "Finding extract target #{obj}..." }
|
70
|
-
if obj.find then
|
71
|
-
logger.debug { "Extractor fetched #{obj}." }
|
72
|
-
yield obj
|
73
|
-
else
|
74
|
-
logger.debug { "Extract target #{obj} not found." }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
alias :each :extract
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def write(obj)
|
85
|
-
# collect the field values in order by resolving the path on obj
|
86
|
-
rec = @csvio.headers.map do |fld|
|
87
|
-
obj.path_value(@fld_path_hash[fld])
|
88
|
-
end
|
89
|
-
@csvio << rec
|
90
|
-
logger.debug { "Extractor wrote #{obj} to CSV output file." }
|
91
|
-
end
|
92
|
-
|
93
|
-
def target_class_from_option(option)
|
94
|
-
return if option.nil?
|
95
|
-
return option if Class === option
|
96
|
-
CaTissue.const_get(option)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module CaTissue
|
2
|
-
# A CollectibleEventParameters is a SpecimenEventParameters which pertains to Specimen
|
3
|
-
# or SpecimenCollectionGroup collection at the point of tissue acquisition from the participant
|
4
|
-
# or receival at the tissue bank.
|
5
|
-
module CollectibleEventParameters
|
6
|
-
# Returns the SpecimenEventParameters in others which matches this CollectibleEventParameters in the scope of an owner Specimen or SCG.
|
7
|
-
# This method relaxes {CaRuby::Resource#match_in_owner_scope} for a CollectibleEventParameters that matches any SpecimenEventParameters
|
8
|
-
# in others of the same class, since there can be at most one CollectibleEventParameters of a given class for a given SCG.
|
9
|
-
def match_in_owner_scope(others)
|
10
|
-
others.detect { |other| minimal_match?(other) }
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# Injects validation to ensure that a CollectibleEventParameters instance cannot be owned by
|
16
|
-
# both a specimen and a SCG.
|
17
|
-
#
|
18
|
-
# @param [Class] klass the including class
|
19
|
-
def self.included(klass)
|
20
|
-
klass.class_eval do
|
21
|
-
owner_attributes.each do |attr|
|
22
|
-
wtr = attribute_metadata(attr).writer
|
23
|
-
redefine_method(wtr) do |base|
|
24
|
-
lambda do |obj|
|
25
|
-
validate_no_owner_confict(attr, obj)
|
26
|
-
send(base, obj)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# @param attribute the owner attribute to set
|
34
|
-
# @param obj the owner to set
|
35
|
-
# @raise [] if there is already a different owner attribute value
|
36
|
-
def validate_no_owner_confict(attribute, obj)
|
37
|
-
return if obj.nil?
|
38
|
-
self.class.owner_attributes.each do |attr|
|
39
|
-
next if attr == attribute
|
40
|
-
other = send(attr)
|
41
|
-
if other then
|
42
|
-
raise ValidationError.new("Cannot add #{qp} to #{attribute} #{obj.qp}, since it is already owned by #{attr} #{other}")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Overrides {CaRuby::Migratable#migratable__migrate_owner} to give owner preference to a migrated SCG
|
48
|
-
# over a migrated Specimen.
|
49
|
-
#
|
50
|
-
# @param (see CaRuby::Migratable#migratable__migrate_owner)
|
51
|
-
def migratable__migrate_owner(row, migrated, mth_hash=nil)
|
52
|
-
migratable__set_scg(row, migrated, mth_hash) or migratable__set_specimen(row, migrated, mth_hash)
|
53
|
-
end
|
54
|
-
|
55
|
-
# @param (see #migratable__migrate_owner)
|
56
|
-
# @return [CaTissue::SpecimenCollectionGroup, nil] the migrated SCG, if any
|
57
|
-
def migratable__set_scg(row, migrated, mth_hash=nil)
|
58
|
-
attr_md = self.class.attribute_metadata(:specimen_collection_group)
|
59
|
-
scg = migratable__target_value(attr_md, row, migrated, mth_hash)
|
60
|
-
if scg then self.specimen_collection_group = scg end
|
61
|
-
end
|
62
|
-
|
63
|
-
# @param (see #migratable__migrate_owner)
|
64
|
-
# @return [CaTissue::Specimen, nil] the migrated specimen, if any
|
65
|
-
def migratable__set_specimen(row, migrated, mth_hash=nil)
|
66
|
-
attr_md = self.class.attribute_metadata(:specimen)
|
67
|
-
spc = migratable__target_value(attr_md, row, migrated, mth_hash)
|
68
|
-
if spc then self.specimen = spc end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'caruby/util/controlled_value'
|
2
|
-
|
3
|
-
module CaTissue
|
4
|
-
class ControlledValue < CaRuby::ControlledValue
|
5
|
-
|
6
|
-
PUBLIC_ID_ALIAS_MAP = {:tissue_site => 'Tissue_Site_PID', :clinical_diagnosis => 'Clinical_Diagnosis_PID'}
|
7
|
-
|
8
|
-
# Returns the standard public id string for the given public_id_or_alias.
|
9
|
-
def self.standard_public_id(public_id_or_alias)
|
10
|
-
PUBLIC_ID_ALIAS_MAP[public_id_or_alias.to_sym] or public_id_or_alias.to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_accessor :identifier, :public_id
|
14
|
-
|
15
|
-
attr_reader :identifier
|
16
|
-
|
17
|
-
def parent_identifier
|
18
|
-
parent.identifier if parent
|
19
|
-
end
|
20
|
-
|
21
|
-
def public_id=(public_id_or_alias)
|
22
|
-
@public_id = self.class.standard_public_id(public_id_or_alias)
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_s
|
26
|
-
"#{value}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'caruby/domain/uniquify'
|
2
|
-
|
3
|
-
module CaTissue
|
4
|
-
class CollectionProtocol
|
5
|
-
include CaRuby::Resource::Unique
|
6
|
-
|
7
|
-
# Makes this CP's short and long title unique.
|
8
|
-
def uniquify
|
9
|
-
super
|
10
|
-
self.short_title = title
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class CollectionProtocolEvent
|
15
|
-
include CaRuby::Resource::Unique
|
16
|
-
end
|
17
|
-
|
18
|
-
class Container
|
19
|
-
include CaRuby::Resource::Unique
|
20
|
-
|
21
|
-
# Makes this Container and all of its subcontainers unique.
|
22
|
-
def uniquify
|
23
|
-
super
|
24
|
-
subcontainers.each { |ctr| ctr.uniquify }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class ParticipantMedicalIdentifier
|
29
|
-
include CaRuby::Resource::Unique
|
30
|
-
end
|
31
|
-
|
32
|
-
class CollectionProtocolRegistration
|
33
|
-
include CaRuby::Resource::Unique
|
34
|
-
|
35
|
-
# Makes this CPR's PPI unique.
|
36
|
-
def uniquify
|
37
|
-
oldval = protocol_participant_identifier || return
|
38
|
-
newval = uniquify_value(oldval)
|
39
|
-
self.protocol_participant_identifier = newval
|
40
|
-
logger.debug { "Reset #{qp} PPI from #{oldval} to unique value #{newval}." }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class SpecimenCollectionGroup
|
45
|
-
include CaRuby::Resource::Unique
|
46
|
-
|
47
|
-
# Makes this SCG's SPN unique.
|
48
|
-
def uniquify
|
49
|
-
super
|
50
|
-
oldval = surgical_pathology_number || return
|
51
|
-
newval = uniquify_value(oldval)
|
52
|
-
self.surgical_pathology_number = newval
|
53
|
-
logger.debug { "Reset #{qp} SPN from #{oldval} to unique value #{newval}." }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Specimen
|
58
|
-
include CaRuby::Resource::Unique
|
59
|
-
end
|
60
|
-
|
61
|
-
class ExternalIdentifier
|
62
|
-
include CaRuby::Resource::Unique
|
63
|
-
|
64
|
-
# Makes this ExternalIdentifier's value unique.
|
65
|
-
def uniquify
|
66
|
-
oldval = value || return
|
67
|
-
newval = uniquify_value(oldval)
|
68
|
-
self.value = newval
|
69
|
-
logger.debug { "Reset #{qp} value from #{oldval} to unique value #{newval}." }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class User
|
74
|
-
include CaRuby::Resource::Unique
|
75
|
-
|
76
|
-
# Makes this User's login id and email address unique.
|
77
|
-
# The result is in the form _name___suffix_+@test.com+
|
78
|
-
# where:
|
79
|
-
# * _name_ is the name prefix portion of the original email address
|
80
|
-
# * _suffix_ is a unique number
|
81
|
-
def uniquify
|
82
|
-
email = email_address ||= self.login_name || return
|
83
|
-
self.login_name = self.email_address = uniquify_value(email[/[^@]+/]) + '@test.com'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|