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
@@ -0,0 +1,5 @@
1
+ module CaTissue
2
+ class AbstractDomainObject
3
+ property :identifier, :primary_key
4
+ end
5
+ end
@@ -1,12 +1,10 @@
1
- require 'catissue/util/position'
1
+ require 'catissue/helpers/position'
2
2
 
3
3
  module CaTissue
4
- resource_import Java::edu.wustl.catissuecore.domain.AbstractPosition
5
-
6
4
  # The +caTissue+ AbstractPosition class is augmented with a comparison operator and the
7
5
  # zero-based +row+ and +column+ methods wrapping the corresponding one-based dimension
8
6
  # attributes. Each AbstractPosition is required to implement the +holder+ and +occupant+
9
- #�methods.
7
+ # methods.
10
8
  class AbstractPosition
11
9
  include Position
12
10
 
@@ -19,4 +17,4 @@ module CaTissue
19
17
  # add the synthetic {#location} attribute
20
18
  add_attribute(:location, Location)
21
19
  end
22
- end
20
+ end
@@ -1,13 +1,11 @@
1
1
  require 'set'
2
- require 'caruby/util/inflector'
3
- require 'caruby/util/validation'
2
+ require 'jinx/helpers/inflector'
3
+ require 'jinx/helpers/validation'
4
4
 
5
5
  module CaTissue
6
- resource_import Java::edu.wustl.catissuecore.domain.AbstractSpecimen
7
-
8
6
  class AbstractSpecimen
9
7
  # Sets the specimen type to the specified value. The value can be a permissible caTissue String value or
10
- # the shortcut symbols :fresh, :fixed and :frozen.
8
+ # the shortcut symbols :fresh, :fixed and +:frozen+.
11
9
  #
12
10
  # @param [String, Symbol, nil] value the value to set
13
11
  def specimen_type=(value)
@@ -28,7 +26,7 @@ module CaTissue
28
26
  add_mandatory_attributes(:lineage, :pathological_status, :specimen_class, :specimen_type, :specimen_characteristics)
29
27
 
30
28
  # @quirk caTissue Specimen characteristics are auto-generated but SpecimenRequirement
31
- # characteristics are not. It is safe to set the :autogenerated flag for both
29
+ # characteristics are not. It is safe to set the +:autogenerated+ flag for both
32
30
  # AbstractSpecimen subclasses. This results in an unnecessary SpecimenRequirement
33
31
  # create database query, but SpecimenRequirement create is rare and there is no harm.
34
32
  #
@@ -40,33 +38,42 @@ module CaTissue
40
38
  # differs from the existing id.
41
39
  #
42
40
  # @quirk caTissue Unlike other dependents, AbstractSpecimen characteristics, events and child
43
- # specimens have cascade style 'all'. This implies that an AbstractSpecimen update does not
41
+ # specimens have cascade style +all+. This implies that an AbstractSpecimen update does not
44
42
  # create a referenced dependent. AbstractSpecimen create cascades to create and AbstractSpecimen
45
43
  # update cascades to update, but AbstractSpecimen update does not cascade to create.
46
- # The :no_cascade_update_to_create flag is set to handle this feature of cascade style 'all'.
44
+ # The +:no_cascade_update_to_create flag+ is set to handle this feature of cascade style +all+.
47
45
  qualify_attribute(:specimen_characteristics, :cascaded, :fetched, :autogenerated, :no_cascade_update_to_create)
48
46
 
49
- # The :no_cascade_update_to_create flag is set since events has cascade style 'all'.
50
- add_dependent_attribute(:specimen_events, :create_only, :disjoint, :no_cascade_update_to_create)
51
-
47
+ # The +:no_cascade_update_to_create+ flag is set since specimen_events has cascade style +all+.
48
+ add_dependent_attribute(:specimen_event_parameters, :disjoint)
49
+
52
50
  set_attribute_inverse(:parent_specimen, :child_specimens)
53
51
 
54
- add_dependent_attribute(:child_specimens, :unfetched, :no_cascade_update_to_create)
52
+ # @quirk caTissue A Specimen update cascades to a child specimen, but the update is not reflected
53
+ # in the caTissue updateObject result. Work-around is to fetch the updated child from the
54
+ # database to ensure that the database content reflects the intended update argument.
55
+ #
56
+ # The +:no_cascade_update_to_create+ flag is set since child_specimens has cascade style +all+.
57
+ add_dependent_attribute(:child_specimens, :unfetched, :fetch_saved, :no_cascade_update_to_create)
55
58
 
