Class: Artk::Resource

Inherits:
Base
  • Object
show all
Defined in:
app/models/artk/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

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_aidsObject



14
15
16
# File 'app/models/artk/resource.rb', line 14

def self.finding_aids
  self.where('eadFaUniqueIdentifier != "" and findingAidTitle !=""')
end

.primary_keyObject



10
11
12
# File 'app/models/artk/resource.rb', line 10

def self.primary_key
  "resourceId"
end

.table_nameObject



6
7
8
# File 'app/models/artk/resource.rb', line 6

def self.table_name
  "Resources"
end

Instance Method Details

#all_seriesObject

Returns all Artk::Component objects that have children components attached to them and are not just the first level of <c> nodes in the finding aid



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   = retrieve_initial_series
  second  = []
  third   = []
  fourth  = []
  fifth   = []
  sixth   = []
  
  # Get additional series, second through sixth
  second  = first.collect { |r| retrieve_additional_series(r) }.flatten unless first.empty?
  third   = second.collect { |r| retrieve_additional_series(r) }.flatten unless second.empty?
  fourth  = third.collect { |r| retrieve_additional_series(r) }.flatten unless third.empty?
  fifth   = fourth.collect { |r| retrieve_additional_series(r) }.flatten unless fourth.empty?
  sixth   = fifth.collect { |r| retrieve_additional_series(r) }.flatten unless fifth.empty?

  return first + second + third + fourth + fifth + sixth
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_titleObject



48
49
50
# File 'app/models/artk/resource.rb', line 48

def pid_and_title
  { :pid => self.eadFaUniqueIdentifier, :title => self.findingAidTitle }
end