caruby-tissue 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/History.txt +11 -7
  2. data/lib/catissue/annotation/annotatable_class.rb +18 -1
  3. data/lib/catissue/annotation/annotation.rb +5 -0
  4. data/lib/catissue/annotation/annotation_class.rb +15 -3
  5. data/lib/catissue/annotation/proxy_class.rb +2 -1
  6. data/lib/catissue/database/annotation/annotation_service.rb +13 -6
  7. data/lib/catissue/database/annotation/annotator.rb +3 -1
  8. data/lib/catissue/database/annotation/entity_facade.rb +21 -29
  9. data/lib/catissue/database/annotation/integration_service.rb +6 -4
  10. data/lib/catissue/database.rb +2 -2
  11. data/lib/catissue/domain/abstract_domain_object.rb +1 -1
  12. data/lib/catissue/domain/abstract_position.rb +1 -1
  13. data/lib/catissue/domain/abstract_specimen.rb +1 -1
  14. data/lib/catissue/domain/abstract_specimen_collection_group.rb +1 -1
  15. data/lib/catissue/domain/address.rb +1 -1
  16. data/lib/catissue/domain/cancer_research_group.rb +1 -1
  17. data/lib/catissue/domain/capacity.rb +1 -1
  18. data/lib/catissue/domain/check_in_check_out_event_parameter.rb +1 -1
  19. data/lib/catissue/domain/collection_event_parameters.rb +1 -1
  20. data/lib/catissue/domain/collection_protocol.rb +1 -1
  21. data/lib/catissue/domain/collection_protocol_event.rb +1 -1
  22. data/lib/catissue/domain/collection_protocol_registration.rb +1 -1
  23. data/lib/catissue/domain/consent_tier_response.rb +1 -1
  24. data/lib/catissue/domain/consent_tier_status.rb +1 -1
  25. data/lib/catissue/domain/container.rb +1 -1
  26. data/lib/catissue/domain/container_position.rb +4 -2
  27. data/lib/catissue/domain/container_type.rb +1 -1
  28. data/lib/catissue/domain/department.rb +1 -1
  29. data/lib/catissue/domain/disposal_event_parameters.rb +1 -1
  30. data/lib/catissue/domain/embedded_event_parameters.rb +1 -1
  31. data/lib/catissue/domain/external_identifier.rb +1 -1
  32. data/lib/catissue/domain/frozen_event_parameters.rb +1 -1
  33. data/lib/catissue/domain/institution.rb +1 -1
  34. data/lib/catissue/domain/new_specimen_array_order_item.rb +1 -1
  35. data/lib/catissue/domain/order_details.rb +1 -1
  36. data/lib/catissue/domain/participant.rb +2 -2
  37. data/lib/catissue/domain/participant_medical_identifier.rb +1 -1
  38. data/lib/catissue/domain/password.rb +1 -1
  39. data/lib/catissue/domain/race.rb +1 -1
  40. data/lib/catissue/domain/received_event_parameters.rb +1 -1
  41. data/lib/catissue/domain/site.rb +1 -1
  42. data/lib/catissue/domain/specimen.rb +49 -40
  43. data/lib/catissue/domain/specimen_array.rb +1 -1
  44. data/lib/catissue/domain/specimen_array_content.rb +1 -1
  45. data/lib/catissue/domain/specimen_array_type.rb +1 -1
  46. data/lib/catissue/domain/specimen_characteristics.rb +1 -1
  47. data/lib/catissue/domain/specimen_collection_group.rb +7 -7
  48. data/lib/catissue/domain/specimen_event_parameters.rb +6 -6
  49. data/lib/catissue/domain/specimen_position.rb +1 -1
  50. data/lib/catissue/domain/specimen_protocol.rb +1 -1
  51. data/lib/catissue/domain/specimen_requirement.rb +13 -13
  52. data/lib/catissue/domain/storage_container.rb +1 -1
  53. data/lib/catissue/domain/storage_type.rb +1 -1
  54. data/lib/catissue/domain/transfer_event_parameters.rb +1 -1
  55. data/lib/catissue/domain/user.rb +1 -1
  56. data/lib/catissue/migration/migrator.rb +2 -2
  57. data/lib/catissue/version.rb +1 -1
  58. data/test/lib/catissue/domain/specimen_test.rb +241 -242
  59. data/test/lib/catissue/test_case.rb +11 -7
  60. metadata +3 -4
  61. data/examples/galena/lib/galena/cli/seed.rb +0 -22
