private void testIsNotRemovedAndRetainsValue(
     String description,
     AttributeTag creatorTag,
     String creator,
     Attribute privateAttribute,
     String expectValue)
     throws DicomException {
   AttributeList list = new AttributeList();
   {
     Attribute a = new LongStringAttribute(creatorTag);
     a.addValue(creator);
     list.put(a);
   }
   list.put(privateAttribute);
   AttributeTag privateTag = privateAttribute.getTag();
   list.removeUnsafePrivateAttributes();
   assertTrue("Checking Creator is not removed", list.get(creatorTag) != null);
   assertEquals(
       "Checking Creator retains value",
       creator,
       Attribute.getDelimitedStringValuesOrEmptyString(list, creatorTag));
   assertTrue("Checking " + description + " is not removed", list.get(privateTag) != null);
   assertEquals(
       "Checking " + description + " retains value",
       expectValue,
       Attribute.getDelimitedStringValuesOrEmptyString(list, privateTag));
 }
Пример #2
0
 // should be extracted to a utility class ... also used in DoseUtility and
 // DoseReporterWithLegacyOCRAndAutoSendToRegistry :(
 public static String getQueryRetrieveLevel(AttributeList identifier, Attribute uniqueKey) {
   String level = null;
   if (identifier != null) {
     Attribute a = identifier.get(TagFromName.QueryRetrieveLevel);
     if (a != null) {
       level = a.getSingleStringValueOrNull();
     }
   }
   if (level == null) {
     // QueryRetrieveLevel must have been (erroneously) missing in query response ... see with Dave
     // Harvey's code on public server
     // so try to guess it from unique key in tree record
     // Fixes [bugs.mrmf] (000224) Missing query/retrieve level in C-FIND response causes tree
     // select and retrieve to fail
     if (uniqueKey != null) {
       AttributeTag tag = uniqueKey.getTag();
       if (tag != null) {
         if (tag.equals(TagFromName.PatientID)) {
           level = "PATIENT";
         } else if (tag.equals(TagFromName.StudyInstanceUID)) {
           level = "STUDY";
         } else if (tag.equals(TagFromName.SeriesInstanceUID)) {
           level = "SERIES";
         } else if (tag.equals(TagFromName.SOPInstanceUID)) {
           level = "IMAGE";
         }
       }
     }
     log.warning(
         "DownloadOrTransmit.getQueryRetrieveLevel(): Guessed missing Query Retrieve Level to be "
             + level);
   }
   return level;
 }
Пример #3
0
 protected void setCurrentRemoteQuerySelection(
     AttributeList uniqueKeys, Attribute uniqueKey, AttributeList identifier) {
   currentRemoteQuerySelectionUniqueKeys = uniqueKeys;
   currentRemoteQuerySelectionUniqueKey = uniqueKey;
   currentRemoteQuerySelectionRetrieveAE = null;
   if (identifier != null) {
     Attribute aRetrieveAETitle = identifier.get(TagFromName.RetrieveAETitle);
     if (aRetrieveAETitle != null)
       currentRemoteQuerySelectionRetrieveAE = aRetrieveAETitle.getSingleStringValueOrNull();
   }
   if (currentRemoteQuerySelectionRetrieveAE == null) {
     // it is legal for RetrieveAETitle to be zero length at all but the lowest levels of
     // the query model :( (See PS 3.4 C.4.1.1.3.2)
     // (so far the Leonardo is the only one that doesn't send it at all levels)
     // we could recurse down to the lower levels and get the union of the value there
     // but lets just keep it simple and ...
     // default to whoever it was we queried in the first place ...
     if (currentRemoteQueryInformationModel != null) {
       currentRemoteQuerySelectionRetrieveAE =
           currentRemoteQueryInformationModel.getCalledAETitle();
     }
   }
   currentRemoteQuerySelectionLevel = null;
   if (identifier != null) {
     Attribute a = identifier.get(TagFromName.QueryRetrieveLevel);
     if (a != null) {
       currentRemoteQuerySelectionLevel = a.getSingleStringValueOrNull();
     }
   }
   if (currentRemoteQuerySelectionLevel == null) {
     // QueryRetrieveLevel must have been (erroneously) missing in query response ... see with Dave
     // Harvey's code on public server
     // so try to guess it from unique key in tree record
     // Fixes [bugs.mrmf] (000224) Missing query/retrieve level in C-FIND response causes tree
     // select and retrieve to fail
     if (uniqueKey != null) {
       AttributeTag tag = uniqueKey.getTag();
       if (tag != null) {
         if (tag.equals(TagFromName.PatientID)) {
           currentRemoteQuerySelectionLevel = "PATIENT";
         } else if (tag.equals(TagFromName.StudyInstanceUID)) {
           currentRemoteQuerySelectionLevel = "STUDY";
         } else if (tag.equals(TagFromName.SeriesInstanceUID)) {
           currentRemoteQuerySelectionLevel = "SERIES";
         } else if (tag.equals(TagFromName.SOPInstanceUID)) {
           currentRemoteQuerySelectionLevel = "IMAGE";
         }
       }
     }
     log.warning(
         "RemotePACs.setCurrentRemoteQuerySelection(): Guessed missing currentRemoteQuerySelectionLevel to be "
             + currentRemoteQuerySelectionLevel);
   }
 }
Пример #4
0
 protected CompositeInstanceContext mergePatientContext(
     Group group, CompositeInstanceContext newContext) {
   if (group.context == null) {
     // System.err.println("mergePatientContext(): creating new context for group");
     group.context = newContext;
   } else {
     AttributeList groupList = group.context.getAttributeList();
     Iterator<Attribute> newListIterator = newContext.getAttributeList().values().iterator();
     while (newListIterator.hasNext()) {
       Attribute a = newListIterator.next();
       AttributeTag tag = a.getTag();
       String groupValue = Attribute.getSingleStringValueOrEmptyString(groupList, tag);
       String newValue = a.getSingleStringValueOrEmptyString();
       if (!newValue.equals(groupValue)) {
         String describeTag = tag + " " + groupList.getDictionary().getFullNameFromTag(tag);
         System.err.println(
             "mergePatientContext(): in group "
                 + group.identity
                 + " for "
                 + describeTag
                 + " values differ between existing group value <"
                 + groupValue
                 + "> and new value <"
                 + newValue
                 + ">");
         if (newValue.length() > 0
             && (groupValue.length() == 0 || isNonZeroLengthDummyValue(groupValue))) {
           System.err.println(
               "mergePatientContext(): in group "
                   + group.identity
                   + " for "
                   + describeTag
                   + " replacing absent/empty/dummy existing group value with new value <"
                   + newValue
                   + ">");
           groupList.put(a);
         }
       }
     }
   }
   return group.context;
 }