Skip to content

Commit dda84a2

Browse files
authored
Merge pull request #878 from aaxelb/fix/osfmap-mismatches
[ENG-8287] Fix/osfmap mismatches
2 parents 2a1e49d + 82b3d5e commit dda84a2

File tree

4 files changed

+29
-54
lines changed

4 files changed

+29
-54
lines changed

tests/trove/derive/test_osfmap_json_mini.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class TestOsfmapJsonMiniDeriver(BaseIndexcardDeriverTest):
154154
},
155155
'osfmap-registration': {
156156
"@id": "https://osf.example/2c4st",
157+
"accessService": [{
158+
"@id": "https://osf.example",
159+
"identifier": [{"@value": "https://osf.example"}],
160+
"name": [{"@value": "OSF"}],
161+
"resourceType": [{"@id": "Agent"}, {"@id": "Organization"}],
162+
}],
157163
"resourceType": [
158164
{"@id": "Registration"}
159165
],
@@ -455,6 +461,10 @@ class TestOsfmapJsonMiniDeriver(BaseIndexcardDeriverTest):
455461
]
456462
}
457463
],
464+
"qualifiedAttribution": [{
465+
"agent": [{"@id": "https://osf.example/bhcjn"}],
466+
"hadRole": [{"@id": "osf:admin-contributor"}],
467+
}],
458468
"archivedAt": [
459469
{"@id": "https://archive.example/details/osf-registrations-2c4st-v1"}
460470
],

trove/derive/osfmap_json_mini.py

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,8 @@
22
from trove.derive.osfmap_json import OsfmapJsonFullDeriver
33
from trove.vocab.namespaces import TROVE
44

5-
INCLUDED_PREDICATE_SET = frozenset({
6-
ns.RDF.type,
7-
ns.DCTERMS.title,
8-
ns.DCTERMS.creator,
9-
ns.DCTERMS.date,
10-
ns.DCTERMS.created,
11-
ns.FOAF.name,
12-
ns.OWL.sameAs,
13-
ns.DCTERMS.conformsTo,
14-
ns.DCTERMS.dateCopyrighted,
15-
ns.DCTERMS.description,
16-
ns.DCTERMS.hasPart,
17-
ns.DCTERMS.isVersionOf,
18-
ns.DCTERMS.modified,
19-
ns.DCTERMS.publisher,
20-
ns.DCTERMS.rights,
21-
ns.DCTERMS.subject,
22-
ns.DCTERMS.isPartOf,
23-
ns.DCTERMS.identifier,
24-
ns.SKOS.inScheme,
25-
ns.SKOS.prefLabel,
26-
ns.OSFMAP.affiliation,
27-
ns.OSFMAP.archivedAt,
28-
ns.DCTERMS.dateAccepted,
29-
ns.DCTERMS.dateModified,
30-
ns.OSFMAP.hostingInstitution,
31-
ns.OSFMAP.keyword,
32-
ns.OSFMAP.fileName,
33-
ns.OSFMAP.filePath,
34-
ns.OSFMAP.isContainedBy
5+
EXCLUDED_PREDICATE_SET = frozenset({
6+
ns.OSFMAP.contains,
357
})
368

379

@@ -57,4 +29,4 @@ def convert_tripledict(self):
5729

5830
@staticmethod
5931
def _should_keep_predicate(predicate: str) -> bool:
60-
return predicate in INCLUDED_PREDICATE_SET
32+
return predicate not in EXCLUDED_PREDICATE_SET

trove/util/trove_params.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,19 @@ def _gather_attrpaths(cls, queryparams: _qp.QueryparamDict, shorthand: rdf.IriSh
100100
if _fields_params:
101101
_requested: dict[str, list[Propertypath]] = defaultdict(list)
102102
for _param_name, _param_value in _fields_params:
103-
try:
104-
(_typenames,) = filter(bool, _param_name.bracketed_names)
105-
except (IndexError, ValueError):
106-
raise trove_exceptions.InvalidQueryParamName(
107-
f'expected "fields[TYPE]" (with exactly one non-empty bracketed segment)'
108-
f' (got "{_param_name}")'
109-
)
110-
else:
111-
for _type in _qp.split_queryparam_value(_typenames):
112-
_type_key = (
113-
GLOB_PATHSTEP
114-
if _type == GLOB_PATHSTEP
115-
else shorthand.expand_iri(_type)
116-
)
117-
_requested[_type_key].extend(
118-
(
119-
parse_propertypath(_path_value, shorthand)
120-
for _path_value in _qp.split_queryparam_value(_param_value)
121-
)
103+
if _param_name.bracketed_names: # e.g. "fields[TYPE1,TYPE2,TYPE3]=..."
104+
_typenames = _qp.split_queryparam_value(_param_name.bracketed_names[0])
105+
else: # omitted brackets equivalent to "fields[*]" (apply to any type)
106+
_typenames = [GLOB_PATHSTEP]
107+
for _typename in _typenames:
108+
if _typename != GLOB_PATHSTEP:
109+
_typename = shorthand.expand_iri(_typename)
110+
_requested[_typename].extend(
111+
( # list of field paths in query param value
112+
parse_propertypath(_path_value, shorthand)
113+
for _path_value in _qp.split_queryparam_value(_param_value)
122114
)
115+
)
123116
_attrpaths = _attrpaths.with_new(freeze(_requested))
124117
return _attrpaths
125118

trove/vocab/osfmap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@
356356
literal('isSupplementedBy', language='en'),
357357
},
358358
},
359-
OSFMAP.verifiedLinks: {
359+
OSFMAP.verifiedLink: {
360360
RDF.type: {RDF.Property},
361361
RDFS.label: {
362362
literal('Verified Links', language='en'),
363363
},
364364
JSONAPI_MEMBERNAME: {
365-
literal('verifiedLinks', language='en'),
365+
literal('verifiedLink', language='en'),
366366
},
367367
},
368368
OSFMAP.archivedAt: {
@@ -572,10 +572,10 @@
572572
literal('accessService', language='en'),
573573
},
574574
},
575-
DCAT.accessUrl: {
575+
DCAT.accessURL: {
576576
RDF.type: {RDF.Property},
577577
JSONAPI_MEMBERNAME: {
578-
literal('accessUrl', language='en'),
578+
literal('accessURL', language='en'),
579579
},
580580
},
581581
OSFMAP.hostingInstitution: {

0 commit comments

Comments
 (0)