data/History.txt CHANGED
@@ -1,28 +1,32 @@
1
1
  === 1.2.1 / 2010-11-23
2
2
 
3
- * Initial public release
3
+ * Initial public release.
4
4
 
5
5
  === 1.2.2 / 2010-11-30
6
6
 
7
- * Enable Galena example
7
+ * Enable Galena example.
8
8
 
9
9
  === 1.2.3 / 2011-02-18
10
10
 
11
- * Support Dynamic Extensions
11
+ * Support Dynamic Extensions.
12
12
 
13
13
  === 1.3.1 / 2011-02-18
14
14
 
15
- * Full PCBIN DE support
15
+ * Full PCBIN DE support.
16
16
 
17
17
  === 1.3.2 / 2011-02-25
18
18
 
19
- * Minor migration bug fixes
19
+ * Minor migration bug fixes.
20
20
 
21
21
  === 1.3.3 / 2011-02-26
22
22
 
23
- * JRuby 1.5 upgrade
23
+ * JRuby 1.5 upgrade.
24
24
 
25
25
  === 1.3.4 / 2011-02-26
26
26
 
27
- * Use caruby-core JRuby 1.5 bug work-around
27
+ * Use caruby-core JRuby 1.5 bug work-around.
28
+
29
+ === 1.3.5 / 2011-03-04
30
+
31
+ * Support annotation migration.
28
32
 
@@ -13,7 +13,11 @@ module CaTissue
13
13
  def self.extended(klass)
14
14
  super
15
15
  # the annotation name => spec hash
16
- klass.class_eval { extend Forwardable; @ann_spec_hash = {} }
16
+ klass.class_eval do
17
+ extend Forwardable
18
+ @ann_spec_hash = {}
19
+ @local_ann_attrs = []
20
+ end
17
21
  end
18
22
 
19
23
  # @return [Integer, nil] this class's entity id, if it exists, otherwise the superclass effective entity id
@@ -79,6 +83,16 @@ module CaTissue
79
83
  end
80
84
  end
81
85
 
86
+ def printable_attributes
87
+ @prbl_attrs ||= super.union(annotation_attributes)
88
+ end
89
+
90
+ def annotation_attributes
91
+ @ann_attrs ||= append_ancestor_enum(@local_ann_attrs) do |sc|
92
+ sc.annotation_attributes if sc < Annotatable
93
+ end
94
+ end
95
+
82
96
  protected
83
97
 
84
98
  # @return [<AnnotationModule>] the annotation modules in the class hierarchy
@@ -250,6 +264,9 @@ module CaTissue
250
264
 
251
265
  # the annotation is a dependent
252
266
  add_dependent_attribute(attribute, :logical)
267
+
268
+ # add the attribute to the local collection
269
+ @local_ann_attrs << attribute
253
270
  end
254
271
  end
255
272
  end
@@ -31,6 +31,11 @@ module CaTissue
31
31
 
32
32
  # If there is no conventional owner, then try the hook.
33
33
  #
34
+ # caTissue alert - DE annotations have a physical dependency ownership model that is at odds
35
+ # with the logical model. An annotation does not directly reference its static hook owner
36
+ # instance. Rather, it references the hook proxy which stands in for the hook entity in the
37
+ # annotation package.
38
+ #
34
39
  # @return the {CaRuby::Resource#owner} or the {#hook}
35
40
  def owner
36
41
  super or hook
@@ -49,6 +49,16 @@ module CaTissue
49
49
  dependent_attributes.each { |attr| save_dependent_attribute(annotation, attr) }
50
50
  end
51
51
 
