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