Class: AgentPerson
- Includes:
- ASModel, AgentManager::Mixin, Assessments::LinkedAgent, AutoGenerator, ExternalDocuments, Notes, Publishable, RecordableCataloging
- Defined in:
- backend/app/model/agent_person.rb,
public/app/models/agent_person.rb
Constant Summary
Constants included from JSONModel
JSONModel::REFERENCE_KEY_REGEX
Constants inherited from Record
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, #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 included from Assessments::LinkedAgent
Methods included from AutoGenerator
Methods included from Publishable
Methods included from Notes
included, #persistent_id_context, #update_from_json
Methods included from RecordableCataloging
Methods included from AgentManager::Mixin
#before_save, included, #linked_agent_roles, #update_from_json, #validate
Methods included from ExternalDocuments
Methods included from ASModel
all_models, included, update_publish_flag, update_suppressed_flag
Methods included from JSONModel
JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, check_valid_refs, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_publish_flags!, set_repository, strict_mode, strict_mode?, validate_schema, with_repository
Methods inherited from Record
#[], #dig, #initialize, #note, #parse_full_title, #request_item
Methods included from PrefixHelper
app_prefix, #app_prefix, app_prefix_js, #app_prefix_js
Methods included from RecordHelper
#badge_for_type, #icon_for_type, #record_class_for_type, #record_for_type, #record_from_resolved_json
Methods included from JsonHelper
#merge_notes, #process_json_notes
Methods included from ManipulateNode
#inheritance, #process_mixed_content, #strip_mixed_content
Constructor Details
This class inherits a constructor from Record
Instance Method Details
#metadata ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 |
# File 'public/app/models/agent_person.rb', line 3 def md = { '@context' => "http://schema.org/", '@type' => 'Person', '@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['birthDate'] = dates['begin'] if dates['begin'] md['deathDate'] = 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['knows'] = json['related_agents'].select {|ra| ra['relator'] == 'is_associative_with' && ra['_resolved']['jsonmodel_type'] == json['jsonmodel_type']}.map do |ag| res = ag['_resolved'] out = {} out['@id'] = res['display_name']['authority_id'] if res['display_name']['authority_id'] out['name'] = res['display_name']['sort_name'] out['url'] = AppConfig[:public_proxy_url] + res['uri'] knows = {} if ag['dates'] knows['startDate'] = ag['dates']['begin'] if ag['dates']['begin'] knows['endDate'] = ag['dates']['end'] if ag['dates']['end'] end knows['description'] = ag['description'] if ag['description'] knows['@type'] = 'Role' unless knows.empty? out['knows'] = knows unless knows.empty? out end md['parent'] = json['related_agents'].select {|ra| ra['relator'] == 'is_child_of'}.map do |ag| res = ag['_resolved'] out = {} out['@id'] = res['display_name']['authority_id'] if res['display_name']['authority_id'] out['name'] = res['display_name']['sort_name'] out['url'] = AppConfig[:public_proxy_url] + res['uri'] out end md['children'] = json['related_agents'].select {|ra| ra['relator'] == 'is_parent_of'}.map do |ag| res = ag['_resolved'] out = {} out['@id'] = res['display_name']['authority_id'] if res['display_name']['authority_id'] out['name'] = res['display_name']['sort_name'] out['url'] = AppConfig[:public_proxy_url] + res['uri'] out end md['affiliation'] = json['related_agents'].select {|ra| ra['relator'] == 'is_associative_with' && ra['_resolved']['jsonmodel_type'] != json['jsonmodel_type']}.map do |ag| res = ag['_resolved'] out = {} out['@id'] = res['display_name']['authority_id'] if res['display_name']['authority_id'] out['name'] = res['display_name']['sort_name'] out['url'] = AppConfig[:public_proxy_url] + res['uri'] out end md.compact.delete_if { |key, value| value.empty? } end |
#related_agents ⇒ Object
82 83 84 85 86 |
# File 'public/app/models/agent_person.rb', line 82 def ASUtils.wrap(json['related_agents']).select {|rel| rel['_resolved']['publish'] } end |