org.dcm4che3.data.Attributes Java Examples

The following examples show how to use org.dcm4che3.data.Attributes. 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: DicomQueryConfiguration.java    From weasis-pacs-connector with Eclipse Public License 2.0 6 votes vote down vote up
private static Study getStudy(Patient patient, final Attributes studyDataset) {
    if (studyDataset == null) {
        throw new IllegalArgumentException("studyDataset cannot be null");
    }
    String uid = studyDataset.getString(Tag.StudyInstanceUID);
    Study s = patient.getStudy(uid);
    if (s == null) {
        s = new Study(uid);
        s.setStudyDescription(studyDataset.getString(Tag.StudyDescription));
        s.setStudyDate(studyDataset.getString(Tag.StudyDate));
        s.setStudyTime(studyDataset.getString(Tag.StudyTime));
        s.setAccessionNumber(studyDataset.getString(Tag.AccessionNumber));
        s.setStudyID(studyDataset.getString(Tag.StudyID));
        s.setReferringPhysicianName(studyDataset.getString(Tag.ReferringPhysicianName));
        patient.addStudy(s);
    }
    return s;
}
 
Example #2
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
@Test
public void testJsonToAttributes_patientName() throws Exception {
  JSONObject jsonObj = new JSONObject("{\""
      + TagUtils.toHexString(Tag.PatientName)
      + "\": {\"vr\": \"PN\",\"Value\": [{"
      + "\"Alphabetic\": \"Yamada^Tarou\", "
      + "\"Ideographic\": \"山田^太郎\", "
      + "\"Phonetic\": \"やまだ^たろう\", "
      + "}]}}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expected = new Attributes();
  expected.setString(Tag.PatientName, VR.PN, "Yamada^Tarou=山田^太郎=やまだ^たろう");
  assertThat(attrs).isEqualTo(expected);
}
 
Example #3
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
@Test
public void testJsonToAttributes_sequence() throws Exception {
  JSONObject jsonObj = new JSONObject("{\""
      + TagUtils.toHexString(Tag.FrameContentSequence)
      + "\": {\"vr\": \"SQ\", \"Value\": " +
      " [{ \"" + TagUtils.toHexString(Tag.DimensionIndexValues)
      + "\": {\"vr\": \"UL\", \"Value\": [1,1]} }] }}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expected = new Attributes();
  Sequence sequence = expected.newSequence(Tag.FrameContentSequence, 1);
  Attributes sequenceElement = new Attributes();
  sequenceElement.setInt(Tag.DimensionIndexValues, VR.UL, 1, 1);
  sequence.add(sequenceElement);
  assertThat(attrs).isEqualTo(expected);
}
 
Example #4
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
@Test
public void testJsonToAttributes_integerString() throws Exception {
  // can be parsed as either string or int.
  JSONObject jsonObj = new JSONObject("{\"" + TagUtils.toHexString(Tag.InstanceNumber)
      + "\": {\"vr\": \"IS\",\"Value\": [" + Integer.MAX_VALUE + "]}}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expectedAsInt = new Attributes();
  expectedAsInt.setInt(Tag.InstanceNumber, VR.IS, Integer.MAX_VALUE);
  assertThat(attrs).isEqualTo(expectedAsInt);

  Attributes expectedAsString = new Attributes();
  expectedAsString.setString(Tag.InstanceNumber, VR.IS, String.valueOf(Integer.MAX_VALUE));
  assertThat(attrs).isEqualTo(expectedAsString);
}
 
Example #5
Source File: CFind.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
public static void addAttributes(Attributes attrs, DicomParam param) {
    int tag = param.getTag();
    String[] ss = param.getValues();
    VR vr = ElementDictionary.vrOf(tag, attrs.getPrivateCreator(tag));
    if (ss == null || ss.length == 0) {
        // Returning key
        if (vr == VR.SQ) {
            attrs.newSequence(tag, 1).add(new Attributes(0));
        } else {
            attrs.setNull(tag, vr);
        }
    } else {
        // Matching key
        attrs.setString(tag, vr, ss);
    }
}
 
Example #6
Source File: CMoveService.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
private void sendErrorResponse(int status, String message, List<String> failedInstanceUids) {
  switch (status) {
    case Status.Cancel:
      MonitoringService.addEvent(Event.CMOVE_CANCEL);
      break;
    case Status.OneOrMoreFailures:
      MonitoringService.addEvent(Event.CMOVE_WARNING);
      break;
    default:
      MonitoringService.addEvent(Event.CMOVE_ERROR);
  }

  Attributes cmdAttr = Commands.mkCMoveRSP(cmd, status);
  if (message != null) {
    cmdAttr.setString(Tag.ErrorComment, VR.LO, message);
  }

  if (failedInstanceUids != null && failedInstanceUids.size() > 0) {
    Attributes dataAttr = new Attributes();
    dataAttr.setString(Tag.FailedSOPInstanceUIDList, VR.UI,
        failedInstanceUids.toArray(new String[]{}));
    as.tryWriteDimseRSP(pc, cmdAttr, dataAttr);
  } else {
    as.tryWriteDimseRSP(pc, cmdAttr);
  }
}
 
Example #7
Source File: AttributesUtil.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
private static void setPatientNames(Attributes attrs, int tag, JSONArray jsonValues) {
  List<String> results = new ArrayList<>();
  for (Object itemObj : jsonValues) {
    JSONObject item = (JSONObject) itemObj;
    String alphabetic = item.has(PN_ALPHABETIC) ? item.getString(PN_ALPHABETIC) : "";
    String ideographic = item.has(PN_IDEOGRAPHIC) ? item.getString(PN_IDEOGRAPHIC) : "";
    String phonetic = item.has(PN_PHONETIC) ? item.getString(PN_PHONETIC) : "";
    StringBuilder result = new StringBuilder();
    result.append(alphabetic);
    if (ideographic.length() > 0 || phonetic.length() > 0) {
      result.append(PN_DELIMITER);
    }
    result.append(ideographic);
    if (phonetic.length() > 0) {
      result.append(PN_DELIMITER);
    }
    result.append(phonetic);
    results.add(result.toString());
  }

  attrs.setString(tag, VR.PN, results.toArray(new String[0]));
}
 
Example #8
Source File: DicomQueryConfiguration.java    From weasis-pacs-connector with Eclipse Public License 2.0 6 votes vote down vote up
private Patient getPatient(Attributes patientDataset) {
    if (patientDataset == null) {
        throw new IllegalArgumentException("patientDataset cannot be null");
    }

    fillPatientAttributes(patientDataset);

    String id = patientDataset.getString(Tag.PatientID, "Unknown");
    String ispid = patientDataset.getString(Tag.IssuerOfPatientID);
    Patient p = getPatient(id, ispid);
    if (p == null) {
        p = new Patient(id, ispid);
        p.setPatientName(patientDataset.getString(Tag.PatientName));
        // Only set birth date, birth time is often not consistent (00:00)
        p.setPatientBirthDate(patientDataset.getString(Tag.PatientBirthDate));
        p.setPatientSex(patientDataset.getString(Tag.PatientSex));
        addPatient(p);
    }
    return p;
}
 
Example #9
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
@Test
public void testAttributesToQidoPathArray_manyModalitiesSet() throws Exception {
  Attributes attrs = new Attributes();
  attrs.setString(Tag.QueryRetrieveLevel, VR.CS, "IMAGE");
  attrs.setString(Tag.ModalitiesInStudy, VR.CS, "MG", "CS", "CR");

  String[] results = AttributesUtil.attributesToQidoPathArray(attrs);

  assertThat(results.length).isEqualTo(3);
  assertThat(results[0]).isEqualTo(
      "instances?limit=50000&" + TagUtils.toHexString(Tag.ModalitiesInStudy) + "=MG&");
  assertThat(results[1]).isEqualTo(
      "instances?limit=50000&" + TagUtils.toHexString(Tag.ModalitiesInStudy) + "=CS&");
  assertThat(results[2]).isEqualTo(
      "instances?limit=50000&" + TagUtils.toHexString(Tag.ModalitiesInStudy) + "=CR&");
}
 
Example #10
Source File: StoreFromStreamSCU.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
public StoreFromStreamSCU(AdvancedParams params, DicomNode callingNode, DicomNode calledNode,
    DicomProgress progress) throws IOException {
    Objects.requireNonNull(callingNode);
    Objects.requireNonNull(calledNode);
    AdvancedParams options = params == null ? new AdvancedParams() : params;
    this.state = new DicomState(progress);
    this.device = new Device("storescu");
    this.conn = new Connection();
    device.addConnection(conn);
    this.ae = new ApplicationEntity(callingNode.getAet());
    device.addApplicationEntity(ae);
    ae.addConnection(conn);

    this.remote = new Connection();

    rq.addPresentationContext(new PresentationContext(1, UID.VerificationSOPClass, UID.ImplicitVRLittleEndian));

    options.configureConnect(rq, remote, calledNode);
    options.configureBind(ae, conn, callingNode);

    // configure
    options.configure(conn);
    options.configureTLS(conn, remote);

    setAttributes(new Attributes());
}
 
Example #11
Source File: StowrsSingleFile.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void uploadDicom(InputStream in, Attributes fmi, String tsuid, String iuid) throws IOException {
    HttpURLConnection httpPost = buildConnection();
    try (DataOutputStream out = new DataOutputStream(httpPost.getOutputStream());
                    DicomOutputStream dos = new DicomOutputStream(out, tsuid)) {
        writeContentMarkers(out);
        dos.writeFileMetaInformation(fmi);

        byte[] buf = new byte[FileUtil.FILE_BUFFER];
        int offset;
        while ((offset = in.read(buf)) > 0) {
            dos.write(buf, 0, offset);
        }
        writeEndMarkers(httpPost, out, iuid);
    } finally {
        removeConnection(httpPost);
    }
}
 
Example #12
Source File: Dicomizer.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
public static void pdf(final Attributes attrs, File pdfFile, File dcmFile) throws IOException {
    attrs.setString(Tag.SOPClassUID, VR.UI, UID.EncapsulatedPDFStorage);
    ensureString(attrs, Tag.SpecificCharacterSet, VR.CS, "ISO_IR 192");// UTF-8
    ensureUID(attrs, Tag.StudyInstanceUID);
    ensureUID(attrs, Tag.SeriesInstanceUID);
    ensureUID(attrs, Tag.SOPInstanceUID);
    setCreationDate(attrs);

    BulkData bulk = new BulkData(pdfFile.toURI().toString(), 0, (int) pdfFile.length(), false);
    attrs.setValue(Tag.EncapsulatedDocument, VR.OB, bulk);
    attrs.setString(Tag.MIMETypeOfEncapsulatedDocument, VR.LO, "application/pdf");
    Attributes fmi = attrs.createFileMetaInformation(UID.ExplicitVRLittleEndian);
    try (DicomOutputStream dos = new DicomOutputStream(dcmFile)) {
        dos.writeDataset(fmi, attrs);
    }
}
 
Example #13
Source File: AbstractStowrs.java    From weasis-dicom-tools with Eclipse Public License 2.0 6 votes vote down vote up
protected Attributes writeEndMarkers(HttpURLConnection httpPost, DataOutputStream out)
    throws IOException, ParserConfigurationException, SAXException {
    endMarkers(out);

    int code = httpPost.getResponseCode();
    if (code == HttpURLConnection.HTTP_OK) {
        LOGGER.info("STOWRS server response message: HTTP Status-Code 200: OK for all the image set"); //$NON-NLS-1$
    } else if (code == HttpURLConnection.HTTP_ACCEPTED || code == HttpURLConnection.HTTP_CONFLICT) {
        LOGGER.warn("STOWRS server response message: HTTP Status-Code {}: {}", code, httpPost.getResponseMessage()); //$NON-NLS-1$
        // See http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.6.html#table_6.6.1-1
        return SAXReader.parse(httpPost.getInputStream());
    } else {
        throw new HttpServerErrorException(String.format("STOWRS server response message: HTTP Status-Code %d: %s",
            code, httpPost.getResponseMessage()));
    }
    return null;
}
 
Example #14
Source File: FindSCU.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
private void onResult(Attributes data) {
    state.addDicomRSP(data);
    int numMatches = totNumMatches.incrementAndGet();
    if (outDir == null) {
        return;
    }

    try {
        if (out == null) {
            File f = new File(outDir, fname(numMatches));
            out = new BufferedOutputStream(new FileOutputStream(f));
        }
        if (xml) {
            writeAsXML(data, out);
        } else {
            // Do not close DicomOutputStream until catOut is false. Only "out" needs to be closed
            DicomOutputStream dos = new DicomOutputStream(out, UID.ImplicitVRLittleEndian);  //NOSONAR
            dos.writeDataset(null, data);
        }
        out.flush();
    } catch (Exception e) {
        LOGGER.error("Building response", e);
        SafeClose.close(out);
        out = null;
    } finally {
        if (!catOut) {
            SafeClose.close(out);
            out = null;
        }
    }
}
 
Example #15
Source File: ServletUtil.java    From weasis-pacs-connector with Eclipse Public License 2.0 5 votes vote down vote up
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 #16
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonToAttributes_empty() throws Exception {
  JSONObject jsonObj = new JSONObject();

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  assertThat(attrs).isEqualTo(new Attributes());
}
 
Example #17
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonToAttributes_decimalString() throws Exception {
  String value = "12345678901234567890.1234567890";
  JSONObject jsonObj = new JSONObject("{\"" + TagUtils.toHexString(Tag.DecimalVisualAcuity)
      + "\": {\"vr\": \"DS\",\"Value\": [" + value + "]}}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expected = new Attributes();
  expected.setString(Tag.DecimalVisualAcuity, VR.DS, value);
  assertThat(attrs).isEqualTo(expected);
}
 
Example #18
Source File: DicomQueryConfiguration.java    From weasis-pacs-connector with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildFromSeriesInstanceUID(CommonQueryParams params, String... seriesInstanceUIDs) {
    AdvancedParams advParams = advancedParams == null ? new AdvancedParams() : advancedParams;
    advParams.getQueryOptions().add(QueryOption.RELATIONAL);

    for (String seriesInstanceUID : seriesInstanceUIDs) {
        if (!StringUtil.hasText(seriesInstanceUID)) {
            continue;
        }

        DicomParam[] keysSeries = {
            // Matching Keys
            new DicomParam(Tag.SeriesInstanceUID, seriesInstanceUID),
            // Return Keys
            CFind.PatientID, CFind.IssuerOfPatientID, CFind.PatientName, CFind.PatientBirthDate, CFind.PatientSex,
            CFind.ReferringPhysicianName, CFind.StudyDescription, CFind.StudyDate, CFind.StudyTime,
            CFind.AccessionNumber, CFind.StudyInstanceUID, CFind.StudyID, CFind.Modality, CFind.SeriesNumber,
            CFind.SeriesDescription };

        try {
            DicomState state =
                CFind.process(advParams, callingNode, calledNode, 0, QueryRetrieveLevel.SERIES, keysSeries);
            LOGGER.debug(C_FIND_WITH_SERIESUID, state.getMessage());

            List<Attributes> series = state.getDicomRSP();
            if (series != null && !series.isEmpty()) {
                Attributes dataset = series.get(0);
                Patient patient = getPatient(dataset);
                Study study = getStudy(patient, dataset);
                for (Attributes seriesDataset : series) {
                    fillInstance(seriesDataset, study);
                }
            }
        } catch (Exception e) {
            LOGGER.error(DICOM_QUERY_ERROR, getArchiveConfigName(), e);
        }
    }
}
 
Example #19
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonToAttributes_intType() throws Exception {
  JSONObject jsonObj = new JSONObject("{\""
      + TagUtils.toHexString(Tag.ConcatenationFrameOffsetNumber)
      + "\": {\"vr\": \"UL\",\"Value\": [1, 1]}}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expected = new Attributes();
  expected.setInt(Tag.ConcatenationFrameOffsetNumber, VR.UL, 1, 1);
  assertThat(attrs).isEqualTo(expected);
}
 
Example #20
Source File: DicomQueryConfiguration.java    From weasis-pacs-connector with Eclipse Public License 2.0 5 votes vote down vote up
private void fillInstance(Attributes seriesDataset, Study study) {
    String serieInstanceUID = seriesDataset.getString(Tag.SeriesInstanceUID);
    if (StringUtil.hasText(serieInstanceUID)) {
        DicomParam[] keysInstance = {
            // Matching Keys
            new DicomParam(Tag.StudyInstanceUID, study.getStudyInstanceUID()),
            new DicomParam(Tag.SeriesInstanceUID, serieInstanceUID),
            // Return Keys
            CFind.SOPInstanceUID, CFind.InstanceNumber };
        DicomState state =
            CFind.process(advancedParams, callingNode, calledNode, 0, QueryRetrieveLevel.IMAGE, keysInstance);
        LOGGER.debug(C_FIND_WITH_SERIESUID, state.getMessage());

        List<Attributes> instances = state.getDicomRSP();
        if (instances != null && !instances.isEmpty()) {
            Series s = getSeries(study, seriesDataset, properties);

            for (Attributes instanceDataSet : instances) {
                Integer frame = ServletUtil.getIntegerFromDicomElement(instanceDataSet, Tag.InstanceNumber, null);
                String sopUID = instanceDataSet.getString(Tag.SOPInstanceUID);
                SopInstance sop = s.getSopInstance(sopUID, frame);
                if (sop == null) {
                    s.addSopInstance(new SopInstance(sopUID, frame));
                }
            }
        }
    }
}
 
Example #21
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonToAttributes_double() throws Exception {
  JSONObject jsonObj = new JSONObject("{\""
      + TagUtils.toHexString(Tag.EventTimeOffset)
      + "\": {\"vr\": \"FD\",\"Value\": [1.25]}}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expected = new Attributes();
  expected.setDouble(Tag.EventTimeOffset, VR.FD, 1.25);
  assertThat(attrs).isEqualTo(expected);
}
 
Example #22
Source File: AttributesUtilTest.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonToAttributes_float() throws Exception {
  JSONObject jsonObj = new JSONObject("{\""
      + TagUtils.toHexString(Tag.DisplayedZValue)
      + "\": {\"vr\": \"FL\",\"Value\": [1.25]}}");

  Attributes attrs = AttributesUtil.jsonToAttributes(jsonObj);

  Attributes expected = new Attributes();
  expected.setFloat(Tag.DisplayedZValue, VR.FL, 1.25f);
  assertThat(attrs).isEqualTo(expected);
}
 
Example #23
Source File: DestinationFilter.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
public DestinationFilter(String filterString) {
  String aeTitle = null;
  this.filterAttrs = new Attributes();

  if (filterString != null && filterString.length() > 0) {
    String[] params = filterString.split("&");
    for (String param : params) {
      String[] keyValue = param.split("=");
      if (keyValue.length != 2) {
        throw new IllegalArgumentException(
            "Invalid filter parameter: " + param);
      }
      if (keyValue[0].equals(AE_TITLE)) {
        aeTitle = keyValue[1];
      } else {
        int tag = TagUtils.forName(keyValue[0]);
        if (tag == -1) {
          throw new IllegalArgumentException(
              "Invalid tag in filter string: " + keyValue[0]);
        }
        this.filterAttrs.setString(tag, VR.LO,
            keyValue[1]); // VR just needs to be any string type for match()
      }
    }
  }

  this.aeTitle = aeTitle;
}
 
Example #24
Source File: CFindService.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public void onDimseRQ(Association association,
    PresentationContext presentationContext,
    Dimse dimse,
    Attributes request,
    Attributes keys) throws IOException {
  if (dimse != Dimse.C_FIND_RQ) {
    throw new DicomServiceException(Status.UnrecognizedOperation);
  }

  MonitoringService.addEvent(Event.CFIND_REQUEST);

  CFindTask task = new CFindTask(association, presentationContext, request, keys);
  association.getApplicationEntity().getDevice().execute(task);
}
 
Example #25
Source File: GetSCU.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
private void updateProgress(Association as, Attributes cmd) {
    DicomProgress p = state.getProgress();
    if (p != null) {
        p.setAttributes(cmd);
        if (p.isCancel() && rspHandler != null) {
            try {
                rspHandler.cancel(as);
            } catch (IOException e) {
                LOGGER.error("Cancel C-GET", e);
            }
        }
    }
}
 
Example #26
Source File: CLIUtils.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
public static void addEmptyAttributes(Attributes attrs, String[] optVals) {
    if (optVals != null) {
        for (int i = 0; i < optVals.length; i++) {
            addAttributes(attrs, toTags(StringUtils.split(optVals[i], '/')));
        }
    }
}
 
Example #27
Source File: DimseTask.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: StubCStoreService.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Override
protected void store(
    Association association,
    PresentationContext presentationContext,
    Attributes request,
    PDVInputStream dataStream,
    Attributes response)
    throws DicomServiceException {
  response.setInt(Tag.Status, VR.US, statusCode);
}
 
Example #29
Source File: ServiceUtil.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
public static void notifyProgession(DicomProgress p, Attributes cmd, ProgressStatus ps, int numberOfSuboperations) {
    if (p != null && cmd != null) {
        int c;
        int f;
        int r;
        int w;
        if (p.getAttributes() == null) {
            c = 0;
            f = 0;
            w = 0;
            r = numberOfSuboperations;
        } else {
            c = p.getNumberOfCompletedSuboperations();
            f = p.getNumberOfFailedSuboperations();
            w = p.getNumberOfWarningSuboperations();
            r = numberOfSuboperations - (c + f + w);
        }

        if (r < 1) {
            r = 1;
        }

        if (ps == ProgressStatus.COMPLETED) {
            c++;
        } else if (ps == ProgressStatus.FAILED) {
            f++;
        } else if (ps == ProgressStatus.WARNING) {
            w++;
        }
        cmd.setInt(Tag.NumberOfCompletedSuboperations, VR.US, c);
        cmd.setInt(Tag.NumberOfFailedSuboperations, VR.US, f);
        cmd.setInt(Tag.NumberOfWarningSuboperations, VR.US, w);
        cmd.setInt(Tag.NumberOfRemainingSuboperations, VR.US, r - 1);
    }
}
 
Example #30
Source File: AbstractStowrs.java    From weasis-dicom-tools with Eclipse Public License 2.0 5 votes vote down vote up
protected String getContentLocation(Attributes metadata) {
    BulkData data = ((BulkData) metadata.getValue(Tag.EncapsulatedDocument));
    if (data != null) {
        return data.getURI();
    }

    data = ((BulkData) metadata.getValue(Tag.PixelData));
    if (data != null) {
        return data.getURI();
    }
    return null;
}