Module: CollectionObjectCatalog

Defined in:
lib/collection_object_catalog.rb,
lib/collection_object_catalog/entry_item.rb,
lib/collection_object_catalog/catalog_entry.rb

Overview

Concept is a chronological history of the collection object

Defined Under Namespace

Classes: CatalogEntry, EntryItem

Constant Summary

EVENT_TYPES =

An arbitrary vocabulary of human-readable event names (tags) in the lifetime of a collection object

[
  :born,
  :died,
  :collected_on,
  :determined,
  :described,
  :given_identifier,
  :georeferenced,
  :destroyed,
  :placed_in_repository,
  :sent_for_loan,
  :returned_from_loan,
  :updated_metadata,
  :added_note,
  :annotated,
  :cited,
  :containerized,
  :imaged,
  :extracted_from,
  :sequenced,
  :dissected,
  :tagged,
  :typified,
  :added_attribute,
  :biologically_classified,
  :fossilized_between, # chronological time period b/w which specimen was fossilized
]

Class Method Summary (collapse)

Class Method Details

+ (Object) data_for(collection_object)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/collection_object_catalog.rb', line 34

def self.data_for(collection_object)
  o = collection_object
  data = CollectionObjectCatalog::CatalogEntry.new(o)
  
  data.items << CollectionObjectCatalog::EntryItem.new(type: :collected_on, object: o.collecting_event, start_date: o.collecting_event.start_date, end_date: o.collecting_event.end_date) if o.collecting_event_id.present? 

  o.biocuration_classifications.each do |b|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :biologically_classified, object: b, start_date: b.created_at.to_time) 
  end

  o.versions.each do |v|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :updated_metadata, object: v, start_date: v.created_at.to_time) 
  end

  o.georeferences.each do |g|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :georeferenced, object: g, start_date: g.created_at.to_time)
  end

  # Broken, definitely broken
  o.type_designations.each do |t|
    date = t.origin_citation ? t.origin_citation.nomenclature_date : nil
    data.items << CollectionObjectCatalog::EntryItem.new(type: :typified, object: t, start_date: date)
  end

  o.taxon_determinations.each do |td|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :determined, object: td, start_date: td.sort_date) 
  end

  o.identifiers.each do |i|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :given_identifier, object: i, start_date: i.created_at) 
  end

  o.loans.each do |l|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :sent_for_loan, object: l, start_date: l.date_sent.to_time) if l.date_sent
    data.items << CollectionObjectCatalog::EntryItem.new(type: :returned_from_loan, object: l, start_date: l.date_closed.to_time) if l.date_closed
  end

  o.tags.each do |t|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :tagged, object: t, start_date: t.created_at.to_time) 
  end

  o.data_attributes.each do |d|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :added_attribute, object: d, start_date: d.created_at.to_time) 
  end

  o.notes.each do |n|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :added_note, object: n, start_date: n.created_at.to_time) 
  end

  o.images.each do |i|
    data.items << CollectionObjectCatalog::EntryItem.new(type: :imaged, object: i, start_date: i.created_at.to_time) 
  end

  data.items << CollectionObjectCatalog::EntryItem.new(type: :containerized, object: o.container, start_date: c.created_at.to_time)  if o.container

  # in eyelet
  # extracts, sequences, 

  data
end