Newer
Older
web-services / affiliations-tools / v1 / expand.ini
@Nicolas Thouvenin Nicolas Thouvenin on 23 Jul 2021 3 KB fix affiliatinos tools for production
# OpenAPI Documentation - JSON format (dot notation)
post.responses.default.description = Return all objects with enrich fields
post.responses.default.content.application/json.schema.$ref =  #/components/schemas/JSONStream
post.summary = Structure one field of each Object as raw affiliation
post.requestBody.required = true
post.requestBody.content.application/json.schema.$ref = #/components/schemas/JSONStream
post.parameters.0.in = query
post.parameters.0.name = path
post.parameters.0.schema.type = string
post.parameters.0.description = The path in each object to struture
post.parameters.1.in = query
post.parameters.1.name = indent
post.parameters.1.schema.type = boolean
post.parameters.1.description = Indent or not the JSON Result

# Necessary plugins
[use]
plugin = basics
plugin = storage
plugin = analytics

# Flow configuration
[JSONParse]
separator = *

# ---------  Découpage du champ  avec libpostal (decoupage en champs)
[expand]
path = value
cacheName = step1
[expand/URLConnect]
url = https://affiliations-libpostal.services.inist.fr/v1/parse
timeout = 10000

# ---------  Enrichissement du resultat libpostal
[expand]
size = 1
cacheName = step2
path = value

[expand/assign]
path = value.value.id
value = get('value.id')

[expand/assign]
path = value
value = get('value.value')

[expand/assign]
path = value.country
value = get('value.country').replace(/\W/g, ' ').trim()

# --------- Création d'un champ Netscity uniqument pour les affiliations françaises
[expand/swing]
path = value.country
test = equal
value =  france

[expand/swing/assign]
path = value.netscity
value = get('value.city').upperCase()

# --------- Enrichissement du champ netscity contenant une ville
[expand/expand]
path = value.netscity
size = 10
cacheName = netscity

[expand/expand/URLConnect]
url = https://affiliations-tools.services.inist.fr/v1/netscity/expand
timeout = 10000

# --------- Selection des informations netscity à conserver
[expand/expand/replace]
path = id
value = get('id')

path = value.id
value = get('id')

path = value.latitude
value = get('value.lat2')

path = value.longitude
value = get('value.lng2')

path = value.province
value = get('value.province')

[expand/assign]
path = value.netscity
value = get('value.netscity.value')

# --------- Enrichissement du champ country avec le vocabulaire 9SD de Loterre
[expand/expand]
path = value.country
size = 10
cacheName = loterre

[expand/expand/URLConnect]
url = https://loterre-resolvers.services.inist.fr/v1/9SD/expand
timeout = 10000

# --------- Selection des informations loterre à conserver
[expand/expand/replace]
path = id
value = get('id')

path = value.id
value = get('id')

path = value.uri
value = get('value.rdf$about')

path = value.code
value = get('value.inist$lodexPlacenameCode/$t')

path = value.latitude
value = get('value.geo$lat/$t')

path = value.longitude
value = get('value.geo$long/$t')

path = value.label
value = get('value.skos$prefLabel').reduce((obj, item) => ((obj[[_.defaultTo(item['xml$lang'],'_')]] = item['$t']), obj), {})

[expand/assign]
path = value.country
value = get('value.country.value')

[dump]
indent = env('indent', false)