52
+ # @return [Boolean] whether this annotation refers to a {#primary?} annotation
53
+ def secondary?
54
+ not @proxy_attribute.nil?
55
+ end
56
+
57
+ # @return [Boolean] whether this annotation is neither a {#primary?} nor a #{secondary} annotation
58
+ def tertiary_annotation
59
+ not (primary? or secondary?)
60
+ end
61
+
52
62
  # Detects or creates the proxy attribute that references the given proxy class.
53
63
  # if this is a primary_entity annotation class which does not
54
64
  # have a caTissue proxy property.
@@ -62,7 +72,9 @@ module CaTissue
62
72
  # set the hook
63
73
  self.hook = proxy.hook
64
74
  # primary superclass gets a proxy as well
65
- if superclass < Annotation and superclass.primary? then superclass.proxy = proxy end
75
+ if superclass < Annotation then
76
+ superclass.ensure_primary_has_proxy(proxy)
77
+ end
66
78
  end
67
79
 
68
80
  # @param [Class] klass the hook class for this primary annotation
@@ -184,7 +196,7 @@ module CaTissue
184
196
 
185
197
  def obtain_proxy_attribute(proxy)
186
198
  # parent proxy is reserved for RadiationTherapy use case described in ParticipantTest.
187
- # TODO - either support this use case of delete the parent proxy call
199
+ # TODO - either support this use case or delete the parent proxy call
188
200
  detect_proxy_attribute(proxy) or create_proxy_attribute(proxy) or parent_proxy_attribute
189
201
  end
190
202
 
@@ -213,7 +225,7 @@ module CaTissue
213
225
  def create_proxy_attribute(proxy)
214
226
  # the proxy attribute symbol
215
227
  attr = proxy.name.demodulize.underscore.to_sym
216
- logger.debug { "Creating primary annotation #{qp} proxy attribute #{attr}..." }
228
+ logger.debug { "Creating primary annotation #{qp} proxy #{proxy} attribute #{attr}..." }
217
229
  # make the attribute
218
230
  attr_accessor(attr)
219
231
  # Add the attribute. Setting the saved flag ensures that the save template passed to
@@ -37,10 +37,11 @@ module CaTissue
37
37
 
38
38
  # Adds each proxy => annotation reference as a dependent attribute.
39
39
  def add_annotation_dependents
40
+ # first add the direct dependents
40
41
  annotation_attributes.each_metadata do |attr_md|
41
42
  attr_md.type.add_dependent_attributes
42
- attr_md.type.proxy = self
43
43
  end
44
+ # now add the recursive indirect dependents
44
45
  annotation_attributes.each_metadata do |attr_md|
45
46
  attr_md.type.add_dependent_attribute_closure
46
47
  end
@@ -37,21 +37,28 @@ module CaTissue
37
37
  # @return [Annotation] the annotation
38
38
  def create(annotation)
39
39
  logger.debug { "Creating annotation #{annotation.qp}..." }
40
- # get the hook
40
+ time { create_annotation(annotation) }
41
+ logger.debug { "Created annotation #{annotation}." }
42
+ annotation
43
+ end
44
+
45
+ private
46
+
47
+ # @param [Annotation] (see #create)
48
+ def create_annotation(annotation)
49
+ # get the hook
41
50
  hook = annotation.hook
42
51
  # If no hook, then this is not a primary annotation. In that case, find a referenced
43
52
  # primary annotation.
53
+ # If no hook, then this is not a primary annotation. In that case, find a referenced
54
+ # primary annotation.
44
55
  if hook then
45
- time { create_primary_annotation(annotation, hook) }
56
+ create_primary_annotation(annotation, hook)
46
57
  else
47
58
  create_secondary_annotation(annotation)
48
59
  end
49
- logger.debug { "Created annotation #{annotation}." }
50
- annotation
51
60
  end
52
61
 
53
- private
54
-
55
62
  # @param annotation (see #create)
56
63
  # @param [Annotable] the annotatable object referenced by this annotation
57
64
  def create_primary_annotation(annotation, hook)
@@ -19,7 +19,9 @@ module CaTissue
19
19
  # @param [String] name the service name
20
20
  # @return [Annotation::AnnotationService] the annotation service
21
21
  def create_annotation_service(name)
