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,11 +1,8 @@
1
- require 'caruby/util/validation'
1
+ require 'jinx/helpers/validation'
2
2
 
3
3
  module CaTissue
4
- # import the Java class
5
- resource_import Java::edu.wustl.catissuecore.domain.SpecimenRequirement
6
-
7
4
  # The SpecimenRequirement domain class.
8
- class SpecimenRequirement < CaTissue::AbstractSpecimen
5
+ class SpecimenRequirement
9
6
  # @quirk caTissue Bug #64: Some domain collection properties not initialized.
10
7
  # Initialize specimens if necessary.
11
8
  #
@@ -16,7 +13,11 @@ module CaTissue
16
13
 
17
14
  add_attribute_aliases(:collection_event => :collection_protocol_event)
18
15
 
19
- add_attribute_defaults(:initial_quantity => 0.0, :pathological_status => 'Not Specified', :specimen_type => 'Not Specified', :storage_type => 'Not Specified')
16
+ add_attribute_defaults(
17
+ :initial_quantity => 0.0,
18
+ :pathological_status => 'Not Specified',
19
+ :specimen_type => 'Not Specified',
20
+ :storage_type => 'Not Specified')
20
21
 
21
22
  add_mandatory_attributes(:collection_protocol_event, :storage_type)
22
23
 
@@ -36,18 +37,18 @@ module CaTissue
36
37
  # parent CPE is created.
37
38
  qualify_attribute(:child_specimens, :logical)
38
39
 
39
- # Overrides {Resource#owner} to return the parent_specimen, if it exists, or the collection_protocol_event otherwise.
40
- def owner
41
- parent_specimen or collection_protocol_event
42
- end
40
+ # The preferred owner attribute evaluation order is the parent specimen, then the CPE.
41
+ order_owner_attributes(:parent_specimen, :collection_protocol_event)
43
42
 
44
- # Returns the SpecimenRequirement in others which matches this SpecimenRequirement in the scope of an owner CollectionProtocolEvent.
45
- # This method relaxes {CaRuby::Resource#match_in_owner_scope} for a SpecimenRequirement that matches any SpecimenRequirement
46
- # in others with the same class, specimen type, pathological_status and characteristics.
43
+ # Returns the SpecimenRequirement in others which matches this SpecimenRequirement in the
44
+ # scope of an owner CollectionProtocolEvent. This method relaxes
45
+ # +Jinx::Resource.match_in_owner_scope+ for a SpecimenRequirement that matches any
46
+ # SpecimenRequirement in others with the same class, specimen type, pathological_status
47
+ # and characteristics.
47
48
  def match_in_owner_scope(others)
48
49
  others.detect do |other|
49
50
  self.class == other.class and specimen_type == other.specimen_type and pathological_status == other.pathological_status and
50
- characteristics and characteristics.match?(other.characteristics)
51
+ characteristics and characteristics.matches?(other.characteristics)
51
52
  end
52
53
  end
53
54
 
@@ -95,14 +96,15 @@ module CaTissue
95
96
  klass.new(params.merge(:collection_protocol_event => event))
96
97
  end
97
98
 
98
- # Returns the {#collection_event} protocol, if any.
99
+ # @return [CaTissue::CollectionProtocol] the collection event protocol, if any
99
100
  def collection_protocol
100
101
  collection_event.protocol if collection_event
101
102
  end
102
103
 
103
104
  protected
104
105
 
105
- # @quirk caTissue Overrides the CaRuby::Resource method to handle caTissue Bug #67 - SpecimenRequirement activityStatus cannot be set.
106
+ # @quirk caTissue Overrides the Jinx::Resource method to handle caTissue Bug #67 -
107
+ # SpecimenRequirement activityStatus cannot be set.
106
108
  #
107
109
  # @return [<Symbol>] the required attributes which are nil for this domain object
108
110
  def missing_mandatory_attributes
@@ -121,16 +123,16 @@ module CaTissue
121
123
  children.size > 1 and children.any? { |drv| not drv.aliquot? }
