Newer
Older
web-services / affiliations-tools / v1 / expand.ini
@Nicolas Thouvenin Nicolas Thouvenin on 14 Jun 2021 3 KB import legacy ws
# 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
cache = boost
[expand/URLConnect]
url = https://ws-libpostal.sandbox.istex.fr/parse/expand
timeout = 5000

# ---------  Enrichissement du resultat libpostal
[expand]
size = 1
cache = boost
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/combine]
persistent = true
path = value.netscity

[expand/combine/URLStream]
url = https://ws-netscity.sandbox.istex.fr/combine
timeout = env('timeout', 5000)

# --------- Selection des informations netscity à conserver
[expand/combine/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/combine]
persistent = true
path = value.country
[expand/combine/URLConnect]
url = https://ws-loterre.sandbox.istex.fr/9SD/combine
timeout = env('timeout', 5000)

# --------- Selection des informations loterre à conserver
[expand/combine/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)