Class: Artk::Resource
- Defined in:
- app/models/artk/resource.rb
Class Method Summary collapse
-
.find_by_ead_id(id) ⇒ Object
TODO: sanitize params?.
- .finding_aids ⇒ Object
- .primary_key ⇒ Object
- .table_name ⇒ Object
Instance Method Summary collapse
-
#all_series ⇒ Object
Returns all Artk::Component objects or <c> nodes that are in the collection.
-
#component(ref) ⇒ Object
Returns a single Artk::Component for a given ref id.
- #pid_and_title ⇒ Object
Class Method Details
.find_by_ead_id(id) ⇒ Object
TODO: sanitize params?
19 20 21 |
# File 'app/models/artk/resource.rb', line 19 def self.find_by_ead_id id self.where("eadFaUniqueIdentifier = '#{id}'").first end |
.finding_aids ⇒ Object
14 15 16 |
# File 'app/models/artk/resource.rb', line 14 def self.finding_aids self.where('eadFaUniqueIdentifier != "" and findingAidTitle !=""').order("findingAidTitle") end |
.primary_key ⇒ Object
10 11 12 |
# File 'app/models/artk/resource.rb', line 10 def self.primary_key "resourceId" end |
.table_name ⇒ Object
6 7 8 |
# File 'app/models/artk/resource.rb', line 6 def self.table_name "Resources" end |
Instance Method Details
#all_series ⇒ Object
Returns all Artk::Component objects or <c> nodes that are in the collection. We have to build the component levels one by one, limited to 6 levels.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/artk/resource.rb', line 25 def all_series first = self.components second = [] third = [] fourth = [] fifth = [] sixth = [] # Get additional series, second through sixth second = first.collect { |r| r.sub_components }.flatten unless first.empty? third = second.collect { |r| r.sub_components }.flatten unless second.empty? fourth = third.collect { |r| r.sub_components }.flatten unless third.empty? fifth = fourth.collect { |r| r.sub_components }.flatten unless fourth.empty? sixth = fifth.collect { |r| r.sub_components }.flatten unless fifth.empty? return (first + second + third + fourth + fifth + sixth).sort end |
#component(ref) ⇒ Object
Returns a single Artk::Component for a given ref id
44 45 46 |
# File 'app/models/artk/resource.rb', line 44 def component ref self.all_series.collect { |c| c if c.persistentId == ref }.compact.first end |
#pid_and_title ⇒ Object
48 49 50 |
# File 'app/models/artk/resource.rb', line 48 def pid_and_title { :pid => self.eadFaUniqueIdentifier, :title => self.findingAidTitle } end |