Autopsy  4.7.0
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-2018 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.event.ActionEvent;
23 import java.awt.event.WindowAdapter;
24 import java.awt.event.WindowEvent;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.logging.Level;
30 import javax.swing.DefaultComboBoxModel;
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;
51 import org.sleuthkit.datamodel.Content;
52 import org.sleuthkit.datamodel.IngestJobInfo;
53 import org.sleuthkit.datamodel.IngestModuleInfo;
54 import org.sleuthkit.datamodel.SleuthkitCase;
55 import org.sleuthkit.datamodel.TskCoreException;
57 
61 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
62 public final class IngestJobSettingsPanel extends javax.swing.JPanel {
63 
64  private static final long serialVersionUID = 1L;
65  private static ImageIcon warningIcon = new ImageIcon(IngestJobSettingsPanel.class.getResource("/org/sleuthkit/autopsy/images/warning_triangle.png"));
66  private static ImageIcon infoIcon = new ImageIcon(IngestJobSettingsPanel.class.getResource("/org/sleuthkit/autopsy/images/information-frame.png"));
67  private final IngestJobSettings settings;
68  private final List<Content> dataSources = new ArrayList<>();
69  private final List<IngestJobInfo> ingestJobs = new ArrayList<>();
70  private final List<IngestModuleModel> modules = new ArrayList<>();
71  private final IngestModulesTableModel tableModel = new IngestModulesTableModel();
73  private static final Logger logger = Logger.getLogger(IngestJobSettingsPanel.class.getName());
74 
82  this.settings = settings;
83  for (IngestModuleTemplate moduleTemplate : settings.getIngestModuleTemplates()) {
84  modules.add(new IngestModuleModel(moduleTemplate));
85  }
86  initComponents();
87  customizeComponents();
88  fileIngestFilterComboBox.setSelectedItem(settings.getFileFilter().getName());
89  }
90 
98  public IngestJobSettingsPanel(IngestJobSettings settings, List<Content> dataSources) {
99  this.settings = settings;
100  this.dataSources.addAll(dataSources);
101  try {
102  SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase();
103  ingestJobs.addAll(skCase.getIngestJobs());
104  } catch (NoCurrentCaseException ex) {
105  logger.log(Level.SEVERE, "No open case", ex);
106  } catch (TskCoreException ex) {
107  logger.log(Level.SEVERE, "Failed to load ingest job information", ex);
108  }
109  for (IngestModuleTemplate moduleTemplate : settings.getIngestModuleTemplates()) {
110  this.modules.add(new IngestModuleModel(moduleTemplate));
111  }
112  initComponents();
113  customizeComponents();
114  fileIngestFilterComboBox.setSelectedItem(settings.getFileFilter().getName());
115  }
116 
123  List<IngestModuleTemplate> moduleTemplates = new ArrayList<>();
124  for (IngestModuleModel module : modules) {
125  IngestModuleTemplate moduleTemplate = module.getIngestModuleTemplate();
126  if (module.hasModuleSettingsPanel()) {
127  IngestModuleIngestJobSettings moduleSettings = module.getModuleSettingsPanel().getSettings();
128  moduleTemplate.setModuleSettings(moduleSettings);
129  }
130  moduleTemplates.add(moduleTemplate);
131  }
132  this.settings.setIngestModuleTemplates(moduleTemplates);
133  return this.settings;
134  }
135 
136  @Messages({"IngestJobSettingsPanel.noPerRunSettings=The selected module has no per-run settings."})
137  private void customizeComponents() {
138  modulesTable.setModel(tableModel);
139  modulesTable.setTableHeader(null);
140  modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
141 
142  // Set the column widths in the table model and add a custom cell
143  // renderer that will display module descriptions from the module models
144  // as tooltips.
146  int width = modulesScrollPane.getPreferredSize().width;
147  for (int i = 0; i < modulesTable.getColumnCount(); ++i) {
148  TableColumn column = modulesTable.getColumnModel().getColumn(i);
149  if (0 == i) {
150  column.setPreferredWidth(((int) (width * 0.15)));
151  } else {
152  column.setCellRenderer(renderer);
153  column.setPreferredWidth(((int) (width * 0.84)));
154  }
155  }
156 
157  // Add a selection listener to the table model that will display the
158  // ingest job options panel of the currently selected module model and
159  // enable or disable the resources configuration panel invocation button.
160  modulesTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
161  ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
162  if (!listSelectionModel.isSelectionEmpty()) {
163  int index = listSelectionModel.getMinSelectionIndex();
164  selectedModule = modules.get(index);
165  ingestSettingsPanel.removeAll();
166  if (null != selectedModule.getModuleSettingsPanel()) {
167  ingestSettingsPanel.add(selectedModule.getModuleSettingsPanel());
168  } else {
169  ingestSettingsPanel.add(new JLabel(Bundle.IngestJobSettingsPanel_noPerRunSettings()));
170  }
171  ingestSettingsPanel.revalidate();
172  ingestSettingsPanel.repaint();
173  globalSettingsButton.setEnabled(null != selectedModule.getGlobalSettingsPanel());
174  descriptionLabel.setText(selectedModule.getDescription());
175  descriptionLabel.setToolTipText(selectedModule.getDescription());
176  }
177  });
178  modulesTable.setRowSelectionInterval(0, 0);
179  this.modulesTable.getColumnModel().getColumn(0).setMaxWidth(22);
180  this.modulesTable.getColumnModel().getColumn(1).setMaxWidth(20);
181  this.modulesTable.getColumnModel().getColumn(1).setMinWidth(20);
182  modulesTable.setRowHeight(20);
183 
184  /*
185  * Only enable the ingest jobs history panel if there are data sources
186  * and jobs for which to display the history.
187  */
188  pastJobsButton.setEnabled(!dataSources.isEmpty() && !ingestJobs.isEmpty());
189  }
190 
191  void setPastJobsButtonVisible(boolean isVisible) {
192  pastJobsButton.setVisible(isVisible);
193  }
194 
200  @SuppressWarnings("unchecked")
201  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
202  private void initComponents() {
203 
204  timeGroup = new javax.swing.ButtonGroup();
205  modulesScrollPane = new javax.swing.JScrollPane();
206  modulesTable = new javax.swing.JTable();
207  jPanel1 = new javax.swing.JPanel();
208  globalSettingsButton = new javax.swing.JButton();
209  jSeparator2 = new javax.swing.JSeparator();
210  descriptionLabel = new javax.swing.JLabel();
211  jScrollPane1 = new javax.swing.JScrollPane();
212  ingestSettingsPanel = new javax.swing.JPanel();
213  jButtonSelectAll = new javax.swing.JButton();
214  jButtonDeselectAll = new javax.swing.JButton();
215  pastJobsButton = new javax.swing.JButton();
216  fileIngestFilterLabel = new javax.swing.JLabel();
217  fileIngestFilterComboBox = new javax.swing.JComboBox<>();
218 
219  setMaximumSize(new java.awt.Dimension(5750, 3000));
220  setMinimumSize(new java.awt.Dimension(0, 0));
221  setPreferredSize(new java.awt.Dimension(625, 450));
222 
223  modulesScrollPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(160, 160, 160)));
224  modulesScrollPane.setMinimumSize(new java.awt.Dimension(0, 0));
225  modulesScrollPane.setPreferredSize(new java.awt.Dimension(160, 160));
226 
227  modulesTable.setBackground(new java.awt.Color(240, 240, 240));
228  modulesTable.setModel(new javax.swing.table.DefaultTableModel(
229  new Object [][] {
230 
231  },
232  new String [] {
233 
234  }
235  ));
236  modulesTable.setShowHorizontalLines(false);
237  modulesTable.setShowVerticalLines(false);
238  modulesScrollPane.setViewportView(modulesTable);
239 
240  jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(160, 160, 160)));
241  jPanel1.setPreferredSize(new java.awt.Dimension(338, 257));
242 
243  globalSettingsButton.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.globalSettingsButton.text")); // NOI18N
244  globalSettingsButton.setActionCommand(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.globalSettingsButton.actionCommand")); // NOI18N
245  globalSettingsButton.setEnabled(false);
246  globalSettingsButton.addActionListener(new java.awt.event.ActionListener() {
247  public void actionPerformed(java.awt.event.ActionEvent evt) {
248  globalSettingsButtonActionPerformed(evt);
249  }
250  });
251 
252  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).");
253 
254  jScrollPane1.setBorder(null);
255  jScrollPane1.setPreferredSize(new java.awt.Dimension(250, 180));
256 
257  ingestSettingsPanel.setMinimumSize(new java.awt.Dimension(0, 300));
258  ingestSettingsPanel.setLayout(new javax.swing.BoxLayout(ingestSettingsPanel, javax.swing.BoxLayout.PAGE_AXIS));
259  jScrollPane1.setViewportView(ingestSettingsPanel);
260 
261  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
262  jPanel1.setLayout(jPanel1Layout);
263  jPanel1Layout.setHorizontalGroup(
264  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
265  .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
266  .addGroup(jPanel1Layout.createSequentialGroup()
267  .addGap(8, 8, 8)
268  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
269  .addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
270  .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
271  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
272  .addGap(0, 0, Short.MAX_VALUE)
273  .addComponent(globalSettingsButton)))
274  .addGap(8, 8, 8))
275  );
276  jPanel1Layout.setVerticalGroup(
277  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
278  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
279  .addContainerGap()
280  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
281  .addGap(18, 18, 18)
282  .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
283  .addGap(8, 8, 8)
284  .addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
285  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
286  .addComponent(globalSettingsButton)
287  .addGap(8, 8, 8))
288  );
289 
290  jButtonSelectAll.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.jButtonSelectAll.text")); // NOI18N
291  jButtonSelectAll.setMargin(new java.awt.Insets(2, 8, 2, 8));
292  jButtonSelectAll.setMaximumSize(new java.awt.Dimension(87, 23));
293  jButtonSelectAll.setMinimumSize(new java.awt.Dimension(87, 23));
294  jButtonSelectAll.addActionListener(new java.awt.event.ActionListener() {
295  public void actionPerformed(java.awt.event.ActionEvent evt) {
296  jButtonSelectAllActionPerformed(evt);
297  }
298  });
299 
300  jButtonDeselectAll.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.jButtonDeselectAll.text")); // NOI18N
301  jButtonDeselectAll.setMargin(new java.awt.Insets(2, 8, 2, 8));
302  jButtonDeselectAll.addActionListener(new java.awt.event.ActionListener() {
303  public void actionPerformed(java.awt.event.ActionEvent evt) {
304  jButtonDeselectAllActionPerformed(evt);
305  }
306  });
307 
308  pastJobsButton.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.pastJobsButton.text")); // NOI18N
309  pastJobsButton.setMargin(new java.awt.Insets(2, 8, 2, 8));
310  pastJobsButton.setMaximumSize(new java.awt.Dimension(87, 23));
311  pastJobsButton.setMinimumSize(new java.awt.Dimension(87, 23));
312  pastJobsButton.addActionListener(new java.awt.event.ActionListener() {
313  public void actionPerformed(java.awt.event.ActionEvent evt) {
314  pastJobsButtonActionPerformed(evt);
315  }
316  });
317 
318  fileIngestFilterLabel.setText(org.openide.util.NbBundle.getMessage(IngestJobSettingsPanel.class, "IngestJobSettingsPanel.fileIngestFilterLabel.text")); // NOI18N
319 
320  fileIngestFilterComboBox.setModel(new DefaultComboBoxModel<>(getComboBoxContents()));
321  fileIngestFilterComboBox.addActionListener(new java.awt.event.ActionListener() {
322  public void actionPerformed(java.awt.event.ActionEvent evt) {
323  fileIngestFilterComboBoxActionPerformed(evt);
324  }
325  });
326 
327  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
328  this.setLayout(layout);
329  layout.setHorizontalGroup(
330  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331  .addGroup(layout.createSequentialGroup()
332  .addGap(5, 5, 5)
333  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
334  .addGroup(layout.createSequentialGroup()
335  .addComponent(jButtonSelectAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
336  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
337  .addComponent(jButtonDeselectAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
338  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
339  .addComponent(pastJobsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
340  .addComponent(modulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
341  .addComponent(fileIngestFilterLabel)
342  .addComponent(fileIngestFilterComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
343  .addGap(4, 4, 4)
344  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
345  .addGap(5, 5, 5))
346  );
347 
348  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonDeselectAll, jButtonSelectAll, pastJobsButton});
349 
350  layout.setVerticalGroup(
351  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
352  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
353  .addContainerGap()
354  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
355  .addGroup(layout.createSequentialGroup()
356  .addComponent(fileIngestFilterLabel)
357  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
358  .addComponent(fileIngestFilterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
359  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
360  .addComponent(modulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
361  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
362  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
363  .addComponent(jButtonSelectAll, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
364  .addComponent(jButtonDeselectAll)
365  .addComponent(pastJobsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
366  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE))
367  .addContainerGap())
368  );
369  }// </editor-fold>//GEN-END:initComponents
370 
371  private void globalSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_globalSettingsButtonActionPerformed
373 
374  dialog.addApplyButtonListener((ActionEvent e) -> {
375  if (selectedModule.hasGlobalSettingsPanel()) {
376  selectedModule.saveResourcesConfig();
377  }
378  dialog.close();
379  });
380 
381  dialog.addWindowListener(new WindowAdapter() {
382  @Override
383  public void windowClosing(WindowEvent e) {
384  dialog.close();
385  }
386  });
387 
388  dialog.display(selectedModule.getGlobalSettingsPanel());
389  }//GEN-LAST:event_globalSettingsButtonActionPerformed
390 
391  private void jButtonSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectAllActionPerformed
392  SelectAllModules(true);
393  }//GEN-LAST:event_jButtonSelectAllActionPerformed
394 
395  private void jButtonDeselectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeselectAllActionPerformed
396  SelectAllModules(false);
397  }//GEN-LAST:event_jButtonDeselectAllActionPerformed
398  @Messages({"IngestJobSettingsPanel.pastJobsButton.action.frame.title=Ingest History"})
399  private void pastJobsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pastJobsButtonActionPerformed
400  JDialog topFrame = (JDialog) SwingUtilities.getWindowAncestor(this);
401  JDialog dialog = new JDialog(topFrame, Bundle.IngestJobSettingsPanel_pastJobsButton_action_frame_title(), false);
402  IngestJobInfoPanel ingestInfo = new IngestJobInfoPanel();
403  dialog.add(ingestInfo);
404  dialog.setLocationRelativeTo(topFrame);
405  dialog.setResizable(true);
406  dialog.pack();
407  dialog.setVisible(true);
408  }//GEN-LAST:event_pastJobsButtonActionPerformed
409 
410  private void fileIngestFilterComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileIngestFilterComboBoxActionPerformed
411  if (fileIngestFilterComboBox.getSelectedItem().toString().equals(FilesSetPanel.getCreateNewFileIngestFilterString())) {
413  FilesSetDefsPanel fileIngestFilterPanel;
415  fileIngestFilterPanel.load();
416  //save the filters that exist before any are created
417  final ArrayList<String> oldFilterList = new ArrayList<>(Arrays.asList(getComboBoxContents()));
418  dialog.addApplyButtonListener(
419  (ActionEvent e) -> {
420  fileIngestFilterPanel.store();
421  ArrayList<FilesSet> newFilterList = new ArrayList<>();
422  try {
423  newFilterList.addAll(FilesSetsManager.getInstance().getCustomFileIngestFilters().values());
425  logger.log(Level.SEVERE, "Failed to get user created file ingest filters, only default available for selection", ex); //NON-NLS
426  }
427  String filterToSelect = settings.getFileFilter().getName();
428  for (FilesSet filter : newFilterList) { //getting one of the recently created filters
429  if (!oldFilterList.contains(filter.getName())) {
430  //set newly created filter to selected filter
431  filterToSelect = filter.getName();
432  break;
433  }
434  }
435  fileIngestFilterComboBox.setModel(new DefaultComboBoxModel<>(getComboBoxContents()));
436  //set the selected filter after the comboBox Contents were updated to include it
437  fileIngestFilterComboBox.setSelectedItem(filterToSelect);
438  //refresh the saved filter in use case where the selected modified filter
439  //has the same name as a previously existing filter
440  updateSelectedFilter(filterToSelect);
441  dialog.close();
442  }
443  );
444  dialog.display(fileIngestFilterPanel);
445  //return to saved selection in case they cancel out of filter creation
446  fileIngestFilterComboBox.setSelectedItem(settings.getFileFilter().getName());
447  } else if (evt.getActionCommand().equals("comboBoxChanged")) {
448  updateSelectedFilter(fileIngestFilterComboBox.getSelectedItem().toString());
449  }
450  }//GEN-LAST:event_fileIngestFilterComboBoxActionPerformed
451 
452  private void updateSelectedFilter(String filterName) {
453  try {
454  Map<String, FilesSet> fileIngestFilters = FilesSetsManager.getInstance()
457  fileIngestFilters.put(fSet.getName(), fSet);
458  }
459  settings.setFileFilter(fileIngestFilters
460  .get(filterName));
463  logger.log(Level.SEVERE, "Failed to get file ingest filter from combobox selection, default filter being used", ex); //NON-NLS
464  }
465  }
466 
477  private String[] getComboBoxContents() {
478  ArrayList<String> nameList = new ArrayList<>();
480  nameList.add(fSet.getName());
481  }
482  try {
484  nameList.add(fSet.getName());
485  }
487  logger.log(Level.SEVERE, "Failed to get user created file ingest filters for combo box, only default available for selection", ex); //NON-NLS
488  }
490  return nameList.toArray(new String[nameList.size()]);
491  }
492 
493  private void SelectAllModules(boolean set) {
494  for (IngestModuleModel module : modules) {
495  module.setEnabled(set);
496  }
497  modulesTable.repaint();
498  }
499 
500  // Variables declaration - do not modify//GEN-BEGIN:variables
501  private javax.swing.JLabel descriptionLabel;
502  private javax.swing.JComboBox<String> fileIngestFilterComboBox;
503  private javax.swing.JLabel fileIngestFilterLabel;
504  private javax.swing.JButton globalSettingsButton;
505  private javax.swing.JPanel ingestSettingsPanel;
506  private javax.swing.JButton jButtonDeselectAll;
507  private javax.swing.JButton jButtonSelectAll;
508  private javax.swing.JPanel jPanel1;
509  private javax.swing.JScrollPane jScrollPane1;
510  private javax.swing.JSeparator jSeparator2;
511  private javax.swing.JScrollPane modulesScrollPane;
512  private javax.swing.JTable modulesTable;
513  private javax.swing.JButton pastJobsButton;
514  private javax.swing.ButtonGroup timeGroup;
515  // End of variables declaration//GEN-END:variables
516 
522  static private class IngestModuleModel {
523 
525  private IngestModuleGlobalSettingsPanel globalSettingsPanel = null;
526  private IngestModuleIngestJobSettingsPanel moduleSettingsPanel = null;
527 
528  IngestModuleModel(IngestModuleTemplate moduleTemplate) {
529  this.moduleTemplate = moduleTemplate;
530  if (moduleTemplate.hasModuleSettingsPanel()) {
531  moduleSettingsPanel = moduleTemplate.getModuleSettingsPanel();
532  }
533  if (moduleTemplate.hasGlobalSettingsPanel()) {
534  globalSettingsPanel = moduleTemplate.getGlobalSettingsPanel();
535  }
536  }
537 
538  IngestModuleTemplate getIngestModuleTemplate() {
539  return moduleTemplate;
540  }
541 
542  String getName() {
543  return moduleTemplate.getModuleName();
544  }
545 
546  String getDescription() {
547  return moduleTemplate.getModuleDescription();
548  }
549 
550  void setEnabled(boolean enabled) {
551  moduleTemplate.setEnabled(enabled);
552  }
553 
554  boolean isEnabled() {
555  return moduleTemplate.isEnabled();
556  }
557 
558  boolean hasModuleSettingsPanel() {
559  return moduleTemplate.hasModuleSettingsPanel();
560  }
561 
562  IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() {
563  return moduleSettingsPanel;
564  }
565 
566  boolean hasGlobalSettingsPanel() {
567  return moduleTemplate.hasGlobalSettingsPanel();
568  }
569 
570  IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
571  return globalSettingsPanel;
572  }
573 
574  void saveResourcesConfig() {
575  globalSettingsPanel.saveSettings();
576  }
577  }
578 
583  private class IngestModulesTableModel extends AbstractTableModel {
584 
585  private static final long serialVersionUID = 1L;
586 
587  @Override
588  public int getRowCount() {
589  return modules.size();
590  }
591 
592  @Override
593  public int getColumnCount() {
594  return 3;
595  }
596 
597  @Override
598  public Object getValueAt(int rowIndex, int columnIndex) {
599  IngestModuleModel module = modules.get(rowIndex);
600  switch (columnIndex) {
601  case 0:
602  return module.isEnabled();
603  case 1:
604  return getIcon(module);
605  default:
606  return module.getName();
607  }
608  }
609 
610  @Override
611  public boolean isCellEditable(int rowIndex, int columnIndex) {
612  return columnIndex == 0;
613  }
614 
615  @Override
616  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
617  if (columnIndex == 0) {
618  modules.get(rowIndex).setEnabled((boolean) aValue);
619  }
620  }
621 
622  @Override
623  public Class<?> getColumnClass(int c) {
624  return getValueAt(0, c).getClass();
625  }
626 
627  private ImageIcon getIcon(IngestModuleModel module) {
628  if (dataSources.isEmpty() || ingestJobs.isEmpty()) {
629  return null;
630  }
631  boolean previousVersionRun = false;
632  for (IngestJobInfo ingestJob : ingestJobs) {
633  if (ingestJob.getStatus() != IngestJobInfo.IngestJobStatusType.COMPLETED) {
634  continue;
635  }
636  long objectId = ingestJob.getObjectId();
637  boolean isSameDataSource = false;
638  for (Content dataSource : dataSources) {
639  isSameDataSource = isSameDataSource || dataSource.getId() == objectId;
640  }
641  if (isSameDataSource) {
642  IngestModuleFactory factory = module.getIngestModuleTemplate().getModuleFactory();
643  if (factory.isDataSourceIngestModuleFactory()) {
644  String uniqueName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) + "-"
645  + factory.getModuleDisplayName() + "-"
646  + IngestModuleInfo.IngestModuleType.DATA_SOURCE_LEVEL.toString() + "-"
647  + factory.getModuleVersionNumber();
648  for (IngestModuleInfo ingestModuleInfo : ingestJob.getIngestModuleInfo()) {
649  boolean sameModule = ingestModuleInfo.getUniqueName().equals(uniqueName);
650  if (sameModule) {
651  if (ingestModuleInfo.getVersion().equals(module.getIngestModuleTemplate().getModuleFactory().getModuleVersionNumber())) {
652  return warningIcon;
653  }
654  }
655  previousVersionRun = previousVersionRun || sameModule;
656  }
657  }
658  if (factory.isFileIngestModuleFactory()) {
659  String uniqueName = FactoryClassNameNormalizer.normalize(factory.getClass().getCanonicalName()) + "-"
660  + factory.getModuleDisplayName() + "-"
661  + IngestModuleInfo.IngestModuleType.FILE_LEVEL.toString() + "-"
662  + factory.getModuleVersionNumber();
663  for (IngestModuleInfo ingestModuleInfo : ingestJob.getIngestModuleInfo()) {
664  boolean sameModule = ingestModuleInfo.getUniqueName().equals(uniqueName);
665  if (sameModule) {
666  if (ingestModuleInfo.getVersion().equals(module.getIngestModuleTemplate().getModuleFactory().getModuleVersionNumber())) {
667  return warningIcon;
668  }
669  }
670  previousVersionRun = previousVersionRun || sameModule;
671  }
672  }
673  }
674  }
675  if (previousVersionRun) {
676  return infoIcon;
677  }
678  return null;
679  }
680  }
681 
686  @Messages({"IngestJobSettingsPanel.IngestModulesTableRenderer.warning.message=This ingest module has been run before on this data source.",
687  "IngestJobSettingsPanel.IngestModulesTableRenderer.info.message=A previous version of this ingest module has been run before on this data source."})
688  private class IngestModulesTableRenderer extends DefaultTableCellRenderer {
689 
690  private static final long serialVersionUID = 1L;
691 
692  List<String> tooltips = new ArrayList<>();
693 
695  for (IngestModuleModel moduleTemplate : modules) {
696  tooltips.add(moduleTemplate.getDescription());
697  }
698  }
699 
700  @Override
701  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
702  super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
703  if (2 == column) {
704  setIcon(null);
705  setToolTipText(tooltips.get(row));
706  } else if (1 == column) {
707  setIcon((Icon) value);
708  setText("");
709  if (warningIcon.equals(value)) {
710  setToolTipText(Bundle.IngestJobSettingsPanel_IngestModulesTableRenderer_warning_message());
711  } else if (infoIcon.equals(value)) {
712  setToolTipText(Bundle.IngestJobSettingsPanel_IngestModulesTableRenderer_info_message());
713  }
714  }
715  return this;
716  }
717  }
718 }
IngestJobSettingsPanel(IngestJobSettings settings, List< Content > dataSources)
void pastJobsButtonActionPerformed(java.awt.event.ActionEvent evt)
void jButtonSelectAllActionPerformed(java.awt.event.ActionEvent evt)
void setIngestModuleTemplates(List< IngestModuleTemplate > moduleTemplates)
void globalSettingsButtonActionPerformed(java.awt.event.ActionEvent evt)
void fileIngestFilterComboBoxActionPerformed(java.awt.event.ActionEvent evt)
void jButtonDeselectAllActionPerformed(java.awt.event.ActionEvent evt)
List< IngestModuleTemplate > getIngestModuleTemplates()
Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
IngestModuleGlobalSettingsPanel getGlobalSettingsPanel()
void setModuleSettings(IngestModuleIngestJobSettings settings)
IngestModuleIngestJobSettingsPanel getModuleSettingsPanel()

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.