Skip to content

Commit 1272b0e

Browse files
authored
fix: file dataset metadata download (#11296)
1 parent 8ae88c5 commit 1272b0e

31 files changed

+302
-42
lines changed

osf/metadata/osf_gathering.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,8 @@ def gather_user_basics(focus):
10201020
if isinstance(focus.dbmodel, osfdb.OSFUser):
10211021
yield (RDF.type, FOAF.Person) # note: assumes osf user accounts represent people
10221022
yield (FOAF.name, focus.dbmodel.fullname)
1023+
yield (FOAF.givenName, focus.dbmodel.given_name)
1024+
yield (FOAF.familyName, focus.dbmodel.family_name)
10231025
_social_links = focus.dbmodel.social_links
10241026
# special cases abound! do these one-by-one (based on OSFUser.SOCIAL_FIELDS)
10251027
yield (DCTERMS.identifier, _social_links.get('github'))

osf/metadata/serializers/google_dataset_json_ld.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ def metadata_as_dict(self) -> dict:
7676

7777
def format_creators(basket):
7878
creator_data = []
79-
for creator in basket.focus.dbmodel.contributors.all():
79+
for creator_iri in basket[DCTERMS.creator]:
8080
creator_data.append({
8181
'@type': 'Person',
82-
'name': creator.fullname,
83-
'givenName': creator.given_name,
84-
'familyName': creator.family_name
82+
'name': next(basket[creator_iri:FOAF.name]),
83+
'givenName': next(basket[creator_iri:FOAF.givenName]),
84+
'familyName': next(basket[creator_iri:FOAF.familyName]),
8585
})
8686
return creator_data
8787

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": "https://schema.org",
3+
"@type": "Dataset",
4+
"creator": [],
5+
"dateCreated": "2123-05-04",
6+
"dateModified": "2123-05-04",
7+
"description": "No description was included in this Dataset collected from the OSF",
8+
"identifier": [
9+
"http://localhost:5000/w3ibb"
10+
],
11+
"keywords": [],
12+
"license": [],
13+
"name": "my-file.blarg",
14+
"publisher": {
15+
"@type": "Organization",
16+
"name": "Center For Open Science"
17+
},
18+
"url": "http://localhost:5000/w3ibb"
19+
}

osf_tests/metadata/expected_metadata_files/file_basic.turtle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<http://localhost:5000/w1ibb> a dcterms:Agent,
4242
foaf:Person ;
4343
dcterms:identifier "http://localhost:5000/w1ibb" ;
44+
foaf:givenName "Person" ;
45+
foaf:familyName "McNamington" ;
4446
foaf:name "Person McNamington" .
4547

4648
<http://localhost:5000> a dcterms:Agent,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": "https://schema.org",
3+
"@type": "Dataset",
4+
"creator": [],
5+
"dateCreated": "2123-05-04",
6+
"dateModified": "2123-05-04",
7+
"description": "No description was included in this Dataset collected from the OSF",
8+
"identifier": [
9+
"http://localhost:5000/w3ibb"
10+
],
11+
"keywords": [],
12+
"license": [],
13+
"name": "my-file.blarg",
14+
"publisher": {
15+
"@type": "Organization",
16+
"name": "Center For Open Science"
17+
},
18+
"url": "http://localhost:5000/w3ibb"
19+
}

osf_tests/metadata/expected_metadata_files/file_full.turtle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
<http://localhost:5000/w1ibb> a dcterms:Agent,
7171
foaf:Person ;
7272
dcterms:identifier "http://localhost:5000/w1ibb" ;
73+
foaf:givenName "Person" ;
74+
foaf:familyName "McNamington" ;
7375
foaf:name "Person McNamington" .
7476

7577
<http://localhost:5000> a dcterms:Agent,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"@context": "https://schema.org",
3+
"@type": "Dataset",
4+
"creator": [
5+
{
6+
"@type": "Person",
7+
"familyName": "McNamington",
8+
"givenName": "Person",
9+
"name": "Person McNamington"
10+
}
11+
],
12+
"dateCreated": "2123-05-04",
13+
"dateModified": "2123-05-04",
14+
"description": "No description was included in this Dataset collected from the OSF",
15+
"identifier": [
16+
"https://doi.org/11.pp/FK2osf.io/w4ibb_v1",
17+
"http://localhost:5000/w4ibb"
18+
],
19+
"keywords": [],
20+
"license": [],
21+
"name": "this is a preprint title!",
22+
"publisher": {
23+
"@type": "Organization",
24+
"name": "Center For Open Science"
25+
},
26+
"url": "http://localhost:5000/w4ibb"
27+
}

osf_tests/metadata/expected_metadata_files/preprint_basic.turtle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
<http://localhost:5000/w1ibb> a dcterms:Agent,
7676
foaf:Person ;
7777
dcterms:identifier "http://localhost:5000/w1ibb" ;
78+
foaf:givenName "Person" ;
79+
foaf:familyName "McNamington" ;
7880
foaf:name "Person McNamington" .
7981

8082
<http://localhost:8000/v2/providers/preprints/preprovi/subjects/> a skos:ConceptScheme ;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"@context": "https://schema.org",
3+
"@type": "Dataset",
4+
"creator": [
5+
{
6+
"@type": "Person",
7+
"familyName": "McNamington",
8+
"givenName": "Person",
9+
"name": "Person McNamington"
10+
}
11+
],
12+
"dateCreated": "2123-05-04",
13+
"dateModified": "2123-05-04",
14+
"description": "No description was included in this Dataset collected from the OSF",
15+
"identifier": [
16+
"https://doi.org/11.pp/FK2osf.io/w4ibb_v1",
17+
"http://localhost:5000/w4ibb"
18+
],
19+
"keywords": [],
20+
"license": [],
21+
"name": "this is a preprint title!",
22+
"publisher": {
23+
"@type": "Organization",
24+
"name": "Center For Open Science"
25+
},
26+
"url": "http://localhost:5000/w4ibb"
27+
}

osf_tests/metadata/expected_metadata_files/preprint_full.turtle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
<http://localhost:5000/w1ibb> a dcterms:Agent,
9898
foaf:Person ;
9999
dcterms:identifier "http://localhost:5000/w1ibb" ;
100+
foaf:givenName "Person" ;
101+
foaf:familyName "McNamington" ;
100102
foaf:name "Person McNamington" .
101103

102104
<http://localhost:8000/v2/providers/preprints/preprovi/subjects/> a skos:ConceptScheme ;

0 commit comments

Comments
 (0)