use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class TFGenerateReport method run.
/**
* Insert the method's description here.
* Creation date: (11/17/2004 2:08:09 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) throws Exception {
ClientTaskStatusSupport pp = getClientTaskStatusSupport();
String report = (String) hashTable.get(TFRefresh.TF_REPORT);
if (report == null) {
report = "";
}
// tfwm.updateSimRunningStatus(pp);
if (tcrit != null && tcn != null) {
if (userDefinedRegrRef != null) {
report += tfwm.generateTestCaseReport(tcn, tcrit, pp, userDefinedRegrRef);
} else {
report += tfwm.generateTestCaseReport(tcn, tcrit, pp, null);
}
} else if (tcn != null) {
report += tfwm.generateTestCaseReport(tcn, null, pp, null);
} else if (tsin != null) {
report += tfwm.generateTestSuiteReport(tsin, pp);
}
if (report != null && report.length() > 0) {
hashTable.put(TFRefresh.TF_REPORT, report);
}
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class TFRunSims method run.
/**
* Insert the method's description here.
* Creation date: (11/17/2004 2:08:09 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) {
ClientTaskStatusSupport pp = getClientTaskStatusSupport();
String errors = (String) hashTable.get(TFRefresh.TF_ERRORS);
if (errors == null) {
errors = "";
}
String error = "";
if (tcrit != null) {
error = tfwm.startSimulations(new TestCriteriaNew[] { tcrit }, pp);
} else if (tcn != null) {
error = tfwm.startSimulations(tcn.getTestCriterias(), pp);
} else if (tsin != null) {
error = tfwm.startTestSuiteSimulations(tsin, pp);
}
errors += (error == null ? "" : error);
if (errors != null && errors.length() > 0) {
hashTable.put(TFRefresh.TF_ERRORS, errors);
}
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class BioModelsNetJPanel method searchImport.
private void searchImport() {
AsynchClientTask searchTask = new AsynchClientTask("Search BioModels", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Hashtable<String, String> vcellCompatibleBioModels_ID_Name_Hash = readVCellCompatibleBioModels_ID_Name_Hash();
ClientTaskStatusSupport clientTaskStatusSupport = getClientTaskStatusSupport();
// clientTaskStatusSupport.setProgress(0);
clientTaskStatusSupport.setMessage("Initializing BioModels Search...");
BioModelsWebServicesServiceLocator bioModelsWebServicesServiceLocator = new BioModelsWebServicesServiceLocator();
BioModelsWebServices bioModelsWebServices = bioModelsWebServicesServiceLocator.getBioModelsWebServices();
// clientTaskStatusSupport.setProgress(10);
clientTaskStatusSupport.setMessage("Executing BioModels Search...");
TreeSet<String> modelIDsMergedSearch = new TreeSet<String>();
boolean bHasModelEntryID = modelEntryIDTextField.getText() != null && modelEntryIDTextField.getText().length() > 0;
if (bHasModelEntryID) {
clientTaskStatusSupport.setMessage("Executing BioModels Search (Model ID matches)...");
// String[] modelIDsAll = bioModelsWebServices.getAllModelsId();
String[] modelIDsAll = vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0]);
for (int i = 0; i < modelIDsAll.length; i++) {
if (modelIDsAll[i].toUpperCase().indexOf(modelEntryIDTextField.getText().toUpperCase()) != -1) {
modelIDsMergedSearch.add(modelIDsAll[i]);
}
}
}
boolean bHasModelName = modelNameTextField.getText() != null && modelNameTextField.getText().length() > 0;
if (bHasModelName) {
clientTaskStatusSupport.setMessage("Executing BioModels Search (Model Name matches)...");
TreeSet<String> modelIDsByNameSet = new TreeSet<String>();
// String[] modelIDsByName = bioModelsWebServices.getModelsIdByName(modelNameTextField.getText());
String[] modelIDsAll = vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0]);
for (int i = 0; i < modelIDsAll.length; i++) {
if (vcellCompatibleBioModels_ID_Name_Hash.get(modelIDsAll[i]).toUpperCase().indexOf(modelNameTextField.getText().toUpperCase()) != -1) {
modelIDsByNameSet.add(modelIDsAll[i]);
}
}
// }
if (bHasModelEntryID) {
// intersection
modelIDsMergedSearch.retainAll(modelIDsByNameSet);
} else {
modelIDsMergedSearch = modelIDsByNameSet;
}
}
boolean bHasModelPublication = publicationTextField.getText() != null && publicationTextField.getText().length() > 0;
if (bHasModelPublication) {
clientTaskStatusSupport.setMessage("Executing BioModels Search (Publication matches)...");
TreeSet<String> modelIDsByPublicationSet = new TreeSet<String>();
String[] modelIDsbyPublication = bioModelsWebServices.getModelsIdByPublication(publicationTextField.getText());
for (int i = 0; i < modelIDsbyPublication.length; i++) {
modelIDsByPublicationSet.add(modelIDsbyPublication[i]);
}
if (bHasModelEntryID || bHasModelName) {
// intersection
modelIDsMergedSearch.retainAll(modelIDsByPublicationSet);
} else {
modelIDsMergedSearch = modelIDsByPublicationSet;
}
}
if (!(bHasModelEntryID || bHasModelName || bHasModelPublication)) {
// Get all models
// modelIDsMergedSearch.addAll(Arrays.asList(bioModelsWebServices.getAllModelsId()));
modelIDsMergedSearch.addAll(Arrays.asList(vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0])));
}
// clientTaskStatusSupport.setProgress(COLLECTION_PROGRESS);
if (modelIDsMergedSearch.size() > 0) {
// Intersect with supported BioModel IDs
modelIDsMergedSearch.retainAll(Arrays.asList(vcellCompatibleBioModels_ID_Name_Hash.keySet().toArray(new String[0])));
clientTaskStatusSupport.setMessage("Found " + modelIDsMergedSearch.size() + " VCell compatible BioModels");
String[] modelIDMergedSearchArr = modelIDsMergedSearch.toArray(new String[0]);
TreeMap<String, String> model_ID_Name_Map = new TreeMap<String, String>();
String nameNotfound = "NameNotFound_0";
for (int i = 0; i < modelIDMergedSearchArr.length; i++) {
if (clientTaskStatusSupport.isInterrupted()) {
// DialogUtils.showWarningDialog(BioModelsNetJPanel.this, "Search Cancelled");
throw UserCancelException.CANCEL_GENERIC;
}
try {
// clientTaskStatusSupport.setMessage("Retrieving "+modelIDMergedSearchArr[i]+" "+(i+1)+" of "+modelIDMergedSearchArr.length);
// String modelName = bioModelsWebServices.getModelNameById(modelIDMergedSearchArr[i]);
String modelName = vcellCompatibleBioModels_ID_Name_Hash.get(modelIDMergedSearchArr[i]);
// Assume model names are unique
model_ID_Name_Map.put(modelName, modelIDMergedSearchArr[i]);
} catch (Exception e) {
// For some reason Web Service API sometimes throws java.util.NoSuchElementException
// if id exists but name can't be found.
e.printStackTrace();
model_ID_Name_Map.put(nameNotfound, modelIDMergedSearchArr[i]);
nameNotfound = TokenMangler.getNextEnumeratedToken(nameNotfound);
}
}
// Make name,id rowdata for tablelist to allow user selection
String[] sortedModelNames = model_ID_Name_Map.keySet().toArray(new String[0]);
final String[][] rowData = new String[sortedModelNames.length][2];
for (int i = 0; i < sortedModelNames.length; i++) {
rowData[i][0] = sortedModelNames[i];
rowData[i][1] = model_ID_Name_Map.get(sortedModelNames[i]);
}
// Allow user to select model for opening
final String importNow = "Import";
final String cancel = "Cancel";
DialogUtils.TableListResult result = DialogUtils.showComponentOptionsTableList(BioModelsNetJPanel.this, "Select a BioModel to import", new String[] { "Model Names", "BioModels Entry ID" }, rowData, ListSelectionModel.SINGLE_SELECTION, null, new String[] { importNow, cancel }, importNow, new Comparator<Object>() {
public int compare(Object o1, Object o2) {
if (o1 instanceof String && o2 instanceof String) {
return ((String) o1).compareTo((String) o2);
}
throw new RuntimeException("row data should only be String");
}
});
if (result.selectedOption != null && result.selectedOption.equals(importNow)) {
// Close Dialog showing "this" panel so ProgressPopup not obscured during openDocument
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
disposeParentDialog();
}
});
closeClientTaskStatusSupport(clientTaskStatusSupport);
// Download and open (in new window) SBML document selected by user
String bioModelSBML = bioModelsWebServices.getModelSBMLById(rowData[result.selectedTableRows[0]][1]);
final ExternalDocInfo externalDocInfo = new ExternalDocInfo(bioModelSBML, sortedModelNames[result.selectedTableRows[0]]);
new Thread(new Runnable() {
public void run() {
documentWindow.getTopLevelWindowManager().getRequestManager().openDocument(externalDocInfo, documentWindow.getTopLevelWindowManager(), true);
}
}).start();
}
} else {
closeClientTaskStatusSupport(clientTaskStatusSupport);
DialogUtils.showWarningDialog(BioModelsNetJPanel.this, "No BioModels found matching current search criteria.");
throw UserCancelException.CANCEL_GENERIC;
}
}
};
ClientTaskDispatcher.dispatch(BioModelsNetJPanel.this, new Hashtable<String, Object>(), new AsynchClientTask[] { searchTask }, true, true, null, true);
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class BioformatsImageDatasetReader method runpb.
// mkdir bioformatsJarTempDir
// cd bioformatsJarTempDir
// ls -1 /home/vcell/workspace_biofthrift/vcell-bioformats/target/dependency/* | xargs -n 1 jar xf
// ls -1 /home/vcell/workspace_biofthrift/vcell-bioformats/target/vcell-bioformats-0.0.4.jar | xargs -n 1 jar xf
// rm -rf META-INF
// mkdir META-INF
// echo -e "Manifest-Version: 1.0\nMain-Class: org.vcell.bioformats.BioFormatsImageDatasetReaderFrm\n"
// jar cf mynewbiof.jar .
private String runpb(ArrayList<String> cmdList, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
// DEBUGGING CODE
// final Exception[] excHolder = new Exception[1];
// System.out.println("\n--cmd begin--");
// Arrays.stream(cmdList.toArray()).map(s->s+" ").forEach(System.out::print);
// System.out.println("\n--cmd end--");
// final PrintStream origstdout = System.out;
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// PrintStream newps = new PrintStream(baos) {
// @Override
// public void println(String x) {
// try {
// baos.write(x.getBytes());
// origstdout.println(x.substring(0, Math.min(x.length()-1, 400)));
// detectException(x);
// detectMessage(clientTaskStatusSupport, x);
// }catch (Exception e) {
// excHolder[0] = e;
// }
// }
// };
// try {
// System.setOut(newps);
// BioFormatsImageDatasetReaderFrm.main(cmdList.toArray(new String[0]));
// String output = baos.toString();
// if(excHolder[0] != null) {
// throw excHolder[0];
// }
// output = output.substring(output.indexOf(BIOF_XML_START_DELIM)+BIOF_XML_START_DELIM.length()+1, output.indexOf(BIOF_XML_END_DELIM));
// if(true) {return output;}
// }finally {
// System.setOut(origstdout);
// }
cmdList.add(0, ResourceUtil.getVCellJava());
cmdList.add(1, "-jar");
cmdList.add(2, // new File("/home/vcell/workspace_biofthrift/vcell-bioformats/target/vcell-bioformats-0.0.4.jar").getAbsolutePath()+":"+
ResourceUtil.getBioFormatsExecutableJarFile().getAbsolutePath());
// cmdList.add(3,"org.vcell.bioformats.BioFormatsImageDatasetReaderFrm");//Main class name in vcell-bioformats project
ProcessBuilder pb = new ProcessBuilder(cmdList);
// out and err in one stream
pb.redirectErrorStream(true);
System.out.println("\n--cmd begin--");
Arrays.stream(pb.command().toArray()).map(s -> s + " ").forEach(System.out::print);
System.out.println("\n--cmd end--");
final Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
detectMessage(clientTaskStatusSupport, line);
detectException(line);
}
p.waitFor(5, TimeUnit.SECONDS);
return sb.substring(sb.indexOf(BIOF_XML_START_DELIM) + BIOF_XML_START_DELIM.length(), sb.indexOf(BIOF_XML_END_DELIM));
}
use of org.vcell.util.ClientTaskStatusSupport in project vcell by virtualcell.
the class WorkflowJGraphProxy method workflowRun.
public void workflowRun() throws Exception {
ClientTaskStatusSupport progress = new ClientTaskStatusSupport() {
String message = "";
int progress = 0;
@Override
public void setProgress(int progress) {
this.progress = progress;
}
@Override
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean isInterrupted() {
return false;
}
@Override
public int getProgress() {
return progress;
}
@Override
public void addProgressDialogListener(ProgressDialogListener progressDialogListener) {
}
};
context.getWorkflow().compute(context, progress);
}
Aggregations