From 21dd5fff1c1a4b27957847e1842be57f033448b9 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 21 Jun 2024 15:32:28 +0200 Subject: [PATCH] template updated --- .../d4gna_to_catalogue_template.ftl | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/catalogue-binding-plugin/src/test/java/geoportal_to_catalogue/d4gna_to_catalogue_template.ftl b/catalogue-binding-plugin/src/test/java/geoportal_to_catalogue/d4gna_to_catalogue_template.ftl index 77a3d31..11508a9 100644 --- a/catalogue-binding-plugin/src/test/java/geoportal_to_catalogue/d4gna_to_catalogue_template.ftl +++ b/catalogue-binding-plugin/src/test/java/geoportal_to_catalogue/d4gna_to_catalogue_template.ftl @@ -6,6 +6,13 @@ <#assign tags=[]> <#assign extras=[]> +<#function sanitizeString(value)> +<#if value??> + <#return value?trim?replace('\n','')?replace('\"','')> + +<#return ""> + + <#-- Macro to assign Tags --> <#macro assignTag in_tags> <#if in_tags??> @@ -26,7 +33,7 @@ <#assign description = ""/> <#if url??> - <#assign resource = {"name": name, "url": url, "description": description, "format": format}> + <#assign resource = {"name": name, "url": url, "description": sanitizeString(description), "format": format}> <#assign resources = resources + [resource]/> @@ -47,7 +54,11 @@ <#-- Macro to assign Extras field --> <#macro assignExtraField key value asObject> <#if key??> - <#assign extra = {"key": key, "value": value, "asObject": asObject}> +<#assign checkedValue = value/> +<#if key != "spatial"> +<#assign checkedValue = sanitizeString(value)/> + + <#assign extra = {"key": sanitizeString(key), "value": checkedValue, "asObject": asObject}> <#assign extras = extras + [extra]/> @@ -120,17 +131,17 @@ + <#-- Starting document mapping to Catalogue --> - +<#compress> { "name": "${jsonProj._id}", "title": "${theDocument.nome}", "license_id": "CC-BY-SA-4.0", "private": false, - <#assign description = theDocument.introduzione?trim /> - <#assign sanitizedNotes = description?replace("\\n", "")> + <#assign sanitizedNotes = sanitizeString(theDocument.introduzione) /> "notes": "${sanitizedNotes}", <#-- @@ -263,10 +274,10 @@ Starting document mapping to Catalogue <#if theDocument.contestoIndagine??> <#if theDocument.contestoIndagine?is_sequence> <#list theDocument.contestoIndagine as my_extra> - <@assignExtraField key="Definizione del contesto d'indagine" value=my_extra asObject=false> + <@assignExtraField key="Contesto Indagine" value=my_extra asObject=false> <#else> - <@assignExtraField key="Definizione del contesto d'indagine" value=theDocument.contestoIndagine asObject=false> + <@assignExtraField key="Contesto Indagine" value=theDocument.contestoIndagine asObject=false> @@ -281,10 +292,10 @@ Starting document mapping to Catalogue <#if theDocument.cronologiaMacrofase??> <#if theDocument.cronologiaMacrofase?is_sequence> <#list theDocument.cronologiaMacrofase as my_extra> - <@assignExtraField key="Cronologia (Macrofase)" value=my_extra asObject=false> + <@assignExtraField key="Cronologia Macrofase" value=my_extra asObject=false> <#else> - <@assignExtraField key="Cronologia (Macrofase)" value=theDocument.cronologiaMacrofase asObject=false> + <@assignExtraField key="Cronologia Macrofase" value=theDocument.cronologiaMacrofase asObject=false> @@ -304,4 +315,4 @@ Starting document mapping to Catalogue <@buildExtrasFields the_extras=extras> } - +