22
- Annotation::AnnotationService.new(@database, name, :integration_service => @integration_service)
22
+ host = CaTissue.access_properties[:host]
23
+ port = CaTissue.access_properties[:port]
24
+ Annotation::AnnotationService.new(@database, name, :host => host, :port => port, :integration_service => @integration_service)
23
25
  end
24
26
  end
25
27
  end
@@ -5,25 +5,16 @@ require 'catissue/database/annotation/id_generator'
5
5
 
6
6
  module CaTissue
7
7
  module Annotation
8
- # Import this EntityManager dependency before EntityManager.
9
- java_import('edu.wustl.common.security.exceptions.UserNotAuthorizedException')
10
-
11
- # Import the caTissue Java EntityManager.
12
- java_import('edu.common.dynamicextensions.entitymanager.EntityManager')
13
-
14
- # EntityFacade is the caRuby interface to the caTissue EntityManager. EntityManager is
8
+ # EntityFacade is the caRuby substitue for the broken caTissue EntityManager. EntityManager is
15
9
  # the caTissue singleton Winnebago object for doing lots of things with dynamic extensions.
16
10
  class EntityFacade
17
11
  include Singleton
18
12
 
19
13
  private
20
14
 
21
- # Initializes the caTissue EntityManager, an id generator and a SQL executor. The id
22
- # generator and executor are used for the caTissue bug work-arounds described in the
23
- # method docs and {IdGenerator}.
15
+ # Initializes the id generator and a SQL executor. The id generator and executor are
16
+ # used for the caTissue bug work-arounds described in the method docs and {IdGenerator}.
24
17
  def initialize
25
- # the encapsulated caTissue singleton
26
- @emgr = EntityManager.instance
27
18
  # the work-around id generator
28
19
  @idgen = IdGenerator.new
29
20
  # a general-purpose SQL executor for calling the work-arounds
@@ -72,7 +63,11 @@ module CaTissue
72
63
  # @param [Class] klass the {Annotatable} class
73
64
  # @return [Integer] the class entity id
74
65
  def hook_entity_id(klass)
75
- entity_id_for_class_designator(klass.java_class.name)
66
+ result = @executor.execute { |dbh| dbh.select_one(HOOK_ENTITY_ID_SQL, klass.java_class.name) }
67
+ if result.nil? then raise AnnotationError.new("Entity id not found for static hook class #{klass.qp}") end
68
+ eid = result[0].to_i
69
+ logger.debug { "Static hook class #{klass.qp} has entity id #{eid}." }
70
+ eid
76
71
  end
77
72
 
78
73
  # caTissue alert - call into caTissue to get entity id doesn't work for non-primary object.
@@ -116,7 +111,7 @@ module CaTissue
116
111
  # @return [Integer, nil] the parent entity id, if any
117
112
  def parent_entity_id(eid)
118
113
  result = @executor.execute { |dbh| dbh.select_one(PARENT_ENTITY_ID_SQL, eid) }
119
- result[0] if result
114
+ result[0].to_i if result and result[0]
120
115
  end
121
116
 
122
117
  # Obtains the undocumented caTisue container id for the given primary entity id.
@@ -138,10 +133,10 @@ module CaTissue
138
133
  # EntityManager.instance.get_container_id_for_entity(eid)
139
134
  # Work-around caTissue bug with direct query.
140
135
  result = @executor.execute { |dbh| dbh.select_one(CTR_ID_SQL, eid) }
141
- cid = result[0].to_i if result
142
- if cid.nil? then
136
+ if result.nil? then
143
137
  raise AnnotationError.new("Dynamic extension container id not found for annotation #{annotation} with entity id #{eid}")
144
138
  end
139
+ cid = result[0].to_i
145
140
  logger.debug { "Annotation with entity id #{eid} has container id #{cid}." }
146
141
  cid
147
142
  end
@@ -163,7 +158,7 @@ module CaTissue
163
158
  pkg, cls_nm = klass.java_class.name.split('.')
164
159
  # Dive into some obscure SQL
165
160
  result = @executor.execute { |dbh| dbh.select_one(CTR_ENTITY_ID_SQL, pkg, cls_nm) }
