Class: AgentCorporateEntity

Inherits:
Record
  • Object
show all
Defined in:
backend/app/model/agent_corporate_entity.rb,
public/app/models/agent_corporate_entity.rb

Constant Summary

Constants inherited from Record

Record::ABSTRACT

Instance Attribute Summary

Attributes inherited from Record

#agents, #classifications, #container_display, #container_summary_for_badge, #container_titles_and_uris, #criteria, #dates, #display_string, #extents, #external_documents, #full, #highlights, #identifier, #json, #lang_materials, #level, #linked_digital_objects, #notes, #other_level, #primary_type, #raw, #repository_information, #resolved_repository, #resolved_resource, #resolved_top_container, #subjects, #uri

Instance Method Summary collapse

Methods inherited from Record

#[], #apply_highlighting, #dig, #initialize, #note, #parse_full_title, #request_item

Constructor Details

This class inherits a constructor from Record

Instance Method Details

#deleteObject



33
34
35
36
37
38
39
# File 'backend/app/model/agent_corporate_entity.rb', line 33

def delete
  begin
    super
  rescue Sequel::DatabaseError
    raise ConflictException.new("This agent is linked to a repository and can't be removed")
  end
end

#metadataObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'public/app/models/agent_corporate_entity.rb', line 3

def 
  md = {
    '@context' => "http://schema.org/",
    '@type' => 'Organization',
    '@id' => AppConfig[:public_proxy_url] + uri,
    'name' => json['display_name']['sort_name'],
    'sameAs' => raw['authority_id'],
    'alternateName' => json['names'].select {|n| !n['is_display_name']}.map {|n| n['sort_name']}
  }

  if (dates = json['dates_of_existence'].first)
    md['foundingDate'] = dates['begin'] if dates['begin']
    md['dissolutionDate'] = dates['end'] if dates['end']
  end

  md['description'] = json['notes'].select {|n| n['jsonmodel_type'] == 'note_bioghist'}.map {|note|
                        strip_mixed_content(note['subnotes'].map {|s| s['content']}.join(' '))
                      }
  md['description'] = md['description'][0] if md['description'].length == 1

  md.compact.delete_if { |key, value| value.empty? }
end


27
28
29
30
31
# File 'public/app/models/agent_corporate_entity.rb', line 27

def related_agents
  ASUtils.wrap(json['related_agents']).select {|rel|
    rel['_resolved']['publish']
  }
end