Search in sources :

Example 16 with EventDto

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"));
}
Also used : SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) SormasToSormasShareInfoCriteria(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria) Date(java.util.Date) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 17 with EventDto

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"));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) EventDto(de.symeda.sormas.api.event.EventDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 18 with EventDto

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;
}
Also used : Button(com.vaadin.ui.Button) EventDto(de.symeda.sormas.api.event.EventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) AutomaticDeletionInfoDto(de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel)

Example 19 with EventDto

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;
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto)

Example 20 with 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));
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) HashSet(java.util.HashSet) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField)

Aggregations

EventDto (de.symeda.sormas.api.event.EventDto)125 Test (org.junit.Test)71 UserDto (de.symeda.sormas.api.user.UserDto)49 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)46 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)39 PersonDto (de.symeda.sormas.api.person.PersonDto)38 Date (java.util.Date)38 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)23 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)22 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)22 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)17 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)16 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)16 SampleDto (de.symeda.sormas.api.sample.SampleDto)14 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)14 List (java.util.List)13 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)11 LocalDate (java.time.LocalDate)11 EventParticipantCriteria (de.symeda.sormas.api.event.EventParticipantCriteria)10