mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +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<>();
|
List<AutoIngestJob> completedJobs = new ArrayList<>();
|
||||||
manager.getJobs(pendingJobs, runningJobs, completedJobs);
|
manager.getJobs(pendingJobs, runningJobs, completedJobs);
|
||||||
// Sort the completed jobs list by completed date
|
// 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));
|
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> runningJobs = jobsSnapshot.getRunningJobs();
|
||||||
List<AutoIngestJob> completedJobs = jobsSnapshot.getCompletedJobs();
|
List<AutoIngestJob> completedJobs = jobsSnapshot.getCompletedJobs();
|
||||||
pendingJobs.sort(new AutoIngestJob.PriorityComparator());
|
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(pendingJobs, pendingTable, pendingTableModel);
|
||||||
refreshTable(runningJobs, runningTable, runningTableModel);
|
refreshTable(runningJobs, runningTable, runningTableModel);
|
||||||
refreshTable(completedJobs, completedTable, completedTableModel);
|
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
|
* Comparator that supports doing a descending sort of jobs based on job
|
||||||
* completion date.
|
* completion date.
|
||||||
*/
|
*/
|
||||||
static class ReverseCompletedDateComparator implements Comparator<AutoIngestJob> {
|
static class CompletedDateDescendingComparator implements Comparator<AutoIngestJob> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(AutoIngestJob o1, AutoIngestJob o2) {
|
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
|
* Comparator that orders jobs in descending order by job priority.
|
||||||
* priority.
|
|
||||||
*/
|
*/
|
||||||
public static class PriorityComparator implements Comparator<AutoIngestJob> {
|
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
|
* Comparator that orders jobs such that those running on the local host
|
||||||
* combination of case name and processing 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
|
@Override
|
||||||
public int compare(AutoIngestJob aJob, AutoIngestJob anotherJob) {
|
public int compare(AutoIngestJob aJob, AutoIngestJob anotherJob) {
|
||||||
if (aJob.getProcessingHostName().equalsIgnoreCase(LOCAL_HOST_NAME)) {
|
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)) {
|
} else if (anotherJob.getProcessingHostName().equalsIgnoreCase(LOCAL_HOST_NAME)) {
|
||||||
return 1; // anotherJob is for this, float to top
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return aJob.getManifest().getCaseName().compareToIgnoreCase(anotherJob.getManifest().getCaseName());
|
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.
|
* Processing statuses for an auto ingest job.
|
||||||
*/
|
*/
|
||||||
|
@ -468,7 +468,7 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
|||||||
}
|
}
|
||||||
for (AutoIngestJob job : hostNamesToRunningJobs.values()) {
|
for (AutoIngestJob job : hostNamesToRunningJobs.values()) {
|
||||||
runningJobs.add(job);
|
runningJobs.add(job);
|
||||||
runningJobs.sort(new AutoIngestJob.CaseNameAndProcessingHostComparator());
|
runningJobs.sort(new AutoIngestJob.LocalHostAndCaseComparator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != completedJobs) {
|
if (null != completedJobs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user