Search in sources :

Example 1 with SormasToSormasShareRequestDto

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

Example 2 with SormasToSormasShareRequestDto

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);
}
Also used : SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) Date(java.util.Date) Transactional(javax.transaction.Transactional)

Example 3 with SormasToSormasShareRequestDto

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));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SormasToSormasShareRequestDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) PersonDto(de.symeda.sormas.api.person.PersonDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasOptionsDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto) SormasToSormasOriginInfoDto(de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) Date(java.util.Date) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 4 with SormasToSormasShareRequestDto

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

Example 5 with SormasToSormasShareRequestDto

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

Aggregations

SormasToSormasShareRequestDto (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestDto)9 Date (java.util.Date)5 PersonDto (de.symeda.sormas.api.person.PersonDto)3 SormasServerDescriptor (de.symeda.sormas.api.sormastosormas.SormasServerDescriptor)3 SormasToSormasOptionsDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto)3 SormasToSormasOriginInfoDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto)3 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)3 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)3 Test (org.junit.Test)3 ContactDto (de.symeda.sormas.api.contact.ContactDto)2 SampleDto (de.symeda.sormas.api.sample.SampleDto)2 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)2 SormasToSormasSampleDto (de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto)2 Transactional (javax.transaction.Transactional)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 EventDto (de.symeda.sormas.api.event.EventDto)1 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)1 SormasToSormasEncryptedDataDto (de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto)1 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)1 SormasToSormasEventParticipantDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto)1