Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 22464f0

Browse files
SORMAS-Foundation#2993 add countries file to resources
1 parent 5d4f115 commit 22464f0

5 files changed

Lines changed: 276 additions & 10 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/importexport/ImportFacade.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package de.symeda.sormas.api.importexport;
1919

2020
import java.io.IOException;
21+
import java.net.URI;
2122

2223
import javax.ejb.Remote;
2324

@@ -45,6 +46,8 @@ public interface ImportFacade {
4546

4647
void generateAreaImportTemplateFile() throws IOException;
4748

49+
void generateCountryImportTemplateFile() throws IOException;
50+
4851
void generateRegionImportTemplateFile() throws IOException;
4952

5053
void generateDistrictImportTemplateFile() throws IOException;
@@ -69,7 +72,7 @@ public interface ImportFacade {
6972

7073
String getCountryImportTemplateFilePath();
7174

72-
String getAllCountriesImportFilePath();
75+
URI getAllCountriesImportFilePath();
7376

7477
String getRegionImportTemplateFilePath();
7578

sormas-backend/src/main/java/de/symeda/sormas/backend/importexport/ImportFacadeEjb.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import java.lang.reflect.Field;
4343
import java.lang.reflect.Method;
4444
import java.lang.reflect.Modifier;
45+
import java.net.URI;
46+
import java.net.URISyntaxException;
4547
import java.nio.charset.Charset;
4648
import java.nio.charset.StandardCharsets;
4749
import java.nio.file.Files;
@@ -97,6 +99,7 @@
9799
import de.symeda.sormas.api.region.AreaDto;
98100
import de.symeda.sormas.api.region.CommunityDto;
99101
import de.symeda.sormas.api.region.CommunityReferenceDto;
102+
import de.symeda.sormas.api.region.CountryDto;
100103
import de.symeda.sormas.api.region.DistrictDto;
101104
import de.symeda.sormas.api.region.DistrictReferenceDto;
102105
import de.symeda.sormas.api.region.RegionDto;
@@ -299,6 +302,11 @@ public void generateAreaImportTemplateFile() throws IOException {
299302
generateImportTemplateFile(AreaDto.class, Paths.get(getAreaImportTemplateFilePath()));
300303
}
301304

305+
@Override
306+
public void generateCountryImportTemplateFile() throws IOException {
307+
generateImportTemplateFile(CountryDto.class, Paths.get(getCountryImportTemplateFilePath()));
308+
}
309+
302310
@Override
303311
public void generateRegionImportTemplateFile() throws IOException {
304312
generateImportTemplateFile(RegionDto.class, Paths.get(getRegionImportTemplateFilePath()));
@@ -395,10 +403,13 @@ public String getCountryImportTemplateFilePath() {
395403
}
396404

397405
@Override
398-
public String getAllCountriesImportFilePath() {
399-
Path exportDirectory = Paths.get(configFacade.getGeneratedFilesPath());
400-
Path filePath = exportDirectory.resolve(ALL_COUNTRIES_IMPORT_FILE_NAME);
401-
return filePath.toString();
406+
public URI getAllCountriesImportFilePath() {
407+
try {
408+
return this.getClass().getClassLoader().getResource(ALL_COUNTRIES_IMPORT_FILE_NAME).toURI();
409+
} catch (URISyntaxException e) {
410+
logger.warn("Cannot get countries import file path: ", e);
411+
throw new RuntimeException(e);
412+
}
402413
}
403414

404415
@Override

sormas-backend/src/main/java/de/symeda/sormas/backend/region/CountryFacadeEjb.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,15 @@ public CountryDto toDto(Country entity) {
160160
CountryDto dto = new CountryDto();
161161
DtoHelper.fillDto(dto, entity);
162162

163-
String nameLanguageKey = "country." + entity.getIsoCode().toUpperCase() + ".name";
163+
String isoCode = entity.getIsoCode();
164+
String nameLanguageKey = isoCode != null ? "country." + isoCode.toUpperCase() + ".name" : null;
164165
String displayName = ObjectUtils.firstNonNull(I18nProperties.getString(nameLanguageKey), entity.getDefaultName());
165166
dto.setDisplayName(displayName);
166167
dto.setDefaultName(entity.getDefaultName());
167168
dto.setArchived(entity.isArchived());
168169
dto.setExternalId(entity.getExternalId());
169170
dto.setIsoCode(entity.getIsoCode());
170-
dto.setUnoCode(entity.getUnoCode());
171+
dto.setUnoCode(isoCode);
171172
dto.setUuid(entity.getUuid());
172173

173174
return dto;
Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
"defaultName","externalId","isoCode","unoCode","archived"
2+
Switzerland,8100,CHE,756,FALSE
3+
Albania,8201,ALB,8,FALSE
4+
Andorra,8202,AND,20,FALSE
5+
Belgium,8204,BEL,56,FALSE
6+
Bulgaria,8205,BGR,100,FALSE
7+
Denmark,8206,DNK,208,FALSE
8+
Germany,8207,DEU,276,FALSE
9+
Faeroe Islands,8210,FRO,234,FALSE
10+
Finland,8211,FIN,246,FALSE
11+
France,8212,FRA,250,FALSE
12+
Gibraltar,8213,GIB,292,FALSE
13+
Greece,8214,GRC,300,FALSE
14+
United Kingdom,8215,GBR,826,FALSE
15+
Ireland,8216,IRL,372,FALSE
16+
Iceland,8217,ISL,352,FALSE
17+
Italy,8218,ITA,380,FALSE
18+
Liechtenstein,8222,LIE,438,FALSE
19+
Luxembourg,8223,LUX,442,FALSE
20+
Malta,8224,MLT,470,FALSE
21+
Isle of Man,8225,IMN,833,FALSE
22+
Monaco,8226,MCO,492,FALSE
23+
Netherlands,8227,NLD,528,FALSE
24+
Norway,8228,NOR,578,FALSE
25+
Austria,8229,AUT,40,FALSE
26+
Poland,8230,POL,616,FALSE
27+
Portugal,8231,PRT,620,FALSE
28+
Romania,8232,ROU,642,FALSE
29+
San Marino,8233,SMR,674,FALSE
30+
Sweden,8234,SWE,752,FALSE
31+
Spain,8236,ESP,724,FALSE
32+
Turkey,8239,TUR,792,FALSE
33+
Hungary,8240,HUN,348,FALSE
34+
Vatican City,8241,VAT,336,FALSE
35+
Cyprus,8242,CYP,196,FALSE
36+
Slovakia,8243,SVK,703,FALSE
37+
Czechia,8244,CZE,203,FALSE
38+
Serbia,8248,SRB,688,FALSE
39+
Croatia,8250,HRV,191,FALSE
40+
Slovenia,8251,SVN,705,FALSE
41+
Bosnia and Herzegovina,8252,BIH,70,FALSE
42+
Montenegro,8254,MNE,499,FALSE
43+
North Macedonia,8255,MKD,807,FALSE
44+
Estonia,8260,EST,233,FALSE
45+
Latvia,8261,LVA,428,FALSE
46+
Lithuania,8262,LTU,440,FALSE
47+
Moldova,8263,MDA,498,FALSE
48+
Russia,8264,RUS,643,FALSE
49+
Ukraine,8265,UKR,804,FALSE
50+
Belarus,8266,BLR,112,FALSE
51+
Jersey,8271,JEY,832,FALSE
52+
Guernsey,8272,GGY,831,FALSE
53+
Svalbard and Jan Mayen,8273,SJM,744,FALSE
54+
Aland Islands,8274,ALA,248,FALSE
55+
Equatorial Guinea,8301,GNQ,226,FALSE
56+
Ethiopia,8302,ETH,231,FALSE
57+
Djibouti,8303,DJI,262,FALSE
58+
Algeria,8304,DZA,12,FALSE
59+
Angola,8305,AGO,24,FALSE
60+
Botswana,8307,BWA,72,FALSE
61+
Burundi,8308,BDI,108,FALSE
62+
Benin,8309,BEN,204,FALSE
63+
Côte d'Ivoire,8310,CIV,384,FALSE
64+
Gabon,8311,GAB,266,FALSE
65+
Gambia,8312,GMB,270,FALSE
66+
Ghana,8313,GHA,288,FALSE
67+
Guinea-Bissau,8314,GNB,624,FALSE
68+
Guinea,8315,GIN,324,FALSE
69+
Cameroon,8317,CMR,120,FALSE
70+
Cabo Verde,8319,CPV,132,FALSE
71+
Kenya,8320,KEN,404,FALSE
72+
Comoros,8321,COM,174,FALSE
73+
Congo (Brazzaville),8322,COG,178,FALSE
74+
Congo (Kinshasa),8323,COD,180,FALSE
75+
Lesotho,8324,LSO,426,FALSE
76+
Liberia,8325,LBR,430,FALSE
77+
Libya,8326,LBY,434,FALSE
78+
Madagascar,8327,MDG,450,FALSE
79+
Malawi,8329,MWI,454,FALSE
80+
Mali,8330,MLI,466,FALSE
81+
Morocco,8331,MAR,504,FALSE
82+
Mauritania,8332,MRT,478,FALSE
83+
Mauritius,8333,MUS,480,FALSE
84+
Mozambique,8334,MOZ,508,FALSE
85+
Niger,8335,NER,562,FALSE
86+
Nigeria,8336,NGA,566,FALSE
87+
Burkina Faso,8337,BFA,854,FALSE
88+
Réunion,8339,REU,638,FALSE
89+
Zimbabwe,8340,ZWE,716,FALSE
90+
Rwanda,8341,RWA,646,FALSE
91+
Zambia,8343,ZMB,894,FALSE
92+
São Tomé and Príncipe,8344,STP,678,FALSE
93+
Senegal,8345,SEN,686,FALSE
94+
Seychelles,8346,SYC,690,FALSE
95+
Sierra Leone,8347,SLE,694,FALSE
96+
Somalia,8348,SOM,706,FALSE
97+
South Africa,8349,ZAF,710,FALSE
98+
Sudan,8350,SDN,729,FALSE
99+
Namibia,8351,NAM,516,FALSE
100+
Eswatini,8352,SWZ,748,FALSE
101+
Tanzania,8353,TZA,834,FALSE
102+
Togo,8354,TGO,768,FALSE
103+
Chad,8356,TCD,148,FALSE
104+
Tunisia,8357,TUN,788,FALSE
105+
Uganda,8358,UGA,800,FALSE
106+
Egypt,8359,EGY,818,FALSE
107+
Central African Republic,8360,CAF,140,FALSE
108+
Mayotte,8361,MYT,175,FALSE
109+
Eritrea,8362,ERI,232,FALSE
110+
South Sudan,8363,SSD,728,FALSE
111+
British Territories in the Indian Ocean,8371,IOT,,FALSE
112+
Western Sahara,8372,ESH,732,FALSE
113+
"Saint Helena, Ascension and Tristan da Cunha",,SHN,,FALSE
114+
Argentina,8401,ARG,32,FALSE
115+
Bahamas,8402,BHS,44,FALSE
116+
Barbados,8403,BRB,52,FALSE
117+
Bermuda,8404,BMU,60,FALSE
118+
Bolivia,8405,BOL,68,FALSE
119+
Brazil,8406,BRA,76,FALSE
120+
Chile,8407,CHL,152,FALSE
121+
Costa Rica,8408,CRI,188,FALSE
122+
Dominican Republic,8409,DOM,214,FALSE
123+
Ecuador,8410,ECU,218,FALSE
124+
El Salvador,8411,SLV,222,FALSE
125+
Falkland Islands,8412,FLK,238,FALSE
126+
Greenland,8413,GRL,304,FALSE
127+
Guadeloupe,8414,GLP,312,FALSE
128+
Guatemala,8415,GTM,320,FALSE
129+
French Guyana,8416,GUF,254,FALSE
130+
Guyana,8417,GUY,328,FALSE
131+
Haiti,8418,HTI,332,FALSE
132+
Belize,8419,BLZ,84,FALSE
133+
Honduras,8420,HND,340,FALSE
134+
Jamaica,8421,JAM,388,FALSE
135+
Canada,8423,CAN,124,FALSE
136+
Colombia,8424,COL,170,FALSE
137+
Cuba,8425,CUB,192,FALSE
138+
Martinique,8426,MTQ,474,FALSE
139+
Mexico,8427,MEX,484,FALSE
140+
Nicaragua,8429,NIC,558,FALSE
141+
Panama,8430,PAN,591,FALSE
142+
Paraguay,8431,PRY,600,FALSE
143+
Peru,8432,PER,604,FALSE
144+
Puerto Rico,8433,PRI,630,FALSE
145+
Saint Pierre and Miquelon,8434,SPM,666,FALSE
146+
Suriname,8435,SUR,740,FALSE
147+
Trinidad and Tobago,8436,TTO,780,FALSE
148+
Uruguay,8437,URY,858,FALSE
149+
Venezuela,8438,VEN,862,FALSE
150+
United States,8439,USA,840,FALSE
151+
Dominica,8440,DMA,212,FALSE
152+
Grenada,8441,GRD,308,FALSE
153+
Antigua and Barbuda,8442,ATG,28,FALSE
154+
Saint Lucia,8443,LCA,662,FALSE
155+
Saint Vincent and the Grenadines,8444,VCT,670,FALSE
156+
Saint Kitts and Nevis,8445,KNA,659,FALSE
157+
Anguilla,8446,AIA,660,FALSE
158+
Saint Martin (France),8448,MAF,663,FALSE
159+
Saint Barthélemy,8449,BLM,652,FALSE
160+
US Virgin Islands,8472,VIR,850,FALSE
161+
Cayman Islands,8473,CYM,136,FALSE
162+
Turks and Caicos Islands,8474,TCA,796,FALSE
163+
Montserrat,8475,MSR,500,FALSE
164+
British Virgin Islands,8476,VGB,92,FALSE
165+
Aruba,8482,ABW,533,FALSE
166+
South Georgia and the South Sandwich Islands,8483,SGS,,FALSE
167+
Curaçao,8484,CUW,531,FALSE
168+
Sint Maarten (Netherlands),8485,SXM,534,FALSE
169+
"Bonaire, Saint Eustatius and Saba",8486,BES,535,FALSE
170+
Afghanistan,8501,AFG,4,FALSE
171+
Bahrain,8502,BHR,48,FALSE
172+
Bhutan,8503,BTN,64,FALSE
173+
Brunei,8504,BRN,96,FALSE
174+
Myanmar,8505,MMR,104,FALSE
175+
Sri Lanka,8506,LKA,144,FALSE
176+
Taiwan (Chinese Taipei),8507,TWN,,FALSE
177+
China,8508,CHN,156,FALSE
178+
Hong Kong,8509,HKG,344,FALSE
179+
India,8510,IND,356,FALSE
180+
Indonesia,8511,IDN,360,FALSE
181+
Iraq,8512,IRQ,368,FALSE
182+
Iran,8513,IRN,364,FALSE
183+
Israel,8514,ISR,376,FALSE
184+
Japan,8515,JPN,392,FALSE
185+
Yemen,8516,YEM,887,FALSE
186+
Jordan,8517,JOR,400,FALSE
187+
Cambodia,8518,KHM,116,FALSE
188+
Qatar,8519,QAT,634,FALSE
189+
Kuwait,8521,KWT,414,FALSE
190+
Laos,8522,LAO,418,FALSE
191+
Lebanon,8523,LBN,422,FALSE
192+
Macao,8524,MAC,446,FALSE
193+
Malaysia,8525,MYS,458,FALSE
194+
Maldives,8526,MDV,462,FALSE
195+
Oman,8527,OMN,512,FALSE
196+
Mongolia,8528,MNG,496,FALSE
197+
Nepal,8529,NPL,524,FALSE
198+
North Korea,8530,PRK,408,FALSE
199+
United Arab Emirates,8532,ARE,784,FALSE
200+
Pakistan,8533,PAK,586,FALSE
201+
Philippines,8534,PHL,608,FALSE
202+
Saudi Arabia,8535,SAU,682,FALSE
203+
Singapore,8537,SGP,702,FALSE
204+
South Korea,8539,KOR,410,FALSE
205+
Syria,8541,SYR,760,FALSE
206+
Thailand,8542,THA,764,FALSE
207+
Vietnam,8545,VNM,704,FALSE
208+
Bangladesh,8546,BGD,50,FALSE
209+
Timor-Leste,8547,TLS,626,FALSE
210+
Palestine,8550,PSE,275,FALSE
211+
Armenia,8560,ARM,51,FALSE
212+
Azerbaijan,8561,AZE,31,FALSE
213+
Georgia,8562,GEO,268,FALSE
214+
Kazakhstan,8563,KAZ,398,FALSE
215+
Kyrgyzstan,8564,KGZ,417,FALSE
216+
Tajikistan,8565,TJK,762,FALSE
217+
Turkmenistan,8566,TKM,795,FALSE
218+
Uzbekistan,8567,UZB,860,FALSE
219+
Australia,8601,AUS,36,FALSE
220+
Fiji,8602,FJI,242,FALSE
221+
Nauru,8604,NRU,520,FALSE
222+
Vanuatu,8605,VUT,548,FALSE
223+
New Caledonia,8606,NCL,540,FALSE
224+
New Zealand,8607,NZL,554,FALSE
225+
Papua New Guinea,8608,PNG,598,FALSE
226+
Tonga,8610,TON,776,FALSE
227+
Wallis and Futuna,8611,WLF,876,FALSE
228+
Samoa,8612,WSM,882,FALSE
229+
Solomon Islands,8614,SLB,90,FALSE
230+
Tuvalu,8615,TUV,798,FALSE
231+
Kiribati,8616,KIR,296,FALSE
232+
Marshall Islands,8617,MHL,584,FALSE
233+
Micronesia,8618,FSM,583,FALSE
234+
Palau,8619,PLW,585,FALSE
235+
American Samoa,8621,ASM,16,FALSE
236+
Northern Marianas,8630,MNP,580,FALSE
237+
Guam,8632,GUM,316,FALSE
238+
United States Minor Outlying Islands,8637,UMI,,FALSE
239+
Cocos (Keeling) Islands,8652,CCK,,FALSE
240+
Heard Island and McDonald Islands,8653,HMD,,FALSE
241+
Norfolk Island,8654,NFK,574,FALSE
242+
Christmas Island,8655,CXR,,FALSE
243+
French Polynesia,8671,PYF,258,FALSE
244+
Cook Islands,8682,COK,184,FALSE
245+
Niue,8683,NIU,570,FALSE
246+
Tokelau,8684,TKL,772,FALSE
247+
Pitcairn Islands,8685,PCN,612,FALSE
248+
Antarctica,8701,ATA,,FALSE
249+
Bouvet Island,8702,BVT,,FALSE
250+
French Southern and Antarctic Lands,8703,ATF,,FALSE

sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ImportAllCountriesLayout.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.net.URI;
56
import java.nio.file.Paths;
67

78
import com.opencsv.exceptions.CsvValidationException;
@@ -26,11 +27,11 @@ public ImportAllCountriesLayout() {
2627
super();
2728

2829
addImportAllCountriesCsvComponent(1, (event) -> {
29-
String templateFilePath = FacadeProvider.getImportFacade().getAllCountriesImportFilePath();
30-
File templateFile = Paths.get(templateFilePath).toFile();
30+
URI countriesFileUri = FacadeProvider.getImportFacade().getAllCountriesImportFilePath();
31+
File countriesFile = Paths.get(countriesFileUri).toFile();
3132
resetDownloadErrorReportButton();
3233
try {
33-
DataImporter importer = new InfrastructureImporter(templateFile, currentUser, InfrastructureType.COUNTRY);
34+
DataImporter importer = new InfrastructureImporter(countriesFile, currentUser, InfrastructureType.COUNTRY);
3435
importer.startImport(this::extendDownloadErrorReportButton, currentUI, true);
3536
} catch (IOException | CsvValidationException e) {
3637
new Notification(

0 commit comments

Comments
 (0)