Search in sources :

Example 1 with CampaignFormMetaDto

use of de.symeda.sormas.api.campaign.form.CampaignFormMetaDto in project SORMAS-Project by hzi-braunschweig.

the class CampaignFormDataEditForm method buildCampaignForm.

private void buildCampaignForm(CampaignFormDataDto campaignFormData) {
    GridLayout campaignFormLayout = new GridLayout(12, 1);
    campaignFormLayout.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(campaignFormLayout, CssStyles.VSPACE_3);
    CampaignFormMetaDto campaignForm = FacadeProvider.getCampaignFormMetaFacade().getCampaignFormMetaByUuid(campaignFormData.getCampaignFormMeta().getUuid());
    campaignFormBuilder = new CampaignFormBuilder(campaignForm.getCampaignFormElements(), campaignFormData.getFormValues(), campaignFormLayout, campaignForm.getCampaignFormTranslations());
    campaignFormBuilder.buildForm();
    final ExpressionProcessor expressionProcessor = new ExpressionProcessor(campaignFormBuilder);
    expressionProcessor.disableExpressionFieldsForEditing();
    expressionProcessor.configureExpressionFieldsWithTooltip();
    expressionProcessor.addExpressionListener();
    getContent().addComponent(campaignFormLayout, CAMPAIGN_FORM_LOC);
}
Also used : GridLayout(com.vaadin.ui.GridLayout) ExpressionProcessor(de.symeda.sormas.ui.campaign.expressions.ExpressionProcessor) CampaignFormMetaDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaDto)

Example 2 with CampaignFormMetaDto

use of de.symeda.sormas.api.campaign.form.CampaignFormMetaDto in project SORMAS-Project by hzi-braunschweig.

the class CampaignFormMetaFacadeEjb method toDto.

public CampaignFormMetaDto toDto(CampaignFormMeta source) {
    if (source == null) {
        return null;
    }
    CampaignFormMetaDto target = new CampaignFormMetaDto();
    DtoHelper.fillDto(target, source);
    target.setFormId(source.getFormId());
    target.setFormName(source.getFormName());
    target.setLanguageCode(source.getLanguageCode());
    target.setCampaignFormElements(source.getCampaignFormElementsList());
    target.setCampaignFormTranslations(source.getCampaignFormTranslationsList());
    return target;
}
Also used : CampaignFormMetaDto(de.symeda.sormas.api.campaign.form.CampaignFormMetaDto)

Example 3 with CampaignFormMetaDto

use of de.symeda.sormas.api.campaign.form.CampaignFormMetaDto 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 CampaignFormMetaDto

use of de.symeda.sormas.api.campaign.form.CampaignFormMetaDto 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 CampaignFormMetaDto

use of de.symeda.sormas.api.campaign.form.CampaignFormMetaDto 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

CampaignFormMetaDto (de.symeda.sormas.api.campaign.form.CampaignFormMetaDto)12 CampaignReferenceDto (de.symeda.sormas.api.campaign.CampaignReferenceDto)4 CampaignDto (de.symeda.sormas.api.campaign.CampaignDto)3 UserDto (de.symeda.sormas.api.user.UserDto)3 ValidationRuntimeException (de.symeda.sormas.api.utils.ValidationRuntimeException)3 AbstractBeanTest (de.symeda.sormas.ui.AbstractBeanTest)3 TestDataCreator (de.symeda.sormas.ui.TestDataCreator)3 File (java.io.File)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 CampaignFormDataDto (de.symeda.sormas.api.campaign.data.CampaignFormDataDto)2 CampaignFormElement (de.symeda.sormas.api.campaign.form.CampaignFormElement)2 CampaignFormElementType (de.symeda.sormas.api.campaign.form.CampaignFormElementType)2 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)2 Validations (de.symeda.sormas.api.i18n.Validations)2 ImportErrorException (de.symeda.sormas.api.importexport.ImportErrorException)2 ImportLineResultDto (de.symeda.sormas.api.importexport.ImportLineResultDto)2 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)2 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)2 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)2