Class: AgentCorporateEntity
- Includes:
- ASModel, AgentManager::Mixin, AutoGenerator, ExternalDocuments, Notes, Publishable, RecordableCataloging
- Defined in:
- backend/app/model/agent_corporate_entity.rb,
public/app/models/agent_corporate_entity.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 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
#delete ⇒ Object
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 |
#metadata ⇒ Object
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 |
#related_agents ⇒ Object
27 28 29 30 31 |
# File 'public/app/models/agent_corporate_entity.rb', line 27 def ASUtils.wrap(json['related_agents']).select {|rel| rel['_resolved']['publish'] } end |