This commit is contained in:
Karl Mortensen 2015-06-12 16:04:02 -04:00
parent 1829b12f81
commit 0efb6b78f2
3 changed files with 26 additions and 18 deletions

View File

@ -72,9 +72,9 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
@Override
public String getPredicate() throws FilterValidationException {
String addQuery = "";
String query = "NULL";
DateSearchPanel panel = this.getComponent();
// first, get the selected timeZone from the dropdown list
String tz = this.getComponent().getTimeZoneComboBox().getSelectedItem().toString();
String tzID = tz.substring(tz.indexOf(" ") + 1); // 1 index after the space is the ID
@ -92,7 +92,7 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
startDate = Calendar.getInstance(new SimpleTimeZone(0, "GMT")); //NON-NLS
startDate.setTime(temp); // convert to GMT
} catch (ParseException ex) {
// for now, no need to show the error message to the user her
// for now, no need to show the error message to the user here
}
if (!startDateValue.equals("")) {
if (startDate != null) {
@ -120,6 +120,13 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
}
}
// If they put the dates in backwards, help them out.
if (fromDate > toDate) {
long temp = toDate;
toDate = fromDate;
fromDate = temp;
}
final boolean modifiedChecked = panel.getModifiedCheckBox().isSelected();
final boolean changedChecked = panel.getChangedCheckBox().isSelected();
final boolean accessedChecked = panel.getAccessedCheckBox().isSelected();
@ -127,32 +134,27 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
if (modifiedChecked || changedChecked || accessedChecked || createdChecked) {
String subQuery = "";
if (modifiedChecked) {
subQuery += " OR mtime BETWEEN " + fromDate + " AND " + toDate; //NON-NLS
query += " OR (mtime BETWEEN " + fromDate + " AND " + toDate + ")"; //NON-NLS
}
if (changedChecked) {
subQuery += " OR ctime BETWEEN " + fromDate + " AND " + toDate; //NON-NLS
query += " OR (ctime BETWEEN " + fromDate + " AND " + toDate + ")"; //NON-NLS
}
if (accessedChecked) {
subQuery += " OR atime BETWEEN " + fromDate + " AND " + toDate; //NON-NLS
query += " OR (atime BETWEEN " + fromDate + " AND " + toDate + ")"; //NON-NLS
}
if (createdChecked) {
subQuery += " OR crtime BETWEEN " + fromDate + " AND " + toDate; //NON-NLS
}
if (!subQuery.isEmpty()) {
addQuery += " AND (" + subQuery + ")"; //NON-NLS
query += " OR (crtime BETWEEN " + fromDate + " AND " + toDate + ")"; //NON-NLS
}
} else {
throw new FilterValidationException(NONE_SELECTED_MESSAGE);
}
return addQuery;
return query;
}

View File

@ -207,11 +207,17 @@ import org.sleuthkit.datamodel.TskCoreException;
//String query = "SELECT " + tempQuery + " FROM tsk_files WHERE ";
String query = "";
int i=0;
for (FileSearchFilter f : this.getEnabledFilters()) {
String result = f.getPredicate();
if (!result.isEmpty()) {
query += " AND (" + result + ")"; //NON-NLS
if(i>0) {
query += " AND (" + result + ")"; //NON-NLS
}
else {
query += " (" + result + ")"; //NON-NLS
}
++i;
}
}

View File

@ -56,7 +56,7 @@ class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearch
throw new FilterValidationException(NONE_SELECTED_MESSAGE);
}
String expr = "";
String expr = "NULL";
if (unknown) {
expr += " OR " + predicateHelper(FileKnown.UNKNOWN); //NON-NLS
}
@ -75,7 +75,7 @@ class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearch
* @return un-padded SQL boolean expression
*/
private String predicateHelper(FileKnown knownStatus) {
return "known is " + knownStatus.getFileKnownValue(); //NON-NLS
return "known = " + knownStatus.getFileKnownValue(); //NON-NLS
}
@Override