Class: Accessionable::Base
- Inherits:
-
Object
- Object
- Accessionable::Base
show all
- Defined in:
- app/models/accessionable/base.rb
Overview
Base class to control generating XML for accessioning with the ENA or EGA
Defined Under Namespace
Classes: Tag
Constant Summary
collapse
- InvalidData =
Class.new(AccessionService::AccessionServiceError)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(accession_number) ⇒ Base
Returns a new instance of Base.
8
9
10
11
12
13
14
|
# File 'app/models/accessionable/base.rb', line 8
def initialize(accession_number)
@accession_number = accession_number
time_now = Time.zone.now
@date = time_now.strftime('%Y-%m-%dT%H:%M:%SZ')
@date_short = time_now.strftime('%Y-%m-%d')
end
|
Instance Attribute Details
#accession_number ⇒ Object
Returns the value of attribute accession_number.
6
7
8
|
# File 'app/models/accessionable/base.rb', line 6
def accession_number
@accession_number
end
|
#date ⇒ Object
Returns the value of attribute date.
6
7
8
|
# File 'app/models/accessionable/base.rb', line 6
def date
@date
end
|
#date_short ⇒ Object
Returns the value of attribute date_short.
6
7
8
|
# File 'app/models/accessionable/base.rb', line 6
def date_short
@date_short
end
|
#name ⇒ Object
Returns the value of attribute name.
6
7
8
|
# File 'app/models/accessionable/base.rb', line 6
def name
@name
end
|
Instance Method Details
#accessionable_id ⇒ Object
58
59
60
|
# File 'app/models/accessionable/base.rb', line 58
def accessionable_id
raise NotImplementError, 'abstract method'
end
|
#add_updated_event(user, classname, eventable) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'app/models/accessionable/base.rb', line 67
def add_updated_event(user, classname, eventable)
eventable.events.create(
created_by: user.login,
message: "#{classname} #{eventable.id} accession data has been updated by user #{user.login}",
content: 'accession number regenerated',
of_interest_to: 'administrators'
)
end
|
#alias ⇒ Object
33
34
35
|
# File 'app/models/accessionable/base.rb', line 33
def alias
"#{name.gsub(/[^a-z\d]/i, '_')}-sc-#{accessionable_id}"
end
|
#errors ⇒ Object
16
17
18
|
# File 'app/models/accessionable/base.rb', line 16
def errors
[]
end
|
41
42
43
44
|
# File 'app/models/accessionable/base.rb', line 41
def (xmldoc)
element = xmldoc.root.elements["/RECEIPT/#{schema_type.upcase}"]
accession_number = element && element.attributes['accession']
end
|
46
47
48
49
|
# File 'app/models/accessionable/base.rb', line 46
def (xmldoc)
element = xmldoc.root.elements["/RECEIPT/#{schema_type.upcase}/EXT_ID[@type='ArrayExpress']"]
accession_number = element && element.attributes['accession']
end
|
#file_name ⇒ Object
37
38
39
|
# File 'app/models/accessionable/base.rb', line 37
def file_name
"#{self.alias}-#{date}.#{schema_type}.xml"
end
|
#label_scope ⇒ Object
76
77
78
|
# File 'app/models/accessionable/base.rb', line 76
def label_scope
@label_scope ||= "metadata.#{self.class.name.split('::').last.downcase}.metadata"
end
|
#released? ⇒ Boolean
62
63
64
65
|
# File 'app/models/accessionable/base.rb', line 62
def released?
false
end
|
#schema_type ⇒ Object
28
29
30
31
|
# File 'app/models/accessionable/base.rb', line 28
def schema_type
self.class.name.split('::').last.downcase
end
|
#update_accession_number!(_user, _accession_number) ⇒ Object
51
52
53
|
# File 'app/models/accessionable/base.rb', line 51
def update_accession_number!(_user, _accession_number)
raise NotImplementedError, 'abstract method'
end
|
#update_array_express_accession_number!(accession_number) ⇒ Object
55
56
|
# File 'app/models/accessionable/base.rb', line 55
def update_array_express_accession_number!(accession_number)
end
|
#xml ⇒ Object
20
21
22
|
# File 'app/models/accessionable/base.rb', line 20
def xml
raise NotImplementedError, 'abstract method'
end
|