use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class RestDatabaseService method query.
public SimulationStatusRepresentation[] query(SimulationStatusServerResource resource, User vcellUser) throws SQLException, DataAccessException {
if (vcellUser == null) {
vcellUser = VCellApiApplication.DUMMY_USER;
}
String userID = vcellUser.getName();
SimpleJobStatusQuerySpec simQuerySpec = new SimpleJobStatusQuerySpec();
simQuerySpec.userid = userID;
simQuerySpec.simId = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SIM_ID);
String hasData = resource.getQueryValue(SimulationStatusServerResource.PARAM_HAS_DATA);
if (hasData != null && hasData.equals("yes")) {
simQuerySpec.hasData = true;
} else if (hasData != null && hasData.equals("no")) {
simQuerySpec.hasData = false;
} else {
simQuerySpec.hasData = null;
}
simQuerySpec.waiting = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.queued = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.dispatched = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.running = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.completed = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_COMPLETED, false);
simQuerySpec.failed = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_FAILED, false);
simQuerySpec.stopped = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_STOPPED, false);
simQuerySpec.submitLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SUBMIT_LOW);
simQuerySpec.submitHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SUBMIT_HIGH);
simQuerySpec.startLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_LOW);
simQuerySpec.startHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_HIGH);
simQuerySpec.endLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_END_LOW);
simQuerySpec.endHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_END_HIGH);
Long startRowParam = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_ROW);
// default
simQuerySpec.startRow = 1;
if (startRowParam != null) {
simQuerySpec.startRow = startRowParam.intValue();
}
Long maxRowsParam = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_MAX_ROWS);
// default
simQuerySpec.maxRows = 10;
if (maxRowsParam != null) {
simQuerySpec.maxRows = maxRowsParam.intValue();
}
SimulationStatus[] simStatuses = null;
HashMap<KeyValue, SimulationDocumentLink> simDocLinks = new HashMap<KeyValue, SimulationDocumentLink>();
//
// ask server for simJobStatuses with above query spec.
// find set of simulation IDs from the result set of simJobStatus
// ask server for simulationStatuses from list of sim IDs.
//
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
SimpleJobStatus[] simpleJobStatusArray = rpcSimServerProxy.getSimpleJobStatus(vcellUser, simQuerySpec);
// gather unique simIDs and go back and ask server for SimulationStatuses
for (SimpleJobStatus simpleJobStatus : simpleJobStatusArray) {
KeyValue simulationKey = simpleJobStatus.jobStatus.getVCSimulationIdentifier().getSimulationKey();
SimulationDocumentLink simulationDocumentLink = simpleJobStatus.simulationDocumentLink;
simDocLinks.put(simulationKey, simulationDocumentLink);
}
KeyValue[] simKeys = simDocLinks.keySet().toArray(new KeyValue[0]);
if (simKeys.length > 0) {
simStatuses = rpcSimServerProxy.getSimulationStatus(vcellUser, simKeys);
}
} finally {
rpcSession.close();
}
ArrayList<SimulationStatusRepresentation> simStatusReps = new ArrayList<SimulationStatusRepresentation>();
for (int i = 0; simStatuses != null && i < simStatuses.length; i++) {
KeyValue simulationKey = simStatuses[i].getVCSimulationIdentifier().getSimulationKey();
SimulationRep simRep = getSimulationRep(simulationKey);
try {
SimulationRepresentation simRepresentation = new SimulationRepresentation(simRep, simDocLinks.get(simulationKey));
simStatusReps.add(new SimulationStatusRepresentation(simRepresentation, simStatuses[i]));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
}
}
return simStatusReps.toArray(new SimulationStatusRepresentation[0]);
}
use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class SimulationJobsTableModel method getValueAt.
@Override
public Object getValueAt(int iRow, int iCol) {
SimpleJobStatus sjs = getValueAt(iRow);
if (sjs == null) {
return null;
}
switch(iCol) {
case iColModelApp:
if (sjs.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) sjs.simulationDocumentLink;
return "(BM) " + bml.bioModelName + ", (App) " + bml.simContextName;
} else if (sjs.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) sjs.simulationDocumentLink;
return "(MM) " + mml.mathModelName;
} else {
return null;
}
case iColSimulation:
return sjs.simulationMetadata.simname;
case iColSimId:
return sjs.simulationMetadata.vcSimID.getSimulationKey().toString() + " / " + sjs.jobStatus.getJobIndex() + " / " + sjs.jobStatus.getTaskID();
case iColSolver:
String str = "";
if (sjs.simulationMetadata.solverTaskDesc != null) {
str = sjs.simulationMetadata.solverTaskDesc.getSolverDescription() == null ? "" : sjs.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
}
return str;
case iColSubmitDate:
DateFormat df = new SimpleDateFormat("MM.dd.yyyy");
Date date = sjs.jobStatus.getStartDate();
return df.format(date);
case iColHasData:
return sjs.jobStatus.hasData() == true ? "Yes" : "No";
case iColStatus:
return sjs.jobStatus.getSchedulerStatus().getDescription();
case iColMessage:
return sjs.jobStatus.getSimulationMessage().getDisplayMessage();
case iColSite:
return sjs.jobStatus.getServerID().toString();
// return sjs.jobStatus.getComputeHost();
default:
return null;
}
}
use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method translateToSimpleJobStatusTransient.
private SimpleJobStatus translateToSimpleJobStatusTransient(SimpleJobStatusPersistent simpleJobStatusPersistent, SimulationJobStatus cachedSimulationJobStatus, StateInfo cachedStateInfo) {
SimulationJobStatus simJobStatus = null;
if (cachedSimulationJobStatus != null) {
simJobStatus = cachedSimulationJobStatus;
} else {
simJobStatus = translateToSimulationJobStatusTransient(simpleJobStatusPersistent.jobStatus);
}
SimpleJobStatus simpleJobStatus = new SimpleJobStatus(simpleJobStatusPersistent.simulationMetadata, simpleJobStatusPersistent.simulationDocumentLink, simJobStatus, cachedStateInfo);
return simpleJobStatus;
}
use of cbit.vcell.server.SimpleJobStatus 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;
}
}
};
}
use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class SimulationJobsTableModel method refreshData.
public void refreshData() {
List<SimpleJobStatus> allJobStatusList = new ArrayList<>();
for (SimpleJobStatus sjj : jobStatusArray) {
allJobStatusList.add(sjj);
}
// ----- apply filters that are not applied by running the query -----------------
List<SimpleJobStatus> filteredJobStatusList = new ArrayList<>();
if (owner.getOrphanedButton().isSelected()) {
// if checked, hide orphans
for (SimpleJobStatus sjj : allJobStatusList) {
if (sjj.simulationDocumentLink != null) {
filteredJobStatusList.add(sjj);
}
}
} else {
filteredJobStatusList = allJobStatusList;
}
// ------- apply search --------------------------------------------------------------------
List<SimpleJobStatus> jobStatusList = new ArrayList<>();
if (searchText == null || searchText.length() == 0) {
jobStatusList.addAll(filteredJobStatusList);
} else {
String lowerCaseSearchText = searchText.toLowerCase();
for (SimpleJobStatus sjs : filteredJobStatusList) {
// search in Solver column
if (sjs.simulationMetadata.solverTaskDesc != null && sjs.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
String str = sjs.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
if (str != null && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
}
// search in Message column
if (sjs.jobStatus != null && sjs.jobStatus.getSimulationMessage() != null) {
String str = sjs.jobStatus.getSimulationMessage().getDisplayMessage();
if (str != null && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
}
// search in Model name, Application name (if available)
String str = null;
if (sjs.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) sjs.simulationDocumentLink;
str = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
} else if (sjs.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) sjs.simulationDocumentLink;
str = "(MM) " + mml.mathModelName;
}
if (str != null && !str.isEmpty() && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
// Search in Simulation name
str = sjs.simulationMetadata.simname;
if (str != null && !str.isEmpty() && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
}
}
setData(jobStatusList);
GuiUtils.flexResizeTableColumns(ownerTable);
}
Aggregations