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()));
}
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);
}
Aggregations