166
- result[0] if result
161
+ result[0].to_i if result
167
162
  end
168
163
 
169
164
  # @param (see #primary_entity_id)
@@ -213,20 +208,17 @@ module CaTissue
213
208
  logger.debug { "Attempting to find entity id #{eid} #{role} associated entity id using variant #{alt}..." }
214
209
  result = @executor.execute { |dbh| dbh.select_one(ASSN_ENTITY_ID_SQL, eid, alt) }
215
210
  end
216
- if result.nil? then
217
- logger.debug { "Entity id #{eid} is not directly associated with #{role}." }
218
- end
219
- result[0] if result
220
- end
221
-
222
- # @param [String] designator the class name, demodulized in the case of an annotation entity
223
- # @return [Integer] the caTissue entity id for the given class name
224
- # @raise [CaRuby::DatabaseError] if the DE entity id is not found for the given designator
225
- def entity_id_for_class_designator(designator)
226
- @emgr.getEntityId(designator) or
227
- raise CaRuby::DatabaseError.new("Dynamic extension entity id not found for #{designator}")
211
+ if result.nil? then logger.debug { "Entity id #{eid} is not directly associated with #{role}." } end
212
+ result[0].to_i if result
228
213
  end
229
214
 
215
+ # The SQL to find an entity id for a primary entity.
216
+ HOOK_ENTITY_ID_SQL = <<EOS
217
+ select IDENTIFIER
218
+ from DYEXTN_ABSTRACT_METADATA
219
+ where NAME = ?
220
+ EOS
221
+
230
222
  # The SQL to find an entity id for a primary entity.
231
223
  CTR_ENTITY_ID_SQL = <<EOS
232
224
  select ctr.ABSTRACT_ENTITY_ID
@@ -6,15 +6,17 @@ module CaTissue
6
6
  class IntegrationService < CaRuby::PersistenceService
7
7
  SERVICE_NAME = 'deintegration'
8
8
 
9
- java_import('deintegration.EntityMap')
9
+ java_import 'deintegration.EntityMap'
10
10
 
11
- java_import('deintegration.EntityMapRecord')
11
+ java_import 'deintegration.EntityMapRecord'
12
12
 
13
- java_import('deintegration.FormContext')
13
+ java_import 'deintegration.FormContext'
14
14
 
15
15
  # @param [EntityFacade] the global entity manager
16
16
  def initialize
17
- super(SERVICE_NAME)
17
+ host = CaTissue.access_properties[:host]
18
+ port = CaTissue.access_properties[:port]
19
+ super(SERVICE_NAME, :host => host, :port => port)
18
20
  # SQL executor to handle caTissue DE API bug work-around
19
21
  @executor = CaRuby::SQLExecutor.new(CaTissue.access_properties)
20
22
  end
@@ -313,7 +313,7 @@ module CaTissue
313
313
  end
314
314
  logger.debug { "Work around caTissue Bug #164 by setting the #{obj.qp} update template #{template.qp} external_identifiers to nil." }
315
315
  template.external_identifiers = nil
316
- elsif Annotation === obj and obj.class.proxy_attribute then
316
+ elsif Annotation === obj and obj.class.secondary? then
317
317
  copy_annotation_proxy_owner_to_template(obj, template)
318
318
  end
319
319
  super
@@ -395,7 +395,7 @@ module CaTissue
395
395
  specimen.is_available = true
396
396
  oiqty = specimen.initial_quantity
397
397
  oaqty = specimen.available_quantity
398
- ostatus = specimen.activity_status
398
+ ostatus = specimen.activity_status
399
399
  specimen.initial_quantity = 1.0
400
400
  specimen.available_quantity = 1.0
401
401
  specimen.activity_status = 'Active'
@@ -1,6 +1,6 @@
1
1
  module CaTissue
2
2
  # explicitly import AbstractDomainObject, since it is not in the default CaTissue package and therefore can't be auto-imported
3
- java_import('edu.wustl.common.domain.AbstractDomainObject')
3
+ java_import Java::edu.wustl.common.domain.AbstractDomainObject
4
4
 
