Module: Sipity::Queries::DoiQueries

Defined in:
app/repositories/sipity/queries/doi_queries.rb

Overview

Queries

Instance Method Summary collapse

Instance Method Details

#build_assign_a_doi_form(attributes = {}) ⇒ Object


25
26
27
# File 'app/repositories/sipity/queries/doi_queries.rb', line 25

def build_assign_a_doi_form(attributes = {})
  Forms::AssignADoiForm.new(attributes)
end

#build_request_a_doi_form(attributes = {}) ⇒ Object


33
34
35
# File 'app/repositories/sipity/queries/doi_queries.rb', line 33

def build_request_a_doi_form(attributes = {})
  Forms::RequestADoiForm.new(attributes)
end

#doi_already_assigned?(sip) ⇒ Boolean

Returns:

  • (Boolean)

19
20
21
22
23
# File 'app/repositories/sipity/queries/doi_queries.rb', line 19

def doi_already_assigned?(sip)
  AdditionalAttributeQueries.sip_attribute_values_for(
    sip: sip, key: Models::AdditionalAttribute::DOI_PREDICATE_NAME
  ).any?
end

#doi_request_is_pending?(sip) ⇒ Boolean

Returns:

  • (Boolean)

5
6
7
8
9
10
11
# File 'app/repositories/sipity/queries/doi_queries.rb', line 5

def doi_request_is_pending?(sip)
  # @todo This query is not entirely correct. It needs to interrogate
  #   the states of the DoiCreationRequest. In this case, I have a leaky
  #   state machine as its enforcement is in
  #   Sipity::Jobs::DoiCreationRequestJob
  Models::DoiCreationRequest.where(sip: sip).any?
end

#find_doi_creation_request(sip:) ⇒ Object


13
14
15
16
17
# File 'app/repositories/sipity/queries/doi_queries.rb', line 13

def find_doi_creation_request(sip:)
  # Going to give you the sip as part of the find; You'll probably want
  # it.
  Models::DoiCreationRequest.includes(:sip).where(sip: sip).first!
end

#gather_doi_creation_request_metadata(sip:) ⇒ Object


29
30
31
# File 'app/repositories/sipity/queries/doi_queries.rb', line 29

def (sip:)
  Services::DoiCreationRequestMetadataGatherer.call(sip: sip)
end