Search in sources :

Example 1 with DestinationEntity

use of org.karnak.backend.data.entity.DestinationEntity in project karnak by OsiriX-Foundation.

the class WarningRemoveProjectUsed method setText.

public void setText(ProjectEntity projectEntity) {
    removeAll();
    Div divTitle = new Div();
    divTitle.setText(String.format("The project %s can't be remove", projectEntity.getName()));
    divTitle.getStyle().set("font-size", "large").set("font-weight", "bolder").set("padding-bottom", "10px").set("color", "red");
    Div divContent = new Div();
    Div divIntro = new Div();
    divIntro.setText("The project is used in the following destinations");
    divIntro.getStyle().set("padding-bottom", "10px");
    divContent.add(divIntro);
    if (projectEntity.getDestinationEntities() != null) {
        for (DestinationEntity destinationEntity : projectEntity.getDestinationEntities()) {
            Div divDestination = new Div();
            divDestination.setText(String.format("Type: %s, Description: %s, ForwardNode: %s", destinationEntity.getDestinationType(), destinationEntity.getDescription(), destinationEntity.getForwardNodeEntity().getFwdAeTitle()));
            divDestination.getStyle().set("padding-left", "20px").set("padding-bottom", "5px");
            divContent.add(divDestination);
        }
    }
    Button cancelButton = new Button("Cancel", event -> {
        close();
    });
    cancelButton.getStyle().set("margin-left", "75%");
    add(divTitle, divContent, cancelButton);
}
Also used : Div(com.vaadin.flow.component.html.Div) DestinationEntity(org.karnak.backend.data.entity.DestinationEntity) Button(com.vaadin.flow.component.button.Button)

Example 2 with DestinationEntity

use of org.karnak.backend.data.entity.DestinationEntity in project karnak by OsiriX-Foundation.

the class ForwardNodeRepoTest method testInvalidDestinationDicom_AETitle_mandatory.

@Test
void testInvalidDestinationDicom_AETitle_mandatory() {
    ForwardNodeEntity forwardNodeEntity = ForwardNodeEntity.ofEmpty();
    forwardNodeEntity.setFwdDescription("description");
    forwardNodeEntity.setFwdAeTitle("fwdAeTitle");
    DestinationEntity destinationEntity = DestinationEntity.ofDicom("description", null, "hostname", 123, null);
    forwardNodeEntity.addDestination(destinationEntity);
    String expectedMessage = "AETitle is mandatory";
    Exception exception = assertThrows(ConstraintViolationException.class, () -> {
        entityManager.persistAndFlush(forwardNodeEntity);
    });
    String actualMessage = exception.getMessage();
    assertTrue(actualMessage.contains(expectedMessage));
}
Also used : DestinationEntity(org.karnak.backend.data.entity.DestinationEntity) ForwardNodeEntity(org.karnak.backend.data.entity.ForwardNodeEntity) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 3 with DestinationEntity

use of org.karnak.backend.data.entity.DestinationEntity in project karnak by OsiriX-Foundation.

the class ForwardNodeRepoTest method testWithDestinationDicom.

// @Test
void testWithDestinationDicom() {
    ForwardNodeEntity forwardNodeEntity = ForwardNodeEntity.ofEmpty();
    forwardNodeEntity.setFwdDescription("description");
    forwardNodeEntity.setFwdAeTitle("fwdAeTitle");
    DestinationEntity destinationEntity = DestinationEntity.ofDicom("description", "aeTitle", "hostname", 123, null);
    forwardNodeEntity.addDestination(destinationEntity);
    entityManager.persistAndFlush(forwardNodeEntity);
    Iterable<ForwardNodeEntity> all = repository.findAll();
    // 
    assertThat(all).hasSize(// 
    1).first().satisfies(forwardNodeConsumer);
    // 
    assertThat(all).hasSize(// 
    1).flatExtracting(// 
    ForwardNodeEntity::getSourceNodes).hasSize(0);
    // 
    assertThat(all).hasSize(// 
    1).flatExtracting(// 
    ForwardNodeEntity::getDestinationEntities).hasSize(// 
    1).first().satisfies(destinationDicomConsumer);
}
Also used : DestinationEntity(org.karnak.backend.data.entity.DestinationEntity) ForwardNodeEntity(org.karnak.backend.data.entity.ForwardNodeEntity)

Example 4 with DestinationEntity

use of org.karnak.backend.data.entity.DestinationEntity in project karnak by OsiriX-Foundation.

