use of org.karnak.backend.data.entity.KheopsAlbumsEntity in project karnak by OsiriX-Foundation.
the class GatewaySetUpService method addDestinationNode.
private void addDestinationNode(List<ForwardDestination> dstList, ForwardDicomNode fwdSrcNode, DestinationEntity dstNode) {
try {
List<AttributeEditor> editors = new ArrayList<>();
if (!dstNode.getCondition().isEmpty()) {
editors.add(new ConditionEditor(dstNode.getCondition()));
}
final boolean filterBySOPClassesEnable = dstNode.isFilterBySOPClasses();
if (filterBySOPClassesEnable) {
editors.add(new FilterEditor(dstNode.getSOPClassUIDEntityFilters()));
}
final List<KheopsAlbumsEntity> kheopsAlbumEntities = dstNode.getKheopsAlbumEntities();
SwitchingAlbum switchingAlbum = new SwitchingAlbum();
if (kheopsAlbumEntities != null && !kheopsAlbumEntities.isEmpty()) {
editors.add((Attributes dcm, AttributeEditorContext context) -> {
kheopsAlbumEntities.forEach(kheopsAlbums -> {
switchingAlbum.apply(dstNode, kheopsAlbums, dcm);
});
});
}
StreamRegistryEditor streamRegistryEditor = new StreamRegistryEditor();
editors.add(streamRegistryEditor);
boolean deidentificationEnable = dstNode.isDesidentification();
boolean profileDefined = dstNode.getProjectEntity() != null && dstNode.getProjectEntity().getProfileEntity() != null;
if (deidentificationEnable && profileDefined) {
// TODO add an option in destination model
editors.add(new DeIdentifyEditor(dstNode));
}
DicomProgress progress = new DicomProgress();
if (dstNode.isActivate()) {
if (dstNode.getDestinationType() == DestinationType.stow) {
// parse headers to hashmap
HashMap<String, String> map = new HashMap<>();
String headers = dstNode.getHeaders();
Document doc = Jsoup.parse(headers);
String key = doc.getElementsByTag("key").text();
String value = doc.getElementsByTag("value").text();
if (StringUtil.hasText(key)) {
map.put(key, value);
}
WebForwardDestination fwd = new WebForwardDestination(dstNode.getId(), fwdSrcNode, dstNode.getUrl(), map, progress, editors, dstNode.getTransferSyntax(), dstNode.isTranscodeOnlyUncompressed());
if (kheopsAlbumEntities != null && !kheopsAlbumEntities.isEmpty()) {
progress.addProgressListener((DicomProgress dicomProgress) -> {
Attributes dcm = dicomProgress.getAttributes();
kheopsAlbumEntities.forEach(kheopsAlbums -> {
switchingAlbum.applyAfterTransfer(kheopsAlbums, dcm);
});
});
}
dstList.add(fwd);
} else {
DicomNode destinationNode = new DicomNode(dstNode.getAeTitle(), dstNode.getHostname(), dstNode.getPort());
DicomForwardDestination dest = new DicomForwardDestination(dstNode.getId(), getDefaultAdvancedParameters(), fwdSrcNode, destinationNode, dstNode.getUseaetdest(), progress, editors, dstNode.getTransferSyntax(), dstNode.isTranscodeOnlyUncompressed());
dstList.add(dest);
}
}
} catch (IOException e) {
LOGGER.error("Cannot build ForwardDestination", e);
}
}
use of org.karnak.backend.data.entity.KheopsAlbumsEntity in project karnak by OsiriX-Foundation.
the class KheopsAlbumsRepoTest method shouldFindAllRecords.
/**
* Test find all.
*/
@Test
void shouldFindAllRecords() {
// Create an entity to save
// Destination
DestinationEntity destinationEntity = new DestinationEntity();
destinationEntity.setAeTitle("AeTitle");
destinationEntity.setDestinationType(DestinationType.dicom);
destinationEntity.setHostname("hostName");
destinationEntity.setPort(1);
destinationEntity = destinationRepo.saveAndFlush(destinationEntity);
// Kheops Albums
KheopsAlbumsEntity entity = new KheopsAlbumsEntity();
entity.setCondition("Condition");
entity.setDestinationEntity(destinationEntity);
// Save the entity
LOGGER.info("Saving entity with Condition [{}]", entity.getCondition());
repository.saveAndFlush(entity);
// Find all
List<KheopsAlbumsEntity> all = repository.findAll();
// Test find all
assertNotNull(all);
assertTrue(all.size() > 0);
assertEquals(1, all.size());
LOGGER.info("Number of entities found [{}]", all.size());
}
use of org.karnak.backend.data.entity.KheopsAlbumsEntity in project karnak by OsiriX-Foundation.
the class KheopsAlbumsRepoTest method shouldSaveAndFindARecord.
/**
* Test save and find record.
*/
@Test
void shouldSaveAndFindARecord() {
// Create an entity to save
KheopsAlbumsEntity entity = new KheopsAlbumsEntity();
entity.setCondition("Condition");
// Save the entity
LOGGER.info("Saving entity with Condition [{}]", entity.getCondition());
entity = repository.save(entity);
// Test Save
assertEquals("Condition", entity.getCondition());
assertNotNull(entity.getId());
LOGGER.info("Entity with Condition [{}] and id [{}] saved", entity.getCondition(), entity.getId());
// Find By Id
Optional<KheopsAlbumsEntity> foundByIdOpt = repository.findById(entity.getId());
// Test Find by Id
assertTrue(foundByIdOpt.isPresent());
LOGGER.info("Entity found with Condition [{}] and id [{}]", foundByIdOpt.get().getCondition(), foundByIdOpt.get().getId());
assertEquals(entity.getId(), foundByIdOpt.get().getId());
}
use of org.karnak.backend.data.entity.KheopsAlbumsEntity in project karnak by OsiriX-Foundation.
the class TextFieldsBindSwitchingAlbum method buildBinder.
private Binder<KheopsAlbumsEntity> buildBinder() {
Binder<KheopsAlbumsEntity> b = new BeanValidationBinder<>(KheopsAlbumsEntity.class);
b.forField(textAuthorizationDestination).withValidator(StringUtils::isNotBlank, "Token destination is mandatory").withValidator(value -> {
if (!textUrlAPI.getValue().isBlank()) {
return validateToken(value, textUrlAPI.getValue(), SwitchingAlbum.MIN_SCOPE_DESTINATION);
}
return true;
}, "Token can't be validate, minimum permissions: [write]").bind(KheopsAlbumsEntity::getAuthorizationDestination, KheopsAlbumsEntity::setAuthorizationDestination);
b.forField(textAuthorizationSource).withValidator(StringUtils::isNotBlank, "Token source is mandatory").withValidator(value -> {
if (!textUrlAPI.getValue().isBlank()) {
return validateToken(value, textUrlAPI.getValue(), SwitchingAlbum.MIN_SCOPE_SOURCE);
}
return true;
}, "Token can't be validate, minimum permissions: [read, send]").bind(KheopsAlbumsEntity::getAuthorizationSource, KheopsAlbumsEntity::setAuthorizationSource);
b.forField(textUrlAPI).withValidator(StringUtils::isNotBlank, "Url API is mandatory").bind(KheopsAlbumsEntity::getUrlAPI, KheopsAlbumsEntity::setUrlAPI);
b.forField(textCondition).withValidator(value -> {
if (!textCondition.getValue().equals("")) {
expressionError = ExpressionResult.isValid(textCondition.getValue(), new ExprCondition(), Boolean.class);
textErrorConditionMsg.setText(expressionError.getMsg());
return expressionError.isValid();
}
textErrorConditionMsg.setText("");
return true;
}, "Condition is not valid").bind(KheopsAlbumsEntity::getCondition, KheopsAlbumsEntity::setCondition);
return b;
}
use of org.karnak.backend.data.entity.KheopsAlbumsEntity in project karnak by OsiriX-Foundation.
the class SwitchingAlbumsView method setEventButtonAdd.
private void setEventButtonAdd() {
newSwitchingAlbum.getButtonAdd().addClickListener(event -> {
newSwitchingAlbum.getTextErrorConditionMsg().setText("");
KheopsAlbumsEntity newKheopsAlbumsEntity = new KheopsAlbumsEntity();
if (newSwitchingAlbumBinder.writeBeanIfValid(newKheopsAlbumsEntity)) {
// Add only if not already existing in table
if (!dataProviderSwitchingAlbums.getItems().contains(newKheopsAlbumsEntity)) {
dataProviderSwitchingAlbums.getItems().add(newKheopsAlbumsEntity);
dataProviderSwitchingAlbums.refreshAll();
newSwitchingAlbum.clear();
} else {
// Otherwise error message already existing
newSwitchingAlbum.getTextErrorConditionMsg().setText("Already existing");
}
}
});
}
Aggregations