5
5
  class AbstractDomainObject
6
6
  include Resource
@@ -1,7 +1,7 @@
1
1
  require 'catissue/util/position'
2
2
 
3
3
  module CaTissue
4
- java_import('edu.wustl.catissuecore.domain.AbstractPosition')
4
+ java_import Java::edu.wustl.catissuecore.domain.AbstractPosition
5
5
 
6
6
  # The +caTissue+ AbstractPosition class is augmented with a comparison operator and the
7
7
  # zero-based +row+ and +column+ methods wrapping the corresponding one-based dimension
@@ -2,7 +2,7 @@ require 'set'
2
2
  require 'caruby/util/inflector'
3
3
 
4
4
  module CaTissue
5
- java_import('edu.wustl.catissuecore.domain.AbstractSpecimen')
5
+ java_import Java::edu.wustl.catissuecore.domain.AbstractSpecimen
6
6
 
7
7
  class AbstractSpecimen
8
8
  include Resource
@@ -1,5 +1,5 @@
1
1
  module CaTissue
2
- java_import('edu.wustl.catissuecore.domain.AbstractSpecimenCollectionGroup')
2
+ java_import Java::edu.wustl.catissuecore.domain.AbstractSpecimenCollectionGroup
3
3
 
4
4
  class AbstractSpecimenCollectionGroup
5
5
  include Resource
@@ -1,5 +1,5 @@
1
1
  module CaTissue
2
- java_import('edu.wustl.catissuecore.domain.Address')
2
+ java_import Java::edu.wustl.catissuecore.domain.Address
3
3
 
4
4
  class Address
5
5
  include Resource
@@ -1,6 +1,6 @@
1
1
  module CaTissue
2
2
  # import the Java class
3
- java_import('edu.wustl.catissuecore.domain.CancerResearchGroup')
3
+ java_import Java::edu.wustl.catissuecore.domain.CancerResearchGroup
4
4
 
5
5
  # The CancerResearchGroup domain class.
6
6
  class CancerResearchGroup
@@ -1,7 +1,7 @@
1
1
  require 'caruby/util/coordinate'
2
2
 
3
3
  module CaTissue
4
- java_import('edu.wustl.catissuecore.domain.Capacity')
4
+ java_import Java::edu.wustl.catissuecore.domain.Capacity
5
5
 
6
6
  class Capacity
7
7
  include Resource
@@ -1,6 +1,6 @@
1
1
  module CaTissue
2
2
  # import the Java class
3
- java_import('edu.wustl.catissuecore.domain.CheckInCheckOutEventParameter')
3
+ java_import Java::edu.wustl.catissuecore.domain.CheckInCheckOutEventParameter
4
4
 
5
5
  class CheckInCheckOutEventParameter
6
6
  include Resource
@@ -2,7 +2,7 @@ require 'catissue/domain/scg_event_parameters'
2
2
 
3
3
  module CaTissue
4
4
  # import the Java class
5
- java_import('edu.wustl.catissuecore.domain.CollectionEventParameters')
5
+ java_import Java::edu.wustl.catissuecore.domain.CollectionEventParameters
6
6
 
7
7
  class CollectionEventParameters
8
8
  include Resource, SCGEventParameters
@@ -3,7 +3,7 @@ require 'catissue/domain/hash_code'
3
3
 
4
4
  module CaTissue
5
5
  # import the Java class
6
- java_import('edu.wustl.catissuecore.domain.CollectionProtocol')
6
+ java_import Java::edu.wustl.catissuecore.domain.CollectionProtocol
7
7
 
8
8
  # The CollectionProtocol domain class.
9
9
  class CollectionProtocol
@@ -3,7 +3,7 @@ require 'catissue/domain/hash_code'
3
3
 
4
4
  module CaTissue
5
5
  # import the Java class
6
- java_import('edu.wustl.catissuecore.domain.CollectionProtocolEvent')
6
+ java_import Java::edu.wustl.catissuecore.domain.CollectionProtocolEvent
7
7
 
8
8
  # The CollectionProtocolRegistration domain class.
9
9
  class CollectionProtocolEvent