Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018-2021 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.filesearch;
20 
21 import java.awt.event.ActionListener;
22 import org.openide.util.NbBundle.Messages;
23 
27 class DataSourceFilter extends AbstractFileSearchFilter<DataSourcePanel> {
28 
34  DataSourceFilter(DataSourcePanel component) {
35  super(component);
36  }
37 
42  DataSourceFilter() {
43  this(new DataSourcePanel());
44  }
45 
46  @Override
47  public boolean isEnabled() {
48  return this.getComponent().isSelected();
49  }
50 
54  void resetDataSourceFilter() {
55  this.getComponent().resetDataSourcePanel();
56  }
57 
58  @Override
59  public String getPredicate() throws FilterValidationException {
60  String predicate = "";
61  for (Long dataSourceObjId : this.getComponent().getDataSourcesSelected()) {
62  if (!predicate.isEmpty()) {
63  predicate += " OR ";
64  }
65  predicate += "data_source_obj_id = '" + dataSourceObjId + "'";
66  }
67  return predicate;
68  }
69 
70  @Override
71  public void addActionListener(ActionListener lis) {
72  //Unused by now
73  }
74 
75  @Override
76  @Messages({
77  "DataSourceFilter.errorMessage.emptyDataSource=At least one data source must be selected."
78  })
79  public boolean isValid() {
80  if (this.getComponent().getDataSourcesSelected().isEmpty()) {
81  setLastError(Bundle.DataSourceFilter_errorMessage_emptyDataSource());
82  return false;
83  }
84  return true;
85  }
86 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.