use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testShareEvent.
@Test
public void testShareEvent() throws SormasToSormasException {
UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
useSurveillanceOfficerLogin(rdcf);
Date dateNow = new Date();
EventDto event = creator.createEvent(EventStatus.SCREENING, EventInvestigationStatus.ONGOING, "Test event title", "Test description", user.toReference(), (e) -> {
e.setRiskLevel(RiskLevel.MODERATE);
e.setMultiDayEvent(true);
e.setStartDate(dateNow);
e.setEndDate(dateNow);
e.setSrcType(EventSourceType.MEDIA_NEWS);
e.setSrcMediaWebsite("Test media name");
e.setSrcMediaName("Test media website");
e.setSrcMediaDetails("Test media details");
e.getEventLocation().setRegion(rdcf.region);
e.getEventLocation().setDistrict(rdcf.district);
});
SormasToSormasOptionsDto options = new SormasToSormasOptionsDto();
options.setOrganization(new SormasServerDescriptor(SECOND_SERVER_ID));
options.setComment("Test comment");
Mockito.when(MockProducer.getSormasToSormasClient().post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> {
assertThat(invocation.getArgument(0, String.class), is(SECOND_SERVER_ID));
assertThat(invocation.getArgument(1, String.class), is("/sormasToSormas/events"));
SormasToSormasDto postBody = invocation.getArgument(2, SormasToSormasDto.class);
assertThat(postBody.getEvents().size(), is(1));
SormasToSormasEventDto sharedEventData = postBody.getEvents().get(0);
EventDto sharedEvent = sharedEventData.getEntity();
assertThat(sharedEvent.getEventTitle(), is("Test event title"));
assertThat(sharedEvent.getEventDesc(), is("Test description"));
assertThat(sharedEvent.getEventStatus(), is(EventStatus.SCREENING));
assertThat(sharedEvent.getEventInvestigationStatus(), is(EventInvestigationStatus.ONGOING));
assertThat(sharedEvent.getRiskLevel(), is(RiskLevel.MODERATE));
assertThat(sharedEvent.isMultiDayEvent(), is(true));
assertThat(sharedEvent.getStartDate().getTime(), is(dateNow.getTime()));
assertThat(sharedEvent.getEndDate().getTime(), is(dateNow.getTime()));
assertThat(sharedEvent.getSrcType(), is(EventSourceType.MEDIA_NEWS));
assertThat(sharedEvent.getSrcMediaWebsite(), is("Test media name"));
assertThat(sharedEvent.getSrcMediaName(), is("Test media website"));
assertThat(sharedEvent.getSrcMediaDetails(), is("Test media details"));
// share information
assertThat(postBody.getOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
assertThat(postBody.getOriginInfo().getSenderName(), is("Surv Off"));
assertThat(postBody.getOriginInfo().getComment(), is("Test comment"));
return Response.noContent().build();
});
getSormasToSormasEventFacade().share(Collections.singletonList(event.getUuid()), options);
List<SormasToSormasShareInfoDto> shareInfoList = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().event(event.toReference()), 0, 100);
assertThat(shareInfoList.size(), is(1));
assertThat(shareInfoList.get(0).getTargetDescriptor().getId(), is(SECOND_SERVER_ID));
assertThat(shareInfoList.get(0).getSender().getCaption(), is("Surv OFF - Surveillance Officer"));
assertThat(shareInfoList.get(0).getComment(), is("Test comment"));
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class ShareDataBuilderHelperTest method testDoNotClearIgnoredPropertiesForEvent.
@Test
public void testDoNotClearIgnoredPropertiesForEvent() {
MockProducer.getProperties().setProperty(SormasToSormasConfig.SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS, Boolean.FALSE.toString());
MockProducer.getProperties().setProperty(SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_ID, Boolean.FALSE.toString());
MockProducer.getProperties().setProperty(SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN, Boolean.FALSE.toString());
MockProducer.getProperties().setProperty(SormasToSormasConfig.SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN, Boolean.FALSE.toString());
UserReferenceDto officerReferenceDto = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
EventDto eventDto = creator.createEvent(officerReferenceDto);
eventDto.setDisease(Disease.CORONAVIRUS);
eventDto.setExternalId("externalId");
eventDto.setExternalToken("externalToken");
eventDto.setInternalToken("internalToken");
getShareDataBuilderHelper().clearIgnoredProperties(eventDto);
assertThat(eventDto.getDisease(), not(nullValue()));
assertThat(eventDto.getExternalId(), is("externalId"));
assertThat(eventDto.getExternalToken(), is("externalToken"));
assertThat(eventDto.getInternalToken(), is("internalToken"));
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantsController method getEventParticipantDataEditComponent.
public CommitDiscardWrapperComponent<?> getEventParticipantDataEditComponent(String eventParticipantUuid) {
final EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantUuid);
final EventDto event = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid(), false);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getEventParticipantFacade().getAutomaticDeletionInfo(eventParticipantUuid);
final EventParticipantEditForm editForm = new EventParticipantEditForm(event, eventParticipant.isPseudonymized(), eventParticipant.getPerson().isPseudonymized(), false);
editForm.setValue(eventParticipant);
editForm.setWidth(100, Unit.PERCENTAGE);
final CommitDiscardWrapperComponent<EventParticipantEditForm> editComponent = createEventParticipantEditCommitWrapper(editForm, null);
if (automaticDeletionInfoDto != null) {
editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_DELETE)) {
editComponent.addDeleteListener(() -> {
FacadeProvider.getEventParticipantFacade().deleteEventParticipant(eventParticipant.toReference());
ControllerProvider.getEventController().navigateToParticipants(eventParticipant.getEvent().getUuid());
}, I18nProperties.getString(Strings.entityEventParticipant));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_ARCHIVE)) {
boolean archived = FacadeProvider.getEventParticipantFacade().isArchived(eventParticipant.getUuid());
Button archiveButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editComponent.isModified()) {
editComponent.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(eventParticipant, FacadeProvider.getEventParticipantFacade(), Strings.headingDearchiveEventParticipant, Strings.confirmationDearchiveEventParticipant, Strings.entityEventParticipant, Strings.messageEventParticipantDearchived, () -> navigateToData(eventParticipant.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(eventParticipant, FacadeProvider.getEventParticipantFacade(), Strings.headingArchiveEventParticipant, Strings.confirmationArchiveEventParticipant, Strings.entityEventParticipant, Strings.messageEventParticipantArchived, () -> navigateToData(eventParticipant.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editComponent.getButtonsPanel().addComponentAsFirst(archiveButton);
editComponent.getButtonsPanel().setComponentAlignment(archiveButton, Alignment.BOTTOM_LEFT);
}
return editComponent;
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method createFromContactList.
public EventDto createFromContactList(List<ContactReferenceDto> contactRefs) {
CommitDiscardWrapperComponent<EventDataForm> eventCreateComponent = getEventCreateComponentForContactList(contactRefs);
EventDto eventDto = eventCreateComponent.getWrappedComponent().getValue();
VaadinUiUtil.showModalPopupWindow(eventCreateComponent, I18nProperties.getString(Strings.headingCreateNewEvent));
return eventDto;
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateSuperordinateEvent.
public void selectOrCreateSuperordinateEvent(EventReferenceDto subordinateEventRef) {
Set<String> excludedUuids = new HashSet<>();
excludedUuids.add(subordinateEventRef.getUuid());
excludedUuids.addAll(FacadeProvider.getEventFacade().getAllSubordinateEventUuids(subordinateEventRef.getUuid()));
EventDto subordinateEvent = FacadeProvider.getEventFacade().getEventByUuid(subordinateEventRef.getUuid(), false);
EventSelectionField selectionField = EventSelectionField.forSuperordinateEvent(subordinateEvent, excludedUuids);
selectionField.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = selectionField.getValue();
if (selectedEvent != null) {
subordinateEvent.setSuperordinateEvent(selectedEvent.toReference());
FacadeProvider.getEventFacade().save(subordinateEvent);
navigateToData(subordinateEventRef.getUuid());
Notification.show(I18nProperties.getString(Strings.messageEventLinkedAsSuperordinate), Type.TRAY_NOTIFICATION);
} else {
createSuperordinateEvent(subordinateEventRef);
}
});
selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
Aggregations