use of org.vcell.workflow.DataInput 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.DataInput 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.DataInput 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.DataInput 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.DataInput in project vcell by virtualcell.
the class WorkflowObjectsTableModel method propertyChange.
@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
super.propertyChange(evt);
if (evt.getSource() instanceof WorkflowObject) {
int changeRow = getRowIndex((WorkflowObject) evt.getSource());
if (changeRow >= 0) {
fireTableRowsUpdated(changeRow, changeRow);
}
} else {
String propertyName = evt.getPropertyName();
if (evt.getSource() == taskContext.getWorkflow()) {
if (propertyName.equals(Workflow.PROPERTY_NAME_PARAMETERS)) {
WorkflowParameter[] oldValue = (WorkflowParameter[]) evt.getOldValue();
if (oldValue != null) {
for (WorkflowParameter parameter : oldValue) {
parameter.removePropertyChangeListener(this);
}
}
WorkflowParameter[] newValue = (WorkflowParameter[]) evt.getNewValue();
if (newValue != null) {
for (WorkflowParameter parameter : newValue) {
parameter.addPropertyChangeListener(this);
}
}
refreshData();
} else if (propertyName.equals(Workflow.PROPERTY_NAME_TASKS)) {
Task[] oldValue = (Task[]) evt.getOldValue();
if (oldValue != null) {
for (Task task : oldValue) {
task.removePropertyChangeListener(this);
for (DataInput dataInput : task.getInputs()) {
dataInput.removePropertyChangeListener(this);
}
for (DataOutput dataOutput : task.getOutputs()) {
dataOutput.removePropertyChangeListener(this);
}
}
}
Task[] newValue = (Task[]) evt.getNewValue();
if (newValue != null) {
for (Task task : newValue) {
task.addPropertyChangeListener(this);
for (DataInput dataInput : task.getInputs()) {
dataInput.addPropertyChangeListener(this);
}
for (DataOutput dataOutput : task.getOutputs()) {
dataOutput.addPropertyChangeListener(this);
}
}
}
refreshData();
}
}
}
}
Aggregations