lib/catissue/database.rb
def update_object(obj)
      # prep work
      case obj
      when CaTissue::SpecimenCollectionGroup then
        if obj.collection_protocol_registration.nil? then
          # add the extraneous SCG template CPR
          logger.debug { "Work around caTissue bug by fetching extraneous #{obj} CPR..." }
          obj.collection_protocol_registration = fetch_association(obj, :collection_protocol_registration)
        end
        if obj.collection_status.nil? and obj.collection_event_parameters then
          obj.collection_status = 'Complete'
          logger.debug { "Set #{obj} status to Complete since it has collection event parameters." }
        end
      when CaTissue::Specimen then
        prepare_specimen_for_update(obj)
      when CaTissue::StorageContainer then
        if obj.storage_type.nil? then
          logger.debug { "Fetching #{obj} storage type prior to update..." }
          lazy_loader.enable { obj.storage_type }
        end
      end
      
      # Delegate update special cases.
      if CaTissue::User === obj then
        if obj.address.identifier.nil? or obj.address.changed? then
          return update_user_address(obj, obj.address)
        end
      end
      if CaTissue::CollectibleEventParameters === obj then
        if obj.specimen_collection_group then
          return save_collectible_scg_event_parameters(obj)
        elsif obj.specimen then
          return update_from_template(obj)
        end
      elsif CaTissue::SpecimenEventParameters === obj then
        return update_from_template(obj)
      elsif CaTissue::ConsentTierResponse === obj then
        return update_consent_tier_response(obj)
      elsif Annotation === obj then
        raise CaRuby::DatabaseError.new("Annotation update is not supported on #{obj}")
      end
      
      # Delegate to the standard update.
      super
    end
def update_object(obj)
      # prep work
      case obj
      when CaTissue::SpecimenCollectionGroup then
        if obj.collection_protocol_registration.nil? then
          # add the extraneous SCG template CPR
          logger.debug { "Work around caTissue bug by fetching extraneous #{obj} CPR..." }
          obj.collection_protocol_registration = fetch_association(obj, :collection_protocol_registration)
        end
        if obj.collection_status.nil? and obj.collection_event_parameters then
          obj.collection_status = 'Complete'
          logger.debug { "Set #{obj} status to Complete since it has collection event parameters." }
        end
      when CaTissue::Specimen then
        prepare_specimen_for_update(obj)
      when CaTissue::StorageContainer then
        if obj.storage_type.nil? then
          logger.debug { "Fetching #{obj} storage type prior to update..." }
          lazy_loader.enable { obj.storage_type }
        end
      end
      
      # Delegate update special cases.
      if CaTissue::User === obj then
        if obj.address.identifier.nil? or obj.address.changed? then
          return update_user_address(obj, obj.address)
        end
      end
      if CaTissue::CollectibleEventParameters === obj then
        if obj.specimen_collection_group then
          return save_collectible_scg_event_parameters(obj)
        elsif obj.specimen then
          return update_from_template(obj)
        end
      elsif CaTissue::SpecimenEventParameters === obj then
        return update_from_template(obj)
      elsif CaTissue::ConsentTierResponse === obj then
        return update_consent_tier_response(obj)
      elsif Annotation === obj then
        raise CaRuby::DatabaseError.new("Annotation update is not supported on #{obj}")
      end
      
      # Delegate to the standard update.
      super
    end
def update_object ( obj ) # prep work case obj when CaTissue :: SpecimenCollectionGroup then if obj . collection_protocol_registration . nil? then # add the extraneous SCG template CPR logger . debug { "Work around caTissue bug by fetching extraneous #{obj} CPR..." } obj . collection_protocol_registration = fetch_association ( obj , :collection_protocol_registration ) end if obj . collection_status . nil? and obj . collection_event_parameters then obj . collection_status = 'Complete' logger . debug { "Set #{obj} status to Complete since it has collection event parameters." } end when CaTissue :: Specimen then prepare_specimen_for_update ( obj ) when CaTissue :: StorageContainer then if obj . storage_type . nil? then logger . debug { "Fetching #{obj} storage type prior to update..." } lazy_loader . enable { obj . storage_type } end end # Delegate update special cases. if CaTissue :: User === obj then if obj . address . identifier . nil? or obj . address . changed? then return update_user_address ( obj , obj . address ) end end if CaTissue :: CollectibleEventParameters === obj then if obj . specimen_collection_group then return save_collectible_scg_event_parameters ( obj ) elsif obj . specimen then return update_from_template ( obj ) end elsif CaTissue :: SpecimenEventParameters === obj then return update_from_template ( obj ) elsif CaTissue :: ConsentTierResponse === obj then return update_consent_tier_response ( obj ) elsif Annotation === obj then raise CaRuby :: DatabaseError . new ( "Annotation update is not supported on #{obj}" ) end # Delegate to the standard update. super end
@quirk caTissue Bug #135: Update SCG SpecimenEventParameters raises AuditException.
   Work around is to update the SCG instead.

 @quirk caTissue CPR consent tier response update results in 'Access denied' error.
   Work-around is to update the response using a direct SQL call.

 @quirk caTissue A collected Specimen must have a label. The caTissue API does not
   auto-generate a label unless an auto-generator is defined. The work-around is to set
   the label to a unique value when the status is updated to collected.

 @quirk caTissue The label is auto-generated by caTissue when the specimen is created.
   Label creation depends on an auto-generator. Therefore, the specimen must be refetched
   when collected in order to reflect the database label value.

 @quirk caTissue The Specimen label is auto-generated when the collection status is changed
   from Pending to Collected. However, the update argument label is not updated to reflect
   the auto-generated value. Note that the barcode is auto-generated on create, not update.

 @quirk caTissue Updating a User does not cascade update to the address.
   address is cascade none in Hibernate, but is created in caTissue, perhaps by biz logic.
   An address change is ignored by the User update. Since Address cannot be updated
   separately due to a different caTissue bug, the address update must be performed
   by a work-around here.

 @quirk caTissue Specimen update does not cascade to a referenced SpecimenEventParameters.
   Even though the reference property is marked cascade in Hibernate, the update does
   not propagate to the SpecimenEventParameters. Specimen create does cascade. SCG update
   cascades. Certain SpecimenEventParameters subclasses have variant Specimen cascade
   behavior, as described in other quirk documentation. The work-around is to update
   the Specimen SpecimenEventParameters directly rather than delegating the update
   to the Specimen owner.

 @quirk caTissue caTissue Specimen update ignores the available quantity. Unlike the
   auto-generated Specimen update, there is no known work-around

 @param (see CaRuby::Database#update_object)
@quirk caTissue Bug #135 : Update SCG SpecimenEventParameters raises AuditException . Work around is to update the SCG instead .