Class: Determiner

Inherits:
Role::ProjectRole show all
Includes:
Roles::Organization, Shared::DwcOccurrenceHooks
Defined in:
app/models/determiner.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Role::ProjectRole

#set_project_if_possible

Methods included from Housekeeping

#has_polymorphic_relationship?

Class Method Details

.human_nameObject



29
30
31
# File 'app/models/determiner.rb', line 29

def self.human_name
  'Determiner'
end

Instance Method Details

#dwc_occurrencesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/determiner.rb', line 11

def dwc_occurrences
  co = DwcOccurrence
    .joins("JOIN collection_objects co on dwc_occurrence_object_id = co.id AND dwc_occurrence_object_type = 'CollectionObject'")
    .joins("JOIN taxon_determinations td on co.id = td.taxon_determination_object_id AND td.taxon_determination_object_type = 'CollectionObject'")
    .joins("JOIN roles r on r.type = 'Determiner' AND r.role_object_type = 'TaxonDetermination' AND r.role_object_id = td.id")
    .where(r: {id:})
    .distinct

  fo = DwcOccurrence
    .joins("JOIN field_occurrences fo on dwc_occurrence_object_id = fo.id AND dwc_occurrence_object_type = 'FieldOccurrence'")
    .joins("JOIN taxon_determinations td on fo.id = td.taxon_determination_object_id AND td.taxon_determination_object_type = 'FieldOccurrence'")
    .joins("JOIN roles r on r.type = 'Determiner' AND r.role_object_type = 'TaxonDetermination' AND r.role_object_id = td.id")
    .where(r: {id:})
    .distinct

  ::Queries.union(DwcOccurrence, [co, fo])
end

#year_active_yearObject



33
34
35
# File 'app/models/determiner.rb', line 33

def year_active_year
  role_object.year_made
end