122
124
  end
123
125
 
124
- # Augments {CaRuby::Resource#validate} to verify that this SpecimenRequirement does not have multiple non-aliquot
125
- # derivatives, which is disallowed by caTissue.
126
+ # Augments +Jinx::Resource.validate+ to verify that this SpecimenRequirement does not have multiple
127
+ # non-aliquot derivatives, which is disallowed by caTissue.
126
128
  #
127
129
  # @quirk caTissue multiple SpecimenRequirement non-aliquot derivatives is accepted by caTissue but results
128
130
  # in obscure downstream errors (cf. Bug #151).
129
131
  #
130
- # @raise [ValidationError] if this SpecimenRequirement has multiple non-aliquot derivatives
132
+ # @raise [Jinx::ValidationError] if this SpecimenRequirement has multiple non-aliquot derivatives
131
133
  def validate_local
132
134
  super
133
- if multiple_derivatives? then raise ValidationError.new("Multiple derivatives not supported by caTissue") end
135
+ if multiple_derivatives? then raise Jinx::ValidationError.new("Multiple derivatives not supported by caTissue") end
134
136
  end
135
137
 
136
138
  # Adds the following default values, if necessary:
@@ -1,14 +1,11 @@
1
1
  require 'enumerator'
2
- require 'caruby/util/validation'
3
- require 'caruby/util/partial_order'
4
- require 'catissue/util/storage_type_holder'
2
+ require 'jinx/helpers/validation'
3
+ require 'jinx/helpers/partial_order'
4
+ require 'catissue/helpers/storage_type_holder'
5
5
 
6
6
  module CaTissue
7
- # import the Java class
8
- resource_import Java::edu.wustl.catissuecore.domain.StorageContainer
9
-
10
7
  # The +caTissue+ +StorageContainer+ domain class wrapper.
11
- class StorageContainer < CaTissue::Container
8
+ class StorageContainer
12
9
  include StorageTypeHolder
13
10
 
14
11
  # @quirk caTissue Bug #64: Some domain collection properties not initialized.
@@ -124,10 +121,10 @@ module CaTissue
124
121
  #
125
122
  # @param [Storable] (see #add)
126
123
  # @return [Boolean] whether this container is not full and can hold the given item's
127
- # {CaTissue::StorableType}
124
+ # {CaTissue::StorageType}
128
125
  def can_hold_child?(storable)
129
126
  st = storable.storable_type
130
- not full? and child_types.any? { |ct| CaRuby::Resource.value_equal?(ct, st) }
127
+ not full? and child_types.any? { |ct| Jinx::Resource.value_equal?(ct, st) }
131
128
  end
132
129
 
133
130
  protected
@@ -142,10 +139,10 @@ module CaTissue
142
139
  #
143
140
  # @param @storable (see #add)
144
141
  # @return [StorageContainer, nil] self if added, nil otherwise
145
- # @raise [ValidationError] if this container does not have a storage type, or if a circular
142
+ # @raise [Jinx::ValidationError] if this container does not have a storage type, or if a circular
146
143
  # containment reference is detected
147
144
  def add_to_existing_container(storable)
148
- if storage_type.nil? then raise ValidationError.new("Cannot add #{storable.qp} to #{qp} with missing storage type") end
145
+ if storage_type.nil? then raise Jinx::ValidationError.new("Cannot add #{storable.qp} to #{qp} with missing storage type") end
149
146
  # the subcontainers in column, row sort order
150
147
  scs = subcontainers.sort { |sc1, sc2| sc1.position.coordinate <=> sc2.position.coordinate }
151
148
  logger.debug { "Looking for a #{self} subcontainer from among #{scs.pp_s} to place #{storable.qp}..." } unless scs.empty?
@@ -155,7 +152,7 @@ module CaTissue
155
152
  # in CaTissue::Database#query_object. The work-around circumvents the bug for now, but
156
153
  # it doesn't hurt to check again.
