This is an internal documentation. There is a good chance you’re looking for something else. See Disclaimer.
Initial Value Generator¶
Country Initial Value Generator¶
This script generates the Tocco initial values for countries.
The data source is https://mledoze.github.io/countries
The BFS data source is https://www.bfs.admin.ch/bfs/de/home/grundlagen/stgb.html
Execute Script¶
Prerequisite: PyYAML is installed (pip install PyYAML
)
Clone the generator from https://gitlab.com/toccoag/country-initial-value-generator
Go to the data source on GitHub and download the latest version of the
countries.json
fileCopy the
countries.json
file to theinput
directoryGo to the BFS data source and download the data in XML format
Extract the
.xml
file from the downloaded ZIP file. Rename it tobfs_countries.xml
and copy it toinput/bfs_countries.xml
directoryRun the script with
python3 CountryImporter.py
Copy the existing initial value file (from the Nice repository
optional/address/resources/db/initialvalues/Country.yaml
) toinput/Country.yaml
Run the script with
python3 CountryDiff.py
For each country code in the Country code no longer exists list do the following in the Nice repository (change set location should be
optional/address/resources/db/initialvalues/2.xx_update_country.xml
):If a country still exist with another iso3 code (new iso3 code must be listed in New country code added), then add the following change set:
<changeSet author="anonymous" dbms="postgresql" id="ID" runOnChange="true"> <preConditions onFail="MARK_RAN"> <tableExists tableName="nice_country"/> </preConditions> <update tableName="nice_country"> <column name="iso3" value="NEW_VALUE"/> <where>iso3 = 'OLD_VALUE'</where> </update> </changeSet>
Set
ID
to something likeupdateCountry_XKV_to_UNK/2.27
,OLD_VALUE
is the old iso3 code andNEW_VALUE
is the new iso3 codeAdditionally, update
input/{licence_plate, sorting}.csv
in the generator repository if necessaryElse, write a change set to set the country to inactive:
<changeSet author="anonymous" dbms="postgresql" id="ID" runOnChange="true"> <preConditions onFail="MARK_RAN"> <tableExists tableName="nice_country"/> </preConditions> <update tableName="nice_country"> <column name="active" value="false"/> <where>iso3 = 'ISO_CODE'</where> </update> </changeSet>
Set
ID
to something likeupdateCountry_remove_ANT/2.27
andISO_CODE
is the iso3 codeCopy the output files (in
output
) to the Nice repository:Override the existing
Country.yaml
file inoptional/address/resources/db/initialvalues
Override the country name section in the language file
language_XX.properties
which is located atoptional/address/resources/model/textresources
Check the git diff to verify the data source quality
Additional Information¶
The
licence_plate
field is not part of the data source. There is a static file underinput/licence_plate.csv
as data source in the formatIso3,Licence_plate_code
The
sorting
field is an internal Tocco field. Per default a country obtains the value100
. If a non-default value is required there is a static file underinput/sorting.csv
in the formatIso3,number
to define the value per countrySome countries have multiple currency codes and calling codes. In such a case the values are comma-separated written into the text field