Search in sources :

Example 1 with SormasToSormasEventPreview

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview in project SORMAS-Project by hzi-braunschweig.

the class EventShareDataBuilder method getEventPreview.

private SormasToSormasEventPreview getEventPreview(Event event, Pseudonymizer pseudonymizer) {
    SormasToSormasEventPreview preview = new SormasToSormasEventPreview();
    preview.setUuid(event.getUuid());
    preview.setReportDateTime(event.getReportDateTime());
    preview.setEventTitle(event.getEventTitle());
    preview.setEventDesc(event.getEventDesc());
    preview.setDisease(event.getDisease());
    preview.setDiseaseDetails(event.getDiseaseDetails());
    preview.setEventLocation(LocationFacadeEjb.toDto(event.getEventLocation()));
    pseudonymizer.pseudonymizeDto(SormasToSormasEventPreview.class, preview, false, null);
    return preview;
}
Also used : SormasToSormasEventPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview)

Example 2 with SormasToSormasEventPreview

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview in project SORMAS-Project by hzi-braunschweig.

the class InfraValidationSoundnessTest method testShareEventValidation.

@Test
public void testShareEventValidation() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException {
    class EventDtoRootNode extends DtoRootNode<SormasToSormasEventDto> {

        public EventDtoRootNode(SormasToSormasEventDto dtoUnderTest) {
            super(dtoUnderTest);
        }
    }
    class EventPreviewRootNode extends DtoRootNode<SormasToSormasEventPreview> {

        public EventPreviewRootNode(SormasToSormasEventPreview dtoUnderTest) {
            super(dtoUnderTest);
        }
    }
    before();
    SormasToSormasEventDto eventDto = new SormasToSormasEventDto();
    EventDtoRootNode rootNode = new EventDtoRootNode(eventDto);
    assertValidationDto(eventDto, rootNode, eventDtoValidator);
    SormasToSormasEventPreview eventPreview = new SormasToSormasEventPreview();
    EventPreviewRootNode previewRootNode = new EventPreviewRootNode(eventPreview);
    assertValidationPreview(eventPreview, previewRootNode, eventDtoValidator);
}
Also used : SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasEventPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 3 with SormasToSormasEventPreview

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview in project SORMAS-Project by hzi-braunschweig.

the class EventPreviewGrid method buildGrid.

private void buildGrid() {
    setSizeFull();
    setSelectionMode(SelectionMode.SINGLE);
    setHeightMode(HeightMode.ROW);
    Language userLanguage = I18nProperties.getUserLanguage();
    removeColumn(SormasToSormasEventPreview.DISEASE);
    addComponentColumn(casePreview -> {
        String diseaseText;
        if (casePreview.getDisease() == null) {
            diseaseText = "";
        } else {
            diseaseText = casePreview.getDisease().toString();
            if (!StringUtils.isEmpty(casePreview.getDiseaseDetails())) {
                diseaseText += " - " + casePreview.getDiseaseDetails();
            }
        }
        return new Label(diseaseText);
    }).setId(SormasToSormasEventPreview.DISEASE);
    removeColumn(SormasToSormasEventPreview.EVENT_LOCATION);
    addComponentColumn(previewData -> new Label(LocationHelper.buildLocationString(previewData.getEventLocation()))).setId(SormasToSormasEventPreview.EVENT_LOCATION);
    setColumns(SormasToSormasEventPreview.UUID, SormasToSormasEventPreview.REPORT_DATE_TIME, SormasToSormasEventPreview.EVENT_TITLE, SormasToSormasEventPreview.EVENT_DESC, SormasToSormasEventPreview.DISEASE, SormasToSormasEventPreview.EVENT_LOCATION);
    ((Column<SormasToSormasEventPreview, String>) getColumn(SormasToSormasEventPreview.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasEventPreview, Date>) getColumn(SormasToSormasEventPreview.REPORT_DATE_TIME)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaption(column.getId(), SormasToSormasEventPreview.I18N_PREFIX, SormasToSormasPersonPreview.I18N_PREFIX));
    }
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) SormasToSormasPersonPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) SormasToSormasEventPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview) DateHelper(de.symeda.sormas.api.utils.DateHelper) StringUtils(org.apache.commons.lang3.StringUtils) Language(de.symeda.sormas.api.Language) HeightMode(com.vaadin.shared.ui.grid.HeightMode) List(java.util.List) Label(com.vaadin.ui.Label) LocationHelper(de.symeda.sormas.api.utils.LocationHelper) Grid(com.vaadin.ui.Grid) DateRenderer(com.vaadin.ui.renderers.DateRenderer) Language(de.symeda.sormas.api.Language) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) Label(com.vaadin.ui.Label) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 4 with SormasToSormasEventPreview

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasShareRequest method getEventsList.

@Transient
public List<SormasToSormasEventPreview> getEventsList() {
    if (eventsList == null) {
        if (StringUtils.isBlank(events)) {
            eventsList = new ArrayList<>();
        } else {
            try {
                ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                eventsList = Arrays.asList(mapper.readValue(events, SormasToSormasEventPreview[].class));
            } catch (IOException e) {
                throw new ValidationRuntimeException("Content of events could not be parsed to List<SormasToSormasEventPreview> - ID: " + getId());
            }
        }
    }
    return eventsList;
}
Also used : IOException(java.io.IOException) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SormasToSormasEventPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview) Transient(javax.persistence.Transient)

Aggregations

SormasToSormasEventPreview (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasEventPreview)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HeightMode (com.vaadin.shared.ui.grid.HeightMode)1 Grid (com.vaadin.ui.Grid)1 Label (com.vaadin.ui.Label)1 DateRenderer (com.vaadin.ui.renderers.DateRenderer)1 Language (de.symeda.sormas.api.Language)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)1 SormasToSormasPersonPreview (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview)1 DateHelper (de.symeda.sormas.api.utils.DateHelper)1 LocationHelper (de.symeda.sormas.api.utils.LocationHelper)1 ValidationRuntimeException (de.symeda.sormas.api.utils.ValidationRuntimeException)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 UuidRenderer (de.symeda.sormas.ui.utils.UuidRenderer)1 IOException (java.io.IOException)1 Date (java.util.Date)1 List (java.util.List)1 Transient (javax.persistence.Transient)1 StringUtils (org.apache.commons.lang3.StringUtils)1