use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class ServerManageConsole method query.
/**
* Insert the method's description here.
* Creation date: (9/3/2003 8:00:07 AM)
*/
private void query() {
boolean bOtherConditions = false;
getRemoveFromListButton().setEnabled(false);
getSubmitSelectedButton().setEnabled(false);
getStopSelectedButton().setEnabled(false);
SimpleJobStatusQuerySpec querySpec = new SimpleJobStatusQuerySpec();
querySpec.maxRows = 1000;
String text = getQuerySimField().getText();
if (text != null && text.trim().length() > 0) {
try {
bOtherConditions = true;
long simID = Long.parseLong(text);
querySpec.simId = simID;
} catch (NumberFormatException ex) {
}
}
text = getQueryHostField().getText();
if (text != null && text.trim().length() > 0) {
bOtherConditions = true;
querySpec.computeHost = text.toLowerCase();
}
text = getQueryServerIDField().getText();
if (text != null && text.trim().length() > 0) {
bOtherConditions = true;
querySpec.serverId = text.toLowerCase();
}
text = getQueryUserField().getText();
if (text != null && text.trim().length() > 0) {
bOtherConditions = true;
querySpec.userid = text;
}
boolean bAllStatus = getQueryAllStatusCheck().isSelected();
querySpec.waiting = bAllStatus || getQueryWaitingCheck().isSelected();
querySpec.queued = bAllStatus || getQueryQueuedCheck().isSelected();
querySpec.dispatched = bAllStatus || getQueryDispatchedCheck().isSelected();
querySpec.running = bAllStatus || getQueryRunningCheck().isSelected();
querySpec.completed = bAllStatus || getQueryCompletedCheck().isSelected();
querySpec.stopped = bAllStatus || getQueryStoppedCheck().isSelected();
querySpec.failed = bAllStatus || getQueryFailedCheck().isSelected();
if (getQuerySubmitDateCheck().isSelected()) {
bOtherConditions = true;
// first second of day low time
querySpec.submitLowMS = getQuerySubmitFromDate().getDate().getTime();
// last second of dat high time
querySpec.submitHighMS = getQuerySubmitToDate().getDate().getTime() + TimeUnit.DAYS.toMillis(1) - 1;
}
if (getQueryStartDateCheck().isSelected()) {
bOtherConditions = true;
// first second of day low time
querySpec.startLowMS = getQueryStartFromDate().getDate().getTime();
// last second of dat high time
querySpec.startHighMS = getQueryStartToDate().getDate().getTime() + TimeUnit.DAYS.toMillis(1) - 1;
}
if (getQueryEndDateCheck().isSelected()) {
bOtherConditions = true;
// first second of day low time
querySpec.endLowMS = getQueryEndFromDate().getDate().getTime();
// last second of dat high time
querySpec.endHighMS = getQueryEndToDate().getDate().getTime() + TimeUnit.DAYS.toMillis(1) - 1;
}
if (getQueryCompletedCheck().isSelected() && !bOtherConditions) {
int n = javax.swing.JOptionPane.showConfirmDialog(this, "You are gonna get all the completed simulation jobs in the database, which is gonna be huge . Continue?", "Confirm", javax.swing.JOptionPane.YES_NO_OPTION);
if (n == javax.swing.JOptionPane.NO_OPTION) {
getNumResultsLabel().setText("0");
getNumSelectedLabel().setText("0");
((JobTableModel) getQueryResultTable().getModel()).setData(null);
return;
}
}
try {
SimulationDatabase simDatabase = new SimulationDatabaseDirect(adminDbTop, dbServerImpl, false);
SimpleJobStatus[] resultList = simDatabase.getSimpleJobStatus(null, querySpec);
getNumResultsLabel().setText("" + resultList.length);
getNumSelectedLabel().setText("0");
((JobTableModel) getQueryResultTable().getModel()).setData(Arrays.asList(resultList));
} catch (Exception ex) {
getNumResultsLabel().setText("Query failed, please try again!");
((JobTableModel) getQueryResultTable().getModel()).setData(null);
}
}
use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class ServerManageConsole method submitSelectedButton_ActionPerformed.
private void submitSelectedButton_ActionPerformed(ActionEvent e) {
int[] srows = getQueryResultTable().getSelectedRows();
if (srows == null || srows.length == 0) {
return;
}
final String SUBMIT_JOBS_OPTION = "submit jobs";
final String CANCEL_OPTION = "cancel";
String response = DialogUtils.showWarningDialog(this, "Are you sure you want to submit " + srows.length + " simulation job(s)? (see console for progress printed to stdout)", new String[] { SUBMIT_JOBS_OPTION, CANCEL_OPTION }, CANCEL_OPTION);
if (response.equals(SUBMIT_JOBS_OPTION)) {
for (int i = 0; i < srows.length; i++) {
int selectedRow = srows[i];
SimpleJobStatus simpleJobStatus = getReturnedSimulationJobStatus(selectedRow);
String statusString = "[" + simpleJobStatus.simulationMetadata.vcSimID + ", " + simpleJobStatus.jobStatus.getSchedulerStatus().getDescription() + "]";
if (simpleJobStatus.jobStatus.getSchedulerStatus().isDone()) {
System.out.println("Submitting job (" + (i + 1) + " of " + srows.length + ") : " + statusString);
resubmitSimulation(simpleJobStatus.simulationMetadata.vcSimID.getOwner().getName(), simpleJobStatus.simulationMetadata.vcSimID.getSimulationKey());
} else {
System.out.println("Submitting job (" + (i + 1) + " of " + srows.length + ") : " + statusString + ", is still running, skipping...");
}
}
}
}
use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.
the class ViewJobsPanel method initialize.
private void initialize() {
try {
setName("ViewSimulationJobsPanel");
// initialize the time button group and its components
getTimeGroup();
// ----------------------------------------------------------------------------------
// filters, buttons
JPanel top = new JPanel();
// table with results
JPanel bottom = new JPanel();
Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
TitledBorder titleTop = BorderFactory.createTitledBorder(loweredEtchedBorder, " User Options ");
titleTop.setTitleJustification(TitledBorder.LEFT);
titleTop.setTitlePosition(TitledBorder.TOP);
TitledBorder titleBottom = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Results ");
titleBottom.setTitleJustification(TitledBorder.LEFT);
titleBottom.setTitlePosition(TitledBorder.TOP);
top.setBorder(titleTop);
bottom.setBorder(titleBottom);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
// top, left, bottom, right
gbc.insets = new Insets(2, 2, 2, 3);
add(top, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
add(bottom, gbc);
// --------------------------------------- top panel (filters, button) --------------
// filters
JPanel left = new JPanel();
TitledBorder titleLeft = BorderFactory.createTitledBorder(loweredEtchedBorder, " Status Filter ");
titleLeft.setTitleJustification(TitledBorder.LEFT);
titleLeft.setTitlePosition(TitledBorder.TOP);
left.setBorder(titleLeft);
JPanel center = new SeparatedJPanel();
// Dimension dim = new Dimension(200, 100);
// center.setMinimumSize(dim);
top.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 1, 3);
top.add(left, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(3, 8, 2, 3);
top.add(getOrphanedButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 8, 2, 3);
top.add(getRefreshAllButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(center, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 3;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.NORTHEAST;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(2, 2, 2, 3);
top.add(getPropertiesPanel(), gbc);
// ------------------------------------ left panel (of top panel) -------------
left.setLayout(new GridBagLayout());
int gridy = 0;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getWaitingButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
JLabel label = new JLabel(waitingIcon);
label.setText(" ");
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 15, 0, 0);
left.add(getQueuedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 10);
label = new JLabel(queuedIcon);
label.setText(" ");
left.add(label, gbc);
// -------------------------------------
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getDispatchedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
label = new JLabel(dispatchedIcon);
label.setText(" ");
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 15, 0, 0);
left.add(getRunningButton(), gbc);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 10);
label = new JLabel(runningIcon);
label.setText(" ");
left.add(label, gbc);
// -------------------------------------
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getCompletedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
label = new JLabel(completedIcon);
label.setText(" ");
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 15, 0, 0);
left.add(getFailedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 10);
label = new JLabel(failedIcon);
label.setText(" ");
left.add(label, gbc);
// -------------------------------------
gridy++;
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 0, 0);
left.add(getStoppedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 0, 0, 3);
label = new JLabel(stoppedIcon);
label.setText(" ");
left.add(label, gbc);
// ---------------------------------------- center panel (of top panel) ------------
center.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 15, 4, 4);
center.add(new JLabel("Max # of results "), gbc);
textFieldJobsLimit = new JTextField();
textFieldJobsLimit.addActionListener(eventHandler);
// textFieldJobsLimit.getDocument().addDocumentListener(eventHandler);
textFieldJobsLimit.setText(maxRows + "");
Dimension d = textFieldJobsLimit.getPreferredSize();
d.width = 60;
textFieldJobsLimit.setPreferredSize(d);
textFieldJobsLimit.setMaximumSize(d);
textFieldJobsLimit.setMinimumSize(d);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 0, 4, 4);
center.add(textFieldJobsLimit, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 11, 2, 4);
center.add(getSubmitDatePanel(), gbc);
getCompletedButton().setSelected(false);
getDispatchedButton().setSelected(true);
getFailedButton().setSelected(true);
getQueuedButton().setSelected(true);
getRunningButton().setSelected(true);
getStoppedButton().setSelected(true);
getWaitingButton().setSelected(true);
getOrphanedButton().setSelected(false);
getPastMonthRadio().setSelected(true);
// ----------------------------------------- bottom panel (the table) -------------------
table = new EditorScrollTable();
model = new SimulationJobsTableModel(table, this);
table.setModel(model);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
table.addMouseMotionListener(new // add toolTipText for each table cell
MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p);
table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
}
});
bottom.setLayout(new GridBagLayout());
gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
// table.setPreferredScrollableViewportSize(new Dimension(700,350)); // apparently useless
bottom.add(table.getEnclosingScrollPane(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 4, 4, 4);
bottom.add(new JLabel("Search "), gbc);
textFieldSearch = new JTextField(70);
textFieldSearch.addActionListener(eventHandler);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
bottom.add(textFieldSearch, gbc);
// gbc = new GridBagConstraints();
// gbc.gridx = 4;
// gbc.gridy = gridy;
// gbc.fill = GridBagConstraints.HORIZONTAL;
// gbc.insets = new Insets(4, 4, 4, 10);
// bottom.add(getShowQuotaButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
bottom.add(countLabel, gbc);
// renderer for the status icon; the tooltip gives the text
DefaultScrollTableCellRenderer statusCellRenderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus js = (SimpleJobStatus) selectedObject;
SchedulerStatus ss1 = js.jobStatus.getSchedulerStatus();
switch(ss1) {
case WAITING:
setIcon(waitingIcon);
break;
case QUEUED:
setIcon(queuedIcon);
break;
case DISPATCHED:
setIcon(dispatchedIcon);
break;
case RUNNING:
setIcon(runningIcon);
break;
case COMPLETED:
setIcon(completedIcon);
break;
case STOPPED:
setIcon(stoppedIcon);
break;
case FAILED:
setIcon(failedIcon);
break;
default:
setIcon(failedIcon);
break;
}
// setText("");
setToolTipText(ss1.getDescription());
setHorizontalTextPosition(SwingConstants.RIGHT);
}
}
return this;
}
};
// statusCellRenderer.setHorizontalAlignment(JLabel.RIGHT);
DefaultScrollTableCellRenderer dateTimeCellRenderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
DateFormat df = new SimpleDateFormat("MM.dd.yyyy HH:MM:SS");
Date date = sjs.jobStatus.getSubmitDate();
String str = "";
if (date != null) {
str = df.format(date);
}
setToolTipText(str);
}
}
return this;
}
};
DefaultScrollTableCellRenderer hasDataCellRenderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
if (sjs.jobStatus.hasData()) {
setIcon(dataYesIcon);
} else {
setIcon(dataNoIcon);
}
}
}
return this;
}
};
table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setCellRenderer(statusCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColSubmitDate).setCellRenderer(dateTimeCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColHasData).setCellRenderer(hasDataCellRenderer);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColDepiction).setMinWidth(400);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setPreferredWidth(30);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setMaxWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
refreshInterface();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
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();
Date date = sjs.jobStatus.getSubmitDate();
if (date != null) {
return df.format(date);
}
return null;
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 RestDatabaseService method query.
public SimpleJobStatus[] query(SimulationTasksServerResource 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(SimulationTasksServerResource.PARAM_SIM_ID);
simQuerySpec.jobId = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_JOB_ID);
simQuerySpec.taskId = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_TASK_ID);
simQuerySpec.computeHost = resource.getQueryValue(SimulationTasksServerResource.PARAM_COMPUTE_HOST);
simQuerySpec.serverId = resource.getQueryValue(SimulationTasksServerResource.PARAM_SERVER_ID);
String hasData = resource.getQueryValue(SimulationTasksServerResource.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(SimulationTasksServerResource.PARAM_STATUS_WAITING, false);
simQuerySpec.queued = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_QUEUED, false);
simQuerySpec.dispatched = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_DISPATCHED, false);
simQuerySpec.running = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_RUNNING, false);
simQuerySpec.completed = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_COMPLETED, false);
simQuerySpec.failed = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_FAILED, false);
simQuerySpec.stopped = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_STOPPED, false);
simQuerySpec.submitLowMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_SUBMIT_LOW);
simQuerySpec.submitHighMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_SUBMIT_HIGH);
simQuerySpec.startLowMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_START_LOW);
simQuerySpec.startHighMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_START_HIGH);
simQuerySpec.endLowMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_END_LOW);
simQuerySpec.endHighMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_END_HIGH);
Long startRowParam = resource.getLongQueryValue(SimulationTasksServerResource.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();
}
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);
return simpleJobStatusArray;
} finally {
rpcSession.close();
}
}
Aggregations