public static Collection<KOSpecialElement> getEditableKoSpecialElements(MediaSeriesGroup group) { List<KOSpecialElement> list = getSpecialElements(group, KOSpecialElement.class); if (list != null && !list.isEmpty()) { for (int i = list.size() - 1; i >= 0; i--) { KOSpecialElement koElement = list.get(i); if (!koElement.getMediaReader().isEditableDicom()) { list.remove(i); } } return list; } return Collections.emptyList(); }
public static final Collection<RejectedKOSpecialElement> getRejectionKoSpecialElements( Collection<DicomSpecialElement> specialElements, String seriesUID) { if (specialElements == null) { return Collections.emptySet(); } SortedSet<RejectedKOSpecialElement> koElementSet = null; for (DicomSpecialElement element : specialElements) { if (element instanceof RejectedKOSpecialElement) { RejectedKOSpecialElement koElement = (RejectedKOSpecialElement) element; Set<String> referencedSeriesInstanceUIDSet = koElement.getReferencedSeriesInstanceUIDSet(); if (seriesUID == null || referencedSeriesInstanceUIDSet.contains(seriesUID) || koElement.getMediaReader().isEditableDicom()) { if (koElementSet == null) { koElementSet = new TreeSet<>(ORDER_BY_DATE); } koElementSet.add(koElement); } } } return koElementSet == null ? Collections.emptySet() : koElementSet; }
/** * * @param seriesUID * @param specialElements * @return the KOSpecialElement collection for the given parameters, if the referenced seriesUID is null all the * KOSpecialElement from specialElements collection are returned. In any case all the KOSpecialElement that * are writable will be added to the returned collection whatever is the seriesUID. These KO are part of the * new created ones by users of the application */ public static final Collection<KOSpecialElement> getKoSpecialElements( Collection<DicomSpecialElement> specialElements, String seriesUID) { if (specialElements == null) { return Collections.emptySet(); } SortedSet<KOSpecialElement> koElementSet = null; for (DicomSpecialElement element : specialElements) { if (element instanceof KOSpecialElement) { KOSpecialElement koElement = (KOSpecialElement) element; Set<String> referencedSeriesInstanceUIDSet = koElement.getReferencedSeriesInstanceUIDSet(); if (seriesUID == null || referencedSeriesInstanceUIDSet.contains(seriesUID) || koElement.getMediaReader().isEditableDicom()) { if (koElementSet == null) { koElementSet = new TreeSet<>(ORDER_BY_DATE); } koElementSet.add(koElement); } } } return koElementSet == null ? Collections.emptySet() : koElementSet; }
@Override public boolean buildFile(File output) { // When object is in memory, write it if (isEditableDicom()) { Attributes dcm = getDicomObject(); if (dcm != null) { try (DicomOutputStream out = new DicomOutputStream(output)) { out.writeDataset(dcm.createFileMetaInformation(UID.ImplicitVRLittleEndian), dcm); return true; } catch (IOException e) { LOGGER.error("Cannot write dicom file", e); //$NON-NLS-1$ } } } return false; }
/** * Get an editable Dicom KeyObject Selection suitable to handle current Dicom Image. A valid object should either * reference the studyInstanceUID of the current Dicom Image or simply be empty ... */ public static KOSpecialElement findValidKOSelection(final ViewCanvas<DicomImageElement> view2d) { MediaSeries<DicomImageElement> dicomSeries = view2d.getSeries(); DicomImageElement currentImage = view2d.getImage(); if (currentImage != null && dicomSeries != null) { String currentStudyInstanceUID = TagD.getTagValue(currentImage, Tag.StudyInstanceUID, String.class); Collection<KOSpecialElement> koElementsWithReferencedSeriesInstanceUID = DicomModel.getKoSpecialElements(dicomSeries); if (koElementsWithReferencedSeriesInstanceUID != null) { for (KOSpecialElement koElement : koElementsWithReferencedSeriesInstanceUID) { if (koElement.getMediaReader().isEditableDicom()) { if (koElement.containsStudyInstanceUIDReference(currentStudyInstanceUID)) { return koElement; } } } for (KOSpecialElement koElement : koElementsWithReferencedSeriesInstanceUID) { if (koElement.getMediaReader().isEditableDicom()) { if (koElement.isEmpty()) { return koElement; } } } } } return null; }
@Override public boolean saveToFile(File output) { // When object is in memory, write it if (getMediaReader().isEditableDicom()) { Attributes dcm = getMediaReader().getDicomObject(); if (dcm != null) { try (DicomOutputStream out = new DicomOutputStream(output)) { out.writeDataset(dcm.createFileMetaInformation(UID.ImplicitVRLittleEndian), dcm); return true; } catch (IOException e) { LOGGER.error("Cannot write dicom ({}): {}", getLabel(), e); //$NON-NLS-1$ } } } return super.saveToFile(output); }
String seriesUID = TagD.getTagValue(spel, Tag.SeriesInstanceUID, String.class); if (seriesInstanceUID.equals(seriesUID)) { if (!spel.getMediaReader().isEditableDicom()) { buildInstance(spel, s);
if (currentSelectedKO.getMediaReader().isEditableDicom()) {