157
154
  if identifier and sc.identifier == identifier then
158
- raise ValidationError.new("#{self} has a circular containment reference to subcontainer #{sc}")
155
+ raise Jinx::ValidationError.new("#{self} has a circular containment reference to subcontainer #{sc}")
159
156
  end
160
157
  # No circular reference; add to subcontainer if possible
161
158
  sc.add_to_existing_container(storable) if StorageContainer === sc
@@ -1,15 +1,11 @@
1
- require 'caruby/util/collection'
2
- require 'caruby/util/partial_order'
3
- require 'catissue/util/storage_type_holder'
4
- require 'catissue/domain/hash_code'
1
+ require 'jinx/helpers/partial_order'
2
+ require 'catissue/helpers/storage_type_holder'
3
+ require 'catissue/helpers/hash_code'
5
4
 
6
5
  module CaTissue
7
- # import the Java class
8
- resource_import Java::edu.wustl.catissuecore.domain.StorageType
9
-
10
6
  # The StorageType domain class.
11
- class StorageType < CaTissue::ContainerType
12
- include StorageTypeHolder, PartialOrder, HashCode
7
+ class StorageType
8
+ include StorageTypeHolder, Jinx::PartialOrder, HashCode
13
9
 
14
10
  add_attribute_aliases(:default_temperature => :default_temprature_in_centigrade)
15
11
 
@@ -58,7 +54,7 @@ module CaTissue
58
54
  #
59
55
  # @param other the object to compare
60
56
  # @return [Boolean] whether this StorageType has a non-nil name equal to the other name or
61
- # is {#equal?} to this StorageType
57
+ # is +equal?+ to this StorageType
62
58
  def ==(other)
63
59
  equal?(other) or (StorageType === other and name and name == other.name)
64
60
  end
@@ -1,13 +1,10 @@
1
- require 'caruby/util/validation'
2
- require 'catissue/util/location'
1
+ require 'jinx/helpers/validation'
2
+ require 'catissue/helpers/location'
3
3
 
4
4
  module CaTissue
5
- # import the Java class
6
- resource_import Java::edu.wustl.catissuecore.domain.TransferEventParameters
7
-
8
5
  # The +caTissue+ TransferEventParameters class is augmented with zero-based
9
6
  # +from_row+, +from_column+, +to_row+ and +to_column+ methods wrapping the corresponding one-based dimension attributes.
10
- class TransferEventParameters < CaTissue::SpecimenEventParameters
7
+ class TransferEventParameters
11
8
  add_attribute_aliases(:from_container => :from_storage_container, :to_container => :to_storage_container)
12
9
 
13
10
  # column and row are the zero-offset counterparts of position_dimension_one and position_dimension_two, resp.
@@ -1,31 +1,26 @@
1
- require 'caruby/util/validation'
2
- require 'catissue/resource'
3
- require 'catissue/util/person'
1
+ require 'jinx/helpers/validation'
2
+ require 'catissue/helpers/person'
4
3
 
5
4
  module CaTissue
6
- # import the Java class
7
- resource_import Java::edu.wustl.catissuecore.domain.User
8
-
9
5
  # The User domain class.
10
6
  #
11
7
  # @quirk caTissue caTissue 1.2 User has an adminuser Java property, but caTissue throws an
12
- # +UnsupportedOperationException+ if they are called.
8
+ # UnsupportedOperationException if it's accessor method is called.
9
+ #
13
10
  # @quirk caTissue clinical study is unsupported by 1.1.x caTissue, removed in 1.2.
14
- # @quirk caTissue obscure GUI artifact User page_of attribute pollutes the data layer as a
15
- # required attribute. Work-around is to simulate the GUI with a default value.
16
- # @quirk caTissue User address can be created but not updated in 1.2.
17
- # @quirk caTissue User address is not fetched on create in 1.2.
18
11
  class User
19
12
  include Person
20
13
 
21
14
  # @quirk caTissue work-around for caTissue Bug #66 - Client missing CSException class et al.
