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