Skip to content
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
10 changes: 10 additions & 0 deletions tests/trove/derive/test_osfmap_json_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ class TestOsfmapJsonMiniDeriver(BaseIndexcardDeriverTest):
},
'osfmap-registration': {
"@id": "https://osf.example/2c4st",
"accessService": [{
"@id": "https://osf.example",
"identifier": [{"@value": "https://osf.example"}],
"name": [{"@value": "OSF"}],
"resourceType": [{"@id": "Agent"}, {"@id": "Organization"}],
}],
"resourceType": [
{"@id": "Registration"}
],
Expand Down Expand Up @@ -455,6 +461,10 @@ class TestOsfmapJsonMiniDeriver(BaseIndexcardDeriverTest):
]
}
],
"qualifiedAttribution": [{
"agent": [{"@id": "https://osf.example/bhcjn"}],
"hadRole": [{"@id": "osf:admin-contributor"}],
}],
"archivedAt": [
{"@id": "https://archive.example/details/osf-registrations-2c4st-v1"}
],
Expand Down
34 changes: 3 additions & 31 deletions trove/derive/osfmap_json_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,8 @@
from trove.derive.osfmap_json import OsfmapJsonFullDeriver
from trove.vocab.namespaces import TROVE

INCLUDED_PREDICATE_SET = frozenset({
ns.RDF.type,
ns.DCTERMS.title,
ns.DCTERMS.creator,
ns.DCTERMS.date,
ns.DCTERMS.created,
ns.FOAF.name,
ns.OWL.sameAs,
ns.DCTERMS.conformsTo,
ns.DCTERMS.dateCopyrighted,
ns.DCTERMS.description,
ns.DCTERMS.hasPart,
ns.DCTERMS.isVersionOf,
ns.DCTERMS.modified,
ns.DCTERMS.publisher,
ns.DCTERMS.rights,
ns.DCTERMS.subject,
ns.DCTERMS.isPartOf,
ns.DCTERMS.identifier,
ns.SKOS.inScheme,
ns.SKOS.prefLabel,
ns.OSFMAP.affiliation,
ns.OSFMAP.archivedAt,
ns.DCTERMS.dateAccepted,
ns.DCTERMS.dateModified,
ns.OSFMAP.hostingInstitution,
ns.OSFMAP.keyword,
ns.OSFMAP.fileName,
ns.OSFMAP.filePath,
ns.OSFMAP.isContainedBy
EXCLUDED_PREDICATE_SET = frozenset({
ns.OSFMAP.contains,
})


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

@staticmethod
def _should_keep_predicate(predicate: str) -> bool:
return predicate in INCLUDED_PREDICATE_SET
return predicate not in EXCLUDED_PREDICATE_SET
31 changes: 12 additions & 19 deletions trove/util/trove_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,19 @@ def _gather_attrpaths(cls, queryparams: _qp.QueryparamDict, shorthand: rdf.IriSh
if _fields_params:
_requested: dict[str, list[Propertypath]] = defaultdict(list)
for _param_name, _param_value in _fields_params:
try:
(_typenames,) = filter(bool, _param_name.bracketed_names)
except (IndexError, ValueError):
raise trove_exceptions.InvalidQueryParamName(
f'expected "fields[TYPE]" (with exactly one non-empty bracketed segment)'
f' (got "{_param_name}")'
)
else:
for _type in _qp.split_queryparam_value(_typenames):
_type_key = (
GLOB_PATHSTEP
if _type == GLOB_PATHSTEP
else shorthand.expand_iri(_type)
)
_requested[_type_key].extend(
(
parse_propertypath(_path_value, shorthand)
for _path_value in _qp.split_queryparam_value(_param_value)
)
if _param_name.bracketed_names: # e.g. "fields[TYPE1,TYPE2,TYPE3]=..."
_typenames = _qp.split_queryparam_value(_param_name.bracketed_names[0])
else: # omitted brackets equivalent to "fields[*]" (apply to any type)
_typenames = [GLOB_PATHSTEP]
for _typename in _typenames:
if _typename != GLOB_PATHSTEP:
_typename = shorthand.expand_iri(_typename)
_requested[_typename].extend(
( # list of field paths in query param value
parse_propertypath(_path_value, shorthand)
for _path_value in _qp.split_queryparam_value(_param_value)
)
)
_attrpaths = _attrpaths.with_new(freeze(_requested))
return _attrpaths

Expand Down
8 changes: 4 additions & 4 deletions trove/vocab/osfmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@
literal('isSupplementedBy', language='en'),
},
},
OSFMAP.verifiedLinks: {
OSFMAP.verifiedLink: {
RDF.type: {RDF.Property},
RDFS.label: {
literal('Verified Links', language='en'),
},
JSONAPI_MEMBERNAME: {
literal('verifiedLinks', language='en'),
literal('verifiedLink', language='en'),
},
},
OSFMAP.archivedAt: {
Expand Down Expand Up @@ -572,10 +572,10 @@
literal('accessService', language='en'),
},
},
DCAT.accessUrl: {
DCAT.accessURL: {
RDF.type: {RDF.Property},
JSONAPI_MEMBERNAME: {
literal('accessUrl', language='en'),
literal('accessURL', language='en'),
},
},
OSFMAP.hostingInstitution: {
Expand Down