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/version.rb
CHANGED
@@ -1,61 +1,81 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'jinx/helpers/os'
|
3
|
+
|
1
4
|
# Wustl wraps the +edu.wustl+ package.
|
2
5
|
module Wustl
|
3
6
|
# Logger configures the +edu.wustl+ logger.
|
4
7
|
module Logger
|
8
|
+
# @quirk caTissue caTissue requires that the log file parent directory exists.
|
9
|
+
# Messages are logged to +client.log+ and +catissuecore.log+ in this directory. If the
|
10
|
+
# directory does not exist, then caTissue raises a FileNotFound exception. The exception
|
11
|
+
# message indicates the log file rather than the log directory. This message is misleading,
|
12
|
+
# since the problem is not that the log file is not found but that the log directory does
|
13
|
+
# not exist. The work-around is to detect the log file from the log4j properties and ensure
|
14
|
+
# that the parent directory exists.
|
15
|
+
#
|
5
16
|
# @quirk caTissue the caTissue logger must be initialized before caTissue objects are created.
|
6
17
|
# The logger at issue is the caTissue client logger, not the caTissue server logger nor
|
7
18
|
# the caRuby logger. The caTissue logger facade class is edu.wustl.common.util.logger.Logger.
|
8
19
|
# In caTissue 1.1.x, initialization is done with +configure+, in 1.2 with
|
9
20
|
# +LoggerConfig.configureLogger+.
|
10
21
|
#
|
11
|
-
# @quirk catTissue +LoggerConfig.configureLogger+ expects file +log4j.properties+ in the
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# * copy this file into the caRuby Tissue distribution as +conf/wustl/log4.properties+
|
15
|
-
# * add +conf/wustl+ to the classpath.
|
16
|
-
# * call +LoggerConfig.configureLogger+ with the config directory as an argument
|
22
|
+
# @quirk catTissue 1.2 +LoggerConfig.configureLogger+ expects file +log4j.properties+ in the
|
23
|
+
# classpath. However, in 1.2 the client property file is +client_log4j.properties+. The
|
24
|
+
# work-around is to configure an empty log if there is no +log4j.properties+ in the classpath.
|
17
25
|
#
|
18
|
-
# @quirk caTissue
|
26
|
+
# @quirk caTissue caTissue ignores the +client.log+ and +catissuecore.log+ log level set in
|
27
|
+
# the client jar +log4j.properties+. caTissue spews forth copious cryptic comments,
|
28
|
+
# regardless of the log level.
|
29
|
+
#
|
30
|
+
# @quirk caTissue 1.1.1 The caTissue client log location is unfortunately hard-coded in a caTissue
|
19
31
|
# configuration file, does not create the parent directory on demand, and issues an obscure error
|
20
|
-
# message if the directory does not exist
|
21
|
-
#
|
32
|
+
# client message if the directory does not exist. The work-around is to ensure that the working
|
33
|
+
# directory contains a log subdirectory.
|
22
34
|
def self.configure
|
23
35
|
# Set the configured flag. Configure only once.
|
24
36
|
if @configured then return else @configured = true end
|
25
|
-
#
|
26
|
-
|
27
|
-
|
37
|
+
# the log4j properties
|
38
|
+
props = Java.load_properties('log4j.properties')
|
39
|
+
|
40
|
+
# Ensure that the parent directory exists.
|
41
|
+
if props then
|
42
|
+
clt_log = props['log4j.appender.clientLog.File']
|
43
|
+
ensure_parent_directory_exists(clt_log) if clt_log
|
44
|
+
core_log = props['log4j.appender.catissuecoreclientLog.File']
|
45
|
+
ensure_parent_directory_exists(core_log) if core_log
|
46
|
+
end
|
47
|
+
|
48
|
+
# The logger is configured differently depending on the caTissue version.
|
28
49
|
log_cls = Java::edu.wustl.common.util.logger.Logger
|
29
50
|
if log_cls.respond_to?(:configure) then
|
51
|
+
# the caTissue 1.1.2 mechanism
|
30
52
|
log_cls.configure("")
|
31
53
|
else
|
32
54
|
# the caTissue 1.2 mechanism
|
33
55
|
cfg_cls = Java::edu.wustl.common.util.logger.LoggerConfig
|
34
|
-
|
56
|
+
# the caTissue 1.2 work-around
|
57
|
+
dir = clt_log ? File.dirname(clt_log) : default_log4j_config_directory
|
58
|
+
# configure the logger
|
35
59
|
cfg_cls.configureLogger(dir)
|
36
60
|
end
|
37
61
|
end
|
38
|
-
|
62
|
+
|
39
63
|
private
|
40
|
-
|
41
|
-
|
42
|
-
|
64
|
+
|
65
|
+
CONF_DIR = File.dirname(__FILE__) + '/../../../conf/wustl'
|
66
|
+
|
67
|
+
# Creates the parent directory of the given target path, if necessary.
|
43
68
|
#
|
44
|
-
# @
|
45
|
-
def self.
|
46
|
-
if
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Dir.mkdir('log')
|
55
|
-
rescue Exception => e
|
56
|
-
raise StandardError.new("Cannot create the log subdirectory required by the caTissue client: #{File.expand_path('log')}")
|
57
|
-
end
|
58
|
-
end
|
69
|
+
# @param [String] path the target path
|
70
|
+
def self.ensure_parent_directory_exists(path)
|
71
|
+
return if path == '/dev/null' or path == 'NUL'
|
72
|
+
File.mkdir(File.dirname(path))
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [String] the log4j config to use if one is not found in the classpath
|
76
|
+
def self.default_log4j_config_directory
|
77
|
+
subdir = Jinx::OS.os_type == :windows ? 'windows' : 'linux'
|
78
|
+
File.expand_path(subdir, CONF_DIR)
|
59
79
|
end
|
60
80
|
end
|
61
81
|
end
|
data/lib/catissue.rb
CHANGED
@@ -1,25 +1,43 @@
|
|
1
|
-
# This file is the entry point included by applications which
|
1
|
+
# This file is the entry point included by applications which use a CaTissue application service.
|
2
|
+
require 'uom'
|
3
|
+
require 'jinx'
|
4
|
+
require 'jinx/json'
|
5
|
+
require 'jinx/json/serializer'
|
6
|
+
require 'caruby'
|
7
|
+
require 'catissue/resource'
|
8
|
+
require 'catissue/metadata'
|
9
|
+
require 'catissue/annotation/annotatable'
|
10
|
+
require 'catissue/helpers/properties_loader'
|
2
11
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'caruby', 'lib')
|
10
|
-
end
|
12
|
+
# The caTissue domain package metadata mix-in. Each domain class automatically
|
13
|
+
# includes this CaTissue module when it is referenced.
|
14
|
+
module CaTissue
|
15
|
+
include Annotatable, Resource
|
16
|
+
|
17
|
+
extend Jinx::Importer
|
11
18
|
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
# Each CaTissue domain class extends CaTissue::Metadata.
|
20
|
+
@metadata_module = Metadata
|
21
|
+
|
22
|
+
# Inject the importer and application properties loader into this CaTissue module.
|
23
|
+
extend PropertiesLoader
|
15
24
|
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
# The caTissue Java package name.
|
26
|
+
packages 'edu.wustl.catissuecore.domain', 'edu.wustl.common.domain'
|
27
|
+
|
28
|
+
# The JRuby mix-ins are in the domain subdirectory.
|
29
|
+
definitions File.dirname(__FILE__) + '/catissue/domain'
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# Augments the superclass +Jinx::Importer.configure_importer+ method to first load
|
34
|
+
# the properties, build the classpath and initialize the caTissue logger.
|
35
|
+
def self.configure_importer
|
36
|
+
# Load the properties on demand.
|
37
|
+
properties
|
38
|
+
# Work around the caTissue logger bug.
|
39
|
+
require 'catissue/helpers/log'
|
40
|
+
# Delegate to superclass for the heavy lifting.
|
41
|
+
super
|
24
42
|
end
|
25
43
|
end
|
@@ -1,38 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require "test/unit"
|
5
|
-
require 'caruby/util/log'
|
6
|
-
require 'caruby/util/uniquifier'
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
|
+
require 'jinx/helpers/uniquifier'
|
7
3
|
require 'catissue/database/controlled_values'
|
8
4
|
|
9
5
|
class ControlledValuesTest < Test::Unit::TestCase
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
def test_search_by_public_id
|
7
|
+
races = CaTissue::ControlledValues.instance.for_public_id('Race_PID')
|
8
|
+
assert_not_nil(races, "Race CVs not loaded")
|
9
|
+
assert_not_nil(races.detect { |cv| cv.value == 'White' }, "Race not found")
|
14
10
|
end
|
15
11
|
|
16
|
-
# works but takes a long time
|
17
|
-
# def test_search_by_public_id
|
18
|
-
# tissue_sites = CaTissue::ControlledValues.instance.for_public_id(:tissue_site)
|
19
|
-
# assert_not_nil(tissue_sites, "Tissue site CVs not loaded")
|
20
|
-
# parent = tissue_sites.detect { |cv| cv.value == 'DIGESTIVE ORGANS' }
|
21
|
-
# assert_not_nil(parent, "DIGESTIVE ORGANS tissue site CVs not loaded")
|
22
|
-
# child = parent.children.detect { |cv| cv.value == 'ESOPHAGUS' }
|
23
|
-
# assert_not_nil(child, "DIGESTIVE ORGANS CV missing ESOPHAGUS child")
|
24
|
-
# gc = child.children.detect { |cv| cv.value == 'Esophagus, NOS' }
|
25
|
-
# assert_not_nil(gc, "ESOPHAGUS CV missing 'Esophagus, NOS' child")
|
26
|
-
# assert(!parent.children.include?(gc), "DIGESTIVE ORGANS CV children incorrectly includes ESOPHAGUS child")
|
27
|
-
# assert(parent.descendants.include?(gc), "DIGESTIVE ORGANS CV missing 'Esophagus, NOS' descendant")
|
28
|
-
# end
|
29
|
-
|
30
12
|
def test_find
|
31
|
-
|
13
|
+
cv = CaTissue::ControlledValues.instance.find(:tissue_site, 'Esophagus, NOS')
|
14
|
+
assert_not_nil(cv, "'Esophagus, NOS' CV not found")
|
32
15
|
end
|
33
16
|
|
34
17
|
def test_find_case_insensitive
|
35
|
-
|
18
|
+
cv = CaTissue::ControlledValues.instance.find(:tissue_site, 'esophagus, NOS')
|
19
|
+
assert_not_nil(cv, "Case-insensitive look-up inoperative")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_find_recursive
|
23
|
+
root = CaTissue::ControlledValues.instance.find(:tissue_site, 'DIGESTIVE ORGANS', true)
|
24
|
+
assert_not_nil(root, "'DIGESTIVE ORGANS' CV not found")
|
25
|
+
assert(!root.children.empty?, "#{root} missing children")
|
26
|
+
stomach = root.children.detect { |cv| cv.value == 'STOMACH' }
|
27
|
+
assert_not_nil(stomach, "#{root} STOMACH child CV not found")
|
28
|
+
pylorus = stomach.children.detect { |cv| cv.value == 'Pylorus' }
|
29
|
+
assert_not_nil(pylorus, "#{pylorus} Pylorus child CV not found")
|
30
|
+
assert(stomach.descendants.include?(pylorus), "#{root} CV missing #{pylorus} descendant")
|
36
31
|
end
|
37
32
|
|
38
33
|
def test_create_delete
|
@@ -44,4 +39,4 @@ class ControlledValuesTest < Test::Unit::TestCase
|
|
44
39
|
assert_nothing_raised("CV not deleted") { CaTissue::ControlledValues.instance.delete(cv) }
|
45
40
|
assert_nil(CaTissue::ControlledValues.instance.find(cv.public_id, cv.value), "Deleted CV found")
|
46
41
|
end
|
47
|
-
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
|
+
|
3
|
+
module CaTissue
|
4
|
+
class DatabaseTest < Test::Unit::TestCase
|
5
|
+
def test_executor
|
6
|
+
assert_nothing_raised("Executor execute failed") do
|
7
|
+
CaTissue::Database.instance.executor.execute { |dbh| dbh.execute(SQL) }
|
8
|
+
end
|
9
|
+
assert_nothing_raised("Executor query failed") do
|
10
|
+
CaTissue::Database.instance.executor.query(SQL)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
SQL = "select count(*) from catissue_site"
|
17
|
+
end
|
18
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require '
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
|
+
require 'jinx/helpers/uniquifier'
|
3
3
|
|
4
4
|
class AddressTest < Test::Unit::TestCase
|
5
5
|
include CaTissue::TestCase
|
@@ -10,6 +10,10 @@ class AddressTest < Test::Unit::TestCase
|
|
10
10
|
@user = defaults.tissue_bank.coordinator
|
11
11
|
@addr = @user.address
|
12
12
|
end
|
13
|
+
|
14
|
+
def test_primary_key
|
15
|
+
assert_equal([:identifier], CaTissue::Address.primary_key_attributes, "Primary key is not the identifier")
|
16
|
+
end
|
13
17
|
|
14
18
|
def test_defaults
|
15
19
|
verify_defaults(@addr)
|
@@ -21,13 +25,7 @@ class AddressTest < Test::Unit::TestCase
|
|
21
25
|
end
|
22
26
|
|
23
27
|
def test_save
|
24
|
-
#
|
25
|
-
|
26
|
-
# Modify the address.
|
27
|
-
expected = @addr.street = "#{Uniquifier.qualifier} Elm"
|
28
|
-
verify_save(@addr)
|
29
|
-
# Find the address.
|
30
|
-
fetched = @addr.copy(:identifier).find
|
31
|
-
assert_equal(expected, fetched.street, "Address street not saved")
|
28
|
+
# Address cannot be created.
|
29
|
+
assert_raises(CaRuby::DatabaseError, "Address create is incorrectly allowed.") { @addr.create }
|
32
30
|
end
|
33
|
-
end
|
31
|
+
end
|
@@ -1,26 +1,15 @@
|
|
1
|
-
require File.
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
2
|
|
3
3
|
class CaTissueTestDefaultsTest < Test::Unit::TestCase
|
4
4
|
include CaTissue::TestCase
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
def setup
|
9
|
-
super
|
10
|
-
@defaults = CaTissueTest::Defaults.instance
|
11
|
-
end
|
12
|
-
|
6
|
+
# Validates the #{CaTissue::TestCase::Seed} data.
|
13
7
|
def test_validation
|
14
|
-
assert_nothing_raised(ValidationError, "Defaults validation unsuccessful") { defaults.add_defaults.validate }
|
15
|
-
end
|
16
|
-
|
17
|
-
# Fetches the test data, creating new objects if necessary
|
18
|
-
def test_find
|
19
|
-
assert_nothing_raised(CaRuby::DatabaseError, "Defaults store unsuccessful") { defaults.each { |obj| database.find(obj) } }
|
8
|
+
assert_nothing_raised(Jinx::ValidationError, "Defaults validation unsuccessful") { defaults.add_defaults.validate }
|
20
9
|
end
|
21
10
|
|
22
|
-
#
|
11
|
+
# Saves the #{CaTissue::TestCase::Seed} data.
|
23
12
|
def test_save
|
24
|
-
defaults.each { |obj| verify_save(obj) }
|
13
|
+
defaults.domain_objects.each { |obj| verify_save(obj) }
|
25
14
|
end
|
26
15
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
2
|
|
3
3
|
class CapacityTest < Test::Unit::TestCase
|
4
4
|
include CaTissue::TestCase
|
5
5
|
|
6
|
-
# Verifies the :rows and
|
6
|
+
# Verifies the :rows and +:columns+ aliases.
|
7
7
|
def test_merge_attributes
|
8
8
|
cpc = CaTissue::Capacity.new(:columns => 5, :rows => 5)
|
9
9
|
assert_equal(5, cpc.one_dimension_capacity, "Rows incorrect")
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require '
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
|
+
require 'jinx/helpers/validation'
|
3
3
|
|
4
4
|
class CollectionEventParametersTest < Test::Unit::TestCase
|
5
5
|
include CaTissue::TestCase
|
@@ -10,13 +10,21 @@ class CollectionEventParametersTest < Test::Unit::TestCase
|
|
10
10
|
@spc = defaults.specimen
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def test_specimen_inverse_integrity
|
14
|
+
# A default CEP is added to a specimen.
|
15
|
+
@spc.add_defaults
|
16
|
+
cep = @spc.collection_event_parameters
|
17
|
+
assert_same(@spc, cep.specimen, "#{cep} not added to #{@spc} event parameters")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_scg_inverse_integrity
|
21
|
+
cep = @scg.collection_event_parameters
|
22
|
+
assert_same(@scg, cep.specimen_collection_group, "#{cep} not added to #{@scg} event parameters")
|
15
23
|
end
|
16
24
|
|
17
|
-
def
|
18
|
-
|
19
|
-
assert_raises(ValidationError, "
|
25
|
+
def test_owner_conflict
|
26
|
+
cep = CaTissue::SpecimenEventParameters.create_parameters(:collection, @scg)
|
27
|
+
assert_raises(Jinx::ValidationError, "Conflict allowed") { cep.specimen = @spc }
|
20
28
|
end
|
21
29
|
|
22
30
|
def test_update_scg_cep
|
@@ -30,7 +38,7 @@ class CollectionEventParametersTest < Test::Unit::TestCase
|
|
30
38
|
end
|
31
39
|
|
32
40
|
def test_update_specimen_cep
|
33
|
-
assert_nothing_raised("#{@
|
41
|
+
assert_nothing_raised("#{@spc} not created") { database.create(@spc) }
|
34
42
|
cep = @spc.collection_event_parameters
|
35
43
|
assert_not_nil(cep, "Autogenerated #{@spc} CEP not found")
|
36
44
|
assert_not_nil(cep.identifier, "Autogenerated #{@spc} CEP identifier not set")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.dirname(__FILE__) + '/../../../helpers/test_case'
|
2
2
|
|
3
3
|
class CollectionProtocolRegistrationTest < Test::Unit::TestCase
|
4
4
|
include CaTissue::TestCase
|
@@ -11,52 +11,62 @@ class CollectionProtocolRegistrationTest < Test::Unit::TestCase
|
|
11
11
|
def test_defaults
|
12
12
|
verify_defaults(@reg)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_missing_ppi_defaults
|
16
16
|
@reg.protocol_participant_identifier = nil
|
17
17
|
verify_defaults(@reg)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def test_inverse_protocol
|
21
21
|
assert(@reg.protocol.registrations.include?(@reg), "Registration not included in protocol registrations")
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
|
+
def test_inverse_scgs
|
25
|
+
assert(!@reg.specimen_collection_groups.empty?, "#{@reg} SCG is missing.")
|
26
|
+
end
|
27
|
+
|
24
28
|
# Tests whether the registration date can be set to either a Ruby or a Java Date and always return a Ruby Date.
|
25
29
|
def test_registration_date
|
26
30
|
value = DateTime.now
|
27
31
|
@reg.registration_date = value
|
28
32
|
assert_equal(value.to_s, @reg.registration_date.to_s, "Registration date incorrect")
|
29
33
|
end
|
30
|
-
|
34
|
+
|
31
35
|
def test_numeric_identifier
|
32
36
|
@reg.protocol_participant_identifier = 1
|
33
37
|
assert_equal("1", @reg.protocol_participant_identifier)
|
34
38
|
end
|
35
|
-
|
39
|
+
|
36
40
|
def test_disable
|
37
41
|
# add a derived specimen
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@reg.visit_path(
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
spc = @reg.specimens.first
|
43
|
+
assert_not_nil(spc, "#{@reg} specimen missing")
|
44
|
+
child = spc.derive(:specimen_class => :molecular, :specimen_requirement => defaults.specimen_requirement)
|
45
|
+
@reg.visit_path(:specimen_collection_groups, :specimens, :child_specimens) do |ref|
|
46
|
+
ref.activity_status = 'Disabled'
|
47
|
+
end
|
48
|
+
assert_equal('Disabled', @reg.activity_status, "#{@reg} not disabled")
|
49
|
+
@reg.specimen_collection_groups.each do |scg|
|
50
|
+
assert_equal('Disabled', scg.activity_status, "#{scg} not disabled")
|
51
|
+
end
|
52
|
+
@reg.specimens.each do |rspc|
|
53
|
+
assert_equal('Disabled', rspc.activity_status, "#{rspc} not disabled")
|
54
|
+
end
|
45
55
|
assert_equal('Disabled', child.activity_status, "Child Specimen #{child} not disabled")
|
46
56
|
end
|
47
|
-
|
57
|
+
|
48
58
|
# Tests creating and fetching a registration.
|
49
59
|
def test_save
|
50
60
|
# store the registration without an SCG
|
51
61
|
@reg.specimen_collection_groups.clear
|
52
62
|
verify_save(@reg)
|
53
|
-
|
63
|
+
|
54
64
|
# an SCG should be auto-generated
|
55
65
|
scg = @reg.specimen_collection_groups.first
|
56
66
|
assert_not_nil(scg, "Missing auto-generated SCG")
|
57
67
|
# the SCG status is pending
|
58
68
|
assert_equal('Pending', scg.collection_status, "Auto-generated SCG collection status incorrect")
|
59
|
-
|
69
|
+
|
60
70
|
# modify the consent status and update
|
61
71
|
rsps = @reg.consent_tier_responses
|
62
72
|
assert_equal(1, rsps.size, "Consent tier responses size incorrect")
|