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