lib/catissue/database.rb
def save_changed_dependents(obj)
      if CaTissue::Specimen === obj then
        dsp = obj.specimen_events.detect { |ep| CaTissue::DisposalEventParameters === ep }
      end
      if dsp then
        obj.specimen_events.delete(dsp)
        logger.debug { "Work around a caTissue #{obj.qp} event parameters save order dependency by deferring the #{dsp.qp} save..." }
        obj.specimen_events.delete(dsp)
      end
      
      # Delegate to the standard save_changed_dependents.
      begin
        super
      ensure
        obj.specimen_events << dsp if dsp
      end
      
      # Save the deferred disposal, if any.
      if dsp then
        logger.debug { "Creating deferred #{obj.qp} dependent #{dsp.qp}..." }
        save_dependent_if_changed(obj, :specimen_events, dsp)
        if obj.activity_status != 'Closed' then
          logger.debug { "Refetching the disposed #{obj.qp} to reflect the modified activity status..." }
          obj.activity_status = nil
          obj.find
        end
      end
    end
def save_changed_dependents(obj)
      if CaTissue::Specimen === obj then
        dsp = obj.specimen_events.detect { |ep| CaTissue::DisposalEventParameters === ep }
      end
      if dsp then
        obj.specimen_events.delete(dsp)
        logger.debug { "Work around a caTissue #{obj.qp} event parameters save order dependency by deferring the #{dsp.qp} save..." }
        obj.specimen_events.delete(dsp)
      end
      
      # Delegate to the standard save_changed_dependents.
      begin
        super
      ensure
        obj.specimen_events << dsp if dsp
      end
      
      # Save the deferred disposal, if any.
      if dsp then
        logger.debug { "Creating deferred #{obj.qp} dependent #{dsp.qp}..." }
        save_dependent_if_changed(obj, :specimen_events, dsp)
        if obj.activity_status != 'Closed' then
          logger.debug { "Refetching the disposed #{obj.qp} to reflect the modified activity status..." }
          obj.activity_status = nil
          obj.find
        end
      end
    end
def save_changed_dependents ( obj ) if CaTissue :: Specimen === obj then dsp = obj . specimen_events . detect { | ep | CaTissue :: DisposalEventParameters === ep } end if dsp then obj . specimen_events . delete ( dsp ) logger . debug { "Work around a caTissue #{obj.qp} event parameters save order dependency by deferring the #{dsp.qp} save..." } obj . specimen_events . delete ( dsp ) end # Delegate to the standard save_changed_dependents. begin super ensure obj . specimen_events << dsp if dsp end # Save the deferred disposal, if any. if dsp then logger . debug { "Creating deferred #{obj.qp} dependent #{dsp.qp}..." } save_dependent_if_changed ( obj , :specimen_events , dsp ) if obj . activity_status != 'Closed' then logger . debug { "Refetching the disposed #{obj.qp} to reflect the modified activity status..." } obj . activity_status = nil obj . find end end end
Overrides +CaRuby::Database::Writer.save_changed_dependents+ to handle the following anomaly:

 @quirk caTissue DisposalEventParameters must be created after all other Specimen SEPs. This
   use case arises when migrating a source biorepository discarded specimen for archival.

   The process for creating a discarded Specimen is as follows:
   * Create the Specimen with status Active.
   * Create the non-disposal events.
   * Create the DisposalEventParameters.

   {#save_changed_dependents} delegates to this method to handle the latter two steps.

   A DisposalEventParameters cannot be created for a closed Specimen. Conversely, caTissue closes
   the Specimen as a side-effect of creating a DisposalEventParameters. Therefore, even if the
   client submits a closed Specimen for create, this CaTissue::Database must first create the
   Specimen with status Active, then submit the DisposalEventParameters.

   This is a work-around on top of the {#create_unavailable_specimen} work-around. See that method
   for the subtle interaction required between these two work-arounds.

 @param (see CaRuby::Writer#save_dependents)
Overrides + CaRuby :: Database :: Writer . save_changed_dependents + to handle the following anomaly :