use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class SampleDataView method initView.
@Override
protected void initView(String params) {
setHeightUndefined();
String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EDIT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CASE_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CONTACT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENT_PARTICIPANT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, PATHOGEN_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ADDITIONAL_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SORMAS_TO_SORMAS_LOC));
DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
container.setWidth(100, Unit.PERCENTAGE);
container.setMargin(true);
setSubComponent(container);
CustomLayout layout = new CustomLayout();
layout.addStyleName(CssStyles.ROOT_COMPONENT);
layout.setTemplateContents(htmlLayout);
layout.setWidth(100, Unit.PERCENTAGE);
layout.setHeightUndefined();
container.addComponent(layout);
SampleDto sampleDto = FacadeProvider.getSampleFacade().getSampleByUuid(getSampleRef().getUuid());
Disease disease = null;
final CaseReferenceDto associatedCase = sampleDto.getAssociatedCase();
if (associatedCase != null) {
final CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(associatedCase.getUuid());
disease = caseDto.getDisease();
final CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto);
caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(caseInfoLayout, CASE_LOC);
}
final ContactReferenceDto associatedContact = sampleDto.getAssociatedContact();
if (associatedContact != null) {
final ContactDto contactDto = FacadeProvider.getContactFacade().getByUuid(associatedContact.getUuid());
disease = contactDto.getDisease();
final ContactInfoLayout contactInfoLayout = new ContactInfoLayout(contactDto, UiFieldAccessCheckers.getDefault(contactDto.isPseudonymized()));
contactInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(contactInfoLayout, CONTACT_LOC);
}
final EventParticipantReferenceDto associatedEventParticipant = sampleDto.getAssociatedEventParticipant();
if (associatedEventParticipant != null) {
final EventParticipantDto eventParticipantDto = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(associatedEventParticipant.getUuid());
final EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(eventParticipantDto.getEvent().getUuid(), false);
disease = eventDto.getDisease();
final EventParticipantInfoLayout eventParticipantInfoLayout = new EventParticipantInfoLayout(eventParticipantDto, eventDto, UiFieldAccessCheckers.getDefault(eventParticipantDto.isPseudonymized()));
eventParticipantInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(eventParticipantInfoLayout, EVENT_PARTICIPANT_LOC);
}
SampleController sampleController = ControllerProvider.getSampleController();
editComponent = sampleController.getSampleEditComponent(getSampleRef().getUuid(), sampleDto.isPseudonymized(), disease, true);
Consumer<Disease> createReferral = (relatedDisease) -> {
// save changes before referral creation
editComponent.commit();
SampleDto committedSample = editComponent.getWrappedComponent().getValue();
sampleController.createReferral(committedSample, relatedDisease);
};
Consumer<SampleDto> openReferredSample = referredSample -> sampleController.navigateToData(referredSample.getUuid());
sampleController.addReferOrLinkToOtherLabButton(editComponent, disease, createReferral, openReferredSample);
Consumer<SampleDto> navigate = targetSampleDto -> sampleController.navigateToData(targetSampleDto.getUuid());
sampleController.addReferredFromButton(editComponent, navigate);
editComponent.setMargin(new MarginInfo(false, false, true, false));
editComponent.setWidth(100, Unit.PERCENTAGE);
editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
layout.addComponent(editComponent, EDIT_LOC);
BiConsumer<PathogenTestDto, Runnable> onSavedPathogenTest = (pathogenTestDto, callback) -> callback.run();
// why? if(sampleDto.getSamplePurpose() !=null && sampleDto.getSamplePurpose().equals(SamplePurpose.EXTERNAL)) {
Supplier<Boolean> createOrEditAllowedCallback = () -> editComponent.getWrappedComponent().getFieldGroup().isValid();
SampleReferenceDto sampleReferenceDto = getSampleRef();
PathogenTestListComponent pathogenTestListComponent = new PathogenTestListComponent(sampleReferenceDto);
pathogenTestListComponent.addSideComponentCreateEventListener(e -> showNavigationConfirmPopupIfDirty(() -> {
if (createOrEditAllowedCallback.get()) {
ControllerProvider.getPathogenTestController().create(sampleReferenceDto, 0, pathogenTestListComponent::reload, onSavedPathogenTest);
} else {
Notification.show(null, I18nProperties.getString(Strings.messageFormHasErrorsPathogenTest), Notification.Type.ERROR_MESSAGE);
}
}));
pathogenTestListComponent.addSideComponentEditEventListener(e -> showNavigationConfirmPopupIfDirty(() -> {
String uuid = e.getUuid();
if (createOrEditAllowedCallback.get()) {
ControllerProvider.getPathogenTestController().edit(uuid, pathogenTestListComponent::reload, onSavedPathogenTest);
} else {
Notification.show(null, I18nProperties.getString(Strings.messageFormHasErrorsPathogenTest), Notification.Type.ERROR_MESSAGE);
}
}));
layout.addComponent(new SideComponentLayout(pathogenTestListComponent), PATHOGEN_TESTS_LOC);
if (UserProvider.getCurrent() != null && UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW) && FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.ADDITIONAL_TESTS)) {
AdditionalTestListComponent additionalTestList = new AdditionalTestListComponent(sampleReferenceDto.getUuid());
additionalTestList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(additionalTestList, ADDITIONAL_TESTS_LOC);
}
boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser();
if (sormasToSormasEnabled || sampleDto.getSormasToSormasOriginInfo() != null) {
VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
sormasToSormasLocLayout.setMargin(false);
sormasToSormasLocLayout.setSpacing(false);
SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(sampleDto);
sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
layout.addComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
}
// }
setSampleEditPermission(container);
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class EventShareDataBuilder method getEventDto.
private EventDto getEventDto(Event event, Pseudonymizer pseudonymizer) {
EventDto eventDto = eventFacade.convertToDto(event, pseudonymizer);
eventDto.setReportingUser(null);
eventDto.setSormasToSormasOriginInfo(null);
dataBuilderHelper.clearIgnoredProperties(eventDto);
return eventDto;
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class EventShareDataBuilder method doBuildShareData.
@Override
protected SormasToSormasEventDto doBuildShareData(Event data, ShareRequestInfo requestInfo) {
Pseudonymizer pseudonymizer = dataBuilderHelper.createPseudonymizer(requestInfo.isPseudonymizedPersonalData(), requestInfo.isPseudonymizedSensitiveData());
EventDto eventDto = getEventDto(data, pseudonymizer);
return new SormasToSormasEventDto(eventDto);
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testSaveSharedEventsWithParticipants.
@Test
public void testSaveSharedEventsWithParticipants() throws SormasToSormasException, SormasToSormasValidationException {
EventDto event = createEventDto(rdcf);
EventParticipantDto eventParticipant = createEventParticipantDto(event.toReference(), UserDto.build().toReference(), rdcf);
SormasToSormasDto shareData = new SormasToSormasDto();
shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
shareData.setEventParticipants(Collections.singletonList(new SormasToSormasEventParticipantDto(eventParticipant)));
SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
EventParticipantDto savedParticipant = getEventParticipantFacade().getEventParticipantByUuid(eventParticipant.getUuid());
assertThat(savedParticipant, is(notNullValue()));
assertThat(savedParticipant.getPerson(), is(notNullValue()));
assertThat(savedParticipant.getPerson().getFirstName(), is("John"));
assertThat(savedParticipant.getPerson().getLastName(), is("Smith"));
assertThat(savedParticipant.getPerson().getAddress().getRegion(), is(rdcf.region));
assertThat(savedParticipant.getPerson().getAddress().getDistrict(), is(rdcf.district));
assertThat(savedParticipant.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
assertThat(savedParticipant.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
}
use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testSyncEvent.
@Test
public void testSyncEvent() throws SormasToSormasException {
useSurveillanceOfficerLogin(rdcf);
UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
EventDto event = creator.createEvent(EventStatus.SCREENING, EventInvestigationStatus.ONGOING, "Test event title", "Test description", officer, e -> {
e.getEventLocation().setRegion(rdcf.region);
e.getEventLocation().setDistrict(rdcf.district);
SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
originInfo.setSenderName("Test Name");
originInfo.setSenderEmail("test@email.com");
originInfo.setOrganizationId(DEFAULT_SERVER_ID);
originInfo.setOwnershipHandedOver(true);
originInfo.setWithEventParticipants(true);
e.setSormasToSormasOriginInfo(originInfo);
});
PersonDto person = creator.createPerson();
EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), person, "Involved", officer, ep -> {
SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
originInfo.setSenderName("Test Name");
originInfo.setSenderEmail("test@email.com");
originInfo.setOrganizationId(DEFAULT_SERVER_ID);
originInfo.setOwnershipHandedOver(true);
originInfo.setWithEventParticipants(true);
ep.setSormasToSormasOriginInfo(originInfo);
}, null);
ShareRequestInfo shareRequestInfo = createShareRequestInfo(getUserService().getByUuid(officer.getUuid()), SECOND_SERVER_ID, false, ShareRequestStatus.ACCEPTED, i -> i.setEvent(getEventService().getByUuid(event.getUuid())));
shareRequestInfo.setWithEventParticipants(true);
shareRequestInfo.getShares().add(createShareInfo(SECOND_SERVER_ID, false, i -> i.setEventParticipant(getEventParticipantService().getByUuid(eventParticipant.getUuid()))));
getShareRequestInfoService().persist(shareRequestInfo);
EventParticipantDto newEventParticipant = creator.createEventParticipant(event.toReference(), person, "Involved", officer);
Mockito.when(MockProducer.getSormasToSormasClient().post(eq(DEFAULT_SERVER_ID), ArgumentMatchers.contains("/events/sync"), ArgumentMatchers.any(), ArgumentMatchers.any())).then(invocation -> {
SyncDataDto syncData = invocation.getArgument(2);
assertThat(syncData.getCriteria().getEntityUuid(), is(event.getUuid()));
assertThat(syncData.getCriteria().getExceptedOrganizationId(), is(DEFAULT_SERVER_ID));
assertThat(syncData.getCriteria().isForwardOnly(), is(false));
assertThat(syncData.getShareData().getEvents().get(0).getEntity().getUuid(), is(event.getUuid()));
// new event participant should not be shared
assertThat(syncData.getShareData().getEventParticipants(), hasSize(1));
return Response.noContent().build();
});
Mockito.when(MockProducer.getSormasToSormasClient().post(eq(SECOND_SERVER_ID), ArgumentMatchers.contains("/events/sync"), ArgumentMatchers.any(), ArgumentMatchers.any())).then(invocation -> {
SyncDataDto syncData = invocation.getArgument(2);
assertThat(syncData.getCriteria().getEntityUuid(), is(event.getUuid()));
assertThat(syncData.getCriteria().getExceptedOrganizationId(), is(nullValue()));
assertThat(syncData.getCriteria().isForwardOnly(), is(true));
assertThat(syncData.getShareData().getEvents().get(0).getEntity().getUuid(), is(event.getUuid()));
// the new event participant should not be shared
assertThat(syncData.getShareData().getEventParticipants(), hasSize(1));
assertThat(syncData.getShareData().getEventParticipants().get(0).getEntity().getUuid(), is(eventParticipant.getUuid()));
return Response.noContent().build();
});
getSormasToSormasEventFacade().syncShares(new ShareTreeCriteria(event.getUuid(), null, false));
// new event participant should have share info with ownership handed over
List<SormasToSormasShareInfoDto> newEventParticipantShareInfoList = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().eventParticipant(newEventParticipant.toReference()), 0, 100);
assertThat(newEventParticipantShareInfoList, hasSize(0));
}
Aggregations