From 8de2b488f6ce31dd6186051c44d19d8b8801e859 Mon Sep 17 00:00:00 2001 From: ebocher Date: Mon, 28 Feb 2022 20:28:36 +0100 Subject: [PATCH] Store the geoclimate version and build number in zone table --- .../org/orbisgis/geoclimate/Geoclimate.groovy | 2 +- geoindicators/pom.xml | 17 +++++++++++ .../orbisgis/geoclimate/Geoindicators.groovy | 30 +++++++++++++++++++ .../WorkflowGeoIndicators.groovy | 8 +++-- .../orbisgis/geoclimate/geoclimate.properties | 2 ++ .../WorkflowGeoIndicatorsTest.groovy | 6 ++++ 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 geoindicators/src/main/resources/org/orbisgis/geoclimate/geoclimate.properties diff --git a/geoclimate/src/main/groovy/org/orbisgis/geoclimate/Geoclimate.groovy b/geoclimate/src/main/groovy/org/orbisgis/geoclimate/Geoclimate.groovy index 8789c7fea1..817ac508d2 100644 --- a/geoclimate/src/main/groovy/org/orbisgis/geoclimate/Geoclimate.groovy +++ b/geoclimate/src/main/groovy/org/orbisgis/geoclimate/Geoclimate.groovy @@ -12,7 +12,7 @@ import java.util.concurrent.Callable */ @CommandLine.Command(name = "Geoclimate", sortOptions = false, - version = "0.1", + version = "0.0.2", mixinStandardHelpOptions = true, description = "Simple command line tool to run Geoclimate algorithms", header = diff --git a/geoindicators/pom.xml b/geoindicators/pom.xml index 0e395a3af9..20fecf4167 100644 --- a/geoindicators/pom.xml +++ b/geoindicators/pom.xml @@ -150,6 +150,23 @@ maven-javadoc-plugin + + + + src/main/resources/ + true + + **/geoclimate.properties + + + + src/main/resources/ + false + + **/geoclimate.properties + + + diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/Geoindicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/Geoindicators.groovy index 9778aecb02..4f0eef2315 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/Geoindicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/Geoindicators.groovy @@ -27,6 +27,7 @@ abstract class Geoindicators extends GroovyProcessFactory { //The whole chain to run the geoindicators public static WorkflowGeoIndicators = new WorkflowGeoIndicators() + static Properties GEOCLIMATE_PROPERTIES //Utility methods static def getUuid(){ @@ -112,4 +113,33 @@ abstract class Geoindicators extends GroovyProcessFactory { static void clearTablesCache(){ System.properties.removeAll {it.key.startsWith("GEOCLIMATE")} } + + /** + * Return the current GeoClimate version + * @return + */ + static def version() { + return geoclimate_property("version") + } + + /** + * Return the current GeoClimate build number + * @return + */ + static def buildNumber() { + return geoclimate_property("build") + } + + /** + * Return geoclimate properties + * @param name + * @return + */ + static def geoclimate_property(String name) { + if(!GEOCLIMATE_PROPERTIES) { + GEOCLIMATE_PROPERTIES = new Properties() + GEOCLIMATE_PROPERTIES.load(Geoindicators.getResourceAsStream("geoclimate.properties")) + } + return GEOCLIMATE_PROPERTIES.get(name) + } } \ No newline at end of file diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index c6bbdcbf13..38d0039f2d 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -1806,8 +1806,10 @@ IProcess computeGeoclimateIndicators() { NB_BLOCK INTEGER, NB_RSU INTEGER, COMPUTATION_TIME INTEGER, - LAST_UPDATE VARCHAR + LAST_UPDATE VARCHAR, VERSION VARCHAR, BUILD_NUMBER VARCHAR )""".toString() + + //Update reporting to the zone table datasource.execute"""update ${zoneTable} set nb_estimated_building = 0, @@ -1815,7 +1817,9 @@ IProcess computeGeoclimateIndicators() { nb_block = ${nbBlock}, nb_rsu = ${nbRSU}, computation_time = ${(System.currentTimeMillis()-start)/1000}, - last_update = CAST(now() AS VARCHAR)""".toString() + last_update = CAST(now() AS VARCHAR), + version = '${Geoindicators.version()}', + build_number = '${Geoindicators.buildNumber()}'""".toString() return [outputTableBuildingIndicators : buildingIndicators, outputTableBlockIndicators : blockIndicators, diff --git a/geoindicators/src/main/resources/org/orbisgis/geoclimate/geoclimate.properties b/geoindicators/src/main/resources/org/orbisgis/geoclimate/geoclimate.properties new file mode 100644 index 0000000000..4467fd0b7b --- /dev/null +++ b/geoindicators/src/main/resources/org/orbisgis/geoclimate/geoclimate.properties @@ -0,0 +1,2 @@ +version=${project.version} +build=${buildNumber} \ No newline at end of file diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index a43df7afe6..bf6539f81c 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -479,4 +479,10 @@ class WorkflowGeoIndicatorsTest { } } + @Test + void GeoClimateProperties() { + assert "0.0.2-SNAPSHOT" == Geoindicators.version() + assertNotNull Geoindicators.buildNumber() + } + }