diff --git a/loterre-resolver/examples.http b/loterre-resolver/examples.http deleted file mode 100644 index 3042be3..0000000 --- a/loterre-resolver/examples.http +++ /dev/null @@ -1,11 +0,0 @@ -# 9SD/expand -POST https://loterre-resolver.services.inist.fr/v1/9SD/expand?indent=true HTTP/1.1 -Content-Type: application/json - -[ - { "value": "Pérou" }, - { "value": "Pays de la Loire" }, - { "value": "Grand-Duché de Luxembourg" }, - { "value": "CAN"} -] -### diff --git a/loterre-resolver/v1/9SD/9SD.xml.gz b/loterre-resolver/v1/9SD/9SD.xml.gz deleted file mode 100644 index be3828c..0000000 --- a/loterre-resolver/v1/9SD/9SD.xml.gz +++ /dev/null Binary files differ diff --git a/loterre-resolver/v1/9SD/combine.ini b/loterre-resolver/v1/9SD/combine.ini deleted file mode 100644 index 6530441..0000000 --- a/loterre-resolver/v1/9SD/combine.ini +++ /dev/null @@ -1,29 +0,0 @@ -# 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 = Fetch all enrichments -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 enrcih with a SKOS Cocnept -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 - -[use] -plugin = analytics - -[exchange] -value = 9SD.xml.gz - -[files] - -[delegate] -file = ./v1/combine.ini - -[dump] -indent = env('indent', false) - diff --git a/loterre-resolver/v1/9SD/expand.ini b/loterre-resolver/v1/9SD/expand.ini deleted file mode 100644 index bbbf438..0000000 --- a/loterre-resolver/v1/9SD/expand.ini +++ /dev/null @@ -1,21 +0,0 @@ -# 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 = Enrich on field of each Object with a SKOS concept -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 enrcih with a SKOS Cocnept -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 - -[env] -path = primer -value = ./9SD.xml.gz - -[delegate] -file = ./v1/expand.ini diff --git a/loterre-resolver/v1/combine.ini b/loterre-resolver/v1/combine.ini deleted file mode 100644 index 23e5f42..0000000 --- a/loterre-resolver/v1/combine.ini +++ /dev/null @@ -1,55 +0,0 @@ -# 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 -[TXTZip] -unzip = true - -[XMLParse] -separator = /rdf:RDF/skos:Concept - -[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 =>_.lowerCase(_.trim((o.$t)))).\ - reduce((accumulator, value, key, collection) => (_.indexOf(collection, value) >= 0 ? accumulator.concat(value) : accumulator), []) - - -[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') - diff --git a/loterre-resolver/v1/expand.ini b/loterre-resolver/v1/expand.ini deleted file mode 100644 index 4889563..0000000 --- a/loterre-resolver/v1/expand.ini +++ /dev/null @@ -1,42 +0,0 @@ -# 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 = Enrich on field of each Object with a SKOS concept -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 enrcih with a SKOS Cocnept -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 = analytics -plugin = storage - -# Flow configuration -[JSONParse] -separator = * - -[expand] -path = value -size = 1 -cacheName = env('primer') - -[expand/assign] -path = value -value = get('value').lowerCase() - -[expand/combine] -path = value -primer = env('primer') -prepend = files -file = ./v1/combine.ini - -[dump] -indent = env('indent', false) diff --git a/loterre-resolvers/examples.http b/loterre-resolvers/examples.http new file mode 100644 index 0000000..50ae6c3 --- /dev/null +++ b/loterre-resolvers/examples.http @@ -0,0 +1,11 @@ +# 9SD/expand +POST https://loterre-resolvers.services.inist.fr/v1/9SD/expand?indent=true HTTP/1.1 +Content-Type: application/json + +[ + { "value": "Pérou" }, + { "value": "Pays de la Loire" }, + { "value": "Grand-Duché de Luxembourg" }, + { "value": "CAN"} +] +### diff --git a/loterre-resolvers/v1/9SD/9SD.xml.gz b/loterre-resolvers/v1/9SD/9SD.xml.gz new file mode 100644 index 0000000..be3828c --- /dev/null +++ b/loterre-resolvers/v1/9SD/9SD.xml.gz Binary files differ diff --git a/loterre-resolvers/v1/9SD/combine.ini b/loterre-resolvers/v1/9SD/combine.ini new file mode 100644 index 0000000..6530441 --- /dev/null +++ b/loterre-resolvers/v1/9SD/combine.ini @@ -0,0 +1,29 @@ +# 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 = Fetch all enrichments +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 enrcih with a SKOS Cocnept +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 + +[use] +plugin = analytics + +[exchange] +value = 9SD.xml.gz + +[files] + +[delegate] +file = ./v1/combine.ini + +[dump] +indent = env('indent', false) + diff --git a/loterre-resolvers/v1/9SD/expand.ini b/loterre-resolvers/v1/9SD/expand.ini new file mode 100644 index 0000000..bbbf438 --- /dev/null +++ b/loterre-resolvers/v1/9SD/expand.ini @@ -0,0 +1,21 @@ +# 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 = Enrich on field of each Object with a SKOS concept +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 enrcih with a SKOS Cocnept +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 + +[env] +path = primer +value = ./9SD.xml.gz + +[delegate] +file = ./v1/expand.ini diff --git a/loterre-resolvers/v1/combine.ini b/loterre-resolvers/v1/combine.ini new file mode 100644 index 0000000..23e5f42 --- /dev/null +++ b/loterre-resolvers/v1/combine.ini @@ -0,0 +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 +[TXTZip] +unzip = true + +[XMLParse] +separator = /rdf:RDF/skos:Concept + +[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 =>_.lowerCase(_.trim((o.$t)))).\ + reduce((accumulator, value, key, collection) => (_.indexOf(collection, value) >= 0 ? accumulator.concat(value) : accumulator), []) + + +[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') + diff --git a/loterre-resolvers/v1/expand.ini b/loterre-resolvers/v1/expand.ini new file mode 100644 index 0000000..4889563 --- /dev/null +++ b/loterre-resolvers/v1/expand.ini @@ -0,0 +1,42 @@ +# 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 = Enrich on field of each Object with a SKOS concept +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 enrcih with a SKOS Cocnept +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 = analytics +plugin = storage + +# Flow configuration +[JSONParse] +separator = * + +[expand] +path = value +size = 1 +cacheName = env('primer') + +[expand/assign] +path = value +value = get('value').lowerCase() + +[expand/combine] +path = value +primer = env('primer') +prepend = files +file = ./v1/combine.ini + +[dump] +indent = env('indent', false)