the class ForwardNodeRepoTest method testWithSourceNodeAndDestinationDicom.

// @Test
void testWithSourceNodeAndDestinationDicom() {
    ForwardNodeEntity forwardNodeEntity = ForwardNodeEntity.ofEmpty();
    forwardNodeEntity.setFwdDescription("description");
    forwardNodeEntity.setFwdAeTitle("fwdAeTitle");
    DicomSourceNodeEntity sourceNode = DicomSourceNodeEntity.ofEmpty();
    sourceNode.setDescription("description");
    sourceNode.setAeTitle("aeTitle");
    sourceNode.setHostname("hostname");
    sourceNode.setCheckHostname(Boolean.TRUE);
    forwardNodeEntity.addSourceNode(sourceNode);
    DestinationEntity destinationEntity = DestinationEntity.ofDicom("description", "aeTitle", "hostname", 123, null);
    forwardNodeEntity.addDestination(destinationEntity);
    entityManager.persistAndFlush(forwardNodeEntity);
    Iterable<ForwardNodeEntity> all = repository.findAll();
    // 
    assertThat(all).hasSize(// 
    1).first().satisfies(forwardNodeConsumer);
    // 
    assertThat(all).hasSize(// 
    1).flatExtracting(// 
    ForwardNodeEntity::getSourceNodes).hasSize(// 
    1).first().satisfies(sourceNodeConsumer);
    // 
    assertThat(all).hasSize(// 
    1).flatExtracting(// 
    ForwardNodeEntity::getDestinationEntities).hasSize(// 
    1).first().satisfies(destinationDicomConsumer);
}
Also used : DestinationEntity(org.karnak.backend.data.entity.DestinationEntity) DicomSourceNodeEntity(org.karnak.backend.data.entity.DicomSourceNodeEntity) ForwardNodeEntity(org.karnak.backend.data.entity.ForwardNodeEntity)

Example 5 with DestinationEntity

use of org.karnak.backend.data.entity.DestinationEntity in project karnak by OsiriX-Foundation.

the class ForwardNodeRepoTest method testWithDestinationStow.

// @Test
void testWithDestinationStow() {
    ForwardNodeEntity forwardNodeEntity = ForwardNodeEntity.ofEmpty();
    forwardNodeEntity.setFwdDescription("description");
    forwardNodeEntity.setFwdAeTitle("fwdAeTitle");
    DestinationEntity destinationEntity = DestinationEntity.ofStow("description", "url", "urlCredentials", "headers");
    forwardNodeEntity.addDestination(destinationEntity);
    entityManager.persistAndFlush(forwardNodeEntity);
    Iterable<ForwardNodeEntity> all = repository.findAll();
    // 
    assertThat(all).hasSize(// 
    1).first().satisfies(forwardNodeConsumer);
    // 
    assertThat(all).hasSize(// 
    1).flatExtracting(// 
    ForwardNodeEntity::getSourceNodes).hasSize(0);
    // 
    assertThat(all).hasSize(// 
    1).flatExtracting(// 
    ForwardNodeEntity::getDestinationEntities).hasSize(// 
    1).first().satisfies(destinationStowConsumer);
}
Also used : DestinationEntity(org.karnak.backend.data.entity.DestinationEntity) ForwardNodeEntity(org.karnak.backend.data.entity.ForwardNodeEntity)

Aggregations

DestinationEntity (org.karnak.backend.data.entity.DestinationEntity)40 Test (org.junit.jupiter.api.Test)23 ForwardNodeEntity (org.karnak.backend.data.entity.ForwardNodeEntity)20 ArrayList (java.util.ArrayList)9 KheopsAlbumsEntity (org.karnak.backend.data.entity.KheopsAlbumsEntity)9 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)8 DicomSourceNodeEntity (org.karnak.backend.data.entity.DicomSourceNodeEntity)6 ProjectEntity (org.karnak.backend.data.entity.ProjectEntity)6 NodeEvent (org.karnak.backend.model.event.NodeEvent)6 HashSet (java.util.HashSet)5 List (java.util.List)5 DicomForwardDestination (org.karnak.backend.dicom.DicomForwardDestination)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Attributes (org.dcm4che3.data.Attributes)4 ProfileEntity (org.karnak.backend.data.entity.ProfileEntity)4 Binder (com.vaadin.flow.data.binder.Binder)3 Set (java.util.Set)3 DestinationType (org.karnak.backend.enums.DestinationType)3 NodeEventType (org.karnak.backend.enums.NodeEventType)3 Component (com.vaadin.flow.component.Component)2