59
+ # The specimen_class attribute constants.
56
60
  class SpecimenClass
57
61
  TISSUE = 'Tissue'
58
62
  FLUID = 'Fluid'
59
63
  MOLECULAR = 'Molecular'
60
64
  CELL = 'Cell'
61
65
 
62
- EXTENT = Set.new([TISSUE, FLUID, MOLECULAR, CELL])
63
-
66
+ # The standard units used for each specimen class.
64
67
  UNIT_HASH = {TISSUE => 'gm', FLUID => 'ml', MOLECULAR => 'ug'}
65
68
 
66
- # @return whether the value is an accepted tissue class value
69
+ # @return [Boolean] whether the value is an accepted tissue class value
67
70
  def self.include?(value)
68
71
  EXTENT.include?(value)
69
72
  end
73
+
74
+ private
75
+
76
+ EXTENT = Set.new([TISSUE, FLUID, MOLECULAR, CELL])
70
77
  end
71
78
 
72
79
  # Initializes this AbstractSpecimen. The default +specimen_class+ is inferred from this
@@ -76,33 +83,33 @@ module CaTissue
76
83
  self.specimen_class ||= infer_specimen_class(self.class)
77
84
  end
78
85
 
79
- # @return whether this specimen is derived from a parent specimen
86
+ # @return [Boolean] whether this specimen is derived from a parent specimen
80
87
  def derived?
81
- not parent.nil?
88
+ !!parent
82
89
  end
83
90
 
84
- # @return whether this specimen is an aliquot
91
+ # @return [Boolean] whether this specimen is an aliquot
85
92
  def aliquot?
86
93
  lineage ||= default_lineage
87
94
  lineage == 'Aliquot'
88
95
  end
89
96
 
90
- # @return this specimen's aliquots
97
+ # @return [<AbstractSpecimen>] this specimen's aliquots
91
98
  def aliquots
92
99
  children.filter { |child| child.aliquot? }
93
100
  end
94
101
 
95
- # @return whether this specimen's type is 'Fresh Tissue'
102
+ # @return [Boolean] whether this specimen's type is 'Fresh Tissue'
96
103
  def fresh?
97
104
  specimen_type == 'Fresh Tissue'
98
105
  end
99
106
 
100
- # @return whether this specimen's type starts with 'Fixed'
107
+ # @return [Boolean] whether this specimen's type starts with 'Fixed'
101
108
  def fixed?
102
109
  specimen_type =~ /^Fixed/
103
110
  end
104
111
 
105
- # @return whether this specimen's type starts with 'Frozen'
112
+ # @return [Boolean] whether this specimen's type starts with 'Frozen'
106
113
  def frozen?
107
114
  specimen_type =~ /^Frozen/
108
115
  end
@@ -119,11 +126,12 @@ module CaTissue
119
126
  SpecimenClass::UNIT_HASH[self.specimen_class]
120
127
  end
121
128
 
122
- # Derives a specimen from this specimen. The params are described in {Specimen#create_specimen},
123
- # with one addition: an optional :count, the optional number of specimens to derive.
129
+ # Derives a new specimen from this specimen. The options are described in
130
+ # {Specimen.create_specimen}, with one addition:
131
+ # * +:count+(+Integer+) - the optional number of specimens to derive
124
132
  #
125
- # If the :count parameter is greater than one and the :specimen_class,
126
- # :specimen_type and :specimen_characteristics parameters are not set to values
133
+ # If the +:count+ option is greater than one and the +:specimen_class+,
134
+ # +:specimen_type+ and +:specimen_characteristics+ options are not set to values
127
135
  # which differ from the respective values for this Specimen, then the specimen is
128
136
  # aliquoted, otherwise the derived specimens are created independently, e.g.:
129
137
  # spc = Specimen.create_specimen(:specimen_class => :tissue, :specimen_type => :frozen)
@@ -144,50 +152,52 @@ module CaTissue
144
152
  #
145
153
  # The default derived specimen label is _label_+_+_n_, where _label_ is this specimen's
146
154
  # label and _n_ is this specimen's child count after including the new derived specimen,
