Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
PastCasesPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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.datasourcesummary.ui;
20 
21 import java.util.Arrays;
22 import java.util.List;
23 import java.util.function.Function;
24 import org.apache.commons.lang3.tuple.Pair;
25 import org.openide.util.NbBundle.Messages;
37 import org.sleuthkit.datamodel.DataSource;
38 
43 @Messages({
44  "PastCasesPanel_caseColumn_title=Case",
45  "PastCasesPanel_countColumn_title=Count",
46  "PastCasesPanel_onNoCrIngest_message=No results will be shown because the Central Repository module was not run."
47 })
48 public class PastCasesPanel extends BaseDataSourceSummaryPanel {
49 
50  private static final long serialVersionUID = 1L;
51  private static final String CR_FACTORY = CentralRepoIngestModuleFactory.class.getName();
52  private static final String CR_NAME = CentralRepoIngestModuleFactory.getModuleName();
53 
54  private static final ColumnModel<Pair<String, Long>> CASE_COL = new ColumnModel<>(
55  Bundle.PastCasesPanel_caseColumn_title(),
56  (pair) -> new DefaultCellModel(pair.getKey()),
57  300
58  );
59 
60  private static final ColumnModel<Pair<String, Long>> COUNT_COL = new ColumnModel<>(
61  Bundle.PastCasesPanel_countColumn_title(),
62  (pair) -> new DefaultCellModel(String.valueOf(pair.getValue())),
63  100
64  );
65 
66  private static final List<ColumnModel<Pair<String, Long>>> DEFAULT_COLUMNS = Arrays.asList(CASE_COL, COUNT_COL);
67 
68  private final JTablePanel<Pair<String, Long>> notableFileTable = JTablePanel.getJTablePanel(DEFAULT_COLUMNS);
69 
70  private final JTablePanel<Pair<String, Long>> sameIdTable = JTablePanel.getJTablePanel(DEFAULT_COLUMNS);
71 
72  private final List<JTablePanel<?>> tables = Arrays.asList(
73  notableFileTable,
74  sameIdTable
75  );
76 
77  private final List<DataFetchComponents<DataSource, ?>> dataFetchComponents;
78 
79  private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
80 
81  public PastCasesPanel() {
82  this(new PastCasesSummary());
83  }
84 
88  public PastCasesPanel(PastCasesSummary pastCaseData) {
89  // set up data acquisition methods
90  dataFetchComponents = Arrays.asList(
92  (dataSource) -> pastCaseData.getPastCasesData(dataSource),
93  (result) -> handleResult(result))
94  );
95 
96  initComponents();
97  }
98 
106  showResultWithModuleCheck(notableFileTable, getSubResult(result, (res) -> res.getTaggedNotable()), CR_FACTORY, CR_NAME);
107  showResultWithModuleCheck(sameIdTable, getSubResult(result, (res) -> res.getSameIdsResults()), CR_FACTORY, CR_NAME);
108  }
109 
122  private <O> DataFetchResult<O> getSubResult(DataFetchResult<PastCasesResult> inputResult, Function<PastCasesResult, O> getSubResult) {
123  if (inputResult == null) {
124  return null;
125  } else if (inputResult.getResultType() == ResultType.SUCCESS) {
126  O innerData = (inputResult.getData() == null) ? null : getSubResult.apply(inputResult.getData());
127  return DataFetchResult.getSuccessResult(innerData);
128  } else {
129  return DataFetchResult.getErrorResult(inputResult.getException());
130  }
131  }
132 
133  @Override
134  protected void fetchInformation(DataSource dataSource) {
135  fetchInformation(dataFetchComponents, dataSource);
136  }
137 
138  @Override
139  protected void onNewDataSource(DataSource dataSource) {
140  onNewDataSource(dataFetchComponents, tables, dataSource);
141  }
142 
143  @Override
144  public void close() {
145  ingestRunningLabel.unregister();
146  super.close();
147  }
148 
154  @SuppressWarnings("unchecked")
155  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
156  private void initComponents() {
157 
158  javax.swing.JScrollPane mainScrollPane = new javax.swing.JScrollPane();
159  javax.swing.JPanel mainContentPanel = new javax.swing.JPanel();
160  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
161  javax.swing.JLabel notableFileLabel = new javax.swing.JLabel();
162  javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
163  javax.swing.JPanel notableFilePanel = notableFileTable;
164  javax.swing.Box.Filler filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
165  javax.swing.JLabel sameIdLabel = new javax.swing.JLabel();
166  javax.swing.Box.Filler filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
167  javax.swing.JPanel sameIdPanel = sameIdTable;
168  javax.swing.Box.Filler filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
169 
170  mainContentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
171  mainContentPanel.setLayout(new javax.swing.BoxLayout(mainContentPanel, javax.swing.BoxLayout.PAGE_AXIS));
172 
173  ingestRunningPanel.setAlignmentX(0.0F);
174  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
175  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
176  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
177  mainContentPanel.add(ingestRunningPanel);
178 
179  org.openide.awt.Mnemonics.setLocalizedText(notableFileLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
180  mainContentPanel.add(notableFileLabel);
181  notableFileLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
182 
183  filler1.setAlignmentX(0.0F);
184  mainContentPanel.add(filler1);
185 
186  notableFilePanel.setAlignmentX(0.0F);
187  notableFilePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
188  notableFilePanel.setMinimumSize(new java.awt.Dimension(100, 106));
189  notableFilePanel.setPreferredSize(new java.awt.Dimension(100, 106));
190  mainContentPanel.add(notableFilePanel);
191 
192  filler2.setAlignmentX(0.0F);
193  mainContentPanel.add(filler2);
194 
195  org.openide.awt.Mnemonics.setLocalizedText(sameIdLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.sameIdLabel.text")); // NOI18N
196  mainContentPanel.add(sameIdLabel);
197 
198  filler3.setAlignmentX(0.0F);
199  mainContentPanel.add(filler3);
200 
201  sameIdPanel.setAlignmentX(0.0F);
202  sameIdPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
203  sameIdPanel.setMinimumSize(new java.awt.Dimension(100, 106));
204  sameIdPanel.setPreferredSize(new java.awt.Dimension(100, 106));
205  mainContentPanel.add(sameIdPanel);
206 
207  filler5.setAlignmentX(0.0F);
208  mainContentPanel.add(filler5);
209 
210  mainScrollPane.setViewportView(mainContentPanel);
211 
212  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
213  this.setLayout(layout);
214  layout.setHorizontalGroup(
215  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
216  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
217  );
218  layout.setVerticalGroup(
219  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
220  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
221  );
222  }// </editor-fold>//GEN-END:initComponents
223 
224 
225  // Variables declaration - do not modify//GEN-BEGIN:variables
226  // End of variables declaration//GEN-END:variables
227 }
void handleResult(DataFetchResult< PastCasesResult > result)
static< T > JTablePanel< T > getJTablePanel(List< ColumnModel< T >> columns)
final List< DataFetchComponents< DataSource,?> > dataFetchComponents
static< R > DataFetchResult< R > getSuccessResult(R data)

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