Class: Accession::Submission
- Inherits:
-
Object
- Object
- Accession::Submission
- Includes:
- Accessionable, ActiveModel::Model
- Defined in:
- lib/accession/accession/submission.rb
Overview
Made up of a sample, user and service Used by Request to extract relevant information to send to appropriate accessioning service
Defined Under Namespace
Classes: Payload
Instance Attribute Summary collapse
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes included from Accessionable
Instance Method Summary collapse
-
#initialize(user, sample) ⇒ Submission
constructor
A new instance of Submission.
- #payload ⇒ Object
- #post ⇒ Object
-
#to_xml ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength.
- #update_accession_number ⇒ Object
Methods included from Accessionable
#date, #ebi_alias_datestamped, #filename, #schema_type, #to_file
Constructor Details
#initialize(user, sample) ⇒ Submission
Returns a new instance of Submission.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/accession/accession/submission.rb', line 18 def initialize(user, sample) @user = user @sample = sample @response = Accession::NullResponse.new if valid? @service = sample.service @contact = Contact.new(user) end end |
Instance Attribute Details
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
9 10 11 |
# File 'lib/accession/accession/submission.rb', line 9 def contact @contact end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/accession/accession/submission.rb', line 9 def response @response end |
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
9 10 11 |
# File 'lib/accession/accession/submission.rb', line 9 def sample @sample end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
9 10 11 |
# File 'lib/accession/accession/submission.rb', line 9 def service @service end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
9 10 11 |
# File 'lib/accession/accession/submission.rb', line 9 def user @user end |
Instance Method Details
#payload ⇒ Object
57 58 59 |
# File 'lib/accession/accession/submission.rb', line 57 def payload @payload ||= Payload.new([self, sample]) end |
#post ⇒ Object
49 50 51 |
# File 'lib/accession/accession/submission.rb', line 49 def post @response = Accession::Request.post(self) if valid? end |
#to_xml ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/accession/accession/submission.rb', line 29 def to_xml # rubocop:todo Metrics/AbcSize, Metrics/MethodLength xml = Builder::XmlMarkup.new xml.instruct! xml.SUBMISSION( XML_NAMESPACE, center_name: CENTER_NAME, broker_name: service.broker, alias: sample.ebi_alias_datestamped, submission_date: date ) do xml.CONTACTS { xml.CONTACT(contact.to_h) } xml.ACTIONS do xml.ACTION { xml.ADD(source: sample.filename, schema: sample.schema_type) } xml.ACTION { xml.tag!(service.visibility) } end end xml.target! end |
#update_accession_number ⇒ Object
53 54 55 |
# File 'lib/accession/accession/submission.rb', line 53 def update_accession_number sample.update_accession_number(response.accession_number) if accessioned? end |