use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto in project SORMAS-Project by hzi-braunschweig.
the class AbstractSormasToSormasInterface method createShareRequest.
private SormasToSormasShareRequestDto createShareRequest(String requestUuid, SormasToSormasOriginInfoDto originInfo, ShareRequestPreviews previews) {
SormasToSormasShareRequestDto request = SormasToSormasShareRequestDto.build();
request.setUuid(requestUuid);
request.setDataType(shareRequestDataType);
request.setStatus(ShareRequestStatus.PENDING);
request.setOriginInfo(originInfo);
request.setCases(previews.getCases());
request.setContacts(previews.getContacts());
request.setEvents(previews.getEvents());
request.setEventParticipants(previews.getEventParticipants());
return request;
}
use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto in project SORMAS-Project by hzi-braunschweig.
the class AbstractSormasToSormasInterface method acceptShareRequest.
@Override
@Transactional(rollbackOn = { Exception.class })
public void acceptShareRequest(String uuid) throws SormasToSormasException, SormasToSormasValidationException {
SormasToSormasShareRequestDto shareRequest = shareRequestFacade.getShareRequestByUuid(uuid);
if (shareRequest.getStatus() != ShareRequestStatus.PENDING) {
throw SormasToSormasException.fromStringProperty(Strings.errorSormasToSormasAcceptNotPending);
}
String organizationId = shareRequest.getOriginInfo().getOrganizationId();
SormasToSormasEncryptedDataDto encryptedData = sormasToSormasRestClient.post(organizationId, requestGetDataEndpoint, uuid, SormasToSormasEncryptedDataDto.class);
decryptAndPersist(encryptedData, (data, existingData) -> processedEntitiesPersister.persistSharedData(data, shareRequest.getOriginInfo(), existingData));
// notify the sender that the request has been accepted
sormasToSormasRestClient.post(organizationId, REQUEST_ACCEPTED_ENDPOINT, uuid, null);
shareRequest.setChangeDate(new Date());
shareRequest.setStatus(ShareRequestStatus.ACCEPTED);
shareRequestFacade.saveShareRequest(shareRequest);
}
use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasContactFacadeEjbTest method testReturnContact.
@Test
public void testReturnContact() throws SormasToSormasException {
useSurveillanceOfficerLogin(rdcf);
PersonDto person = creator.createPerson();
UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
ContactDto contact = creator.createContact(officer, officer, person.toReference(), null, new Date(), new Date(), Disease.CORONAVIRUS, rdcf, c -> {
SormasToSormasOriginInfoDto originInfo = new SormasToSormasOriginInfoDto();
originInfo.setSenderName("Test Name");
originInfo.setSenderEmail("test@email.com");
originInfo.setOrganizationId(DEFAULT_SERVER_ID);
originInfo.setOwnershipHandedOver(true);
c.setSormasToSormasOriginInfo(originInfo);
});
SormasToSormasShareRequestDto shareRequest = new SormasToSormasShareRequestDto();
shareRequest.setUuid(DataHelper.createUuid());
shareRequest.setOriginInfo(contact.getSormasToSormasOriginInfo());
getSormasToSormasShareRequestFacade().saveShareRequest(shareRequest);
SampleDto sharedSample = creator.createSample(contact.toReference(), officer, rdcf.facility, s -> s.setSormasToSormasOriginInfo(contact.getSormasToSormasOriginInfo()));
SormasToSormasOptionsDto options = new SormasToSormasOptionsDto();
options.setOrganization(new SormasServerDescriptor(SECOND_SERVER_ID));
options.setHandOverOwnership(true);
options.setWithSamples(true);
options.setComment("Test comment");
Mockito.when(MockProducer.getSormasToSormasClient().put(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocation -> Response.noContent().build());
getSormasToSormasContactFacade().share(Collections.singletonList(contact.getUuid()), options);
// contact ownership should be lost
ContactDto sharedContact = getContactFacade().getByUuid(contact.getUuid());
assertThat(sharedContact.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
// sample ownership should be lost
sharedSample = getSampleFacade().getSampleByUuid(sharedSample.getUuid());
assertThat(sharedSample.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(false));
}
use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasController method showRequestDetails.
public void showRequestDetails(SormasToSormasShareRequestIndexDto request) {
SormasToSormasShareRequestDto shareRequest = FacadeProvider.getSormasToSormasShareRequestFacade().getShareRequestByUuid(request.getUuid());
ShareRequestLayout shareRequestLayout = new ShareRequestLayout(shareRequest);
shareRequestLayout.setWidth(900, Sizeable.Unit.PIXELS);
shareRequestLayout.setMargin(true);
VaadinUiUtil.showPopupWindow(shareRequestLayout, I18nProperties.getString(Strings.headingShareRequestDetails));
}
use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasShareRequestFacadeEJB method toDto.
public static SormasToSormasShareRequestDto toDto(SormasToSormasShareRequest source) {
if (source == null) {
return null;
}
SormasToSormasShareRequestDto target = new SormasToSormasShareRequestDto();
DtoHelper.fillDto(target, source);
target.setDataType(source.getDataType());
target.setStatus(source.getStatus());
target.setOriginInfo(SormasToSormasOriginInfoFacadeEjb.toDto(source.getOriginInfo()));
target.setCases(source.getCasesList());
target.setContacts(source.getContactsList());
target.setEvents(source.getEventsList());
target.setEventParticipants(source.getEventParticipantsList());
target.setResponseComment(source.getResponseComment());
return target;
}
Aggregations