Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
IngestJobSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2016 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest;
20 
21 import java.awt.Component;
22 import java.awt.Dimension;
23 import java.awt.Toolkit;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.WindowAdapter;
26 import java.awt.event.WindowEvent;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
31 import javax.swing.Icon;
32 import javax.swing.ImageIcon;
33 import javax.swing.JDialog;
34 import javax.swing.JLabel;
35 import javax.swing.JTable;
36 import javax.swing.ListSelectionModel;
37 import javax.swing.SwingUtilities;
38 import javax.swing.event.ListSelectionEvent;
39 import javax.swing.table.AbstractTableModel;
40 import javax.swing.table.DefaultTableCellRenderer;
41 import javax.swing.table.TableColumn;
42 import org.openide.util.NbBundle.Messages;
46 import org.sleuthkit.datamodel.Content;
47 import org.sleuthkit.datamodel.IngestJobInfo;
48 import org.sleuthkit.datamodel.IngestModuleInfo;
49 import org.sleuthkit.datamodel.SleuthkitCase;
50 import org.sleuthkit.datamodel.TskCoreException;
51 
55 public final class IngestJobSettingsPanel extends javax.swing.JPanel {
56 
57  private static final long serialVersionUID = 1L;
58  private static ImageIcon warningIcon = new ImageIcon(IngestJobSettingsPanel.class.getResource("/org/sleuthkit/autopsy/images/warning_triangle.png"));
59  private static ImageIcon infoIcon = new ImageIcon(IngestJobSettingsPanel.class.getResource("/org/sleuthkit/autopsy/images/information-frame.png"));
60  private final IngestJobSettings settings;
61  private final List<Content> dataSources = new ArrayList<>();
62  private final List<IngestJobInfo> ingestJobs = new ArrayList<>();
63  private final List<IngestModuleModel> modules = new ArrayList<>();
66  private static final Logger logger = Logger.getLogger(IngestJobSettingsPanel.class.getName());
67 
74  this.settings = settings;
75  for (IngestModuleTemplate moduleTemplate : settings.getIngestModuleTemplates()) {
76  modules.add(new IngestModuleModel(moduleTemplate));
77  }
80  }
81 
88  IngestJobSettingsPanel(IngestJobSettings settings, List<Content> dataSources) {
89  this.settings = settings;
90  this.dataSources.addAll(dataSources);
91  try {
92  SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
93  ingestJobs.addAll(skCase.getIngestJobs());
94  } catch (IllegalStateException ex) {
95  logger.log(Level.SEVERE, "No open case", ex);
96  } catch (TskCoreException ex) {
97  logger.log(Level.SEVERE, "Failed to load ingest job information", ex);
98  }
99  for (IngestModuleTemplate moduleTemplate : settings.getIngestModuleTemplates()) {
100  this.modules.add(new IngestModuleModel(moduleTemplate));
101  }
102  initComponents();
104  }
105 
112  List<IngestModuleTemplate> moduleTemplates = new ArrayList<>();
113  for (IngestModuleModel module : modules) {
114  IngestModuleTemplate moduleTemplate = module.getIngestModuleTemplate();
115  if (module.hasModuleSettingsPanel()) {
116  IngestModuleIngestJobSettings moduleSettings = module.getModuleSettingsPanel().getSettings();
117  moduleTemplate.setModuleSettings(moduleSettings);
118  }
119  moduleTemplates.add(moduleTemplate);
120  }
121  this.settings.setIngestModuleTemplates(moduleTemplates);
122  return this.settings;
123  }
124 
125  @Messages({"IngestJobSettingsPanel.noPerRunSettings=The selected module has no per-run settings."})
126  private void customizeComponents() {
127  modulesTable.setModel(tableModel);
128  modulesTable.setTableHeader(null);
129  modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
130 
131  // Set the column widths in the table model and add a custom cell
132  // renderer that will display module descriptions from the module models
133  // as tooltips.
135  int width = modulesScrollPane.getPreferredSize().width;
136  for (int i = 0; i < modulesTable.getColumnCount(); ++i) {
137  TableColumn column = modulesTable.getColumnModel().getColumn(i);
138  if (0 == i) {
139  column.setPreferredWidth(((int) (width * 0.15)));
140  } else {
141  column.setCellRenderer(renderer);
142  column.setPreferredWidth(((int) (width * 0.84)));
143  }
144  }
145 
146  // Add a selection listener to the table model that will display the
147  // ingest job options panel of the currently selected module model and
148  // enable or disable the resources configuration panel invocation button.
149  modulesTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
150  ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
151  if (!listSelectionModel.isSelectionEmpty()) {
152  int index = listSelectionModel.getMinSelectionIndex();
153  selectedModule = modules.get(index);
154  ingestSettingsPanel.removeAll();
155  if (null != selectedModule.getModuleSettingsPanel()) {
156  ingestSettingsPanel.add(selectedModule.getModuleSettingsPanel());
157  } else {
158  ingestSettingsPanel.add(new JLabel(Bundle.IngestJobSettingsPanel_noPerRunSettings()));
159  }
160  ingestSettingsPanel.revalidate();
161  ingestSettingsPanel.repaint();
162  globalSettingsButton.setEnabled(null != selectedModule.getGlobalSettingsPanel());
163  descriptionLabel.setText(selectedModule.getDescription());
164  descriptionLabel.setToolTipText(selectedModule.getDescription());
165  }
166  });
167  modulesTable.setRowSelectionInterval(0, 0);
168  processUnallocCheckbox.setSelected(this.settings.getProcessUnallocatedSpace());
169  this.modulesTable.getColumnModel().getColumn(0).setMaxWidth(22);
170  this.modulesTable.getColumnModel().getColumn(1).setMaxWidth(20);
171  this.modulesTable.getColumnModel().getColumn(1).setMinWidth(20);
172  modulesTable.setRowHeight(20);
173 
174  /*
175  * Only enable the ingest jobs history panel if there are data sources
176  * and jobs for which to display the history.
177  */
178  pastJobsButton.setEnabled(!dataSources.isEmpty() && !ingestJobs.isEmpty());
179  }
180 
186  @SuppressWarnings("unchecked")
187  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
188  private void initComponents() {
189 
190  timeGroup = new javax.swing.ButtonGroup();
191  modulesScrollPane = new javax.swing.JScrollPane();
192  modulesTable = new javax.swing.JTable();
193  jPanel1 = new javax.swing.JPanel();
194  globalSettingsButton = new javax.swing.JButton();
195  jSeparator2 = new javax.swing.JSeparator();
196  descriptionLabel = new javax.swing.JLabel();
197  jScrollPane1 = new javax.swing.JScrollPane();
198  ingestSettingsPanel = new javax.swing.JPanel();
199  jButtonSelectAll = new javax.swing.JButton();
200  jButtonDeselectAll = new javax.swing.JButton();
201  processUnallocCheckbox = new javax.swing.JCheckBox();
202  pastJobsButton = new javax.swing.JButton();
203 
204  setMaximumSize(new java.awt.Dimension(5750, 3000));
205  setMinimumSize(new java.awt.Dimension(0, 0));
206  setPreferredSize(new java.awt.Dimension(625, 450));
207 
208  modulesScrollPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(160, 160, 160)));
209  modulesScrollPane.setMinimumSize(new java.awt.Dimension(0, 0));
210  modulesScrollPane.setPreferredSize(new java.awt.Dimension(160, 160));
211 
212  modulesTable.setBackground(new java.awt.Color(240, 240, 240));
213  modulesTable.setModel(new javax.swing.table.DefaultTableModel(
214  new Object [][] {
215 
216  },
217  new String [] {
218 
219  }
220  ));
221  modulesTable.setShowHorizontalLines(false);
222  modulesTable.setShowVerticalLines(false);
223  modulesScrollPane.setViewportView(modulesTable);
224 
225  jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(160, 160, 160)));
226  jPanel1.setPreferredSize(new java.awt.Dimension(338, 257));
227 
228  globalSettingsButton.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.globalSettingsButton.text")); // NOI18N
229  globalSettingsButton.setActionCommand(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.globalSettingsButton.actionCommand")); // NOI18N
230  globalSettingsButton.setEnabled(false);
231  globalSettingsButton.addActionListener(new java.awt.event.ActionListener() {
232  public void actionPerformed(java.awt.event.ActionEvent evt) {
234  }
235  });
236 
237  descriptionLabel.setText("DO NOT REMOVE. This dummy text is used to anchor the inner panel's size to the outer panel, while still being expandable. Without this the expandability behavior doesn't work well. This text will never be shown, as it would only be shown when no module is selected (which is not possible).");
238 
239  jScrollPane1.setBorder(null);
240  jScrollPane1.setPreferredSize(new java.awt.Dimension(250, 180));
241 
242  ingestSettingsPanel.setMinimumSize(new java.awt.Dimension(0, 300));
243  ingestSettingsPanel.setLayout(new javax.swing.BoxLayout(ingestSettingsPanel, javax.swing.BoxLayout.PAGE_AXIS));
244  jScrollPane1.setViewportView(ingestSettingsPanel);
245 
246  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
247  jPanel1.setLayout(jPanel1Layout);
248  jPanel1Layout.setHorizontalGroup(
249  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
250  .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
251  .addGroup(jPanel1Layout.createSequentialGroup()
252  .addContainerGap()
253  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
254  .addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
255  .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
256  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
257  .addGap(0, 0, Short.MAX_VALUE)
258  .addComponent(globalSettingsButton)))
259  .addContainerGap())
260  );
261  jPanel1Layout.setVerticalGroup(
262  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
264  .addContainerGap()
265  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
266  .addGap(18, 18, 18)
267  .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
268  .addGap(8, 8, 8)
269  .addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
270  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
271  .addComponent(globalSettingsButton)
272  .addGap(8, 8, 8))
273  );
274 
275  jButtonSelectAll.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.jButtonSelectAll.text")); // NOI18N
276  jButtonSelectAll.addActionListener(new java.awt.event.ActionListener() {
277  public void actionPerformed(java.awt.event.ActionEvent evt) {
279  }
280  });
281 
282  jButtonDeselectAll.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.jButtonDeselectAll.text")); // NOI18N
283  jButtonDeselectAll.addActionListener(new java.awt.event.ActionListener() {
284  public void actionPerformed(java.awt.event.ActionEvent evt) {
286  }
287  });
288 
289  processUnallocCheckbox.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.processUnallocCheckbox.text")); // NOI18N
290  processUnallocCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.processUnallocCheckbox.toolTipText")); // NOI18N
291  processUnallocCheckbox.addActionListener(new java.awt.event.ActionListener() {
292  public void actionPerformed(java.awt.event.ActionEvent evt) {
294  }
295  });
296 
297  pastJobsButton.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.pastJobsButton.text")); // NOI18N
298  pastJobsButton.addActionListener(new java.awt.event.ActionListener() {
299  public void actionPerformed(java.awt.event.ActionEvent evt) {
301  }
302  });
303 
304  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
305  this.setLayout(layout);
306  layout.setHorizontalGroup(
307  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308  .addGroup(layout.createSequentialGroup()
309  .addContainerGap()
310  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
311  .addComponent(modulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
312  .addGroup(layout.createSequentialGroup()
313  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
314  .addComponent(processUnallocCheckbox)
315  .addGroup(layout.createSequentialGroup()
316  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
317  .addComponent(jButtonSelectAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
318  .addComponent(pastJobsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
319  .addGap(5, 5, 5)
320  .addComponent(jButtonDeselectAll)))
321  .addGap(0, 0, Short.MAX_VALUE)))
322  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
323  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
324  .addContainerGap())
325  );
326  layout.setVerticalGroup(
327  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328  .addGroup(layout.createSequentialGroup()
329  .addContainerGap()
330  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331  .addGroup(layout.createSequentialGroup()
332  .addComponent(modulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
333  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
335  .addComponent(jButtonSelectAll)
336  .addComponent(jButtonDeselectAll))
337  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
338  .addComponent(pastJobsButton)
339  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
340  .addComponent(processUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
341  .addGroup(layout.createSequentialGroup()
342  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)
343  .addContainerGap())))
344  );
345  }// </editor-fold>//GEN-END:initComponents
346 
347  private void globalSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_globalSettingsButtonActionPerformed
349 
350  dialog.addApplyButtonListener((ActionEvent e) -> {
351  if (selectedModule.hasGlobalSettingsPanel()) {
352  selectedModule.saveResourcesConfig();
353  }
354  dialog.close();
355  });
356 
357  dialog.addWindowListener(new WindowAdapter() {
358  @Override
359  public void windowClosing(WindowEvent e) {
360  dialog.close();
361  }
362  });
363 
364  dialog.display(selectedModule.getGlobalSettingsPanel());
365  }//GEN-LAST:event_globalSettingsButtonActionPerformed
366 
367  private void jButtonSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectAllActionPerformed
368  SelectAllModules(true);
369  }//GEN-LAST:event_jButtonSelectAllActionPerformed
370 
371  private void jButtonDeselectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeselectAllActionPerformed
372  SelectAllModules(false);
373  }//GEN-LAST:event_jButtonDeselectAllActionPerformed
374 
375  private void processUnallocCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_processUnallocCheckboxActionPerformed
376  this.settings.setProcessUnallocatedSpace(processUnallocCheckbox.isSelected());
377  }//GEN-LAST:event_processUnallocCheckboxActionPerformed
378  @Messages({"IngestJobSettingsPanel.pastJobsButton.action.frame.title=Ingest History"})
379  private void pastJobsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pastJobsButtonActionPerformed
380  JDialog topFrame = (JDialog) SwingUtilities.getWindowAncestor(this);
381  JDialog dialog = new JDialog(topFrame, Bundle.IngestJobSettingsPanel_pastJobsButton_action_frame_title(), false);
382  IngestJobInfoPanel ingestInfo = new IngestJobInfoPanel();
383  dialog.add(ingestInfo);
384  Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
385  double w = dialog.getSize().getWidth();
386  double h = dialog.getSize().getHeight();
387  dialog.setLocation((int) ((screenDimension.getWidth() - w) / 2), (int) ((screenDimension.getHeight() - h) / 2));
388  dialog.setResizable(true);
389  dialog.pack();
390  dialog.setVisible(true);
391  }//GEN-LAST:event_pastJobsButtonActionPerformed
392 
393  private void SelectAllModules(boolean set) {
394  for (IngestModuleModel module : modules) {
395  module.setEnabled(set);
396  }
397  modulesTable.repaint();
398  }
399 
400  // Variables declaration - do not modify//GEN-BEGIN:variables
401  private javax.swing.JLabel descriptionLabel;
402  private javax.swing.JButton globalSettingsButton;
403  private javax.swing.JPanel ingestSettingsPanel;
404  private javax.swing.JButton jButtonDeselectAll;
405  private javax.swing.JButton jButtonSelectAll;
406  private javax.swing.JPanel jPanel1;
407  private javax.swing.JScrollPane jScrollPane1;
408  private javax.swing.JSeparator jSeparator2;
409  private javax.swing.JScrollPane modulesScrollPane;
410  private javax.swing.JTable modulesTable;
411  private javax.swing.JButton pastJobsButton;
412  private javax.swing.JCheckBox processUnallocCheckbox;
413  private javax.swing.ButtonGroup timeGroup;
414  // End of variables declaration//GEN-END:variables
415 
421  static private class IngestModuleModel {
422 
423  private final IngestModuleTemplate moduleTemplate;
426 
427  IngestModuleModel(IngestModuleTemplate moduleTemplate) {
428  this.moduleTemplate = moduleTemplate;
429  if (moduleTemplate.hasModuleSettingsPanel()) {
430  moduleSettingsPanel = moduleTemplate.getModuleSettingsPanel();
431  }
432  if (moduleTemplate.hasGlobalSettingsPanel()) {
433  globalSettingsPanel = moduleTemplate.getGlobalSettingsPanel();
434  }
435  }
436 
437  IngestModuleTemplate getIngestModuleTemplate() {
438  return moduleTemplate;
439  }
440 
441  String getName() {
442  return moduleTemplate.getModuleName();
443  }
444 
445  String getDescription() {
446  return moduleTemplate.getModuleDescription();
447  }
448 
449  void setEnabled(boolean enabled) {
450  moduleTemplate.setEnabled(enabled);
451  }
452 
453  boolean isEnabled() {
454  return moduleTemplate.isEnabled();
455  }
456 
457  boolean hasModuleSettingsPanel() {
458  return moduleTemplate.hasModuleSettingsPanel();
459  }
460 
461  IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() {
462  return moduleSettingsPanel;
463  }
464 
465  boolean hasGlobalSettingsPanel() {
466  return moduleTemplate.hasGlobalSettingsPanel();
467  }
468 
469  IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
470  return globalSettingsPanel;
471  }
472 
473  void saveResourcesConfig() {
474  globalSettingsPanel.saveSettings();
475  }
476  }
477 
482  private class IngestModulesTableModel extends AbstractTableModel {
483 
484  private static final long serialVersionUID = 1L;
485 
486  @Override
487  public int getRowCount() {
488  return modules.size();
489  }
490 
491  @Override
492  public int getColumnCount() {
493  return 3;
494  }
495 
496  @Override
497  public Object getValueAt(int rowIndex, int columnIndex) {
498  IngestModuleModel module = modules.get(rowIndex);
499  switch (columnIndex) {
500  case 0:
501  return module.isEnabled();
502  case 1:
503  return getIcon(module);
504  default:
505  return module.getName();
506  }
507  }
508 
509  @Override
510  public boolean isCellEditable(int rowIndex, int columnIndex) {
511  return columnIndex == 0;
512  }
513 
514  @Override
515  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
516  if (columnIndex == 0) {
517  modules.get(rowIndex).setEnabled((boolean) aValue);
518  }
519  }
520 
521  @Override
522  public Class<?> getColumnClass(int c) {
523  return getValueAt(0, c).getClass();
524  }
525 
526  private ImageIcon getIcon(IngestModuleModel module) {
527  if (dataSources.isEmpty() || ingestJobs.isEmpty()) {
528  return null;
529  }
530  boolean previousVersionRun = false;
531  for (IngestJobInfo ingestJob : ingestJobs) {
532  if (ingestJob.getStatus() != IngestJobInfo.IngestJobStatusType.COMPLETED) {
533  continue;
534  }
535  long objectId = ingestJob.getObjectId();
536  boolean isSameDataSource = false;
537  for (Content dataSource : dataSources) {
538  isSameDataSource = isSameDataSource || dataSource.getId() == objectId;
539  }
540  if (isSameDataSource) {
541  IngestModuleFactory factory = module.getIngestModuleTemplate().getModuleFactory();
542  if (factory.isDataSourceIngestModuleFactory()) {
543  String uniqueName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) + "-"
544  + factory.getModuleDisplayName() + "-"
545  + IngestModuleInfo.IngestModuleType.DATA_SOURCE_LEVEL.toString() + "-"
546  + factory.getModuleVersionNumber();
547  for (IngestModuleInfo ingestModuleInfo : ingestJob.getIngestModuleInfo()) {
548  boolean sameModule = ingestModuleInfo.getUniqueName().equals(uniqueName);
549  if (sameModule) {
550  if (ingestModuleInfo.getVersion().equals(module.getIngestModuleTemplate().getModuleFactory().getModuleVersionNumber())) {
551  return warningIcon;
552  }
553  }
554  previousVersionRun = previousVersionRun || sameModule;
555  }
556  }
557  if (factory.isFileIngestModuleFactory()) {
558  String uniqueName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) + "-"
559  + factory.getModuleDisplayName() + "-"
560  + IngestModuleInfo.IngestModuleType.FILE_LEVEL.toString() + "-"
561  + factory.getModuleVersionNumber();
562  for (IngestModuleInfo ingestModuleInfo : ingestJob.getIngestModuleInfo()) {
563  boolean sameModule = ingestModuleInfo.getUniqueName().equals(uniqueName);
564  if (sameModule) {
565  if (ingestModuleInfo.getVersion().equals(module.getIngestModuleTemplate().getModuleFactory().getModuleVersionNumber())) {
566  return warningIcon;
567  }
568  }
569  previousVersionRun = previousVersionRun || sameModule;
570  }
571  }
572  }
573  }
574  if (previousVersionRun) {
575  return infoIcon;
576  }
577  return null;
578  }
579  }
580 
585  @Messages({"IngestJobSettingsPanel.IngestModulesTableRenderer.warning.message=This ingest module has been run before on this data source.",
586  "IngestJobSettingsPanel.IngestModulesTableRenderer.info.message=A previous version of this ingest module has been run before on this data source."})
587  private class IngestModulesTableRenderer extends DefaultTableCellRenderer {
588 
589  private static final long serialVersionUID = 1L;
590 
591  List<String> tooltips = new ArrayList<>();
592 
594  for (IngestModuleModel moduleTemplate : modules) {
595  tooltips.add(moduleTemplate.getDescription());
596  }
597  }
598 
599  @Override
600  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
601  super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
602  if (2 == column) {
603  setIcon(null);
604  setToolTipText(tooltips.get(row));
605  } else if (1 == column) {
606  setIcon((Icon) value);
607  setText("");
608  if (warningIcon.equals(value)) {
609  setToolTipText(Bundle.IngestJobSettingsPanel_IngestModulesTableRenderer_warning_message());
610  } else if (infoIcon.equals(value)) {
611  setToolTipText(Bundle.IngestJobSettingsPanel_IngestModulesTableRenderer_info_message());
612  }
613  }
614  return this;
615  }
616  }
617 }
void processUnallocCheckboxActionPerformed(java.awt.event.ActionEvent evt)
void pastJobsButtonActionPerformed(java.awt.event.ActionEvent evt)
void jButtonSelectAllActionPerformed(java.awt.event.ActionEvent evt)
void globalSettingsButtonActionPerformed(java.awt.event.ActionEvent evt)
void jButtonDeselectAllActionPerformed(java.awt.event.ActionEvent evt)
Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.