Skip to content

Commit c5b9316

Browse files
committed
also include the short name, but with addition of department, and also fixed the address #2379
1 parent ddf8e92 commit c5b9316

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

lib/seek/bio_schema/resource_decorators/institution.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ module ResourceDecorators
55
class Institution < Thing
66
schema_mappings full_address: :address,
77
image: :logo,
8-
ror_url: :identifier
8+
ror_url: :identifier,
9+
base_title: :name,
10+
department_organization: :department
911

1012
def schema_type
1113
'ResearchOrganization'
1214
end
1315

16+
def department_organization
17+
return nil if department.blank?
18+
{
19+
'@type': 'Organization',
20+
name: department
21+
}
22+
end
23+
1424
def url
1525
web_page.blank? ? identifier : web_page
1626
end
@@ -21,9 +31,10 @@ def conformance
2131

2232
def full_address
2333
full = {}
24-
full[:address_country] = country
25-
full[:address_locality] = city unless city.blank?
26-
full[:street_address] = address unless address.blank?
34+
full[:@type]='PostalAddress'
35+
full[:addressCountry] = country
36+
full[:addressLocality] = city unless city.blank?
37+
full[:streetAddress] = address unless address.blank?
2738
full
2839
end
2940
end

test/unit/bio_schema/schema_ld_generation_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,22 @@ def setup
696696
'@type' => 'ResearchOrganization',
697697
'dct:conformsTo' => 'https://schema.org/ResearchOrganization',
698698
'@id' => "http://localhost:3000/institutions/#{institution.id}",
699-
"name"=>"Manchester Institute of Biotechnology, University of Manchester",
699+
"name"=>"University of Manchester",
700+
"department"=>{"@type"=>"Organization", "name"=>"Manchester Institute of Biotechnology"},
700701
'url' => 'http://www.manchester.ac.uk/',
701702
'identifier' => 'https://ror.org/027m9bs27',
702-
"address"=>{"address_country"=>"GB", "address_locality"=>"Manchester", "street_address"=>"Manchester Centre for Integrative Systems Biology, MIB/CEAS, The University of Manchester Faraday Building, Sackville Street, Manchester M60 1QD United Kingdom"}
703+
"address"=>{"@type"=>"PostalAddress","addressCountry"=>"GB", "addressLocality"=>"Manchester", "streetAddress"=>"Manchester Centre for Integrative Systems Biology, MIB/CEAS, The University of Manchester Faraday Building, Sackville Street, Manchester M60 1QD United Kingdom"}
703704
}
704705

705706
json = JSON.parse(institution.to_schema_ld)
706707
assert_equal expected, json
708+
709+
# check without ror_id and department
710+
institution.update_columns(department:'', ror_id:nil)
711+
json = JSON.parse(institution.to_schema_ld)
712+
expected.delete('department')
713+
expected.delete('identifier')
714+
assert_equal expected, json
707715
end
708716

709717
test 'organism' do

0 commit comments

Comments
 (0)