22
15
  # caTissue User class initializes roleId to "", which triggers a client exception on subsequent
23
16
  # getRoleId call. Use a private variable instead and bypass getRoleId.
17
+ #
18
+ # @quirk caTissue 1.2 Call to getRoleId results in the following error:
19
+ # NoClassDefFoundError: gov/nih/nci/security/dao/SearchCriteria
20
+ # This bug is probably a result of caTissue "fixing" Bug #66.
21
+ # The work-around to the caTissue bug fix bug is to return nil unless the role id has been set
22
+ # by a call to the {#role_id=} setter method.
24
23
  def role_id
25
- # TODO - uncomment following and get rid of @role_id i.v. when bug is fixed.
26
- #value = send(old_method)
27
- #return if value == ''
28
- #value.to_i
29
24
  @role_id
30
25
  end
31
26
 
@@ -45,18 +40,15 @@ module CaTissue
45
40
  setRoleId(value_s)
46
41
  end
47
42
 
48
- # @quirk caTissue caTissue 1.2 User has an adminuser Java property, but caTissue throws an
49
- # UnsupportedOperationException if they are called.
50
- if attribute_defined?(:adminuser) then remove_attribute(:adminuser) end
43
+ if property_defined?(:adminuser) then remove_attribute(:adminuser) end
51
44
 
52
- # make the convenience {, CaRuby::Person::Name} name a first-class attribute
45
+ # Make the convenience {CaRuby::Person::Name} name a first-class attribute.
53
46
  add_attribute(:name, CaRuby::Person::Name)
54
47
 
55
- # @quirk caTissue clinical study is unsupported by 1.1.x caTissue, removed in 1.2.
56
- if attribute_defined?(:clinical_studies) then remove_attribute(:clinical_studies) end
48
+ if property_defined?(:clinical_studies) then remove_attribute(:clinical_studies) end
57
49
 
58
- # clarify that collection_protocols is a coordinator -> protocol association.
59
- # make assigned protocol and site attribute names consistent.
50
+ # Clarify that collection_protocols is a coordinator -> protocol association.
51
+ # Make assigned protocol and site attribute names consistent.
60
52
  add_attribute_aliases(:coordinated_protocols => :collection_protocols, :protocols => :assigned_protocols, :assigned_sites => :sites)
61
53
 
62
54
  # login_name is a database unique key.
@@ -76,14 +68,15 @@ module CaTissue
76
68
  add_mandatory_attributes(:activity_status, :address, :cancer_research_group, :department,
77
69
  :email_address, :first_name, :institution, :last_name, :page_of, :role_id)
78
70
 
79
- # @quirk caTissue User address can be created but not updated in 1.2.
80
- #
81
- # @quirk caTissue User address is not fetched on create in 1.2.
71
+ # @quirk caTissue 1.2 User address can be updated in 1.1.2, but not 1.2. This difference is handled
72
+ # by the caRuby {CaTissue::Database} update case logic.
82
73
  #
83
- # @quirk caRuby adding the :saved_fetch qualifier results in JRuby load_error. TODO - fix this.
74
+ # @quirk caTissue 1.2 User address is fetched on create in 1.1.2, but not 1.2. This difference is
75
+ # handled by the caRuby {CaTissue::Database} create case logic.
84
76
  add_dependent_attribute(:address)
85
77
 
86
- # Password cannot be saved in 1.2.
78
+ # Password is removed as a visible caRuby attribute, since it is immutable in 1.2 and there
79
+ # is no use case for its access.
87
80
  remove_attribute(:passwords)
88
81
 
89
82
  set_attribute_inverse(:protocols, :assigned_protocol_users)
@@ -108,7 +101,7 @@ module CaTissue
108
101
 
109
102
  private
110
103
 
111
- # By default, the emailAddress is the same as the loginName.
104
+ # By default, the email address is the same as the login name.
112
105
  def add_defaults_local
113
106
  super
114
107
  self.login_name ||= email_address
