diff --git a/biblio-tools/v1/unpaywall/corhal.ini b/biblio-tools/v1/unpaywall/corhal.ini index da78d05..43e120e 100644 --- a/biblio-tools/v1/unpaywall/corhal.ini +++ b/biblio-tools/v1/unpaywall/corhal.ini @@ -37,10 +37,6 @@ path = token value = env('UNPAYWALL_API_KEY') -path = fields -value = fix('') - - # Passage des doi en minuscule pour être compatible unpaywall [assign] path = value @@ -107,7 +103,6 @@ path = value value = self() -[debug] # Croissements des resultats et des dois (avec le champ __id comme clé) [exchange] value = get('output.data.GetByDOI').unionBy(self.input, '__id') diff --git a/biblio-tools/v1/unpaywall/expand.ini b/biblio-tools/v1/unpaywall/expand.ini index 0f5b364..a0b90ee 100644 --- a/biblio-tools/v1/unpaywall/expand.ini +++ b/biblio-tools/v1/unpaywall/expand.ini @@ -37,10 +37,6 @@ path = token value = env('UNPAYWALL_API_KEY') -path = fields -value = fix('') - - # Passage des doi en minuscule pour être compatible unpaywall [assign] path = value @@ -105,7 +101,7 @@ value = get('value') path = value -value = get('value') +value = self() # Croissements des resultats et des dois (avec le champ __id comme clé) [exchange] diff --git a/biblio-tools/v1/unpaywall/is_oa.ini b/biblio-tools/v1/unpaywall/is_oa.ini index dbbaa77..b62c73d 100644 --- a/biblio-tools/v1/unpaywall/is_oa.ini +++ b/biblio-tools/v1/unpaywall/is_oa.ini @@ -18,16 +18,16 @@ post.parameters.0.name = indent post.parameters.0.schema.type = boolean + # Necessary plugins [use] plugin = basics -plugin = analytics -plugin = storage # Flow configuration [JSONParse] separator = * +# Quelques paramètres modifiables si besoin [env] path = size value = 10 @@ -38,67 +38,82 @@ path = token value = env('UNPAYWALL_API_KEY') +# Passage des doi en minuscule pour être compatible unpaywall [assign] path = value value = get('value').toLower() -# Pour traiter par lot on groupe puis on utilise spawn qui crée un buffer par lot +# Début du traitement par lot [group] size = env('size') -[spawn] -[spawn/ungroup] -[spawn/bufferize] +# Création d'une requete graphql avec une liste de DOI +[replace] +path = request.query +value = self().map('value').map(x => JSON.stringify(x)).join(',').thru(allIdentifiers => `{GetByDOI(dois:[${allIdentifiers}]){doi, is_oa}}`) -# On réalise un mapping dynamique sur le champ value (et on sauvegarde les correspondances trouvées) -[spawn/combine] -path = value -default = n/a -primer = get('bufferID') -prepend = buffers -append = transit -#cacheName = post-v1-unpaywall-is_oa +path = input +value = self() -[spawn/combine/group] -size = env('size') - -[spawn/combine/replace] -path = dois -value = self().map('value').map(x => JSON.stringify(x)).join(',') - -# On crée un objet contenant tous les valeurs nécessaire pour créer une requete -[spawn/combine/replace] -path = query -value = fix('{GetByDOI(dois:[', self.dois, ']){doi, is_oa}}').join('') - -[spawn/combine/URLStream] -;url = https://unpaywall.inist.fr/api/graphql +# Envoi de la requete vers le mirroir +[URLFetch] url = http://vpunpaywallmir.intra.inist.fr:59700/api/graphql header = env('token').prepend('x-api-key:') -path = data.GetByDOI.* +path = request +json = true +target = output timeout = 5000 +retries = 3 noerror = false -# On supprime les réponses qui n'ont pas abouties ( -[spawn/combine/drop] -path = is_oa +# Reformatage des résulats (output) +[map] +path = output.data.GetByDOI -# On créé l'object attendu par combine { id, value } pour faire le mapping -[spawn/combine/replace] -path = id +# Suppression des réponses qui n'ont pas abouties +[map/remove] +test = has('is_oa') +reverse = true + +# Création d'un objet reponse +[map/replace] +path = __id value = get('doi').toLower() path = value -value = get('is_oa', 'n/a') +value = get('is_oa') -# On nettoie l'objet en supprimant les champs temporaires -[spawn/exchange] -value = self().omit('bufferID') +# Reformatage des DOIS (input) +[map] +path = input -# On simplifie la structure -[assign] +# Création d'un objet similaire à l'objet reponse +[map/replace] +path = __id +value = get('value') + path = value -value = get('value.value', self.value) +value = self() + +# Croissements des resultats et des dois (avec le champ __id comme clé) +[exchange] +value = get('output.data.GetByDOI').unionBy(self.input, '__id') + +# Fin du traitement par lot +[ungroup] + +# Suppression des champs ajoutés +[exchange] +value = self().omit('__id') + +# On marque les réponses qui n'ont pas abouti +[swing] +test = get('value').isBoolean() +reverse = true + +[swing/assign] +path = value +value = fix('n/a') [dump] indent = env('indent') diff --git a/biblio-tools/v1/unpaywall/works/expand.ini b/biblio-tools/v1/unpaywall/works/expand.ini index 0459011..db0033a 100644 --- a/biblio-tools/v1/unpaywall/works/expand.ini +++ b/biblio-tools/v1/unpaywall/works/expand.ini @@ -40,10 +40,6 @@ path = token value = env('UNPAYWALL_API_KEY') -path = fields -value = fix('') - - # Passage des doi en minuscule pour être compatible unpaywall [assign] path = value