mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-11 23:46:15 +00:00
Add AutoIngestJob Comparator, rename Comparators for clarity
This commit is contained in:
parent
8bf3ffe717
commit
80cd65629c
@ -982,7 +982,7 @@ public final class AutoIngestControlPanel extends JPanel implements Observer {
|
||||
List<AutoIngestJob> completedJobs = new ArrayList<>();
|
||||
manager.getJobs(pendingJobs, runningJobs, completedJobs);
|
||||
// Sort the completed jobs list by completed date
|
||||
Collections.sort(completedJobs, new AutoIngestJob.ReverseCompletedDateComparator());
|
||||
Collections.sort(completedJobs, new AutoIngestJob.CompletedDateDescendingComparator());
|
||||
EventQueue.invokeLater(new RefreshComponentsTask(pendingJobs, runningJobs, completedJobs));
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +454,8 @@ public final class AutoIngestDashboard extends JPanel implements Observer {
|
||||
List<AutoIngestJob> runningJobs = jobsSnapshot.getRunningJobs();
|
||||
List<AutoIngestJob> completedJobs = jobsSnapshot.getCompletedJobs();
|
||||
pendingJobs.sort(new AutoIngestJob.PriorityComparator());
|
||||
completedJobs.sort(new AutoIngestJob.ReverseCompletedDateComparator());
|
||||
runningJobs.sort(new AutoIngestJob.DataSourceFileNameComparator());
|
||||
completedJobs.sort(new AutoIngestJob.CompletedDateDescendingComparator());
|
||||
refreshTable(pendingJobs, pendingTable, pendingTableModel);
|
||||
refreshTable(runningJobs, runningTable, runningTableModel);
|
||||
refreshTable(completedJobs, completedTable, completedTableModel);
|
||||
|
@ -502,7 +502,7 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
* Comparator that supports doing a descending sort of jobs based on job
|
||||
* completion date.
|
||||
*/
|
||||
static class ReverseCompletedDateComparator implements Comparator<AutoIngestJob> {
|
||||
static class CompletedDateDescendingComparator implements Comparator<AutoIngestJob> {
|
||||
|
||||
@Override
|
||||
public int compare(AutoIngestJob o1, AutoIngestJob o2) {
|
||||
@ -512,8 +512,7 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator that supports doing a descending sort of jobs based on job
|
||||
* priority.
|
||||
* Comparator that orders jobs in descending order by job priority.
|
||||
*/
|
||||
public static class PriorityComparator implements Comparator<AutoIngestJob> {
|
||||
|
||||
@ -525,17 +524,19 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator that supports doing an alphabetical sort of jobs based on a
|
||||
* combination of case name and processing host.
|
||||
* Comparator that orders jobs such that those running on the local host
|
||||
* appear first, then the remaining jobs are sorted alphabetically by case
|
||||
* name. This is very specific to the auto ionghest control panel use case,
|
||||
* where there is at most one job running on the local host.
|
||||
*/
|
||||
static class CaseNameAndProcessingHostComparator implements Comparator<AutoIngestJob> {
|
||||
static class LocalHostAndCaseComparator implements Comparator<AutoIngestJob> {
|
||||
|
||||
@Override
|
||||
public int compare(AutoIngestJob aJob, AutoIngestJob anotherJob) {
|
||||
if (aJob.getProcessingHostName().equalsIgnoreCase(LOCAL_HOST_NAME)) {
|
||||
return -1; // aJob is for this, float to top
|
||||
return -1;
|
||||
} else if (anotherJob.getProcessingHostName().equalsIgnoreCase(LOCAL_HOST_NAME)) {
|
||||
return 1; // anotherJob is for this, float to top
|
||||
return 1;
|
||||
} else {
|
||||
return aJob.getManifest().getCaseName().compareToIgnoreCase(anotherJob.getManifest().getCaseName());
|
||||
}
|
||||
@ -543,6 +544,18 @@ public final class AutoIngestJob implements Comparable<AutoIngestJob>, Serializa
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator that orders jobs by data source name.
|
||||
*/
|
||||
static class DataSourceFileNameComparator implements Comparator<AutoIngestJob> {
|
||||
|
||||
@Override
|
||||
public int compare(AutoIngestJob aJob, AutoIngestJob anotherJob) {
|
||||
return aJob.getManifest().getDataSourceFileName().compareToIgnoreCase(anotherJob.getManifest().getDataSourceFileName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Processing statuses for an auto ingest job.
|
||||
*/
|
||||
|
@ -468,7 +468,7 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
||||
}
|
||||
for (AutoIngestJob job : hostNamesToRunningJobs.values()) {
|
||||
runningJobs.add(job);
|
||||
runningJobs.sort(new AutoIngestJob.CaseNameAndProcessingHostComparator());
|
||||
runningJobs.sort(new AutoIngestJob.LocalHostAndCaseComparator());
|
||||
}
|
||||
}
|
||||
if (null != completedJobs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user