use of de.symeda.sormas.api.campaign.CampaignReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CampaignDataView method fillNewFormDropdown.
private void fillNewFormDropdown(Panel containerPanel) {
CampaignReferenceDto campaignReferenceDto = campaignSelector.getValue();
if (campaignReferenceDto != null) {
List<CampaignFormMetaReferenceDto> campagaignFormReferences = FacadeProvider.getCampaignFormMetaFacade().getCampaignFormMetasAsReferencesByCampaign(campaignReferenceDto.getUuid());
for (CampaignFormMetaReferenceDto campaignForm : campagaignFormReferences) {
Button campaignFormButton = ButtonHelper.createButton(campaignForm.toString(), e -> {
ControllerProvider.getCampaignController().createCampaignDataForm(criteria.getCampaign(), campaignForm);
newFormButton.setPopupVisible(false);
});
campaignFormButton.setWidth(100, Unit.PERCENTAGE);
((VerticalLayout) containerPanel.getContent()).addComponent(campaignFormButton);
}
if (campagaignFormReferences.size() >= 10) {
// setting a fixed height will enable a scrollbar. Increase width to accommodate it
containerPanel.setHeight(400, Unit.PIXELS);
containerPanel.setWidth(containerPanel.getContent().getWidth() + 20.0f, Unit.PIXELS);
} else {
containerPanel.setHeightUndefined();
containerPanel.setWidth(containerPanel.getContent().getWidth(), Unit.PIXELS);
}
}
}
use of de.symeda.sormas.api.campaign.CampaignReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CampaignDataView method fillImportDropdown.
private void fillImportDropdown(Panel containerPanel) {
CampaignReferenceDto campaignReferenceDto = campaignSelector.getValue();
if (campaignReferenceDto != null) {
List<CampaignFormMetaReferenceDto> campagaignFormReferences = FacadeProvider.getCampaignFormMetaFacade().getCampaignFormMetasAsReferencesByCampaign(campaignReferenceDto.getUuid());
for (CampaignFormMetaReferenceDto campaignForm : campagaignFormReferences) {
Button campaignFormButton = ButtonHelper.createButton(campaignForm.toString(), e -> {
importCampaignButton.setPopupVisible(false);
try {
Window popupWindow = VaadinUiUtil.showPopupWindow(new CampaignFormDataImportLayout(campaignForm, campaignReferenceDto));
popupWindow.setCaption(I18nProperties.getString(Strings.headingImportCampaign));
popupWindow.addCloseListener(c -> grid.reload());
} catch (IOException ioException) {
ioException.printStackTrace();
}
});
campaignFormButton.setWidth(100, Unit.PERCENTAGE);
((VerticalLayout) containerPanel.getContent()).addComponent(campaignFormButton);
}
if (campagaignFormReferences.size() >= 10) {
// setting a fixed height will enable a scrollbar. Increase width to accommodate it
containerPanel.setHeight(400, Unit.PIXELS);
containerPanel.setWidth(containerPanel.getContent().getWidth() + 20.0f, Unit.PIXELS);
} else {
containerPanel.setHeightUndefined();
containerPanel.setWidth(containerPanel.getContent().getWidth(), Unit.PIXELS);
}
}
}
use of de.symeda.sormas.api.campaign.CampaignReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CampaignFormDataImporterTest method testImportCampaignFormData.
@Test
@Ignore("Remove ignore once we have replaced H2 - #2526")
public void testImportCampaignFormData() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
final TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Nat", "User", UserRole.NATIONAL_USER);
final CampaignDto campaign = creator.createCampaign(user);
final CampaignFormMetaDto campaignForm = creator.createCampaignForm(campaign);
File csvFile = new File(getClass().getClassLoader().getResource("campaign/sormas_campaign_data_import_test_success.csv").toURI());
CampaignFormDataImporterExtension campaignFormDataImporter = new CampaignFormDataImporterExtension(csvFile, false, user, campaignForm.getUuid(), new CampaignReferenceDto(campaign.getUuid()));
ImportResultStatus importResult = campaignFormDataImporter.runImport();
assertTrue(campaignFormDataImporter.getErrorMessages().isEmpty());
assertEquals(ImportResultStatus.COMPLETED, importResult);
}
use of de.symeda.sormas.api.campaign.CampaignReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CampaignFormDataImporterTest method testImportCampaignFormDataWithWrongDataType.
@Test
public void testImportCampaignFormDataWithWrongDataType() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
final TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Nat", "User", UserRole.NATIONAL_USER);
final CampaignDto campaign = creator.createCampaign(user);
final CampaignFormMetaDto campaignForm = creator.createCampaignForm(campaign);
File csvFile = new File(getClass().getClassLoader().getResource("campaign/sormas_campaign_data_import_test_wrong_type.csv").toURI());
CampaignFormDataImporterExtension campaignFormDataImporter = new CampaignFormDataImporterExtension(csvFile, false, user, campaignForm.getUuid(), new CampaignReferenceDto(campaign.getUuid()));
ImportResultStatus importResult = campaignFormDataImporter.runImport();
assertFalse(campaignFormDataImporter.getErrorMessages().isEmpty());
assertEquals("Value nonNumeric in column infected does not match expected data type.", campaignFormDataImporter.getErrorMessages().get(0));
}
use of de.symeda.sormas.api.campaign.CampaignReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CampaignFormDataImporterTest method testImportCampaignFormDataIgnoringNonExistingColumn.
@Test
@Ignore("Remove ignore once we have replaced H2 - #2526")
public void testImportCampaignFormDataIgnoringNonExistingColumn() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
final TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Nat", "User", UserRole.NATIONAL_USER);
final CampaignDto campaign = creator.createCampaign(user);
final CampaignFormMetaDto campaignForm = creator.createCampaignForm(campaign);
File csvFile = new File(getClass().getClassLoader().getResource("campaign/sormas_campaign_data_import_test_nonexisting_column.csv").toURI());
CampaignFormDataImporterExtension campaignFormDataImporter = new CampaignFormDataImporterExtension(csvFile, false, user, campaignForm.getUuid(), new CampaignReferenceDto(campaign.getUuid()));
campaignFormDataImporter.runImport();
assertTrue(campaignFormDataImporter.getErrorMessages().isEmpty());
}
Aggregations