Java Code Examples for org.dcm4che3.data.Attributes#getInt()
The following examples show how to use
org.dcm4che3.data.Attributes#getInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StorageCommitmentService.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
@Override protected void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes cmd, Attributes data) throws IOException { try { if (dimse != Dimse.N_ACTION_RQ) { throw new DicomServiceException(Status.UnrecognizedOperation); } if (!cmd.getString(Tag.RequestedSOPClassUID).equals(UID.StorageCommitmentPushModelSOPClass)) { throw new DicomServiceException(Status.NoSuchSOPclass); } if (!cmd.getString(Tag.RequestedSOPInstanceUID) .equals(UID.StorageCommitmentPushModelSOPInstance)) { throw new DicomServiceException(Status.NoSuchObjectInstance); } int actionTypeID = cmd.getInt(Tag.ActionTypeID, 0); if (actionTypeID != 1) { throw new DicomServiceException(Status.NoSuchActionType).setActionTypeID(actionTypeID); } MonitoringService.addEvent(Event.COMMITMENT_REQUEST); Aet remoteAet = aets.getAet(as.getRemoteAET()); if (remoteAet == null) { MonitoringService.addEvent(Event.COMMITMENT_ERROR); throw new DicomServiceException(Status.ProcessingFailure, "Unknown AET: " + as.getRemoteAET()); } CommitmentReportTask task = new CommitmentReportTask(as.getApplicationEntity(), data, remoteAet); as.getApplicationEntity().getDevice().execute(task); as.writeDimseRSP(pc, Commands.mkNActionRSP(cmd, Status.Success)); } catch (RuntimeException e) { throw new DicomServiceException(Status.ProcessingFailure, e); } }
Example 2
Source File: DimseTask.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
DimseTask(Association as, PresentationContext pc, Attributes cmd) { this.as = as; this.pc = pc; this.cmd = cmd; int msgId = cmd.getInt(Tag.MessageID, -1); as.addCancelRQHandler(msgId, this); }
Example 3
Source File: DicomProgress.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
private int getIntTag(int tag) { Attributes dcm = attributes; if (dcm == null) { return -1; } return dcm.getInt(tag, -1); }
Example 4
Source File: DicomProgress.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
public int getStatus() { if (isCancel()) { return Status.Cancel; } Attributes dcm = attributes; if (dcm == null) { return Status.Pending; } return dcm.getInt(Tag.Status, Status.Pending); }
Example 5
Source File: ServiceUtil.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
public static int getTotalOfSuboperations(Attributes cmd) { if (cmd != null) { int c = cmd.getInt(Tag.NumberOfCompletedSuboperations, 0); int f = cmd.getInt(Tag.NumberOfFailedSuboperations, 0); int w = cmd.getInt(Tag.NumberOfWarningSuboperations, 0); int r = cmd.getInt(Tag.NumberOfRemainingSuboperations, 0); return r + c + f + w; } return 0; }
Example 6
Source File: StoreSCU.java From weasis-dicom-tools with Eclipse Public License 2.0 | 5 votes |
private void onCStoreRSP(Attributes cmd, File f) { int status = cmd.getInt(Tag.Status, -1); state.setStatus(status); ProgressStatus ps; switch (status) { case Status.Success: totalSize += f.length(); ps = ProgressStatus.COMPLETED; break; case Status.CoercionOfDataElements: case Status.ElementsDiscarded: case Status.DataSetDoesNotMatchSOPClassWarning: totalSize += f.length(); ps = ProgressStatus.WARNING; System.err.println(MessageFormat.format("WARNING: Received C-STORE-RSP with Status {0}H for {1}", TagUtils.shortToHexString(status), f)); System.err.println(cmd); break; default: ps = ProgressStatus.FAILED; System.err.println(MessageFormat.format("ERROR: Received C-STORE-RSP with Status {0}H for {1}", TagUtils.shortToHexString(status), f)); System.err.println(cmd); } ServiceUtil.notifyProgession(state.getProgress(), cmd, ps, filesScanned); }
Example 7
Source File: ServletUtil.java From weasis-pacs-connector with Eclipse Public License 2.0 | 5 votes |
public static Integer getIntegerFromDicomElement(Attributes dicom, int tag, String privateCreatorID, Integer defaultValue) { if (dicom == null || !dicom.containsValue(tag)) { return defaultValue; } try { return dicom.getInt(privateCreatorID, tag, defaultValue == null ? 0 : defaultValue); } catch (NumberFormatException e) { LOGGER.error("Cannot parse Integer of {}: {} ", TagUtils.toString(tag), e.getMessage()); //$NON-NLS-1$ } return defaultValue; }
Example 8
Source File: StorageCommitmentServiceTest.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 4 votes |
@Override protected void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes cmd, Attributes data) throws IOException { // Throwing exceptions here is only meaningful in sense that it prevents checkFuture // completion. Might as well checkFuture.complete(false) instead. if (dimse != Dimse.N_EVENT_REPORT_RQ) { throw new DicomServiceException(Status.UnrecognizedOperation); } if (!cmd.getString(Tag.AffectedSOPClassUID).equals(UID.StorageCommitmentPushModelSOPClass)) { throw new DicomServiceException(Status.NoSuchSOPclass); } if (!cmd.getString(Tag.AffectedSOPInstanceUID) .equals(UID.StorageCommitmentPushModelSOPInstance)) { throw new DicomServiceException(Status.NoSuchObjectInstance); } int eventTypeID = cmd.getInt(Tag.EventTypeID, 0); Sequence presentSeq = data.getSequence(Tag.ReferencedSOPSequence); Sequence absentSeq = data.getSequence(Tag.FailedSOPSequence); switch (eventTypeID) { case 1: if (presentSeq == null || presentSeq.size() == 0 || absentSeq != null) { throw new DicomServiceException(Status.ProcessingFailure); } break; case 2: if (absentSeq == null || absentSeq.size() == 0) { throw new DicomServiceException(Status.ProcessingFailure); } break; default: throw new DicomServiceException(Status.NoSuchEventType) .setEventTypeID(eventTypeID); } try { checkFuture.complete(data.equals(expectReportAttrs)); Attributes rsp = Commands.mkNEventReportRSP(cmd, Status.Success); as.writeDimseRSP(pc, rsp); } catch (AssociationStateException e) { e.printStackTrace(); } }
Example 9
Source File: DimseRSPAssert.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 4 votes |
@Override public void onDimseRSP(Association association, Attributes cmd, Attributes data) { super.onDimseRSP(association, cmd, data); resultStatus = cmd.getInt(Tag.Status, /* default status */ -1); // assert from here hangs test instead of failing it }
Example 10
Source File: StoreFromStreamSCU.java From weasis-dicom-tools with Eclipse Public License 2.0 | 4 votes |
/** * @see <a * href="ERROR CODE STATUS">https://github.com/dcm4che/dcm4che/blob/master/dcm4che-net/src/main/java/org/dcm4che3/net/Status.java</a> */ private void onCStoreRSP(Attributes cmd) { int status = cmd.getInt(Tag.Status, -1); state.setStatus(status); ProgressStatus ps; switch (status) { case Status.Success: ps = ProgressStatus.COMPLETED; break; case Status.CoercionOfDataElements: case Status.ElementsDiscarded: case Status.DataSetDoesNotMatchSOPClassWarning: ps = ProgressStatus.WARNING; if (lastStatusCode != status && nbStatusLog < 3) { nbStatusLog++; lastStatusCode = status; if (LOGGER.isDebugEnabled()) { LOGGER.warn("Received C-STORE-RSP with Status {}H{}", TagUtils.shortToHexString(status), "\r\n" + cmd.toString()); } else { LOGGER.warn("Received C-STORE-RSP with Status {}H", TagUtils.shortToHexString(status)); } } break; default: ps = ProgressStatus.FAILED; if (lastStatusCode != status && nbStatusLog < 3) { nbStatusLog++; lastStatusCode = status; if (LOGGER.isDebugEnabled()) { LOGGER.error("Received C-STORE-RSP with Status {}H{}", TagUtils.shortToHexString(status), "\r\n" + cmd.toString()); } else { LOGGER.error("Received C-STORE-RSP with Status {}H", TagUtils.shortToHexString(status)); } } } ServiceUtil.notifyProgession(state.getProgress(), cmd, ps, numberOfSuboperations); }