Module: Sipity::Commands::DoiCommands

Extended by:
ActiveSupport::Concern
Defined in:
app/repositories/sipity/commands/doi_commands.rb

Overview

Commands

Instance Method Summary collapse

Instance Method Details

#submit_assign_a_doi_form(form, requested_by:) ⇒ Object


10
11
12
13
14
15
16
17
# File 'app/repositories/sipity/commands/doi_commands.rb', line 10

def submit_assign_a_doi_form(form, requested_by:)
  form.submit do |f|
    EventLogCommands.log_event!(entity: f.sip, user: requested_by, event_name: __method__)
    AdditionalAttributeCommands.update_sip_attribute_values!(
      sip: f.sip, key: f.identifier_key, values: f.identifier
    )
  end
end

#submit_doi_creation_request_job!(sip:) ⇒ Object (private)


45
46
47
48
49
# File 'app/repositories/sipity/commands/doi_commands.rb', line 45

def submit_doi_creation_request_job!(sip:)
  request = Models::DoiCreationRequest.create!(sip: sip)
  Jobs.submit('doi_creation_request_job', sip.id)
  request
end

#submit_request_a_doi_form(form, requested_by:) ⇒ Object


19
20
21
22
23
24
25
26
27
28
# File 'app/repositories/sipity/commands/doi_commands.rb', line 19

def submit_request_a_doi_form(form, requested_by:)
  form.submit do |f|
    AdditionalAttributeCommands.update_sip_attribute_values!(
      sip: f.sip, key: Models::AdditionalAttribute::PUBLISHER_PREDICATE_NAME, values: f.publisher
    )
    AdditionalAttributeCommands.update_sip_publication_date!(sip: f.sip, publication_date: f.publication_date)
    EventLogCommands.log_event!(entity: f.sip, user: requested_by, event_name: __method__)
    submit_doi_creation_request_job!(sip: f.sip)
  end
end

#update_sip_doi_creation_request_state!(sip:, state:, response_message: nil) ⇒ Object


30
31
32
33
34
35
# File 'app/repositories/sipity/commands/doi_commands.rb', line 30

def update_sip_doi_creation_request_state!(sip:, state:, response_message: nil)
  doi_creation_request = find_doi_creation_request(sip: sip)
  attributes = { state: state.to_s.downcase }
  attributes[:response_message] = response_message if response_message.present?
  doi_creation_request.update(attributes)
end

#update_sip_with_doi_predicate!(sip:, values:) ⇒ Object


37
38
39
40
41
# File 'app/repositories/sipity/commands/doi_commands.rb', line 37

def update_sip_with_doi_predicate!(sip:, values:)
  AdditionalAttributeCommands.update_sip_attribute_values!(
    sip: sip, key: Models::AdditionalAttribute::DOI_PREDICATE_NAME, values: values
  )
end