147
- # e.g. 3090_3 for the third child in parent specimen with label 3090.
155
+ # e.g. +3090_3+ for the third child in the parent specimen with label +3090+.
148
156
  #
149
- # @return the new derived specimen if _count_ is one, otherwise an Array of _count_ derived specimens
150
- # @raise [ValidationError] if an aliquoted parent available quantity is not greater than zero
157
+ # @param [{Symbol => Object}, nil] opts the attribute => value hash
158
+ # @return [AbstractSpecimen, <AbstractSpecimen>] the new derived specimen if the +:count+ option
159
+ # is missing or one, otherwise an Array of _count_ derived specimens
160
+ # @raise [Jinx::ValidationError] if an aliquoted parent available quantity is not greater than zero
151
161
  # or the derived specimen quantities exceed the parent available quantity
152
- def derive(params={})
162
+ def derive(opts=Hash::EMPTY_HASH)
153
163
  # add defaults
154
164
  add_defaults if specimen_class.nil?
155
- # copy the parameters
156
- params = params.dup
165
+ # copy the option hash
166
+ opts = opts.dup
157
167
  # standardize the requirement param, if any
158
- rqmt = params.delete(:requirement)
159
- params[:specimen_requirement] ||= rqmt if rqmt
168
+ rqmt = opts.delete(:requirement)
169
+ opts[:specimen_requirement] ||= rqmt if rqmt
160
170
  # the default specimen parameters
161
- unless params.has_key?(:specimen_requirement) then
162
- params[:specimen_class] ||= self.specimen_class ||= infer_specimen_class
163
- params[:specimen_type] ||= self.specimen_type
171
+ unless opts.has_key?(:specimen_requirement) then
172
+ opts[:specimen_class] ||= self.specimen_class ||= infer_specimen_class
173
+ opts[:specimen_type] ||= self.specimen_type
164
174
  end
165
- unless Class === params[:specimen_class] then
166
- params[:specimen_class] = infer_class(params)
175
+ unless Class === opts[:specimen_class] then
176
+ opts[:specimen_class] = infer_class(opts)
167
177
  end
168
- count = params.delete(:count)
178
+ count = opts.delete(:count)
169
179
  count ||= 1
170
180
  aliquot_flag = false
171
- if count > 1 and params[:specimen_class] == self.class and params[:specimen_type] == self.specimen_type then
181
+ if count > 1 and opts[:specimen_class] == self.class and opts[:specimen_type] == self.specimen_type then
172
182
  # aliquots share the specimen_characteristics
173
- child_chr = params[:specimen_characteristics] ||= specimen_characteristics
183
+ child_chr = opts[:specimen_characteristics] ||= specimen_characteristics
174
184
  aliquot_flag = child_chr == specimen_characteristics
175
185
  end
176
186
  # set aliquot parameters if necessary
177
- if aliquot_flag then set_aliquot_parameters(params, count) end
187
+ if aliquot_flag then set_aliquot_parameters(opts, count) end
178
188
  # make the derived specimens
179
- count == 1 ? create_derived(params) : Array.new(count) { create_derived(params) }
189
+ count == 1 ? create_derived(opts) : Array.new(count) { create_derived(opts) }
180
190
  end
181
191
 
182
192
  # Returns whether this AbstractSpecimen is minimally consistent with the other specimen.
183
- # This method augments the {CaRuby::Resource#minimal_match?} with an additional restriction
193
+ # This method augments the +Jinx::Resource.minimal_match?+ with an additional restriction
184
194
  # that the other specimen is the same type as this specimen and
185
195
  # is a tolerant match on specimen class, specimen type and pathological status.
186
196
  # A _tolerant_ match condition holds if the other attribute value is equal to this
187
197
  # AbstractSpecimen's attribute value or the other value is the default 'Not Specified'.
188
198
  #
189
- # @param (see CaRuby::Resource#minimal_match?)
190
- # @return (see CaRuby::Resource#minimal_match?)
199
+ # @param (see Jinx::Resource#minimal_match?)
200
+ # @return (see Jinx::Resource#minimal_match?)
191
201
  def minimal_match?(other)
192
202
  super and tolerant_match?(other, TOLERANT_MATCH_ATTRS)
193
203
  end
