use of cbit.vcell.server.SimulationJobStatus.SchedulerStatus in project vcell by virtualcell.
the class SimulationJobsTableModel method getComparator.
public Comparator<SimpleJobStatus> getComparator(final int col, final boolean ascending) {
final int scale = ascending ? 1 : -1;
return new Comparator<SimpleJobStatus>() {
public int compare(SimpleJobStatus o1, SimpleJobStatus o2) {
String s1 = "";
String s2 = "";
switch(col) {
case iColModelApp:
if (o1.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) o1.simulationDocumentLink;
s1 = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
} else if (o1.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) o1.simulationDocumentLink;
s1 = "(MM) " + mml.mathModelName;
}
if (o2.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) o2.simulationDocumentLink;
s2 = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
} else if (o2.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) o2.simulationDocumentLink;
s2 = "(MM) " + mml.mathModelName;
}
return scale * s1.compareToIgnoreCase(s2);
case iColSimulation:
s1 = o1.simulationMetadata.simname;
s2 = o2.simulationMetadata.simname;
if (!s1.equalsIgnoreCase(s2)) {
return scale * s1.compareToIgnoreCase(s2);
} else {
// if same simulation, sort by date
Date d1 = o1.jobStatus.getStartDate();
Date d2 = o2.jobStatus.getStartDate();
return scale * d1.compareTo(d2);
}
case iColSimId:
s1 = o1.simulationMetadata.vcSimID.getSimulationKey().toString() + "," + o1.jobStatus.getJobIndex() + "," + o1.jobStatus.getTaskID();
s2 = o2.simulationMetadata.vcSimID.getSimulationKey().toString() + "," + o2.jobStatus.getJobIndex() + "," + o2.jobStatus.getTaskID();
return scale * s1.compareToIgnoreCase(s2);
case iColSolver:
if (o1.simulationMetadata.solverTaskDesc != null && o1.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
s1 = o1.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
}
if (o2.simulationMetadata.solverTaskDesc != null && o2.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
s2 = o2.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
}
return scale * s1.compareToIgnoreCase(s2);
case iColSubmitDate:
Date d1 = o1.jobStatus.getSubmitDate();
Date d2 = o2.jobStatus.getSubmitDate();
return scale * d1.compareTo(d2);
case iColHasData:
Boolean b1 = o1.jobStatus.hasData();
Boolean b2 = o2.jobStatus.hasData();
return scale * b1.compareTo(b2);
case iColStatus:
SchedulerStatus ss1 = o1.jobStatus.getSchedulerStatus();
SchedulerStatus ss2 = o2.jobStatus.getSchedulerStatus();
return scale * ss1.compareTo(ss2);
case iColMessage:
if (o1.jobStatus != null && o1.jobStatus.getSimulationMessage() != null) {
s1 = o1.jobStatus.getSimulationMessage().getDisplayMessage();
}
if (o2.jobStatus != null && o2.jobStatus.getSimulationMessage() != null) {
s2 = o2.jobStatus.getSimulationMessage().getDisplayMessage();
}
return scale * s1.compareToIgnoreCase(s2);
case iColSite:
s1 = o1.jobStatus.getServerID().toString();
s2 = o2.jobStatus.getServerID().toString();
return scale * s1.compareToIgnoreCase(s2);
default:
return 0;
}
}
};
}
Aggregations