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

Commit 96b62e2

Browse files
authored
Feature 2978 occupations quarantine types for switzerland (SORMAS-Foundation#3033)
* SORMAS-Foundation#2978 Add support for configuring enums visibility * SORMAS-Foundation#2978 Switzerland specific Occupation and Quarantine Type * SORMAS-Foundation#2978 removed unrequested translations * SORMAS-Foundation#2978 removed blank at end of files
1 parent 0677975 commit 96b62e2

9 files changed

Lines changed: 221 additions & 12 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/contact/QuarantineType.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package de.symeda.sormas.api.contact;
22

3+
import de.symeda.sormas.api.CountryHelper;
34
import de.symeda.sormas.api.i18n.I18nProperties;
5+
import de.symeda.sormas.api.utils.HideForCountriesExcept;
46

57
public enum QuarantineType {
68

9+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
10+
HOSPITAL,
11+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
12+
HOTEL,
13+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
14+
ASYLUM_ACCOMMODATION,
715
INSTITUTIONELL,
816
HOME,
917
NONE,

sormas-api/src/main/java/de/symeda/sormas/api/person/OccupationType.java

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,120 @@
1717
*******************************************************************************/
1818
package de.symeda.sormas.api.person;
1919

20+
import de.symeda.sormas.api.CountryHelper;
2021
import de.symeda.sormas.api.i18n.I18nProperties;
22+
import de.symeda.sormas.api.utils.HideForCountriesExcept;
2123

2224
public enum OccupationType {
2325

26+
// Switzerland NOGA specific Occupation Types
27+
/**
28+
* G. WHOLESALE AND RETAIL TRADE; REPAIR OF MOTOR VEHICLES AND MOTORCYCLES
29+
*/
30+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
31+
RETAIL_AND_REPAIR_SERVICE,
32+
/**
33+
* C.MANUFACTURING
34+
*/
35+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
36+
MANUFACTURING,
37+
/**
38+
* F.CONSTRUCTION
39+
*/
40+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
41+
CONSTRUCTION,
42+
/**
43+
* H.TRANSPORTATION AND STORAGE
44+
*/
45+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
46+
TRANSPORT_AND_STORAGE,
47+
/**
48+
* Q.HUMAN HEALTH AND SOCIAL WORK ACTIVITIES
49+
*/
50+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
51+
HEALTH_AND_SOCIAL,
52+
/**
53+
* P.EDUCATION
54+
*/
55+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
56+
EDUCATION,
57+
/**
58+
* I.ACCOMMODATION AND FOOD SERVICE ACTIVITIES
59+
*/
60+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
61+
ACCOMMODATION_AND_FOOD_SERVICES,
62+
/**
63+
* R.ARTS, ENTERTAINMENT AND RECREATION
64+
*/
65+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
66+
ARTS_ENTERTAINMENT_AND_RECREATION,
67+
/**
68+
* O.PUBLIC ADMINISTRATION AND DEFENCE; COMPULSORY SOCIAL SECURITY
69+
*/
70+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
71+
PUBLIC_ADMINISTRATION_AND_DEFENCE,
72+
/**
73+
* K.FINANCIAL AND INSURANCE ACTIVITIES
74+
*/
75+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
76+
FINANCE_AND_INSURANCE,
77+
/**
78+
* J.INFORMATION AND COMMUNICATION
79+
*/
80+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
81+
INFORMATION_AND_COMMUNICATION,
82+
/**
83+
* M.PROFESSIONAL, SCIENTIFIC AND TECHNICAL ACTIVITIES
84+
*/
85+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
86+
PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL,
87+
/**
88+
* N.ADMINISTRATIVE AND SUPPORT SERVICE ACTIVITIES
89+
*/
90+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
91+
ADMINISTRATIVE_AND_SUPPORT,
92+
/**
93+
* S.OTHER SERVICE ACTIVITIES
94+
*/
95+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
96+
SERVICE_OTHER,
97+
/**
98+
* L.REAL ESTATE ACTIVITIES
99+
*/
100+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
101+
REAL_ESTATE,
102+
/**
103+
* D.ELECTRICITY, GAS, STEAM AND AIR-CONDITIONING SUPPLY
104+
*/
105+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
106+
ENERGY_SUPPLY,
107+
/**
108+
* E.WATER SUPPLY; SEWERAGE, WASTE MANAGEMENT AND REMEDIATION ACTIVITIES
109+
*/
110+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
111+
WATER_SUPPLY_AND_WASTE,
112+
/**
113+
* U.ACTIVITIES OF EXTRATERRITORIAL ORGANISATIONS AND BODIES
114+
*/
115+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
116+
EXTRATERRITORIAL_ORGANIZATIONS,
117+
/**
118+
* A.AGRICULTURE, FORESTRY AND FISHING
119+
*/
120+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
121+
AGRICULTURE,
122+
/**
123+
* B.MINING AND QUARRYING
124+
*/
125+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
126+
MINING,
127+
/**
128+
* T.ACTIVITIES OF HOUSEHOLDS AS EMPLOYERS; UNDIFFERENTIATED GOODS- AND SERVICES-PRODUCING ACTIVITIES OF HOUSEHOLDS FOR OWN USE
129+
*/
130+
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_SWITZERLAND)
131+
PRIVATE_HOUSEHOLD,
132+
133+
// Generic Occupation Types
24134
FARMER,
25135
BUTCHER,
26136
HUNTER_MEAT_TRADER,
@@ -40,4 +150,5 @@ public enum OccupationType {
40150
public String toString() {
41151
return I18nProperties.getEnumCaption(this);
42152
}
153+
43154
}

sormas-api/src/main/resources/enum.properties

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,28 @@ OccupationType.TRANSPORTER = Transporter
585585
OccupationType.WORKING_WITH_ANIMALS = Working with animals
586586
OccupationType.LABORATORY_STAFF = Laboratory staff
587587

588+
OccupationType.AGRICULTURE = A. Agriculture & forestry, fisheries
589+
OccupationType.MINING = B. Mining & quarrying
590+
OccupationType.MANUFACTURING = C. Manufacturing industry /manufacture of goods
591+
OccupationType.ENERGY_SUPPLY = D. Energy supply
592+
OccupationType.WATER_SUPPLY_AND_WASTE = E. Water supply; sewerage and waste management
593+
OccupationType.CONSTRUCTION = F. Construction industry /building
594+
OccupationType.RETAIL_AND_REPAIR_SERVICE = G. Wholesale and retail trade; repair services
595+
OccupationType.TRANSPORT_AND_STORAGE = H. Transport and storage
596+
OccupationType.ACCOMMODATION_AND_FOOD_SERVICES = I. Hotels and restaurants /accommodation & gastronomy
597+
OccupationType.INFORMATION_AND_COMMUNICATION = J. Information & communication
598+
OccupationType.FINANCE_AND_INSURANCE = K. Finance & insurance
599+
OccupationType.REAL_ESTATE = L. Real estate and housing
600+
OccupationType.PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL = M. Service: freelance, scientific, technical
601+
OccupationType.ADMINISTRATIVE_AND_SUPPORT = N. Service: other economic activities
602+
OccupationType.PUBLIC_ADMINISTRATION_AND_DEFENCE = O. Public administration and defence; social services/security
603+
OccupationType.EDUCATION = P. Education & teaching
604+
OccupationType.HEALTH_AND_SOCIAL = Q. Health & social services
605+
OccupationType.ARTS_ENTERTAINMENT_AND_RECREATION = R. Arts, entertainment & recreation
606+
OccupationType.SERVICE_OTHER = S. Service: other
607+
OccupationType.PRIVATE_HOUSEHOLD = T. Private households with domestic staff
608+
OccupationType.EXTRATERRITORIAL_ORGANIZATIONS = U. Exterritorial organisations & bodies
609+
588610
# PathogenTestResultType
589611
PathogenTestResultType.INDETERMINATE = Indeterminate
590612
PathogenTestResultType.NEGATIVE = Negative
@@ -658,6 +680,9 @@ QuarantineType.NONE = None
658680
QuarantineType.UNKNOWN = Unknown
659681
QuarantineType.OTHER = Other
660682

683+
QuarantineType.HOSPITAL = Hospital
684+
QuarantineType.HOTEL = Hotel
685+
QuarantineType.ASYLUM_ACCOMMODATION = Asylum Accommodation
661686

662687
# ReportingType
663688
ReportingType.NOT_RAISED = Not raised
@@ -1098,4 +1123,4 @@ EndOfIsolationReason.OTHER=Other
10981123
EndOfQuarantineReason.ASYMPTOMATIC=Asymptomatic after 10 days
10991124
EndOfQuarantineReason.ISOLATED_AS_CASE=Isolated as Case
11001125
EndOfQuarantineReason.LOST_TO_FOLLOWUP=Lost to follow-up
1101-
EndOfQuarantineReason.OTHER=Other
1126+
EndOfQuarantineReason.OTHER=Other

sormas-api/src/main/resources/enum_de-CH.properties

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,28 @@ OccupationType.TRANSPORTER = Mithelfende*r Angehörige*r
585585
OccupationType.WORKING_WITH_ANIMALS = Arbeiten mit Tieren
586586
OccupationType.LABORATORY_STAFF = Laborpersonal
587587

588+
OccupationType.AGRICULTURE = A. Land- & Forstwirtschaft, Fischerei
589+
OccupationType.MINING = B. Bergbau & Gewinnung von Steinen/Erden
590+
OccupationType.MANUFACTURING = C. Verarbeitendes Gewerbe/Herstellung von Waren
591+
OccupationType.ENERGY_SUPPLY = D. Energieversorgung
592+
OccupationType.WATER_SUPPLY_AND_WASTE = E. Wasserversorgung; Abwasser- und Abfallentsorgung
593+
OccupationType.CONSTRUCTION = F. Baugewerbe/Bau
594+
OccupationType.RETAIL_AND_REPAIR_SERVICE = G. Handel; Reparaturgewerbe
595+
OccupationType.TRANSPORT_AND_STORAGE = H. Verkehr und Lagerei
596+
OccupationType.ACCOMMODATION_AND_FOOD_SERVICES = I. Gastgewerbe/Beherbergung & Gastronomie
597+
OccupationType.INFORMATION_AND_COMMUNICATION = J. Information & Kommunikation
598+
OccupationType.FINANCE_AND_INSURANCE = K. Finanz- & Versicherungswesen
599+
OccupationType.REAL_ESTATE = L. Grundstücks- und Wohnungswesen
600+
OccupationType.PROFESSIONAL_SCIENTIFIC_AND_TECHNICAL = M. Dienstleistung: freiberuflich, wissenschaftl., techn.
601+
OccupationType.ADMINISTRATIVE_AND_SUPPORT = N. Dienstleistung: sonstige wirtschaftliche
602+
OccupationType.PUBLIC_ADMINISTRATION_AND_DEFENCE = O. Öffentliche Verwaltung, Verteidigung; Sozialversicherung
603+
OccupationType.EDUCATION = P. Erziehung & Unterricht
604+
OccupationType.HEALTH_AND_SOCIAL = Q. Gesundheits- & Sozialwesen
605+
OccupationType.ARTS_ENTERTAINMENT_AND_RECREATION = R. Kunst, Unterhaltung & Erholung
606+
OccupationType.SERVICE_OTHER = S. Dienstleistung: sonstige
607+
OccupationType.PRIVATE_HOUSEHOLD = T. Private Haushalte mit Hauspersonal
608+
OccupationType.EXTRATERRITORIAL_ORGANIZATIONS = U. Exterritoriale Organisationen & Körperschaften
609+
588610
# PathogenTestResultType
589611
PathogenTestResultType.INDETERMINATE = Unbestimmt
590612
PathogenTestResultType.NEGATIVE = Negativ
@@ -658,6 +680,9 @@ QuarantineType.NONE = Keine
658680
QuarantineType.UNKNOWN = Unbekannt
659681
QuarantineType.OTHER = Anderer
660682

683+
QuarantineType.HOSPITAL = Spital
684+
QuarantineType.HOTEL = Hotel
685+
QuarantineType.ASYLUM_ACCOMMODATION = Asylzentrum
661686

662687
# ReportingType
663688
ReportingType.NOT_RAISED = Nicht erhoben

sormas-app/app/src/main/java/de/symeda/sormas/app/person/edit/PersonEditFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import de.symeda.sormas.app.backend.caze.Case;
5555
import de.symeda.sormas.app.backend.common.AbstractDomainObject;
5656
import de.symeda.sormas.app.backend.common.DatabaseHelper;
57+
import de.symeda.sormas.app.backend.config.ConfigProvider;
5758
import de.symeda.sormas.app.backend.contact.Contact;
5859
import de.symeda.sormas.app.backend.location.Location;
5960
import de.symeda.sormas.app.backend.person.Person;
@@ -179,14 +180,15 @@ public static void setUpLayoutBinding(
179180
(Integer) contentBinding.personBirthdateMM.getValue());
180181
});
181182
int year = Calendar.getInstance().get(Calendar.YEAR);
183+
FieldVisibilityCheckers countryVisibilityChecker = FieldVisibilityCheckers.withCountry(ConfigProvider.getServerCountryCode());
182184
contentBinding.personBirthdateYYYY.setSelectionOnOpen(year - 35);
183185
contentBinding.personApproximateAgeType.initializeSpinner(approximateAgeTypeList);
184186
contentBinding.personSex.initializeSpinner(sexList);
185187
contentBinding.personCauseOfDeath.initializeSpinner(causeOfDeathList);
186188
contentBinding.personCauseOfDeathDisease.initializeSpinner(diseaseList);
187189
contentBinding.personDeathPlaceType.initializeSpinner(deathPlaceTypeList);
188190
contentBinding.personBurialConductor.initializeSpinner(burialConductorList);
189-
contentBinding.personOccupationType.initializeSpinner(DataUtils.getEnumItems(OccupationType.class, true));
191+
contentBinding.personOccupationType.initializeSpinner(DataUtils.getEnumItems(OccupationType.class, true, countryVisibilityChecker));
190192
contentBinding.personEducationType.initializeSpinner(DataUtils.getEnumItems(EducationType.class, true));
191193
contentBinding.personPresentCondition.initializeSpinner(DataUtils.getEnumItems(PresentCondition.class, true));
192194

