Tested all stocks

This commit is contained in:
Luca Frosini 2023-04-12 19:05:24 +02:00
parent 83f9a45143
commit ea50d8ae32
3 changed files with 29 additions and 5 deletions

View File

@ -24,13 +24,18 @@ public class FreeMarkerTest {
return new File(resourcesDirectory, "examples/AssessmentUnit");
}
public File getStockExampleDirectory() throws Exception {
File resourcesDirectory = FreeMarker.getResourcesDirectory();
return new File(resourcesDirectory, "examples/Stock");
}
@Test
public void testIt() throws Exception {
FreeMarker freeMarker = new FreeMarker();
Template template = freeMarker.getTemplate("AssessmentUnit.ftl");
File assessmentUnitExamplesDir = getAssessmentUnitExampleDirectory();
File assessmentUnitExamplesDir = getStockExampleDirectory();
for(File json : assessmentUnitExamplesDir.listFiles()) {
ObjectMapper mapper = new ObjectMapper();
Map map = mapper.readValue(json, Map.class);
@ -42,8 +47,10 @@ public class FreeMarkerTest {
* <#assign uri_resolver_base_url="https://data.d4science.org/ctlg/GRSF_Admin">
* <#assign include_sensitive=true>
*/
File out = new File(FreeMarker.getResourcesDirectory(), json.getName());
File outDir = new File(FreeMarker.getResourcesDirectory(), "out");
outDir.delete();
outDir.mkdir();
File out = new File(outDir, json.getName());
out.delete();
Writer writer = new FileWriter(out);

View File

@ -0,0 +1 @@
/Stock/

View File

@ -70,7 +70,7 @@
{
"title" : "${stock_name}",
"license_id": "${license_id}",
"description": "Short Name: ${short_name}\nGRSF Semantic Identifier: ${grsf_semantic_identifier}\nRecord URL: ${record_url}",
"description": "Short Name: ${short_name}\n<#if grsf_semantic_identifier??>GRSF Semantic Identifier: ${grsf_semantic_identifier}\n</#if>Record URL: ${record_url}",
"groups": [
<@group groupname="abundance-level-group" var=abundance_level />
<@group groupname="abundance-level-firms-standard-group" var=firms_standard_abundance_level />
@ -83,7 +83,9 @@
<@group groupname="landing-group" var=landings />
<@group groupname="scientific-advice-group" var=scientific_advice />
<@group groupname="state-and-trend-group" var=state_and_trend_of_marine_resources />
<#if sdg_flag??>
<@group groupname="grsf-sdg-flag-group" var=sdg_flag?c include=sdg_flag />
</#if>
<@group groupname="stock-group" var="OK" sep=""/>
],
"tags" : [
@ -129,9 +131,11 @@
<@metadata key="GRSF Semantic Identifier" namespace="stock_identity" var=grsf_semantic_identifier />
<@metadatalist key="Assessment Area" namespace="stock_identity" list=assessment_area />
<@metadatalist key="Connected Record" namespace="stock_identity" list=connected />
<#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 /> -->
</#if>
<@metadata key="GRSF Type" namespace="stock_identity" var=grsf_type?capitalize />
<@metadatalist key="Similar GRSF Record" namespace="stock_identity" list=similar_grsf_record />
<@metadatalist key="Species" namespace="stock_identity" list=species />
@ -178,13 +182,25 @@
<#-- END of Stock Data Section-->
<#-- Record Info Section -->
<@metadata key="Annotation" var=annotations include=include_sensitive />
<#-- TODO
<#if annotations?? && include_sensitive >
<#list annotations as an>
<@metadata key="Annotation" var=an />
</#list>
</#if>
-->
<@metadata key="Citation" var=citation />
<@metadata key="Domain" var="Stock" />
<#if spatial??>
<@metadata key="spatial" var=spatial?json_string />
</#if>
<@metadata key="GRSF UUID" var=grsf_uuid />
<@metadata key="Record URL" var=record_url />
<#if sdg_flag??>
<@metadata key="SDG Flag" var=sdg_flag?c />
</#if>
<@metadata key="Status of the Record" var=status_grsf_record />
<@metadata key="system:type" var=grsf_type?capitalize sep=""/>
<#-- END of Record Info Section -->