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