gbv / wikidata-jskos

Access Wikidata in JSKOS format
https://coli-conc.gbv.de/services/wikidata/
MIT License
7 stars 3 forks source link

If mappings are requested with a fromScheme that is not Wikidata, mappings are still returned #63

Closed stefandesu closed 4 years ago

stefandesu commented 4 years ago

fromScheme basically seems to get ignored. For example, if you query mappings from DDC to BK, you'll get WD to BK mappings. In my opinion, these requests should return no mapping at all.

stefandesu commented 4 years ago

Hmm, we have https://github.com/gbv/wikidata-jskos/blob/5311646386821a144c72ac2431f70661d10587ec/lib/queries/get-mappings-from.js#L12 and https://github.com/gbv/wikidata-jskos/blob/5311646386821a144c72ac2431f70661d10587ec/lib/queries/get-mappings-to.js#L8, but still get a result.

Here is an example query: https://coli-conc.gbv.de/services/wikidata/mappings?fromScheme=http:%2F%2Fdewey.info%2Fscheme%2Fedition%2Fe23%2F&toScheme=http:%2F%2Furi.gbv.de%2Fterminology%2Fbk%2F&partOf=http:%2F%2Fcoli-conc.gbv.de%2Fconcordances%2Fddc_rvk_math&limit=3

(partOf is also ignored, by the way)

stefandesu commented 4 years ago

Found it:

https://github.com/gbv/wikidata-jskos/blob/5311646386821a144c72ac2431f70661d10587ec/lib/wikidata-service.js#L66-L68

This is setting query.fromScheme to null, thus making the query as if there was no fromScheme at all.

stefandesu commented 4 years ago

@nichtich, would a solution like this be okay?

if (query.fromScheme) {
  query.fromScheme = this.detectWikidataConceptScheme(query.fromScheme)
  // Return empty list if incompatible scheme is queried
  if (!query.fromScheme) {
    return Promise.resolve([]) 
  }
}

Same thing for toScheme. And should we also mitigate the partOf issue, i.e. returning an empty array if partOf is present on the query?