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..e7cad49 100644 --- a/loterre-resolvers/v1/combine.ini +++ b/loterre-resolvers/v1/combine.ini @@ -1,64 +1,55 @@ -# 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 - [assign] -path = localization -value = get('skos$broader.rdf$resource').concat('').filter(Boolean) - -[SKOSPathEnum] -path = localization -label = skos$prefLabel -recursion = true - -[OBJFlatten] -safe = true - -[replace] -path = concept -value = self() - -# 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() - - -[exploding] -id = concept -value = keys - -; 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') +value = fix(_.deburr(String(self.value).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/g, '').toLowerCase())) + +path = loterreID +value = env('loterreID') + +path = primer +value = env('primer') + +# Check if the file is already download +[load] +domain = fix('loterre-vocabulaires').append('-loaded') +path = loterreID +target = isAlreadyDownload + +# if not download, do it and save it +[swing] +test = get('isAlreadyDownload').isEmpty() + +[swing/save] +domain = fix('loterre-vocabulaires').append('-loaded') +path = loterreID + +# Download the vocabulary from URL +[swing/singleton] +file = ./v1/download.ini + +# Build un reverse index from the dowload vocabulary +[swing/singleton] +file = ./v1/compile.ini + +[swing/exchange] +value = self().pick(['id', 'value', 'state']) + +# Search concept in the reverse index file +[debug] +path = value +text = SEARCH + +[load] +path = value +target = value2 +domain = env('loterreID').prepend('loterre-').append('indexes') + + +[debug] +path = value2 +text = FOUND? + +# Transcribe URI and its internal links (broader, narrower) +[expand] +path = value +file = ./v1/transcribe.ini diff --git a/loterre-resolvers/v1/download.ini b/loterre-resolvers/v1/download.ini new file mode 100644 index 0000000..c29b027 --- /dev/null +++ b/loterre-resolvers/v1/download.ini @@ -0,0 +1,34 @@ +[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] +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..d30e671 100644 --- a/loterre-resolvers/v1/process.ini +++ b/loterre-resolvers/v1/process.ini @@ -16,33 +16,21 @@ [use] plugin = basics plugin = analytics +plugin = storage # Flow configuration [JSONParse] separator = * +[debug] +path = value +text = REQUEST + [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') +;cacheName = fix(`post-v1-expand-week-${env('loterreID')}-${env('weekNumber')}`) ; Pour les documents sans résulat, on donne une valeur par défaut [swing] diff --git a/loterre-resolvers/v1/transcribe.ini b/loterre-resolvers/v1/transcribe.ini new file mode 100644 index 0000000..782db77 --- /dev/null +++ b/loterre-resolvers/v1/transcribe.ini @@ -0,0 +1,42 @@ +# Necessary plugins +[use] +plugin = basics +plugin = analytics +plugin = storage + +# Load concept form URI +[load] +domain = env('loterreID').prepend('loterre-').append('concepts') +path = value.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] +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] +domain = env('loterreID').prepend('loterre-').append('concepts') +path = rdf$resource + +[map/exchange] +value = self().pick(['skos$prefLabel', 'rdf$about']) +