Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store the geoclimate version and build number in zone table #687

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}

}