Search in sources :

Example 1 with FeatureConfigurationDto

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));
}
Also used : FeatureConfigurationDto(de.symeda.sormas.api.feature.FeatureConfigurationDto) ConfigFacadeEjb(de.symeda.sormas.backend.common.ConfigFacadeEjb) Test(org.junit.Test)

Example 2 with FeatureConfigurationDto

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;
}
Also used : CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) DatabaseTable(de.symeda.sormas.api.importexport.DatabaseTable) FeatureConfigurationDto(de.symeda.sormas.api.feature.FeatureConfigurationDto) ConfigFacade(de.symeda.sormas.api.ConfigFacade) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with FeatureConfigurationDto

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;
}
Also used : FeatureConfigurationDto(de.symeda.sormas.api.feature.FeatureConfigurationDto)

Example 4 with FeatureConfigurationDto

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);
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FeatureConfigurationDto(de.symeda.sormas.api.feature.FeatureConfigurationDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 5 with FeatureConfigurationDto

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);
    }
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) Arrays(java.util.Arrays) CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) CountryFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.CountryFieldVisibilityChecker) Random(java.util.Random) PersonDto(de.symeda.sormas.api.person.PersonDto) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) EntityDto(de.symeda.sormas.api.EntityDto) CommunityDto(de.symeda.sormas.api.infrastructure.community.CommunityDto) Map(java.util.Map) CellCopyPolicy(org.apache.poi.ss.usermodel.CellCopyPolicy) Path(java.nio.file.Path) SubcontinentDto(de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto) EnumSet(java.util.EnumSet) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) PrescriptionDto(de.symeda.sormas.api.therapy.PrescriptionDto) Stateless(javax.ejb.Stateless) TaskDto(de.symeda.sormas.api.task.TaskDto) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) DiseaseConfigurationFacadeEjbLocal(de.symeda.sormas.backend.disease.DiseaseConfigurationFacadeEjb.DiseaseConfigurationFacadeEjbLocal) WorkbookUtil(org.apache.poi.ss.util.WorkbookUtil) Collection(java.util.Collection) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) XssfHelper(de.symeda.sormas.backend.util.XssfHelper) List(java.util.List) UserService(de.symeda.sormas.backend.user.UserService) Stream(java.util.stream.Stream) AreaReference(org.apache.poi.ss.util.AreaReference) SpreadsheetVersion(org.apache.poi.ss.SpreadsheetVersion) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) ActivityAsCaseDto(de.symeda.sormas.api.activityascase.ActivityAsCaseDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) CellStyle(org.apache.poi.ss.usermodel.CellStyle) FeatureConfigurationFacadeEjbLocal(de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal) TestReportDto(de.symeda.sormas.api.labmessage.TestReportDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) InfoFacade(de.symeda.sormas.api.info.InfoFacade) DateHelper(de.symeda.sormas.api.utils.DateHelper) RegionDto(de.symeda.sormas.api.infrastructure.region.RegionDto) HashMap(java.util.HashMap) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) PersonContactDetailDto(de.symeda.sormas.api.person.PersonContactDetailDto) SurveillanceReportDto(de.symeda.sormas.api.caze.surveillancereport.SurveillanceReportDto) ArrayList(java.util.ArrayList) CellReference(org.apache.poi.ss.util.CellReference) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) DiseaseFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.DiseaseFieldVisibilityChecker) BiPredicate(java.util.function.BiPredicate) FeatureTypeFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.FeatureTypeFieldVisibilityChecker) LocalBean(javax.ejb.LocalBean) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto) ContinentDto(de.symeda.sormas.api.infrastructure.continent.ContinentDto) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) ConfigFacadeEjbLocal(de.symeda.sormas.backend.common.ConfigFacadeEjb.ConfigFacadeEjbLocal) EJB(javax.ejb.EJB) ClinicalVisitDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto) OutputStream(java.io.OutputStream) LocationDto(de.symeda.sormas.api.location.LocationDto) TypeUtils(org.apache.commons.lang3.reflect.TypeUtils) DependingOnFeatureType(de.symeda.sormas.api.utils.DependingOnFeatureType) DataHelper(de.symeda.sormas.api.utils.DataHelper) Files(java.nio.file.Files) UserDto(de.symeda.sormas.api.user.UserDto) LabMessageDto(de.symeda.sormas.api.labmessage.LabMessageDto) IOException(java.io.IOException) FeatureConfigurationDto(de.symeda.sormas.api.feature.FeatureConfigurationDto) Field(java.lang.reflect.Field) Captions(de.symeda.sormas.api.i18n.Captions) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) File(java.io.File) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) UserRight(de.symeda.sormas.api.user.UserRight) VisitDto(de.symeda.sormas.api.visit.VisitDto) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) SampleDto(de.symeda.sormas.api.sample.SampleDto) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) VaccinationDto(de.symeda.sormas.api.vaccination.VaccinationDto) Paths(java.nio.file.Paths) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) XSSFCell(org.apache.poi.xssf.usermodel.XSSFCell) Collections(java.util.Collections) ActionDto(de.symeda.sormas.api.action.ActionDto) TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) CountryFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.CountryFieldVisibilityChecker) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) IOException(java.io.IOException) FeatureConfigurationDto(de.symeda.sormas.api.feature.FeatureConfigurationDto) DiseaseFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.DiseaseFieldVisibilityChecker) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) FeatureTypeFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.FeatureTypeFieldVisibilityChecker) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

FeatureConfigurationDto (de.symeda.sormas.api.feature.FeatureConfigurationDto)6 DatabaseTable (de.symeda.sormas.api.importexport.DatabaseTable)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 CheckBox (com.vaadin.v7.ui.CheckBox)1 ConfigFacade (de.symeda.sormas.api.ConfigFacade)1 EntityDto (de.symeda.sormas.api.EntityDto)1 ActionDto (de.symeda.sormas.api.action.ActionDto)1 ActivityAsCaseDto (de.symeda.sormas.api.activityascase.ActivityAsCaseDto)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 SurveillanceReportDto (de.symeda.sormas.api.caze.surveillancereport.SurveillanceReportDto)1 ClinicalVisitDto (de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto)1 HealthConditionsDto (de.symeda.sormas.api.clinicalcourse.HealthConditionsDto)1 ContactDto (de.symeda.sormas.api.contact.ContactDto)1 EpiDataDto (de.symeda.sormas.api.epidata.EpiDataDto)1 EventDto (de.symeda.sormas.api.event.EventDto)1 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)1 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)1 FeatureType (de.symeda.sormas.api.feature.FeatureType)1