Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HYC-1997 - Affiliation Updates #1139

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def facet
end
end


configure_blacklight do |config|
# Advanced search configuration
config.advanced_search ||= Blacklight::OpenStructWithHashAccess.new
Expand Down Expand Up @@ -138,7 +137,7 @@ def facet
# The ordering of the field names is the order of the display
config.add_facet_field solr_name('resource_type', :facetable), label: 'Resource Type', limit: 5
config.add_facet_field solr_name('creator_label', :facetable), label: 'Creator', limit: 5
config.add_facet_field solr_name('affiliation_label', :facetable), label: 'Departments', limit: 5
config.add_facet_field solr_name('affiliation_label', :facetable), label: 'Departments', limit: 5, helper_method: :format_affiliation_facet
# Search results version of the date_issued facet
config.add_facet_field 'date_issued_isim', field: 'date_issued_isim', label: 'Date', range: true, range_config: {
input_label_range_begin: 'from year',
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/hyc_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def language_links_facets(options)
options
end

# Format affiliation to display short label if available, otherwise display the original facet value
def format_affiliation_facet(facet_value)
label = DepartmentsService.short_label(facet_value)
label.blank? ? facet_value : label
end

def get_work_url(model, id)
Rails.application.routes.url_helpers.send("#{Hyrax::Name.new(model).singular_route_key}_url", id)
end
Expand Down
33 changes: 8 additions & 25 deletions app/overrides/lib/active-fedora/rdf/indexing_service_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def build_person_display(field_key, people)
display_text << "ORCID: #{orcid.first}" unless orcid.first.blank?
@orcid_label.push(orcid)

display_text = build_affiliations(person['affiliation'], display_text)
add_affiliation(person['affiliation'], display_text)

other_affil = Array(person['other_affiliation'])
display_text << "Other Affiliation: #{other_affil.first}" unless other_affil.first.blank?
Expand All @@ -137,31 +137,14 @@ def build_person_display(field_key, people)
displays.flatten
end

def build_affiliations(affiliation_identifier, display_text)
affiliations = split_affiliations(affiliation_identifier)
unless affiliations.blank?
display_text << "Affiliation: #{affiliations.join(', ')}"

affiliation_ids = Array(affiliation_identifier)
short_labels = affiliation_ids.map do |affil_id|
DepartmentsService.short_label(affil_id)
end
@affiliation_label.push(short_labels)
end

display_text
end

# split affiliations out
def split_affiliations(affiliations)
affiliations_list = []

Array(affiliations).reject { |a| a.blank? }.each do |aff|
Array(DepartmentsService.term(aff)).join(';').split(';').each do |value|
affiliations_list.push(value.squish!)
def add_affiliation(affiliation_relation, display_text)
affiliation_identifier = Array(affiliation_relation).first
term = DepartmentsService.term(affiliation_identifier)
if term.present?
display_text << "Affiliation: #{affiliation_identifier}"
term.split(';').each do |term_val|
@affiliation_label.push(term_val.strip)
end
end

affiliations_list.uniq
end
end
45 changes: 18 additions & 27 deletions app/renderers/hyrax/renderers/person_attribute_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ def render_dl_row

markup << %(<dt>#{label}</dt>\n<dd><ul class='tabular'>)
attributes = microdata_object_attributes(field).merge(class: "attribute attribute-#{field}")
# conditional can be removed once all people objects have indexes
if values.first.match('index:')
sort_people_by_index(values).each do |value|
markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
end
else
Array(values).each do |value|
markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
end
sort_people_by_index(values).each do |value|
markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
end

markup << %(</ul></dd>)
# Add 'itemprop' to default list of allowed attributes
sanitize markup, attributes: %w(href src width height alt cite datetime title class name xml:lang abbr itemprop itemtype target)
Expand All @@ -30,26 +24,15 @@ def render_dl_row
def attribute_value_to_html(value)
person = value.split('||')
display_text = ''
# conditional can be removed once all people objects have indexes
if value.match('index:')
display_text << "<li><span#{html_attributes(microdata_value_attributes(field.to_s.chomp('_display')))}>#{person[1]}</span>"
if person.length > 2
display_text << '<ul>'
person[2..-1].each do |attr|
display_text << "<li>#{format_attribute(attr)}</li>"
end
display_text << '</ul>'
end
else
display_text << "<li><span#{html_attributes(microdata_value_attributes(field.to_s.chomp('_display')))}>#{person[0]}</span>"
if person.length > 1
display_text << '<ul>'
person[1..-1].each do |attr|
display_text << "<li>#{format_attribute(attr)}</li>"
end
display_text << '</ul>'
display_text << "<li><span#{html_attributes(microdata_value_attributes(field.to_s.chomp('_display')))}>#{person[1]}</span>"
if person.length > 2
display_text << '<ul>'
person[2..-1].each do |attr|
display_text << "<li>#{format_attribute(attr)}</li>"
end
display_text << '</ul>'
end

display_text << '</li>'
rescue ArgumentError
value
Expand All @@ -60,6 +43,14 @@ def format_attribute(text)
text_pieces = text.split(' ')
url = text_pieces[1].strip
text = "#{text_pieces[0]} <a href='#{url}' target='_blank'>#{url}</a>"
elsif text =~ /Affiliation:/
# Get the full hierarchy of terms, with correct short labels, for the affiliation id
term = DepartmentsService.term(text.split(':').last.strip)
if term.present?
text = term.split(';').map do |term_val|
DepartmentsService.short_label(term_val.strip)
end.join(', ')
end
end

text
Expand Down
2 changes: 1 addition & 1 deletion app/services/departments_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module DepartmentsService

def self.select_all_options
authority.all.reject { |item| item['active'] == false }.map do |element|
[element[:id], element[:id]]
[element[:short_label], element[:id]]
end
end

Expand Down
80 changes: 62 additions & 18 deletions config/authorities/departments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ terms:
term: Gillings School of Global Public Health; Carolina Global Breastfeeding Institute
active: true
short_label: Carolina Global Breastfeeding Institute
- id: Carolina Health Informatics Program
term: Carolina Health Informatics Program
active: true
short_label: Carolina Health Informatics Program
- id: Neurodevelopment Disorders Research Center
term: School of Medicine; Neurodevelopment Disorders Research Center; Carolina Institute for Developmental Disabilities
active: false
Expand Down Expand Up @@ -161,7 +165,7 @@ terms:
active: false
short_label: Heart and Vascular Center
- id: Center for Esophageal Diseases and Swallowing
term: School of Medicine, Department of Medicine, Center for Esophageal Diseases and Swallowing
term: School of Medicine; Department of Medicine; Center for Esophageal Diseases and Swallowing
active: true
short_label: Center for Esophageal Diseases and Swallowing
- id: Center for Faculty Excellence
Expand All @@ -176,6 +180,10 @@ terms:
term: School of Medicine; Center for Heart and Vascular Care
active: true
short_label: Center for Heart and Vascular Care
- id: Center for Information, Technology, and Public Life
term: Center for Information, Technology, and Public Life
active: true
short_label: Center for Information, Technology, and Public Life
- id: Center for Integrative Chemical Biology and Drug Discovery
term: Eshelman School of Pharmacy; Center for Integrative Chemical Biology and Drug Discovery
active: true
Expand All @@ -193,7 +201,7 @@ terms:
active: true
short_label: Center for Nanotechnology in Drug Delivery
- id: Center for Pain Research and Innovation
term: School of Dentistry, Center for Pain Research and Innovation
term: School of Dentistry; Center for Pain Research and Innovation
active: true
short_label: Center for Pain Research and Innovation
- id: Center of Pharmacogenomics and Individualized Therapy
Expand Down Expand Up @@ -317,9 +325,9 @@ terms:
active: true
short_label: Curriculum in Russian and East European Studies
- id: Curriculum in Toxicology
term: School of Medicine; Curriculum in Toxicology
term: School of Medicine; Curriculum in Toxicology and Environmental Medicine
active: true
short_label: Curriculum in Toxicology
short_label: Curriculum in Toxicology and Environmental Medicine
- id: CF/Pulmonary Research and Treatment Center
term: School of Medicine; Cystic Fibrosis and Pulmonary Diseases Research and Treatment Center
active: false
Expand Down Expand Up @@ -549,9 +557,9 @@ terms:
active: true
short_label: Department of Genetics
- id: Department of Geography
term: College of Arts and Sciences; Department of Geography
term: College of Arts and Sciences; Department of Geography and Environment
active: true
short_label: Department of Geography
short_label: Department of Geography and Environment
- id: Department of Geological Sciences
term: College of Arts and Sciences; Department of Geological Sciences
active: true
Expand Down Expand Up @@ -761,7 +769,7 @@ terms:
active: true
short_label: Department of Religious Studies
- id: Department of Research Computing
term: Information Technology Services, Department of Research Computing
term: Information Technology Services; Department of Research Computing
active: true
short_label: Department of Research Computing
- id: Department of Romance Languages
Expand Down Expand Up @@ -837,7 +845,7 @@ terms:
active: true
short_label: Division of Cardiology
- id: Division of Cardiothoracic Surgery
term: School of Medicine, Department of Surgery, Division of Cardiothoracic Surgery
term: School of Medicine; Department of Surgery; Division of Cardiothoracic Surgery
active: true
short_label: Division of Cardiothoracic Surgery
- id: Division of Chemical Biology and Medicinal Chemistry
Expand Down Expand Up @@ -908,6 +916,10 @@ terms:
term: School of Medicine; Department of Allied Health Sciences; Division of Occupational Science and Occupational Therapy
active: true
short_label: Division of Occupational Science and Occupational Therapy
- id: Division of Pediatric Dermatology
term: School of Medicine; Department of Dermatology; Division of Pediatric Dermatology
active: true
short_label: Division of Pediatric Dermatology
- id: Division of Pharmaceutical Outcomes and Policy
term: Eshelman School of Pharmacy; Division of Pharmaceutical Outcomes and Policy
active: true
Expand All @@ -924,6 +936,14 @@ terms:
term: School of Medicine; Department of Allied Health Sciences; Division of Physical Therapy
active: true
short_label: Division of Physical Therapy
- id: Division of Plastic and Reconstructive Surgery
term: School of Medicine; Department of Surgery; Division of Plastic and Reconstructive Surgery
active: true
short_label: Division of Plastic and Reconstructive Surgery
- id: Division of Practice Advancement and Clinical Education
term: Eshelman School of Pharmacy; Division of Practice Advancement and Clinical Education
active: true
short_label: Division of Practice Advancement and Clinical Education
- id: Division of Pulmonary Diseases and Critical Care Medicine
term: School of Medicine; Department of Medicine; Division of Pulmonary Diseases and Critical Care Medicine
active: true
Expand Down Expand Up @@ -1169,7 +1189,7 @@ terms:
active: true
short_label: Mass Communication Graduate Program
- id: Marsico Lung Institute/UNC Cystic Fibrosis Center
term: School of Medicine, Marsico Lung Institute/UNC Cystic Fibrosis Center
term: School of Medicine; Marsico Lung Institute/UNC Cystic Fibrosis Center
active: true
short_label: Marsico Lung Institute/UNC Cystic Fibrosis Center
- id: Materials Science Program
Expand All @@ -1185,7 +1205,7 @@ terms:
active: false
short_label: Mathematical Decision Sciences Program
- id: Matthew Gfeller Sport-Related Traumatic Brain Injury Research Center
term: College of Arts and Sciences, Department of Exercise and Sports Science, Matthew Gfeller Sport-Related Traumatic Brain Injury Research Center
term: College of Arts and Sciences; Department of Exercise and Sports Science; Matthew Gfeller Sport-Related Traumatic Brain Injury Research Center
active: true
short_label: Matthew Gfeller Sport-Related Traumatic Brain Injury Research Center
- id: Michael Hooker Microscopy Facility
Expand All @@ -1197,7 +1217,7 @@ terms:
active: true
short_label: Molecular and Cellular Pathology Graduate Program
- id: Moore Undergraduate Research Apprenticeship Program (MURAP)
term: Institute of African American Research, Moore Undergraduate Research Apprenticeship Program (MURAP)
term: Institute of African American Research; Moore Undergraduate Research Apprenticeship Program (MURAP)
active: true
short_label: Moore Undergraduate Research Apprenticeship Program (MURAP)
- id: Musicology Graduate Program
Expand Down Expand Up @@ -1225,7 +1245,7 @@ terms:
active: true
short_label: Neuroscience Curriculum
- id: NIMH Psychoactive Drug Screening Program
term: School of Medicine, Department of Pharmacology, NIMH Psychoactive Drug Screening Program
term: School of Medicine; Department of Pharmacology; NIMH Psychoactive Drug Screening Program
active: true
short_label: NIMH Psychoactive Drug Screening Program
- id: North Carolina Institute for Public Health
Expand Down Expand Up @@ -1293,7 +1313,7 @@ terms:
active: true
short_label: Organic Chemistry Program
- id: Partnerships in Aging Program
term: Office of the Provost, Partnerships in Aging Program
term: Office of the Provost; Partnerships in Aging Program
active: true
short_label: Partnerships in Aging Program
- id: Pathobiology and Translational Science Graduate Program
Expand Down Expand Up @@ -1372,10 +1392,18 @@ terms:
term: School of Education; School Counseling Graduate Program
active: true
short_label: School Counseling Graduate Program
- id: School of Civic Life and Leadership
term: School of Civic Life and Leadership
active: true
short_label: School of Civic Life and Leadership
- id: School of Data Science and Society
term: School of Data Science and Society
active: true
short_label: School of Data Science and Society
- id: School of Dentistry
term: School of Dentistry
term: Adams School of Dentistry
active: true
short_label: School of Dentistry
short_label: Adams School of Dentistry
- id: School of Education
term: School of Education
active: true
Expand Down Expand Up @@ -1548,6 +1576,22 @@ terms:
term: School of Medicine; UNC/NCSU Joint Department of Biomedical Engineering
active: true
short_label: UNC/NCSU Joint Department of Biomedical Engineering
- id: UNC Project-Liberia
term: School of Medicine; UNC Project-Liberia
active: true
short_label: UNC Project-Liberia
- id: UNC Project-Nicaragua
term: School of Medicine; UNC Project-Nicaragua
active: true
short_label: UNC Project-Nicaragua
- id: UNC Project-Vietnam
term: School of Medicine; UNC Project-Vietnam
active: true
short_label: UNC Project-Vietnam
- id: UNC Project-Zambia
term: School of Medicine; UNC Project-Zambia
active: true
short_label: UNC Project-Zambia
- id: University of North Carolina at Chapel Hill. Graduate School
term: University of North Carolina at Chapel Hill. Graduate School
active: true
Expand Down Expand Up @@ -1589,19 +1633,19 @@ terms:
active: false
short_label: Louis Round Wilson Library
- id: UNC Global Women's Health
term: School of Medicine, Department of Obstetrics and Gynecology, UNC Global Women's Health
term: School of Medicine; Department of Obstetrics and Gynecology; UNC Global Women's Health
active: true
short_label: UNC Global Women's Health
- id: UNC Medical Center
term: UNC Medical Center
active: true
short_label: UNC Medical Center
- id: UNC Project-China
term: School of Medicine, UNC Project-China
term: School of Medicine; UNC Project-China
active: true
short_label: UNC Project-China
- id: UNC Project-Malawi
term: School of Medicine, UNC Project-Malawi
term: School of Medicine; UNC Project-Malawi
active: true
short_label: UNC Project-Malawi
- id: University of North Carolina at Chapel Hill
Expand Down
Loading
Loading