Search in sources :

Example 1 with CommunityCriteria

use of de.symeda.sormas.api.infrastructure.community.CommunityCriteria in project SORMAS-Project by hzi-braunschweig.

the class InfrastructureImporterTest method testDontImportDuplicateInfrastructure.

@Test
public void testDontImportDuplicateInfrastructure() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
    RDCF rdcf = new TestDataCreator().createRDCF("Default Region", "Default District", "Default Community", "Default Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Default", "User", UserRole.ADMIN);
    // Import region
    File regionCsvFile = new File(getClass().getClassLoader().getResource("sormas_region_import_test.csv").toURI());
    InfrastructureImporter importer = new InfrastructureImporterExtension(regionCsvFile, user, InfrastructureType.REGION);
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importer.runImport());
    assertEquals(2, getRegionFacade().count(new RegionCriteria()));
    // Import district
    File districtCsvFile = new File(getClass().getClassLoader().getResource("sormas_district_import_test.csv").toURI());
    importer = new InfrastructureImporterExtension(districtCsvFile, user, InfrastructureType.DISTRICT);
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importer.runImport());
    assertEquals(2, getDistrictFacade().count(new DistrictCriteria()));
    // Import community
    File communityCsvFile = new File(getClass().getClassLoader().getResource("sormas_community_import_test.csv").toURI());
    importer = new InfrastructureImporterExtension(communityCsvFile, user, InfrastructureType.COMMUNITY);
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importer.runImport());
    assertEquals(2, getCommunityFacade().count(new CommunityCriteria()));
    // Import facility
    File facilityCsvFile = new File(getClass().getClassLoader().getResource("sormas_facility_import_test.csv").toURI());
    importer = new InfrastructureImporterExtension(facilityCsvFile, user, InfrastructureType.FACILITY);
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importer.runImport());
    assertEquals(3, getFacilityFacade().count(new FacilityCriteria()));
    // Import point of entry
    File poeCsvFile = new File(getClass().getClassLoader().getResource("sormas_poe_import_test.csv").toURI());
    importer = new InfrastructureImporterExtension(poeCsvFile, user, InfrastructureType.POINT_OF_ENTRY);
    assertEquals(ImportResultStatus.COMPLETED_WITH_ERRORS, importer.runImport());
    assertEquals(1, getPointOfEntryFacade().count(new PointOfEntryCriteria()));
}
Also used : PointOfEntryCriteria(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryCriteria) RDCF(de.symeda.sormas.ui.TestDataCreator.RDCF) RegionCriteria(de.symeda.sormas.api.infrastructure.region.RegionCriteria) UserDto(de.symeda.sormas.api.user.UserDto) TestDataCreator(de.symeda.sormas.ui.TestDataCreator) DistrictCriteria(de.symeda.sormas.api.infrastructure.district.DistrictCriteria) FacilityCriteria(de.symeda.sormas.api.infrastructure.facility.FacilityCriteria) File(java.io.File) CommunityCriteria(de.symeda.sormas.api.infrastructure.community.CommunityCriteria) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 2 with CommunityCriteria

use of de.symeda.sormas.api.infrastructure.community.CommunityCriteria in project SORMAS-Project by hzi-braunschweig.

the class CommunitiesGrid method setLazyDataProvider.

public void setLazyDataProvider() {
    DataProvider<CommunityDto, CommunityCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getCommunityFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> {
        return (int) FacadeProvider.getCommunityFacade().count(query.getFilter().orElse(null));
    });
    setDataProvider(dataProvider);
    setSelectionMode(SelectionMode.NONE);
}
Also used : SortProperty(de.symeda.sormas.api.utils.SortProperty) CommunityDto(de.symeda.sormas.api.infrastructure.community.CommunityDto) CommunityCriteria(de.symeda.sormas.api.infrastructure.community.CommunityCriteria)

Aggregations

CommunityCriteria (de.symeda.sormas.api.infrastructure.community.CommunityCriteria)2 CommunityDto (de.symeda.sormas.api.infrastructure.community.CommunityDto)1 DistrictCriteria (de.symeda.sormas.api.infrastructure.district.DistrictCriteria)1 FacilityCriteria (de.symeda.sormas.api.infrastructure.facility.FacilityCriteria)1 PointOfEntryCriteria (de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryCriteria)1 RegionCriteria (de.symeda.sormas.api.infrastructure.region.RegionCriteria)1 UserDto (de.symeda.sormas.api.user.UserDto)1 SortProperty (de.symeda.sormas.api.utils.SortProperty)1 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)1 TestDataCreator (de.symeda.sormas.ui.TestDataCreator)1 RDCF (de.symeda.sormas.ui.TestDataCreator.RDCF)1 File (java.io.File)1 Test (org.junit.Test)1