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

View File

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

View File

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