Class: Accessionable::Dac
Overview
Represents a Data Access Committee who co-ordinate access to managed (EGA) studies. Should ideally be a completely separate record from Study but currently just a group of attributes in the Study::Metadata
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
Attributes inherited from Base
#accession_number, #date, #date_short, #name
Instance Method Summary collapse
- #accessionable_id ⇒ Object
- #errors ⇒ Object
-
#initialize(study) ⇒ Dac
constructor
A new instance of Dac.
- #protect?(service) ⇒ Boolean
- #update_accession_number!(user, accession_number) ⇒ Object
-
#xml ⇒ Object
rubocop:todo Metrics/MethodLength.
Methods inherited from Base
#add_updated_event, #alias, #center_name, #extract_accession_number, #extract_array_express_accession_number, #file_name, #label_scope, #released?, #schema_type, #update_array_express_accession_number!
Constructor Details
#initialize(study) ⇒ Dac
Returns a new instance of Dac.
8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/accessionable/dac.rb', line 8 def initialize(study) @study = study @name = study.dac_refname @contacts = study.data_access_contacts.map do |contact| { email: contact.email, name: contact.name, organisation: AccessionService::CenterName } end super(study.dac_accession_number) end |
Instance Attribute Details
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
6 7 8 |
# File 'app/models/accessionable/dac.rb', line 6 def contacts @contacts end |
Instance Method Details
#accessionable_id ⇒ Object
49 50 51 |
# File 'app/models/accessionable/dac.rb', line 49 def accessionable_id @study.id end |
#errors ⇒ Object
19 20 21 |
# File 'app/models/accessionable/dac.rb', line 19 def errors [].tap { |errors| errors << 'Data Access Contacts Empty. Please add a contact' if @contacts.empty? } end |
#protect?(service) ⇒ Boolean
45 46 47 |
# File 'app/models/accessionable/dac.rb', line 45 def protect?(service) service.dac_visibility(@study) == AccessionService::Protect end |
#update_accession_number!(user, accession_number) ⇒ Object
38 39 40 41 42 43 |
# File 'app/models/accessionable/dac.rb', line 38 def update_accession_number!(user, accession_number) @accession_number = accession_number add_updated_event(user, "DAC for Study #{@study.id}", @study) if @accession_number @study..ega_dac_accession_number = accession_number @study.save! end |
#xml ⇒ Object
rubocop:todo Metrics/MethodLength
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/accessionable/dac.rb', line 23 def xml # rubocop:todo Metrics/MethodLength xml = Builder::XmlMarkup.new xml.instruct! xml.DAC_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do xml.DAC(alias: self.alias, accession: accession_number, center_name: center_name) do xml.CONTACTS do contacts.each do |contact| xml.CONTACT(name: contact[:name], email: contact[:email], organisation: contact[:organisation]) end end end end xml.target! end |