@@ -1,7 +1,8 @@
1
- require 'caruby/util/validation'
1
+ require 'jinx/helpers/validation'
2
2
 
3
3
  module CaTissue
4
- # A Collectible mix-in instance can hold a #{ReceivedEventParameters} and a #{CollectedEventParameters}.
4
+ # A Collectible mix-in instance can hold a #{CaTissue::ReceivedEventParameters} and a
5
+ # #{CaTissue::CollectedEventParameters}.
5
6
  module Collectible
6
7
  # Builds this collectible domain object's SpecimenEventParameters from atomic parameters.
7
8
  #
@@ -9,7 +10,7 @@ module CaTissue
9
10
  # scg = CaTissue::SpecimenCollectionGroup.new(..., :collector => collector, :receiver => receiver)
10
11
  # scg.collection_event_parameters.user #=> collector
11
12
  # scg.received_event_parameters.user #=> receiver
12
- # @param (see CaRuby::Resource#merge_attributes)
13
+ # @param (see Jinx::Resource#merge_attributes)
13
14
  # @option opts (see #collect)
14
15
  def merge_attributes(other, attributes=nil)
15
16
  if Hash === other then
@@ -20,61 +21,65 @@ module CaTissue
20
21
  super
21
22
  end
22
23
 
23
- # Collects and receives this {Collectible} with the given options.
24
+ # Collects and receives this Collectible with the given options.
24
25
  #
25
26
  # @param (see #extract_event_parameters)
26
27
  # @option opts (see #extract_event_parameters)
27
- # @return [CaTissue::SpecimenEventParameters] the augmented SEPS
28
- # @raise [ValidationError] if this SCG has already been received
28
+ # @raise [Jinx::ValidationError] if this Collectible has already been received
29
29
  def collect(opts)
30
- raise ValidationError.new("#{self} is already collected") if received?
30
+ raise Jinx::ValidationError.new("#{self} is already collected") if received?
31
31
  specimen_event_parameters.merge!(extract_event_parameters(opts))
32
32
  end
33
33
 
34
- # Returns whether this SCG has a collected event.
34
+ # @return [Boolean] whether this Collectible has a collected event.
35
35
  def collected?
36
36
  collection_event_parameters
37
37
  end
38
38
 
39
- # Returns the User who collected this SCG.
39
+ # Returns the User who collected this Collectible.
40
40
  def collector
41
41
  ep = collection_event_parameters
42
42
  ep.user if ep
43
43
  end
44
44
 
45
- # @return [Date] the date this SCG was donated by the participant.
45
+ # @return [Date] the date this Collectible was donated by the participant.
46
46
  def collection_timestamp
47
47
  ep = collection_event_parameters
48
48
  ep.timestamp if ep
49
49
  end
50
50
 
51
- # Returns the CollectionEventParameters for this specimen group.
51
+ # Returns the CollectionEventParameters for this Collectible.
52
52
  def collection_event_parameters
53
53
  event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep }
54
54
  end
55
55
 
56
- # Returns whether this SCG has a received event.
56
+ # Returns the {CollectibleEventParameters} for this Collectible.
57
+ def collectible_event_parameters
58
+ event_parameters.select { |ep| CaTissue::CollectibleEventParameters === ep }
59
+ end
60
+
61
+ # Returns whether this Collectible has a received event.
57
62
  def received?
58
63
  received_event_parameters
59
64
  end
60
65
 
61
- # Returns the User who received this specimen group.
66
+ # Returns the User who received this Collectible.
62
67
  def receiver
63
68
  ep = received_event_parameters
64
69
  ep.user if ep
65
70
  end
66
71
 
67
- # Returns the ReceivedEventParameters for this specimen group.
72
+ # Returns the ReceivedEventParameters for this Collectible.
68
73
  def received_event_parameters
69
74
  event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep }
70
75
  end
71
76
 
72
77
  private
73
78
 