@@ -206,12 +216,12 @@ module CaTissue
206
216
  # @param [Integer] count the number of aliquots
207
217
  def set_aliquot_parameters(params, count); end
208
218
 
209
- # Overrides {CaRuby::Resource#each_defaults_dependent} to visit the {CaTissue::SpecimenCharacteristics}.
219
+ # Overrides +Jinx::Resource.each_defaultable_reference} to visit the {CaTissue::SpecimenCharacteristics+.
210
220
  # The characteristics are not dependent since they can be shared among aliquots.
211
221
  # However, the defaults should be added to them. Do so here.
212
222
  #
213
- # @yield (see CaRuby::Resource#each_defaults_dependent)
214
- def each_defaults_dependent
223
+ # @yield (see Jinx::Resource#each_defaultable_reference)
224
+ def each_defaultable_reference
215
225
  super { |dep| yield dep }
216
226
  yield characteristics if characteristics
217
227
  end
@@ -228,11 +238,11 @@ module CaTissue
228
238
  self.characteristics ||= default_characteristics
229
239
  end
230
240
 
231
- # Returns the Class from the given params hash.If the :specimen_class parameter
241
+ # Returns the Class from the given params hash.If the +:specimen_class+ parameter
232
242
  # is set to a Class, then this method returns that Class. Otherwise, if the parameter is a
233
243
  # String or Symbol, then the Class is formed from the parameter as a prefix and 'Specimen' or
234
244
  # 'SpecimenRequirement' depending on this AbstractSpecimen's subclass. If the
235
- # :specimen_class parameter is missing and there is a :specimen_requirement parameter,
245
+ # :specimen_class parameter is missing and there is a +:specimen_requirement+ parameter,
236
246
  # then the specimen requirement specimen_class attribute value is used.
237
247
  #
238
248
  # @param [{Symbol => Object}] params the specimen attribute => value hash
@@ -251,19 +261,23 @@ module CaTissue
251
261
  CaTissue.const_get(cls_nm)
252
262
  end
253
263
 
254
- # Creates a derived specimen.
264
+ # Creates a derived specimen. The options is an attribute => value hash. The options
265
+ # can also include a +:specimen_requirement+. The non-domain attribute values of the
266
+ # new derived specimen are determined according to the following precedence rule:
267
+ # 1. The attribute => value option.
268
+ # 2. The requirement property value.
269
+ # 3. This specimen's property value.
255
270
  #
256
- # @param [{Symbol => Object}] params the derived specimen attribute => value hash
257
- # @return [Specimen] the derived specimen
258
- def create_derived(params)
271
+ # @param [{Symbol => Object}] opts the derived specimen attribute => value hash
272
+ # @return [AbstractSpecimen] the derived specimen or requirement
273
+ def create_derived(opts)
259
274
  # Merge the non-domain attribute values from this specimen, unless there is a requirement.
260
- # Precedence order is given params highest, requirements next, this specimen lowest
261
- params = value_hash(DERIVED_MERGEABLE_ATTRS).merge!(params) unless params.has_key?(:specimen_requirement)
262
- # copy this specimen's characteristics if not already given in the derived specimen params
263
- params[:specimen_characteristics] ||= default_derived_characteristics
264
- # make the new specimen
265
- spc = Specimen.create_specimen(params)
266
- # set the parent
275
+ opts = value_hash(DERIVED_MERGEABLE_ATTRS).merge!(opts) unless opts.has_key?(:specimen_requirement)
276
+ # Copy this specimen's characteristics, if not already given in the options.
277
+ opts[:specimen_characteristics] ||= default_derived_characteristics
278
+ # Make the new specimen.
279
+ spc = Specimen.create_specimen(opts)
280
+ # The derived specimen's parent is this specimen.
267
281
  spc.parent = self
268
282
  spc
269
283
  end
@@ -274,8 +288,8 @@ module CaTissue
274
288
  # @return [CaTissue::SpecimenCharacteristics, nil] a copy of this Specimen's specimen_characteristics, or nil if none
275
289
  def default_derived_characteristics
276
290
  chrs = specimen_characteristics || return
277
- attrs = chrs.class.nondomain_attributes.reject { |attr| attr == :identifier }
278
- chrs.copy(attrs)
291
+ pas = chrs.class.nondomain_attributes.reject { |pa| pa == :identifier }
292
+ chrs.copy(pas)
279
293
  end
