Search in sources :

Example 1 with CampaignReferenceDto

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);
        }
    }
}
Also used : PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) CampaignFormMetaReferenceDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaReferenceDto) VerticalLayout(com.vaadin.ui.VerticalLayout) CampaignReferenceDto(de.symeda.sormas.api.campaign.CampaignReferenceDto)

Example 2 with CampaignReferenceDto

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);
        }
    }
}
Also used : Window(com.vaadin.ui.Window) CampaignFormDataImportLayout(de.symeda.sormas.ui.campaign.importer.CampaignFormDataImportLayout) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) CampaignFormMetaReferenceDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaReferenceDto) VerticalLayout(com.vaadin.ui.VerticalLayout) IOException(java.io.IOException) CampaignReferenceDto(de.symeda.sormas.api.campaign.CampaignReferenceDto)

Example 3 with CampaignReferenceDto

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);
}
Also used : CampaignDto(de.symeda.sormas.api.campaign.CampaignDto) UserDto(de.symeda.sormas.api.user.UserDto) CampaignFormMetaDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaDto) TestDataCreator(de.symeda.sormas.ui.TestDataCreator) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) File(java.io.File) CampaignReferenceDto(de.symeda.sormas.api.campaign.CampaignReferenceDto) Ignore(org.junit.Ignore) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 4 with CampaignReferenceDto

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));
}
Also used : CampaignDto(de.symeda.sormas.api.campaign.CampaignDto) UserDto(de.symeda.sormas.api.user.UserDto) CampaignFormMetaDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaDto) TestDataCreator(de.symeda.sormas.ui.TestDataCreator) ImportResultStatus(de.symeda.sormas.ui.importer.ImportResultStatus) File(java.io.File) CampaignReferenceDto(de.symeda.sormas.api.campaign.CampaignReferenceDto) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Example 5 with CampaignReferenceDto

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());
}
Also used : CampaignDto(de.symeda.sormas.api.campaign.CampaignDto) UserDto(de.symeda.sormas.api.user.UserDto) CampaignFormMetaDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaDto) TestDataCreator(de.symeda.sormas.ui.TestDataCreator) File(java.io.File) CampaignReferenceDto(de.symeda.sormas.api.campaign.CampaignReferenceDto) Ignore(org.junit.Ignore) AbstractBeanTest(de.symeda.sormas.ui.AbstractBeanTest) Test(org.junit.Test)

Aggregations

CampaignReferenceDto (de.symeda.sormas.api.campaign.CampaignReferenceDto)9 CampaignDto (de.symeda.sormas.api.campaign.CampaignDto)4 UserDto (de.symeda.sormas.api.user.UserDto)4 Test (org.junit.Test)4 CampaignFormMetaDto (de.symeda.sormas.api.campaign.form.CampaignFormMetaDto)3 CampaignFormMetaReferenceDto (de.symeda.sormas.api.campaign.form.CampaignFormMetaReferenceDto)3 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)3 TestDataCreator (de.symeda.sormas.ui.TestDataCreator)3 File (java.io.File)3 Button (com.vaadin.ui.Button)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 ImportResultStatus (de.symeda.sormas.ui.importer.ImportResultStatus)2 IOException (java.io.IOException)2 Ignore (org.junit.Ignore)2 PopupButton (org.vaadin.hene.popupbutton.PopupButton)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Window (com.vaadin.ui.Window)1 CampaignFormDataDto (de.symeda.sormas.api.campaign.data.CampaignFormDataDto)1 CampaignFormDataEntry (de.symeda.sormas.api.campaign.data.CampaignFormDataEntry)1 CampaignDiagramDataDto (de.symeda.sormas.api.campaign.diagram.CampaignDiagramDataDto)1