use of org.karnak.backend.service.kheops.SwitchingAlbum 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);
}
}
Aggregations