Autopsy  4.4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataContentViewerOtherCasesTableModel.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2017 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.centralrepository.contentviewer;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.table.AbstractTableModel;
24 import org.openide.util.NbBundle.Messages;
27 
31 public class DataContentViewerOtherCasesTableModel extends AbstractTableModel {
32 
33  @Messages({"DataContentViewerOtherCasesTableModel.case=Case",
34  "DataContentViewerOtherCasesTableModel.device=Device",
35  "DataContentViewerOtherCasesTableModel.dataSource=Data Source",
36  "DataContentViewerOtherCasesTableModel.path=Path",
37  "DataContentViewerOtherCasesTableModel.type=Correlation Type",
38  "DataContentViewerOtherCasesTableModel.value=Correlation Value",
39  "DataContentViewerOtherCasesTableModel.scope=Scope",
40  "DataContentViewerOtherCasesTableModel.known=Known",
41  "DataContentViewerOtherCasesTableModel.comment=Comment",
42  "DataContentViewerOtherCasesTableModel.noData=No Data.",})
43  enum TableColumns {
44  // Ordering here determines displayed column order in Content Viewer.
45  CASE_NAME(Bundle.DataContentViewerOtherCasesTableModel_case(), 75),
46  DATA_SOURCE(Bundle.DataContentViewerOtherCasesTableModel_dataSource(), 75),
47  TYPE(Bundle.DataContentViewerOtherCasesTableModel_type(), 40),
48  VALUE(Bundle.DataContentViewerOtherCasesTableModel_value(), 145),
49  KNOWN(Bundle.DataContentViewerOtherCasesTableModel_known(), 45),
50  SCOPE(Bundle.DataContentViewerOtherCasesTableModel_scope(), 20),
51  COMMENT(Bundle.DataContentViewerOtherCasesTableModel_comment(), 200),
52  FILE_PATH(Bundle.DataContentViewerOtherCasesTableModel_path(), 250),
53  DEVICE(Bundle.DataContentViewerOtherCasesTableModel_device(), 145);
54 
55  private final String columnName;
56  private final int columnWidth;
57 
58  TableColumns(String columnName, int columnWidth) {
59  this.columnName = columnName;
60  this.columnWidth = columnWidth;
61  }
62 
63  public String columnName() {
64  return columnName;
65  }
66 
67  public int columnWidth() {
68  return columnWidth;
69  }
70  };
71 
72  List<CorrelationAttribute> eamArtifacts;
73 
75  eamArtifacts = new ArrayList<>();
76  }
77 
78  @Override
79  public int getColumnCount() {
80  return TableColumns.values().length;
81  }
82 
93  public int getColumnPreferredWidth(int colIdx) {
94  return TableColumns.values()[colIdx].columnWidth();
95  }
96 
97  @Override
98  public int getRowCount() {
99  return eamArtifacts.size();
100  }
101 
102  @Override
103  public String getColumnName(int colIdx) {
104  return TableColumns.values()[colIdx].columnName();
105  }
106 
107  @Override
108  public Object getValueAt(int rowIdx, int colIdx) {
109  if (0 == eamArtifacts.size()) {
110  return Bundle.DataContentViewerOtherCasesTableModel_noData();
111  }
112 
113  return mapValueById(rowIdx, TableColumns.values()[colIdx]);
114  }
115 
116  public Object getRow(int rowIdx) {
117  return eamArtifacts.get(rowIdx);
118  }
119 
128  private Object mapValueById(int rowIdx, TableColumns colId) {
129  CorrelationAttribute eamArtifact = eamArtifacts.get(rowIdx);
130  CorrelationAttributeInstance eamArtifactInstance = eamArtifact.getInstances().get(0);
131  String value = Bundle.DataContentViewerOtherCasesTableModel_noData();
132 
133  switch (colId) {
134  case CASE_NAME:
135  if (null != eamArtifactInstance.getCorrelationCase()) {
136  value = eamArtifactInstance.getCorrelationCase().getDisplayName();
137  }
138  break;
139  case DEVICE:
140  if (null != eamArtifactInstance.getCorrelationDataSource()) {
141  value = eamArtifactInstance.getCorrelationDataSource().getDeviceID();
142  }
143  break;
144  case DATA_SOURCE:
145  if (null != eamArtifactInstance.getCorrelationDataSource()) {
146  value = eamArtifactInstance.getCorrelationDataSource().getName();
147  }
148  break;
149  case FILE_PATH:
150  value = eamArtifactInstance.getFilePath();
151  break;
152  case TYPE:
153  value = eamArtifact.getCorrelationType().getDisplayName();
154  break;
155  case VALUE:
156  value = eamArtifact.getCorrelationValue();
157  break;
158  case SCOPE:
159  value = eamArtifactInstance.getGlobalStatus().toString();
160  break;
161  case KNOWN:
162  value = eamArtifactInstance.getKnownStatus().getName();
163  break;
164  case COMMENT:
165  value = eamArtifactInstance.getComment();
166  break;
167  }
168  return value;
169  }
170 
171  @Override
172  public Class<String> getColumnClass(int colIdx) {
173  return String.class;
174  }
175 
182  public void addEamArtifact(CorrelationAttribute eamArtifact) {
183  eamArtifacts.add(eamArtifact);
184  fireTableDataChanged();
185  }
186 
187  public void clearTable() {
188  eamArtifacts.clear();
189  fireTableDataChanged();
190  }
191 
192 }

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.