diff --git a/biblio-tools/v1/wos/fetch.ini b/biblio-tools/v1/wos/fetch.ini index 4aea256..d13c1a2 100644 --- a/biblio-tools/v1/wos/fetch.ini +++ b/biblio-tools/v1/wos/fetch.ini @@ -5,6 +5,9 @@ post.description = Recherche et récuperation dans le Web of science post.summary = Récupération de notices WOS à partir d'un tableau de requetes post.tags.0 = biblio-tools +post.responses.default.content.application/json.example.0.value = { ... } +post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream +post.responses.default.description = une réponse sous forme d'un objet ou n/a pour chaque DOI post.requestBody.content.application/json.example.0.value.databaseId = WOK post.requestBody.content.application/json.example.0.value.usrQuery = TS=(cadmium) post.requestBody.content.application/json.example.0.value.count = 5 diff --git a/loterre-resolvers/v1/9SD/expand.ini b/loterre-resolvers/v1/9SD/expand.ini index 3df12d9..7a7f442 100644 --- a/loterre-resolvers/v1/9SD/expand.ini +++ b/loterre-resolvers/v1/9SD/expand.ini @@ -22,7 +22,7 @@ value = thru(() => new Date()).thru(currentDate => Math.floor((currentDate - (new Date(currentDate.getFullYear(), 0, 1)))/(24 * 60 * 60 * 1000))).thru(days => Math.ceil(days / 7)) path = loterreID -value = fix('2XK') +value = fix('9SD') [delegate] file = ./v1/process.ini diff --git a/loterre-resolvers/v1/9SD/identify.ini b/loterre-resolvers/v1/9SD/identify.ini index 7417a35..f6eefc1 100644 --- a/loterre-resolvers/v1/9SD/identify.ini +++ b/loterre-resolvers/v1/9SD/identify.ini @@ -34,7 +34,7 @@ value = thru(() => new Date()).thru(currentDate => Math.floor((currentDate - (new Date(currentDate.getFullYear(), 0, 1)))/(24 * 60 * 60 * 1000))).thru(days => Math.ceil(days / 7)) path = loterreID -value = fix('2XK') +value = fix('9SD') [delegate] file = ./v1/process.ini diff --git a/loterre-resolvers/v1/P66/identify.ini b/loterre-resolvers/v1/P66/identify.ini index bceb3f9..ddb0970 100644 --- a/loterre-resolvers/v1/P66/identify.ini +++ b/loterre-resolvers/v1/P66/identify.ini @@ -41,7 +41,7 @@ value = thru(() => new Date()).thru(currentDate => Math.floor((currentDate - (new Date(currentDate.getFullYear(), 0, 1)))/(24 * 60 * 60 * 1000))).thru(days => Math.ceil(days / 7)) path = loterreID -value = fix('2XK') +value = fix('P66') [delegate] file = ./v1/process.ini diff --git a/loterre-resolvers/v1/combine.ini b/loterre-resolvers/v1/combine.ini index 592d02f..5077a17 100644 --- a/loterre-resolvers/v1/combine.ini +++ b/loterre-resolvers/v1/combine.ini @@ -1,64 +1,58 @@ -# Context input/output -append = dump?indent=true - -# OpenAPI Documentation - JSON format (dot notation) -post.responses.default.description = Return all objects from XML/SKOS file -post.responses.default.content.application/json.schema.type = array -post.responses.default.content.application/json.schema.items.type = object -post.responses.default.content.application/json.schema.items.properties.id.type = string -post.responses.default.content.application/json.schema.items.properties.value.$ref = #/components/schemas/anyValue -post.summary = Transform XML/SKOS file to array of JSON Objects -post.requestBody.required = true -post.requestBody.content.text/xml.schema.type = string -post.requestBody.content.text/xml.schema.format = binary - -# Necessary plugins -[use] -plugin = basics -plugin = loterre -plugin = analytics - -# Flow configuration -[URLStream] -path = false - -[XMLParse] -separator = /rdf:RDF/skos:Concept - +# STEP 0 : On noramise la valeur à rechercher (de la même manière que l'index a été créé) [assign] -path = localization -value = get('skos$broader.rdf$resource').concat('').filter(Boolean) +path = value +value = fix(_.deburr(String(self.value).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/g, '').toLowerCase())) -[SKOSPathEnum] -path = localization -label = skos$prefLabel -recursion = true +path = loterreID +value = env('loterreID') -[OBJFlatten] -safe = true +# primer contient l'URL à Télécharger (voir download.ini) +path = primer +value = env('primer') -[replace] -path = concept -value = self() +# STEP 1 : On vérifie si le vocabulaire est présent localement +[load] +location = env('location') +domain = fix('loterre-vocabulaires').append('-loaded') +path = loterreID +target = isAlreadyDownload -# select all keys and remove duplicates to avoid ambiguities -path = keys -value = fix(_.get(self, 'skos$prefLabel'), _.get(self, 'skos$altLabel'), _.get(self, 'skos$hiddenLabel')). \ - flatten().\ - filter(o => _.has(o, '$t')).\ - map(o => _.deburr(String(o.$t).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/g, '').toLowerCase())).\ - uniq() +# STEP 1.1 : si il n'est pas présent localement +[swing] +test = get('isAlreadyDownload').isEmpty() +# STEP 1.2 : on mémorise le fait que l'on va en faire une copie local +[swing/save] +location = env('location') +domain = fix('loterre-vocabulaires').append('-loaded') +path = loterreID -[exploding] -id = concept -value = keys +# STEP 1.3 : On télécharge la version distante en XML, on la convertit en JSON et on sauvegarde localement +[swing/singleton] +file = ./v1/download.ini -; invert id & value because of [exploding] which works only by value (not by id) +# STEP 1.4 : Avec la version JSON fraichement généré on construit un index inversé +[swing/singleton] +file = ./v1/compile.ini + +[swing/exchange] +value = self().pick(['id', 'value', 'state']) + +# STEP 2 : On cherche une correspondance dans l'index inversé +[load] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('indexes') +path = value +target = result + [replace] path = id -value = get('value') - -path = value value = get('id') +path = value +value = get('result.value', 'n/a') + +# STEP 2 : si l'index inversé nous donne une URI, avec on va chercher les informations associées +[expand] +path = value +file = ./v1/transcribe.ini diff --git a/loterre-resolvers/v1/compile.ini b/loterre-resolvers/v1/compile.ini new file mode 100644 index 0000000..4655ecb --- /dev/null +++ b/loterre-resolvers/v1/compile.ini @@ -0,0 +1,40 @@ +[use] +plugin = basics +plugin = analytics +plugin = storage + +# build the reverse index +[cast] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('concepts') + +[replace] +path = id +value = get('rdf$about') +# select all keys and remove duplicates to avoid ambiguities +path = value +value = get('indexKeys') + +# create a entry for all keys +[exploding] + +# invert id & value because of [exploding] which works only by value (not by id) +[replace] +path = id +value = get('value') +path = value +value = get('id') + +[debug] +text = INDEX + +[save] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('indexes') +path = id + +[pop] + +[replace] +path = state +value = compile diff --git a/loterre-resolvers/v1/download.ini b/loterre-resolvers/v1/download.ini new file mode 100644 index 0000000..799abbe --- /dev/null +++ b/loterre-resolvers/v1/download.ini @@ -0,0 +1,35 @@ +[use] +plugin = basics +plugin = analytics +plugin = storage + + +# Download the skos and save it +[exchange] +value = get('primer') + +[URLStream] +path = false + +[XMLParse] +separator = /rdf:RDF/skos:Concept + +# build indexKeys (remove duplicates to avoid ambiguities) +[assign] +path = indexKeys +value = fix(_.get(self, 'skos$prefLabel'), _.get(self, 'skos$altLabel'), _.get(self, 'skos$hiddenLabel')). \ + flatten().\ + filter(o => _.has(o, '$t')).\ + map(o => _.deburr(String(o.$t).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/g, '').toLowerCase())).\ + uniq() + +[save] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('concepts') +path = rdf$about + +[pop] + +[replace] +path = state +value = download diff --git a/loterre-resolvers/v1/process.ini b/loterre-resolvers/v1/process.ini index 5785455..a4775ca 100644 --- a/loterre-resolvers/v1/process.ini +++ b/loterre-resolvers/v1/process.ini @@ -16,34 +16,22 @@ [use] plugin = basics plugin = analytics +plugin = storage + +[env] +path = location +value= fix(`${env('TMPDIR', '/tmp')}/databases/${env('loterreID', 'noid')}`) # Flow configuration [JSONParse] separator = * +# On utilise [expand] pour travailler uniqument sur le champ value, sans toucher aux autres champs (si ils existent) [expand] path = value size = 1 -cacheName = fix(`post-v1-expand-week-${env('loterreID')}-${env('weekNumber')}`) - -[expand/assign] -path = value -value = fix(_.deburr(String(self.value).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/g, '').toLowerCase())) - -[expand/combine] -path = value -primer = env('primer') file = ./v1/combine.ini -[expand/remove] -test = get('value.value').isString() - -[expand/replace] -path = id -value = get('id') -path = value -value = get('value.value') - ; Pour les documents sans résulat, on donne une valeur par défaut [swing] test = get('value.rdf$about').isEmpty() diff --git a/loterre-resolvers/v1/transcribe.ini b/loterre-resolvers/v1/transcribe.ini new file mode 100644 index 0000000..799874a --- /dev/null +++ b/loterre-resolvers/v1/transcribe.ini @@ -0,0 +1,45 @@ +# Necessary plugins +[use] +plugin = basics +plugin = analytics +plugin = storage + +# Load concept form URI +[load] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('concepts') +path = value +target = value + +# transcribe broaderConcept +[assign] +path = value.skos$broader +value = get('value.skos$broader').castArray().filter(Boolean) + +[map] +path = value.skos$broader + +[map/load] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('concepts') +path = rdf$resource + +[map/exchange] +value = self().pick(['skos$prefLabel', 'rdf$about']) + +# transcribe narrowerConcept +[assign] +path = value.skos$narrower +value = get('value.skos$narrower').castArray().filter(Boolean) + +[map] +path = value.skos$narrower + +[map/load] +location = env('location') +domain = env('loterreID').prepend('loterre-').append('concepts') +path = rdf$resource + +[map/exchange] +value = self().pick(['skos$prefLabel', 'rdf$about']) +