use of org.karnak.backend.data.entity.MaskEntity in project karnak by OsiriX-Foundation.
the class MaskRepoTest method shouldDeleteRecord.
/**
* Test delete record.
*/
@Test
void shouldDeleteRecord() {
// Create an entity to save
MaskEntity entity = new MaskEntity();
String name = "Name";
entity.setStationName(name);
entity.addRectangle(new Rectangle());
// Save the entity
LOGGER.info("Saving entity with name [{}]", entity.getStationName());
entity = repository.save(entity);
// Retrieve the entity
Optional<MaskEntity> foundByIdOpt = repository.findById(entity.getId());
// Test Find by Id
assertTrue(foundByIdOpt.isPresent());
// Delete the entity
entity = foundByIdOpt.get();
Long id = entity.getId();
LOGGER.info("Deleting entity with id [{}]", id);
repository.delete(entity);
// Test Delete
foundByIdOpt = repository.findById(id);
LOGGER.info("Is deleted entity with id [{}] present: [{}]", id, foundByIdOpt.isPresent());
assertFalse(foundByIdOpt.isPresent());
}
use of org.karnak.backend.data.entity.MaskEntity in project karnak by OsiriX-Foundation.
the class MaskRepoTest method shouldSaveAndFindARecord.
/**
* Test save and find record.
*/
@Test
void shouldSaveAndFindARecord() {
// Create an entity to save
MaskEntity entity = new MaskEntity();
entity.setStationName("Name");
// Save the entity
LOGGER.info("Saving entity with name [{}]", entity.getStationName());
entity = repository.save(entity);
// Test Save
assertEquals("Name", entity.getStationName());
assertNotNull(entity.getId());
LOGGER.info("Entity with name [{}] and id [{}] saved", entity.getStationName(), entity.getId());
// Find By Id
Optional<MaskEntity> foundByIdOpt = repository.findById(entity.getId());
// Test Find by Id
assertTrue(foundByIdOpt.isPresent());
LOGGER.info("Entity found with name [{}] and id [{}]", foundByIdOpt.get().getStationName(), foundByIdOpt.get().getId());
assertEquals(entity.getId(), foundByIdOpt.get().getId());
}
use of org.karnak.backend.data.entity.MaskEntity in project karnak by OsiriX-Foundation.
the class ProfileTest method should_apply.
@Test
void should_apply() {
// Init data
Attributes attributes = new Attributes();
DestinationEntity destinationEntity = new DestinationEntity();
destinationEntity.setDestinationType(DestinationType.dicom);
ProjectEntity projectEntity = new ProjectEntity();
ProfileEntity profileEntityProject = new ProfileEntity();
projectEntity.setProfileEntity(profileEntityProject);
byte[] tabByte = new byte[16];
tabByte[0] = 1;
projectEntity.addActiveSecretEntity(new SecretEntity(tabByte));
destinationEntity.setProjectEntity(projectEntity);
destinationEntity.setPseudonymType(PseudonymType.EXTID_IN_TAG);
destinationEntity.setTag("0008,0080");
destinationEntity.setSavePseudonym(false);
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");
profileElementEntityCleanPixelData.setCondition("!tagValueContains(#Tag.StationName,'ICT256')");
profileElementEntities.add(profileElementEntityBasic);
profileElementEntities.add(profileElementEntityCleanPixelData);
profileEntity.setProfileElementEntities(profileElementEntities);
profileEntity.setDefaultIssuerOfPatientId("defaultIssuerOfPatientId");
Set<MaskEntity> maskEntities = new HashSet<>();
MaskEntity maskEntity = new MaskEntity();
maskEntities.add(maskEntity);
maskEntity.setColor("1234567897");
maskEntity.setStationName("stationName");
maskEntity.setRectangles(Arrays.asList(new Rectangle()));
profileEntity.setMaskEntities(maskEntities);
AttributeEditorContext context = new AttributeEditorContext("tsuid", null, null);
attributes.setString(Tag.PatientID, VR.SH, "patientID");
attributes.setString(Tag.SeriesInstanceUID, VR.SH, "seriesInstanceUID");
attributes.setString(Tag.SOPInstanceUID, VR.SH, "sopInstanceUID");
attributes.setString(Tag.IssuerOfPatientID, VR.SH, "issuerOfPatientID");
attributes.setString(Tag.PixelData, VR.SH, "pixelData");
attributes.setString(Tag.SOPClassUID, VR.SH, "1.2.840.10008.5.1.4.1.1.88.74");
attributes.setString(Tag.BurnedInAnnotation, VR.SH, "YES");
attributes.setString(Tag.StationName, VR.SH, "stationName");
attributes.setString(524416, VR.SH, "pseudonym");
// Call method
Profile profile = new Profile(profileEntity);
// profile.init(profileEntity);
profile.apply(attributes, destinationEntity, profileEntity, context);
// Test results
assertEquals("NONE", context.getAbort().name());
assertNull(context.getMaskArea());
}
use of org.karnak.backend.data.entity.MaskEntity in project karnak by OsiriX-Foundation.
the class ProfilePipeService method createNewProfile.
private ProfileEntity createNewProfile(ProfilePipeBody profilePipeYml, Boolean byDefault) {
final ProfileEntity newProfileEntity = new ProfileEntity(profilePipeYml.getName(), profilePipeYml.getVersion(), profilePipeYml.getMinimumKarnakVersion(), null, byDefault);
if (profilePipeYml.getMasks() != null) {
profilePipeYml.getMasks().forEach(m -> {
MaskEntity maskEntity = new MaskEntity(m.getStationName(), m.getColor(), newProfileEntity);
m.getRectangles().forEach(maskEntity::addRectangle);
newProfileEntity.addMask(maskEntity);
});
}
AtomicInteger profilePosition = new AtomicInteger(0);
profilePipeYml.getProfileElements().forEach(profileBody -> {
ProfileElementEntity profileElementEntity = new ProfileElementEntity(profileBody.getName(), profileBody.getCodename(), profileBody.getCondition(), profileBody.getAction(), profileBody.getOption(), profilePosition.get(), newProfileEntity);
if (profileBody.getArguments() != null) {
profileBody.getArguments().forEach((key, value) -> {
final ArgumentEntity argumentEntity = new ArgumentEntity(key, value, profileElementEntity);
profileElementEntity.addArgument(argumentEntity);
});
}
if (profileBody.getTags() != null) {
profileBody.getTags().forEach(tag -> {
final IncludedTagEntity includedTagEntityValue = new IncludedTagEntity(tag, profileElementEntity);
profileElementEntity.addIncludedTag(includedTagEntityValue);
});
}
if (profileBody.getExcludedTags() != null) {
profileBody.getExcludedTags().forEach(excludedTag -> {
final ExcludedTagEntity excludedTagEntityValue = new ExcludedTagEntity(excludedTag, profileElementEntity);
profileElementEntity.addExceptedtags(excludedTagEntityValue);
});
}
newProfileEntity.addProfilePipe(profileElementEntity);
profilePosition.getAndIncrement();
});
return newProfileEntity;
}
use of org.karnak.backend.data.entity.MaskEntity in project karnak by OsiriX-Foundation.
the class MaskRepoTest 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);
// Mask
MaskEntity entity = new MaskEntity();
entity.setStationName("Name");
entity.addRectangle(new Rectangle());
entity.setProfileEntity(profileEntity);
// Save the entity
LOGGER.info("Saving entity with name [{}]", entity.getStationName());
repository.saveAndFlush(entity);
// Find all
List<MaskEntity> all = repository.findAll();
// Test find all
assertNotNull(all);
assertTrue(all.size() > 0);
assertEquals(1, all.size());
LOGGER.info("Number of entities found [{}]", all.size());
}
Aggregations