Autopsy  4.19.1
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 
56  void setSelectedDataSource(long dataSourceId) {
57  this.getComponent().setDataSourceSelected(dataSourceId);
58  }
59 
63  void resetDataSourceFilter() {
64  this.getComponent().resetDataSourcePanel();
65  }
66 
67  @Override
68  public String getPredicate() throws FilterValidationException {
69  String predicate = "";
70  for (Long dataSourceObjId : this.getComponent().getDataSourcesSelected()) {
71  if (!predicate.isEmpty()) {
72  predicate += " OR ";
73  }
74  predicate += "data_source_obj_id = '" + dataSourceObjId + "'";
75  }
76  return predicate;
77  }
78 
79  @Override
80  public void addActionListener(ActionListener lis) {
81  //Unused by now
82  }
83 
84  @Override
85  @Messages({
86  "DataSourceFilter.errorMessage.emptyDataSource=At least one data source must be selected."
87  })
88  public boolean isValid() {
89  if (this.getComponent().getDataSourcesSelected().isEmpty()) {
90  setLastError(Bundle.DataSourceFilter_errorMessage_emptyDataSource());
91  return false;
92  }
93  return true;
94  }
95 }

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