74
- # Overrides {CaRuby::Resource#each_defaults_dependent} to visit the {CaTissue::ReceivedEventParameters}.
79
+ # Overrides +Jinx::Resource.each_defaultable_reference+ to visit the +CaTissue::ReceivedEventParameters+.
75
80
  #
76
- # @yield (see CaRuby::Resource#each_defaults_dependent)
77
- def each_defaults_dependent
81
+ # @yield (see Jinx::Resource#each_defaultable_reference)
82
+ def each_defaultable_reference
78
83
  # visit ReceivedEventParameters first
79
84
  rep = received_event_parameters
80
85
  yield rep if rep
@@ -107,7 +112,7 @@ module CaTissue
107
112
  cdate = opts.delete(:collected_date)
108
113
  cdate ||= rdate
109
114
  eps << CaTissue::SpecimenEventParameters.create_parameters(:collection, self, :user => cltr, :timestamp => cdate)
110
- logger.debug { "SCG #{self} event parameters: #{eps.pp_s(:single_line)}" }
115
+ logger.debug { "Collectible #{self} event parameters: #{eps.pp_s(:single_line)}" }
111
116
  eps
112
117
  end
113
118
  end
@@ -0,0 +1,68 @@
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
7
+ # in the scope of an owner Specimen or SCG. This method relaxes +Jinx::Resource.match_in_owner_scope+
8
+ # for a CollectibleEventParameters that matches any SpecimenEventParameters in others of the same
9
+ # class, since there can be at most one CollectibleEventParameters of a given class for a given SCG.
10
+ def match_in_owner_scope(others)
11
+ others.detect { |other| minimal_match?(other) }
12
+ end
13
+
14
+ private
15
+
16
+ # Injects validations into the owner writer methods for the following constraints:
17
+ # * a CollectibleEventParameters instance cannot be owned by both a specimen and a SCG.
18
+ # * a Collectible cannot include more than one CollectibleEventParameters instance of a given type.
19
+ #
20
+ # @param [Class] klass the including class
21
+ def self.included(klass)
22
+ klass.class_eval do
23
+ [:specimenCollectionGroup, :specimen].each do |pa|
24
+ wtr = "#{pa}=".to_sym
25
+ redefine_method(wtr) do |base|
26
+ lambda do |obj|
27
+ validate_no_owner_confict(pa, obj)
28
+ validate_exclusivity(pa, obj)
29
+ send(base, obj)
30
+ end
31
+ end
32
+ logger.debug { "Redefined the #{qp} #{pa} method to ensure the owner exclusivity constraints." }
33
+ end
34
+ end
35
+ end
36
+
37
+ # @param attribute the owner attribute to set
38
+ # @param obj the owner to set
39
+ # @raise [Jinx::ValidationError] if this event parameters object already has a different owner attribute referent
40
+ def validate_no_owner_confict(attribute, obj)
41
+ return if obj.nil?
42
+ self.class.owner_attributes.each do |oa|
43
+ next if oa == attribute
44
+ other = send(oa)
45
+ if other then
46
+ raise Jinx::ValidationError.new("Cannot add #{qp} to #{attribute} #{obj}, since it is already owned by #{other}")
47
+ end
48
+ end
49
+ end
50
+
51
+ def validate_exclusivity(attribute, obj)
52
+ return if obj.nil?
53
+ inv = self.class.property(attribute).inverse
54
+ other = obj.send(inv).detect { |ep| self.class === ep }
55
+ if other and other != self then
56
+ raise Jinx::ValidationError.new("Cannot add #{self} to #{attribute} #{obj}, since #{obj} already includes #{other}")
57
+ end
58
+ end
59
+
60
+ # Overrides +Jinx::Migratable.migratable__preferred_owner+ to give preference to
61
+ # a SCG over a Specimen.
62
+ #
63
+ # @param (see Jinx::Migratable#migratable__migrate_owner)
64
+ def migratable__preferred_owner(candidates)
65
+ candidates.detect { |obj| CaTissue::SpecimenCollectionGroup === obj }
66
+ end
67
+ end
68
+ end