sormas-app/app/src/main/java/de/symeda/sormas/app/util/DataUtils.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import de.symeda.sormas.api.Month;
2222
import de.symeda.sormas.api.i18n.I18nProperties;
2323
import de.symeda.sormas.api.utils.DateHelper;
24+
import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers;
2425
import de.symeda.sormas.app.R;
2526
import de.symeda.sormas.app.backend.common.DatabaseHelper;
2627
import de.symeda.sormas.app.component.Item;
@@ -32,23 +33,33 @@
3233

3334
public class DataUtils {
3435

35-
public static <E> List<Item> getEnumItems(Class<E> clazz) {
36+
public static <E extends Enum<?>> List<Item> getEnumItems(Class<E> clazz) {
3637
return getEnumItems(clazz, true);
3738
}
3839

39-
public static <E> List<Item> getEnumItems(Class<E> clazz, boolean withNull) {
40+
public static <E extends Enum<?>> List<Item> getEnumItems(Class<E> clazz, boolean withNull) {
41+
return getEnumItems(clazz, withNull, null);
42+
}
43+
44+
public static <E extends Enum<?>> List<Item> getEnumItems(Class<E> clazz, boolean withNull, FieldVisibilityCheckers checkers) {
4045
E[] enumConstants = clazz.getEnumConstants();
4146
if (!clazz.isEnum()) {
4247
throw new IllegalArgumentException(clazz.toString() + " is not an enum");
4348
}
44-
List<Item> list = new ArrayList<Item>();
49+
List<Item> list = new ArrayList<>();
4550

4651
if (withNull) {
4752
list.add(new Item<E>("", null));
4853
}
4954

50-
for (int i = 0; i < enumConstants.length; i++) {
51-
list.add(new Item<E>(enumConstants[i].toString(), enumConstants[i]));
55+
for (E enumConstant: enumConstants) {
56+
boolean visible = true;
57+
if (checkers != null) {
58+
visible = checkers.isVisible(clazz, enumConstant.name());
59+
}
60+
if (visible) {
61+
list.add(new Item<>(enumConstant.toString(), enumConstant));
62+
}
5263
}
5364
return list;
5465
}

sormas-app/app/src/test/java/de/symeda/sormas/app/util/DataUtilsTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ public void getEnumItems() {
2323
assertThat(enumItems.size(), is(YesNoUnknown.values().length));
2424
}
2525

26-
@Test(expected = IllegalArgumentException.class)
27-
public void getEnumItemsIllegalArgument() {
28-
DataUtils.getEnumItems(Object.class, false);
29-
}
30-
3126
@Test(expected = NullPointerException.class)
3227
public void getEnumItemsNullPointer() {
3328
DataUtils.getEnumItems(null, false);

sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FieldHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
import de.symeda.sormas.api.Disease;
4242
import de.symeda.sormas.api.symptoms.SymptomsDto;
4343
import de.symeda.sormas.api.utils.Diseases;
44+
import de.symeda.sormas.api.utils.fieldaccess.checkers.PersonalDataFieldAccessChecker;
45+
import de.symeda.sormas.api.utils.fieldaccess.checkers.SensitiveDataFieldAccessChecker;
46+
import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers;
47+
import de.symeda.sormas.ui.UserProvider;
4448

4549
public final class FieldHelper {
4650

@@ -590,4 +594,9 @@ public static Stream<Component> stream(Component parent) {
590594
public static Stream<Field> streamFields(Component parent) {
591595
return FieldHelper.stream(parent).filter(c -> c instanceof Field).map(c -> (Field) c);
592596
}
597+
598+
public static Collection<Enum<?>> getVisibleEnumItems(Class<Enum<?>> enumClass, FieldVisibilityCheckers checkers) {
599+
return Arrays.stream(enumClass.getEnumConstants()).filter(constant -> checkers.isVisible(enumClass, constant.name()))
600+
.collect(Collectors.toList());
601+
}
593602
}

sormas-ui/src/main/java/de/symeda/sormas/ui/utils/SormasFieldGroupFieldFactory.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.symeda.sormas.ui.utils;
22

33
import java.util.Date;
4+
import java.util.EnumSet;
45
import java.util.List;
56

67
import com.vaadin.ui.themes.ValoTheme;
@@ -177,4 +178,26 @@ protected void populateWithDiseaseData(ComboBox diseaseField) {
177178
newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString());
178179
}
179180
}
181+
182+
@SuppressWarnings("unchecked")
183+
@Override
184+
protected void populateWithEnumData(AbstractSelect select, Class<? extends Enum> enumClass) {
185+
select.removeAllItems();
186+
for (Object p : select.getContainerPropertyIds()) {
187+
select.removeContainerProperty(p);
188+
}
189+
select.addContainerProperty(CAPTION_PROPERTY_ID, String.class, "");
190+
select.setItemCaptionPropertyId(CAPTION_PROPERTY_ID);
191+
EnumSet<?> enumSet = EnumSet.allOf(enumClass);
192+
for (Object r : enumSet) {
193+
boolean visible = true;
194+
if (fieldVisibilityCheckers != null) {
195+
visible = fieldVisibilityCheckers.isVisible(enumClass, ((Enum<?>) r).name());
196+
}
197+
if (visible) {
198+
Item newItem = select.addItem(r);
199+
newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString());
200+
}
201+
}
202+
}
180203
}

0 commit comments

Comments
 (0)