diff --git a/src/test/resources/freemarker/Fishery.ftl b/src/test/resources/freemarker/Fishery.ftl index b1be329..9be79fb 100644 --- a/src/test/resources/freemarker/Fishery.ftl +++ b/src/test/resources/freemarker/Fishery.ftl @@ -2,10 +2,11 @@ <#assign groupList = [] > <#assign tagList = [] > -<#macro group groupname var="" include=true sep=","> +<#macro group name title var="" include=true sep=","> <#if var?has_content && include> { - "name": "${groupname}" + "name": "${name}", + "title": "${title}" }${sep} @@ -79,14 +80,15 @@ <#if timeseries?has_content && .data_model[timeseries]??> <#assign timeseriesList += [{"property":"${timeseries}","filename":"${key}"}]> <#if groupname?has_content> - <#assign groupList += ["${groupname}"]> + <#assign groupList += [{"name":"${groupname}", "title":"${key}"}] > <#if include> <#local list = .data_model[timeseries] > + <#assign valueSep = "" > <#list list[0..*5] as ts> { "key": "<#if namespace?has_content>${namespace}:${key}", - "value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string} - <#if ts.reporting_year_or_assessment_id?has_content>Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string} - <#if ts.reference_year?has_content>Ref. Year: ${ts.reference_year?json_string} - <#if ts.data_owner?has_content>Data Owner: ${ts.data_owner?json_string} - <#if ts.db_source?has_content>DB Source: ${ts.db_source?json_string}]" + "value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string}<#assign valueSep = " - " ><#if ts.reporting_year_or_assessment_id?has_content>${valueSep}Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string}<#assign valueSep = " - " ><#if ts.reference_year?has_content>${valueSep}Ref. Year: ${ts.reference_year?json_string}<#assign valueSep = " - " ><#if ts.data_owner?has_content>${valueSep}Data Owner: ${ts.data_owner?json_string}<#assign valueSep = " - " ><#if ts.db_source?has_content>${valueSep}DB Source: ${ts.db_source?json_string}]" }${sep} @@ -124,6 +126,7 @@ <#-- START of Common Metadata --> <@metadata key="GRSF Type" namespace="fishery_identity" var=grsf_type?capitalize /> <@metadata key="Short Name" namespace="fishery_identity" var=short_name /> + <#if database_sources??> <@metadatalist key="Database Source" namespace="fishery_identity" list=database_sources?map(database_source -> database_source.name) /> <#-- database_sources will change from list of objects to list of string. Use the line below in place of the line above--> <#-- <@metadatalist key="Database Source" namespace="fishery_identity" list=database_sources /> --> @@ -133,17 +136,17 @@ <@metadatalist key="Connected Fishery Record" namespace="fishery_identity" list=connected /> <@metadatalist key="Data Owner" namespace="fishery_data" list=data_owner include=include_sensitive /> - <#if database_sources??> <@timeseries key="Catch" namespace="fishery_data" timeseries="catches" groupname="catch-group" /> <@timeseries key="Landing" namespace="fishery_data" timeseries="landings" groupname="landing-group" /> <#if sdg_flag??> - <@metadata key="SDG Flag" var=sdg_flag?c /> + <@metadata key="SDG Flag" var=sdg_flag?c /> <#if sdg_flag> - <#assign groupList += ["grsf-sdg-flag-group"]> + <#assign groupList += [{"name":"grsf-sdg-flag-group", "title":"GRSF SDG Flag"}] > + <@metadata key="Status of the Record" var=status_grsf_record /> <@metadata key="spatial" var=spatial /> <@metadata key="Domain" var="Fishery" /> @@ -158,7 +161,7 @@ <#if traceability_flag??> <@metadata key="Traceability Flag" var=traceability_flag?c /> <#if traceability_flag> - <#assign groupList += ["grsf-traceability-flag-group"]> + <#assign groupList += [{"name":"grsf-traceability-flag-group", "title":"GRSF Traceability Flag"}] > <@metadatalist key="Fishing Area" namespace="fishery_identity" list=fishing_area tagValues=true /> @@ -174,14 +177,15 @@ <@metadata key="system:type" var=grsf_type?capitalize sep=""/> ], "groups": [ - <#list groupList as groupname> + <#list groupList as group> { - "name": "${groupname}" + "name": "${group.name}", + "title": "${group.title}" }, - <@group groupname="assessment-method-group" var=assessment_methods /> - <@group groupname="scientific-advice-group" var=scientific_advice /> - <@group groupname="fishery-group" var="OK" sep=""/> + <@group name="assessment-method-group" title="Assessment Method" var=assessment_methods /> + <@group name="scientific-advice-group" title="Scientific Advice" var=scientific_advice /> + <@group name="fishery-group" title="Fishery" var="OK" sep=""/> ], "tags": [ <#list tagList as tag> diff --git a/src/test/resources/freemarker/Stock.ftl b/src/test/resources/freemarker/Stock.ftl index f6e4d98..ad466ad 100644 --- a/src/test/resources/freemarker/Stock.ftl +++ b/src/test/resources/freemarker/Stock.ftl @@ -2,10 +2,11 @@ <#assign groupList = [] > <#assign tagList = [] > -<#macro group groupname var="" include=true sep=","> +<#macro group name title var="" include=true sep=","> <#if var?has_content && include> { - "name": "${groupname}" + "name": "${name}", + "title": "${title}" }${sep} @@ -79,14 +80,15 @@ <#if timeseries?has_content && .data_model[timeseries]??> <#assign timeseriesList += [{"property":"${timeseries}","filename":"${key}"}]> <#if groupname?has_content> - <#assign groupList += ["${groupname}"]> + <#assign groupList += [{"name":"${groupname}", "title":"${key}"}] > <#if include> - <#local list = .data_model[timeseries] > + <#assign list = .data_model[timeseries] > + <#assign valueSep = "" > <#list list[0..*5] as ts> { "key": "<#if namespace?has_content>${namespace}:${key}", - "value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string} - <#if ts.reporting_year_or_assessment_id?has_content>Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string} - <#if ts.reference_year?has_content>Ref. Year: ${ts.reference_year?json_string} - <#if ts.data_owner?has_content>Data Owner: ${ts.data_owner?json_string} - <#if ts.db_source?has_content>DB Source: ${ts.db_source?json_string}]" + "value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string}<#assign valueSep = " - " ><#if ts.reporting_year_or_assessment_id?has_content>${valueSep}Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string}<#assign valueSep = " - " ><#if ts.reference_year?has_content>${valueSep}Ref. Year: ${ts.reference_year?json_string}<#assign valueSep = " - " ><#if ts.data_owner?has_content>${valueSep}Data Owner: ${ts.data_owner?json_string}<#assign valueSep = " - " ><#if ts.db_source?has_content>${valueSep}DB Source: ${ts.db_source?json_string}]" }${sep} @@ -124,6 +126,7 @@ <#-- START of Common Metadata --> <@metadata key="GRSF Type" namespace="stock_identity" var=grsf_type?capitalize /> <@metadata key="Short Name" namespace="stock_identity" var=short_name /> + <#if database_sources??> <@metadatalist key="Database Source" namespace="stock_identity" list=database_sources?map(database_source -> database_source.name) /> <#-- database_sources will change from list of objects to list of string. Use the line below in place of the line above--> <#-- <@metadatalist key="Database Source" namespace="stock_identity" list=database_sources /> --> @@ -133,7 +136,6 @@ <@metadatalist key="Connected Stock Record" namespace="stock_identity" list=connected /> <@metadatalist key="Data Owner" namespace="stock_data" list=data_owner include=include_sensitive /> - <#if database_sources??> <@timeseries key="Catch" namespace="stock_data" timeseries="catches" groupname="catch-group" /> <@timeseries key="Landing" namespace="stock_data" timeseries="landings" groupname="landing-group" /> @@ -141,7 +143,7 @@ <#if sdg_flag??> <@metadata key="SDG Flag" var=sdg_flag?c /> <#if sdg_flag> - <#assign groupList += ["grsf-sdg-flag-group"]> + <#assign groupList += [{"name":"grsf-sdg-flag-group", "title":"GRSF SDG Flag"}] > <@metadata key="Status of the Record" var=status_grsf_record /> @@ -198,15 +200,16 @@ <@metadata key="system:type" var=grsf_type?capitalize sep=""/> ], "groups": [ - <#list groupList as groupname> + <#list groupList as group> { - "name": "${groupname}" + "name": "${group.name}", + "title": "${group.title}" }, <#-- <@groupFromRefersTo var=refers_to /> --> - <@group groupname="assessment-method-group" var=assessment_methods /> - <@group groupname="scientific-advice-group" var=scientific_advice /> - <@group groupname="stock-group" var="OK" sep=""/> + <@group name="assessment-method-group" title="Assessment Method" var=assessment_methods /> + <@group name="scientific-advice-group" title="Scientific Advice" var=scientific_advice /> + <@group name="stock-group" title="Stock" var="OK" sep=""/> ], "tags": [ <#list tagList as tag> @@ -256,4 +259,4 @@ }<#sep>, ] -} \ No newline at end of file +} diff --git a/src/test/resources/freemarker/TraceabilityUnit.ftl b/src/test/resources/freemarker/TraceabilityUnit.ftl index 29fe1d0..e90d2a7 100644 --- a/src/test/resources/freemarker/TraceabilityUnit.ftl +++ b/src/test/resources/freemarker/TraceabilityUnit.ftl @@ -2,14 +2,28 @@ <#assign groupList = [] > <#assign tagList = [] > -<#macro group groupname var="" include=true sep=","> +<#macro group name title var="" include=true sep=","> <#if var?has_content && include> { - "name": "${groupname}" + "name": "${name}", + "title": "${title}" }${sep} +<#-- +<#macro groupFromRefersTo var="" include=true sep=","> + <#if var?has_content && include> + <#list var as elem> + { + TODO neeed a Switch case + "name": "${elem.name}" + }${sep} + + + +--> + <#macro tag tagname="" include=true sep=","> <#if tagname?has_content && include> { @@ -66,14 +80,15 @@ <#if timeseries?has_content && .data_model[timeseries]??> <#assign timeseriesList += [{"property":"${timeseries}","filename":"${key}"}]> <#if groupname?has_content> - <#assign groupList += ["${groupname}"]> + <#assign groupList += [{"name":"${groupname}", "title":"${key}"}] > <#if include> <#local list = .data_model[timeseries] > + <#local valueSep = "" > <#list list[0..*5] as ts> { "key": "<#if namespace?has_content>${namespace}:${key}", - "value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string} - <#if ts.reporting_year_or_assessment_id?has_content>Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string} - <#if ts.reference_year?has_content>Ref. Year: ${ts.reference_year?json_string} - <#if ts.data_owner?has_content>Data Owner: ${ts.data_owner?json_string} - <#if ts.db_source?has_content>DB Source: ${ts.db_source?json_string}]" + "value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string}<#assign valueSep = " - " ><#if ts.reporting_year_or_assessment_id?has_content>${valueSep}Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string}<#assign valueSep = " - " ><#if ts.reference_year?has_content>${valueSep}Ref. Year: ${ts.reference_year?json_string}<#assign valueSep = " - " ><#if ts.data_owner?has_content>${valueSep}Data Owner: ${ts.data_owner?json_string}<#assign valueSep = " - " ><#if ts.db_source?has_content>${valueSep}DB Source: ${ts.db_source?json_string}]" }${sep} @@ -132,12 +147,13 @@ <@metadata key="system:type" var="Traceability Unit" sep=""/> ], "groups": [ - <#list groupList as groupname> + <#list groupList as group> { - "name": "${groupname}" + "name": "${group.name}", + "title": "${group.title}" }, - <@group groupname="traceability-unit-group" var="OK" sep=""/> + <@group name="traceability-unit-group" title="Traceability Unit" var="OK" sep=""/> ], "tags": [ <#list tagList as tag>