use of org.weasis.dicom.param.DicomNode 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.weasis.dicom.param.DicomNode in project karnak by OsiriX-Foundation.
the class Util method getEchoResponse.
public static boolean getEchoResponse(StringBuilder result, String callingAET, DicomNode calledNode, boolean fontIcon, String format, Integer connectTimeout) {
boolean success = false;
boolean xml = "XML".equalsIgnoreCase(format);
try {
AdvancedParams params = new AdvancedParams();
DicomState state;
if (connectTimeout != null) {
ConnectOptions connectOptions = new ConnectOptions();
connectOptions.setConnectTimeout(connectTimeout);
params.setConnectOptions(connectOptions);
state = Echo.process(params, new DicomNode(callingAET), calledNode);
} else {
state = Echo.process(callingAET, calledNode);
}
success = state.getStatus() == Status.Success;
if (xml) {
result.append("<DcmStatus>");
if (success) {
result.append("Success").append("</DcmStatus>");
result.append("<DcmStatusMessage>").append(state.getMessage()).append("</DcmStatusMessage>");
} else {
result.append("Error ").append(Integer.toHexString(state.getStatus())).append("</DcmStatus>");
result.append("<DcmStatusMessage>").append(state.getMessage()).append("</DcmStatusMessage>");
}
} else {
// "HTML" and anything else
result.append(success ? "<span style=\"color:green\">" + getOKItem(fontIcon) : "<span style=\"color:red\">" + getWarningItem(fontIcon));
result.append("</span> DICOM Status: ");
if (success) {
result.append("Success");
} else {
result.append("error code ");
result.append(Integer.toHexString(state.getStatus()));
}
result.append("<br>DICOM Message: ");
result.append(state.getMessage());
result.append("<br>");
}
} catch (Throwable e) {
if (xml) {
result.append("<DcmStatus>DICOM unexpected error</DcmStatus>");
result.append("<DcmStatusMessage>").append(e.getMessage()).append("</DcmStatusMessage>");
} else {
// "HTML" and anything else
result.append("<span style=\"color:red\">");
result.append(getWarningItem(fontIcon));
result.append(" DICOM unexpected error: ");
result.append(e.getMessage());
result.append("</span><br>");
}
}
return success;
}
use of org.weasis.dicom.param.DicomNode in project karnak by OsiriX-Foundation.
the class DicomEchoLogic method dicomEcho.
public void dicomEcho(DicomEchoQueryData data) {
String aet = data.getCalledAet();
String hostname = data.getCalledHostname();
int port = data.getCalledPort();
StringBuilder result = new StringBuilder();
result.append("<P><h6>Network status</h6>");
boolean reachable = Util.getNetworkResponse(result, aet, hostname, port, true);
result.append("</P>");
if (reachable) {
result.append("<br><P>");
DicomNode dcmNode = new DicomNode(data.getCalledAet(), data.getCalledHostname(), data.getCalledPort());
result.append("<h6>DICOM Echo: ");
result.append(dcmNode.getAet());
result.append("</h6>");
Util.getEchoResponse(result, data.getCallingAet(), dcmNode, true, "HTML");
result.append("</P>");
}
view.displayStatus(result.toString());
}
use of org.weasis.dicom.param.DicomNode in project karnak by OsiriX-Foundation.
the class DicomEchoThread method call.
@Override
public String call() throws Exception {
StringBuilder result = new StringBuilder();
result.append("<P>");
DicomNode dcmNode = node.getCalledNode();
result.append("<h6>DICOM Echo: ");
result.append(node.toString());
result.append("</h6>");
result.append(dcmNode.toString());
result.append("<br>");
result.append("<small>");
boolean success = Util.getEchoResponse(result, "PACSMONITOR", dcmNode, true, "HTML", 3000);
if (!success) {
Util.getNetworkResponse(result, dcmNode.getAet(), dcmNode.getHostname(), dcmNode.getPort(), true);
}
result.append("</small>");
result.append("</P>");
result.append("<hr>");
return result.toString();
}
use of org.weasis.dicom.param.DicomNode in project karnak by OsiriX-Foundation.
the class ForwardDestinationTest method when_uid_rlelossless_or_endian_should_return_explicit_vr_little_endian.
@Test
void when_uid_rlelossless_or_endian_should_return_explicit_vr_little_endian() throws IOException {
// Init data
ForwardDicomNode forwardDicomNode = new ForwardDicomNode("fwdAeTitle");
DicomNode dicomNode = new DicomNode("fwdAeTitle", 1111);
ForwardDestination forwardDestination = new DicomForwardDestination(forwardDicomNode, dicomNode);
// Mock
dicomUtilsMock.when(() -> DicomUtils.isNative(Mockito.anyString())).thenReturn(true);
dicomOutputDataMock.when(() -> DicomOutputData.isSupportedSyntax(Mockito.anyString())).thenReturn(false);
// Call method
String outputTransferSyntax = forwardDestination.getOutputTransferSyntax(UID.RLELossless);
// Test result
assertEquals(UID.ExplicitVRLittleEndian, outputTransferSyntax);
// Call method
outputTransferSyntax = forwardDestination.getOutputTransferSyntax(UID.ImplicitVRLittleEndian);
// Test result
assertEquals(UID.ExplicitVRLittleEndian, outputTransferSyntax);
// Call method
outputTransferSyntax = forwardDestination.getOutputTransferSyntax(UID.ExplicitVRBigEndian);
// Test result
assertEquals(UID.ExplicitVRLittleEndian, outputTransferSyntax);
}
Aggregations