diff --git a/biblio-tools/examples.http b/biblio-tools/examples.http index cac4312..c66ca1f 100644 --- a/biblio-tools/examples.http +++ b/biblio-tools/examples.http @@ -180,3 +180,15 @@ { "id":4, "value": ""} ] ### + +# hal/works/expand +POST {{baseUrl}}/v1/hal/works/expand?indent=true HTTP/1.1 +Content-Type: application/json + +[ + { "id":1, "value": "10.1016/S0047-6374(98)00099-2"}, + { "id":2, "value": "10.35562/arabesques.1222"}, + { "id":3, "value": "10.3324/haematol.2016.148908"}, + { "id":4, "value": ""} +] +### diff --git a/biblio-tools/v1/hal/works/expand.ini b/biblio-tools/v1/hal/works/expand.ini new file mode 100644 index 0000000..8867278 --- /dev/null +++ b/biblio-tools/v1/hal/works/expand.ini @@ -0,0 +1,115 @@ +# OpenAPI Documentation - JSON format (dot notation) +mimeType = application/json + +post.operationId = post-v1-crossref-works-expand +post.description = Récupération des métadonnées associées à un DOI dans HAL +post.summary = Récupération à partir d'un tableau d'objets avec à minima un champ value contenant le DOI +post.tags.0 = biblio-tools +post.requestBody.content.application/json.example.0.id = 1 +post.requestBody.content.application/json.example.0.value = 10.35562/arabesques.1222 +post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.requestBody.required = true +post.responses.default.content.application/json.example.0.id = 1 +post.responses.default.content.application/json.example.0.value = { ... } +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.responses.default.description = Les prefixes DOI en version textuel +post.parameters.0.description = Indenter le JSON résultant +post.parameters.0.in = query +post.parameters.0.name = indent +post.parameters.0.schema.type = boolean + +# Necessary plugins +[use] +plugin = basics + +# Flow configuration +[JSONParse] +separator = * + +# Quelques paramètres modifiables si besoin +[env] +path = size +value = 10 + +path = indent +value = true + +# Début du traitement par lot +[group] +size = env('size') + +# Création d'une requete avec une liste d'identifiants +#?q=doiId_s:(10.3324/haematol.2016.148908%20OR%2010.35562/arabesques.1222)&wt=json&fl=label_xml +[replace] +path = output.0.q +value = self().map('value').filter(Boolean).map(JSON.stringify).join(' OR ').thru(allIdentifiers => `doiId_s:(${allIdentifiers})`) + +path = output.0.wt +value = json + +path = output.0.fl +value = label_xml + +path = output.0.rows +value = env('size') + +path = input +value = self() + +[map] +path = output + +# Envoi de la requete +[map/URLStream] +url = https://api.archives-ouvertes.fr/search/ +json = true +path = response.docs.* +timeout = 30000 +retries = 3 +noerror = false + + +# Création d'un objet réponse +[map/exchange] +value = get('label_xml') + +[map/spawn] +[map/spawn/XMLParse] +separator = /TEI +[map/spawn/OBJFlatten] +[map/spawn/replace] +path = id1 +value = get('text/body/listBibl/biblFull/sourceDesc/biblStruct/idno').filter({type: 'doi'}).first().get('$t') + +path = id2 +value = get('text/body/listBibl/biblFull/sourceDesc/biblStruct/idno/$t') + +path = value +value = self() + +[map/spawn/replace] +path = id +value = fix(self.id1, self.id2).filter(Boolean).first() + +path = value +value = get('value') + + +# Croisements des resultats et des dois +[exchange] +value = get('input').map((i) => ({ ...i, value:_.get(_.find(self.output, {id:i.value}), 'value') })) + +# Fin du traitement par lot +[ungroup] + +# On marque les réponses qui n'ont pas abouti +[swing] +test = has('value.xmlns$hal') +reverse = true + +[swing/assign] +path = value +value = fix('n/a') + +[dump] +indent = env('indent', false)