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.
Files changed (255) hide show
  1. data/Gemfile +17 -0
  2. data/History.md +5 -1
  3. data/README.md +2 -2
  4. data/bin/crtdump +2 -8
  5. data/bin/crtexample +2 -5
  6. data/bin/crtmigrate +3 -6
  7. data/bin/crtsmoke +3 -8
  8. data/conf/wustl/{log4j.properties → linux/log4j.properties} +3 -3
  9. data/conf/wustl/windows/log4j.properties +40 -0
  10. data/examples/galena/Gemfile +16 -0
  11. data/examples/galena/Gemfile.lock +88 -0
  12. data/examples/galena/README.md +16 -16
  13. data/examples/galena/Rakefile +30 -0
  14. data/examples/galena/bin/seed +5 -11
  15. data/examples/galena/conf/annotation/defaults.yaml +2 -0
  16. data/examples/galena/conf/{migration/annotation_fields.yaml → annotation/fields.yaml} +2 -4
  17. data/examples/galena/conf/defaults.yaml +9 -0
  18. data/examples/galena/conf/{migration/filter_fields.yaml → filter/fields.yaml} +0 -1
  19. data/examples/galena/conf/filter/values.yaml +8 -0
  20. data/examples/galena/conf/{migration/frozen_defaults.yaml → frozen/defaults.yaml} +0 -0
  21. data/examples/galena/conf/{migration/frozen_fields.yaml → frozen/fields.yaml} +0 -2
  22. data/examples/galena/conf/{migration/general_fields.yaml → general/fields.yaml} +0 -24
  23. data/examples/galena/conf/registration/fields.yaml +6 -0
  24. data/examples/galena/conf/{migration/simple_fields.yaml → simple/fields.yaml} +1 -6
  25. data/examples/galena/data/annotation.csv +1 -1
  26. data/examples/galena/data/filter.csv +1 -1
  27. data/examples/galena/data/frozen.csv +1 -1
  28. data/examples/galena/data/general.csv +1 -1
  29. data/examples/galena/data/registration.csv +1 -1
  30. data/examples/galena/data/simple.csv +1 -1
  31. data/examples/galena/galena.gemspec +24 -0
  32. data/examples/galena/lib/galena/filter.rb +25 -0
  33. data/examples/galena/lib/galena/{tissue/migration/frozen_shims.rb → frozen.rb} +6 -10
  34. data/examples/galena/lib/galena/seed.rb +126 -0
  35. data/examples/galena/lib/galena/version.rb +3 -0
  36. data/examples/galena/lib/galena.rb +18 -7
  37. data/examples/galena/log/galena.log +37351 -0
  38. data/examples/galena/log/galena.log.0 +147830 -0
  39. data/examples/galena/spec/annotation_spec.rb +46 -0
  40. data/examples/galena/spec/filter_spec.rb +94 -0
  41. data/examples/galena/spec/frozen_spec.rb +39 -0
  42. data/examples/galena/spec/general_spec.rb +62 -0
  43. data/examples/galena/spec/registration_spec.rb +37 -0
  44. data/examples/galena/spec/seed.rb +107 -0
  45. data/examples/galena/spec/simple_spec.rb +58 -0
  46. data/examples/galena/spec/spec_helper.rb +11 -0
  47. data/examples/galena/spec/support/migration.rb +70 -0
  48. data/lib/catissue/annotation/annotatable.rb +10 -8
  49. data/lib/catissue/annotation/annotation.rb +7 -7
  50. data/lib/catissue/annotation/de_integration.rb +9 -20
  51. data/lib/catissue/annotation/importer.rb +148 -0
  52. data/lib/catissue/annotation/introspector.rb +32 -0
  53. data/lib/catissue/annotation/metadata.rb +422 -0
  54. data/lib/catissue/annotation/proxy.rb +2 -2
  55. data/lib/catissue/annotation/proxy_class.rb +45 -30
  56. data/lib/catissue/annotation/record_entry_proxy.rb +2 -2
  57. data/lib/catissue/cli/command.rb +14 -24
  58. data/lib/catissue/cli/example.rb +5 -3
  59. data/lib/catissue/cli/migrate.rb +45 -37
  60. data/lib/catissue/cli/smoke.rb +2 -3
  61. data/lib/catissue/database/annotation/annotation_service.rb +8 -17
  62. data/lib/catissue/database/annotation/entity_facade.rb +33 -30
  63. data/lib/catissue/database/annotation/id_generator.rb +1 -1
  64. data/lib/catissue/database/annotation/integration_service.rb +11 -4
  65. data/lib/catissue/database/annotation/reference_writer.rb +38 -38
  66. data/lib/catissue/database/controlled_value_finder.rb +13 -28
  67. data/lib/catissue/database/controlled_values.rb +73 -45
  68. data/lib/catissue/database.rb +637 -277
  69. data/lib/catissue/domain/abstract_domain_object.rb +5 -0
  70. data/lib/catissue/domain/abstract_position.rb +3 -5
  71. data/lib/catissue/domain/abstract_specimen.rb +79 -65
  72. data/lib/catissue/domain/abstract_specimen_collection_group.rb +3 -6
  73. data/lib/catissue/domain/address.rb +0 -2
  74. data/lib/catissue/domain/cancer_research_group.rb +0 -3
  75. data/lib/catissue/domain/capacity.rb +2 -4
  76. data/lib/catissue/domain/check_in_check_out_event_parameter.rb +0 -3
  77. data/lib/catissue/domain/collection_event_parameters.rb +2 -7
  78. data/lib/catissue/domain/collection_protocol.rb +11 -16
  79. data/lib/catissue/domain/collection_protocol_event.rb +19 -12
  80. data/lib/catissue/domain/collection_protocol_registration.rb +8 -12
  81. data/lib/catissue/domain/consent_tier_response.rb +0 -4
  82. data/lib/catissue/domain/consent_tier_status.rb +1 -4
  83. data/lib/catissue/domain/container.rb +10 -10
  84. data/lib/catissue/domain/container_position.rb +4 -7
  85. data/lib/catissue/domain/container_type.rb +4 -7
  86. data/lib/catissue/domain/department.rb +0 -3
  87. data/lib/catissue/domain/disposal_event_parameters.rb +5 -5
  88. data/lib/catissue/domain/embedded_event_parameters.rb +1 -4
  89. data/lib/catissue/domain/external_identifier.rb +0 -12
  90. data/lib/catissue/domain/frozen_event_parameters.rb +1 -4
  91. data/lib/catissue/domain/institution.rb +0 -3
  92. data/lib/catissue/domain/new_specimen_array_order_item.rb +0 -5
  93. data/lib/catissue/domain/order_details.rb +0 -2
  94. data/lib/catissue/domain/participant/clinical/chemotherapy.rb +1 -3
  95. data/lib/catissue/domain/participant/clinical/duration.rb +2 -4
  96. data/lib/catissue/domain/participant/clinical/radiation_therapy.rb +2 -4
  97. data/lib/catissue/domain/participant.rb +22 -24
  98. data/lib/catissue/domain/participant_medical_identifier.rb +0 -4
  99. data/lib/catissue/domain/password.rb +0 -4
  100. data/lib/catissue/domain/race.rb +0 -3
  101. data/lib/catissue/domain/received_event_parameters.rb +3 -6
  102. data/lib/catissue/domain/site.rb +1 -4
  103. data/lib/catissue/domain/specimen/pathology/additional_finding.rb +12 -0
  104. data/lib/catissue/domain/specimen/pathology/details.rb +12 -0
  105. data/lib/catissue/domain/specimen/pathology/gleason_score.rb +12 -0
  106. data/lib/catissue/domain/specimen/pathology/histologic_grade.rb +12 -0
  107. data/lib/catissue/domain/specimen/pathology/histologic_type.rb +19 -0
  108. data/lib/catissue/domain/specimen/pathology/histologic_variant_type.rb +12 -0
  109. data/lib/catissue/domain/specimen/pathology/invasion.rb +12 -0
  110. data/lib/catissue/domain/specimen/pathology/prostate_specimen_gleason_score.rb +5 -11
  111. data/lib/catissue/domain/specimen/pathology/prostate_specimen_pathology_annotation.rb +12 -12
  112. data/lib/catissue/domain/specimen/pathology/specimen_additional_finding.rb +5 -14
  113. data/lib/catissue/domain/specimen/pathology/specimen_base_solid_tissue_pathology_annotation.rb +6 -21
  114. data/lib/catissue/domain/specimen/pathology/specimen_details.rb +4 -10
  115. data/lib/catissue/domain/specimen/pathology/specimen_histologic_grade.rb +4 -10
  116. data/lib/catissue/domain/specimen/pathology/specimen_histologic_type.rb +6 -14
  117. data/lib/catissue/domain/specimen/pathology/specimen_histologic_variant_type.rb +5 -11
  118. data/lib/catissue/domain/specimen/pathology/specimen_invasion.rb +5 -11
  119. data/lib/catissue/domain/specimen.rb +113 -76
  120. data/lib/catissue/domain/specimen_array.rb +0 -3
  121. data/lib/catissue/domain/specimen_array_content.rb +1 -4
  122. data/lib/catissue/domain/specimen_array_type.rb +1 -4
  123. data/lib/catissue/domain/specimen_characteristics.rb +0 -3
  124. data/lib/catissue/domain/specimen_collection_group/pathology/base_pathology_annotation.rb +2 -4
  125. data/lib/catissue/domain/specimen_collection_group/pathology/base_solid_tissue_pathology_annotation.rb +2 -4
  126. data/lib/catissue/domain/specimen_collection_group.rb +43 -53
  127. data/lib/catissue/domain/specimen_event_parameters.rb +24 -32
  128. data/lib/catissue/domain/specimen_position.rb +8 -5
  129. data/lib/catissue/domain/specimen_protocol.rb +3 -6
  130. data/lib/catissue/domain/specimen_requirement.rb +22 -20
  131. data/lib/catissue/domain/storage_container.rb +9 -12
  132. data/lib/catissue/domain/storage_type.rb +6 -10
  133. data/lib/catissue/domain/transfer_event_parameters.rb +3 -6
  134. data/lib/catissue/domain/user.rb +22 -29
  135. data/lib/catissue/{util → helpers}/collectible.rb +23 -18
  136. data/lib/catissue/helpers/collectible_event_parameters.rb +68 -0
  137. data/lib/catissue/helpers/controlled_value.rb +35 -0
  138. data/lib/catissue/{domain → helpers}/hash_code.rb +0 -0
  139. data/lib/catissue/{util → helpers}/location.rb +6 -5
  140. data/lib/catissue/helpers/log.rb +4 -0
  141. data/lib/catissue/{util → helpers}/person.rb +1 -1
  142. data/lib/catissue/{util → helpers}/position.rb +10 -8
  143. data/lib/catissue/helpers/properties_loader.rb +143 -0
  144. data/lib/catissue/{util → helpers}/storable.rb +2 -1
  145. data/lib/catissue/{util → helpers}/storage_type_holder.rb +9 -3
  146. data/lib/catissue/{annotation/annotatable_class.rb → metadata.rb} +73 -95
  147. data/lib/catissue/migration/migratable.rb +93 -44
  148. data/lib/catissue/migration/migrator.rb +26 -42
  149. data/lib/catissue/migration/shims.rb +1 -1
  150. data/lib/catissue/migration/unique.rb +76 -0
  151. data/lib/catissue/resource.rb +16 -20
  152. data/lib/catissue/version.rb +1 -1
  153. data/lib/catissue/wustl/logger.rb +52 -32
  154. data/lib/catissue.rb +38 -20
  155. data/test/lib/catissue/database/controlled_values_test.rb +22 -27
  156. data/test/lib/catissue/database/database_test.rb +18 -0
  157. data/test/lib/catissue/domain/address_test.rb +9 -11
  158. data/test/lib/catissue/domain/ca_tissue_test_defaults_test.rb +5 -16
  159. data/test/lib/catissue/domain/capacity_test.rb +2 -2
  160. data/test/lib/catissue/domain/collection_event_parameters_test.rb +16 -8
  161. data/test/lib/catissue/domain/collection_protocol_event_test.rb +1 -1
  162. data/test/lib/catissue/domain/collection_protocol_registration_test.rb +26 -16
  163. data/test/lib/catissue/domain/collection_protocol_test.rb +2 -2
  164. data/test/lib/catissue/domain/container_position_test.rb +7 -4
  165. data/test/lib/catissue/domain/department_test.rb +3 -3
  166. data/test/lib/catissue/domain/disposal_event_parameters_test.rb +1 -1
  167. data/test/lib/catissue/domain/external_identifier_test.rb +5 -1
  168. data/test/lib/catissue/domain/location_test.rb +4 -4
  169. data/test/lib/catissue/domain/participant_medical_identifier_test.rb +3 -3
  170. data/test/lib/catissue/domain/participant_test.rb +33 -20
  171. data/test/lib/catissue/domain/received_event_parameters_test.rb +19 -0
  172. data/test/lib/catissue/domain/site_test.rb +2 -2
  173. data/test/lib/catissue/domain/specimen_array_test.rb +3 -3
  174. data/test/lib/catissue/domain/specimen_array_type_test.rb +6 -6
  175. data/test/lib/catissue/domain/specimen_characteristics_test.rb +1 -1
  176. data/test/lib/catissue/domain/specimen_collection_group_test.rb +49 -13
  177. data/test/lib/catissue/domain/specimen_event_parameters_test.rb +4 -4
  178. data/test/lib/catissue/domain/specimen_position_test.rb +1 -1
  179. data/test/lib/catissue/domain/specimen_requirement_test.rb +2 -2
  180. data/test/lib/catissue/domain/specimen_test.rb +58 -24
  181. data/test/lib/catissue/domain/storage_container_test.rb +3 -16
  182. data/test/lib/catissue/domain/storage_type_test.rb +3 -3
  183. data/test/lib/catissue/domain/transfer_event_parameters_test.rb +17 -17
  184. data/test/lib/catissue/domain/user_test.rb +32 -34
  185. data/test/lib/catissue/helpers/properties_loader_test.rb +19 -0
  186. data/test/lib/catissue/migration/{test_case.rb → helpers/test_case.rb} +30 -20
  187. data/test/lib/examples/galena/tissue/domain/examples_test.rb +28 -38
  188. data/test/lib/examples/galena/tissue/helpers/test_case.rb +24 -0
  189. metadata +175 -99
  190. data/bin/crtextract +0 -47
  191. data/examples/galena/conf/extract/simple_fields.yaml +0 -4
  192. data/examples/galena/conf/migration/annotation_defaults.yaml +0 -2
  193. data/examples/galena/conf/migration/filter_defaults.yaml +0 -1
  194. data/examples/galena/conf/migration/filter_values.yaml +0 -13
  195. data/examples/galena/conf/migration/participant_fields.yaml +0 -4
  196. data/examples/galena/conf/migration/registration_fields.yaml +0 -5
  197. data/examples/galena/data/participant.csv +0 -1
  198. data/examples/galena/lib/galena/tissue/migration/filter_shims.rb +0 -41
  199. data/examples/galena/lib/galena/tissue/seed/defaults.rb +0 -127
  200. data/examples/psbin/README.md +0 -45
  201. data/examples/psbin/conf/adjuvant_hormone_defaults.yaml +0 -2
  202. data/examples/psbin/conf/adjuvant_radiation_defaults.yaml +0 -3
  203. data/examples/psbin/conf/biopsy_defaults.yaml +0 -3
  204. data/examples/psbin/conf/biopsy_fields.yaml +0 -9
  205. data/examples/psbin/conf/neoadjuvant_hormone_defaults.yaml +0 -2
  206. data/examples/psbin/conf/neoadjuvant_radiation_defaults.yaml +0 -3
  207. data/examples/psbin/conf/patient_defaults.yaml +0 -3
  208. data/examples/psbin/conf/patient_fields.yaml +0 -5
  209. data/examples/psbin/conf/surgery_defaults.yaml +0 -4
  210. data/examples/psbin/conf/surgery_fields.yaml +0 -15
  211. data/examples/psbin/conf/t_stage_defaults.yaml +0 -1
  212. data/examples/psbin/conf/t_stage_fields.yaml +0 -4
  213. data/examples/psbin/conf/therapy_fields.yaml +0 -5
  214. data/examples/psbin/data/adjuvant_hormone.csv +0 -1
  215. data/examples/psbin/data/adjuvant_radiation.csv +0 -1
  216. data/examples/psbin/data/biopsy.csv +0 -1
  217. data/examples/psbin/data/neoadjuvant_hormone.csv +0 -1
  218. data/examples/psbin/data/neoadjuvant_radiation.csv +0 -1
  219. data/examples/psbin/data/patient.csv +0 -1
  220. data/examples/psbin/data/surgery.csv +0 -1
  221. data/examples/psbin/data/t_stage.csv +0 -1
  222. data/examples/psbin/lib/psbin/biopsy_shims.rb +0 -15
  223. data/examples/psbin/lib/psbin/surgery_shims.rb +0 -15
  224. data/lib/catissue/annotation/annotation_class.rb +0 -406
  225. data/lib/catissue/annotation/annotation_module.rb +0 -106
  226. data/lib/catissue/domain.rb +0 -26
  227. data/lib/catissue/extract/command.rb +0 -31
  228. data/lib/catissue/extract/delta.rb +0 -58
  229. data/lib/catissue/extract/extractor.rb +0 -99
  230. data/lib/catissue/migration/uniquify.rb +0 -2
  231. data/lib/catissue/util/collectible_event_parameters.rb +0 -71
  232. data/lib/catissue/util/controlled_value.rb +0 -29
  233. data/lib/catissue/util/uniquify.rb +0 -86
  234. data/test/fixtures/catissue/domain/conf/catissue_override.yaml +0 -9
  235. data/test/fixtures/catissue/extract/conf/scg_extract.yaml +0 -3
  236. data/test/fixtures/catissue/extract/conf/scg_fields.yaml +0 -3
  237. data/test/fixtures/catissue/extract/conf/spc_extract.yaml +0 -3
  238. data/test/fixtures/catissue/extract/conf/spc_fields.yaml +0 -4
  239. data/test/fixtures/lib/catissue/defaults_test_fixture.rb +0 -206
  240. data/test/fixtures/lib/examples/galena/migration/alt_key_shims.rb +0 -7
  241. data/test/lib/catissue/domain/base_haemotology_pathology_test.rb +0 -24
  242. data/test/lib/catissue/extract/delta_test.rb +0 -25
  243. data/test/lib/catissue/extract/extractor_test.rb +0 -43
  244. data/test/lib/catissue/import/importable_module_test.rb +0 -14
  245. data/test/lib/catissue/test_case.rb +0 -247
  246. data/test/lib/examples/galena/tissue/migration/annotation_test.rb +0 -29
  247. data/test/lib/examples/galena/tissue/migration/filter_test.rb +0 -29
  248. data/test/lib/examples/galena/tissue/migration/frozen_test.rb +0 -36
  249. data/test/lib/examples/galena/tissue/migration/general_test.rb +0 -56
  250. data/test/lib/examples/galena/tissue/migration/participant_test.rb +0 -61
  251. data/test/lib/examples/galena/tissue/migration/registration_test.rb +0 -17
  252. data/test/lib/examples/galena/tissue/migration/seedify.rb +0 -119
  253. data/test/lib/examples/galena/tissue/migration/simple_test.rb +0 -30
  254. data/test/lib/examples/galena/tissue/migration/test_case.rb +0 -72
  255. data/test/lib/examples/psbin/migration_test.rb +0 -153
