Improved templates

This commit is contained in:
Luca Frosini 2023-04-17 14:47:41 +02:00
parent 9d13eb6d8d
commit 828c600b96
3 changed files with 56 additions and 33 deletions

View File

@ -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}
</#if>
</#macro>
@ -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>
<#if include>
<#local list = .data_model[timeseries] >
<#assign valueSep = "" >
<#list list[0..*5] as ts>
{
"key": "<#if namespace?has_content>${namespace}:</#if>${key}",
"value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string} - </#if><#if ts.reporting_year_or_assessment_id?has_content>Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string} - </#if><#if ts.reference_year?has_content>Ref. Year: ${ts.reference_year?json_string} - </#if><#if ts.data_owner?has_content>Data Owner: ${ts.data_owner?json_string} - </#if><#if ts.db_source?has_content>DB Source: ${ts.db_source?json_string}</#if>]"
"value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string}<#assign valueSep = " - " ></#if><#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><#if ts.reference_year?has_content>${valueSep}Ref. Year: ${ts.reference_year?json_string}<#assign valueSep = " - " ></#if><#if ts.data_owner?has_content>${valueSep}Data Owner: ${ts.data_owner?json_string}<#assign valueSep = " - " ></#if><#if ts.db_source?has_content>${valueSep}DB Source: ${ts.db_source?json_string}</#if>]"
}${sep}
</#list>
</#if>
@ -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"}] >
</#if>
</#if>
<@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"}] >
</#if>
</#if>
<@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}"
},
</#list>
<@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>

View File

@ -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}
</#if>
</#macro>
@ -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>
<#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}:</#if>${key}",
"value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string} - </#if><#if ts.reporting_year_or_assessment_id?has_content>Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string} - </#if><#if ts.reference_year?has_content>Ref. Year: ${ts.reference_year?json_string} - </#if><#if ts.data_owner?has_content>Data Owner: ${ts.data_owner?json_string} - </#if><#if ts.db_source?has_content>DB Source: ${ts.db_source?json_string}</#if>]"
"value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string}<#assign valueSep = " - " ></#if><#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><#if ts.reference_year?has_content>${valueSep}Ref. Year: ${ts.reference_year?json_string}<#assign valueSep = " - " ></#if><#if ts.data_owner?has_content>${valueSep}Data Owner: ${ts.data_owner?json_string}<#assign valueSep = " - " ></#if><#if ts.db_source?has_content>${valueSep}DB Source: ${ts.db_source?json_string}</#if>]"
}${sep}
</#list>
</#if>
@ -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"}] >
</#if>
</#if>
<@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}"
},
</#list>
<#-- <@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>,</#sep>
</#list>
]
}
}

View File

@ -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}
</#if>
</#macro>
<#--
<#macro groupFromRefersTo var="" include=true sep=",">
<#if var?has_content && include>
<#list var as elem>
{
TODO neeed a Switch case
"name": "${elem.name}"
}${sep}
</#list>
</#if>
</#macro>
-->
<#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>
<#if include>
<#local list = .data_model[timeseries] >
<#local valueSep = "" >
<#list list[0..*5] as ts>
{
"key": "<#if namespace?has_content>${namespace}:</#if>${key}",
"value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string} - </#if><#if ts.reporting_year_or_assessment_id?has_content>Rep. Year or Assessment ID: ${ts.reporting_year_or_assessment_id?json_string} - </#if><#if ts.reference_year?has_content>Ref. Year: ${ts.reference_year?json_string} - </#if><#if ts.data_owner?has_content>Data Owner: ${ts.data_owner?json_string} - </#if><#if ts.db_source?has_content>DB Source: ${ts.db_source?json_string}</#if>]"
"value": "${ts.value?json_string} [<#if ts.unit?has_content>Unit: ${ts.unit?json_string}<#assign valueSep = " - " ></#if><#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><#if ts.reference_year?has_content>${valueSep}Ref. Year: ${ts.reference_year?json_string}<#assign valueSep = " - " ></#if><#if ts.data_owner?has_content>${valueSep}Data Owner: ${ts.data_owner?json_string}<#assign valueSep = " - " ></#if><#if ts.db_source?has_content>${valueSep}DB Source: ${ts.db_source?json_string}</#if>]"
}${sep}
</#list>
</#if>
@ -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}"
},
</#list>
<@group groupname="traceability-unit-group" var="OK" sep=""/>
<@group name="traceability-unit-group" title="Traceability Unit" var="OK" sep=""/>
],
"tags": [
<#list tagList as tag>