Commits

John Paulett committed fef3895

Prevent specific DICOM series (scans) from being uploaded.

  • Participants
  • Parent commits 3487ac0

Comments (0)

Files changed (3)

File src/main/java/org/nrg/dcm/Series.java

 	private final Set<String> modalities = new TreeSet<String>();
 	private final Set<File> files = new LinkedHashSet<File>();
 	private DicomObject sampleObject = null;
+	private boolean uploadAllowed = true;
 	
 	Series(final Study study,
 			final String uid, final int number, final String modality) {
 	public boolean equals(final Object o) {
 		return o instanceof Series && getAttributes().equals(((Entity)o).getAttributes());
 	}
+
+	public void setUploadAllowed(final boolean uploadAllowed) {
+		this.uploadAllowed = uploadAllowed;
+	}
+
+	public boolean isUploadAllowed() {
+		return uploadAllowed;
+	}
 }

File src/main/java/org/nrg/dcm/Study.java

 
 		final Collection<File> files = new ArrayList<File>();
 		for (final Series s : series) {
-			for (final File f : s) {
-				files.add(f);
+			if (s.isUploadAllowed()) {
+				for (final File f : s) {
+					files.add(f);
+				}
 			}
 		}
 

File src/main/java/org/nrg/upload/ui/SessionReviewPanel.java

  */
 package org.nrg.upload.ui;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
 import javax.swing.BoxLayout;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableModel;
 
+import org.dcm4che2.data.Tag;
 import org.nrg.dcm.DicomUtils;
+import org.nrg.dcm.Series;
+import org.nrg.dcm.Study;
 import org.nrg.upload.data.Session;
 import org.nrg.util.Utils;
 
 		add(new JLabel("Description: " + session.getDescription()));
 		add(buildModalitiesLabel(session));
 		add(new JLabel(describeScans(session)));
+		
+		// for now, only allow selection of series from DICOM
+		if (session instanceof Study) {
+			add(buildScansTable((Study) session));
+		}
+		
 		validate();
 		setVisible(true);
 	}
 			return new JLabel(DicomUtils.join(new StringBuilder("Modalities: "), modalities, ",").toString());
 		}
 	}
+
+	private static JScrollPane buildScansTable(final Study study){
+		final ScansTableModel tableModel = new ScansTableModel(study);
+		final JTable table = new JTable(tableModel);
+		final JScrollPane scrollPane = new JScrollPane(table);
+		table.setFillsViewportHeight(true);
+		return scrollPane;
+	}
 	
 	public Session getSession() { return session; }
 
 		sb.append(")");
 		return sb.toString();
 	}
+
+	static class ScansTableModel extends DefaultTableModel {
+		private static final long serialVersionUID = 3558061608731992249L;
+		private static final int SELECT_COLUMN = 0;
+		private static final String[] COLUMNS = new String[] { "Upload", "Scan Type", "File Count" , "Size (bytes)"};
+		private static final Class<?>[] COLUMN_TYPES = new Class[] {Boolean.class, String.class, Integer.class, Long.class};
+		
+		public ScansTableModel(final Study study) {
+			super(COLUMNS, 0);
+			
+			// use a list so the TableModelListener has random-access ability on the series 
+			final List<Series> seriesList = new ArrayList<Series>();
+			
+			for (final Series series : study.getSeries()) {
+				seriesList.add(series);
+				final String description = series.getSampleObject().getString(Tag.SeriesDescription);
+				addRow(new Object[] { Boolean.TRUE, description, series.getFileCount(),
+						Utils.showNearestUnits(new StringBuilder(), series.getSize(), "b").toString() });
+			}
+			
+			addTableModelListener(new TableModelListener() {
+				public void tableChanged(TableModelEvent e) {
+					final int row = e.getFirstRow();
+					seriesList.get(row).setUploadAllowed((Boolean) getValueAt(row, SELECT_COLUMN));
+				}
+			});
+		}
+
+		@Override
+		public Class<?> getColumnClass(final int col) {
+	        return COLUMN_TYPES[col];
+		}
+
+		@Override
+		public boolean isCellEditable(final int row, final int col) {
+			// user can only click the usable checkbox in the first column
+			return col == SELECT_COLUMN;
+		}
+	}
+
 }