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 WorkflowObjectsTableModel method getValue.
private String getValue(WorkflowObject workflowObject) {
if (workflowObject instanceof Task) {
return "";
} else {
Object data = null;
Class dataType = null;
if (workflowObject instanceof WorkflowDataSource) {
WorkflowDataSource dataHolder = (WorkflowDataSource) workflowObject;
WorkflowDataSource dataSource = taskContext.getWorkflow().getDataSource((DataObject) dataHolder);
data = taskContext.getRepository().getData(dataSource);
dataType = dataHolder.getType();
} else if (workflowObject instanceof DataInput) {
DataInput dataInput = (DataInput) workflowObject;
data = taskContext.getData(dataInput);
dataType = dataInput.getType();
}
if (data instanceof RowColumnResultSet) {
RowColumnResultSet rc = (RowColumnResultSet) data;
int N = rc.getColumnDescriptionsCount();
StringBuffer buffer = new StringBuffer(rc.getRowCount() + " rows of " + N + " {");
int MAX = 3;
for (int i = 0; i < N; i++) {
buffer.append("\"" + rc.getColumnDescriptions(i).getDisplayName() + "\"");
if (i >= MAX - 1) {
buffer.append(", ...");
break;
}
if (i < N - 1) {
buffer.append(", ");
}
}
buffer.append("}");
return buffer.toString();
} else if (data instanceof String) {
return "\"" + (String) data + "\"";
} else if (data instanceof ROI) {
return "ROI \"" + ((ROI) data).getROIName() + "\"";
} else if (data instanceof ROI[]) {
ROI[] rois = (ROI[]) data;
int N = rois.length;
int MAX = 3;
StringBuffer buffer = new StringBuffer("ROI[" + N + "] { ");
for (int i = 0; i < N; i++) {
buffer.append("\"" + rois[i].getROIName() + "\"");
if (i >= MAX - 1) {
buffer.append(", ...");
break;
}
if (i < N - 1) {
buffer.append(", ");
}
}
buffer.append("}");
return buffer.toString();
} else if (data instanceof Image) {
Image image = (Image) data;
return image.getClass().getSimpleName() + " " + image.getISize().toString();
} else if (data instanceof ImageTimeSeries) {
ImageTimeSeries ts = (ImageTimeSeries) data;
int N = ts.getSizeT();
double[] times = ts.getImageTimeStamps();
return ts.getType().getSimpleName() + "[" + N + "] " + ts.getISize() + " times=[" + times[0] + "," + times[N - 1] + "]";
} else if (data != null) {
return data.toString();
} else {
return "null " + dataType.getSimpleName();
}
}
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowObjectsTableModel method setValueAt.
public void setValueAt(Object value, int row, int col) {
if (value == null) {
return;
}
try {
String inputValue = (String) value;
inputValue = inputValue.trim();
WorkflowObject workflowObject = getValueAt(row);
switch(col) {
case COLUMN_VALUE:
{
if (inputValue.length() == 0) {
return;
}
if (workflowObject instanceof WorkflowParameter) {
WorkflowParameter dataHolder = (WorkflowParameter) workflowObject;
Class dataClass = dataHolder.getType();
Repository repository = taskContext.getRepository();
Workflow workflow = taskContext.getWorkflow();
if (dataClass.equals(Double.class)) {
repository.setData(dataHolder, Double.valueOf(inputValue));
workflow.refreshStatus();
} else if (dataClass.equals(Float.class)) {
repository.setData(dataHolder, Float.valueOf(inputValue));
workflow.refreshStatus();
} else if (dataClass.equals(Integer.class)) {
repository.setData(dataHolder, Integer.valueOf(inputValue));
workflow.refreshStatus();
} else if (dataClass.equals(Boolean.class)) {
repository.setData(dataHolder, Boolean.valueOf(inputValue));
workflow.refreshStatus();
} else if (dataClass.equals(String.class)) {
repository.setData(dataHolder, inputValue);
workflow.refreshStatus();
} else {
System.out.println("type " + dataClass.getSimpleName() + " not supported");
}
}
break;
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowObjectsPanel method showButtonPressed.
private void showButtonPressed() {
int[] rows = parametersFunctionsTable.getSelectedRows();
if (rows == null || rows.length == 0) {
return;
}
for (int r : rows) {
if (r < parametersFunctionsTableModel.getRowCount()) {
WorkflowObject workflowObject = parametersFunctionsTableModel.getValueAt(r);
displayData(taskContext, workflowObject);
}
}
}
use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowObjectsPanel method tableSelectionChanged.
protected void tableSelectionChanged() {
int[] rows = parametersFunctionsTable.getSelectedRows();
if (rows == null || rows.length == 0) {
showButton.setEnabled(false);
deleteButton.setEnabled(false);
return;
}
boolean bAllTasks = true;
boolean bAllDisplable = true;
for (int r : rows) {
if (r < parametersFunctionsTableModel.getRowCount()) {
WorkflowObject workflowObject = parametersFunctionsTableModel.getValueAt(r);
if (!(workflowObject instanceof Task)) {
bAllTasks = false;
}
if (!hasDisplayData(taskContext, workflowObject)) {
bAllDisplable = false;
}
}
}
deleteButton.setEnabled(bAllTasks);
showButton.setEnabled(bAllDisplable);
}
Aggregations