use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowJGraphProxy method addCells.
private void addCells(mxEventObject event) {
try {
// remove an existing connection
Object[] cells = (Object[]) event.getProperty("cells");
// add tasks first
for (Object cellObject : cells) {
if (cellObject instanceof WorkflowObjectCell) {
WorkflowObjectCell cell = (WorkflowObjectCell) cellObject;
if (!cell.isEdge()) {
// don't know how to add an object through an event yet ...
WorkflowObject addedTask = cell.workflowObject;
if (cell.workflowObject instanceof Task) {
Task task = (Task) cell.workflowObject;
task.setName(context.getWorkflow().getNextAvailableTaskName(task.getName()));
context.getWorkflow().addTask((Task) cell.workflowObject);
cell.setId(cell.workflowObject.getName());
cell.setGraph(graph);
} else {
// not a task, not an edge, and not already added ... can't handle this now
System.err.println("can't handle this now ... non-edge cell (id=" + cell.getId() + ") added to jGraphX but not already added to workflow");
}
}
}
}
// add edges next
for (Object cellObject : cells) {
if (cellObject instanceof mxCell) {
mxCell cell = (mxCell) cellObject;
if (cell.isEdge()) {
mxICell source = cell.getSource();
mxICell target = cell.getTarget();
if ((source instanceof WorkflowObjectCell) && (target instanceof WorkflowObjectCell)) {
String validationError = validateConnection(source, target);
if (validationError == null) {
WorkflowObject workflowSourceObject = ((WorkflowObjectCell) source).workflowObject;
WorkflowObject workflowTargetObject = ((WorkflowObjectCell) target).workflowObject;
if (workflowSourceObject instanceof DataOutput && workflowTargetObject instanceof DataInput) {
DataInput input = (DataInput) workflowTargetObject;
if (context.getWorkflow().getConnectorSource(input) != null) {
System.out.println("don't add this connection, a connection already exists");
} else {
DataOutput output = (DataOutput) workflowSourceObject;
context.getWorkflow().connect2(output, input);
System.out.println("added edge from " + workflowSourceObject.getPath() + " to " + workflowTargetObject.getPath());
}
}
} else {
System.out.println("didn't connect, " + validationError);
}
}
}
}
}
} finally {
context.getWorkflow().refreshStatus();
}
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowJGraphProxy method validateConnection.
private String validateConnection(mxICell source, mxICell target) {
try {
if (!(source instanceof WorkflowObjectCell) || !(target instanceof WorkflowObjectCell)) {
return "source or target is null";
}
WorkflowObject workflowSourceObject = ((WorkflowObjectCell) source).workflowObject;
WorkflowObject workflowTargetObject = ((WorkflowObjectCell) target).workflowObject;
if (workflowSourceObject instanceof DataOutput && workflowTargetObject instanceof DataInput) {
DataInput input = (DataInput) workflowTargetObject;
Type inputClass = input.getType();
if (context.getWorkflow().getConnectorSource(input) != null) {
return "don't add this connection, a connection already exists";
} else {
DataOutput output = (DataOutput) workflowSourceObject;
Type outputClass = output.getType();
if (outputClass.getClass().isAssignableFrom(inputClass.getClass())) {
return null;
} else {
return "can't connect " + workflowSourceObject.getPath() + " of type " + outputClass + "\n to " + workflowTargetObject.getPath() + " of type " + inputClass;
}
}
} else {
return "unknown source or desintation type";
}
} catch (Exception e) {
e.printStackTrace();
return "error validating edge: exception: " + e.getMessage();
} finally {
context.getWorkflow().refreshStatus();
}
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowObjectsPanel method hasDisplayData.
private boolean hasDisplayData(TaskContext taskContext, WorkflowObject workflowObject) {
if (workflowObject instanceof DataInput || workflowObject instanceof DataOutput) {
String title = parametersFunctionsTableModel.getName(workflowObject);
WindowListener listener = new WindowAdapter() {
};
Object data = null;
if (workflowObject instanceof WorkflowDataSource) {
WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
data = taskContext.getRepository().getData(dataHolder);
} else if (workflowObject instanceof DataInput) {
DataInput dataInput = (DataInput) workflowObject;
data = taskContext.getData(dataInput);
}
if (data instanceof RowColumnResultSet || data instanceof ROI || data instanceof ProfileData[] || data instanceof Image || data instanceof ImageTimeSeries) {
return true;
}
}
return false;
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowObjectsPanel method displayData.
private void displayData(TaskContext taskContext, WorkflowObject workflowObject) {
if (workflowObject instanceof DataInput || workflowObject instanceof DataOutput) {
String title = parametersFunctionsTableModel.getName(workflowObject);
WindowListener listener = new WindowAdapter() {
};
Object data = null;
if (workflowObject instanceof WorkflowDataSource) {
WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
data = taskContext.getRepository().getData(dataHolder);
} else if (workflowObject instanceof DataInput) {
DataInput dataInput = (DataInput) workflowObject;
data = taskContext.getData(dataInput);
}
if (data instanceof RowColumnResultSet) {
RowColumnResultSet rc = (RowColumnResultSet) data;
try {
new DisplayPlotOp().displayPlot(rc, title, listener);
} catch (ExpressionException e) {
e.printStackTrace();
}
} else if (data instanceof ROI) {
ROI roi = (ROI) data;
Image image = roi.getRoiImages()[0];
new DisplayImageOp().displayImage(image, title, listener);
} else if (data instanceof ProfileData[]) {
ProfileData[] profileData = (ProfileData[]) data;
new DisplayProfileLikelihoodPlotsOp().displayProfileLikelihoodPlots(profileData, title, listener);
} else if (data instanceof Image) {
Image image = (Image) data;
new DisplayImageOp().displayImage(image, title, listener);
} else if (data instanceof ImageTimeSeries) {
ImageTimeSeries imageTimeSeries = (ImageTimeSeries) data;
try {
DisplayTimeSeries.displayImageTimeSeries(imageTimeSeries, title, listener);
} catch (ImageException | IOException e) {
e.printStackTrace();
}
}
}
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowObjectsTableModel method computeData.
/**
* Insert the method's description here.
* Creation date: (9/23/2003 1:24:52 PM)
* @return cbit.vcell.model.Parameter
* @param row int
*/
protected List<WorkflowObject> computeData() {
ArrayList<WorkflowObject> allWorkflowObjectList = new ArrayList<WorkflowObject>();
if (taskContext == null) {
return null;
}
Workflow workflow = taskContext.getWorkflow();
if (bTasks) {
allWorkflowObjectList.addAll(workflow.getTasks());
}
if (bParameters) {
allWorkflowObjectList.addAll(workflow.getParameters());
}
if (bTaskInputs) {
for (Task task : workflow.getTasks()) {
allWorkflowObjectList.addAll(task.getInputs());
}
}
if (bTaskOutputs) {
for (Task task : workflow.getTasks()) {
allWorkflowObjectList.addAll(task.getOutputs());
}
}
boolean bSearchInactive = searchText == null || searchText.length() == 0;
String lowerCaseSearchText = bSearchInactive ? null : searchText.toLowerCase();
ArrayList<WorkflowObject> workflowObjectList = new ArrayList<WorkflowObject>();
for (WorkflowObject workflowObject : allWorkflowObjectList) {
if (bSearchInactive || getValue(workflowObject).toLowerCase().contains(lowerCaseSearchText) || getName(workflowObject).toLowerCase().contains(lowerCaseSearchText) || getType(workflowObject).toLowerCase().contains(lowerCaseSearchText) || getStatus(taskContext, workflowObject).toLowerCase().contains(lowerCaseSearchText)) {
workflowObjectList.add(workflowObject);
}
}
return workflowObjectList;
}
Aggregations