@@ -1,6 +1,6 @@
1
1
  module CaTissue
2
2
  # The version of this caRuby Tissue release.
3
- VERSION = "1.5.6"
3
+ VERSION = "2.1.1"
4
4
 
5
5
  # The supported caTissue release versions.
6
6
  CATISSUE_VERSIONS = "1.1.2-1.2"
@@ -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 class
12
- # path. However, in 1.2 the client property file is +client_log4j.properties+. Work-around is
13
- # as follows:
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 The caTissue client log location is unfortunately hard-coded in a caTissue client
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 in release 1.1.x. The work-around is to ensure that the
21
- # working directory contains a log subdirectory.
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
- # make the required log subdirectory in the working directory
26
- ensure_log_directory_exists
27
- # the caTissue 1.1.x mechanism
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
- dir = File.join(File.dirname(__FILE__), '..', '..', '..', 'conf', 'wustl')
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
- # Makes a +./log+ subdirectory to avoid a caTissue log initializer error. This method should be called
42
- # before configuring the logger.
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
- # @quirk caTissue avoid caTissue error by creating log subdirectory.
45
- def self.ensure_log_directory_exists
46
- if File.directory?('log') then
47
- unless File.writable?('log') then
48
- raise StandardError.new("caTissue log subdirectory #{File.expand_path('log')} is not writable")
49
- end
50
- elsif File.exists?('log') then
51
- raise StandardError.new("Existing file #{File.expand_path('log')} prevents creation of the required caTissue log subdirectory")
52
- else
53
- begin
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 reference a CaTissue object or service.
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
- # the caRuby core gem
4
- require 'rubygems'
5
- begin
6
- gem 'caruby-core'
7
- rescue LoadError
8
- # if the gem is not available, then try a local development source
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
- require 'caruby/util/log'
13
- require 'catissue/domain'
14
- require 'catissue/database'
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
- # CaTissue wraps the caTissue Java API.
17
- # See the caRuby[http://http://caruby.rubyforge.org/] home page for more information.
18
- module CaTissue
19
- # @param [<String>] nodes the path components relative to the caRuby Tissue source directory
20
- # @return [String] the file path to the specified path components
21
- def self.path(*nodes)
22
- root = File.join(File.dirname(__FILE__), '..')
23
- File.expand_path(File.join(*nodes), root)
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
- $:.unshift 'lib'
2
- $:.unshift '../caruby/lib'
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
- LOG_FILE = 'test/results/catissue/log/catissue.log'
11
-
12
- def setup
13
- CaRuby::Log.instance.open(LOG_FILE, :debug => true)
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
- assert_not_nil(CaTissue::ControlledValues.instance.find(:tissue_site, 'Esophagus, NOS'), "'Esophagus, NOS' CV not found")
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
- assert_not_nil(CaTissue::ControlledValues.instance.find(:tissue_site, 'esophagus, NOS'), "Case-insensitive look-up inoperative")
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.join(File.dirname(__FILE__), '..', 'test_case')
2
- require 'caruby/util/uniquifier'
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
- # Create the address.
25
- verify_save(@addr)
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.join(File.dirname(__FILE__), '..', 'test_case')
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
- attr_reader :defaults
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
- # Store the test data
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.join(File.dirname(__FILE__), '..', 'test_case')
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 :columns aliases.
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.join(File.dirname(__FILE__), '..', 'test_case')
2
- require 'caruby/util/validation'
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 test_scg_owner_conflict
14
- assert_raises(ValidationError, "Owner conflict allowed") { @scg.received_event_parameters.specimen = @spc }
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 test_specimen_owner_conflict
18
- @spc.collect(:receiver => @scg.receiver)
19
- assert_raises(ValidationError, "Owner conflict allowed") { @spc.received_event_parameters.specimen_collection_group = @scg }
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("#{@scg} not created") { database.create(@spc) }
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.join(File.dirname(__FILE__), '..', 'test_case')
1
+ require File.dirname(__FILE__) + '/../../../helpers/test_case'
2
2
 
3
3
  class CollectionProtocolEventTest < Test::Unit::TestCase
4
4
  include CaTissue::TestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', 'test_case')
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
- specimen = @reg.specimens.first
39
- child = specimen.derive(:specimen_class => :molecular, :specimen_requirement => defaults.specimen_requirement)
40
- attributes = [:specimen_collection_groups, :specimens, :child_specimens]
41
- @reg.visit_path(attributes) { |obj| obj.activity_status = 'Disabled' }
42
- assert_equal('Disabled', @reg.activity_status, "Registration not disabled")
43
- @reg.specimen_collection_groups.each { |scg| assert_equal('Disabled', scg.activity_status, "SCG #{scg} not disabled") }
44
- @reg.specimens.each { |spc| assert_equal('Disabled', spc.activity_status, "Specimen #{spc} not disabled") }
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")