Search in sources :

Example 1 with SormasToSormasContactPreview

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

the class InfraValidationSoundnessTest method testShareContactValidation.

@Test
public void testShareContactValidation() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException {
    class ContactDtoRootNode extends DtoRootNode<SormasToSormasContactDto> {

        public ContactDtoRootNode(SormasToSormasContactDto dtoUnderTest) {
            super(dtoUnderTest);
        }
    }
    class ContactPreviewRootNode extends DtoRootNode<SormasToSormasContactPreview> {

        public ContactPreviewRootNode(SormasToSormasContactPreview dtoUnderTest) {
            super(dtoUnderTest);
        }
    }
    before();
    SormasToSormasContactDto contactDto = new SormasToSormasContactDto();
    ContactDtoRootNode rootNode = new ContactDtoRootNode(contactDto);
    assertValidationDto(contactDto, rootNode, contactDtoValidator);
    SormasToSormasContactPreview contactPreview = new SormasToSormasContactPreview();
    ContactPreviewRootNode previewRootNode = new ContactPreviewRootNode(contactPreview);
    assertValidationPreview(contactPreview, previewRootNode, contactDtoValidator);
}
Also used : SormasToSormasContactPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasContactPreview) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with SormasToSormasContactPreview

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

the class ContactsPreviewGrid method buildGrid.

private void buildGrid() {
    setSizeFull();
    setSelectionMode(Grid.SelectionMode.SINGLE);
    setHeightMode(HeightMode.ROW);
    Language userLanguage = I18nProperties.getUserLanguage();
    removeColumn(SormasToSormasContactPreview.DISEASE);
    addComponentColumn(eventPreview -> {
        String diseaseText = eventPreview.getDisease().toString();
        if (!StringUtils.isEmpty(eventPreview.getDiseaseDetails())) {
            diseaseText += " - " + eventPreview.getDiseaseDetails();
        }
        return new Label(diseaseText);
    }).setId(SormasToSormasContactPreview.DISEASE);
    List<String> columnConfig = new ArrayList<>();
    columnConfig.addAll(Arrays.asList(SormasToSormasContactPreview.UUID, SormasToSormasContactPreview.REPORT_DATE_TIME, SormasToSormasContactPreview.DISEASE, SormasToSormasContactPreview.CONTACT_STATUS, SormasToSormasContactPreview.CONTACT_CLASSIFICATION, SormasToSormasContactPreview.CONTACT_CATEGORY));
    columnConfig.addAll(PreviewGridHelper.createPersonColumns(this, SormasToSormasContactPreview::getPerson));
    columnConfig.addAll(Arrays.asList(SormasToSormasContactPreview.REGION, SormasToSormasContactPreview.DISTRICT, SormasToSormasContactPreview.COMMUNITY, SormasToSormasContactPreview.LAST_CONTACT_DATE));
    setColumns(columnConfig);
    ((Column<SormasToSormasContactPreview, String>) getColumn(SormasToSormasContactPreview.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasContactPreview, Date>) getColumn(SormasToSormasContactPreview.REPORT_DATE_TIME)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    ((Column<SormasToSormasContactPreview, Date>) getColumn(SormasToSormasContactPreview.LAST_CONTACT_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(userLanguage)));
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.findPrefixCaption(column.getId(), SormasToSormasContactPreview.I18N_PREFIX, SormasToSormasPersonPreview.I18N_PREFIX));
    }
}
Also used : Arrays(java.util.Arrays) 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) Collection(java.util.Collection) SormasToSormasContactPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasContactPreview) 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) ArrayList(java.util.ArrayList) List(java.util.List) Label(com.vaadin.ui.Label) 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) ArrayList(java.util.ArrayList) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 3 with SormasToSormasContactPreview

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

the class ShareDataBuilderHelper method getContactPreview.

public SormasToSormasContactPreview getContactPreview(Contact contact, Pseudonymizer pseudonymizer) {
    SormasToSormasContactPreview contactPreview = new SormasToSormasContactPreview();
    contactPreview.setUuid(contact.getUuid());
    contactPreview.setReportDateTime(contact.getReportDateTime());
    contactPreview.setDisease(contact.getDisease());
    contactPreview.setDiseaseDetails(contact.getDiseaseDetails());
    contactPreview.setLastContactDate(contact.getLastContactDate());
    contactPreview.setContactClassification(contact.getContactClassification());
    contactPreview.setContactCategory(contact.getContactCategory());
    contactPreview.setContactStatus(contact.getContactStatus());
    contactPreview.setRegion(RegionFacadeEjb.toReferenceDto(contact.getRegion()));
    contactPreview.setDistrict(DistrictFacadeEjb.toReferenceDto(contact.getDistrict()));
    contactPreview.setCommunity(CommunityFacadeEjb.toReferenceDto(contact.getCommunity()));
    contactPreview.setPerson(getPersonPreview(contact.getPerson()));
    contactPreview.setCaze(CaseFacadeEjb.toReferenceDto(contact.getCaze()));
    pseudonymizer.pseudonymizeDto(SormasToSormasContactPreview.class, contactPreview, false, null);
    return contactPreview;
}
Also used : SormasToSormasContactPreview(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasContactPreview)

Example 4 with SormasToSormasContactPreview

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

the class SormasToSormasShareRequest method getContactsList.

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

Aggregations

SormasToSormasContactPreview (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasContactPreview)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 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)1 SormasToSormasPersonPreview (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasPersonPreview)1 DateHelper (de.symeda.sormas.api.utils.DateHelper)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 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1