use of de.symeda.sormas.api.feature.FeatureConfigurationDto in project SORMAS-Project by hzi-braunschweig.
the class DatabaseTableTest method testCasesAndVisitsEnabled.
@Test
public void testCasesAndVisitsEnabled() {
FeatureConfigurationDto caseSurveillanceFeatureConfiguration = new FeatureConfigurationDto();
caseSurveillanceFeatureConfiguration.setFeatureType(FeatureType.CASE_SURVEILANCE);
caseSurveillanceFeatureConfiguration.setEnabled(true);
FeatureConfigurationDto caseFollowupFeatureConfiguration = new FeatureConfigurationDto();
caseFollowupFeatureConfiguration.setFeatureType(FeatureType.CASE_FOLLOWUP);
caseFollowupFeatureConfiguration.setEnabled(true);
List<FeatureConfigurationDto> caseFeatureCOnfigurations = Arrays.asList(caseSurveillanceFeatureConfiguration, caseFollowupFeatureConfiguration);
assertThat(DatabaseTable.CASES.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.HOSPITALIZATIONS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.PREVIOUSHOSPITALIZATIONS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.PORT_HEALTH_INFO.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.MATERNAL_HISTORIES.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.EPIDATA.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.EXPOSURES.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.ACTIVITIES_AS_CASE.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.HEALTH_CONDITIONS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.SYMPTOMS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.VISITS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(true));
assertThat(DatabaseTable.CONTACTS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(false));
assertThat(DatabaseTable.IMMUNIZATIONS.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(false));
assertThat(DatabaseTable.SAMPLES.isEnabled(caseFeatureCOnfigurations, new ConfigFacadeEjb()), is(false));
}
use of de.symeda.sormas.api.feature.FeatureConfigurationDto in project SORMAS-Project by hzi-braunschweig.
the class DatabaseExportView method createDatabaseTablesLayout.
private HorizontalLayout createDatabaseTablesLayout() {
HorizontalLayout databaseTablesLayout = new HorizontalLayout();
databaseTablesLayout.setMargin(false);
databaseTablesLayout.setSpacing(true);
VerticalLayout sormasDataLayout = new VerticalLayout();
sormasDataLayout.setMargin(false);
sormasDataLayout.setSpacing(false);
Label sormasDataHeadline = new Label(I18nProperties.getCaption(Captions.exportSormasData));
CssStyles.style(sormasDataHeadline, CssStyles.H4);
sormasDataLayout.addComponent(sormasDataHeadline);
VerticalLayout infrastructureDataLayout = new VerticalLayout();
infrastructureDataLayout.setMargin(false);
infrastructureDataLayout.setSpacing(false);
Label infrastructureDataHeadline = new Label(I18nProperties.getCaption(Captions.exportInfrastructureData));
CssStyles.style(infrastructureDataHeadline, CssStyles.H4);
infrastructureDataLayout.addComponent(infrastructureDataHeadline);
VerticalLayout configurationDataLayout = new VerticalLayout();
configurationDataLayout.setMargin(false);
configurationDataLayout.setSpacing(false);
Label configurationDataHeadline = new Label(I18nProperties.getCaption(Captions.exportConfigurationData));
CssStyles.style(configurationDataHeadline, CssStyles.H4);
configurationDataLayout.addComponent(configurationDataHeadline);
VerticalLayout externalDataLayout = new VerticalLayout();
externalDataLayout.setMargin(false);
externalDataLayout.setSpacing(false);
Label externalDataHeadline = new Label(I18nProperties.getCaption(Captions.exportExternalData));
CssStyles.style(externalDataHeadline, CssStyles.H4);
externalDataLayout.addComponent(externalDataHeadline);
List<FeatureConfigurationDto> featureConfigurations = FacadeProvider.getFeatureConfigurationFacade().getActiveServerFeatureConfigurations();
ConfigFacade configFacade = FacadeProvider.getConfigFacade();
for (DatabaseTable databaseTable : DatabaseTable.values()) {
if (!databaseTable.isEnabled(featureConfigurations, configFacade)) {
continue;
}
CheckBox checkBox = new CheckBox(databaseTable.toString());
int indent = getIndent(databaseTable);
if (indent == 1) {
CssStyles.style(checkBox, CssStyles.INDENT_LEFT_1);
} else if (indent == 2) {
CssStyles.style(checkBox, CssStyles.INDENT_LEFT_2);
} else if (indent == 3) {
CssStyles.style(checkBox, CssStyles.INDENT_LEFT_3);
}
switch(databaseTable.getDatabaseTableType()) {
case SORMAS:
sormasDataLayout.addComponent(checkBox);
break;
case INFRASTRUCTURE:
infrastructureDataLayout.addComponent(checkBox);
break;
case CONFIGURATION:
configurationDataLayout.addComponent(checkBox);
break;
case EXTERNAL:
externalDataLayout.addComponent(checkBox);
break;
default:
throw new IllegalArgumentException(databaseTable.getDatabaseTableType().toString());
}
databaseTableToggles.put(checkBox, databaseTable);
}
databaseTablesLayout.addComponent(sormasDataLayout);
databaseTablesLayout.addComponent(infrastructureDataLayout);
databaseTablesLayout.addComponent(configurationDataLayout);
databaseTablesLayout.addComponent(externalDataLayout);
return databaseTablesLayout;
}
use of de.symeda.sormas.api.feature.FeatureConfigurationDto in project SORMAS-Project by hzi-braunschweig.
the class FeatureConfigurationFacadeEjb method toDto.
public static FeatureConfigurationDto toDto(FeatureConfiguration source) {
if (source == null) {
return null;
}
FeatureConfigurationDto target = new FeatureConfigurationDto();
DtoHelper.fillDto(target, source);
target.setFeatureType(source.getFeatureType());
target.setRegion(RegionFacadeEjb.toReferenceDto(source.getRegion()));
target.setDistrict(DistrictFacadeEjb.toReferenceDto(source.getDistrict()));
target.setDisease(source.getDisease());
target.setEndDate(source.getEndDate());
target.setEnabled(source.isEnabled());
target.setProperties(source.getProperties());
return target;
}
use of de.symeda.sormas.api.feature.FeatureConfigurationDto in project SORMAS-Project by hzi-braunschweig.
the class FeatureConfigurationFacadeEjb method saveFeatureConfiguration.
@Override
public void saveFeatureConfiguration(@Valid FeatureConfigurationIndexDto configuration, FeatureType featureType) {
// Delete an existing configuration that was set inactive and is not a server feature
if (!featureType.isServerFeature() && Boolean.FALSE.equals(configuration.isEnabled())) {
FeatureConfiguration existingConfiguration = service.getByUuid(configuration.getUuid());
if (existingConfiguration != null) {
service.deletePermanent(existingConfiguration);
}
return;
}
// Create or update an active configuration
FeatureConfigurationDto configurationDto = toDto(service.getByUuid(configuration.getUuid()));
if (configurationDto == null) {
configurationDto = FeatureConfigurationDto.build();
configurationDto.setFeatureType(featureType);
configurationDto.setDisease(configuration.getDisease());
configurationDto.setRegion(new RegionReferenceDto(configuration.getRegionUuid(), null, null));
configurationDto.setDistrict(new DistrictReferenceDto(configuration.getDistrictUuid(), null, null));
configurationDto.setEnabled(configuration.isEnabled());
}
if (configuration.getEndDate() != null) {
configurationDto.setEndDate(DateHelper.getEndOfDay(configuration.getEndDate()));
}
FeatureConfiguration entity = fromDto(configurationDto, true);
service.ensurePersisted(entity);
}
use of de.symeda.sormas.api.feature.FeatureConfigurationDto in project SORMAS-Project by hzi-braunschweig.
the class InfoFacadeEjb method generateDataProtectionDictionary.
@Override
public String generateDataProtectionDictionary() throws IOException {
List<FeatureConfigurationDto> featureConfigurations = featureConfigurationFacade.getActiveServerFeatureConfigurations();
FieldVisibilityCheckers fieldVisibilityCheckers = FieldVisibilityCheckers.withCheckers(new CountryFieldVisibilityChecker(configFacade.getCountryLocale()), new DiseaseFieldVisibilityChecker(diseaseConfigurationFacade.getAllActiveDiseases()), new FeatureTypeFieldVisibilityChecker(featureConfigurations));
List<EntityInfo> entities = DATA_DICTIONARY_ENTITIES.stream().filter(e -> isVisibleByFeatureConfiguration(e.getEntityClass(), featureConfigurations)).collect(Collectors.toList());
try (XSSFWorkbook dataProtectionInputWorkbook = new XSSFWorkbook(getDataProtectionFile())) {
XSSFSheet dataProtectionSheet = dataProtectionInputWorkbook.getSheetAt(0);
List<ColumnData> dataProtectionColumns = getDataProtectionColumns(dataProtectionSheet);
Map<String, List<XSSFCell>> dataProtectionData = getDataProtectionCellData(dataProtectionSheet);
return generateDataDictionary(entities, getColumnsForDataProtectionDictionary(), new VisibilityChecks((dtoClass, field) -> fieldVisibilityCheckers.isVisible(dtoClass, field) && isVisibleByFeatureConfiguration(field.getType(), featureConfigurations), fieldVisibilityCheckers), dataProtectionColumns, dataProtectionData, true);
} catch (InvalidFormatException e) {
throw new IOException(e);
}
}
Aggregations