280
294
 
281
295
  # @return a copy of the parent characteristics, if any, or a new SpecimenCharacteristics otherwise
@@ -1,6 +1,4 @@
1
1
  module CaTissue
2
- resource_import Java::edu.wustl.catissuecore.domain.AbstractSpecimenCollectionGroup
3
-
4
2
  class AbstractSpecimenCollectionGroup
5
3
  add_attribute_aliases(:diagnosis => :clinical_diagnosis, :site => :specimen_collection_site, :collection_site => :specimen_collection_site)
6
4
 
@@ -8,14 +6,13 @@ module CaTissue
8
6
 
9
7
  add_mandatory_attributes(:activity_status)
10
8
 
11
- # Overrides {CaRuby::Resource#each_dependent} to exclude Specimens or SpecimenRequirements with a parent,
9
+ # Overrides +Jinx::Resource.each_dependent+ to exclude Specimens or SpecimenRequirements with a parent,
12
10
  # since parent is the immediate Specimen or SpecimenRequirement owner.
13
11
  #
14
- # @yield (see CaRuby::Resource#each_dependent)
15
- # @yieldparam (see CaRuby::Resource#each_dependent)
12
+ # @yield (see Jinx::Resource#each_dependent)
13
+ # @yieldparam (see Jinx::Resource#each_dependent)
16
14
  def each_dependent
17
15
  super { |dep| yield dep unless AbstractSpecimen === dep and dep.parent }
18
16
  end
19
-
20
17
  end
21
18
  end
@@ -1,6 +1,4 @@
1
1
  module CaTissue
2
- resource_import Java::edu.wustl.catissuecore.domain.Address
3
-
4
2
  class Address
5
3
  # Sets this Address's zip_code to value. The value argument can be nil, a String or an Integer.
6
4
  def zip_code=(value)
@@ -1,7 +1,4 @@
1
1
  module CaTissue
2
- # import the Java class
3
- resource_import Java::edu.wustl.catissuecore.domain.CancerResearchGroup
4
-
5
2
  # The CancerResearchGroup domain class.
6
3
  class CancerResearchGroup
7
4
  set_secondary_key_attributes(:name)
@@ -1,8 +1,6 @@
1
- require 'caruby/util/coordinate'
1
+ require 'caruby/helpers/coordinate'
2
2
 
3
3
  module CaTissue
4
- resource_import Java::edu.wustl.catissuecore.domain.Capacity
5
-
6
4
  class Capacity
7
5
  # Sets the first dimension to the specified value. If value is nil, then the dimension is set to default one.
8
6
  def one_dimension_capacity=(value)
@@ -24,7 +22,7 @@ module CaTissue
24
22
 
25
23
  add_mandatory_attributes(:one_dimension_capacity, :two_dimension_capacity)
26
24
 
27
- # Returns the read-only Coordinate with this Capacity's #rows and {#columns}.
25
+ # Returns the read-only Coordinate with this capacity's rows and columns.
28
26
  def bounds
29
27
  @bounds ||= Coordinate.new(columns, rows)
30
28
  end
@@ -1,7 +1,4 @@
1
1
  module CaTissue
2
- # import the Java class
3
- resource_import Java::edu.wustl.catissuecore.domain.CheckInCheckOutEventParameter
4
-
5
2
  class CheckInCheckOutEventParameter
6
3
  # The check-in/check-out status permissible values.
7
4
  module Status
@@ -1,17 +1,12 @@
1
- require 'catissue/util/collectible_event_parameters'
2
- require 'caruby/util/validation'
1
+ require 'catissue/helpers/collectible_event_parameters'
3
2
 
4
3
  module CaTissue
5
- # import the Java class
6
- resource_import Java::edu.wustl.catissuecore.domain.CollectionEventParameters
7
-
8
4
  class CollectionEventParameters
9
5
  include CollectibleEventParameters
10
6
 
11
7
  add_attribute_defaults(:collection_procedure => 'Not Specified', :container => 'Not Specified')
12
8
 
13
9
  # An auto-generated CEP must fetch the user.
14
- qualify_attribute(:user, :saved_fetch)
15
-
10
+ qualify_attribute(:user, :fetch_saved)
16
11
  end
17
12
  end
@@ -1,13 +1,10 @@
1
1
  require 'date'
