Skip to content

Commit

Permalink
Merge pull request #687 from ebocher/add_version
Browse files Browse the repository at this point in the history
Store the geoclimate version and build number in zone table
  • Loading branch information
ebocher authored Mar 1, 2022
2 parents 00ec61c + 8de2b48 commit bcd457a
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
17 changes: 17 additions & 0 deletions geoindicators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>

<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>**/geoclimate.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/geoclimate.properties</exclude>
</excludes>
</resource>
</resources>
</build>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1806,16 +1806,20 @@ 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,
nb_building = ${nbBuilding},
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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=${project.version}
build=${buildNumber}
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,10 @@ class WorkflowGeoIndicatorsTest {
}
}

@Test
void GeoClimateProperties() {
assert "0.0.2-SNAPSHOT" == Geoindicators.version()
assertNotNull Geoindicators.buildNumber()
}

}

0 comments on commit bcd457a

Please sign in to comment.