Search in sources :

Example 6 with ProfileElementEntity

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

the class ProfileElementRepoTest method shouldFindAllRecords.

/**
 * Test find all.
 */
@Test
void shouldFindAllRecords() {
    // Create an entity to save
    // Profile
    ProfileEntity profileEntity = new ProfileEntity();
    profileEntity.setName("name");
    profileEntity = profileRepo.saveAndFlush(profileEntity);
    // ProfileElement
    ProfileElementEntity entity = new ProfileElementEntity();
    entity.setName("Name");
    entity.setProfileEntity(profileEntity);
    // Save the entity
    LOGGER.info("Saving entity with name [{}]", entity.getName());
    repository.saveAndFlush(entity);
    // Find all
    List<ProfileElementEntity> all = repository.findAll();
    // Test find all
    assertNotNull(all);
    assertTrue(all.size() > 0);
    assertEquals(1, all.size());
    LOGGER.info("Number of entities found [{}]", all.size());
}
Also used : ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 7 with ProfileElementEntity

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

the class ProfileErrorView method setView.

public void setView(ArrayList<ProfileError> profileErrors) {
    removeAll();
    add(new H2("Errors occured in profile elements"));
    for (ProfileError profileError : profileErrors) {
        ProfileElementEntity profileElementEntity = profileError.getProfileElement();
        Div profileName = setProfileName((profileElementEntity.getPosition() + 1) + ". " + profileElementEntity.getName());
        add(profileName);
        if (profileError.getError() != null) {
            profileName.add(setErrorIcon());
            add(setProfileError("Error : " + profileError.getError()));
        } else {
            profileName.add(setSuccessIcon());
        }
        setProfileShowHide(profileElementEntity);
    }
}
Also used : Div(com.vaadin.flow.component.html.Div) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) H2(com.vaadin.flow.component.html.H2)

Example 8 with ProfileElementEntity

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

the class ArgumentRepoTest method shouldFindAllRecords.

/**
 * Test find all.
 */
@Test
void shouldFindAllRecords() {
    // Create an entity to save
    // Profile
    ProfileEntity profileEntity = new ProfileEntity();
    profileEntity.setName("name");
    profileEntity = profileRepo.saveAndFlush(profileEntity);
    // Profile element
    ProfileElementEntity profileElementEntity = new ProfileElementEntity();
    profileElementEntity.setName("name");
    profileElementEntity.setProfileEntity(profileEntity);
    profileElementEntity = profileElementRepo.saveAndFlush(profileElementEntity);
    // Argument
    ArgumentEntity entity = new ArgumentEntity();
    entity.setKey("Key");
    entity.setProfileElementEntity(profileElementEntity);
    // Save the entity
    LOGGER.info("Saving entity with Key [{}]", entity.getKey());
    repository.saveAndFlush(entity);
    // Find all
    List<ArgumentEntity> all = repository.findAll();
    // Test find all
    assertNotNull(all);
    assertTrue(all.size() > 0);
    assertEquals(1, all.size());
    LOGGER.info("Number of entities found [{}]", all.size());
}
Also used : ArgumentEntity(org.karnak.backend.data.entity.ArgumentEntity) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) Test(org.junit.jupiter.api.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 9 with ProfileElementEntity

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

the class AttributesByDefaultTest method should_set_deIdentification_method_code_sequence.

@Test
void should_set_deIdentification_method_code_sequence() {
    // Init data
    Attributes attributes = new Attributes();
    ProjectEntity projectEntity = new ProjectEntity();
    ProfileEntity profileEntity = new ProfileEntity();
    Set<ProfileElementEntity> profileElementEntities = new HashSet<>();
    ProfileElementEntity profileElementEntityBasic = new ProfileElementEntity();
    profileElementEntityBasic.setCodename("basic.dicom.profile");
    profileElementEntityBasic.setName("nameBasic");
    ProfileElementEntity profileElementEntityCleanPixelData = new ProfileElementEntity();
    profileElementEntityCleanPixelData.setCodename("clean.pixel.data");
    profileElementEntityCleanPixelData.setName("nameCleanPixel");
    profileElementEntityBasic.setPosition(1);
    profileElementEntityCleanPixelData.setPosition(2);
    profileElementEntityBasic.setAction("ReplaceNull");
    profileElementEntityCleanPixelData.setAction("ReplaceNull");
    profileElementEntities.add(profileElementEntityBasic);
    profileElementEntities.add(profileElementEntityCleanPixelData);
    profileEntity.setProfileElementEntities(profileElementEntities);
    projectEntity.setProfileEntity(profileEntity);
    // Call method
    AttributesByDefault.setDeidentificationMethodCodeSequence(attributes, projectEntity);
    // Test results
    assertNotNull(attributes.getValue(Tag.DeidentificationMethodCodeSequence));
    Sequence sequence = (Sequence) attributes.getValue(Tag.DeidentificationMethodCodeSequence);
    assertEquals("113100", sequence.get(0).getValue(Tag.CodeValue));
    assertEquals("DCM", sequence.get(0).getValue(Tag.CodingSchemeDesignator));
    assertEquals(ProfileItemType.getCodeMeaning("basic.dicom.profile"), sequence.get(0).getValue(Tag.CodeMeaning));
    assertEquals("113101", sequence.get(1).getValue(Tag.CodeValue));
    assertEquals("DCM", sequence.get(1).getValue(Tag.CodingSchemeDesignator));
    assertEquals(ProfileItemType.getCodeMeaning("clean.pixel.data"), sequence.get(1).getValue(Tag.CodeMeaning));
}
Also used : ProjectEntity(org.karnak.backend.data.entity.ProjectEntity) ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) Attributes(org.dcm4che3.data.Attributes) Sequence(org.dcm4che3.data.Sequence) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 10 with ProfileElementEntity

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

