Class: CaTissue::Migrator
- Inherits:
-
CaRuby::Migrator
- Object
- CaRuby::Migrator
- CaTissue::Migrator
- Defined in:
- lib/catissue/migration/migrator.rb
Overview
Migrates a CSV extract to caTissue. See the #initialize documentation for usage options.
See the Galena Cancer Center Tissue Bank Migration Example for further information about how the options tailor migration, esp. the use of the field mappings and shims.
Constant Summary collapse
- NAME =
The default name of this migrator.
'caTissue Migrator'
- DEF_CONF_FILE =
File.join('conf', 'migration.yaml')
- SHIM_FILE =
The built-in caTissue migration shims.
File.join(File.dirname(__FILE__), 'shims.rb')
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Migrator
constructor
Creates a new Migrator with the given options.
Constructor Details
#initialize(opts = {}) ⇒ Migrator
Creates a new Migrator with the given options.
This migrator must include sufficient information to build a well-formed migration target object. For example, if the target object is a new SpecimenCollectionGroup, then the migration must also be able to build that SCG’s CollectionProtocolRegistration. The CPR in turn must either exist in the database or the migration must build a Participant and a CollectionProtocol.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/catissue/migration/migrator.rb', line 37 def initialize(opts={}) # if there is a configuration file, then add config options into the parameter options conf_file = opts.delete(:file) if conf_file then conf = CaRuby::Properties.new(conf_file, :array => [:shims]) # add config options but don't override the parameter options opts.merge!(conf, :deep) { |key, oldval, newval| oldval } end # open the log file before building structure log_file = opts[:log] CaRuby::Log.instance.open(log_file, :debug => opts[:debug]) if log_file # tailor the options opts[:name] ||= NAME opts[:database] ||= CaTissue::Database.instance # prepend this migrator's shims shims = opts[:shims] ||= [] shims.unshift(SHIM_FILE) # call the CaRuby::Migrator initializer with the augmented options super # The remaining options are specific to this CaTissue::Migrator subclass. # If the unique option is set, then append the CaTissue-specific uniquifier shim. if opts[:unique] then # add the uniquify shim @shims << UNIQUIFY_SHIM end # The tissue site CV look-up option. tissue_sites = opts[:tissue_sites] if tissue_sites then CaTissue::SpecimenCharacteristics.tissue_site_cv_finder = ControlledValueFinder.new(:tissue_site, tissue_sites) logger.info("Migrator enabled controlled value lookup.") end # The clinical diagnosis CV look-up option. diagnoses = opts[:diagnoses] if diagnoses then CaTissue::SpecimenCollectionGroup.diagnosis_cv_finder = ControlledValueFinder.new(:clinical_diagnosis, diagnoses) logger.info("Migrator enabled controlled value lookup.") end end |