Class: Frigg::Persister

Inherits:
Valkyrie::Persistence::Fedora::Persister
  • Object
show all
Defined in:
lib/frigg/persister.rb

Overview

Persister for Postgres MetadataAdapter.

Instance Method Summary collapse

Instance Method Details

#save(resource:, external_resource: false, perform_af_validation: false) ⇒ Valkyrie::Resource

Persists a resource within the database

Modified from the upstream to skip previously persisted check

rubocop:disable Lint/UnusedMethodArgument

Parameters:

  • resource (Valkyrie::Resource)

Returns:

  • (Valkyrie::Resource)

    the persisted/updated resource

Raises:

  • (Valkyrie::Persistence::StaleObjectError)

    raised if the resource was modified in the database between been read into memory and persisted



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/frigg/persister.rb', line 15

def save(resource:, external_resource: false, perform_af_validation: false)
  # TODO
  #   orm_object = resource_factory.from_resource(resource: resource)
  #   orm_object.transaction do
  #     orm_object.save!
  #     if resource.id && resource.id.to_s != orm_object.id
  #       raise Valkyrie::Persistence::UnsupportedDatatype,
  #             "Postgres' primary key column can not save with the given ID #{resource.id}. " \
  #             "To avoid this error, set the ID to be nil via `resource.id = nil` before you save it. \n" \
  #             "Called from #{Gem.location_of_caller.join(':')}"
  #     end
  #   end
  #   resource_factory.to_resource(object: orm_object)
  # rescue ActiveRecord::StaleObjectError
  #   raise Valkyrie::Persistence::StaleObjectError, "The object #{resource.id} has been updated by another process."
end