the class ProfileTest method should_evaluate_condition_clean_pixel_case_exclude_station_name.

@Test
void should_evaluate_condition_clean_pixel_case_exclude_station_name() {
    // Init data
    ProfileEntity profileEntity = new ProfileEntity();
    Attributes attributes = new Attributes();
    attributes.setString(Tag.StationName, VR.SH, "ICT256");
    Set<ProfileElementEntity> profileElementEntities = new HashSet<>();
    ProfileElementEntity profileElementEntityCleanPixelData = new ProfileElementEntity();
    profileElementEntityCleanPixelData.setCodename("clean.pixel.data");
    profileElementEntityCleanPixelData.setName("nameCleanPixel");
    profileElementEntityCleanPixelData.setAction("ReplaceNull");
    profileElementEntityCleanPixelData.setCondition("!tagValueContains(#Tag.StationName,'ICT256')");
    profileElementEntities.add(profileElementEntityCleanPixelData);
    profileEntity.setProfileElementEntities(profileElementEntities);
    Profile profile = new Profile(profileEntity);
    // Evaluate condition
    boolean evaluation = profile.evaluateConditionCleanPixelData(attributes);
    // Test results
    assertFalse(evaluation);
}
Also used : ProfileElementEntity(org.karnak.backend.data.entity.ProfileElementEntity) Attributes(org.dcm4che3.data.Attributes) ProfileEntity(org.karnak.backend.data.entity.ProfileEntity) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

ProfileElementEntity (org.karnak.backend.data.entity.ProfileElementEntity)31 Test (org.junit.jupiter.api.Test)24 ProfileEntity (org.karnak.backend.data.entity.ProfileEntity)24 Attributes (org.dcm4che3.data.Attributes)18 IncludedTagEntity (org.karnak.backend.data.entity.IncludedTagEntity)14 Profile (org.karnak.backend.service.profilepipe.Profile)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 HashSet (java.util.HashSet)7 Sequence (org.dcm4che3.data.Sequence)7 ArgumentEntity (org.karnak.backend.data.entity.ArgumentEntity)6 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)6 ProjectEntity (org.karnak.backend.data.entity.ProjectEntity)3 ProfileItemType (org.karnak.backend.enums.ProfileItemType)3 H2 (com.vaadin.flow.component.html.H2)2 ArrayList (java.util.ArrayList)2 MaskEntity (org.karnak.backend.data.entity.MaskEntity)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 Div (com.vaadin.flow.component.html.Div)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1