2
- require 'catissue/domain/hash_code'
2
+ require 'catissue/helpers/hash_code'
3
3
 
4
4
  module CaTissue
5
- # import the Java class
6
- resource_import Java::edu.wustl.catissuecore.domain.CollectionProtocol
7
-
8
5
  # The CollectionProtocol domain class.
9
6
  #
10
- # @quirk caTissue Augment the standard metadata storable reference attributes to work around caTissue Bug #150:
7
+ # @quirk caTissue Augment the standard metadata savable reference attributes to work around caTissue Bug #150:
11
8
  # Create CollectionProtocol in API ignores startDate.
12
9
  class CollectionProtocol
13
10
  include HashCode
@@ -30,15 +27,15 @@ module CaTissue
30
27
 
31
28
  add_dependent_attribute(:consent_tiers)
32
29
 
33
- # @quirk caTissue Augment the standard metadata storable reference attributes to work around caTissue Bug #150:
30
+ # @quirk caTissue Augment the standard metadata savable reference attributes to work around caTissue Bug #150:
34
31
  # Create CollectionProtocol in API ignores startDate.
35
32
  qualify_attribute(:start_date, :update_only)
36
33
 
37
- # @quirk caTissue Augment the standard metadata storable reference attributes to work around caTissue Bug #150:
34
+ # @quirk caTissue Augment the standard metadata savable reference attributes to work around caTissue Bug #150:
38
35
  # Create CollectionProtocol in API ignores startDate.
39
36
  set_attribute_type(:coordinators, CaTissue::User)
40
37
 
41
- # @quirk caTissue Augment the standard metadata storable reference attributes to work around caTissue Bug #150:
38
+ # @quirk caTissue Augment the standard metadata savable reference attributes to work around caTissue Bug #150:
42
39
  # Create CollectionProtocol in API ignores startDate.
43
40
  qualify_attribute(:coordinators, :fetched)
44
41
 
@@ -67,9 +64,9 @@ module CaTissue
67
64
  registrations.detect { |registration| registration.participant == participant }
68
65
  end
69
66
 
70
- # Returns the event in this protocol with the earliest study calendar event point.
71
- def first_event
72
- events.sort_by { |event| event.event_point or CollectionProtocolEvent::DEFAULT_EVENT_POINT }.first
67
+ # Returns this protocol's events sorted by study calendar event point.
68
+ def sorted_events
69
+ events.sort_by { |ev| ev.event_point || CollectionProtocolEvent::DEFAULT_EVENT_POINT }
73
70
  end
74
71
 
75
72
  # Returns the specimens collected from the given participant for this CollectionProtocol,
@@ -83,7 +80,7 @@ module CaTissue
83
80
  # Adds specimens to this protocol. The following parameter options are supported:
84
81
  # * :participant - the Participant from whom the specimen is collected
85
82
  # * :biospecimens - the collected top-level underived specimens
86
- # * additional SCG parameters as described in {SpecimenCollectionGroup#merge}.
83
+ # * additional SCG parameters as described in {CaTissue::SpecimenCollectionGroup#merge_attributes}.
87
84
  #
88
85
  # If the options does not include a +:collection_protocol_event+, then the SCG is assigned
89
86
  # to the first collection event in this protocol.
@@ -98,7 +95,7 @@ module CaTissue
98
95
  #
99
96
  # @param [(<Specimen>, {Symbol => Object})] specimens_and_params the specimens to add followed
100
97
  # by the required parameter hash
101
- # @return [SpecimenCollectionGroup] a new SCG for the given participant containing the specimens
98
+ # @return [CaTissue::SpecimenCollectionGroup] a new SCG for the given participant containing the specimens
102
99
  # @raise [ArgumentError] if the {SpecimenCollectionGroup} does not include all required attributes
103
100
  def add_specimens(*specimens_and_params)
104
101
  params = specimens_and_params.pop
@@ -164,10 +161,8 @@ module CaTissue
164
161
  def add_default_site
165
162
  if coordinators.size == 1 then
166
163
  site = coordinators.first.sites.first
167
- else
168
- site = CaTissue::Site.default_site
169
- site.find unless site.identifier
170
164
  end
165
+ site ||= CaTissue::Site.default_site
171
166
  sites << site
172
167
  end
173
168